From 051438e48a83b9dd0dadfdf9eebae4e89060c313 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 18 Jan 2016 20:54:30 +0300 Subject: [PATCH] Refresh data when target was changed. --- .../partials/query.editor.html | 2 +- plugins/datasource-zabbix/queryCtrl.js | 30 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/plugins/datasource-zabbix/partials/query.editor.html b/plugins/datasource-zabbix/partials/query.editor.html index 6206b58..a65af2e 100644 --- a/plugins/datasource-zabbix/partials/query.editor.html +++ b/plugins/datasource-zabbix/partials/query.editor.html @@ -160,7 +160,7 @@ ng-model="target.item.filter" bs-typeahead="getItemNames" ng-change="onTargetPartChange(target.item)" - ng-blur="parseTarget()" + ng-blur="onItemBlur()" data-min-length=0 data-items=100 class="input-large tight-form-input" diff --git a/plugins/datasource-zabbix/queryCtrl.js b/plugins/datasource-zabbix/queryCtrl.js index a81291b..6d05da9 100644 --- a/plugins/datasource-zabbix/queryCtrl.js +++ b/plugins/datasource-zabbix/queryCtrl.js @@ -55,8 +55,6 @@ define([ $scope.itserviceList = [{name: "test"}]; $scope.updateITServiceList(); } - - $scope.target.errors = validateTarget($scope.target); }; $scope.initFilters = function () { @@ -189,22 +187,36 @@ define([ // Handle group blur and filter hosts $scope.onGroupBlur = function() { $scope.metric.filteredHosts = $scope.filterHosts(); + $scope.parseTarget(); + $scope.get_data(); }; // Handle host blur and filter applications $scope.onHostBlur = function() { $scope.metric.filteredApplications = $scope.filterApplications(); + $scope.parseTarget(); + $scope.get_data(); }; // Handle application blur and filter items $scope.onApplicationBlur = function() { $scope.metric.filteredItems = $scope.filterItems(); + $scope.parseTarget(); + $scope.get_data(); + }; + + $scope.onItemBlur = function () { + $scope.parseTarget(); + $scope.get_data(); }; $scope.parseTarget = function() { // Parse target }; + // Validate target and set validation info + $scope.validateTarget = function () {}; + /** * Switch query editor to specified mode. * Modes: @@ -228,7 +240,6 @@ define([ $scope.targetBlur = function () { setItemAlias(); - $scope.target.errors = validateTarget($scope.target); if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) { $scope.oldTarget = angular.copy($scope.target); $scope.get_data(); @@ -239,7 +250,6 @@ define([ * Call when IT service is selected. */ $scope.selectITService = function () { - $scope.target.errors = validateTarget($scope.target); if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) { $scope.oldTarget = angular.copy($scope.target); $scope.get_data(); @@ -279,18 +289,6 @@ define([ }); } - ////////////////////////////// - // VALIDATION - ////////////////////////////// - - function validateTarget(target) { - var errs = {}; - if (!target) { - errs = 'Not defined'; - } - return errs; - } - $scope.init(); });