Commit 7224728a by bergquist

Merge branch 'refresh_temp_value_by_time_range_changes' of…

Merge branch 'refresh_temp_value_by_time_range_changes' of https://github.com/mtanda/grafana into mtanda-refresh_temp_value_by_time_range_changes
parents ca7c3cc2 aff4bf8f
......@@ -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;
}
......
......@@ -12,7 +12,7 @@ function (angular, _) {
var replacementDefaults = {
type: 'query',
datasource: null,
refresh: false,
refresh: 'Never',
name: '',
options: [],
includeAll: false,
......
......@@ -170,9 +170,9 @@
<input type="text" class="gf-form-input" ng-model='current.regex' placeholder="/.*-(.*)-.*/" ng-model-onblur ng-change="runQuery()"></input>
</div>
<div class="gf-form">
<span class="gf-form-label width-7">Update</span>
<editor-checkbox text="On Dashboard Load" model="current.refresh"></editor-checkbox>
<tip>Check if you want values to be updated on dashboard load, will slow down dashboard load time</tip>
<span class="gf-form-label width-7">Refresh</span>
<select class="input-large tight-form-input" ng-model="current.refresh" ng-options="f for f in ['Never', 'On Dashboard Load', 'On Time Change and Dashboard Load']"></select>
<tip>When to update the values of this template, will slow down dashboard load / time change</tip>
</div>
</div>
......
......@@ -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);
......
......@@ -258,6 +258,6 @@
"annotations": {
"enable": false
},
"refresh": false,
"refresh": "Never",
"version": 6
}
......@@ -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);
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment