Merge branch 'reflect_panel_repeat_when_time_range_changed' of https://github.com/mtanda/grafana

This commit is contained in:
Torkel Ödegaard 2016-07-06 07:40:51 +02:00
commit 069100099d

View File

@ -8,7 +8,7 @@ function (angular, _, kbn) {
var module = angular.module('grafana.services'); 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; var self = this;
function getNoneOption() { return { text: 'None', value: '', isNone: true }; } function getNoneOption() { return { text: 'None', value: '', isNone: true }; }
@ -27,7 +27,17 @@ function (angular, _, kbn) {
.filter(function(variable) { .filter(function(variable) {
return variable.refresh === 2; return variable.refresh === 2;
}).map(function(variable) { }).map(function(variable) {
return self.updateOptions(variable); var previousVariable = angular.copy(variable);
return self.updateOptions(variable).then(function () {
return self.variableUpdated(variable).then(function () {
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');
}
});
});
}); });
return $q.all(promises); return $q.all(promises);
@ -35,6 +45,7 @@ function (angular, _, kbn) {
}, $rootScope); }, $rootScope);
this.init = function(dashboard) { this.init = function(dashboard) {
this.dashboard = dashboard;
this.variables = dashboard.templating.list; this.variables = dashboard.templating.list;
templateSrv.init(this.variables); templateSrv.init(this.variables);
@ -145,7 +156,7 @@ function (angular, _, kbn) {
this.variableUpdated = function(variable) { this.variableUpdated = function(variable) {
templateSrv.updateTemplateData(); templateSrv.updateTemplateData();
return this.updateOptionsInChildVariables(variable); return self.updateOptionsInChildVariables(variable);
}; };
this.updateOptionsInChildVariables = function(updatedVariable) { this.updateOptionsInChildVariables = function(updatedVariable) {