diff --git a/plugins/datasource-zabbix/queryCtrl.js b/plugins/datasource-zabbix/queryCtrl.js index faa02a1..33d744e 100644 --- a/plugins/datasource-zabbix/queryCtrl.js +++ b/plugins/datasource-zabbix/queryCtrl.js @@ -34,7 +34,7 @@ define([ return metricFunctions.createFuncInstance(func.def, func.params); }); - if ($scope.target.mode ===0 || + if ($scope.target.mode === 0 || $scope.target.mode === 2) { $scope.downsampleFunctionList = [ @@ -83,11 +83,12 @@ define([ }; $scope.getMetricsFromCache = function () { + var item_type = $scope.editorModes[$scope.target.mode]; $scope.metric = { groupList: zabbixCache.getGroups(), hostList: zabbixCache.getHosts(), applicationList: zabbixCache.getApplications(), - itemList: zabbixCache.getItems() + itemList: zabbixCache.getItems(item_type) }; }; @@ -305,6 +306,12 @@ define([ $scope.functionChanged = function() {}; + $scope.editorModes = { + 0: 'num', + 1: 'itservice', + 2: 'text' + }; + /** * Switch query editor to specified mode. * Modes: diff --git a/plugins/datasource-zabbix/zabbixCache.js b/plugins/datasource-zabbix/zabbixCache.js index ad1c9ce..57405cc 100644 --- a/plugins/datasource-zabbix/zabbixCache.js +++ b/plugins/datasource-zabbix/zabbixCache.js @@ -60,8 +60,22 @@ function (angular, _, utils) { return this._applications; }; - p.getItems = function() { - return this._items; + p.getItems = function(type) { + switch (type) { + case 'num': + return _.filter(this._items, function(item) { + return (item.value_type === '0' || + item.value_type === '3'); + }); + case 'text': + return _.filter(this._items, function(item) { + return (item.value_type === '1' || + item.value_type === '2' || + item.value_type === '4'); + }); + default: + return this._items; + } }; p.getHost = function(hostid) {