Prechádzať zdrojové kódy

Added support for broadcasting an array of queries, added multi query support to stringquery panel

Rashid Khan 13 rokov pred
rodič
commit
ce5273b7df

+ 16 - 0
js/directives.js

@@ -66,5 +66,21 @@ angular.module('kibana.directives', [])
       }
       }
     }
     }
   }
   }
+}).directive('ngModelOnblur', function() {
+  return {
+    restrict: 'A',
+    require: 'ngModel',
+    link: function(scope, elm, attr, ngModelCtrl) {
+      if (attr.type === 'radio' || attr.type === 'checkbox') return;
+      
+      elm.unbind('input').unbind('keydown').unbind('change');
+      elm.bind('blur', function() {
+        scope.$apply(function() {
+          ngModelCtrl.$setViewValue(elm.val());
+        });         
+      });
+    }
+  };
 });
 });
+;
 
 

+ 0 - 2
panels/dashcontrol/module.js

@@ -1,8 +1,6 @@
 angular.module('kibana.dashcontrol', [])
 angular.module('kibana.dashcontrol', [])
 .controller('dashcontrol', function($scope, $http, eventBus, timer) {
 .controller('dashcontrol', function($scope, $http, eventBus, timer) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     group   : "default",
     group   : "default",

+ 0 - 2
panels/fields/module.js

@@ -1,8 +1,6 @@
 angular.module('kibana.fields', [])
 angular.module('kibana.fields', [])
 .controller('fields', function($scope, eventBus, $timeout) {
 .controller('fields', function($scope, eventBus, $timeout) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     group   : "default",
     group   : "default",

+ 7 - 3
panels/histogram/module.js

@@ -1,8 +1,6 @@
 angular.module('kibana.histogram', [])
 angular.module('kibana.histogram', [])
 .controller('histogram', function($scope, eventBus) {
 .controller('histogram', function($scope, eventBus) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     query   : [ {query: "*", label:"Query"} ],
     query   : [ {query: "*", label:"Query"} ],
@@ -17,7 +15,13 @@ angular.module('kibana.histogram', [])
   $scope.init = function() {
   $scope.init = function() {
     eventBus.register($scope,'time', function(event,time){set_time(time)});
     eventBus.register($scope,'time', function(event,time){set_time(time)});
     eventBus.register($scope,'query', function(event, query) {
     eventBus.register($scope,'query', function(event, query) {
-      $scope.panel.query[0].query = query;
+      if(_.isArray(query)) {
+        $scope.panel.query = _.map(query,function(q) {
+          return {query: q, label: q};
+        })
+      } else {
+        $scope.panel.query[0] = {query: query, label: query}
+      }
       $scope.get_data();
       $scope.get_data();
     });
     });
     // Now that we're all setup, request the time from our group if we don't 
     // Now that we're all setup, request the time from our group if we don't 

+ 6 - 0
panels/hits/editor.html

@@ -1,3 +1,9 @@
+  <div class="row-fluid">
+    <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>
+  </div>
+
   <div class="row-fluid">    
   <div class="row-fluid">    
     <div class="span9">
     <div class="span9">
       <form class="input-append">
       <form class="input-append">

+ 1 - 3
panels/hits/module.js

@@ -1,8 +1,6 @@
 angular.module('kibana.hits', [])
 angular.module('kibana.hits', [])
 .controller('hits', function($scope, eventBus) {
 .controller('hits', function($scope, eventBus) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     query   : "*",
     query   : "*",
@@ -14,7 +12,7 @@ angular.module('kibana.hits', [])
   $scope.init = function () {
   $scope.init = function () {
     eventBus.register($scope,'time', function(event,time){set_time(time)});
     eventBus.register($scope,'time', function(event,time){set_time(time)});
     eventBus.register($scope,'query', function(event, query) {
     eventBus.register($scope,'query', function(event, query) {
-      $scope.panel.query = query;
+      $scope.panel.query = _.isArray(query) ? query[0] : query;
       $scope.get_data();
       $scope.get_data();
     });
     });
     // Now that we're all setup, request the time from our group
     // Now that we're all setup, request the time from our group

+ 6 - 0
panels/map/editor.html

@@ -1,3 +1,9 @@
+  <div class="row-fluid">
+    <div class="span11">
+    The map panel uses 2 letter country or US state codes to plot concentrations on a map. Darker terroritories mean more records matched that area. 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="row-fluid">    
     <div class="span6">
     <div class="span6">
       <form class="input-append">
       <form class="input-append">

+ 1 - 3
panels/map/module.js

@@ -1,8 +1,6 @@
 angular.module('kibana.map', [])
 angular.module('kibana.map', [])
 .controller('map', function($scope, eventBus) {
 .controller('map', function($scope, eventBus) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     query   : "*",
     query   : "*",
@@ -17,7 +15,7 @@ angular.module('kibana.map', [])
   $scope.init = function() {
   $scope.init = function() {
     eventBus.register($scope,'time', function(event,time){set_time(time)});
     eventBus.register($scope,'time', function(event,time){set_time(time)});
     eventBus.register($scope,'query', function(event, query) {
     eventBus.register($scope,'query', function(event, query) {
-      $scope.panel.query = query;
+      $scope.panel.query = _.isArray(query) ? query[0] : query;
       $scope.get_data();
       $scope.get_data();
     });
     });
     // Now that we're all setup, request the time from our group
     // Now that we're all setup, request the time from our group

+ 8 - 2
panels/pie/module.js

@@ -1,8 +1,6 @@
 angular.module('kibana.pie', [])
 angular.module('kibana.pie', [])
 .controller('pie', function($scope, eventBus) {
 .controller('pie', function($scope, eventBus) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     query   : { field:"_all", query:"*", goal: 1}, 
     query   : { field:"_all", query:"*", goal: 1}, 
@@ -23,8 +21,16 @@ angular.module('kibana.pie', [])
     eventBus.register($scope,'query', function(event, query) {
     eventBus.register($scope,'query', function(event, query) {
       if($scope.panel.mode !== 'query') {
       if($scope.panel.mode !== 'query') {
         $scope.panel.query.query = query;
         $scope.panel.query.query = query;
+        $scope.panel.query.query = _.isArray(query) ? query[0] : query;
         $scope.get_data();
         $scope.get_data();
+      } else {
+        if(_.isArray(query))
+          $scope.panel.query = _.map(query,function(q) {
+            return {query: q, label: q}}) 
+        else
+          $scope.panel.query[0] = {query: query, label: query}
       }
       }
+      $scope.get_data();
     });
     });
     // Now that we're all setup, request the time from our group
     // Now that we're all setup, request the time from our group
     eventBus.broadcast($scope.$id,$scope.panel.group,'get_time')
     eventBus.broadcast($scope.$id,$scope.panel.group,'get_time')

+ 0 - 4
panels/sort/module.js

@@ -1,13 +1,9 @@
 angular.module('kibana.sort', [])
 angular.module('kibana.sort', [])
 .controller('sort', function($scope, eventBus) {
 .controller('sort', function($scope, eventBus) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     label   : "Sort",
     label   : "Sort",
-    query   : "*",
-    size    : 100,
     sort    : [config.timefield,'desc'],
     sort    : [config.timefield,'desc'],
     group   : "default"
     group   : "default"
   }
   }

+ 9 - 0
panels/stringquery/editor.html

@@ -0,0 +1,9 @@
+<div class="row-fluid">    
+  <div class="span3">
+    <label class="small">Allow Mulitple</label><input type="checkbox" ng-model="panel.multi" ng-checked="panel.multi">
+  </div>
+  <div class="span4" ng-show="panel.multi">
+    <label class="small">Multiquery Arrangement</label> 
+    <select class="input-medium" ng-model="panel.multi_arrange" ng-options="f for f in ['vertical','horizontal']"></select>
+  </div>
+</div>

+ 24 - 7
panels/stringquery/module.html

@@ -1,9 +1,26 @@
 <kibana-panel ng-controller='stringquery'>
 <kibana-panel ng-controller='stringquery'>
-  <form class="input-append" style="margin-bottom:0px; width:100%; white-space:nowrap;">
-    <label><small>{{panel.label}}</small></label>
-    <input type="text" ng-model="panel.query" style="width:85%">
-    <button type="submit" class="btn btn-info" ng-click="send_query(panel.query)"><i class="icon-search"></i></button>
-    <button type="submit" class="btn btn-danger" ng-click="panel.query='';send_query(panel.query)"><i class="icon-ban-circle"></i></button>
-
-  </form>
+  <div ng-switch="_.isArray(panel.query)">
+    <div ng-switch-when="false">
+      <form class="input-append" style="margin-bottom:0px; width:100%; white-space:nowrap;">
+        <label><small>{{panel.label}}</small></label>
+        <input type="text" ng-model="panel.query" style="width:85%">
+        <button type="submit" class="btn btn-info" ng-click="send_query(panel.query)"><i class="icon-search"></i></button>
+        <button type="submit" class="btn btn-danger" ng-click="panel.query='';send_query(panel.query)"><i class="icon-ban-circle"></i></button>
+        <button ng-show="panel.multi" type="submit" class="btn" ng-click="add_query()"><i class="icon-plus"></i></button>
+      </form>
+    </div>
+    <div ng-switch-when="true">
+        <form ng-class="{form-inline: panel.multi_arrange == 'horizontal'}" style="width:100%;" >        
+          <span ng-repeat="q in panel.query">
+            <span class="input-append" style="margin-bottom:0px;margin-right:5px">
+              <button class="btn btn-danger" type="submit" style="width:50px;margin-left:-50px;visibility:hidden"></button>
+              <input style="margin-bottom:5px;" type="text"  ng-model="panel.query[$index]" ng-model-onblur style="width:90%">
+              <button class="btn btn-danger" ng-show="panel.query.length > 1" ng-click="remove_query($index);send_query(panel.query)"><i class="icon-minus"></i></button><br>
+            </span><br style:"height:0px" ng-show="panel.multi_arrange == 'vertical'">
+          </span>
+        </form>
+      <button type="submit" class="btn btn-info" ng-click="send_query(panel.query)"><i class="icon-search"></i> Search</button>
+      <button type="submit" class="btn" ng-click="send_query(panel.query);add_query();"><i class="icon-plus"></i> Add Query</button>
+    </div>
+  </div>
 </kibana-panel>
 </kibana-panel>

+ 21 - 7
panels/stringquery/module.js

@@ -1,15 +1,15 @@
 angular.module('kibana.stringquery', [])
 angular.module('kibana.stringquery', [])
 .controller('stringquery', function($scope, eventBus) {
 .controller('stringquery', function($scope, eventBus) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     label   : "Search",
     label   : "Search",
     query   : "*",
     query   : "*",
     size    : 100,
     size    : 100,
     sort    : [config.timefield,'desc'],
     sort    : [config.timefield,'desc'],
-    group   : "default"
+    group   : "default",
+    multi   : false,
+    multi_arrange: 'horizontal',
   }
   }
   _.defaults($scope.panel,_d);
   _.defaults($scope.panel,_d);
 
 
@@ -19,11 +19,25 @@ angular.module('kibana.stringquery', [])
   $scope.init = function() {
   $scope.init = function() {
     eventBus.register($scope,'query',function(event,query) {
     eventBus.register($scope,'query',function(event,query) {
       $scope.panel.query = query;
       $scope.panel.query = query;
-    });
+    });   
+  }
+
+  $scope.send_query = function(query) {
+    eventBus.broadcast($scope.$id,$scope.panel.group,'query',query)
+  }
+
+  $scope.add_query = function() {
+    if (_.isArray($scope.panel.query))
+      $scope.panel.query.push("")
+    else {
+      $scope.panel.query = new Array($scope.panel.query)
+      $scope.panel.query.push("")
+    }
+  } 
 
 
-    $scope.send_query = function(query) {
-      eventBus.broadcast($scope.$id,$scope.panel.group,'query',query)
-    }    
+  $scope.remove_query = function(index) {
+    $scope.panel.query.splice(index,1);
   }
   }
+
   $scope.init();
   $scope.init();
 });
 });

+ 1 - 3
panels/table/module.js

@@ -1,8 +1,6 @@
 angular.module('kibana.table', [])
 angular.module('kibana.table', [])
 .controller('table', function($scope, eventBus) {
 .controller('table', function($scope, eventBus) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     query   : "*",
     query   : "*",
@@ -29,7 +27,7 @@ angular.module('kibana.table', [])
     });
     });
     eventBus.register($scope,'query',function(event,query) {
     eventBus.register($scope,'query',function(event,query) {
       $scope.panel.offset = 0;
       $scope.panel.offset = 0;
-      $scope.panel.query = query;
+      $scope.panel.query = _.isArray(query) ? query[0] : query;
       $scope.get_data();
       $scope.get_data();
     });
     });
     eventBus.register($scope,'sort', function(event,sort){
     eventBus.register($scope,'sort', function(event,sort){

+ 0 - 2
panels/text/module.js

@@ -1,8 +1,6 @@
 angular.module('kibana.text', [])
 angular.module('kibana.text', [])
 .controller('text', function($scope, $rootScope) {
 .controller('text', function($scope, $rootScope) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     group   : "default",
     group   : "default",

+ 0 - 2
panels/timepicker/module.js

@@ -26,8 +26,6 @@ a pattern
 angular.module('kibana.timepicker', [])
 angular.module('kibana.timepicker', [])
 .controller('timepicker', function($scope, eventBus, $timeout, timer, $http) {
 .controller('timepicker', function($scope, eventBus, $timeout, timer, $http) {
 
 
-  var _id = _.uniqueId();
-
   // Set and populate defaults
   // Set and populate defaults
   var _d = {
   var _d = {
     mode          : "relative",
     mode          : "relative",