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) { ...@@ -358,9 +358,15 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) {
} }
this.getExpandedVariables = function(target, dimensionKey, variable) { 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) return _.chain(variable.options)
.filter(function(v) { .filter(function(v) {
return v.selected; if (allSelected) {
return v.text !== 'All';
} else {
return v.selected;
}
}) })
.map(function(v) { .map(function(v) {
var t = angular.copy(target); var t = angular.copy(target);
...@@ -369,6 +375,10 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) { ...@@ -369,6 +375,10 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) {
}).value(); }).value();
}; };
this.containsVariable = function (str, variableName) {
return str.indexOf('$' + variableName) !== -1;
};
this.expandTemplateVariable = function(targets, templateSrv) { this.expandTemplateVariable = function(targets, templateSrv) {
var self = this; var self = this;
return _.chain(targets) return _.chain(targets)
...@@ -379,7 +389,7 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) { ...@@ -379,7 +389,7 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) {
if (dimensionKey) { if (dimensionKey) {
var variable = _.find(templateSrv.variables, function(variable) { 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); return self.getExpandedVariables(target, dimensionKey, variable);
} else { } 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