From ce5273b7df18423c8138ca2cd4b4f775629fa37a Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Thu, 21 Feb 2013 15:26:48 -0700 Subject: [PATCH] Added support for broadcasting an array of queries, added multi query support to stringquery panel --- js/directives.js | 16 ++++++++++++++++ panels/dashcontrol/module.js | 2 -- panels/fields/module.js | 2 -- panels/histogram/module.js | 10 +++++++--- panels/hits/editor.html | 6 ++++++ panels/hits/module.js | 4 +--- panels/map/editor.html | 6 ++++++ panels/map/module.js | 4 +--- panels/pie/module.js | 10 ++++++++-- panels/sort/module.js | 4 ---- panels/stringquery/editor.html | 9 +++++++++ panels/stringquery/module.html | 31 ++++++++++++++++++++++++------- panels/stringquery/module.js | 30 ++++++++++++++++++++++-------- panels/table/module.js | 4 +--- panels/text/module.js | 2 -- panels/timepicker/module.js | 2 -- 16 files changed, 101 insertions(+), 41 deletions(-) create mode 100644 panels/stringquery/editor.html diff --git a/js/directives.js b/js/directives.js index 720403ca62c..c5c09f0ad39 100644 --- a/js/directives.js +++ b/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()); + }); + }); + } + }; }); +; diff --git a/panels/dashcontrol/module.js b/panels/dashcontrol/module.js index 3f604298972..4edbd8b882e 100644 --- a/panels/dashcontrol/module.js +++ b/panels/dashcontrol/module.js @@ -1,8 +1,6 @@ angular.module('kibana.dashcontrol', []) .controller('dashcontrol', function($scope, $http, eventBus, timer) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { group : "default", diff --git a/panels/fields/module.js b/panels/fields/module.js index 534ef8e5cd4..334f964eee6 100644 --- a/panels/fields/module.js +++ b/panels/fields/module.js @@ -1,8 +1,6 @@ angular.module('kibana.fields', []) .controller('fields', function($scope, eventBus, $timeout) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { group : "default", diff --git a/panels/histogram/module.js b/panels/histogram/module.js index 5d5b163959a..6fe930ce034 100644 --- a/panels/histogram/module.js +++ b/panels/histogram/module.js @@ -1,8 +1,6 @@ angular.module('kibana.histogram', []) .controller('histogram', function($scope, eventBus) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { query : [ {query: "*", label:"Query"} ], @@ -17,7 +15,13 @@ angular.module('kibana.histogram', []) $scope.init = function() { eventBus.register($scope,'time', function(event,time){set_time(time)}); 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(); }); // Now that we're all setup, request the time from our group if we don't diff --git a/panels/hits/editor.html b/panels/hits/editor.html index 3d1852ed454..437e7a16dd4 100644 --- a/panels/hits/editor.html +++ b/panels/hits/editor.html @@ -1,3 +1,9 @@ +
+
+ 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 first query will be displayed +
+
+
diff --git a/panels/hits/module.js b/panels/hits/module.js index 3d622e7888f..f78480df03b 100644 --- a/panels/hits/module.js +++ b/panels/hits/module.js @@ -1,8 +1,6 @@ angular.module('kibana.hits', []) .controller('hits', function($scope, eventBus) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { query : "*", @@ -14,7 +12,7 @@ angular.module('kibana.hits', []) $scope.init = function () { eventBus.register($scope,'time', function(event,time){set_time(time)}); eventBus.register($scope,'query', function(event, query) { - $scope.panel.query = query; + $scope.panel.query = _.isArray(query) ? query[0] : query; $scope.get_data(); }); // Now that we're all setup, request the time from our group diff --git a/panels/map/editor.html b/panels/map/editor.html index ef8762d7f50..b83a614b290 100644 --- a/panels/map/editor.html +++ b/panels/map/editor.html @@ -1,3 +1,9 @@ +
+
+ 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 first query will be displayed +
+
+
diff --git a/panels/map/module.js b/panels/map/module.js index 284c44983f2..dd9b69130a2 100644 --- a/panels/map/module.js +++ b/panels/map/module.js @@ -1,8 +1,6 @@ angular.module('kibana.map', []) .controller('map', function($scope, eventBus) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { query : "*", @@ -17,7 +15,7 @@ angular.module('kibana.map', []) $scope.init = function() { eventBus.register($scope,'time', function(event,time){set_time(time)}); eventBus.register($scope,'query', function(event, query) { - $scope.panel.query = query; + $scope.panel.query = _.isArray(query) ? query[0] : query; $scope.get_data(); }); // Now that we're all setup, request the time from our group diff --git a/panels/pie/module.js b/panels/pie/module.js index a2051c5a3f3..34c3c789a0a 100644 --- a/panels/pie/module.js +++ b/panels/pie/module.js @@ -1,8 +1,6 @@ angular.module('kibana.pie', []) .controller('pie', function($scope, eventBus) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { query : { field:"_all", query:"*", goal: 1}, @@ -23,8 +21,16 @@ angular.module('kibana.pie', []) eventBus.register($scope,'query', function(event, query) { if($scope.panel.mode !== 'query') { $scope.panel.query.query = query; + $scope.panel.query.query = _.isArray(query) ? query[0] : query; $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 eventBus.broadcast($scope.$id,$scope.panel.group,'get_time') diff --git a/panels/sort/module.js b/panels/sort/module.js index 6c7c32c050c..8498a4d9031 100644 --- a/panels/sort/module.js +++ b/panels/sort/module.js @@ -1,13 +1,9 @@ angular.module('kibana.sort', []) .controller('sort', function($scope, eventBus) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { label : "Sort", - query : "*", - size : 100, sort : [config.timefield,'desc'], group : "default" } diff --git a/panels/stringquery/editor.html b/panels/stringquery/editor.html new file mode 100644 index 00000000000..cd49fe50794 --- /dev/null +++ b/panels/stringquery/editor.html @@ -0,0 +1,9 @@ +
+
+ +
+
+ + +
+
\ No newline at end of file diff --git a/panels/stringquery/module.html b/panels/stringquery/module.html index 1cb9265e616..0e15bdda015 100644 --- a/panels/stringquery/module.html +++ b/panels/stringquery/module.html @@ -1,9 +1,26 @@ - - - - - - - +
+
+
+ + + + + +
+
+
+
+ + + + +
+

+
+
+ + +
+
\ No newline at end of file diff --git a/panels/stringquery/module.js b/panels/stringquery/module.js index 4d205ad8ad9..e289e51afbf 100644 --- a/panels/stringquery/module.js +++ b/panels/stringquery/module.js @@ -1,15 +1,15 @@ angular.module('kibana.stringquery', []) .controller('stringquery', function($scope, eventBus) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { label : "Search", query : "*", size : 100, sort : [config.timefield,'desc'], - group : "default" + group : "default", + multi : false, + multi_arrange: 'horizontal', } _.defaults($scope.panel,_d); @@ -19,11 +19,25 @@ angular.module('kibana.stringquery', []) $scope.init = function() { eventBus.register($scope,'query',function(event,query) { $scope.panel.query = query; - }); - - $scope.send_query = function(query) { - eventBus.broadcast($scope.$id,$scope.panel.group,'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.remove_query = function(index) { + $scope.panel.query.splice(index,1); + } + $scope.init(); }); \ No newline at end of file diff --git a/panels/table/module.js b/panels/table/module.js index 8c7313b243b..d59a983b591 100644 --- a/panels/table/module.js +++ b/panels/table/module.js @@ -1,8 +1,6 @@ angular.module('kibana.table', []) .controller('table', function($scope, eventBus) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { query : "*", @@ -29,7 +27,7 @@ angular.module('kibana.table', []) }); eventBus.register($scope,'query',function(event,query) { $scope.panel.offset = 0; - $scope.panel.query = query; + $scope.panel.query = _.isArray(query) ? query[0] : query; $scope.get_data(); }); eventBus.register($scope,'sort', function(event,sort){ diff --git a/panels/text/module.js b/panels/text/module.js index d7c20e5bba9..b08d629a534 100644 --- a/panels/text/module.js +++ b/panels/text/module.js @@ -1,8 +1,6 @@ angular.module('kibana.text', []) .controller('text', function($scope, $rootScope) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { group : "default", diff --git a/panels/timepicker/module.js b/panels/timepicker/module.js index f72cfe9249d..d20676634d3 100644 --- a/panels/timepicker/module.js +++ b/panels/timepicker/module.js @@ -26,8 +26,6 @@ a pattern angular.module('kibana.timepicker', []) .controller('timepicker', function($scope, eventBus, $timeout, timer, $http) { - var _id = _.uniqueId(); - // Set and populate defaults var _d = { mode : "relative",