Просмотр исходного кода

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.)
woodsaj 9 лет назад
Родитель
Сommit
dc4743a392
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      public/app/features/templating/templateValuesSrv.js

+ 4 - 0
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();
           });
         }