From a35ed05bc3976b3808d84373a59a6e66255d40eb Mon Sep 17 00:00:00 2001 From: Torkel Odegaard Date: Tue, 11 Feb 2014 20:58:51 +0100 Subject: [PATCH] Closes #54, template/filter can now use "All", when all is not a wildcard but the specific metric segments specified in the filter query. --- src/app/panels/filtering/module.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/panels/filtering/module.js b/src/app/panels/filtering/module.js index 51b5a8e224e..f0d69040029 100644 --- a/src/app/panels/filtering/module.js +++ b/src/app/panels/filtering/module.js @@ -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