Browse Source

feat(templating): simplified templating forms removed all formats

Torkel Ödegaard 9 years ago
parent
commit
078e69d06d

+ 0 - 5
public/app/core/directives/value_select_dropdown.js

@@ -179,11 +179,6 @@ function (angular, _, coreModule) {
       vm.variable.current.text = _.pluck(vm.selectedValues, 'text').join(' + ');
       vm.variable.current.tags = vm.selectedTags;
 
-      // only single value
-      if (vm.selectedValues.length === 1) {
-        vm.variable.current.value = vm.selectedValues[0].value;
-      }
-
       if (commitChange) {
         vm.commitChanges();
       }

+ 7 - 22
public/app/features/templating/partials/editor.html

@@ -79,7 +79,7 @@
 						<input type="text" class="gf-form-input max-width-14" placeholder="name" ng-model='current.name'></input>
 					</div>
 					<div class="gf-form">
-						<span class="gf-form-label width-7">Type</span>
+						<span class="gf-form-label width-4">Type</span>
 						<div class="gf-form-select-wrapper max-width-10">
 							<select class="gf-form-input  max-width-10" ng-model="current.type" ng-options="f for f in ['query', 'interval', 'custom']" ng-change="typeChanged()"></select>
 						</div>
@@ -97,8 +97,9 @@
 						<input type="text" class="gf-form-input max-width-14" ng-model='current.label' placeholder="optional display name"></input>
 					</div>
 					<div class="gf-form">
-						<editor-checkbox class="width-10" text="Hide label" model="current.hideLabel" change="runQuery()"></editor-checkbox>
-						<editor-checkbox class="width-11" text="Hide variable" model="current.hideVariable" change="runQuery()"></editor-checkbox>
+						<span class="gf-form-label width-4">Hide</span>
+						<editor-checkbox text="Label" model="current.hideLabel" change="runQuery()"></editor-checkbox>
+						<editor-checkbox text="Variable" model="current.hideVariable" change="runQuery()"></editor-checkbox>
 					</div>
 				</div>
 
@@ -133,14 +134,9 @@
 					<input type="text" class="gf-form-input max-width-22" ng-model='current.query' ng-blur="runQuery()" placeholder="1, 10, 20, myvalue"></input>
 				</div>
 				<div class="gf-form ">
+					<span class="gf-form-label width-13">Include All option</span>
+					<input ng-show="current.includeAll" type="text" class="gf-form-input max-width-22" ng-model='current.customAllValue' placeholder="auto"></input>
 					<editor-checkbox class="width-13" text="All value" model="current.includeAll" change="runQuery()"></editor-checkbox>
-					<input ng-show="current.includeAll" type="text" class="gf-form-input max-width-22" ng-model='current.options[0].value' style="margin-left: 4px;"></input>
-				</div>
-				<div class="gf-form">
-					<span class="gf-form-label width-13" ng-show="current.includeAll">All format</span>
-					<div class="gf-form-select-wrapper max-width-10" ng-show="current.includeAll">
-						<select class="gf-form-input" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values', 'lucene', 'pipe']"></select>
-					</div>
 				</div>
 			</div>
 
@@ -158,20 +154,9 @@
 				</div>
 				<div class="gf-form">
 					<span class="gf-form-label width-7">All value</span>
+					<input type="text" class="gf-form-input max-width-15" ng-show="current.includeAll" ng-model='current.customAllValue' placeholder="auto"></input>
 					<editor-checkbox class="width-13" text="Enable" model="current.includeAll" change="runQuery()"></editor-checkbox>
 				</div>
-				<div class="gf-form-inline" ng-show="current.includeAll">
-					<div class="gf-form">
-						<span class="gf-form-label width-7">All format</span>
-						<div class="gf-form-select-wrapper">
-							<select class="gf-form-input" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values', 'lucene', 'pipe']"></select>
-						</div>
-					</div>
-					<div class="gf-form max-width-30">
-						<span class="gf-form-label width-7">All value</span>
-						<input type="text" class="gf-form-input" ng-model='current.options[0].value'></input>
-					</div>
-				</div>
 				<div class="gf-form">
 					<span class="gf-form-label width-7">Update</span>
 					<editor-checkbox text="On Dashboard Load" model="current.refresh"></editor-checkbox>

+ 36 - 36
public/app/features/templating/templateValuesSrv.js

@@ -108,7 +108,6 @@ function (angular, _, kbn) {
       if (variable.type === 'custom' && variable.includeAll) {
         self.addAllOption(variable);
       }
-
     };
 
     this.updateOptions = function(variable) {
@@ -245,41 +244,42 @@ function (angular, _, kbn) {
     };
 
     this.addAllOption = function(variable) {
-      var allValue = '';
-      switch(variable.allFormat) {
-        case 'wildcard': {
-          allValue = '*';
-          break;
-        }
-        case 'regex wildcard': {
-          allValue = '.*';
-          break;
-        }
-        case 'lucene': {
-          var quotedValues = _.map(variable.options, function(val) {
-            return '\\\"' + val.text + '\\\"';
-          });
-          allValue = '(' + quotedValues.join(' OR ') + ')';
-          break;
-        }
-        case 'regex values': {
-          allValue = '(' + _.map(variable.options, function(option) {
-            return self.regexEscape(option.text);
-          }).join('|') + ')';
-          break;
-        }
-        case 'pipe': {
-          allValue = _.pluck(variable.options, 'text').join('|');
-          break;
-        }
-        default: {
-          allValue = '{';
-          allValue += _.pluck(variable.options, 'text').join(',');
-          allValue += '}';
-        }
-      }
-
-      variable.options.unshift({text: 'All', value: allValue});
+      // var allValue = '';
+      // switch(variable.allFormat) {
+      //   case 'wildcard': {
+      //     allValue = '*';
+      //     break;
+      //   }
+      //   case 'regex wildcard': {
+      //     allValue = '.*';
+      //     break;
+      //   }
+      //   case 'lucene': {
+      //     var quotedValues = _.map(variable.options, function(val) {
+      //       return '\\\"' + val.text + '\\\"';
+      //     });
+      //     allValue = '(' + quotedValues.join(' OR ') + ')';
+      //     break;
+      //   }
+      //   case 'regex values': {
+      //     allValue = '(' + _.map(variable.options, function(option) {
+      //       return self.regexEscape(option.text);
+      //     }).join('|') + ')';
+      //     break;
+      //   }
+      //   case 'pipe': {
+      //     allValue = _.pluck(variable.options, 'text').join('|');
+      //     break;
+      //   }
+      //   default: {
+      //     allValue = '{';
+      //     allValue += _.pluck(variable.options, 'text').join(',');
+      //     allValue += '}';
+      //   }
+      //  }
+      //
+      var value =_.pluck(variable.options, 'text');
+      variable.options.unshift({text: 'All', value: value});
     };
 
   });

+ 1 - 1
public/app/plugins/datasource/elasticsearch/datasource.js

@@ -190,7 +190,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
       payload = payload.replace(/\$interval/g, options.interval);
       payload = payload.replace(/\$timeFrom/g, options.range.from.valueOf());
       payload = payload.replace(/\$timeTo/g, options.range.to.valueOf());
-      payload = templateSrv.replace(payload, options.scopedVars);
+      payload = templateSrv.replace(payload, options.scopedVars, 'lucene');
 
       return this._post('_msearch', payload).then(function(res) {
         return new ElasticResponse(sentTargets, res).getTimeSeries();