From 0723ad57b7ce7999696732a3467ad7af12b417f5 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Tue, 23 Jul 2013 17:22:27 -0700 Subject: [PATCH] Added query to selector to every panel where it makes sense --- js/controllers.js | 4 ++-- js/services.js | 14 ++++++++++++++ js/shared.js | 12 ++++++++++++ panels/bettermap/editor.html | 1 + panels/bettermap/module.js | 16 ++++++++++------ panels/column/panelgeneral.html | 3 --- panels/filtering/module.html | 12 +++++++++--- panels/filtering/module.js | 4 +--- panels/histogram/editor.html | 9 +++------ panels/histogram/module.html | 18 +++++++++--------- panels/histogram/module.js | 32 ++++++++++++-------------------- panels/hits/editor.html | 1 + panels/hits/module.js | 20 ++++++++------------ panels/map/editor.html | 1 + panels/map/module.js | 14 ++++++++------ panels/pie/editor.html | 1 + panels/pie/module.html | 4 ++-- panels/pie/module.js | 18 ++++++++++++++---- panels/query/module.html | 6 +++--- panels/query/module.js | 2 +- panels/table/editor.html | 1 + panels/table/module.js | 13 ++++++++----- panels/text/module.js | 4 +++- panels/trends/editor.html | 1 + panels/trends/module.js | 21 ++++++++++----------- partials/paneleditor.html | 4 ++-- partials/querySelect.html | 11 +++++++++-- 27 files changed, 146 insertions(+), 101 deletions(-) diff --git a/js/controllers.js b/js/controllers.js index 2ea1be3aa1c..c6195b273fa 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -23,7 +23,6 @@ angular.module('kibana.controllers', []) $scope.config = config; // Make underscore.js available to views $scope._ = _; - $scope.dashboard = dashboard; // Provide a global list of all see fields @@ -89,7 +88,7 @@ angular.module('kibana.controllers', []) $scope.init(); }) -.controller('RowCtrl', function($scope, $rootScope, $timeout, ejsResource) { +.controller('RowCtrl', function($scope, $rootScope, $timeout, ejsResource, querySrv) { var _d = { title: "Row", @@ -104,6 +103,7 @@ angular.module('kibana.controllers', []) $scope.init = function() { + $scope.querySrv = querySrv; $scope.reset_panel(); }; diff --git a/js/services.js b/js/services.js index f6cd7495092..7cf83ccfbd4 100644 --- a/js/services.js +++ b/js/services.js @@ -289,6 +289,20 @@ angular.module('kibana.services', []) return _.findWhere(self.list,{query:queryString}); }; + this.idsByMode = function(config) { + switch(config.mode) + { + case 'all': + return self.ids; + case 'pinned': + return _.pluck(_.where(self.list,{pin:true}),'id'); + case 'selected': + return _.intersection(self.ids,config.ids); + default: + return self.ids; + } + }; + var nextId = function() { if(_q.idQueue.length > 0) { return _q.idQueue.shift(); diff --git a/js/shared.js b/js/shared.js index fe7c553fc33..91e457bb982 100644 --- a/js/shared.js +++ b/js/shared.js @@ -343,3 +343,15 @@ _.mixin({ return array; } }); + +_.mixin({ + toggleInOut: function(array,value) { + 'use strict'; + if(_.contains(array,value)) { + array = _.without(array,value); + } else { + array.push(value); + } + return array; + } +}); diff --git a/panels/bettermap/editor.html b/panels/bettermap/editor.html index d2ebb3e7ac5..963801de903 100644 --- a/panels/bettermap/editor.html +++ b/panels/bettermap/editor.html @@ -22,6 +22,7 @@ +
Panel Spy
diff --git a/panels/bettermap/module.js b/panels/bettermap/module.js index 9e7020e3b97..75e1f2781d1 100644 --- a/panels/bettermap/module.js +++ b/panels/bettermap/module.js @@ -6,11 +6,10 @@ ## Better maps So the cavaet for this panel is that, for better or worse, it does NOT use the terms facet and it - DOES query sequentially. This however means that + DOES query sequentially. This however means that it transfer more data and is generally heavier + to computer, while showing less actual data ### Parameters - * query :: A single query string, not and array. This panel can only handle one - query at a time. * size :: How many results to show, more results = slower * field :: field containing a 2 element array in the format [lon,lat] * tooltip :: field to extract the tool tip value from @@ -25,7 +24,10 @@ angular.module('kibana.bettermap', []) // Set and populate defaults var _d = { status : "Experimental", - query : "*", + queries : { + mode : 'all', + ids : [] + }, size : 1000, spyable : true, tooltip : "_id", @@ -66,9 +68,11 @@ angular.module('kibana.bettermap', []) var _segment = _.isUndefined(segment) ? 0 : segment; + $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); + // This could probably be changed to a BoolFilter var boolQuery = $scope.ejs.BoolQuery(); - _.each(querySrv.list,function(q) { - boolQuery = boolQuery.should(querySrv.toEjsObj(q)); + _.each($scope.panel.queries.ids,function(id) { + boolQuery = boolQuery.should(querySrv.getEjsObj(id)); }); var request = $scope.ejs.Request().indices(dashboard.indices[_segment]) diff --git a/panels/column/panelgeneral.html b/panels/column/panelgeneral.html index 404499b7828..b952c1e0363 100644 --- a/panels/column/panelgeneral.html +++ b/panels/column/panelgeneral.html @@ -2,9 +2,6 @@
-
- -
diff --git a/panels/filtering/module.html b/panels/filtering/module.html index 3a79da21326..45956494304 100644 --- a/panels/filtering/module.html +++ b/panels/filtering/module.html @@ -8,16 +8,22 @@ vertical-align: top; margin-left: 10px; width: 200px; - padding: 5px; + padding: 5px 5px 0px 5px; border: #555 1px solid; margin: 0px 5px 5px 0px; } + .filter-panel-filter ul { + margin-bottom: 3px; + } .filter-must { border-bottom: #7EB26D 3px solid; } .filter-mustNot { border-bottom: #E24D42 3px solid; } + .filter-deselected { + opacity: 0.5; + } .filter-either { border-bottom: #EF843C 3px solid; } @@ -34,8 +40,8 @@
-
-
+
+
{{filterSrv.list[id].type}} {{filterSrv.list[id].mandate}} diff --git a/panels/filtering/module.js b/panels/filtering/module.js index 7f3595667e5..00a0b6f46ea 100644 --- a/panels/filtering/module.js +++ b/panels/filtering/module.js @@ -6,8 +6,6 @@ An experimental for interacting with the filter service - ### Parameters - */ 'use strict'; @@ -17,7 +15,7 @@ angular.module('kibana.filtering', []) // Set and populate defaults var _d = { - status : "Experimental" + status : "Beta" }; _.defaults($scope.panel,_d); diff --git a/panels/histogram/editor.html b/panels/histogram/editor.html index 7e3b6e4f52c..89c330545d0 100644 --- a/panels/histogram/editor.html +++ b/panels/histogram/editor.html @@ -1,27 +1,23 @@
-
+
-
-
-
-
In {{panel.mode}} mode the configured field must be a numeric type
-
Chart Options
+
Chart Settings
@@ -64,6 +60,7 @@
+
Panel Spy
diff --git a/panels/histogram/module.html b/panels/histogram/module.html index b8ce6893374..4abffa5bca6 100644 --- a/panels/histogram/module.html +++ b/panels/histogram/module.html @@ -21,15 +21,15 @@
- - - Zoom Out | - - - - {{series.info.alias}} ({{series.hits}}) - - {{panel.value_field}} {{panel.mode}} per {{panel.interval}} | ({{hits}} hits) + + + Zoom Out | + + + + {{series.info.alias}} ({{series.hits}}) + + {{panel.value_field}} {{panel.mode}} per {{panel.interval}} | ({{hits}} hits)
diff --git a/panels/histogram/module.js b/panels/histogram/module.js index ade19af47e8..4752d8c31ab 100644 --- a/panels/histogram/module.js +++ b/panels/histogram/module.js @@ -10,9 +10,6 @@ yeah, you should know that it uses facetting. It should be pretty safe. ### Parameters - * query :: an array of objects as such: {query: 'somequery', label 'legent text'}. - this is usually populated by a stringquery panel wher the query and label - parameter are the same * auto_int :: Auto calculate data point interval? * resolution :: If auto_int is enables, shoot for this many data points, rounding to sane intervals @@ -46,10 +43,12 @@ angular.module('kibana.histogram', []) // Set and populate defaults var _d = { status : "Stable", - group : "default", mode : 'count', time_field : '@timestamp', - queries : [], + queries : { + mode : 'all', + ids : [] + }, value_field : null, auto_int : true, resolution : 100, @@ -69,12 +68,10 @@ angular.module('kibana.histogram', []) percentage : false, interactive : true, }; + _.defaults($scope.panel,_d); $scope.init = function() { - - $scope.querySrv = querySrv; - $scope.$on('refresh',function(){ $scope.get_data(); }); @@ -91,6 +88,7 @@ angular.module('kibana.histogram', []) return; } + var _range = $scope.range = filterSrv.timeRange('min'); if ($scope.panel.auto_int) { @@ -102,8 +100,9 @@ angular.module('kibana.histogram', []) var _segment = _.isUndefined(segment) ? 0 : segment; var request = $scope.ejs.Request().indices(dashboard.indices[_segment]); + $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); // Build the query - _.each(querySrv.ids, function(id) { + _.each($scope.panel.queries.ids, function(id) { var query = $scope.ejs.FilteredQuery( querySrv.getEjsObj(id), filterSrv.getBoolFilter(filterSrv.ids) @@ -132,7 +131,6 @@ angular.module('kibana.histogram', []) // Populate scope when we have results results.then(function(results) { - $scope.panel.loading = false; if(_segment === 0) { $scope.hits = 0; @@ -151,13 +149,13 @@ angular.module('kibana.histogram', []) // Make sure we're still on the same query/queries if($scope.query_id === query_id && - _.intersection(facetIds,querySrv.ids).length === querySrv.ids.length + _.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length ) { var i = 0; var data, hits; - _.each(querySrv.ids, function(id) { + _.each($scope.panel.queries.ids, function(id) { var v = results.facets[id]; // Null values at each end of the time range ensure we see entire range @@ -343,20 +341,14 @@ angular.module('kibana.histogram', []) borderColor: '#eee', color: "#eee", hoverable: true, - }, - colors: ['#86B22D','#BF6730','#1D7373','#BFB930','#BF3030','#77207D'] + } }; if(scope.panel.interactive) { - options.selection = { mode: "x", color: '#aaa' }; + options.selection = { mode: "x", color: '#666' }; } scope.plot = $.plot(elem, scope.data, options); - - // Work around for missing legend at initialization. - if(!scope.$$phase) { - scope.$apply(); - } } catch(e) { elem.text(e); diff --git a/panels/hits/editor.html b/panels/hits/editor.html index d39b3ab0e8b..d4d7cf750bc 100644 --- a/panels/hits/editor.html +++ b/panels/hits/editor.html @@ -26,4 +26,5 @@
+
diff --git a/panels/hits/module.js b/panels/hits/module.js index 51f78cfa135..fc064aa86b6 100644 --- a/panels/hits/module.js +++ b/panels/hits/module.js @@ -8,8 +8,6 @@ A variety of representations of the hits a query matches ### Parameters - * query :: An array of queries. No labels here, just an array of strings. Maybe - there should be labels. Probably. * style :: A hash of css styles * arrangement :: How should I arrange the query results? 'horizontal' or 'vertical' * chart :: Show a chart? 'none', 'bar', 'pie' @@ -27,8 +25,10 @@ angular.module('kibana.hits', []) // Set and populate defaults var _d = { status : "Beta", - query : ["*"], - group : "default", + queries : { + mode : 'all', + ids : [] + }, style : { "font-size": '10pt'}, arrangement : 'horizontal', chart : 'bar', @@ -61,8 +61,9 @@ angular.module('kibana.hits', []) var _segment = _.isUndefined(segment) ? 0 : segment; var request = $scope.ejs.Request().indices(dashboard.indices[_segment]); + $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); // Build the question part of the query - _.each(querySrv.ids, function(id) { + _.each($scope.panel.queries.ids, function(id) { var _q = $scope.ejs.FilteredQuery( querySrv.getEjsObj(id), filterSrv.getBoolFilter(filterSrv.ids)); @@ -99,10 +100,10 @@ angular.module('kibana.hits', []) // Make sure we're still on the same query/queries if($scope.query_id === query_id && - _.intersection(facetIds,querySrv.ids).length === querySrv.ids.length + _.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length ) { var i = 0; - _.each(querySrv.ids, function(id) { + _.each($scope.panel.queries.ids, function(id) { var v = results.facets[id]; var hits = _.isUndefined($scope.data[i]) || _segment === 0 ? v.count : $scope.data[i].hits+v.count; @@ -231,11 +232,6 @@ angular.module('kibana.hits', []) }); } - // Work around for missing legend at initialization - if(!scope.$$phase) { - scope.$apply(); - } - } catch(e) { elem.text(e); } diff --git a/panels/map/editor.html b/panels/map/editor.html index a9c0af438e8..9325ef6b2b9 100644 --- a/panels/map/editor.html +++ b/panels/map/editor.html @@ -15,6 +15,7 @@
+
Panel Spy
diff --git a/panels/map/module.js b/panels/map/module.js index 777b71d71ff..ef6830f4f96 100644 --- a/panels/map/module.js +++ b/panels/map/module.js @@ -12,8 +12,6 @@ There's no way to query sequentially here, so I'm going to hit them all at once! ### Parameters - * query :: A single query string, not and array. This panel can only handle one - query at a time. * map :: 'world', 'us' or 'europe' * colors :: an array of colors to use for the regions of the map. If this is a 2 element array, jquerymap will generate shades between these colors @@ -33,13 +31,15 @@ angular.module('kibana.map', []) // Set and populate defaults var _d = { status : "Beta", - query : "*", + queries : { + mode : 'all', + ids : [] + }, map : "world", colors : ['#A0E2E2', '#265656'], size : 100, exclude : [], spyable : true, - group : "default", index_limit : 0 }; _.defaults($scope.panel,_d); @@ -61,9 +61,11 @@ angular.module('kibana.map', []) var request; request = $scope.ejs.Request().indices(dashboard.indices); + $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); + // This could probably be changed to a BoolFilter var boolQuery = $scope.ejs.BoolQuery(); - _.each(querySrv.list,function(q) { - boolQuery = boolQuery.should($scope.ejs.QueryStringQuery(q.query || '*')); + _.each($scope.panel.queries.ids,function(id) { + boolQuery = boolQuery.should(querySrv.getEjsObj(id)); }); // Then the insert into facet and make the request diff --git a/panels/pie/editor.html b/panels/pie/editor.html index d650cbdf80d..fd826c1c69d 100644 --- a/panels/pie/editor.html +++ b/panels/pie/editor.html @@ -48,6 +48,7 @@
+
Panel Spy
diff --git a/panels/pie/module.html b/panels/pie/module.html index 485cc637b9f..a36cf2c92a4 100644 --- a/panels/pie/module.html +++ b/panels/pie/module.html @@ -3,14 +3,14 @@ -
+
{{query.label}} ({{query.data[0][1]}})

-
+
{{query.label}} ({{query.data[0][1]}})
\ No newline at end of file diff --git a/panels/pie/module.js b/panels/pie/module.js index 640356464ef..681af420401 100644 --- a/panels/pie/module.js +++ b/panels/pie/module.js @@ -11,9 +11,8 @@ represents ### Parameters - * query :: An object with 3 possible parameters depends on the mode: + * query :: An object with 2 possible parameters depends on the mode: ** field: Fields to run a terms facet on. Only does anything in terms mode - ** query: A string of the query to run ** goal: How many to shoot for, only does anything in goal mode * exclude :: In terms mode, ignore these terms * donut :: Drill a big hole in the pie @@ -35,6 +34,10 @@ angular.module('kibana.pie', []) var _d = { status : "Deprecating Soon", query : { field:"_type", goal: 100}, + queries : { + mode : 'all', + ids : [] + }, size : 10, exclude : [], donut : false, @@ -84,15 +87,18 @@ angular.module('kibana.pie', []) return; } + $scope.panel.loading = true; var request = $scope.ejs.Request().indices(dashboard.indices); + $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); // This could probably be changed to a BoolFilter var boolQuery = $scope.ejs.BoolQuery(); - _.each(querySrv.list,function(q) { - boolQuery = boolQuery.should(querySrv.toEjsObj(q)); + _.each($scope.panel.queries.ids,function(id) { + boolQuery = boolQuery.should(querySrv.getEjsObj(id)); }); + var results; // Terms mode @@ -246,6 +252,10 @@ angular.module('kibana.pie', []) if(elem.is(":visible")){ scripts.wait(function(){ scope.plot = $.plot(elem, scope.data, pie); + scope.legend = scope.plot.getData(); + if(!scope.$$phase) { + scope.$apply(); + } }); } diff --git a/panels/query/module.html b/panels/query/module.html index ae71080abd5..ca3b6ee34b5 100644 --- a/panels/query/module.html +++ b/panels/query/module.html @@ -41,13 +41,13 @@ } -
+
+
Panel Spy
diff --git a/panels/table/module.js b/panels/table/module.js index 0f9acefeeb0..4937082d684 100644 --- a/panels/table/module.js +++ b/panels/table/module.js @@ -7,7 +7,6 @@ A paginated table of events matching a query ### Parameters - * query :: A string representing then current query * size :: Number of events per page to show * pages :: Number of pages to show. size * pages = number of cached events. Bigger = more memory usage byh the browser @@ -35,7 +34,10 @@ angular.module('kibana.table', []) // Set and populate defaults var _d = { status : "Stable", - query : "*", + queries : { + mode : 'all', + ids : [] + }, size : 100, // Per page pages : 5, // Pages available offset : 0, @@ -53,7 +55,6 @@ angular.module('kibana.table', []) _.defaults($scope.panel,_d); $scope.init = function () { - $scope.set_listeners($scope.panel.group); $scope.get_data(); @@ -133,14 +134,16 @@ angular.module('kibana.table', []) $scope.panel.loading = true; + $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); + var _segment = _.isUndefined(segment) ? 0 : segment; $scope.segment = _segment; var request = $scope.ejs.Request().indices(dashboard.indices[_segment]); var boolQuery = $scope.ejs.BoolQuery(); - _.each(querySrv.list,function(q) { - boolQuery = boolQuery.should(querySrv.toEjsObj(q)); + _.each($scope.panel.queries.ids,function(id) { + boolQuery = boolQuery.should(querySrv.getEjsObj(id)); }); request = request.query( diff --git a/panels/text/module.js b/panels/text/module.js index fb0beb70876..2a63d7298ae 100644 --- a/panels/text/module.js +++ b/panels/text/module.js @@ -53,7 +53,9 @@ angular.module('kibana.text', []) element.html(htmlText); // For whatever reason, this fixes chrome. I don't like it, I think // it makes things slow? - scope.$apply(); + if(!scope.$$phase) { + scope.$apply(); + } }); } diff --git a/panels/trends/editor.html b/panels/trends/editor.html index 74d34122258..a14f519d0cd 100644 --- a/panels/trends/editor.html +++ b/panels/trends/editor.html @@ -26,4 +26,5 @@
+
diff --git a/panels/trends/module.js b/panels/trends/module.js index 7d524bf93c7..943454dc49a 100644 --- a/panels/trends/module.js +++ b/panels/trends/module.js @@ -10,12 +10,6 @@ * style :: A hash of css styles * arrangement :: How should I arrange the query results? 'horizontal' or 'vertical' * ago :: Date math formatted time to look back - ### Group Events - #### Sends - * get_time :: On panel initialization get time range to query - #### Receives - * time :: An object containing the time range to use and the index(es) to query - * query :: An Array of queries, even if its only one */ @@ -27,7 +21,10 @@ angular.module('kibana.trends', []) // Set and populate defaults var _d = { status : "Beta", - query : ["*"], + queries : { + mode : 'all', + ids : [] + }, group : "default", style : { "font-size": '14pt'}, ago : '1d', @@ -54,6 +51,8 @@ angular.module('kibana.trends', []) $scope.index = segment > 0 ? $scope.index : dashboard.indices; } + $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); + // Determine a time field var timeField = _.uniq(_.pluck(filterSrv.getByType('time'),'field')); if(timeField.length > 1) { @@ -78,7 +77,7 @@ angular.module('kibana.trends', []) // Build the question part of the query - _.each(querySrv.ids, function(id) { + _.each($scope.panel.queries.ids, function(id) { var q = $scope.ejs.FilteredQuery( querySrv.getEjsObj(id), filterSrv.getBoolFilter(_ids_without_time).must( @@ -95,7 +94,7 @@ angular.module('kibana.trends', []) // And again for the old time period - _.each(querySrv.ids, function(id) { + _.each($scope.panel.queries.ids, function(id) { var q = $scope.ejs.FilteredQuery( querySrv.getEjsObj(id), filterSrv.getBoolFilter(_ids_without_time).must( @@ -152,10 +151,10 @@ angular.module('kibana.trends', []) // Make sure we're still on the same query/queries if($scope.query_id === query_id && - _.intersection(facetIds,querySrv.ids).length === querySrv.ids.length + _.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length ) { var i = 0; - _.each(querySrv.ids, function(id) { + _.each($scope.panel.queries.ids, function(id) { var v = results.facets[id]; var n = results.facets[id].count; var o = results.facets['old_'+id].count; diff --git a/partials/paneleditor.html b/partials/paneleditor.html index 4fcfa14076d..f5eb79005b8 100644 --- a/partials/paneleditor.html +++ b/partials/paneleditor.html @@ -11,8 +11,8 @@
-

{{panel.type}} panel settings. ({{panel.status}})

-
No additional settings are available for this type of panel.
+

{{panel.type}} panel settings. ({{panel.status}})

+
No additional settings are available for this type of panel.
diff --git a/partials/querySelect.html b/partials/querySelect.html index 0e26f43a41a..f62ee13742a 100644 --- a/partials/querySelect.html +++ b/partials/querySelect.html @@ -2,13 +2,20 @@ .querySelect .query { margin-right: 5px; } + .querySelect .selected { + border: 3px solid; + } + .querySelect .unselected { + border: 0px solid; + }

Queries

- - {{querySrv.list[id].alias || querySrv.list[id].query}} + + + {{querySrv.list[id].alias || querySrv.list[id].query}}