From 330d90053fe8f07525d85366a319628b5bab599e Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 14 May 2015 23:50:36 +0300 Subject: [PATCH 1/2] Fix #8 and #10 issues. Remove timeseries reduce (not working properly). --- zabbix/datasource.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index ad4ccc0eb..f95c9e87b 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -39,14 +39,14 @@ function (angular, _, kbn) { // Need for find target alias var targets = options.targets; - // TODO: remove undefined targets from request - // Check that all targets defined - var targetsDefined = options.targets.every(function (target, index, array) { - return target.item; + // Remove undefined and hidden targets + var displayedTargets = _.filter(targets, function (target) { + return (!target.hide && target.item); }); - if (targetsDefined) { + + if (displayedTargets.length) { // Extract zabbix api item objects from targets - var target_items = _.map(options.targets, 'item'); + var target_items = _.map(displayedTargets, 'item'); } else { // No valid targets, return the empty dataset var d = $q.defer(); @@ -75,13 +75,15 @@ function (angular, _, kbn) { // Index returned datapoints by item/metric id var indexed_result = _.groupBy(response, 'itemid'); + // TODO: realize correct timeseries reduce + /* // Reduce timeseries to the same size for stacking and tooltip work properly var min_length = _.min(_.map(indexed_result, function (history) { return history.length; })); _.each(indexed_result, function (item) { item.splice(0, item.length - min_length); - }); + });*/ // Sort result as the same as targets for display // stacked timeseries in proper order @@ -120,7 +122,7 @@ function (angular, _, kbn) { // Request data from Zabbix API - ZabbixAPIDatasource.prototype.doZabbixAPIRequest = function(request_data) { + ZabbixAPIDatasource.prototype.performZabbixAPIRequest = function(request_data) { var options = { method: 'POST', headers: { @@ -192,7 +194,7 @@ function (angular, _, kbn) { data.params.time_till = end; } - apiRequests.push(self.doZabbixAPIRequest(data)); + apiRequests.push(self.performZabbixAPIRequest(data)); }); return this.handleMultipleRequest(apiRequests); @@ -265,7 +267,7 @@ function (angular, _, kbn) { id: 1 }; - return this.doZabbixAPIRequest(data); + return this.performZabbixAPIRequest(data); }; @@ -285,7 +287,7 @@ function (angular, _, kbn) { data.params.groupids = groupid; } - return this.doZabbixAPIRequest(data); + return this.performZabbixAPIRequest(data); }; @@ -303,7 +305,7 @@ function (angular, _, kbn) { id: 1 }; - return this.doZabbixAPIRequest(data); + return this.performZabbixAPIRequest(data); }; @@ -329,7 +331,7 @@ function (angular, _, kbn) { data.params.applicationids = applicationid; } - return this.doZabbixAPIRequest(data); + return this.performZabbixAPIRequest(data); }; From bdae2d6e5ec96b4a5ac2d8e92521529c8ce2083a Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 14 May 2015 23:57:36 +0300 Subject: [PATCH 2/2] Fix #7 issue. --- zabbix/queryCtrl.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/zabbix/queryCtrl.js b/zabbix/queryCtrl.js index e367f4937..e64432c2a 100644 --- a/zabbix/queryCtrl.js +++ b/zabbix/queryCtrl.js @@ -65,17 +65,18 @@ function (angular, _) { // Call when host selected $scope.selectHost = function() { + if ($scope.target.host) { + // Update item list + if ($scope.target.application) { + $scope.updateItemList($scope.target.host.hostid, $scope.target.application.applicationid); + } else { + $scope.updateItemList($scope.target.host.hostid, null); + } - // Update item list - if ($scope.target.application) { - $scope.updateItemList($scope.target.host.hostid, $scope.target.application.applicationid); - } else { - $scope.updateItemList($scope.target.host.hostid, null); + // Update application list + $scope.updateAppList($scope.target.host.hostid); } - // Update application list - $scope.updateAppList($scope.target.host.hostid); - $scope.target.errors = validateTarget($scope.target); if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) { $scope.oldTarget = angular.copy($scope.target);