mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix cloudwatch multivalue (#6282)
* Fixed missing contains variable problem * allow All option to be used in cloudwatch templating
This commit is contained in:
parent
b6d112f8d7
commit
977cdd5933
@ -358,9 +358,15 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) {
|
||||
}
|
||||
|
||||
this.getExpandedVariables = function(target, dimensionKey, variable) {
|
||||
/* if the all checkbox is marked we should add all values to the targets */
|
||||
var allSelected = _.find(variable.options, {'selected': true, 'text': 'All'});
|
||||
return _.chain(variable.options)
|
||||
.filter(function(v) {
|
||||
if (allSelected) {
|
||||
return v.text !== 'All';
|
||||
} else {
|
||||
return v.selected;
|
||||
}
|
||||
})
|
||||
.map(function(v) {
|
||||
var t = angular.copy(target);
|
||||
@ -369,6 +375,10 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) {
|
||||
}).value();
|
||||
};
|
||||
|
||||
this.containsVariable = function (str, variableName) {
|
||||
return str.indexOf('$' + variableName) !== -1;
|
||||
};
|
||||
|
||||
this.expandTemplateVariable = function(targets, templateSrv) {
|
||||
var self = this;
|
||||
return _.chain(targets)
|
||||
@ -379,7 +389,7 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) {
|
||||
|
||||
if (dimensionKey) {
|
||||
var variable = _.find(templateSrv.variables, function(variable) {
|
||||
return templateSrv.containsVariable(target.dimensions[dimensionKey], variable.name);
|
||||
return self.containsVariable(target.dimensions[dimensionKey], variable.name);
|
||||
});
|
||||
return self.getExpandedVariables(target, dimensionKey, variable);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user