mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(templating): refactoring of the refresh values of #4281
This commit is contained in:
parent
d9231eb805
commit
4a5b753fd8
@ -404,8 +404,8 @@ function (angular, $, _, moment) {
|
|||||||
if (oldVersion < 11) {
|
if (oldVersion < 11) {
|
||||||
// update template variables
|
// update template variables
|
||||||
_.each(this.templating.list, function(templateVariable) {
|
_.each(this.templating.list, function(templateVariable) {
|
||||||
if (templateVariable.refresh) { templateVariable.refresh = 'On Dashboard Load'; }
|
if (templateVariable.refresh) { templateVariable.refresh = 1; }
|
||||||
if (!templateVariable.refresh) { templateVariable.refresh = 'Never'; }
|
if (!templateVariable.refresh) { templateVariable.refresh = 0; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,19 @@ function (angular, _) {
|
|||||||
var replacementDefaults = {
|
var replacementDefaults = {
|
||||||
type: 'query',
|
type: 'query',
|
||||||
datasource: null,
|
datasource: null,
|
||||||
refresh: 'Never',
|
refresh: 0,
|
||||||
name: '',
|
name: '',
|
||||||
options: [],
|
options: [],
|
||||||
includeAll: false,
|
includeAll: false,
|
||||||
multi: false,
|
multi: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.refreshOptions = [
|
||||||
|
{value: 0, text: "Never"},
|
||||||
|
{value: 1, text: "On Dashboard Load"},
|
||||||
|
{value: 2, text: "On Time Range Change"},
|
||||||
|
];
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
$scope.mode = 'list';
|
$scope.mode = 'list';
|
||||||
|
|
||||||
|
@ -171,8 +171,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
<span class="gf-form-label width-7">Refresh</span>
|
<span class="gf-form-label width-7">Refresh</span>
|
||||||
<select class="gf-form-input max-width-22" ng-model="current.refresh" ng-options="f for f in ['Never', 'On Dashboard Load', 'On Time Change and Dashboard Load']"></select>
|
<select class="gf-form-input max-width-14" ng-model="current.refresh" ng-options="f.value as f.text for f in refreshOptions"></select>
|
||||||
<tip>When to update the values of this template, will slow down dashboard load / time change</tip>
|
<tip>When to update the values of this variable, will slow down dashboard load / time change</tip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -13,22 +13,25 @@ function (angular, _, kbn) {
|
|||||||
|
|
||||||
function getNoneOption() { return { text: 'None', value: '', isNone: true }; }
|
function getNoneOption() { return { text: 'None', value: '', isNone: true }; }
|
||||||
|
|
||||||
$rootScope.onAppEvent('time-range-changed', function() {
|
// update time variant variables
|
||||||
var variable = _.findWhere(self.variables, { type: 'interval' });
|
|
||||||
if (variable) {
|
|
||||||
self.updateAutoInterval(variable);
|
|
||||||
}
|
|
||||||
}, $rootScope);
|
|
||||||
|
|
||||||
$rootScope.onAppEvent('refresh', function() {
|
$rootScope.onAppEvent('refresh', function() {
|
||||||
var promises = _.chain(self.variables)
|
|
||||||
.filter(function(variable) {
|
// look for interval variables
|
||||||
return variable.refresh === 'On Time Change and Dashboard Load';
|
var intervalVariable = _.findWhere(self.variables, { type: 'interval' });
|
||||||
})
|
if (intervalVariable) {
|
||||||
.map(function(variable) {
|
self.updateAutoInterval(intervalVariable);
|
||||||
return self.updateOptions(variable);
|
}
|
||||||
}).value();
|
|
||||||
|
// update variables with refresh === 2
|
||||||
|
var promises = self.variables
|
||||||
|
.filter(function(variable) {
|
||||||
|
return variable.refresh === 2;
|
||||||
|
}).map(function(variable) {
|
||||||
|
return self.updateOptions(variable);
|
||||||
|
});
|
||||||
|
|
||||||
return $q.all(promises);
|
return $q.all(promises);
|
||||||
|
|
||||||
}, $rootScope);
|
}, $rootScope);
|
||||||
|
|
||||||
this.init = function(dashboard) {
|
this.init = function(dashboard) {
|
||||||
|
Loading…
Reference in New Issue
Block a user