Commit 6ff188e4 by Torkel Ödegaard

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

parent 44edaad1
...@@ -165,7 +165,7 @@ function (angular, _, config, gfunc, Parser) { ...@@ -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 @@ ...@@ -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>
\ No newline at end of file
...@@ -19,9 +19,6 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) { ...@@ -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, _) { ...@@ -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, _) { ...@@ -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 { ...@@ -66,7 +66,8 @@ code, pre {
} }
.panel { .panel {
display: inline-table; display: inline-block;
float: left;
vertical-align: top; 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