Просмотр исходного кода

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

Torkel Ödegaard 11 лет назад
Родитель
Сommit
6ff188e4d9

+ 1 - 1
src/app/controllers/graphiteTarget.js

@@ -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,
             }));
           });

+ 6 - 2
src/app/partials/panelgeneral.html

@@ -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>
+</div>

+ 0 - 3
src/app/services/influxdb/influxdbDatasource.js

@@ -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;

+ 6 - 4
src/app/services/templateSrv.js

@@ -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;
+      });
     };
 
   });

+ 2 - 1
src/css/less/overrides.less

@@ -66,7 +66,8 @@ code, pre {
 }
 
 .panel {
-  display: inline-table;
+  display: inline-block;
+  float: left;
   vertical-align: top;
 }