diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js index 01c5787481b..ff53eb93f70 100644 --- a/public/app/features/dashboard/dashboardSrv.js +++ b/public/app/features/dashboard/dashboardSrv.js @@ -212,7 +212,7 @@ function (angular, $, _, moment) { var i, j, k; var oldVersion = this.schemaVersion; var panelUpgrades = []; - this.schemaVersion = 10; + this.schemaVersion = 11; if (oldVersion === this.schemaVersion) { return; @@ -401,6 +401,14 @@ function (angular, $, _, moment) { }); } + if (oldVersion < 11) { + // update template variables + _.each(this.templating.list, function(templateVariable) { + if (templateVariable.refresh) { templateVariable.refresh = 'On Dashboard Load'; } + if (!templateVariable.refresh) { templateVariable.refresh = 'Never'; } + }); + } + if (panelUpgrades.length === 0) { return; } diff --git a/public/app/features/templating/editorCtrl.js b/public/app/features/templating/editorCtrl.js index 46a3072090d..1b31ce9cf1a 100644 --- a/public/app/features/templating/editorCtrl.js +++ b/public/app/features/templating/editorCtrl.js @@ -12,7 +12,7 @@ function (angular, _) { var replacementDefaults = { type: 'query', datasource: null, - refresh: false, + refresh: 'Never', name: '', options: [], includeAll: false, diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 64541868f3b..3028bfa8a36 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -170,9 +170,9 @@
- Update - - Check if you want values to be updated on dashboard load, will slow down dashboard load time + Refresh + + When to update the values of this template, will slow down dashboard load / time change
diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index 51895ff1ebf..e5861ad12c1 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -20,6 +20,17 @@ function (angular, _, kbn) { } }, $rootScope); + $rootScope.onAppEvent('refresh', function() { + var promises = _.chain(self.variables) + .filter(function(variable) { + return variable.refresh === 'On Time Change and Dashboard Load'; + }) + .map(function(variable) { + return self.updateOptions(variable); + }).value(); + return $q.all(promises); + }, $rootScope); + this.init = function(dashboard) { this.variables = dashboard.templating.list; templateSrv.init(this.variables); @@ -60,7 +71,7 @@ function (angular, _, kbn) { if (urlValue !== void 0) { return self.setVariableFromUrl(variable, urlValue).then(lock.resolve); } - else if (variable.refresh) { + else if (variable.refresh === 'On Dashboard Load' || variable.refresh === 'On Time Change and Dashboard Load') { return self.updateOptions(variable).then(function() { if (_.isEmpty(variable.current) && variable.options.length) { console.log("setting current for %s", variable.name); diff --git a/public/dashboards/template_vars.json b/public/dashboards/template_vars.json index fbf2ae0dc9d..53dd5e3cfbf 100644 --- a/public/dashboards/template_vars.json +++ b/public/dashboards/template_vars.json @@ -258,6 +258,6 @@ "annotations": { "enable": false }, - "refresh": false, + "refresh": "Never", "version": 6 } diff --git a/public/test/specs/dashboardSrv-specs.js b/public/test/specs/dashboardSrv-specs.js index 8f455864650..86f54f274fb 100644 --- a/public/test/specs/dashboardSrv-specs.js +++ b/public/test/specs/dashboardSrv-specs.js @@ -194,7 +194,7 @@ define([ }); it('dashboard schema version should be set to latest', function() { - expect(model.schemaVersion).to.be(10); + expect(model.schemaVersion).to.be(11); }); });