@@ -11,6 +11,7 @@ function (angular, _, $, kbn) {
11
11
12
12
module . service ( 'templateValuesSrv' , function ( $q , $rootScope , datasourceSrv , $location , templateSrv , timeSrv ) {
13
13
var self = this ;
14
+ this . variableLock = { } ;
14
15
15
16
function getNoneOption ( ) { return { text : 'None' , value : '' , isNone : true } ; }
16
17
@@ -101,6 +102,8 @@ function (angular, _, $, kbn) {
101
102
} else {
102
103
lock . resolve ( ) ;
103
104
}
105
+ } ) . finally ( function ( ) {
106
+ delete self . variableLock [ variable . name ] ;
104
107
} ) ;
105
108
} ;
106
109
@@ -135,7 +138,7 @@ function (angular, _, $, kbn) {
135
138
templateSrv . setGrafanaVariable ( '$__auto_interval' , interval ) ;
136
139
} ;
137
140
138
- this . setVariableValue = function ( variable , option , initPhase ) {
141
+ this . setVariableValue = function ( variable , option ) {
139
142
variable . current = angular . copy ( option ) ;
140
143
141
144
if ( _ . isArray ( variable . current . text ) ) {
@@ -145,13 +148,7 @@ function (angular, _, $, kbn) {
145
148
self . selectOptionsForCurrentValue ( variable ) ;
146
149
templateSrv . updateTemplateData ( ) ;
147
150
148
- // on first load, variable loading is ordered to ensure
149
- // that parents are updated before children.
150
- if ( initPhase ) {
151
- return $q . when ( ) ;
152
- }
153
-
154
- return self . updateOptionsInChildVariables ( variable ) ;
151
+ return this . updateOptionsInChildVariables ( variable ) ;
155
152
} ;
156
153
157
154
this . variableUpdated = function ( variable ) {
@@ -160,6 +157,11 @@ function (angular, _, $, kbn) {
160
157
} ;
161
158
162
159
this . updateOptionsInChildVariables = function ( updatedVariable ) {
160
+ // if there is a variable lock ignore cascading update because we are in a boot up scenario
161
+ if ( self . variableLock [ updatedVariable . name ] ) {
162
+ return $q . when ( ) ;
163
+ }
164
+
163
165
var promises = _ . map ( self . variables , function ( otherVariable ) {
164
166
if ( otherVariable === updatedVariable ) {
165
167
return ;
0 commit comments