Commit a35ed05b by Torkel Odegaard

Closes #54, template/filter can now use "All", when all is not a wildcard but…

Closes #54, template/filter can now use "All", when all is not a wildcard but the specific metric segments specified in the filter query.
parent e5743144
......@@ -41,8 +41,19 @@ function (angular, app, _) {
filter.options = _.map(results, function(node) {
return { text: node.text, value: node.text };
});
if (filter.includeAll) {
filter.options.unshift({text: 'All', value: '*'});
if(endsWithWildcard(filter.query)) {
filter.options.unshift({text: 'All', value: '*'});
}
else {
var allExpr = '{';
_.each(filter.options, function(option) {
allExpr += option.text + ',';
});
allExpr = allExpr.substring(0, allExpr.length - 1) + '}';
filter.options.unshift({text: 'All', value: allExpr});
}
}
filterSrv.filterOptionSelected(filter, filter.options[0]);
......@@ -66,5 +77,13 @@ function (angular, app, _) {
$rootScope.$broadcast('render');
};
function endsWithWildcard(query) {
if (query.length === 0) {
return false;
}
return query[query.length - 1] === '*';
}
});
});
\ No newline at end of file
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