From 46c9fa90be212a74419a3762cf54ab57193f2939 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Sat, 30 May 2015 20:54:03 +0300 Subject: [PATCH] Fix query editor for work with templated variables. --- zabbix/datasource.js | 7 +- zabbix/partials/query.editor.html | 2 +- zabbix/queryCtrl.js | 106 ++++++++++-------------------- 3 files changed, 41 insertions(+), 74 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index 33a8f4b..af924a2 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -49,7 +49,7 @@ function (angular, _, kbn) { name: target.alias }]; return this.performTimeSeriesQuery(item, from, to).then(_.partial( - this.handleZabbixAPIResponse, alias)); + this.handleHistoryResponse, alias)); } else { // Handle templated target @@ -73,13 +73,14 @@ function (angular, _, kbn) { var self = this; return $q.all(_.map(hosts, function (hostname) { if (hosts.length > 1) { + // Select the host that the item belongs for multiple hosts request var selectHosts = true; } return this.findZabbixItem(hostname, itemnames, selectHosts); }, this)).then(function (items) { items = _.flatten(items); return self.performTimeSeriesQuery(items, from, to) - .then(_.partial(self.handleZabbixAPIResponse, items)); + .then(_.partial(self.handleHistoryResponse, items)); }); } else { return []; @@ -127,7 +128,7 @@ function (angular, _, kbn) { // Convert Zabbix API data to Grafana format - ZabbixAPIDatasource.prototype.handleZabbixAPIResponse = function(items, response) { + ZabbixAPIDatasource.prototype.handleHistoryResponse = function(items, response) { /** * Response should be in the format: * data: [ diff --git a/zabbix/partials/query.editor.html b/zabbix/partials/query.editor.html index ba6b5fb..05d969d 100644 --- a/zabbix/partials/query.editor.html +++ b/zabbix/partials/query.editor.html @@ -59,7 +59,7 @@ ng-change="selectHostGroup()" ng-model="target.hostGroup" bs-tooltip="target.hostGroup.name.length > 25 ? target.hostGroup.name : ''" - ng-options="hostgroup.name for hostgroup in metric.hostGroupList" > + ng-options="hostgroup.name for hostgroup in metric.groupList" >