Commit 6ff188e4 by Torkel Ödegaard

test for adding syntax in addition to [[variable]]

parent 44edaad1
......@@ -165,7 +165,7 @@ function (angular, _, config, gfunc, Parser) {
_.each(templateSrv.variables, function(variable) {
$scope.altSegments.unshift(new MetricSegment({
type: 'template',
value: '[[' + variable.name + ']]',
value: '$' + variable.name + ']]',
expandable: true,
}));
});
......
......@@ -4,8 +4,12 @@
<div class="editor-option">
<label class="small">Title</label><input type="text" class="input-medium" ng-model='panel.title'></input>
</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>
</div>
<div class="editor-option">
<label class="small">Height</label><input type="text" class="input-medium" ng-model='panel.height'></select>
</div>
</div>
</div>
......@@ -19,9 +19,6 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
this.username = datasource.username;
this.password = datasource.password;
this.name = datasource.name;
this.templateSettings = {
interpolate : /\[\[([\s\S]+?)\]\]/g,
};
this.saveTemp = _.isUndefined(datasource.save_temp) ? true : datasource.save_temp;
this.saveTempTTL = _.isUndefined(datasource.save_temp_ttl) ? '30d' : datasource.save_temp_ttl;
......
......@@ -8,10 +8,12 @@ function (angular, _) {
var module = angular.module('grafana.services');
module.service('templateSrv', function($q, $routeParams) {
var self = this;
this.init = function(variables) {
this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g };
this.variables = variables;
this.regex = /\$(\w+)|\[\[([\s\S]+?)\]\]/g;
this.updateTemplateData(true);
};
......@@ -39,11 +41,11 @@ function (angular, _) {
};
this.replace = function(target) {
if (!target || target.indexOf('[[') === -1) {
return target;
}
if (!target) { return; }
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 {
display: inline-table;
display: inline-block;
float: left;
vertical-align: top;
}
......
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