Commit 490141da by Mitsuhiro Tanda

(cloudwatch) expand multi select template variable

parent 6e4ed4de
......@@ -23,6 +23,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
var queries = [];
options = angular.copy(options);
options.targets = this.expandTemplateVariable(options.targets);
_.each(options.targets, function(target) {
if (target.hide || !target.namespace || !target.metricName || _.isEmpty(target.statistics)) {
return;
......@@ -337,6 +338,36 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
});
}
this.expandTemplateVariable = function(targets) {
return _.chain(targets)
.map(function(target) {
var dimensionKey = null;
var variableName = null;
_.each(target.dimensions, function(v, k) {
if (templateSrv.variableExists(v)) {
dimensionKey = k;
variableName = v;
}
});
if (dimensionKey) {
var variable = _.find(templateSrv.variables, function(variable) {
return templateSrv.containsVariable(variableName, variable.name);
});
return _.chain(variable.options)
.filter(function(v) {
return v.selected;
})
.map(function(v) {
var t = angular.copy(target);
t.dimensions[dimensionKey] = v.value;
return t;
}).value();
} else {
return [target];
}
}).flatten().value();
};
this.convertToCloudWatchTime = function(date, roundUp) {
if (_.isString(date)) {
date = dateMath.parse(date, roundUp);
......
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