From dc4743a392e4a4494f967b8d27f758db7917309c Mon Sep 17 00:00:00 2001 From: woodsaj Date: Tue, 8 Mar 2016 15:41:24 +0800 Subject: [PATCH] ensure current template variable is set. - When distributing a dashboard it is often not practical to have "current" template variable option set. This commit ensures that for dashboards with no current, it is assigned when the dashboard loads (assuming refresh on load is set.) --- public/app/features/templating/templateValuesSrv.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index 5256c3e59b5..7750bb34a19 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -64,6 +64,10 @@ function (angular, _, kbn) { } else if (variable.refresh) { return self.updateOptions(variable).then(function() { + if (_.isEmpty(variable.current) && variable.options.length) { + console.log("setting current for %s", variable.name); + self.setVariableValue(variable, variable.options[0], true); + } self.variableLock[variableName].resolve(); }); }