From 389f8aef4dec9f880baa4e2ba5a90b51646816f3 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 26 Aug 2013 17:56:40 -0700 Subject: [PATCH] white-space cleanse, and added forin flags to a couple files that need to be looked at at a later date. --- js/app.js | 6 ++-- js/controllers.js | 6 ++-- js/directives.js | 4 +-- js/services.js | 2 +- js/shared.js | 57 +++++++++++++++++----------------- panels/bettermap/module.js | 10 +++--- panels/column/module.js | 4 +-- panels/dashcontrol/module.js | 4 +-- panels/derivequeries/module.js | 8 ++--- panels/fields/module.js | 2 +- panels/hits/module.js | 34 ++++++++++---------- panels/map/module.js | 16 +++++----- panels/pie/module.js | 42 ++++++++++++------------- panels/query/module.js | 4 +-- panels/table/module.js | 22 ++++++------- panels/terms/module.js | 34 ++++++++++---------- panels/text/module.js | 4 +-- panels/timepicker/module.js | 20 ++++++------ panels/trends/module.js | 18 +++++------ 19 files changed, 149 insertions(+), 148 deletions(-) diff --git a/js/app.js b/js/app.js index d7aef44584f2f..b812468c198cd 100644 --- a/js/app.js +++ b/js/app.js @@ -5,9 +5,9 @@ // Base modules var modules = [ 'kibana.services', - 'kibana.controllers', - 'kibana.filters', - 'kibana.directives', + 'kibana.controllers', + 'kibana.filters', + 'kibana.directives', 'elasticjs.service', '$strap.directives', 'kibana.panels', diff --git a/js/controllers.js b/js/controllers.js index 3cb76a0535b47..21070740421b9 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -3,7 +3,7 @@ 'use strict'; angular.module('kibana.controllers', []) -.controller('DashCtrl', function($scope, $rootScope, $http, $timeout, $route, ejsResource, +.controller('DashCtrl', function($scope, $rootScope, $http, $timeout, $route, ejsResource, fields, dashboard, alertSrv) { $scope.editor = { @@ -23,7 +23,7 @@ angular.module('kibana.controllers', []) $scope.fields = fields; $scope.reset_row(); - var ejs = $scope.ejs = ejsResource(config.elasticsearch); + var ejs = $scope.ejs = ejsResource(config.elasticsearch); }; $scope.add_row = function(dash,row) { @@ -58,7 +58,7 @@ angular.module('kibana.controllers', []) return $scope.editorTabs; }; - // This is whoafully incomplete, but will do for now + // This is whoafully incomplete, but will do for now $scope.parse_error = function(data) { var _error = data.match("nested: (.*?);"); return _.isNull(_error) ? data : _error[1]; diff --git a/js/directives.js b/js/directives.js index 4dde7de11f2a9..3157eb6255e5f 100644 --- a/js/directives.js +++ b/js/directives.js @@ -9,7 +9,7 @@ angular.module('kibana.directives', []) link: function(scope, elem, attrs) { var template = ''+ - ' '+ '{{panel.type}} '+ '

'+ @@ -73,7 +73,7 @@ angular.module('kibana.directives', []) elm.bind('blur', function() { scope.$apply(function() { ngModelCtrl.$setViewValue(elm.val()); - }); + }); }); } }; diff --git a/js/services.js b/js/services.js index 101579b4de71c..5d3b03e7de5e1 100644 --- a/js/services.js +++ b/js/services.js @@ -1,4 +1,4 @@ -/*jshint globalstrict:true */ +/*jshint globalstrict:true, forin:false */ /*global angular:true */ /*global Blob:false*/ 'use strict'; diff --git a/js/shared.js b/js/shared.js index 94c09d3f30d87..ba402e492a072 100644 --- a/js/shared.js +++ b/js/shared.js @@ -1,3 +1,4 @@ +/*jshint forin:false*/ // Wrap this all up in a 'kbn' object so I don't have a billion globals (function() { 'use strict'; @@ -102,54 +103,54 @@ kbn.round_interval = function(interval) { switch (true) { // 0.5s - case (interval <= 500): + case (interval <= 500): return 100; // 0.1s // 5s - case (interval <= 5000): + case (interval <= 5000): return 1000; // 1s // 7.5s - case (interval <= 7500): + case (interval <= 7500): return 5000; // 5s // 15s - case (interval <= 15000): + case (interval <= 15000): return 10000; // 10s // 45s - case (interval <= 45000): + case (interval <= 45000): return 30000; // 30s // 3m - case (interval <= 180000): + case (interval <= 180000): return 60000; // 1m // 9m - case (interval <= 450000): + case (interval <= 450000): return 300000; // 5m // 20m - case (interval <= 1200000): + case (interval <= 1200000): return 600000; // 10m // 45m - case (interval <= 2700000): + case (interval <= 2700000): return 1800000; // 30m // 2h - case (interval <= 7200000): + case (interval <= 7200000): return 3600000; // 1h // 6h - case (interval <= 21600000): + case (interval <= 21600000): return 10800000; // 3h // 24h - case (interval <= 86400000): + case (interval <= 86400000): return 43200000; // 12h // 48h - case (interval <= 172800000): + case (interval <= 172800000): return 86400000; // 24h // 1w - case (interval <= 604800000): + case (interval <= 604800000): return 86400000; // 24h // 3w - case (interval <= 1814400000): + case (interval <= 1814400000): return 604800000; // 1w // 2y - case (interval < 3628800000): + case (interval < 3628800000): return 2592000000; // 30d - default: + default: return 31536000000; // 1y } }; @@ -194,21 +195,21 @@ kbn.interval_to_seconds = function(string) { var matches = string.match(/(\d+(?:\.\d+)?)([Mwdhmsy])/); switch (matches[2]) { - case 'y': + case 'y': return matches[1]*31536000; - case 'M': + case 'M': return matches[1]*2592000; - case 'w': + case 'w': return matches[1]*604800; - case 'd': + case 'd': return matches[1]*86400; - case 'h': + case 'h': return matches[1]*3600; - case 'm': + case 'm': return matches[1]*60; - case 's': + case 's': return matches[1]; - } + } }; // This should go away, moment.js can do this @@ -235,7 +236,7 @@ if (objidx > 0) { strval = strval + ', '; } - + strval = strval + JSON.stringify(obj[objidx]); } array[rootname] = strval; @@ -299,7 +300,7 @@ _.mixin({ array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] ); return array; - } + } }); _.mixin({ @@ -308,7 +309,7 @@ _.mixin({ array.splice(index, 1); return array; - } + } }); _.mixin({ diff --git a/panels/bettermap/module.js b/panels/bettermap/module.js index 3ba77bc089110..e6fb1c7a5ae9c 100644 --- a/panels/bettermap/module.js +++ b/panels/bettermap/module.js @@ -61,7 +61,7 @@ angular.module('kibana.bettermap', []) $scope.panel.error = "Please select a field that contains geo point in [lon,lat] format"; return; } - + // Determine the field to sort on var timeField = _.uniq(_.pluck(filterSrv.getByType('time'),'field')); if(timeField.length > 1) { @@ -75,7 +75,7 @@ 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 + // This could probably be changed to a BoolFilter var boolQuery = $scope.ejs.BoolQuery(); _.each($scope.panel.queries.ids,function(id) { boolQuery = boolQuery.should(querySrv.getEjsObj(id)); @@ -132,7 +132,7 @@ angular.module('kibana.bettermap', []) } else { return; } - + $scope.$emit('draw'); // Get $size results then stop querying @@ -169,12 +169,12 @@ angular.module('kibana.bettermap', []) var map, markers, layerGroup, mcg; - function render_panel() { + function render_panel() { scope.panelMeta.loading = false; var scripts = $LAB.script("panels/bettermap/lib/leaflet.js").wait() .script("panels/bettermap/lib/plugins.js"); - + //add markers dynamically scripts.wait(function(){ if(_.isUndefined(map)) { diff --git a/panels/column/module.js b/panels/column/module.js index 9bf1c03540c90..df9d7ecab3ae0 100644 --- a/panels/column/module.js +++ b/panels/column/module.js @@ -6,7 +6,7 @@ ### Parameters * panels :: an array of panel objects. All of their spans should be set to 12 - + */ 'use strict'; @@ -84,7 +84,7 @@ angular.module('kibana.column', []) } elem.html($compile(angular.element(template))(scope)); }); - }); + }); } }; }).filter('withoutColumn', function() { diff --git a/panels/dashcontrol/module.js b/panels/dashcontrol/module.js index 1119943b34b7f..0a4bf9e6e5533 100644 --- a/panels/dashcontrol/module.js +++ b/panels/dashcontrol/module.js @@ -17,7 +17,7 @@ * hide_control :: Upon save, hide this panel * elasticsearch_size :: show this many dashboards under the ES section in the load drop down * temp :: Allow saving of temp dashboards - * ttl :: Enable setting ttl. + * ttl :: Enable setting ttl. * temp_ttl :: How long should temp dashboards persist */ @@ -91,7 +91,7 @@ angular.module('kibana.dashcontrol', []) ).then( function(result) { if(!_.isUndefined(result._id)) { - alertSrv.set('Dashboard Saved','This dashboard has been saved to Elasticsearch as "' + + alertSrv.set('Dashboard Saved','This dashboard has been saved to Elasticsearch as "' + result._id + '"','success',5000); if(type === 'temp') { $scope.share = dashboard.share_link(dashboard.current.title,'temp',result._id); diff --git a/panels/derivequeries/module.js b/panels/derivequeries/module.js index 77d4723ac485e..5154e086e7748 100644 --- a/panels/derivequeries/module.js +++ b/panels/derivequeries/module.js @@ -5,7 +5,7 @@ ## Derivequeries ### Parameters - * label :: The label to stick over the field + * label :: The label to stick over the field * query :: A string to use as a filter for the terms facet * field :: the field to facet on * rest :: include a filter that matches all other terms, @@ -54,7 +54,7 @@ angular.module('kibana.derivequeries', []) $scope.get_data = function() { update_history($scope.panel.query); - + // Make sure we have everything for the request to complete if(dashboard.indices.length === 0) { return; @@ -122,8 +122,8 @@ angular.module('kibana.derivequeries', []) }); }; - $scope.set_refresh = function (state) { - $scope.refresh = state; + $scope.set_refresh = function (state) { + $scope.refresh = state; }; $scope.close_edit = function() { diff --git a/panels/fields/module.js b/panels/fields/module.js index 6119d79e1dfc6..b5204ebead3f1 100644 --- a/panels/fields/module.js +++ b/panels/fields/module.js @@ -23,7 +23,7 @@ angular.module('kibana.fields', []) var _d = { style : {}, arrange : 'vertical', - micropanel_position : 'right', + micropanel_position : 'right', }; _.defaults($scope.panel,_d); diff --git a/panels/hits/module.js b/panels/hits/module.js index 271ebc10a097a..0a8bc7da0c013 100644 --- a/panels/hits/module.js +++ b/panels/hits/module.js @@ -10,7 +10,7 @@ * arrangement :: How should I arrange the query results? 'horizontal' or 'vertical' * chart :: Show a chart? 'none', 'bar', 'pie' * donut :: Only applies to 'pie' charts. Punches a hole in the chart for some reason - * tilt :: Only 'pie' charts. Janky 3D effect. Looks terrible 90% of the time. + * tilt :: Only 'pie' charts. Janky 3D effect. Looks terrible 90% of the time. * lables :: Only 'pie' charts. Labels on the pie? */ @@ -48,7 +48,7 @@ angular.module('kibana.hits', []) $scope.init = function () { $scope.hits = 0; - + $scope.$on('refresh',function(){ $scope.get_data(); }); @@ -67,14 +67,14 @@ 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($scope.panel.queries.ids, function(id) { var _q = $scope.ejs.FilteredQuery( querySrv.getEjsObj(id), filterSrv.getBoolFilter(filterSrv.ids)); - + request = request .facet($scope.ejs.QueryFacet(id) .query(_q) @@ -95,7 +95,7 @@ angular.module('kibana.hits', []) $scope.data = []; query_id = $scope.query_id = new Date().getTime(); } - + // Check for error and abort if found if(!(_.isUndefined(results.error))) { $scope.panel.error = $scope.parse_error(results.error); @@ -106,18 +106,18 @@ angular.module('kibana.hits', []) var facetIds = _.map(_.keys(results.facets),function(k){return parseInt(k, 10);}); // Make sure we're still on the same query/queries - if($scope.query_id === query_id && + if($scope.query_id === query_id && _.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length ) { var i = 0; _.each($scope.panel.queries.ids, function(id) { var v = results.facets[id]; - var hits = _.isUndefined($scope.data[i]) || _segment === 0 ? + var hits = _.isUndefined($scope.data[i]) || _segment === 0 ? v.count : $scope.data[i].hits+v.count; $scope.hits += v.count; // Create series - $scope.data[i] = { + $scope.data[i] = { info: querySrv.list[id], id: id, hits: hits, @@ -130,13 +130,13 @@ angular.module('kibana.hits', []) if(_segment < dashboard.indices.length-1) { $scope.get_data(_segment+1,query_id); } - + } }); }; - $scope.set_refresh = function (state) { - $scope.refresh = state; + $scope.set_refresh = function (state) { + $scope.refresh = state; }; $scope.close_edit = function() { @@ -161,7 +161,7 @@ angular.module('kibana.hits', []) scope.$on('render',function(){ render_panel(); }); - + // Re-render if the window is resized angular.element(window).bind('resize', function(){ render_panel(); @@ -186,7 +186,7 @@ angular.module('kibana.hits', []) scripts.wait(function(){ // Populate element try { - // Add plot to scope so we can build out own legend + // Add plot to scope so we can build out own legend if(scope.panel.chart === 'bar') { scope.plot = $.plot(elem, scope.data, { legend: { show: false }, @@ -222,7 +222,7 @@ angular.module('kibana.hits', []) stroke: { width: 0 }, - label: { + label: { show: scope.panel.labels, radius: 2/3, formatter: function(label, series){ @@ -230,7 +230,7 @@ angular.module('kibana.hits', []) ' "style="font-size:8pt;text-align:center;padding:2px;color:white;">'+ label+'
'+Math.round(series.percent)+'%'; }, - threshold: 0.1 + threshold: 0.1 } } }, @@ -247,7 +247,7 @@ angular.module('kibana.hits', []) } function tt(x, y, contents) { - var tooltip = $('#pie-tooltip').length ? + var tooltip = $('#pie-tooltip').length ? $('#pie-tooltip') : $('
'); //var tooltip = $('#pie-tooltip') tooltip.html(contents).css({ @@ -265,7 +265,7 @@ angular.module('kibana.hits', []) elem.bind("plothover", function (event, pos, item) { if (item) { - var value = scope.panel.chart === 'bar' ? + var value = scope.panel.chart === 'bar' ? item.datapoint[1] : item.datapoint[1][0][1]; tt(pos.pageX, pos.pageY, "
Last Elasticsearch Query

"+
           'curl -XGET '+config.elasticsearch+'/'+dashboard.indices+"/_search?pretty -d'\n"+
           angular.toJson(JSON.parse(request.toString()),true)+
-        "'
", - }; + "'", + }; }; $scope.build_search = function(field,value) { @@ -137,12 +137,12 @@ angular.module('kibana.map', []) // Using LABjs, wait until all scripts are loaded before rendering panel var scripts = $LAB.script("panels/map/lib/jquery.jvectormap.min.js").wait() .script("panels/map/lib/map."+scope.panel.map+".js"); - + // Populate element. Note that jvectormap appends, does not replace. scripts.wait(function(){ elem.text(''); $('.jvectormap-zoomin,.jvectormap-zoomout,.jvectormap-label').remove(); - var map = elem.vectorMap({ + var map = elem.vectorMap({ map: scope.panel.map, regionStyle: {initial: {fill: '#8c8c8c'}}, zoomOnScroll: false, diff --git a/panels/pie/module.js b/panels/pie/module.js index fb8386b823072..2a19cfca2ba1e 100644 --- a/panels/pie/module.js +++ b/panels/pie/module.js @@ -14,7 +14,7 @@ * legend :: Show the legend? * labels :: Label the slices of the pie? * mode :: 'terms' or 'goal' - * default_field :: LOL wat? A dumb fail over field if for some reason the query object + * default_field :: LOL wat? A dumb fail over field if for some reason the query object doesn't have a field * spyable :: Show the 'eye' icon that displays the last ES query for this panel */ @@ -36,7 +36,7 @@ angular.module('kibana.pie', []) editorTabs : [ {title:'Queries', src:'partials/querySelect.html'} ], - query : { field:"_type", goal: 100}, + query : { field:"_type", goal: 100}, queries : { mode : 'all', ids : [] @@ -70,8 +70,8 @@ angular.module('kibana.pie', []) } }; - $scope.set_refresh = function (state) { - $scope.refresh = state; + $scope.set_refresh = function (state) { + $scope.refresh = state; }; $scope.close_edit = function() { @@ -83,18 +83,18 @@ angular.module('kibana.pie', []) }; $scope.get_data = function() { - + // Make sure we have everything for the request to complete if(dashboard.indices.length === 0) { return; - } + } $scope.panelMeta.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 + // This could probably be changed to a BoolFilter var boolQuery = $scope.ejs.BoolQuery(); _.each($scope.panel.queries.ids,function(id) { boolQuery = boolQuery.should(querySrv.getEjsObj(id)); @@ -127,7 +127,7 @@ angular.module('kibana.pie', []) $scope.data = []; var k = 0; _.each(results.facets.pie.terms, function(v) { - var slice = { label : v.term, data : v.count }; + var slice = { label : v.term, data : v.count }; $scope.data.push(); $scope.data.push(slice); k = k + 1; @@ -140,9 +140,9 @@ angular.module('kibana.pie', []) .query(boolQuery) .filter(filterSrv.getBoolFilter(filterSrv.ids)) .size(0); - + $scope.populate_modal(request); - + results = request.doSearch(); results.then(function(results) { @@ -165,8 +165,8 @@ angular.module('kibana.pie', []) body : "
Last Elasticsearch Query
"+
           'curl -XGET '+config.elasticsearch+'/'+dashboard.indices+"/_search?pretty -d'\n"+
           angular.toJson(JSON.parse(request.toString()),true)+
-        "'
", - }; + "'", + }; }; }) @@ -194,11 +194,11 @@ angular.module('kibana.pie', []) var scripts = $LAB.script("common/lib/panels/jquery.flot.js").wait() .script("common/lib/panels/jquery.flot.pie.js"); - + var label; if(scope.panel.mode === 'goal') { - label = { + label = { show: scope.panel.labels, radius: 0, formatter: function(label, series){ @@ -211,15 +211,15 @@ angular.module('kibana.pie', []) } }, }; - } else { - label = { + } else { + label = { show: scope.panel.labels, radius: 2/3, formatter: function(label, series){ return '
'+ label+'
'+Math.round(series.percent)+'%
'; }, - threshold: 0.1 + threshold: 0.1 }; } @@ -241,10 +241,10 @@ angular.module('kibana.pie', []) } }, //grid: { hoverable: true, clickable: true }, - grid: { + grid: { backgroundColor: null, - hoverable: true, - clickable: true + hoverable: true, + clickable: true }, legend: { show: false }, colors: querySrv.colors @@ -263,7 +263,7 @@ angular.module('kibana.pie', []) } function tt(x, y, contents) { - var tooltip = $('#pie-tooltip').length ? + var tooltip = $('#pie-tooltip').length ? $('#pie-tooltip') : $('
'); tooltip.html(contents).css({ diff --git a/panels/query/module.js b/panels/query/module.js index f43306d693e31..4896d7f97ec00 100644 --- a/panels/query/module.js +++ b/panels/query/module.js @@ -5,9 +5,9 @@ ## query ### Parameters - * label :: The label to stick over the field + * label :: The label to stick over the field * query :: A string or an array of querys. String if multi is off, array if it is on - This should be fixed, it should always be an array even if its only + This should be fixed, it should always be an array even if its only one element */ diff --git a/panels/table/module.js b/panels/table/module.js index 18b74b297271d..631248cd049f9 100644 --- a/panels/table/module.js +++ b/panels/table/module.js @@ -6,14 +6,14 @@ ### Parameters * size :: Number of events per page to show - * pages :: Number of pages to show. size * pages = number of cached events. + * pages :: Number of pages to show. size * pages = number of cached events. Bigger = more memory usage byh the browser * offset :: Position from which to start in the array of hits * sort :: An array with 2 elements. sort[0]: field, sort[1]: direction ('asc' or 'desc') * style :: hash of css properties * fields :: columns to show in table * overflow :: 'height' or 'min-height' controls wether the row will expand (min-height) to - to fit the table, or if the table will scroll to fit the row (height) + to fit the table, or if the table will scroll to fit the row (height) * trimFactor :: If line is > this many characters, divided by the number of columns, trim it. * sortable :: Allow sorting? * spyable :: Show the 'eye' icon that reveals the last ES query for this panel @@ -110,7 +110,7 @@ angular.module('kibana.table', []) } else { $scope.panel.highlight.push(field); } - }; + }; $scope.toggle_details = function(row) { row.kibana = row.kibana || {}; @@ -147,7 +147,7 @@ angular.module('kibana.table', []) if(dashboard.indices.length === 0) { return; } - + $scope.panelMeta.loading = true; $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); @@ -208,14 +208,14 @@ angular.module('kibana.table', []) _sort : hit.sort }; })); - + $scope.hits += results.hits.total; // Sort the data $scope.data = _.sortBy($scope.data, function(v){ return v._sort[0]; }); - + // Reverse if needed if($scope.panel.sort[1] === 'desc') { $scope.data.reverse(); @@ -245,14 +245,14 @@ angular.module('kibana.table', []) }; $scope.without_kibana = function (row) { - return { + return { _source : row._source, highlight : row.highlight }; - }; + }; - $scope.set_refresh = function (state) { - $scope.refresh = state; + $scope.set_refresh = function (state) { + $scope.refresh = state; }; $scope.close_edit = function() { @@ -296,7 +296,7 @@ angular.module('kibana.table', []) type = fields.mapping[event._index][event._type][field]['type']; if(type === 'date' && scope.panel.normTimes) { return moment(text).format('YYYY-MM-DD HH:mm:ss'); - } + } } return text; }; diff --git a/panels/terms/module.js b/panels/terms/module.js index cefde518bb493..ab13b8b424beb 100644 --- a/panels/terms/module.js +++ b/panels/terms/module.js @@ -11,7 +11,7 @@ * arrangement :: How should I arrange the query results? 'horizontal' or 'vertical' * chart :: Show a chart? 'none', 'bar', 'pie' * donut :: Only applies to 'pie' charts. Punches a hole in the chart for some reason - * tilt :: Only 'pie' charts. Janky 3D effect. Looks terrible 90% of the time. + * tilt :: Only 'pie' charts. Janky 3D effect. Looks terrible 90% of the time. * lables :: Only 'pie' charts. Labels on the pie? */ @@ -26,7 +26,7 @@ angular.module('kibana.terms', []) {title:'Queries', src:'partials/querySelect.html'} ], status : "Beta", - description : "Displays the results of an elasticsearch facet as a pie chart, bar chart, or a "+ + description : "Displays the results of an elasticsearch facet as a pie chart, bar chart, or a "+ "table" }; @@ -55,7 +55,7 @@ angular.module('kibana.terms', []) $scope.init = function () { $scope.hits = 0; - + $scope.$on('refresh',function(){ $scope.get_data(); }); @@ -67,7 +67,7 @@ angular.module('kibana.terms', []) // Make sure we have everything for the request to complete if(dashboard.indices.length === 0) { return; - } + } $scope.panelMeta.loading = true; var request, @@ -77,7 +77,7 @@ angular.module('kibana.terms', []) request = $scope.ejs.Request().indices(dashboard.indices); $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); - // This could probably be changed to a BoolFilter + // This could probably be changed to a BoolFilter boolQuery = $scope.ejs.BoolQuery(); _.each($scope.panel.queries.ids,function(id) { boolQuery = boolQuery.should(querySrv.getEjsObj(id)); @@ -108,11 +108,11 @@ angular.module('kibana.terms', []) $scope.hits = results.hits.total; $scope.data = []; _.each(results.facets.terms.terms, function(v) { - var slice = { label : v.term, data : [[k,v.count]], actions: true}; + var slice = { label : v.term, data : [[k,v.count]], actions: true}; $scope.data.push(slice); k = k + 1; }); - + $scope.data.push({label:'Missing field', data:[[k,results.facets.terms.missing]],meta:"missing",color:'#aaa',opacity:0}); $scope.data.push({label:'Other values', @@ -135,8 +135,8 @@ angular.module('kibana.terms', []) dashboard.refresh(); }; - $scope.set_refresh = function (state) { - $scope.refresh = state; + $scope.set_refresh = function (state) { + $scope.refresh = state; }; $scope.close_edit = function() { @@ -169,7 +169,7 @@ angular.module('kibana.terms', []) scope.$on('render',function(){ render_panel(); }); - + // Re-render if the window is resized angular.element(window).bind('resize', function(){ render_panel(); @@ -186,16 +186,16 @@ angular.module('kibana.terms', []) // Make a clone we can operate on. chartData = _.clone(scope.data); - chartData = scope.panel.missing ? chartData : + chartData = scope.panel.missing ? chartData : _.without(chartData,_.findWhere(chartData,{meta:'missing'})); - chartData = scope.panel.other ? chartData : + chartData = scope.panel.other ? chartData : _.without(chartData,_.findWhere(chartData,{meta:'other'})); // Populate element. scripts.wait(function(){ // Populate element try { - // Add plot to scope so we can build out own legend + // Add plot to scope so we can build out own legend if(scope.panel.chart === 'bar') { plot = $.plot(elem, chartData, { legend: { show: false }, @@ -238,11 +238,11 @@ angular.module('kibana.terms', []) stroke: { width: 0 }, - label: { + label: { show: scope.panel.labels, radius: 2/3, formatter: labelFormat, - threshold: 0.1 + threshold: 0.1 } } }, @@ -269,7 +269,7 @@ angular.module('kibana.terms', []) } function tt(x, y, contents) { - var tooltip = $('#pie-tooltip').length ? + var tooltip = $('#pie-tooltip').length ? $('#pie-tooltip') : $('
'); //var tooltip = $('#pie-tooltip') tooltip.html(contents).css({ @@ -293,7 +293,7 @@ angular.module('kibana.terms', []) elem.bind("plothover", function (event, pos, item) { if (item) { - var value = scope.panel.chart === 'bar' ? + var value = scope.panel.chart === 'bar' ? item.datapoint[1] : item.datapoint[1][0][1]; tt(pos.pageX, pos.pageY, "