mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'built_in_template_variables'
This commit is contained in:
@@ -17,6 +17,11 @@ function (angular, _, kbn) {
|
||||
this._grafanaVariables = {};
|
||||
this._adhocVariables = {};
|
||||
|
||||
// default built ins
|
||||
this._builtIns = {};
|
||||
this._builtIns['__interval'] = {text: '1s', value: '1s'};
|
||||
this._builtIns['__interval_ms'] = {text: '100', value: '100'};
|
||||
|
||||
this.init = function(variables) {
|
||||
this.variables = variables;
|
||||
this.updateTemplateData();
|
||||
@@ -42,6 +47,7 @@ function (angular, _, kbn) {
|
||||
|
||||
this._index[variable.name] = variable;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.variableInitialized = function(variable) {
|
||||
@@ -103,10 +109,10 @@ function (angular, _, kbn) {
|
||||
return this.distributeVariable(value, variable.name);
|
||||
}
|
||||
default: {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
if (_.isArray(value)) {
|
||||
return '{' + value.join(',') + '}';
|
||||
}
|
||||
return '{' + value.join(',') + '}';
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -135,7 +141,7 @@ function (angular, _, kbn) {
|
||||
str = _.escape(str);
|
||||
this._regex.lastIndex = 0;
|
||||
return str.replace(this._regex, function(match, g1, g2) {
|
||||
if (self._index[g1 || g2]) {
|
||||
if (self._index[g1 || g2] || self._builtIns[g1 || g2]) {
|
||||
return '<span class="template-variable">' + match + '</span>';
|
||||
}
|
||||
return match;
|
||||
|
||||
Reference in New Issue
Block a user