Commit 9fd76768 by Torkel Ödegaard

Merge branch 'v3.1.x'

parents 6d28365e 0de0f4d0
......@@ -16,10 +16,6 @@ function (angular, $, _, moment) {
data = {};
}
if (!data.id && data.version) {
data.schemaVersion = data.version;
}
this.id = data.id || null;
this.title = data.title || 'No Title';
this.autoUpdate = data.autoUpdate;
......
......@@ -11,6 +11,7 @@ function (angular, _, $, kbn) {
module.service('templateValuesSrv', function($q, $rootScope, datasourceSrv, $location, templateSrv, timeSrv) {
var self = this;
this.variableLock = {};
function getNoneOption() { return { text: 'None', value: '', isNone: true }; }
......@@ -101,6 +102,8 @@ function (angular, _, $, kbn) {
} else {
lock.resolve();
}
}).finally(function() {
delete self.variableLock[variable.name];
});
};
......@@ -135,7 +138,7 @@ function (angular, _, $, kbn) {
templateSrv.setGrafanaVariable('$__auto_interval', interval);
};
this.setVariableValue = function(variable, option, initPhase) {
this.setVariableValue = function(variable, option) {
variable.current = angular.copy(option);
if (_.isArray(variable.current.text)) {
......@@ -145,13 +148,7 @@ function (angular, _, $, kbn) {
self.selectOptionsForCurrentValue(variable);
templateSrv.updateTemplateData();
// on first load, variable loading is ordered to ensure
// that parents are updated before children.
if (initPhase) {
return $q.when();
}
return self.updateOptionsInChildVariables(variable);
return this.updateOptionsInChildVariables(variable);
};
this.variableUpdated = function(variable) {
......@@ -160,6 +157,11 @@ function (angular, _, $, kbn) {
};
this.updateOptionsInChildVariables = function(updatedVariable) {
// if there is a variable lock ignore cascading update because we are in a boot up scenario
if (self.variableLock[updatedVariable.name]) {
return $q.when();
}
var promises = _.map(self.variables, function(otherVariable) {
if (otherVariable === updatedVariable) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment