Commit 977cdd59 by mkm85 Committed by Torkel Ödegaard

Fix cloudwatch multivalue (#6282)

* Fixed missing contains variable problem

* allow All option to be used in cloudwatch templating
parent b6d112f8
......@@ -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 {
......
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