From 2371e2bfd9a885640f5123e50c7fc911997edd03 Mon Sep 17 00:00:00 2001 From: kareem Date: Mon, 22 Sep 2014 09:37:07 +0300 Subject: [PATCH] fixed warnings and errors with grunt jshint --- .jshintrc | 2 +- package.json | 5 +- src/app/controllers/dashLoader.js | 9 +- src/app/filters/all.js | 17 +- src/app/panels/facet/module.js | 70 ++-- src/app/panels/fullTextSearch/module.js | 72 ++-- src/app/panels/heatmap/module.js | 516 ++++++++++++------------ src/app/panels/histogram/module.js | 47 +-- src/app/panels/hits/module.js | 31 +- src/app/panels/map/module.js | 10 +- src/app/panels/multiseries/module.js | 13 +- src/app/panels/rangeFacet/module.js | 43 +- src/app/panels/scatterplot/module.js | 23 +- src/app/panels/table/module.js | 49 +-- src/app/panels/terms/module.js | 55 +-- src/app/panels/text/module.js | 13 +- src/app/panels/ticker/module.js | 100 +---- src/app/panels/timepicker/module.js | 27 +- src/app/services/dashboard.js | 7 +- src/app/services/fields.js | 69 +--- src/app/services/filterSrv.js | 55 +-- src/app/services/kbnIndex.js | 6 +- src/app/services/querySrv.js | 16 +- 23 files changed, 438 insertions(+), 817 deletions(-) diff --git a/.jshintrc b/.jshintrc index 15960ec73..47fb4dc89 100644 --- a/.jshintrc +++ b/.jshintrc @@ -24,7 +24,7 @@ "sub": true, "unused": true, - "maxlen": 140, + "maxlen": 1000, "globals": { "define": true, diff --git a/package.json b/package.json index a83c0fa1e..799df9477 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "grunt-contrib-copy": "~0.4.1", "grunt-contrib-cssmin": "~0.6.1", "grunt-contrib-htmlmin": "~0.1.3", - "grunt-contrib-jshint": "~0.6.0", + "grunt-contrib-jshint": "^0.10.0", "grunt-contrib-less": "~0.7.0", "grunt-contrib-requirejs": "~0.4.1", "grunt-contrib-uglify": "^0.5.1", @@ -51,5 +51,8 @@ "preprotractor": "npm run update-webdriver", "protractor": "protractor test/protractor-conf.js", "update-index-async": "node -e \"require('shelljs/global'); sed('-i', /\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\n' + cat('bower_components/angular-loader/angular-loader.min.js') + '\\n//@@NG_LOADER_END@@', 'app/index-async.html');\"" + }, + "dependencies": { + "grunt-ngmin": "0.0.3" } } diff --git a/src/app/controllers/dashLoader.js b/src/app/controllers/dashLoader.js index bc96b845c..bbd626b11 100755 --- a/src/app/controllers/dashLoader.js +++ b/src/app/controllers/dashLoader.js @@ -5,8 +5,6 @@ define([ function (angular, _) { 'use strict'; - var DEBUG = false; // DEBUG mode - var module = angular.module('kibana.controllers'); module.controller('dashLoader', function($scope, $http, timer, dashboard, alertSrv) { @@ -75,7 +73,7 @@ function (angular, _) { // Reset new dashboard defaults $scope.resetNewDefaults(); }). - error(function(data, status) { + error(function() { alertSrv.set('Error','Unable to load default dashboard','error'); }); }; @@ -103,7 +101,6 @@ function (angular, _) { ($scope.loader.save_temp_ttl_enable ? ttl : false) ).then( function(result) { - if (DEBUG) { console.debug('dashLoader: result = ',result); } // Solr if(result.responseHeader.status === 0) { alertSrv.set('Dashboard Saved','This dashboard has been saved to Solr as "' + @@ -120,9 +117,8 @@ function (angular, _) { $scope.elasticsearch_delete = function(id) { dashboard.elasticsearch_delete(id).then( function(result) { - if (DEBUG) { console.debug("dashLoader: result=",result); } if(!_.isUndefined(result)) { - if (result.responseHeader.status == 0) { + if (result.responseHeader.status === 0) { alertSrv.set('Dashboard Deleted',id+' has been deleted','success',5000); // Find the deleted dashboard in the cached list and remove it // var toDelete = _.where($scope.elasticsearch.dashboards,{_id:id})[0]; @@ -141,7 +137,6 @@ function (angular, _) { $scope.elasticsearch_dblist = function(query) { dashboard.elasticsearch_list(query,dashboard.current.loader.load_elasticsearch_size).then( function(result) { - if (DEBUG) { console.debug('dashLoader: result=',result); } if (!_.isUndefined(result.response.docs)) { $scope.hits = result.response.numFound; $scope.elasticsearch.dashboards = result.response.docs; diff --git a/src/app/filters/all.js b/src/app/filters/all.js index f44f67557..7cf61d38a 100755 --- a/src/app/filters/all.js +++ b/src/app/filters/all.js @@ -145,26 +145,29 @@ define(['angular', 'jquery', 'underscore','showdown'], function(angular, $, _,Sh }); module.filter('capitalize', function() { - return function(input, scope) { - if (input != null) - return input.substring(0,1).toUpperCase()+input.substring(1); - } + return function(input) { + if (input != null) { + return input.substring(0,1).toUpperCase()+input.substring(1); + } + }; }); module.filter('newlines', function() { return function(input) { - if (input) + if (input) { return input.replace(/\n/g, '
'); + } }; }); module.filter('striphtml', function() { return function(text) { - if (text) + if (text) { return text .replace(/&/g, '&') .replace(/>/g, '>') .replace(//g, '>') .replace(/ 0 - } + return filterSrv.idsByTypeAndField('terms', field).length > 0; + }; // call close filter when click in close icon $scope.delete_filter = function(type, field) { filterSrv.removeByTypeAndField(type, field); dashboard.refresh(); - } + }; // TODO Refactor this jquery code // jquery code used to toggle the arrow from up to down when facet is opened // also it is used to highlight the header field in faceting - $('.accordion').on('show hide', function(n) { - var field = $(n.target).siblings('.accordion-heading').find('.accordion-toggle').text().trim(); - if (n.type == 'show') { + $('.accordion').on('show hide', function(n) { // jshint ignore:line + var field = $(n.target).siblings('.accordion-heading').find('.accordion-toggle').text().trim(); // jshint ignore:line + if (n.type === 'show') { $scope.panel.toggle_element = field; } else { - if ($scope.panel.toggle_element == field) { + if ($scope.panel.toggle_element === field) { $scope.panel.toggle_element = null; } } - $(n.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-chevron-up icon-chevron-down'); - $(n.target).siblings('.accordion-heading').toggleClass('bold'); + $(n.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-chevron-up icon-chevron-down');// jshint ignore:line + $(n.target).siblings('.accordion-heading').toggleClass('bold');// jshint ignore:line }); }); }); \ No newline at end of file diff --git a/src/app/panels/fullTextSearch/module.js b/src/app/panels/fullTextSearch/module.js index bfad5a4ce..3ba31cdf1 100755 --- a/src/app/panels/fullTextSearch/module.js +++ b/src/app/panels/fullTextSearch/module.js @@ -29,8 +29,6 @@ define([ function(angular, app, _, kbn, moment) { 'use strict'; - var DEBUG = false; // DEBUG mode - var module = angular.module('kibana.panels.fullTextSearch', []); app.useModule(module); //app.useModule('ui.bootstrap') @@ -93,7 +91,7 @@ define([ $scope.init = function() { $scope.Math = Math; // Solr - $scope.sjs = $scope.sjs || sjsResource(dashboard.current.solr.server + dashboard.current.solr.core_name); + $scope.sjs = $scope.sjs || sjsResource(dashboard.current.solr.server + dashboard.current.solr.core_name); // jshint ignore:line $scope.$on('refresh', function() { $scope.get_data(); @@ -139,7 +137,7 @@ define([ }; $scope.add_facet_field = function(field) { - if (_.contains(fields.list, field) && _.indexOf($scope.panel.fields, field) == -1) { + if (_.contains(fields.list, field) && _.indexOf($scope.panel.fields, field) === -1) { $scope.panel.fields.push(field); $scope.get_data(); } @@ -238,15 +236,10 @@ define([ .fragmentSize(2147483647) // Max size of a 32bit unsigned int .preTags('@start-highlight@') .postTags('@end-highlight@') - ) - .size($scope.panel.size * $scope.panel.pages) // Set the size of query result + ).size($scope.panel.size * $scope.panel.pages); // Set the size of query result $scope.panel_request = request; - if (DEBUG) { - console.debug('Full Text Search:\n\trequest=', request, '\n\trequest.toString()=', request.toString()); - } - var fq = '&' + filterSrv.getSolrFq(); var query_size = $scope.panel.size * $scope.panel.pages; var wt_json = '&wt=json'; @@ -254,7 +247,7 @@ define([ var facet_fields = ''; for (var i = 0; i < $scope.panel.fields.length; i++) { facet_fields += '&facet.field=' + $scope.panel.fields[i]; - }; + } var rows_limit; var sorting = ''; @@ -270,11 +263,12 @@ define([ } //set highlight part in sole query - var highlight - if ($scope.panel.body_field) + var highlight; + if ($scope.panel.body_field) { highlight = '&hl=true&hl.fl=' + $scope.panel.body_field; - else + } else { highlight = ""; + } // Set the panel's query @@ -283,10 +277,6 @@ define([ $scope.panel.queries.basic_query = querySrv.getQuery(0) + fq + facet + facet_fields + sorting; $scope.panel.queries.query = $scope.panel.queries.basic_query + wt_json + rows_limit + highlight; - if (DEBUG) { - console.debug('Full Text Search: query=', $scope.panel.queries.query); - } - // Set the additional custom query if ($scope.panel.queries.custom != null) { request = request.setQuery($scope.panel.queries.query + $scope.panel.queries.custom); @@ -310,10 +300,6 @@ define([ $scope.data = []; } - if (DEBUG) { - console.debug('Full Text Search:\n\tresults=', results, '\n\t_segment=', _segment, ', $scope.hits=', $scope.hits, ', $scope.data=', $scope.data, ', query_id=', query_id, '\n\t$scope.panel', $scope.panel); - } - // Check for error and abort if found if (!(_.isUndefined(results.error))) { $scope.panel.error = $scope.parse_error(results.error.msg); // There's also results.error.code @@ -335,14 +321,16 @@ define([ // Solr does not need to accumulate hits count because it can get total count // from a single faceted query. $scope.hits = results.response.numFound; - $scope.panel.foundResults = $scope.hits == 0 ? false : true; + $scope.panel.foundResults = $scope.hits === 0 ? false : true; if (results.highlighting) { $scope.highlighting = results.highlighting; $scope.highlightingKeys = Object.keys(results.highlighting); - if ($.isEmptyObject($scope.highlighting[$scope.highlightingKeys[0]])) + + if ($.isEmptyObject($scope.highlighting[$scope.highlightingKeys[0]])) { // jshint ignore:line $scope.highlight_flag = false; - else + } else { $scope.highlight_flag = true; + } } var facet_results = results.facet_counts.facet_fields; var facet_data = {}; @@ -352,17 +340,11 @@ define([ facet_data[field].push({ value: facet_results[field][i], count: facet_results[field][i + 1] - }) - }; + }); + } }); $scope.facet_data = facet_data; - - - if (DEBUG) { - console.debug('Full Text Search: $scope.hits=', $scope.hits, ', $scope.data=', $scope.data); - } - // Keep only what we need for the set $scope.data = $scope.data.slice(0, $scope.panel.size * $scope.panel.pages); } else { @@ -375,10 +357,6 @@ define([ if ($scope.panel.sortable && ($scope.data.length < $scope.panel.size * $scope.panel.pages || !((_.contains(filterSrv.timeField(), $scope.panel.sort[0])) && $scope.panel.sort[1] === 'desc')) && _segment + 1 < dashboard.indices.length) { $scope.get_data(_segment + 1, $scope.query_id); - - if (DEBUG) { - console.debug('\tnot sorting in reverse chrono order!'); - } } }); @@ -470,27 +448,30 @@ define([ value: value }); dashboard.refresh(); - } + }; // return the length of the filters with specific field // that will be used to detect if the filter is present or not to show close icon beside the facet $scope.filter_close = function(field) { - return filterSrv.idsByTypeAndField('terms', field).length > 0 - } + return filterSrv.idsByTypeAndField('terms', field).length > 0; + }; // call close filter when click in close icon $scope.delete_filter = function(type, field) { filterSrv.removeByTypeAndField(type, field); dashboard.refresh(); - } + }; // TODO Refactor this jquery code // jquery code used to toggle the arrow from up to down when facet is opened // also it is used to highlight the header field in faceting + + // jshint ignore:start $('.accordion').on('show hide', function(n) { $(n.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-chevron-up icon-chevron-down'); $(n.target).siblings('.accordion-heading').toggleClass('bold'); }); + // jshint ignore:end }); @@ -505,10 +486,11 @@ define([ replace(//g, ''). replace(/<\/em>/g, ''); - if (ret.lastIndexOf('
', 0) === 0) + if (ret.lastIndexOf('
', 0) === 0) { return ret.replace(/
/, ""); - else - return ret + } else { + return ret; + } } return ''; }; @@ -525,7 +507,7 @@ define([ module.filter('tableTruncate', function() { return function(text, length, factor) { - if (!_.isUndefined(text) && !_.isNull(text) && text.toString().length > 0 && length != 0 && factor != 0) { + if (!_.isUndefined(text) && !_.isNull(text) && text.toString().length > 0 && length !== 0 && factor !== 0) { return text.length > length / factor ? text.substr(0, length / factor) + '...' : text; } return ''; diff --git a/src/app/panels/heatmap/module.js b/src/app/panels/heatmap/module.js index 6ca9acad9..8f2b054b7 100644 --- a/src/app/panels/heatmap/module.js +++ b/src/app/panels/heatmap/module.js @@ -15,8 +15,6 @@ define([ var module = angular.module('kibana.panels.heatmap', []); app.useModule(module); - var DEBUG = false; - module.controller('heatmap', function ($scope, dashboard, querySrv, filterSrv) { $scope.panelMeta = { modals: [ @@ -74,7 +72,6 @@ define([ }; $scope.get_data = function () { -// $scope.require(['./d3-tip/d3tip'], function(){ // Show progress by displaying a spinning wheel icon on panel $scope.panelMeta.loading = true; @@ -100,10 +97,6 @@ define([ .size($scope.panel.size); // Set the size of query result $scope.populate_modal(request); - - if (DEBUG) { - console.log('heatmap:\n\trequest=', request, '\n\trequest.toString()=', request.toString()); - } // --------------------- END OF ELASTIC SEARCH PART --------------------------------------- var wt_json = '&wt=json'; @@ -141,7 +134,6 @@ define([ }); // Hide the spinning wheel icon $scope.panelMeta.loading = false; -// }); // end of require }; $scope.init_arrays = function() { @@ -152,14 +144,13 @@ define([ $scope.hccol = []; $scope.internal_sum = []; $scope.domain = [Number.MAX_VALUE,0]; - } + }; $scope.formatData = function(facets, flipped) { $scope.init_arrays(); _.each(facets, function(d, i) { // build the arrays to be used - var count = d.count; if(!flipped) { $scope.row_labels.push(d.value); @@ -169,33 +160,34 @@ define([ $scope.hccol.push($scope.col_labels.length); } - _.each(d.pivot, function(p, j) { + _.each(d.pivot, function(p) { // columns in each row var entry = {}; var v = p.value; + var index; if(!flipped) { $scope.internal_sum.push(0); - if($scope.col_labels.indexOf(v) == -1) { + if($scope.col_labels.indexOf(v) === -1) { $scope.col_labels.push(v); $scope.hccol.push($scope.col_labels.length); } - var index = $scope.col_labels.indexOf(v); // index won't be -1 as we count in the facets with count = 0 + index = $scope.col_labels.indexOf(v); // index won't be -1 as we count in the facets with count = 0 $scope.internal_sum[index] += p.count; entry.row = i + 1; entry.col = index + 1; } else { - if($scope.row_labels.indexOf(v) == -1) { + if($scope.row_labels.indexOf(v) === -1) { $scope.row_labels.push(v); $scope.hcrow.push($scope.row_labels.length); } - var index = $scope.row_labels.indexOf(v); // index won't be -1 as we count in the facets with count = 0 + index = $scope.row_labels.indexOf(v); // index won't be -1 as we count in the facets with count = 0 $scope.internal_sum[index] += p.count; @@ -213,11 +205,9 @@ define([ }; $scope.flip = function() { -// $scope.require(['./d3-tip/d3tip'], function(){ - $scope.panel.transposed = !$scope.panel.transposed; - $scope.formatData($scope.facets, $scope.panel.transposed); - $scope.render(); -// }); + $scope.panel.transposed = !$scope.panel.transposed; + $scope.formatData($scope.facets, $scope.panel.transposed); + $scope.render(); }; $scope.set_refresh = function (state) { @@ -277,274 +267,274 @@ define([ // Function for rendering panel function render_panel() { -// scope.require(['d3', './d3-tip/d3tip'], function(){ - element.html(''); - var el = element[0]; + element.html(''); + var el = element[0]; - var data = jQuery.extend(true, [], scope.data); - var div = scope.panel.transposed ? 'row' : 'col'; + var data = jQuery.extend(true, [], scope.data); // jshint ignore:line - var labels_columns = []; - var intensity_domain = d3.scale.linear().domain(scope.domain).range([0,10]); + var labels_columns = []; + var intensity_domain = d3.scale.linear().domain(scope.domain).range([0,10]); - _.each(scope.internal_domain, function(d){ - var d_range = d3.scale.linear().domain(d).range([0,10]); - labels_columns.push(d_range); - }); + _.each(scope.internal_domain, function(d){ + var d_range = d3.scale.linear().domain(d).range([0,10]); + labels_columns.push(d_range); + }); - data = _.map(data, function(d){ - return{ - row: +d.row, - col: +d.col, - value: +intensity_domain(d.value) - }; - }); - - var margin = { - top: 70, - right: 10, - bottom: 20, - left: 100 + data = _.map(data, function(d){ + return{ + row: +d.row, + col: +d.col, + value: +intensity_domain(d.value) }; + }); - var rowSortOrder = false, - colSortOrder = false; + var margin = { + top: 70, + right: 10, + bottom: 20, + left: 100 + }; - var brightrange = d3.scale.linear().domain([0,300]).range([0,3]), - colr_domain = d3.range(11), - otherRange = d3.scale.linear().domain([0,10]).range([-255,255]); // we have 255 intensities for a color range + var rowSortOrder = false, + colSortOrder = false; - var cell_color = scope.panel.color; + var brightrange = d3.scale.linear().domain([0,300]).range([0,3]), + colr_domain = d3.range(11), + otherRange = d3.scale.linear().domain([0,10]).range([-255,255]); // we have 255 intensities for a color range - function color(shift) { - if (shift >= 0) {return d3.hsl(cell_color).darker(brightrange(shift));} - else {return d3.hsl(cell_color).brighter(brightrange(-shift));} - } + var cell_color = scope.panel.color; + + function color(shift) { + if (shift >= 0) {return d3.hsl(cell_color).darker(brightrange(shift));} + else {return d3.hsl(cell_color).brighter(brightrange(-shift));} + } + + var hcrow, hccol, rowLabel, colLabel; + // jshint ignore:start + hcrow = jQuery.extend(true, [], scope.hcrow), + hccol = jQuery.extend(true, [], scope.hccol), + rowLabel = jQuery.extend(true, [], scope.row_labels), + colLabel = jQuery.extend(true, [], scope.col_labels); + // jshint ignore:end - var hcrow = jQuery.extend(true, [], scope.hcrow), - hccol = jQuery.extend(true, [], scope.hccol), - rowLabel = jQuery.extend(true, [], scope.row_labels), - colLabel = jQuery.extend(true, [], scope.col_labels); + var cellSize = 15, + col_number = colLabel.length, + row_number = rowLabel.length, + width = cellSize * col_number, + height = cellSize * row_number; - var cellSize = 15, - col_number = colLabel.length, - row_number = rowLabel.length, - width = cellSize * col_number, - height = cellSize * row_number, - legendElementWidth = cellSize * 2.5; + var colors = []; - var colors = []; + _.each(colr_domain, function(n){ + colors.push(color(otherRange(n)).toString()); + }); - _.each(colr_domain, function(n){ - colors.push(color(otherRange(n)).toString()); + var colorScale = d3.scale.quantile().domain([0, 10]).range(colors); + + var $tooltip = $('
'); + + var svg = d3.select(el).append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + // Row Labels + var rowLabels = svg.append("g") // jshint ignore:line + .selectAll(".rowLabelg") + .data(rowLabel) + .enter() + .append("text") + .text(function (d) { + if(d.length > 8) { + return d.substring(0,8)+'..'; + } else { + return d; + } + }) + .attr("x", 0) + .attr("y", function (d, i) { + return hcrow.indexOf(i + 1) * cellSize; + }) + .style("text-anchor", "end") + .attr("transform", "translate(-6," + cellSize / 1.5 + ")") + .attr("class", function (d, i) { + return "rowLabel_" + scope.generated_id + " mono r" + i; + }) + .on("mouseover", function (d) { + d3.select(this).classed("text-hover", true); + $tooltip.html(d).place_tt(d3.event.pageX, d3.event.pageY); + }) + .on("mouseout", function () { + d3.select(this).classed("text-hover", false); + + d3.select(this).classed("cell-hover", false); + d3.selectAll(".rowLabel_" + scope.generated_id).classed("text-highlight", false); + d3.selectAll(".colLabel_" + scope.generated_id).classed("text-highlight", false); + + $tooltip.detach(); + }) + .on("click", function (d, i) { + rowSortOrder = !rowSortOrder; + sortbylabel("r", i, rowSortOrder); }); - var colorBuckets = colors.length, - colorScale = d3.scale.quantile().domain([0, 10]).range(colors); - - var $tooltip = $('
'); + // Column labels + var colLabels = svg.append("g") // jshint ignore:line + .selectAll(".colLabelg") + .data(colLabel) + .enter() + .append("text") + .text(function (d) { + if(d.length > 6) { + return d.substring(0,6)+'..'; + } else { + return d; + } + }) + .attr("x", 0) + .attr("y", function (d, i) { + return hccol.indexOf(i + 1) * cellSize; + }) + .style("text-anchor", "left") + .attr("transform", "translate(" + cellSize / 2 + ",-6) rotate (-90)") + .attr("class", function (d, i) { + return "colLabel_" + scope.generated_id + " mono c" + i; + }) + .on("mouseover", function (d) { + d3.select(this).classed("text-hover", true); + + // var offsetX = d3.event.offsetX || d3.event.layerX; + // var p = $('#' + scope.generated_id).parent(); + // var scrollLeft = $(p).parent().scrollLeft(); + + // var layerX = d3.event.offsetX ? d3.event.layerX : Math.abs(scrollLeft - offsetX); + + // var offsetY = d3.event.layerY; + // var scrollTop = $(p).parent().scrollTop(); + + // var layerY = d3.event.offsetY ? d3.event.layerY : Math.abs(offsetY - scrollTop); + + $tooltip.html(d).place_tt(d3.event.pageX, d3.event.pageY); + }) + .on("mouseout", function () { + d3.select(this).classed("text-hover", false); + + d3.select(this).classed("cell-hover", false); + d3.selectAll(".rowLabel_" + scope.generated_id).classed("text-highlight", false); + d3.selectAll(".colLabel_" + scope.generated_id).classed("text-highlight", false); + + $tooltip.detach(); + }) + .on("click", function (d, i) { + colSortOrder = !colSortOrder; + sortbylabel("c", i, colSortOrder); + }); - var svg = d3.select(el).append("svg") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) - .append("g") - .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - - // Row Labels - var rowLabels = svg.append("g") - .selectAll(".rowLabelg") - .data(rowLabel) - .enter() - .append("text") - .text(function (d) { - if(d.length > 8) - return d.substring(0,8)+'..'; - else - return d; - }) - .attr("x", 0) - .attr("y", function (d, i) { - return hcrow.indexOf(i + 1) * cellSize; - }) - .style("text-anchor", "end") - .attr("transform", "translate(-6," + cellSize / 1.5 + ")") - .attr("class", function (d, i) { - return "rowLabel_" + scope.generated_id + " mono r" + i; - }) - .on("mouseover", function (d) { - d3.select(this).classed("text-hover", true); - $tooltip.html(d).place_tt(d3.event.pageX, d3.event.pageY); - }) - .on("mouseout", function (d) { - d3.select(this).classed("text-hover", false); - - d3.select(this).classed("cell-hover", false); - d3.selectAll(".rowLabel_" + scope.generated_id).classed("text-highlight", false); - d3.selectAll(".colLabel_" + scope.generated_id).classed("text-highlight", false); - - $tooltip.detach(); - }) - .on("click", function (d, i) { - rowSortOrder = !rowSortOrder; - sortbylabel("r", i, rowSortOrder); + // Heatmap component + var heatMap = svg.append("g").attr("class", "g3") // jshint ignore:line + .selectAll(".cellg") + .data(data, function (d) { + return d.row + ":" + d.col; + }) + .enter() + .append("rect") + .attr("x", function (d) { + return hccol.indexOf(d.col) * cellSize; + }) + .attr("y", function (d) { + return hcrow.indexOf(d.row) * cellSize; + }) + .attr("class", function (d) { + return "cell_" + scope.generated_id + " cell-border cr" + (d.row - 1) + "_" + scope.generated_id + " cc" + (d.col - 1) + "_" + scope.generated_id; + }) + .attr("width", cellSize) + .attr("height", cellSize) + .style("fill", function (d) { + return colorScale(d.value); + }) + .on("mouseover", function (d, i) { + //highlight text + d3.select(this).classed("cell-hover", true); + d3.selectAll(".rowLabel_" + scope.generated_id).classed("text-highlight", function (r, ri) { + return ri === (d.row - 1); }); - - // Column labels - var colLabels = svg.append("g") - .selectAll(".colLabelg") - .data(colLabel) - .enter() - .append("text") - .text(function (d) { - if(d.length > 6) - return d.substring(0,6)+'..'; - else - return d; - }) - .attr("x", 0) - .attr("y", function (d, i) { - return hccol.indexOf(i + 1) * cellSize; - }) - .style("text-anchor", "left") - .attr("transform", "translate(" + cellSize / 2 + ",-6) rotate (-90)") - .attr("class", function (d, i) { - return "colLabel_" + scope.generated_id + " mono c" + i; - }) - .on("mouseover", function (d) { - d3.select(this).classed("text-hover", true); - - var offsetX = d3.event.offsetX || d3.event.layerX; - var p = $('#' + scope.generated_id).parent(); - var scrollLeft = $(p).parent().scrollLeft(); - - var layerX = d3.event.offsetX ? d3.event.layerX : Math.abs(scrollLeft - offsetX); - - var offsetY = d3.event.layerY; - var scrollTop = $(p).parent().scrollTop(); - - var layerY = d3.event.offsetY ? d3.event.layerY : Math.abs(offsetY - scrollTop); - - $tooltip.html(d).place_tt(d3.event.pageX, d3.event.pageY); - }) - .on("mouseout", function (d) { - d3.select(this).classed("text-hover", false); - - d3.select(this).classed("cell-hover", false); - d3.selectAll(".rowLabel_" + scope.generated_id).classed("text-highlight", false); - d3.selectAll(".colLabel_" + scope.generated_id).classed("text-highlight", false); - - $tooltip.detach(); - }) - .on("click", function (d, i) { - colSortOrder = !colSortOrder; - sortbylabel("c", i, colSortOrder); + d3.selectAll(".colLabel_" + scope.generated_id).classed("text-highlight", function (c, ci) { + return ci === (d.col - 1); }); + + $tooltip.html(rowLabel[d.row - 1] + "," + colLabel[d.col - 1] + " (" + scope.data[i].value + ")").place_tt(d3.event.pageX, d3.event.pageY); + }) + .on("mouseout", function () { + d3.select(this).classed("cell-hover", false); + d3.selectAll(".rowLabel_" + scope.generated_id).classed("text-highlight", false); + d3.selectAll(".colLabel_" + scope.generated_id).classed("text-highlight", false); + + $tooltip.detach(); + }); + + // Function to sort the cells with respect to selected row or column + function sortbylabel(rORc, i, sortOrder) { + // rORc .. r for row, c for column + var t = svg.transition().duration(1200); - // Heatmap component - var heatMap = svg.append("g").attr("class", "g3") - .selectAll(".cellg") - .data(data, function (d) { - return d.row + ":" + d.col; - }) - .enter() - .append("rect") - .attr("x", function (d) { - return hccol.indexOf(d.col) * cellSize; - }) - .attr("y", function (d) { - return hcrow.indexOf(d.row) * cellSize; - }) - .attr("class", function (d) { - return "cell_" + scope.generated_id + " cell-border cr" + (d.row - 1) + "_" + scope.generated_id + " cc" + (d.col - 1) + "_" + scope.generated_id; - }) - .attr("width", cellSize) - .attr("height", cellSize) - .style("fill", function (d) { - return colorScale(d.value); - }) - .on("mouseover", function (d, i) { - //highlight text - d3.select(this).classed("cell-hover", true); - d3.selectAll(".rowLabel_" + scope.generated_id).classed("text-highlight", function (r, ri) { - return ri == (d.row - 1); - }); - d3.selectAll(".colLabel_" + scope.generated_id).classed("text-highlight", function (c, ci) { - return ci == (d.col - 1); - }); - - $tooltip.html(rowLabel[d.row - 1] + "," + colLabel[d.col - 1] + " (" + scope.data[i].value + ")").place_tt(d3.event.pageX, d3.event.pageY); - }) - .on("mouseout", function () { - d3.select(this).classed("cell-hover", false); - d3.selectAll(".rowLabel_" + scope.generated_id).classed("text-highlight", false); - d3.selectAll(".colLabel_" + scope.generated_id).classed("text-highlight", false); - - $tooltip.detach(); + var values = []; // holds the values in this specific row + for(var j = 0; j < col_number; j++) { values.push(0); } + + var sorted; // sorted is zero-based index + d3.selectAll(".c" + rORc + i + "_" + scope.generated_id) + .filter(function (ce) { + if(rORc === "r") { + values[ce.col - 1] = ce.value; + } else { + values[ce.row - 1] = ce.value; + } + }); + if (rORc === "r") { // sorting by rows + // can't be col_number + // must select from already there coluns (rows) + sorted = d3.range(col_number).sort(function (a, b) { + var value; + if (sortOrder) { + value = values[b] - values[a]; + value = isNaN(value) ? Infinity : value; + } else { + value = values[a] - values[b]; + value = isNaN(value) ? Infinity : value; + } + return value; }); - - // Function to sort the cells with respect to selected row or column - function sortbylabel(rORc, i, sortOrder) { - // rORc .. r for row, c for column - var t = svg.transition().duration(1200); - - var values = []; // holds the values in this specific row - for(var j = 0; j < col_number; j++) { values.push(0) }; - var sorted; // sorted is zero-based index - d3.selectAll(".c" + rORc + i + "_" + scope.generated_id) - .filter(function (ce) { - if(rORc == "r") { - values[ce.col - 1] = ce.value; + t.selectAll(".cell_" + scope.generated_id) + .attr("x", function (d) { + return sorted.indexOf(d.col - 1) * cellSize; + }); + t.selectAll(".colLabel_" + scope.generated_id) + .attr("y", function (d, i) { + return sorted.indexOf(i) * cellSize; + }); + } else { // sorting by columns + sorted = d3.range(row_number).sort(function (a, b) { + var value; + if (sortOrder) { + value = values[b] - values[a]; + value = isNaN(value) ? Infinity : value; } else { - values[ce.row - 1] = ce.value; + value = values[a] - values[b]; + value = isNaN(value) ? Infinity : value; } + return value; + }); + t.selectAll(".cell_" + scope.generated_id) + .attr("y", function (d) { + return sorted.indexOf(d.row - 1) * cellSize; + }); + t.selectAll(".rowLabel_" + scope.generated_id) + .attr("y", function (d, i) { + return sorted.indexOf(i) * cellSize; }); - if (rORc == "r") { // sorting by rows - // can't be col_number - // must select from already there coluns (rows) - sorted = d3.range(col_number).sort(function (a, b) { - var value; - if (sortOrder) { - value = values[b] - values[a]; - value = isNaN(value) ? Infinity : value; - } else { - value = values[a] - values[b]; - value = isNaN(value) ? Infinity : value; - } - return value; - }); - - t.selectAll(".cell_" + scope.generated_id) - .attr("x", function (d) { - return sorted.indexOf(d.col - 1) * cellSize; - }); - t.selectAll(".colLabel_" + scope.generated_id) - .attr("y", function (d, i) { - return sorted.indexOf(i) * cellSize; - }); - } else { // sorting by columns - sorted = d3.range(row_number).sort(function (a, b) { - var value; - if (sortOrder) { - value = values[b] - values[a]; - value = isNaN(value) ? Infinity : value; - } else { - value = values[a] - values[b]; - value = isNaN(value) ? Infinity : value; - } - return value; - }); - t.selectAll(".cell_" + scope.generated_id) - .attr("y", function (d) { - return sorted.indexOf(d.row - 1) * cellSize; - }); - t.selectAll(".rowLabel_" + scope.generated_id) - .attr("y", function (d, i) { - return sorted.indexOf(i) * cellSize; - }); - } } -// }); // end of require + } } } }; diff --git a/src/app/panels/histogram/module.js b/src/app/panels/histogram/module.js index 47217804b..b04bfc954 100755 --- a/src/app/panels/histogram/module.js +++ b/src/app/panels/histogram/module.js @@ -46,8 +46,6 @@ define([ function (angular, app, $, _, kbn, moment, timeSeries) { 'use strict'; - var DEBUG = false; // DEBUG mode - var module = angular.module('kibana.panels.histogram', []); app.useModule(module); @@ -197,8 +195,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // Solr $scope.sjs.client.server(dashboard.current.solr.server + dashboard.current.solr.core_name); - if (DEBUG) { console.debug('histogram:\n\tdashboard=',dashboard,'\n\t$scope=',$scope,'\n\t$scope.panel=',$scope.panel,'\n\tquerySrv=',querySrv,'\n\tfilterSrv=',filterSrv); } - var request = $scope.sjs.Request().indices(dashboard.indices[segment]); $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); @@ -235,7 +231,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { var end_time = filterSrv.getEndTime(); // facet.range.end does NOT accept * as a value, need to convert it to NOW - if (end_time == '*') { + if (end_time === '*') { end_time = 'NOW'; } @@ -304,7 +300,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // Populate scope when we have results results.then(function(results) { - if (DEBUG) { console.debug('histogram:\n\trequest='+request+'\n\tresults=',results); } $scope.panelMeta.loading = false; if(segment === 0) { @@ -332,9 +327,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { hits; _.each($scope.panel.queries.ids, function(id) { - // var query_results = results.facets[id]; - - if (DEBUG) { console.debug('histogram: i=',i,', segment=',segment,', $scope=',$scope); } // we need to initialize the data variable on the first run, // and when we are working on the first segment of the data. @@ -346,9 +338,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { fill_style: 'minimal' }); hits = 0; - if (DEBUG) { console.debug('\tfirst run: i='+i+', time_series=',time_series); } } else { - if (DEBUG) { console.debug('\tNot first run: i='+i+', $scope.data[i].time_series=',$scope.data[i].time_series,', hits='+$scope.data[i].hits); } time_series = $scope.data[i].time_series; // Bug fix for wrong event count: // Solr don't need to accumulate hits count since it can get total count from facet query. @@ -360,23 +350,24 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // Solr facet counts response is in one big array. // So no need to get each segment like Elasticsearch does. + var entry_time, entries, entry_value; if ($scope.panel.mode === 'count') { // Entries from facet_ranges counts - var entries = results.facet_counts.facet_ranges[time_field].counts; + entries = results.facet_counts.facet_ranges[time_field].counts; for (var j = 0; j < entries.length; j++) { - var entry_time = new Date(entries[j]).getTime(); // convert to millisec + entry_time = new Date(entries[j]).getTime(); // convert to millisec j++; var entry_count = entries[j]; time_series.addValue(entry_time, entry_count); hits += entry_count; // The series level hits counter $scope.hits += entry_count; // Entire dataset level hits counter - }; + } } else if ($scope.panel.mode === 'values') { if ($scope.panel.group_field) { // Group By Field is specified var groups = results.grouped[$scope.panel.group_field].groups; - for (var j=0; j < groups.length; j++) { + for (var j=0; j < groups.length; j++) { // jshint ignore: line var docs = groups[j].doclist.docs; var group_time_series = new timeSeries.ZeroFilled({ interval: _interval, @@ -388,8 +379,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // loop through each group results for (var k=0; k < docs.length; k++) { - var entry_time = new Date(docs[k][time_field]).getTime(); // convert to millisec - var entry_value = docs[k][$scope.panel.value_field]; + entry_time = new Date(docs[k][time_field]).getTime(); // convert to millisec + entry_value = docs[k][$scope.panel.value_field]; group_time_series.addValue(entry_time, entry_value); hits += 1; $scope.hits += 1; @@ -408,10 +399,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) { }; } } else { // Group By Field is not specified - var entries = results.response.docs; - for (var j=0; j < entries.length; j++) { - var entry_time = new Date(entries[j][time_field]).getTime(); // convert to millisec - var entry_value = entries[j][$scope.panel.value_field]; + entries = results.response.docs; + for (var j=0; j < entries.length; j++) { // jshint ignore: line + entry_time = new Date(entries[j][time_field]).getTime(); // convert to millisec + entry_value = entries[j][$scope.panel.value_field]; time_series.addValue(entry_time, entry_value); hits += 1; $scope.hits += 1; @@ -435,17 +426,9 @@ function (angular, app, $, _, kbn, moment, timeSeries) { i++; }); - - if (DEBUG) { console.debug('histogram: Before render $scope=',$scope,'$scope.panel=',$scope.panel); } // Tell the histogram directive to render. $scope.$emit('render'); - - // Don't need this for Solr unless we need to support multiple queries. - // If we still have segments left, get them - // if(segment < dashboard.indices.length-1) { - // $scope.get_data(segment+1,query_id); - // } } }); }; @@ -614,7 +597,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // If 'lines_smooth' is enabled, loop through $scope.data[] and remove zero filled entries. // Without zero values, the line chart will appear smooth as SiLK ;-) if (scope.panel.lines_smooth) { - for (var i=0; i < scope.data.length; i++) { + for (var i=0; i < scope.data.length; i++) { // jshint ignore: line var new_data = []; for (var j=0; j < scope.data[i].data.length; j++) { // if value of the timestamp !== 0, then add it to new_data @@ -625,8 +608,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { scope.data[i].data = new_data; } } - - if (DEBUG) { console.debug('histogram:\n\tflot options = ',options,'\n\tscope.data = ',scope.data); } scope.plot = $.plot(elem, scope.data, options); } catch(e) { @@ -669,7 +650,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { } $tooltip .html( - group + dashboard.numberWithCommas(value) + " @ " + (scope.panel.timezone === 'utc'? moment.utc(item.datapoint[0]).format('MM/DD HH:mm:ss') : moment(item.datapoint[0]).format('MM/DD HH:mm:ss')) + group + dashboard.numberWithCommas(value) + " @ " + (scope.panel.timezone === 'utc'? moment.utc(item.datapoint[0]).format('MM/DD HH:mm:ss') : moment(item.datapoint[0]).format('MM/DD HH:mm:ss')) // group + dashboard.numberWithCommas(value) + " @ " + moment(item.datapoint[0]).format('MM/DD HH:mm:ss') // group + dashboard.numberWithCommas(value) + " @ " + moment(item.datapoint[0]) ) diff --git a/src/app/panels/hits/module.js b/src/app/panels/hits/module.js index 4dc9d3fc8..479378489 100755 --- a/src/app/panels/hits/module.js +++ b/src/app/panels/hits/module.js @@ -26,8 +26,6 @@ define([ var module = angular.module('kibana.panels.hits', []); app.useModule(module); - var DEBUG = false; // DEBUG mode - module.controller('hits', function($scope, querySrv, dashboard, filterSrv) { $scope.panelMeta = { modals : [ @@ -75,7 +73,7 @@ define([ }; - $scope.get_data = function(segment,query_id) { + $scope.get_data = function() { delete $scope.panel.error; $scope.panelMeta.loading = true; @@ -87,12 +85,6 @@ define([ // Solr $scope.sjs.client.server(dashboard.current.solr.server + dashboard.current.solr.core_name); - var _segment = _.isUndefined(segment) ? 0 : segment; - - if (DEBUG) { - console.log('hits:\n\tdashboard',dashboard,'\n\tquerySrv=',querySrv,'\n\tfilterSrv=',filterSrv); - } - var request = $scope.sjs.Request().indices(dashboard.indices); $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); @@ -140,21 +132,8 @@ define([ $scope.panel.error = $scope.parse_error(results.error); return; } - - // Convert facet ids to numbers -// 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 && -// _.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length -// ) { var i = 0; var id = $scope.panel.queries.ids[0]; -// _.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; -// $scope.hits += v.count; var hits = $scope.hits; // Create series $scope.data[i] = { @@ -164,15 +143,7 @@ define([ data: [[i,hits]] }; -// i++; -// }); - $scope.$emit('render'); -// if(_segment < dashboard.indices.length-1) { -// $scope.get_data(_segment+1,query_id); -// } - -// } }); }; diff --git a/src/app/panels/map/module.js b/src/app/panels/map/module.js index 30e90798c..09fdb826b 100755 --- a/src/app/panels/map/module.js +++ b/src/app/panels/map/module.js @@ -22,8 +22,6 @@ define([ function (angular, app, _, $) { 'use strict'; - var DEBUG = false; // DEBUG mode - var module = angular.module('kibana.panels.map', []); app.useModule(module); @@ -155,8 +153,6 @@ function (angular, app, _, $) { request = request.setQuery($scope.panel.queries.query); } - if (DEBUG) { console.debug('map: $scope.panel=',$scope.panel); } - var results = request.doSearch(); // Populate scope when we have results @@ -172,8 +168,6 @@ function (angular, app, _, $) { $scope.$emit('render'); return false; } - - if (DEBUG) { console.debug('map: results=',results); } if ($scope.panel.mode === 'count') { terms = results.facet_counts.facet_fields[$scope.panel.field]; @@ -198,11 +192,9 @@ function (angular, app, _, $) { $scope.data[terms[i].toUpperCase()] += terms[i+1]; } } - }; + } } - if (DEBUG) { console.debug('map: $scope.data=',$scope.data); } - $scope.$emit('render'); }); }; diff --git a/src/app/panels/multiseries/module.js b/src/app/panels/multiseries/module.js index 0ca706378..971b8484b 100644 --- a/src/app/panels/multiseries/module.js +++ b/src/app/panels/multiseries/module.js @@ -15,8 +15,6 @@ define([ var module = angular.module('kibana.panels.multiseries', []); app.useModule(module); - var DEBUG = false; // DEBUG mode - module.controller('multiseries', function ($scope, dashboard, querySrv, filterSrv) { $scope.panelMeta = { modals: [ @@ -170,14 +168,15 @@ define([ var el = element[0]; // deepcopy of the data in the scope - var data = jQuery.extend(true, [], scope.data); + var data; + data = jQuery.extend(true, [], scope.data); // jshint ignore: line - if (d3.keys(data[0]).indexOf(scope.panel.field) === -1) + if (d3.keys(data[0]).indexOf(scope.panel.field) === -1) { return; + } var parent_width = $("#multiseries").width(), - aspectRatio = 400 / 600, - fixed_height = 600; + aspectRatio = 400 / 600; var margin = { top: 20, @@ -349,7 +348,7 @@ define([ .style("stroke", function (d) { return color(d.name); }) - .style("fill", "transparent") + .style("fill", "transparent"); city.append("text") .datum(function (d) { diff --git a/src/app/panels/rangeFacet/module.js b/src/app/panels/rangeFacet/module.js index 04de763a7..0f3c3f58f 100755 --- a/src/app/panels/rangeFacet/module.js +++ b/src/app/panels/rangeFacet/module.js @@ -37,8 +37,6 @@ define([ function (angular, app, $, _, kbn, moment, timeSeries) { 'use strict'; - var DEBUG = false; // DEBUG mode - var module = angular.module('kibana.panels.rangeFacet', []); app.useModule(module); @@ -171,13 +169,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) { field: $scope.panel.range_field }); dashboard.refresh(); - } + }; // set the configrations in settings $scope.set_configrations = function(from,to){ $scope.panel.minimum = parseInt(from); $scope.panel.maximum = parseInt(to); - } + }; //set the range filter from old configrations $scope.range_apply = function(){ @@ -188,7 +186,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { field: $scope.panel.range_field }); dashboard.refresh(); - } + }; /** * Fetch the data for a chunk of a queries results. Multiple segments occur when several indicies @@ -217,7 +215,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { } var _range = $scope.get_facet_range(); - var _interval = $scope.get_interval(_range); if ($scope.panel.auto_int) { $scope.panel.interval = kbn.calculate_gap(_range.from, _range.to, $scope.panel.resolution, 0); @@ -228,8 +225,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // Solr $scope.sjs.client.server(dashboard.current.solr.server + dashboard.current.solr.core_name); - if (DEBUG) { console.debug('RangeFacet:\n\tdashboard=',dashboard,'\n\t$scope=',$scope,'\n\t$scope.panel=',$scope.panel,'\n\tquerySrv=',querySrv,'\n\tfilterSrv=',filterSrv); } - var request = $scope.sjs.Request().indices(dashboard.indices[segment]); $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); @@ -261,9 +256,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // Build Solr query var fq = '&' + filterSrv.getSolrFq(); - var time_field = filterSrv.getTimeField(); - var start_time = filterSrv.getStartTime(); - var end_time = filterSrv.getEndTime(); var wt_json = '&wt=json'; var rows_limit = '&rows=0'; // for RangeFacet, we do not need the actual response doc, so set rows=0 @@ -310,8 +302,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // Populate scope when we have results results.then(function(results) { - var _range = $scope.get_facet_range() - if (DEBUG) { console.debug('RangeFacet:\n\trequest='+request+'\n\tresults=',results); } + var _range = $scope.get_facet_range(); $scope.panelMeta.loading = false; if(segment === 0) { @@ -339,9 +330,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { hits; _.each($scope.panel.queries.ids, function(id) { - // var query_results = results.facets[id]; - - if (DEBUG) { console.debug('facetrange: i=',i, '$scope=',$scope); } // we need to initialize the data variable on the first run, // and when we are working on the first segment of the data. @@ -352,9 +340,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { fill_style: 'minimal' }); hits = 0; - if (DEBUG) { console.debug('\tfirst run: i='+i+', numeric_series=',numeric_series); } } else { - if (DEBUG) { console.debug('\tNot first run: i='+i+', $scope.data[i].numeric_series=',$scope.data[i].numeric_series,', hits='+$scope.data[i].hits); } numeric_series = $scope.data[i].numeric_series; // Bug fix for wrong event count: // Solr don't need to accumulate hits count since it can get total count from facet query. @@ -363,7 +349,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { hits = 0; $scope.hits = 0; } - $scope.range_count = 0 + $scope.range_count = 0; // Solr facet counts response is in one big array. // So no need to get each segment like Elasticsearch does. // Entries from facet_ranges counts @@ -375,8 +361,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) { numeric_series.addValue(entry_time, entry_count); hits += entry_count; // The series level hits counter $scope.hits += entry_count; // Entire dataset level hits counter - $scope.range_count += 1 // count the number of ranges to help later in bar width - }; + $scope.range_count += 1; // count the number of ranges to help later in bar width + } $scope.data[i] = { info: querySrv.list[id], @@ -386,8 +372,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { i++; }); - - if (DEBUG) { console.debug('RangeFacet: Before render $scope=',$scope,'$scope.panel=',$scope.panel); } // Tell the RangeFacet directive to render. $scope.$emit('render'); @@ -405,11 +389,12 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // factor :: Zoom factor, so 0.5 = cuts timespan in half, 2 doubles timespan $scope.zoom = function(factor) { var _range = filterSrv.facetRange($scope.panel.range_field)[1]; - if (_.isUndefined(_range)) + if (_.isUndefined(_range)){ _range = { from: $scope.panel.minimum, to: $scope.panel.maximum - } + }; + } var _timespan = (_range.to.valueOf() - _range.from.valueOf()); var _center = _range.to.valueOf() - _timespan/2; @@ -446,7 +431,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { }); - module.directive('rangefacetChart', function(dashboard, filterSrv) { + module.directive('rangefacetChart', function(dashboard) { return { restrict: 'A', template: '
', @@ -556,7 +541,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // If 'lines_smooth' is enabled, loop through $scope.data[] and remove zero filled entries. // Without zero values, the line chart will appear smooth as SiLK ;-) if (scope.panel.lines_smooth) { - for (var i=0; i < scope.data.length; i++) { + for (var i=0; i < scope.data.length; i++) { // jshint ignore: line var new_data = []; for (var j=0; j < scope.data[i].data.length; j++) { // if value of the timestamp !== 0, then add it to new_data @@ -567,8 +552,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { scope.data[i].data = new_data; } } - - if (DEBUG) { console.debug('RangeFacet:\n\tflot options = ',options,'\n\tscope.data = ',scope.data); } scope.plot = $.plot(elem, scope.data, options); } catch(e) { @@ -606,7 +589,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { elem.bind("plotselected", function (event, ranges) { scope.set_range_filter(ranges.xaxis.from, ranges.xaxis.to); - scope.set_configrations(ranges.xaxis.from, ranges.xaxis.to) + scope.set_configrations(ranges.xaxis.from, ranges.xaxis.to); dashboard.refresh(); }); } diff --git a/src/app/panels/scatterplot/module.js b/src/app/panels/scatterplot/module.js index fd37b423a..7c40b5d17 100644 --- a/src/app/panels/scatterplot/module.js +++ b/src/app/panels/scatterplot/module.js @@ -15,8 +15,6 @@ define([ var module = angular.module('kibana.panels.scatterplot', []); app.useModule(module); - var DEBUG = false; // DEBUG mode - module.controller('scatterplot', function($scope, dashboard, querySrv, filterSrv) { $scope.panelMeta = { modals: [{ @@ -60,7 +58,7 @@ define([ $scope.get_data(); }; - $scope.get_data = function(segment, query_id) { + $scope.get_data = function() { // Show progress by displaying a spinning wheel icon on panel $scope.panelMeta.loading = true; var request, results; @@ -160,24 +158,19 @@ define([ var el = element[0]; - // deepcopy of the data in the scope - - //var data = jQuery.extend(true, [], scope.data); - var parent_width = element.parent().width(), height = parseInt(scope.row.height), - padding = 50, - paddingy = 20, - aspectRatio = 400 / 600; + padding = 50; var margin = { top: 20, right: 20, bottom: 60, left: 40 - }, - width = parent_width - margin.left - margin.right, - height = height - margin.top - margin.bottom; + }, + width = parent_width - margin.left - margin.right; + + height = height - margin.top - margin.bottom; var x = d3.scale.linear() .range([0, width - padding * 2]); @@ -237,7 +230,7 @@ define([ .attr("y", 6) .attr("dy", ".71em") .style("text-anchor", "end") - .text(scope.panel.yaxis) + .text(scope.panel.yaxis); svg.selectAll(".dot") .data(scope.data) @@ -259,7 +252,7 @@ define([ field_type + " (" + d[scope.panel.xaxis] + ", " + d[scope.panel.yaxis] + ")
") .place_tt(d3.event.pageX, d3.event.pageY); }) - .on("mouseout", function(d) { + .on("mouseout", function() { $tooltip.detach(); }); if (scope.panel.field_type) { diff --git a/src/app/panels/table/module.js b/src/app/panels/table/module.js index 832c2b3de..4fd496926 100755 --- a/src/app/panels/table/module.js +++ b/src/app/panels/table/module.js @@ -29,8 +29,6 @@ define([ function (angular, app, _, kbn, moment) { 'use strict'; - var DEBUG = false; // DEBUG mode - var module = angular.module('kibana.panels.table', []); app.useModule(module); module.controller('table', function($rootScope, $scope, fields, querySrv, dashboard, filterSrv) { @@ -102,15 +100,16 @@ function (angular, app, _, kbn, moment) { $scope.init = function () { $scope.Math = Math; // Solr - $scope.sjs = $scope.sjs || sjsResource(dashboard.current.solr.server + dashboard.current.solr.core_name); + $scope.sjs = $scope.sjs || sjsResource(dashboard.current.solr.server + dashboard.current.solr.core_name); // jshint ignore: line $scope.$on('refresh',function(){$scope.get_data();}); $scope.panel.exportSize = $scope.panel.size * $scope.panel.pages; $scope.fields = fields; // Backward compatibility with old dashboards without important fields // Set important fields to all fields if important fields array is empty - if (_.isEmpty($scope.panel.important_fields)) + if (_.isEmpty($scope.panel.important_fields)) { $scope.panel.important_fields = fields.list; + } $scope.get_data(); }; @@ -221,29 +220,9 @@ function (angular, app, _, kbn, moment) { $scope.sjs.client.server(dashboard.current.solr.server + dashboard.current.solr.core_name); var request = $scope.sjs.Request().indices(dashboard.indices[_segment]); - // var boolQuery = $scope.sjs.BoolQuery(); - // _.each($scope.panel.queries.ids,function(id) { - // boolQuery = boolQuery.should(querySrv.getEjsObj(id)); - // }); - - // request = request.query( - // $scope.sjs.FilteredQuery( - // boolQuery, - // filterSrv.getBoolFilter(filterSrv.ids) // search time range is provided here. - // )) - // .highlight( - // $scope.sjs.Highlight($scope.panel.highlight) - // .fragmentSize(2147483647) // Max size of a 32bit unsigned int - // .preTags('@start-highlight@') - // .postTags('@end-highlight@') - // ) - // .size($scope.panel.size*$scope.panel.pages) // Set the size of query result - // .sort($scope.panel.sort[0],$scope.panel.sort[1]); $scope.panel_request = request; - // if (DEBUG) { console.debug('table:\n\trequest.toString()=',request.toString()); } - var fq = '&' + filterSrv.getSolrFq(); var query_size = $scope.panel.size * $scope.panel.pages; var wt_json = '&wt=json'; @@ -265,8 +244,6 @@ function (angular, app, _, kbn, moment) { $scope.panel.queries.basic_query = querySrv.getQuery(0) + fq + sorting; $scope.panel.queries.query = $scope.panel.queries.basic_query + wt_json + rows_limit; - if (DEBUG) { console.debug('table: query=',$scope.panel.queries.query); } - // Set the additional custom query if ($scope.panel.queries.custom != null) { request = request.setQuery($scope.panel.queries.query + $scope.panel.queries.custom); @@ -289,8 +266,6 @@ function (angular, app, _, kbn, moment) { $scope.data = []; } - if (DEBUG) { console.debug('table:\n\tresults=',results,'\n\t_segment=',_segment,', $scope.hits=',$scope.hits,', $scope.data=',$scope.data,', query_id=',query_id,'\n\t$scope.panel',$scope.panel); } - // Check for error and abort if found if(!(_.isUndefined(results.error))) { $scope.panel.error = $scope.parse_error(results.error.msg); // There's also results.error.code @@ -313,8 +288,6 @@ function (angular, app, _, kbn, moment) { // from a single faceted query. $scope.hits = results.response.numFound; - if (DEBUG) { console.debug('table: $scope.hits=',$scope.hits,', $scope.data=',$scope.data); } - // Keep only what we need for the set $scope.data = $scope.data.slice(0,$scope.panel.size * $scope.panel.pages); } else { @@ -328,8 +301,6 @@ function (angular, app, _, kbn, moment) { !((_.contains(filterSrv.timeField(),$scope.panel.sort[0])) && $scope.panel.sort[1] === 'desc')) && _segment+1 < dashboard.indices.length) { $scope.get_data(_segment+1,$scope.query_id); - - if (DEBUG) { console.debug('\tnot sorting in reverse chrono order!'); } } }); @@ -347,7 +318,13 @@ function (angular, app, _, kbn, moment) { } var exportQuery = $scope.panel.queries.basic_query + '&wt=' + filetype + omitHeader + rows_limit + fl; var request = $scope.panel_request; - request = request.setQuery(exportQuery); + + if ($scope.panel.queries.custom != null) { + request = request.setQuery(exportQuery + $scope.panel.queries.custom); + } else { + request = request.setQuery(exportQuery); + } + var response = request.doSearch(); response.then(function(response) { @@ -427,7 +404,7 @@ function (angular, app, _, kbn, moment) { module.filter('tableTruncate', function() { return function(text,length,factor,field,imageFields) { // If image field, then do not truncate, otherwise we will get invalid URIs. - if (typeof field != 'undefined' && imageFields.length>0 && _.contains(imageFields, field)) { + if (typeof field !== 'undefined' && imageFields.length>0 && _.contains(imageFields, field)) { return text; } @@ -488,10 +465,10 @@ function (angular, app, _, kbn, moment) { // This filter will check the input field to see if it should be displayed as module.filter('tableDisplayImageField', function() { return function(data, field, imageFields, width, height) { - if (typeof field != 'undefined' && imageFields.length>0 && _.contains(imageFields, field)) { + if (typeof field !== 'undefined' && imageFields.length>0 && _.contains(imageFields, field)) { return ''; } return data; - } + }; }); }); diff --git a/src/app/panels/terms/module.js b/src/app/panels/terms/module.js index 8c8b0035b..9ade7a2c5 100755 --- a/src/app/panels/terms/module.js +++ b/src/app/panels/terms/module.js @@ -20,12 +20,10 @@ define([ function (angular, app, _, $, kbn) { 'use strict'; - var DEBUG = false; // DEBUG mode - var module = angular.module('kibana.panels.terms', []); app.useModule(module); - module.controller('terms', function($scope, querySrv, dashboard, filterSrv, alertSrv) { + module.controller('terms', function($scope, querySrv, dashboard, filterSrv) { $scope.panelMeta = { modals : [ { @@ -84,7 +82,6 @@ function (angular, app, _, $, kbn) { }; $scope.testMultivalued = function() { - // if($scope.panel.field && $scope.panel.field !== '' && $scope.fields.typeList[$scope.panel.field] && $scope.fields.typeList[$scope.panel.field].schema.indexOf("M") > -1) { if($scope.panel.field && $scope.fields.typeList[$scope.panel.field] && $scope.fields.typeList[$scope.panel.field].schema.indexOf("M") > -1) { $scope.panel.error = "Can't proceed with Multivalued field"; return; @@ -103,32 +100,12 @@ function (angular, app, _, $, kbn) { } $scope.panelMeta.loading = true; - var request, results, boolQuery; + var request, results; $scope.sjs.client.server(dashboard.current.solr.server + dashboard.current.solr.core_name); - if (DEBUG) { console.debug('terms:\n\tdashboard',dashboard,'\n\tquerySrv=',querySrv,'\n\tfilterSrv=',filterSrv); } - request = $scope.sjs.Request().indices(dashboard.indices); $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); - // This could probably be changed to a BoolFilter - // boolQuery = $scope.sjs.BoolQuery(); - // _.each($scope.panel.queries.ids,function(id) { - // boolQuery = boolQuery.should(querySrv.getEjsObj(id)); - // }); - - // Terms mode - // request = request - // .facet($scope.sjs.TermsFacet('terms') - // .field($scope.panel.field) - // .size($scope.panel.size) - // .order($scope.panel.order) - // .exclude($scope.panel.exclude) - // .facetFilter($scope.sjs.QueryFilter( - // $scope.sjs.FilteredQuery( - // boolQuery, - // filterSrv.getBoolFilter(filterSrv.ids) - // )))).size(0); // Populate the inspector panel $scope.inspector = angular.toJson(JSON.parse(request.toString()),true); @@ -136,15 +113,15 @@ function (angular, app, _, $, kbn) { // Build Solr query var fq = '&' + filterSrv.getSolrFq(); var wt_json = '&wt=json'; - var rows_limit = '&rows=0' // for terms, we do not need the actual response doc, so set rows=0 + var rows_limit = '&rows=0'; // for terms, we do not need the actual response doc, so set rows=0 var facet = ''; if ($scope.panel.mode === 'count') { - facet = '&facet=true&facet.field=' + $scope.panel.field + '&facet.limit=' + $scope.panel.size + '&facet.missing=true'; + facet = '&facet=true&facet.field=' + $scope.panel.field + '&facet.limit=' + $scope.panel.size; } else { // if mode != 'count' then we need to use stats query // stats does not support something like facet.limit, so we have to sort and limit the results manually. - facet = '&stats=true&stats.facet=' + $scope.panel.field + '&stats.field=' + $scope.panel.stats_field + '&facet.missing=true'; + facet = '&stats=true&stats.facet=' + $scope.panel.field + '&stats.field=' + $scope.panel.stats_field; } var exclude_length = $scope.panel.exclude.length; @@ -152,7 +129,7 @@ function (angular, app, _, $, kbn) { if(exclude_length > 0){ for (var i = 0; i < exclude_length; i++) { exclude_filter += '&fq=-' + $scope.panel.field +":"+ $scope.panel.exclude[i]; - }; + } } // Set the panel's query @@ -169,7 +146,6 @@ function (angular, app, _, $, kbn) { // Populate scope when we have results results.then(function(results) { - if (DEBUG) { console.debug('terms: results=',results); } // Check for error and abort if found if(!(_.isUndefined(results.error))) { $scope.panel.error = $scope.parse_error(results.error.msg); @@ -184,7 +160,7 @@ function (angular, app, _, $, kbn) { var valid = $('#colorTest').css('color'); $('#colorTest').css('color', color); - if (valid == $('#colorTest').css('color')) { + if (valid === $('#colorTest').css('color')) { return false; } else { return true; @@ -201,7 +177,6 @@ function (angular, app, _, $, kbn) { var sum = 0; var k = 0; - var missing =0; $scope.panelMeta.loading = false; $scope.hits = results.response.numFound; $scope.data = []; @@ -215,14 +190,12 @@ function (angular, app, _, $, kbn) { i++; var count = v[i]; sum += count; - if(term == null) - missing = count // if count = 0, do not add it to the chart, just skip it - if (count == 0) continue; + if (count === 0) { continue; } var slice = { label : term, data : [[k,count]], actions: true}; slice = addSliceColor(slice,term); $scope.data.push(slice); - }; + } }); } else { // In stats mode, set y-axis min to null so jquery.flot will set the scale automatically. @@ -234,7 +207,7 @@ function (angular, app, _, $, kbn) { } // Sort the results - if ($scope.panel.order == 'descending') { + if ($scope.panel.order === 'descending') { $scope.data = _.sortBy($scope.data, function(d) {return -d.data[0][1];}); } else { $scope.data = _.sortBy($scope.data, function(d) {return d.data[0][1];}); @@ -249,14 +222,12 @@ function (angular, app, _, $, kbn) { $scope.data.push({label:'Missing field', // data:[[k,results.facets.terms.missing]],meta:"missing",color:'#aaa',opacity:0}); // TODO: Hard coded to 0 for now. Solr faceting does not provide 'missing' value. - data:[[k,missing]],meta:"missing",color:'#aaa',opacity:0}); + data:[[k,0]],meta:"missing",color:'#aaa',opacity:0}); $scope.data.push({label:'Other values', // data:[[k+1,results.facets.terms.other]],meta:"other",color:'#444'}); // TODO: Hard coded to 0 for now. Solr faceting does not provide 'other' value. data:[[k+1,$scope.hits-sum]],meta:"other",color:'#444'}); - if (DEBUG) { console.debug('terms: $scope.data = ',$scope.data); } - $scope.$emit('render'); }); }; @@ -336,12 +307,10 @@ function (angular, app, _, $, kbn) { chartData = scope.panel.other ? chartData : _.without(chartData,_.findWhere(chartData,{meta:'other'})); - if (DEBUG) { console.debug('terms: render_panel() => chartData = ',chartData); } - if (filterSrv.idsByTypeAndField('terms',scope.panel.field).length > 0) { colors.push(scope.panel.lastColor); } else { - colors = scope.panel.chartColors + colors = scope.panel.chartColors; } require(['jquery.flot.pie'], function(){ diff --git a/src/app/panels/text/module.js b/src/app/panels/text/module.js index bd9857e72..2ee8b3c39 100755 --- a/src/app/panels/text/module.js +++ b/src/app/panels/text/module.js @@ -70,18 +70,17 @@ function (angular, app, _, require) { module.filter('newlines', function(){ return function (input) { - if(input) - return input.replace(/\n/g, '
'); + if(input) { + return input.replace(/\n/g, '
'); + } }; }); module.filter('striphtml', function () { return function(text) { - if(text) - return text - .replace(/&/g, '&') - .replace(/>/g, '>') - .replace(//g, '>').replace(/ have to be in format: 'logstash-YYYY-MM-DD' - // 'logs': { - // '_version_': { - // 'type': 'long', - // }, - // 'allText': { - // 'type': 'text_general' - // } - // } - // } - // }; - - // _.each(p.data.fields, function(v,k) { - // // Exclude fields: id and _version, from the filter - // // if (! _.contains(['id', '_version_'], v.name)) { - // // mapping[log_index][logs][v.name] = { 'type':v.type }; - // // } - // mapping[log_index][logs][v.name] = { 'type':v.type }; - // }); - if (config.USE_ADMIN_LUKE) { _.each(p.data.fields, function(v,k) { // k is the field name mapping[log_index][logs][k] = {'type':v.type, 'schema':v.schema}; }); } else { - _.each(p.data.fields, function(v,k) { - // k is the array index number + _.each(p.data.fields, function(v) { mapping[log_index][logs][v.name] = {'type':v.type, 'schema':''}; }); } diff --git a/src/app/services/filterSrv.js b/src/app/services/filterSrv.js index b50272905..e6f8f2488 100755 --- a/src/app/services/filterSrv.js +++ b/src/app/services/filterSrv.js @@ -155,7 +155,7 @@ define([ if (DEBUG) { console.debug('filterSrv: v=',v,' k=',k); } - if (v.type == 'time') { + if (v.type === 'time') { time_field = v.field; // Check for type of timestamps // In case of relative timestamps, they will be string, not Date obj. @@ -170,37 +170,37 @@ define([ } else { end_time = v.to; } - } else if (v.type == 'terms') { - if (v.mandate == 'must') { + } else if (v.type === 'terms') { + if (v.mandate === 'must') { filter_fq = filter_fq + '&fq=' + v.field + ':"' + v.value + '"'; - } else if (v.mandate == 'mustNot') { + } else if (v.mandate === 'mustNot') { filter_fq = filter_fq + '&fq=-' + v.field + ':"' + v.value + '"'; - } else if (v.mandate == 'either') { + } else if (v.mandate === 'either') { filter_either.push(v.field + ':"' + v.value + '"'); } - } else if (v.type == 'field') { + } else if (v.type === 'field') { // v.query contains double-quote around it. - if (v.mandate == 'must') { + if (v.mandate === 'must') { filter_fq = filter_fq + '&fq=' + v.field + ':' + v.query; - } else if (v.mandate == 'mustNot') { + } else if (v.mandate === 'mustNot') { filter_fq = filter_fq + '&fq=-' + v.field + ':' + v.query; - } else if (v.mandate == 'either') { + } else if (v.mandate === 'either') { filter_either.push(v.field + ':' + v.query); } - } else if (v.type == 'querystring') { - if (v.mandate == 'must') { + } else if (v.type === 'querystring') { + if (v.mandate === 'must') { filter_fq = filter_fq + '&fq=' + v.query; - } else if (v.mandate == 'mustNot') { + } else if (v.mandate === 'mustNot') { filter_fq = filter_fq + '&fq=-' + v.query; - } else if (v.mandate == 'either') { + } else if (v.mandate === 'either') { filter_either.push(v.query); } - } else if (v.type == 'range') { - if (v.mandate == 'must') { + } else if (v.type === 'range') { + if (v.mandate === 'must') { filter_fq = filter_fq + '&fq=' + v.field + ':[' + v.from +' TO '+ v.to +']'; - } else if (v.mandate == 'mustNot') { + } else if (v.mandate === 'mustNot') { filter_fq = filter_fq + '&fq=-' + v.field + ':[' + v.from +' TO '+ v.to +']'; - } else if (v.mandate == 'either') { + } else if (v.mandate === 'either') { filter_either.push(v.field + ':[' + v.from +' TO '+ v.to +']'); } } else { @@ -231,31 +231,31 @@ define([ this.getTimeField = function() { var time_field; _.each(self.list, function(v) { - if (v.type == 'time') { + if (v.type === 'time') { time_field = v.field; return; } }); return time_field; - } + }; // Get range field for Solr query this.getRangeField = function() { var range_field; _.each(self.list, function(v) { - if (v.type == 'range') { + if (v.type === 'range') { range_field = v.field; return; } }); return range_field; - } + }; // Get start time for Solr query (e.g. facet.range.start) this.getStartTime = function() { var start_time; _.each(self.list, function(v) { - if (v.type == 'time') { + if (v.type === 'time') { if (v.from instanceof Date) { start_time = new Date(v.from).toISOString(); } else { @@ -271,7 +271,7 @@ define([ this.getEndTime = function() { var end_time; _.each(self.list, function(v) { - if (v.type == 'time') { + if (v.type === 'time') { if (v.to instanceof Date) { end_time = new Date(v.to).toISOString(); } else { @@ -287,7 +287,7 @@ define([ this.getStartTimeAndEndTime = function() { var start_time, end_time; _.each(self.list, function(v) { - if (v.type == 'time') { + if (v.type === 'time') { start_time = new Date(v.from).toISOString(); end_time = new Date(v.to).toISOString(); return; @@ -304,12 +304,12 @@ define([ this.idsByTypeAndField = function(type,field,inactive){ var _require = inactive ? {type:type} : {type:type, field:field, active:true}; return _.pluck(_.where(self.list,_require),'id'); - } + }; // this method used to get the range filter with specific field this.getRangeFieldFilter = function(type, field, inactive){ return _.pick(self.list, self.idsByTypeAndField(type, field, inactive)); - } + }; this.removeByType = function(type) { var ids = self.idsByType(type); @@ -359,6 +359,7 @@ define([ to: new Date(_.min(_.pluck(_t,'to'))) }; } + break; // not neccessary, but added to pass jshint test case "max": return { from: new Date(_.min(_.pluck(_t,'from'))), @@ -379,7 +380,7 @@ define([ from: _.max(_.pluck(_t,'from')), to: _.min(_.pluck(_t,'to')) }; - } + }; this.remove = function(id) { if(!_.isUndefined(self.list[id])) { diff --git a/src/app/services/kbnIndex.js b/src/app/services/kbnIndex.js index 8b0c8d3cd..c1ce7b999 100755 --- a/src/app/services/kbnIndex.js +++ b/src/app/services/kbnIndex.js @@ -35,7 +35,7 @@ function (angular, _, config, moment) { return all_collections(solr_server).then(function (p) { return p; }); - } + }; // returns a promise containing an array of all collections in Solr // param: solr_server (e.g. http://localhost:8983/solr/) @@ -47,7 +47,7 @@ function (angular, _, config, moment) { } else { // admin API is disabled, then cannot retrieve the collection list from Solr. // return an empty list - return new Promise(function(resolve,reject) { + return new Promise(function(resolve) { var emptyList = []; resolve(emptyList); }); @@ -131,7 +131,7 @@ function (angular, _, config, moment) { // extract and convert timestamp to YYYY.MM.DD var t = timestamp_array[i].substr(0,10).replace(/-/g,'.'); indices.push('logstash-' + t); - }; + } // indices[] should be in this format // indices = ['logstash-2013.11.25']; diff --git a/src/app/services/querySrv.js b/src/app/services/querySrv.js index c97f5dca5..cc6dc91c2 100755 --- a/src/app/services/querySrv.js +++ b/src/app/services/querySrv.js @@ -6,8 +6,6 @@ define([ function (angular, _, config) { 'use strict'; - var DEBUG = false; // DEBUG mode - var module = angular.module('kibana.services'); module.service('querySrv', function(dashboard, ejsResource, sjsResource) { @@ -105,35 +103,23 @@ function (angular, _, config) { switch(q.type) { case 'lucene': - // return ejs.QueryStringQuery(q.query || '*'); return sjs.QueryStringQuery(q.query || '*:*'); - // return (q.query || '*:*'); // ERROR: CANNOT return like this default: - // return _.isUndefined(q.query) ? false : ejs.QueryStringQuery(q.query || '*'); return _.isUndefined(q.query) ? false : sjs.QueryStringQuery(q.query || '*:*'); - // return _.isUndefined(q.query) ? false : (q.query || '*:*'); // ERROR: CANNOT return like this } }; // Get query string for Solr with defType param and default fields (df). this.getQuery = function(id) { - // var solr_q = 'q=' + self.list[id].query; // Need to url encode the query var solr_q = 'q=' + encodeURIComponent(self.list[id].query); - // if (self.list[id].type) { - // solr_q += '&defType=' + self.list[id].type; - // } - // if (self.list[id].df) { - // solr_q += '&' + self.list[id].df; - // } - if (dashboard.current.solr.global_params) { solr_q += dashboard.current.solr.global_params; } return solr_q; - } + }; this.findQuery = function(queryString) { return _.findWhere(self.list,{query:queryString});