From 3b85901b9590208b923efef931fc1c9544777b62 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Fri, 13 May 2016 16:29:11 +0900 Subject: [PATCH 1/2] reflect panel repeat status when variable updated --- public/app/features/templating/templateValuesSrv.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index d44f07ed366..0efc5eb468c 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -8,7 +8,7 @@ function (angular, _, kbn) { var module = angular.module('grafana.services'); - module.service('templateValuesSrv', function($q, $rootScope, datasourceSrv, $location, templateSrv, timeSrv) { + module.service('templateValuesSrv', function($q, $rootScope, datasourceSrv, $location, templateSrv, timeSrv, dynamicDashboardSrv) { var self = this; function getNoneOption() { return { text: 'None', value: '', isNone: true }; } @@ -27,7 +27,12 @@ function (angular, _, kbn) { .filter(function(variable) { return variable.refresh === 2; }).map(function(variable) { - return self.updateOptions(variable); + return self.updateOptions(variable).then(function () { + return self.variableUpdated(variable).then(function () { + dynamicDashboardSrv.update(self.dashboard); + $rootScope.$emit('template-variable-value-updated'); + }); + }); }); return $q.all(promises); @@ -35,6 +40,7 @@ function (angular, _, kbn) { }, $rootScope); this.init = function(dashboard) { + this.dashboard = dashboard; this.variables = dashboard.templating.list; templateSrv.init(this.variables); @@ -143,7 +149,7 @@ function (angular, _, kbn) { this.variableUpdated = function(variable) { templateSrv.updateTemplateData(); - return this.updateOptionsInChildVariables(variable); + return self.updateOptionsInChildVariables(variable); }; this.updateOptionsInChildVariables = function(updatedVariable) { From f585d22ce78027ccdf36b3dc9f4629aa998af7ef Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Mon, 16 May 2016 19:18:50 +0900 Subject: [PATCH 2/2] (templating) update dynamic dashboard only if variable is changed --- public/app/features/templating/templateValuesSrv.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index 0efc5eb468c..bec7545d9c6 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -27,10 +27,15 @@ function (angular, _, kbn) { .filter(function(variable) { return variable.refresh === 2; }).map(function(variable) { + var previousVariable = angular.copy(variable); return self.updateOptions(variable).then(function () { return self.variableUpdated(variable).then(function () { - dynamicDashboardSrv.update(self.dashboard); - $rootScope.$emit('template-variable-value-updated'); + var updatedVariable = angular.copy(variable); + delete(updatedVariable.$$hashKey); + if (JSON.stringify(previousVariable) !== JSON.stringify(updatedVariable)) { + dynamicDashboardSrv.update(self.dashboard); + $rootScope.$emit('template-variable-value-updated'); + } }); }); });