فهرست منبع

Added an option for the hits panel to receive its counter from the histogram panel

Rashid Khan 13 سال پیش
والد
کامیت
47bc78c7f7
3فایلهای تغییر یافته به همراه24 افزوده شده و 6 حذف شده
  1. 4 1
      panels/histogram/module.js
  2. 9 3
      panels/hits/editor.html
  3. 11 2
      panels/hits/module.js

+ 4 - 1
panels/histogram/module.js

@@ -86,13 +86,15 @@ angular.module('kibana.histogram', [])
     // Populate scope when we have results
     results.then(function(results) {
       $scope.panel.loading = false;
-      $scope.hits = results.hits.total;
       if(_segment == 0) {
+        $scope.hits = 0;
         $scope.data = [];
         query_id = $scope.query_id = new Date().getTime();
       }
       
       if($scope.query_id === query_id) {
+        $scope.hits += results.hits.total;
+
         _.each(results.facets, function(v, k) {
           // Null values at each end of the time range ensure we see entire range
           if(_.isUndefined($scope.data[k]) || _segment == 0) {
@@ -122,6 +124,7 @@ angular.module('kibana.histogram', [])
           $scope.data[k] = series.data
         });
 
+        eventBus.broadcast($scope.$id,$scope.panel.group,'hits',$scope.hits)
         $scope.$emit('render')
         if(_segment < $scope.panel.index.length-1) {
           $scope.get_data(_segment+1,query_id)

+ 9 - 3
panels/hits/editor.html

@@ -1,11 +1,17 @@
   <div class="row-fluid" ng-controller="hits">
-    <div class="span11">
-    The hits panel shows a simple count of how many records match your filtered query. If multiple queries are sent from a single panel the <strong>first query will be displayed</strong>
+    <div class="span2"> 
+      <label class="small">Run Query</label><input type="checkbox" ng-model="panel.run_query" ng-checked="panel.run_query">
+    </div>
+    <div class="span9" ng-show='!panel.run_query'>
+      With query running disabled, this panel receives its hit count from a histogram panel. If multiple queries are running this <strong>will show the total of all queries</strong>.
+    </div>
+    <div class="span9" ng-show='panel.run_query'>
+      This shows a simple count of how many records match your filtered query. If multiple queries are sent from a single panel the <strong>first query will be displayed</strong>
     </div>
   </div>
 
   <div class="row-fluid">    
-    <div class="span9">
+    <div class="span9" ng-show='panel.run_query'>
       <form class="input-append">
         <h6>Query</h6>
         <input type="text" style="width:85%" ng-model="panel.query">

+ 11 - 2
panels/hits/module.js

@@ -6,15 +6,24 @@ angular.module('kibana.hits', [])
     query   : "*",
     group   : "default",
     style   : { "font-size": '36pt', "font-weight": "bold" },
+    run_query : false
   }
   _.defaults($scope.panel,_d)
 
   $scope.init = function () {
-    eventBus.register($scope,'time', function(event,time){set_time(time)});
+    $scope.hits = 0;
+    eventBus.register($scope,'time', function(event,time){
+      if($scope.panel.run_query)
+        set_time(time)
+    });
     eventBus.register($scope,'query', function(event, query) {
       $scope.panel.query = _.isArray(query) ? query[0] : query;
-      $scope.get_data();
+      if($scope.panel.run_query)
+        $scope.get_data();
     });
+    eventBus.register($scope,'hits', function(event, hits) {
+      $scope.hits = hits;
+    })
     // Now that we're all setup, request the time from our group
     eventBus.broadcast($scope.$id,$scope.panel.group,'get_time')
   }