Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed warnings and errors with grunt jshint #47

Merged
merged 1 commit into from
Sep 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"sub": true,
"unused": true,

"maxlen": 140,
"maxlen": 1000,

"globals": {
"define": true,
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
9 changes: 2 additions & 7 deletions src/app/controllers/dashLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
});
};
Expand Down Expand Up @@ -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 "' +
Expand All @@ -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];
Expand All @@ -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;
Expand Down
17 changes: 10 additions & 7 deletions src/app/filters/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<br/>');
}
};
});

module.filter('striphtml', function() {
return function(text) {
if (text)
if (text) {
return text
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
}
};
});

Expand All @@ -175,7 +178,7 @@ define(['angular', 'jquery', 'underscore','showdown'], function(angular, $, _,Sh
var textConverted = text.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
return converter.makeHtml(textConverted)
return converter.makeHtml(textConverted);
}
};
});
Expand Down
70 changes: 23 additions & 47 deletions src/app/panels/facet/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ define([
'app',
'underscore',
'kbn',
'moment',
'bootstrap',
],
function(angular, app, _, kbn, moment) {
function(angular, app, _, kbn) {
'use strict';
var DEBUG = false; // DEBUG mode

var module = angular.module('kibana.panels.facet',[]);
app.useModule(module);

module.controller('facet', function($rootScope, $scope, fields, querySrv, dashboard, filterSrv) {
$scope.panelMeta = {
modals: [{
Expand Down Expand Up @@ -66,7 +66,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();
Expand All @@ -82,7 +82,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();
}
Expand Down Expand Up @@ -120,35 +120,22 @@ define([
$scope.sjs.FilteredQuery(
boolQuery,
filterSrv.getBoolFilter(filterSrv.ids) // search time range is provided here.
)).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('Facet:\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';
var facet = '&facet=true';
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 = '';
}

// Set the panel's query

//var query = $scope.panel.searchQuery == null ? querySrv.getQuery(0) : 'q=' + $scope.panel.searchQuery
$scope.panel.queries.basic_query = querySrv.getQuery(0) + fq + facet + facet_fields;
$scope.panel.queries.query = $scope.panel.queries.basic_query + wt_json;

if (DEBUG) {
console.debug('Facet: 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);
Expand All @@ -172,10 +159,6 @@ define([
$scope.data = [];
}

if (DEBUG) {
console.debug('Facet :\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
Expand All @@ -197,14 +180,15 @@ 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 = {};
Expand All @@ -214,14 +198,10 @@ 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('Facet: $scope.hits=', $scope.hits, ', $scope.data=', $scope.data);
}
} else {
return;
}
Expand All @@ -232,10 +212,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!');
}
}

});
Expand Down Expand Up @@ -270,34 +246,34 @@ 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
$('.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
});
});
});
Loading