Commit 078e69d0 by Torkel Ödegaard

feat(templating): simplified templating forms removed all formats

parent f44d6e06
...@@ -179,11 +179,6 @@ function (angular, _, coreModule) { ...@@ -179,11 +179,6 @@ function (angular, _, coreModule) {
vm.variable.current.text = _.pluck(vm.selectedValues, 'text').join(' + '); vm.variable.current.text = _.pluck(vm.selectedValues, 'text').join(' + ');
vm.variable.current.tags = vm.selectedTags; vm.variable.current.tags = vm.selectedTags;
// only single value
if (vm.selectedValues.length === 1) {
vm.variable.current.value = vm.selectedValues[0].value;
}
if (commitChange) { if (commitChange) {
vm.commitChanges(); vm.commitChanges();
} }
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<input type="text" class="gf-form-input max-width-14" placeholder="name" ng-model='current.name'></input> <input type="text" class="gf-form-input max-width-14" placeholder="name" ng-model='current.name'></input>
</div> </div>
<div class="gf-form"> <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"> <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> <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> </div>
...@@ -97,8 +97,9 @@ ...@@ -97,8 +97,9 @@
<input type="text" class="gf-form-input max-width-14" ng-model='current.label' placeholder="optional display name"></input> <input type="text" class="gf-form-input max-width-14" ng-model='current.label' placeholder="optional display name"></input>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<editor-checkbox class="width-10" text="Hide label" model="current.hideLabel" change="runQuery()"></editor-checkbox> <span class="gf-form-label width-4">Hide</span>
<editor-checkbox class="width-11" text="Hide variable" model="current.hideVariable" change="runQuery()"></editor-checkbox> <editor-checkbox text="Label" model="current.hideLabel" change="runQuery()"></editor-checkbox>
<editor-checkbox text="Variable" model="current.hideVariable" change="runQuery()"></editor-checkbox>
</div> </div>
</div> </div>
...@@ -133,14 +134,9 @@ ...@@ -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> <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>
<div class="gf-form "> <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> <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>
</div> </div>
...@@ -158,20 +154,9 @@ ...@@ -158,20 +154,9 @@
</div> </div>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-7">All value</span> <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> <editor-checkbox class="width-13" text="Enable" model="current.includeAll" change="runQuery()"></editor-checkbox>
</div> </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"> <div class="gf-form">
<span class="gf-form-label width-7">Update</span> <span class="gf-form-label width-7">Update</span>
<editor-checkbox text="On Dashboard Load" model="current.refresh"></editor-checkbox> <editor-checkbox text="On Dashboard Load" model="current.refresh"></editor-checkbox>
......
...@@ -108,7 +108,6 @@ function (angular, _, kbn) { ...@@ -108,7 +108,6 @@ function (angular, _, kbn) {
if (variable.type === 'custom' && variable.includeAll) { if (variable.type === 'custom' && variable.includeAll) {
self.addAllOption(variable); self.addAllOption(variable);
} }
}; };
this.updateOptions = function(variable) { this.updateOptions = function(variable) {
...@@ -245,41 +244,42 @@ function (angular, _, kbn) { ...@@ -245,41 +244,42 @@ function (angular, _, kbn) {
}; };
this.addAllOption = function(variable) { this.addAllOption = function(variable) {
var allValue = ''; // var allValue = '';
switch(variable.allFormat) { // switch(variable.allFormat) {
case 'wildcard': { // case 'wildcard': {
allValue = '*'; // allValue = '*';
break; // break;
} // }
case 'regex wildcard': { // case 'regex wildcard': {
allValue = '.*'; // allValue = '.*';
break; // break;
} // }
case 'lucene': { // case 'lucene': {
var quotedValues = _.map(variable.options, function(val) { // var quotedValues = _.map(variable.options, function(val) {
return '\\\"' + val.text + '\\\"'; // return '\\\"' + val.text + '\\\"';
}); // });
allValue = '(' + quotedValues.join(' OR ') + ')'; // allValue = '(' + quotedValues.join(' OR ') + ')';
break; // break;
} // }
case 'regex values': { // case 'regex values': {
allValue = '(' + _.map(variable.options, function(option) { // allValue = '(' + _.map(variable.options, function(option) {
return self.regexEscape(option.text); // return self.regexEscape(option.text);
}).join('|') + ')'; // }).join('|') + ')';
break; // break;
} // }
case 'pipe': { // case 'pipe': {
allValue = _.pluck(variable.options, 'text').join('|'); // allValue = _.pluck(variable.options, 'text').join('|');
break; // break;
} // }
default: { // default: {
allValue = '{'; // allValue = '{';
allValue += _.pluck(variable.options, 'text').join(','); // allValue += _.pluck(variable.options, 'text').join(',');
allValue += '}'; // allValue += '}';
} // }
} // }
//
variable.options.unshift({text: 'All', value: allValue}); var value =_.pluck(variable.options, 'text');
variable.options.unshift({text: 'All', value: value});
}; };
}); });
......
...@@ -190,7 +190,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes ...@@ -190,7 +190,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
payload = payload.replace(/\$interval/g, options.interval); payload = payload.replace(/\$interval/g, options.interval);
payload = payload.replace(/\$timeFrom/g, options.range.from.valueOf()); payload = payload.replace(/\$timeFrom/g, options.range.from.valueOf());
payload = payload.replace(/\$timeTo/g, options.range.to.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 this._post('_msearch', payload).then(function(res) {
return new ElasticResponse(sentTargets, res).getTimeSeries(); return new ElasticResponse(sentTargets, res).getTimeSeries();
......
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