From cdf9437e7561f0a3489d64d031260c541594a49b Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 9 Jun 2015 12:39:12 +0300 Subject: [PATCH] Compact updateItemList() function. --- zabbix/datasource.js | 2 +- zabbix/queryCtrl.js | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index cc8d95c..2be6941 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -2,7 +2,7 @@ define([ 'angular', 'lodash', 'kbn', - './queryCtrl', + './queryCtrl' ], function (angular, _, kbn) { 'use strict'; diff --git a/zabbix/queryCtrl.js b/zabbix/queryCtrl.js index e166d96..ce9f52d 100644 --- a/zabbix/queryCtrl.js +++ b/zabbix/queryCtrl.js @@ -182,17 +182,12 @@ function (angular, _) { var apps = $scope.target.application ? splitMetrics(templateSrv.replace($scope.target.application.name)) : undefined; $scope.datasource.itemFindQuery(groups, hosts, apps).then(function (items) { // Show only unique item names - var uniq_items = _.uniq(items, function (item) { + var uniq_items = _.map(_.uniq(items, function (item) { return expandItemName(item); + }), function (item) { + return {name: expandItemName(item)} }); $scope.metric.itemList = $scope.metric.itemList.concat(uniq_items); - - // Expand item parameters - $scope.metric.itemList.forEach(function (item, index, array) { - if (item && item.key_ && item.name) { - item.name = expandItemName(item); - } - }); }); };