소스 검색

Closes #54, template/filter can now use "All", when all is not a wildcard but the specific metric segments specified in the filter query.

Torkel Odegaard 12 년 전
부모
커밋
a35ed05bc3
1개의 변경된 파일20개의 추가작업 그리고 1개의 파일을 삭제
  1. 20 1
      src/app/panels/filtering/module.js

+ 20 - 1
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] === '*';
+    }
+
   });
 });