|
|
@@ -28,17 +28,11 @@ function (angular, _, kbn) {
|
|
|
for (var i = 0; i < this.variables.length; i++) {
|
|
|
var variable = this.variables[i];
|
|
|
var urlValue = queryParams['var-' + variable.name];
|
|
|
- if (variable.refresh) {
|
|
|
- promises.push(this.updateOptions(variable));
|
|
|
- }
|
|
|
if (urlValue !== void 0) {
|
|
|
- var option = _.findWhere(variable.options, { text: urlValue });
|
|
|
- option = option || { text: urlValue, value: urlValue };
|
|
|
-
|
|
|
- var promise = this.setVariableValue(variable, option, true);
|
|
|
- this.updateAutoInterval(variable);
|
|
|
-
|
|
|
- promises.push(promise);
|
|
|
+ promises.push(this.setVariableFromUrl(variable, urlValue));
|
|
|
+ }
|
|
|
+ else if (variable.refresh) {
|
|
|
+ promises.push(this.updateOptions(variable));
|
|
|
}
|
|
|
else if (variable.type === 'interval') {
|
|
|
this.updateAutoInterval(variable);
|
|
|
@@ -48,6 +42,25 @@ function (angular, _, kbn) {
|
|
|
return $q.all(promises);
|
|
|
};
|
|
|
|
|
|
+ this.setVariableFromUrl = function(variable, urlValue) {
|
|
|
+ if (variable.refresh) {
|
|
|
+ var self = this;
|
|
|
+ //refresh the list of options before setting the value
|
|
|
+ return this.updateOptions(variable).then(function() {
|
|
|
+ var option = _.findWhere(variable.options, { text: urlValue });
|
|
|
+ option = option || { text: urlValue, value: urlValue };
|
|
|
+
|
|
|
+ self.updateAutoInterval(variable);
|
|
|
+ return self.setVariableValue(variable, option);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ var option = _.findWhere(variable.options, { text: urlValue });
|
|
|
+ option = option || { text: urlValue, value: urlValue };
|
|
|
+
|
|
|
+ this.updateAutoInterval(variable);
|
|
|
+ return this.setVariableValue(variable, option);
|
|
|
+ };
|
|
|
+
|
|
|
this.updateAutoInterval = function(variable) {
|
|
|
if (!variable.auto) { return; }
|
|
|
|