mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
test for adding syntax in addition to [[variable]]
This commit is contained in:
parent
44edaad19d
commit
6ff188e4d9
@ -165,7 +165,7 @@ function (angular, _, config, gfunc, Parser) {
|
|||||||
_.each(templateSrv.variables, function(variable) {
|
_.each(templateSrv.variables, function(variable) {
|
||||||
$scope.altSegments.unshift(new MetricSegment({
|
$scope.altSegments.unshift(new MetricSegment({
|
||||||
type: 'template',
|
type: 'template',
|
||||||
value: '[[' + variable.name + ']]',
|
value: '$' + variable.name + ']]',
|
||||||
expandable: true,
|
expandable: true,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -4,8 +4,12 @@
|
|||||||
<div class="editor-option">
|
<div class="editor-option">
|
||||||
<label class="small">Title</label><input type="text" class="input-medium" ng-model='panel.title'></input>
|
<label class="small">Title</label><input type="text" class="input-medium" ng-model='panel.title'></input>
|
||||||
</div>
|
</div>
|
||||||
<div class="editor-option" ng-hide="panel.sizeable == false">
|
<div class="editor-option">
|
||||||
<label class="small">Span</label> <select class="input-mini" ng-model="panel.span" ng-options="f for f in [0,1,2,3,4,5,6,7,8,9,10,11,12]"></select>
|
<label class="small">Span</label> <select class="input-mini" ng-model="panel.span" ng-options="f for f in [0,1,2,3,4,5,6,7,8,9,10,11,12]"></select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="editor-option">
|
||||||
|
<label class="small">Height</label><input type="text" class="input-medium" ng-model='panel.height'></select>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,9 +19,6 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
|
|||||||
this.username = datasource.username;
|
this.username = datasource.username;
|
||||||
this.password = datasource.password;
|
this.password = datasource.password;
|
||||||
this.name = datasource.name;
|
this.name = datasource.name;
|
||||||
this.templateSettings = {
|
|
||||||
interpolate : /\[\[([\s\S]+?)\]\]/g,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.saveTemp = _.isUndefined(datasource.save_temp) ? true : datasource.save_temp;
|
this.saveTemp = _.isUndefined(datasource.save_temp) ? true : datasource.save_temp;
|
||||||
this.saveTempTTL = _.isUndefined(datasource.save_temp_ttl) ? '30d' : datasource.save_temp_ttl;
|
this.saveTempTTL = _.isUndefined(datasource.save_temp_ttl) ? '30d' : datasource.save_temp_ttl;
|
||||||
|
@ -8,10 +8,12 @@ function (angular, _) {
|
|||||||
var module = angular.module('grafana.services');
|
var module = angular.module('grafana.services');
|
||||||
|
|
||||||
module.service('templateSrv', function($q, $routeParams) {
|
module.service('templateSrv', function($q, $routeParams) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
this.init = function(variables) {
|
this.init = function(variables) {
|
||||||
this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g };
|
this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g };
|
||||||
this.variables = variables;
|
this.variables = variables;
|
||||||
|
this.regex = /\$(\w+)|\[\[([\s\S]+?)\]\]/g;
|
||||||
this.updateTemplateData(true);
|
this.updateTemplateData(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,11 +41,11 @@ function (angular, _) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.replace = function(target) {
|
this.replace = function(target) {
|
||||||
if (!target || target.indexOf('[[') === -1) {
|
if (!target) { return; }
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _.template(target, this._templateData, this.templateSettings);
|
return target.replace(this.regex, function(match, g1, g2) {
|
||||||
|
return self._templateData[g1 || g2] || match;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -66,7 +66,8 @@ code, pre {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
display: inline-table;
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user