mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(elasticsearch): added new templating all format and muli format named , also added automatic setting of correct all and multi format depending on data source, closes #2696
This commit is contained in:
@@ -36,6 +36,17 @@ function (angular, _) {
|
||||
$scope.reset();
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('current.datasource', function(val) {
|
||||
if ($scope.mode === 'new') {
|
||||
datasourceSrv.get(val).then(function(ds) {
|
||||
if (ds.meta.defaultMatchFormat) {
|
||||
$scope.current.allFormat = ds.meta.defaultMatchFormat;
|
||||
$scope.current.multiFormat = ds.meta.defaultMatchFormat;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.add = function() {
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
All format
|
||||
</li>
|
||||
<li ng-show="current.includeAll">
|
||||
<select class="input-medium tight-form-input last" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values']"></select>
|
||||
<select class="input-medium tight-form-input last" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values', 'lucene']"></select>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
@@ -217,7 +217,7 @@
|
||||
Multi format
|
||||
</li>
|
||||
<li ng-show="current.multi">
|
||||
<select class="input-medium tight-form-input last" ng-model="current.multiFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'regex values']"></select>
|
||||
<select class="input-medium tight-form-input last" ng-model="current.multiFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'regex values', 'lucene']"></select>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
@@ -39,10 +39,17 @@ function (angular, _) {
|
||||
if (_.isString(value)) {
|
||||
return value;
|
||||
} else {
|
||||
if (variable.multiFormat === 'regex values') {
|
||||
return '(' + value.join('|') + ')';
|
||||
switch(variable.multiFormat) {
|
||||
case "regex values": {
|
||||
return '(' + value.join('|') + ')';
|
||||
}
|
||||
case "lucene": {
|
||||
return '(' + value.join(' OR ') + ')';
|
||||
}
|
||||
default: {
|
||||
return '{' + value.join(',') + '}';
|
||||
}
|
||||
}
|
||||
return '{' + value.join(',') + '}';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -253,21 +253,29 @@ function (angular, _, kbn) {
|
||||
this.addAllOption = function(variable) {
|
||||
var allValue = '';
|
||||
switch(variable.allFormat) {
|
||||
case 'wildcard':
|
||||
allValue = '*';
|
||||
break;
|
||||
case 'regex wildcard':
|
||||
allValue = '.*';
|
||||
break;
|
||||
case 'regex values':
|
||||
allValue = '(' + _.map(variable.options, function(option) {
|
||||
return self.regexEscape(option.text);
|
||||
}).join('|') + ')';
|
||||
break;
|
||||
default:
|
||||
allValue = '{';
|
||||
allValue += _.pluck(variable.options, 'text').join(',');
|
||||
allValue += '}';
|
||||
case 'wildcard': {
|
||||
allValue = '*';
|
||||
break;
|
||||
}
|
||||
case 'regex wildcard': {
|
||||
allValue = '.*';
|
||||
break;
|
||||
}
|
||||
case 'lucene': {
|
||||
allValue = '(' + _.pluck(variable.options, 'text').join(' OR ') + ')';
|
||||
break;
|
||||
}
|
||||
case 'regex values': {
|
||||
allValue = '(' + _.map(variable.options, function(option) {
|
||||
return self.regexEscape(option.text);
|
||||
}).join('|') + ')';
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
allValue = '{';
|
||||
allValue += _.pluck(variable.options, 'text').join(',');
|
||||
allValue += '}';
|
||||
}
|
||||
}
|
||||
|
||||
variable.options.unshift({text: 'All', value: allValue});
|
||||
|
||||
Reference in New Issue
Block a user