From bd60d2e264cc4af80efe2bc677a3b915f84693c8 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Sat, 16 Jan 2016 22:53:40 +0300 Subject: [PATCH] Show only unique values and expand item names in bs-typeahead. --- plugins/datasource-zabbix/queryCtrl.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/datasource-zabbix/queryCtrl.js b/plugins/datasource-zabbix/queryCtrl.js index 68c286a..adb00b3 100644 --- a/plugins/datasource-zabbix/queryCtrl.js +++ b/plugins/datasource-zabbix/queryCtrl.js @@ -73,14 +73,20 @@ define([ // Get list of metric names for bs-typeahead directive function getMetricNames(scope, metricList) { - return _.map(scope.metric[metricList], 'name'); + return _.uniq(_.map(scope.metric[metricList], 'name')); } // Map functions $scope.getGroupNames = _.partial(getMetricNames, $scope, 'groupList'); $scope.getHostNames = _.partial(getMetricNames, $scope, 'hostList'); $scope.getApplicationNames = _.partial(getMetricNames, $scope, 'applicationList'); - $scope.getItemNames = _.partial(getMetricNames, $scope, 'itemList'); + + $scope.getItemNames = function () { + var expandedItems = _.map($scope.metric.itemList, function (item) { + return zabbixHelperSrv.expandItemName(item); + }); + return _.uniq(expandedItems); + }; /** * Switch query editor to specified mode.