diff --git a/.jscs.json b/.jscs.json new file mode 100644 index 00000000000..dcf694dcc63 --- /dev/null +++ b/.jscs.json @@ -0,0 +1,13 @@ +{ + "disallowImplicitTypeConversion": ["string"], + "disallowKeywords": ["with"], + "disallowMultipleLineBreaks": true, + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInsideArrayBrackets": true, + "disallowSpacesInsideParentheses": true, + "validateIndentation": 2 +} \ No newline at end of file diff --git a/package.json b/package.json index eb219ff5e99..1e2a173ba8b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "grunt-string-replace": "~0.2.4", "grunt-contrib-htmlmin": "~0.1.3", "grunt-contrib-requirejs": "~0.4.1", - "grunt-angular-templates": "~0.3.12", + "grunt-angular-templates": "^0.5.5", "grunt-contrib-compress": "~0.5.2", "grunt-contrib-uglify": "~0.2.4", "load-grunt-tasks": "~0.2.0", @@ -46,7 +46,6 @@ "grunt-cli": "~0.1.13", "jshint-stylish": "~0.1.5", "grunt-contrib-concat": "^0.4.0", - "grunt-angular-templates": "^0.5.5", "grunt-usemin": "^2.1.1", "grunt-filerev": "^0.2.1" }, @@ -59,6 +58,6 @@ }, "license": "Apache License", "dependencies": { - + "grunt-jscs-checker": "^0.4.4" } } diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 55d47488f4e..aa6a2e12d95 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -78,7 +78,7 @@ function($, _, moment) { } }; - kbn.secondsToHms = function(seconds){ + kbn.secondsToHms = function(seconds) { var numyears = Math.floor(seconds / 31536000); if(numyears){ return numyears + 'y'; @@ -191,7 +191,7 @@ function($, _, moment) { kbn.parseDateMath = function(mathString, time, roundUp) { var dateTime = moment(time); - for (var i = 0; i < mathString.length; ) { + for (var i = 0; i < mathString.length;) { var c = mathString.charAt(i++), type, num, @@ -296,10 +296,10 @@ function($, _, moment) { kbn.query_color_dot = function (color, diameter) { return '
'; + 'display:inline-block', + 'color:' + color, + 'font-size:' + diameter + 'px', + ].join(';') + '">'; }; kbn.byteFormat = function(size, decimals) { diff --git a/src/app/components/require.config.js b/src/app/components/require.config.js index d8158861946..37b91735e35 100644 --- a/src/app/components/require.config.js +++ b/src/app/components/require.config.js @@ -41,7 +41,6 @@ require.config({ 'jquery.flot.time': '../vendor/jquery/jquery.flot.time', 'jquery.flot.byte': '../vendor/jquery/jquery.flot.byte', - modernizr: '../vendor/modernizr-2.6.1', elasticjs: '../vendor/elasticjs/elastic-angular-client', diff --git a/src/app/components/underscore.extended.js b/src/app/components/underscore.extended.js index 00d80efbd89..e86afae9f5c 100644 --- a/src/app/components/underscore.extended.js +++ b/src/app/components/underscore.extended.js @@ -11,7 +11,7 @@ function () { */ _.mixin({ move: function (array, fromIndex, toIndex) { - array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] ); + array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]); return array; }, remove: function (array, index) { diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index 3bf630c6fdc..b4113a507ac 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -49,7 +49,6 @@ function (angular, $, config, _) { $scope.panelMoveOver = panelMove.onOver; $scope.panelMoveOut = panelMove.onOut; - $scope.init = function() { $scope.config = config; diff --git a/src/app/controllers/dashLoader.js b/src/app/controllers/dashLoader.js index 45e0ec0a3d4..d660e6d475a 100644 --- a/src/app/controllers/dashLoader.js +++ b/src/app/controllers/dashLoader.js @@ -105,12 +105,11 @@ function (angular, _, moment) { }; $scope.save_gist = function() { - dashboard.save_gist($scope.gist.title).then( - function(link) { - if(!_.isUndefined(link)) { + dashboard.save_gist($scope.gist.title).then(function(link) { + if (!_.isUndefined(link)) { $scope.gist.last = link; alertSrv.set('Gist saved','You will be able to access your exported dashboard file at '+ - ''+link+' in a moment','success'); + ''+link+' in a moment','success'); } else { alertSrv.set('Save failed','Gist could not be saved','error',5000); } @@ -118,9 +117,8 @@ function (angular, _, moment) { }; $scope.gist_dblist = function(id) { - dashboard.gist_list(id).then( - function(files) { - if(files && files.length > 0) { + dashboard.gist_list(id).then(function(files) { + if (files && files.length > 0) { $scope.gist.files = files; } else { alertSrv.set('Gist Failed','Could not retrieve dashboard list from gist','error',5000); diff --git a/src/app/controllers/graphiteImport.js b/src/app/controllers/graphiteImport.js index 9c63c977277..e0a0f36389c 100644 --- a/src/app/controllers/graphiteImport.js +++ b/src/app/controllers/graphiteImport.js @@ -16,7 +16,6 @@ function (angular, app, _) { $scope.setDatasource(null); }; - $scope.setDatasource = function(datasource) { $scope.datasource = datasourceSrv.get(datasource); @@ -26,7 +25,6 @@ function (angular, app, _) { } }; - $scope.listAll = function(query) { delete $scope.error; diff --git a/src/app/controllers/graphiteTarget.js b/src/app/controllers/graphiteTarget.js index c39a2198100..abb5410a66e 100644 --- a/src/app/controllers/graphiteTarget.js +++ b/src/app/controllers/graphiteTarget.js @@ -165,7 +165,7 @@ function (angular, _, config, gfunc, Parser) { segment.html = segment.val = segment.text; }); - _.each($scope.filter.templateParameters, function( templateParameter ) { + _.each($scope.filter.templateParameters, function(templateParameter) { segments.unshift({ type: 'template', html: '[[' + templateParameter.name + ']]', diff --git a/src/app/controllers/influxTargetCtrl.js b/src/app/controllers/influxTargetCtrl.js index a7dcbf85828..f94844e380e 100644 --- a/src/app/controllers/influxTargetCtrl.js +++ b/src/app/controllers/influxTargetCtrl.js @@ -16,13 +16,16 @@ function (angular) { $scope.rawQuery = false; - $scope.functions = ['count', 'mean', 'sum', 'min', - 'max', 'mode', 'distinct', 'median', - 'derivative', 'stddev', 'first', 'last', - 'difference']; + $scope.functions = [ + 'count', 'mean', 'sum', 'min', + 'max', 'mode', 'distinct', 'median', + 'derivative', 'stddev', 'first', 'last', + 'difference' + ]; + $scope.operators = ['=', '=~', '>', '<', '!~', '<>']; $scope.oldSeries = $scope.target.series; - $scope.$on('typeahead-updated', function(){ + $scope.$on('typeahead-updated', function() { $timeout($scope.get_data); }); }; diff --git a/src/app/controllers/metricKeys.js b/src/app/controllers/metricKeys.js index ae95327d80a..61ac85cfed2 100644 --- a/src/app/controllers/metricKeys.js +++ b/src/app/controllers/metricKeys.js @@ -53,7 +53,7 @@ function (angular, _, config) { $scope.infoText = "Fetching all metrics from graphite..."; getFromEachGraphite('/metrics/index.json', saveMetricsArray) - .then( function() { + .then(function() { $scope.infoText = "Indexing complete!"; }).then(null, function(err) { $scope.errorText = err; @@ -61,12 +61,12 @@ function (angular, _, config) { }; function getFromEachGraphite(request, data_callback, error_callback) { - return $q.all( _.map( config.datasources, function( datasource ) { - if ( datasource.type = 'graphite' ) { - return $http.get( datasource.url + request ) - .then( data_callback, error_callback ); + return $q.all(_.map(config.datasources, function(datasource) { + if (datasource.type = 'graphite') { + return $http.get(datasource.url + request) + .then(data_callback, error_callback); } - } ) ); + })); } function saveMetricsArray(data, currentIndex) { @@ -86,7 +86,6 @@ function (angular, _, config) { }); } - function deleteIndex() { var deferred = $q.defer(); @@ -119,7 +118,7 @@ function (angular, _, config) { type : "nGram", min_gram : "3", max_gram : "8", - token_chars: [ "letter", "digit", "punctuation", "symbol"] + token_chars: ["letter", "digit", "punctuation", "symbol"] } } } @@ -179,7 +178,7 @@ function (angular, _, config) { function loadMetricsRecursive(metricPath) { - return getFromEachGraphite( '/metrics/find/?query=' + metricPath, receiveMetric ); + return getFromEachGraphite('/metrics/find/?query=' + metricPath, receiveMetric); } }); diff --git a/src/app/controllers/pulldown.js b/src/app/controllers/pulldown.js index b29e42a59df..425f7c2813c 100644 --- a/src/app/controllers/pulldown.js +++ b/src/app/controllers/pulldown.js @@ -9,35 +9,34 @@ function (angular, app, _) { var module = angular.module('kibana.controllers'); module.controller('PulldownCtrl', function($scope, $rootScope, $timeout) { - var _d = { - collapse: false, - notice: false, - enable: true - }; + var _d = { + collapse: false, + notice: false, + enable: true + }; - _.defaults($scope.pulldown,_d); + _.defaults($scope.pulldown,_d); - $scope.init = function() { - // Provide a combined skeleton for panels that must interact with panel and row. - // This might create name spacing issues. - $scope.panel = $scope.pulldown; - $scope.row = $scope.pulldown; - }; + $scope.init = function() { + // Provide a combined skeleton for panels that must interact with panel and row. + // This might create name spacing issues. + $scope.panel = $scope.pulldown; + $scope.row = $scope.pulldown; + }; - $scope.toggle_pulldown = function(pulldown) { - pulldown.collapse = pulldown.collapse ? false : true; - if (!pulldown.collapse) { - $timeout(function() { - $scope.$broadcast('render'); - }); - } else { - $scope.row.notice = false; - } - }; + $scope.toggle_pulldown = function(pulldown) { + pulldown.collapse = pulldown.collapse ? false : true; + if (!pulldown.collapse) { + $timeout(function() { + $scope.$broadcast('render'); + }); + } else { + $scope.row.notice = false; + } + }; - $scope.init(); + $scope.init(); - } - ); + }); }); \ No newline at end of file diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index ace80b3b755..736c500a1e0 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -41,7 +41,7 @@ function (angular, _, config, $) { var selectedDash = $scope.results.dashboards[$scope.selectedIndex]; if (selectedDash) { $location.path("/dashboard/elasticsearch/" + encodeURIComponent(selectedDash._id)); - setTimeout(function(){ + setTimeout(function() { $('body').click(); // hack to force dropdown to close; }); } @@ -162,7 +162,7 @@ function (angular, _, config, $) { type: 'graphite', title: 'test', span: 12, - targets: [ { target: metricId } ] + targets: [{ target: metricId }] } ] }); diff --git a/src/app/controllers/submenuCtrl.js b/src/app/controllers/submenuCtrl.js index 4ecddc869f0..6781ef63da7 100644 --- a/src/app/controllers/submenuCtrl.js +++ b/src/app/controllers/submenuCtrl.js @@ -9,20 +9,19 @@ function (angular, app, _) { var module = angular.module('kibana.controllers'); module.controller('SubmenuCtrl', function($scope) { - var _d = { - enable: true - }; + var _d = { + enable: true + }; - _.defaults($scope.pulldown,_d); + _.defaults($scope.pulldown,_d); - $scope.init = function() { - $scope.panel = $scope.pulldown; - $scope.row = $scope.pulldown; - }; + $scope.init = function() { + $scope.panel = $scope.pulldown; + $scope.row = $scope.pulldown; + }; - $scope.init(); + $scope.init(); - } - ); + }); }); \ No newline at end of file diff --git a/src/app/directives/addGraphiteFunc.js b/src/app/directives/addGraphiteFunc.js index f5801bb3106..e137a770b03 100644 --- a/src/app/directives/addGraphiteFunc.js +++ b/src/app/directives/addGraphiteFunc.js @@ -8,7 +8,6 @@ define([ function (angular, app, _, $, gfunc) { 'use strict'; - angular .module('kibana.directives') .directive('graphiteAddFunc', function($compile) { diff --git a/src/app/directives/dashUpload.js b/src/app/directives/dashUpload.js index c5914e070ab..c6b4239c0f6 100644 --- a/src/app/directives/dashUpload.js +++ b/src/app/directives/dashUpload.js @@ -6,7 +6,7 @@ function (angular) { var module = angular.module('kibana.directives'); - module.directive('dashUpload', function(timer, dashboard, alertSrv){ + module.directive('dashUpload', function(timer, dashboard, alertSrv) { return { restrict: 'A', link: function(scope) { diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index b27ed32d352..95e2848a8b1 100755 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -388,11 +388,11 @@ function (angular, $, kbn, moment, _) { } elem.bind("plotselected", function (event, ranges) { - scope.$apply( function() { - scope.filter.setTime({ - from : moment.utc(ranges.xaxis.from).toDate(), - to : moment.utc(ranges.xaxis.to).toDate(), - }); + scope.$apply(function() { + scope.filter.setTime({ + from : moment.utc(ranges.xaxis.from).toDate(), + to : moment.utc(ranges.xaxis.to).toDate(), + }); }); }); } diff --git a/src/app/directives/graphiteFuncEditor.js b/src/app/directives/graphiteFuncEditor.js index 7767d097c04..b2a3f4523b1 100644 --- a/src/app/directives/graphiteFuncEditor.js +++ b/src/app/directives/graphiteFuncEditor.js @@ -75,11 +75,11 @@ function (angular, _, $) { if ($input.val() !== '' || func.def.params[paramIndex].optional) { $link.text($input.val()); - + func.updateParam($input.val(), paramIndex); scheduledRelinkIfNeeded(); - - $scope.$apply($scope.targetChanged); + + $scope.$apply($scope.targetChanged); } $input.hide(); @@ -104,7 +104,7 @@ function (angular, _, $) { var options = funcDef.params[paramIndex].options; if (funcDef.params[paramIndex].type === 'int') { - options = _.map(options, function(val) { return val.toString(); } ); + options = _.map(options, function(val) { return val.toString(); }); } $input.typeahead({ @@ -230,7 +230,7 @@ function (angular, _, $) { addElementsAndCompile(); ifJustAddedFocusFistParam(); registerFuncControlsToggle(); - registerFuncControlsActions(); + registerFuncControlsActions(); } relink(); @@ -239,5 +239,4 @@ function (angular, _, $) { }); - }); \ No newline at end of file diff --git a/src/app/directives/influxdbFuncEditor.js b/src/app/directives/influxdbFuncEditor.js index e10dad85127..33015a791a1 100644 --- a/src/app/directives/influxdbFuncEditor.js +++ b/src/app/directives/influxdbFuncEditor.js @@ -133,5 +133,4 @@ function (angular, _, $) { }); - }); \ No newline at end of file diff --git a/src/app/directives/kibanaPanel.js b/src/app/directives/kibanaPanel.js index 87cfee0419b..a58b76d93e7 100644 --- a/src/app/directives/kibanaPanel.js +++ b/src/app/directives/kibanaPanel.js @@ -111,7 +111,6 @@ function (angular, $, _, PanelBaseCtrl) { }); }); - } }; }); diff --git a/src/app/panels/annotations/module.js b/src/app/panels/annotations/module.js index 747fb63b8d9..389a9b05d0c 100644 --- a/src/app/panels/annotations/module.js +++ b/src/app/panels/annotations/module.js @@ -63,6 +63,5 @@ function (angular, app, _) { $rootScope.$broadcast('refresh'); }; - }); }); \ No newline at end of file diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index dd13ad68c5c..0533c97b98d 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -414,6 +414,4 @@ function (angular, app, $, _, kbn, moment, timeSeries) { }); - }); - diff --git a/src/app/panels/graph/timeSeries.js b/src/app/panels/graph/timeSeries.js index 1eec0f72e7e..7bf692c789d 100644 --- a/src/app/panels/graph/timeSeries.js +++ b/src/app/panels/graph/timeSeries.js @@ -70,6 +70,5 @@ function (_, kbn) { return result; }; - return ts; }); \ No newline at end of file diff --git a/src/app/panels/text/module.js b/src/app/panels/text/module.js index 70d0118d167..37735d3b376 100644 --- a/src/app/panels/text/module.js +++ b/src/app/panels/text/module.js @@ -84,7 +84,7 @@ function (angular, app, _, require) { }; }); - module.filter('newlines', function(){ + module.filter('newlines', function() { return function (input) { return input.replace(/\n/g, '
'); }; diff --git a/src/app/panels/timepicker/module.js b/src/app/panels/timepicker/module.js index e3c0692c03b..da310b663e5 100644 --- a/src/app/panels/timepicker/module.js +++ b/src/app/panels/timepicker/module.js @@ -32,7 +32,6 @@ function (angular, app, _, moment, kbn) { " or if you're using time stamped indices, you need one of these" }; - // Set and populate defaults var _d = { status : "Stable", @@ -156,7 +155,7 @@ function (angular, app, _, moment, kbn) { var pad = function(n, width, z) { z = z || '0'; - n = n + ''; + n = n.toString(); return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; }; @@ -194,6 +193,5 @@ function (angular, app, _, moment, kbn) { return moment(new Date(date.getTime() + date.getTimezoneOffset() * 60000)).toDate(); }; - }); }); diff --git a/src/app/services/alertSrv.js b/src/app/services/alertSrv.js index ad441fb255a..35395bbd536 100644 --- a/src/app/services/alertSrv.js +++ b/src/app/services/alertSrv.js @@ -21,7 +21,7 @@ function (angular, _) { severity: severity || 'info', }, _ca = angular.toJson(_a), - _clist = _.map(self.list,function(alert){return angular.toJson(alert);}); + _clist = _.map(self.list,function(alert) {return angular.toJson(alert);}); // If we already have this alert, remove it and add a new one // Why do this instead of skipping the add because it resets the timer diff --git a/src/app/services/dashboard.js b/src/app/services/dashboard.js index 9f2ba8db9bf..a6faac89906 100644 --- a/src/app/services/dashboard.js +++ b/src/app/services/dashboard.js @@ -28,8 +28,8 @@ function (angular, $, kbn, _, config, moment, Modernizr) { failover: false, panel_hints: true, rows: [], - pulldowns: [ { type: 'templating' }, { type: 'annotations' } ], - nav: [ { type: 'timepicker' } ], + pulldowns: [{ type: 'templating' }, { type: 'annotations' }], + nav: [{ type: 'timepicker' }], services: {}, loader: { save_gist: false, @@ -59,7 +59,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) { this.last = {}; this.availablePanels = []; - $rootScope.$on('$routeChangeSuccess',function(){ + $rootScope.$on('$routeChangeSuccess',function() { // Clear the current dashboard to prevent reloading self.current = {}; self.indices = []; diff --git a/src/app/services/dashboard/dashboardKeyBindings.js b/src/app/services/dashboard/dashboardKeyBindings.js index eb40a225794..c05bff75504 100644 --- a/src/app/services/dashboard/dashboardKeyBindings.js +++ b/src/app/services/dashboard/dashboardKeyBindings.js @@ -10,49 +10,49 @@ function(angular, $) { module.service('dashboardKeybindings', function($rootScope, keyboardManager, dashboard) { this.shortcuts = function() { - $rootScope.$on('panel-fullscreen-enter', function() { - $rootScope.fullscreen = true; - }); + $rootScope.$on('panel-fullscreen-enter', function() { + $rootScope.fullscreen = true; + }); - $rootScope.$on('panel-fullscreen-exit', function() { - $rootScope.fullscreen = false; - }); + $rootScope.$on('panel-fullscreen-exit', function() { + $rootScope.fullscreen = false; + }); - $rootScope.$on('dashboard-saved', function() { - if ($rootScope.fullscreen) { - $rootScope.$emit('panel-fullscreen-exit'); - } - }); + $rootScope.$on('dashboard-saved', function() { + if ($rootScope.fullscreen) { + $rootScope.$emit('panel-fullscreen-exit'); + } + }); - keyboardManager.bind('ctrl+f', function(evt) { - $rootScope.$emit('open-search', evt); - }, { inputDisabled: true }); + keyboardManager.bind('ctrl+f', function(evt) { + $rootScope.$emit('open-search', evt); + }, { inputDisabled: true }); - keyboardManager.bind('ctrl+h', function() { - var current = dashboard.current.hideControls; - dashboard.current.hideControls = !current; - dashboard.current.panel_hints = current; - }, { inputDisabled: true }); + keyboardManager.bind('ctrl+h', function() { + var current = dashboard.current.hideControls; + dashboard.current.hideControls = !current; + dashboard.current.panel_hints = current; + }, { inputDisabled: true }); - keyboardManager.bind('ctrl+s', function(evt) { - $rootScope.$emit('save-dashboard', evt); - }, { inputDisabled: true }); + keyboardManager.bind('ctrl+s', function(evt) { + $rootScope.$emit('save-dashboard', evt); + }, { inputDisabled: true }); - keyboardManager.bind('ctrl+r', function() { - dashboard.refresh(); - }, { inputDisabled: true }); + keyboardManager.bind('ctrl+r', function() { + dashboard.refresh(); + }, { inputDisabled: true }); - keyboardManager.bind('ctrl+z', function(evt) { - $rootScope.$emit('zoom-out', evt); - }, { inputDisabled: true }); + keyboardManager.bind('ctrl+z', function(evt) { + $rootScope.$emit('zoom-out', evt); + }, { inputDisabled: true }); - keyboardManager.bind('esc', function() { - var popups = $('.popover.in'); - if (popups.length > 0) { - return; - } - $rootScope.$emit('panel-fullscreen-exit'); - }, { inputDisabled: true }); + keyboardManager.bind('esc', function() { + var popups = $('.popover.in'); + if (popups.length > 0) { + return; + } + $rootScope.$emit('panel-fullscreen-exit'); + }, { inputDisabled: true }); }; }); }); diff --git a/src/app/services/datasourceSrv.js b/src/app/services/datasourceSrv.js index 1f6f882ff5a..1c5dbc63fc5 100644 --- a/src/app/services/datasourceSrv.js +++ b/src/app/services/datasourceSrv.js @@ -13,7 +13,7 @@ function (angular, _, config) { module.service('datasourceSrv', function($q, $http, GraphiteDatasource, InfluxDatasource) { this.init = function() { - var defaultDatasource = _.findWhere(_.values(config.datasources), { default: true } ); + var defaultDatasource = _.findWhere(_.values(config.datasources), { default: true }); this.default = this.datasourceFactory(defaultDatasource); }; diff --git a/src/app/services/filterSrv.js b/src/app/services/filterSrv.js index c098a8e7ff7..bc17c945110 100644 --- a/src/app/services/filterSrv.js +++ b/src/app/services/filterSrv.js @@ -9,102 +9,102 @@ define([ var module = angular.module('kibana.services'); module.factory('filterSrv', function(dashboard, $rootScope, $timeout, $routeParams) { - // defaults - var _d = { - templateParameters: [], - time: {} - }; + // defaults + var _d = { + templateParameters: [], + time: {} + }; - var result = { + var result = { - updateTemplateData: function(initial) { - var _templateData = {}; - _.each(this.templateParameters, function(templateParameter) { - if (initial) { - var urlValue = $routeParams[ templateParameter.name ]; - if (urlValue) { - templateParameter.current = { text: urlValue, value: urlValue }; + updateTemplateData: function(initial) { + var _templateData = {}; + _.each(this.templateParameters, function(templateParameter) { + if (initial) { + var urlValue = $routeParams[ templateParameter.name ]; + if (urlValue) { + templateParameter.current = { text: urlValue, value: urlValue }; + } } + if (!templateParameter.current || !templateParameter.current.value) { + return; + } + _templateData[templateParameter.name] = templateParameter.current.value; + }); + this._templateData = _templateData; + }, + + addTemplateParameter: function(templateParameter) { + this.templateParameters.push(templateParameter); + this.updateTemplateData(); + }, + + applyTemplateToTarget: function(target) { + if (target.indexOf('[[') === -1) { + return target; } - if (!templateParameter.current || !templateParameter.current.value) { - return; + + return _.template(target, this._templateData, this.templateSettings); + }, + + setTime: function(time) { + _.extend(this.time, time); + + // disable refresh if we have an absolute time + if (time.to !== 'now') { + this.old_refresh = this.dashboard.refresh; + dashboard.set_interval(false); + } + else if (this.old_refresh && this.old_refresh !== this.dashboard.refresh) { + dashboard.set_interval(this.old_refresh); + this.old_refresh = null; } - _templateData[templateParameter.name] = templateParameter.current.value; - }); - this._templateData = _templateData; - }, - addTemplateParameter: function(templateParameter) { - this.templateParameters.push(templateParameter); - this.updateTemplateData(); - }, + $timeout(function() { + dashboard.refresh(); + },0); + }, + + timeRange: function(parse) { + var _t = this.time; + if(_.isUndefined(_t) || _.isUndefined(_t.from)) { + return false; + } + if(parse === false) { + return { + from: _t.from, + to: _t.to + }; + } else { + var _from = _t.from; + var _to = _t.to || new Date(); + + return { + from : kbn.parseDate(_from), + to : kbn.parseDate(_to) + }; + } + }, + + removeTemplateParameter: function(templateParameter) { + this.templateParameters = _.without(this.templateParameters, templateParameter); + this.dashboard.services.filter.list = this.templateParameters; + }, + + init: function(dashboard) { + _.defaults(this, _d); + this.dashboard = dashboard; + this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g }; + + if(dashboard.services && dashboard.services.filter) { + this.time = dashboard.services.filter.time; + this.templateParameters = dashboard.services.filter.list || []; + this.updateTemplateData(true); + } - applyTemplateToTarget: function(target) { - if (target.indexOf('[[') === -1) { - return target; } - - return _.template(target, this._templateData, this.templateSettings); - }, - - setTime: function(time) { - _.extend(this.time, time); - - // disable refresh if we have an absolute time - if (time.to !== 'now') { - this.old_refresh = this.dashboard.refresh; - dashboard.set_interval(false); - } - else if (this.old_refresh && this.old_refresh !== this.dashboard.refresh) { - dashboard.set_interval(this.old_refresh); - this.old_refresh = null; - } - - $timeout(function(){ - dashboard.refresh(); - },0); - }, - - timeRange: function(parse) { - var _t = this.time; - if(_.isUndefined(_t) || _.isUndefined(_t.from)) { - return false; - } - if(parse === false) { - return { - from: _t.from, - to: _t.to - }; - } else { - var _from = _t.from; - var _to = _t.to || new Date(); - - return { - from : kbn.parseDate(_from), - to : kbn.parseDate(_to) - }; - } - }, - - removeTemplateParameter: function(templateParameter) { - this.templateParameters = _.without(this.templateParameters, templateParameter); - this.dashboard.services.filter.list = this.templateParameters; - }, - - init: function(dashboard) { - _.defaults(this, _d); - this.dashboard = dashboard; - this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g }; - - if(dashboard.services && dashboard.services.filter) { - this.time = dashboard.services.filter.time; - this.templateParameters = dashboard.services.filter.list || []; - this.updateTemplateData(true); - } - - } - }; - return result; + }; + return result; }); }); diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index 748f6085a7b..d0821df6d6e 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -27,7 +27,7 @@ function (_) { addFuncDef({ name: 'scaleToSeconds', category: categories.Transform, - params: [ { name: 'seconds', type: 'int' } ], + params: [{ name: 'seconds', type: 'int' }], defaultParams: [1], }); @@ -39,21 +39,21 @@ function (_) { addFuncDef({ name: "holtWintersConfidenceBands", category: categories.Calculate, - params: [ { name: "delta", type: 'int' } ], + params: [{ name: "delta", type: 'int' }], defaultParams: [3] }); addFuncDef({ name: "holtWintersAberration", category: categories.Calculate, - params: [ { name: "delta", type: 'int' } ], + params: [{ name: "delta", type: 'int' }], defaultParams: [3] }); addFuncDef({ name: "nPercentile", category: categories.Calculate, - params: [ { name: "Nth percentile", type: 'int' } ], + params: [{ name: "Nth percentile", type: 'int' }], defaultParams: [95] }); @@ -82,14 +82,14 @@ function (_) { addFuncDef({ name: 'percentileOfSeries', category: categories.Combine, - params: [ { name: "n", type: "int" }, { name: "interpolate", type: "select", options: ["true", "false"] } ], + params: [{ name: "n", type: "int" }, { name: "interpolate", type: "select", options: ["true", "false"] }], defaultParams: [95, "false"] }); addFuncDef({ name: 'sumSeriesWithWildcards', category: categories.Combine, - params: [ { name: "node", type: "int" } ], + params: [{ name: "node", type: "int" }], defaultParams: [3] }); @@ -108,28 +108,28 @@ function (_) { addFuncDef({ name: 'averageSeriesWithWildcards', category: categories.Combine, - params: [ { name: "node", type: "int" } ], + params: [{ name: "node", type: "int" }], defaultParams: [3] }); addFuncDef({ name: "alias", category: categories.Special, - params: [ { name: "alias", type: 'string' } ], + params: [{ name: "alias", type: 'string' }], defaultParams: ['alias'] }); addFuncDef({ name: "aliasSub", category: categories.Special, - params: [ { name: "search", type: 'string' }, { name: "replace", type: 'string' } ], + params: [{ name: "search", type: 'string' }, { name: "replace", type: 'string' }], defaultParams: ['', ''] }); addFuncDef({ name: "stacked", category: categories.Special, - params: [ { name: "stack", type: 'string' } ], + params: [{ name: "stack", type: 'string' }], defaultParams: ['stacked'] }); @@ -212,7 +212,7 @@ function (_) { addFuncDef({ name: 'randomWalk', category: categories.Special, - params: [ { name: "name", type: "string", } ], + params: [{ name: "name", type: "string", }], defaultParams: ['randomWalk'] }); @@ -224,7 +224,7 @@ function (_) { addFuncDef({ name: 'constantLine', category: categories.Special, - params: [ { name: "value", type: "int", } ], + params: [{ name: "value", type: "int", }], defaultParams: [10] }); @@ -236,28 +236,28 @@ function (_) { addFuncDef({ name: 'keepLastValue', category: categories.Special, - params: [ { name: "n", type: "int", } ], + params: [{ name: "n", type: "int", }], defaultParams: [100] }); addFuncDef({ name: 'scale', category: categories.Transform, - params: [ { name: "factor", type: "int", } ], + params: [{ name: "factor", type: "int", }], defaultParams: [1] }); addFuncDef({ name: 'offset', category: categories.Transform, - params: [ { name: "amount", type: "int", } ], + params: [{ name: "amount", type: "int", }], defaultParams: [10] }); addFuncDef({ name: 'transformNull', category: categories.Transform, - params: [ { name: "amount", type: "int", } ], + params: [{ name: "amount", type: "int", }], defaultParams: [0] }); @@ -274,28 +274,28 @@ function (_) { addFuncDef({ name: 'nonNegativeDerivative', category: categories.Transform, - params: [ { name: "max value or 0", type: "int", } ], + params: [{ name: "max value or 0", type: "int", }], defaultParams: [0] }); addFuncDef({ name: 'timeShift', category: categories.Transform, - params: [ { name: "amount", type: "select", options: ['1h', '6h', '12h', '1d', '2d', '7d', '14d', '30d'] }], + params: [{ name: "amount", type: "select", options: ['1h', '6h', '12h', '1d', '2d', '7d', '14d', '30d'] }], defaultParams: ['1d'] }); addFuncDef({ name: 'summarize', category: categories.Transform, - params: [ { name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }], + params: [{ name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }], defaultParams: ['1h', 'sum'] }); addFuncDef({ name: 'smartSummarize', category: categories.Transform, - params: [ { name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }], + params: [{ name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }], defaultParams: ['1h', 'sum'] }); @@ -307,169 +307,168 @@ function (_) { addFuncDef({ name: 'hitcount', category: categories.Transform, - params: [ { name: "interval", type: "string" }], + params: [{ name: "interval", type: "string" }], defaultParams: ['10s'] }); addFuncDef({ name: 'log', category: categories.Transform, - params: [ { name: "base", type: "int" }], + params: [{ name: "base", type: "int" }], defaultParams: ['10'] }); - addFuncDef({ name: 'averageAbove', category: categories.Filter, - params: [ { name: "n", type: "int", } ], + params: [{ name: "n", type: "int", }], defaultParams: [25] }); addFuncDef({ name: 'averageBelow', category: categories.Filter, - params: [ { name: "n", type: "int", } ], + params: [{ name: "n", type: "int", }], defaultParams: [25] }); addFuncDef({ name: 'currentAbove', category: categories.Filter, - params: [ { name: "n", type: "int", } ], + params: [{ name: "n", type: "int", }], defaultParams: [25] }); addFuncDef({ name: 'currentBelow', category: categories.Filter, - params: [ { name: "n", type: "int", } ], + params: [{ name: "n", type: "int", }], defaultParams: [25] }); addFuncDef({ name: 'maximumAbove', category: categories.Filter, - params: [ { name: "value", type: "int" } ], + params: [{ name: "value", type: "int" }], defaultParams: [0] }); addFuncDef({ name: 'maximumBelow', category: categories.Filter, - params: [ { name: "value", type: "int" } ], + params: [{ name: "value", type: "int" }], defaultParams: [0] }); addFuncDef({ name: 'minimumAbove', category: categories.Filter, - params: [ { name: "value", type: "int" } ], + params: [{ name: "value", type: "int" }], defaultParams: [0] }); addFuncDef({ name: 'limit', category: categories.Filter, - params: [ { name: "n", type: "int" } ], + params: [{ name: "n", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'mostDeviant', category: categories.Filter, - params: [ { name: "n", type: "int" } ], + params: [{ name: "n", type: "int" }], defaultParams: [10] }); addFuncDef({ name: "exclude", category: categories.Filter, - params: [ { name: "exclude", type: 'string' } ], + params: [{ name: "exclude", type: 'string' }], defaultParams: ['exclude'] }); addFuncDef({ name: 'highestCurrent', category: categories.Filter, - params: [ { name: "count", type: "int" } ], + params: [{ name: "count", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'highestMax', category: categories.Filter, - params: [ { name: "count", type: "int" } ], + params: [{ name: "count", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'lowestCurrent', category: categories.Filter, - params: [ { name: "count", type: "int" } ], + params: [{ name: "count", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'movingAverage', category: categories.Filter, - params: [ { name: "window size", type: "int" } ], + params: [{ name: "window size", type: "int" }], defaultParams: [10] }); addFuncDef({ name: 'movingMedian', category: categories.Filter, - params: [ { name: "windowSize", type: "select", options: ['1min', '5min', '15min', '30min', '1hour'] } ], + params: [{ name: "windowSize", type: "select", options: ['1min', '5min', '15min', '30min', '1hour'] }], defaultParams: ['1min'] }); addFuncDef({ name: 'stdev', category: categories.Filter, - params: [ { name: "n", type: "int" }, { name: "tolerance", type: "int" } ], + params: [{ name: "n", type: "int" }, { name: "tolerance", type: "int" }], defaultParams: [5,0.1] }); addFuncDef({ name: 'highestAverage', category: categories.Filter, - params: [ { name: "count", type: "int" } ], + params: [{ name: "count", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'lowestAverage', category: categories.Filter, - params: [ { name: "count", type: "int" } ], + params: [{ name: "count", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'removeAbovePercentile', category: categories.Filter, - params: [ { name: "n", type: "int" } ], + params: [{ name: "n", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'removeAboveValue', category: categories.Filter, - params: [ { name: "n", type: "int" } ], + params: [{ name: "n", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'removeBelowPercentile', category: categories.Filter, - params: [ { name: "n", type: "int" } ], + params: [{ name: "n", type: "int" }], defaultParams: [5] }); addFuncDef({ name: 'removeBelowValue', category: categories.Filter, - params: [ { name: "n", type: "int" } ], + params: [{ name: "n", type: "int" }], defaultParams: [5] }); diff --git a/src/app/services/graphite/graphiteDatasource.js b/src/app/services/graphite/graphiteDatasource.js index b53ac014e88..33f809cf411 100644 --- a/src/app/services/graphite/graphiteDatasource.js +++ b/src/app/services/graphite/graphiteDatasource.js @@ -186,7 +186,6 @@ function (angular, _, $, config, kbn, moment) { return clean_options; }; - return GraphiteDatasource; }); diff --git a/src/app/services/graphite/lexer.js b/src/app/services/graphite/lexer.js index 3cc3a1a2774..c9b77103ad0 100644 --- a/src/app/services/graphite/lexer.js +++ b/src/app/services/graphite/lexer.js @@ -157,7 +157,7 @@ define([ tokenize: function() { var list = []; var token; - while(token = this.next()) { + while (token = this.next()) { list.push(token); } return list; @@ -721,5 +721,3 @@ define([ return Lexer; }); - - diff --git a/src/app/services/graphite/parser.js b/src/app/services/graphite/parser.js index 1733df20bdf..c3e2598a816 100644 --- a/src/app/services/graphite/parser.js +++ b/src/app/services/graphite/parser.js @@ -20,7 +20,7 @@ define([ try { return this.functionCall() || this.metricExpression(); } - catch(e) { + catch (e) { return { type: 'error', message: e.message, @@ -34,7 +34,7 @@ define([ var curlySegment = ""; - while(!this.match('') && !this.match('}')) { + while (!this.match('') && !this.match('}')) { curlySegment += this.consumeToken().value; } @@ -108,7 +108,7 @@ define([ node.segments.push(this.metricSegment()); - while(this.match('.')) { + while (this.match('.')) { this.consumeToken(); var segment = this.metricSegment(); @@ -204,7 +204,7 @@ define([ // returns token value and incre consumeToken: function() { this.index++; - return this.tokens[this.index-1]; + return this.tokens[this.index - 1]; }, matchToken: function(type, index) { diff --git a/src/app/services/influxdb/influxdbDatasource.js b/src/app/services/influxdb/influxdbDatasource.js index 01ef1ae9d44..0151a92502b 100644 --- a/src/app/services/influxdb/influxdbDatasource.js +++ b/src/app/services/influxdb/influxdbDatasource.js @@ -44,7 +44,7 @@ function (angular, _, kbn) { var orderIndex = lowerCaseQueryElements.indexOf("order"); if (whereIndex !== -1) { - queryElements.splice(whereIndex+1, 0, timeFilter, "and"); + queryElements.splice(whereIndex + 1, 0, timeFilter, "and"); } else { if (groupByIndex !== -1) { @@ -122,7 +122,7 @@ function (angular, _, kbn) { try { interpolated = filterSrv.applyTemplateToTarget(query); } - catch(err) { + catch (err) { return $q.reject(err); } @@ -193,12 +193,12 @@ function (angular, _, kbn) { var datapoints = []; var value; - for(var i = 0; i < series.points.length; i++) { + for (var i = 0; i < series.points.length; i++) { value = isNaN(series.points[i][index]) ? null : series.points[i][index]; datapoints[i] = [value, series.points[i][timeCol]]; } - output.push({ target:target, datapoints:datapoints }); + output.push({ target: target, datapoints: datapoints }); }); }); @@ -235,7 +235,6 @@ function (angular, _, kbn) { return (date.getTime() / 1000).toFixed(0) + 's'; } - return InfluxDatasource; }); diff --git a/src/app/services/keyboardManager.js b/src/app/services/keyboardManager.js index d6543e7aa9d..be9314b38f3 100644 --- a/src/app/services/keyboardManager.js +++ b/src/app/services/keyboardManager.js @@ -28,7 +28,7 @@ function (angular) { label = label.toLowerCase(); elt = opt.target; - if(typeof opt.target === 'string') { + if (typeof opt.target === 'string') { elt = document.getElementById(opt.target); } @@ -75,79 +75,79 @@ function (angular) { var kp = 0; // Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken var shift_nums = { - "`":"~", - "1":"!", - "2":"@", - "3":"#", - "4":"$", - "5":"%", - "6":"^", - "7":"&", - "8":"*", - "9":"(", - "0":")", - "-":"_", - "=":"+", - ";":":", - "'":"\"", - ",":"<", - ".":">", - "/":"?", - "\\":"|" + "`": "~", + "1": "!", + "2": "@", + "3": "#", + "4": "$", + "5": "%", + "6": "^", + "7": "&", + "8": "*", + "9": "(", + "0": ")", + "-": "_", + "=": "+", + ";": ":", + "'": "\"", + ",": "<", + ".": ">", + "/": "?", + "\\": "|" }; // Special Keys - and their codes var special_keys = { - 'esc':27, - 'escape':27, - 'tab':9, - 'space':32, - 'return':13, - 'enter':13, - 'backspace':8, + 'esc': 27, + 'escape': 27, + 'tab': 9, + 'space': 32, + 'return': 13, + 'enter': 13, + 'backspace': 8, - 'scrolllock':145, - 'scroll_lock':145, - 'scroll':145, - 'capslock':20, - 'caps_lock':20, - 'caps':20, - 'numlock':144, - 'num_lock':144, - 'num':144, + 'scrolllock': 145, + 'scroll_lock': 145, + 'scroll': 145, + 'capslock': 20, + 'caps_lock': 20, + 'caps': 20, + 'numlock': 144, + 'num_lock': 144, + 'num': 144, - 'pause':19, - 'break':19, + 'pause': 19, + 'break': 19, - 'insert':45, - 'home':36, - 'delete':46, - 'end':35, + 'insert': 45, + 'home': 36, + 'delete': 46, + 'end': 35, - 'pageup':33, - 'page_up':33, - 'pu':33, + 'pageup': 33, + 'page_up': 33, + 'pu': 33, - 'pagedown':34, - 'page_down':34, - 'pd':34, + 'pagedown': 34, + 'page_down': 34, + 'pd': 34, - 'left':37, - 'up':38, - 'right':39, - 'down':40, + 'left': 37, + 'up': 38, + 'right': 39, + 'down': 40, - 'f1':112, - 'f2':113, - 'f3':114, - 'f4':115, - 'f5':116, - 'f6':117, - 'f7':118, - 'f8':119, - 'f9':120, - 'f10':121, - 'f11':122, - 'f12':123 + 'f1': 112, + 'f2': 113, + 'f3': 114, + 'f4': 115, + 'f5': 116, + 'f6': 117, + 'f7': 118, + 'f8': 119, + 'f9': 120, + 'f10': 121, + 'f11': 122, + 'f12': 123 }; // Some modifiers key var modifiers = { @@ -169,7 +169,7 @@ function (angular) { } }; // Foreach keys in label (split on +) - for(var i=0, l=keys.length; k=keys[i],i 1) { // If it is a special key - if(special_keys[k] === code) { + if (special_keys[k] === code) { kp++; } } else if (opt['keyCode']) { // If a specific key is set into the config @@ -193,13 +193,13 @@ function (angular) { kp++; } } else { // The special keys did not match - if(character === k) { + if (character === k) { kp++; } else { - if(shift_nums[character] && e.shiftKey) { // Stupid Shift key bug created by using lowercase + if (shift_nums[character] && e.shiftKey) { // Stupid Shift key bug created by using lowercase character = shift_nums[character]; - if(character === k) { + if (character === k) { kp++; } } @@ -207,7 +207,7 @@ function (angular) { } } - if(kp === keys.length && + if (kp === keys.length && modifiers.ctrl.pressed === modifiers.ctrl.wanted && modifiers.shift.pressed === modifiers.shift.wanted && modifiers.alt.pressed === modifiers.alt.wanted && @@ -216,7 +216,7 @@ function (angular) { callback(e); }, 1); - if(!opt['propagate']) { // Stop the event + if (!opt['propagate']) { // Stop the event // e.cancelBubble is supported by IE - this will kill the bubbling process. e.cancelBubble = true; e.returnValue = false; @@ -238,10 +238,10 @@ function (angular) { 'event': opt['type'] }; //Attach the function with the event - if(elt.addEventListener) { + if (elt.addEventListener) { elt.addEventListener(opt['type'], fct, false); } - else if(elt.attachEvent) { + else if (elt.attachEvent) { elt.attachEvent('on' + opt['type'], fct); } else { @@ -255,7 +255,7 @@ function (angular) { var binding = keyboardManagerService.keyboardEvent[label]; delete(keyboardManagerService.keyboardEvent[label]); - if(!binding) { + if (!binding) { return; } @@ -263,14 +263,14 @@ function (angular) { elt = binding['target'], callback = binding['callback']; - if(elt.detachEvent) { + if (elt.detachEvent) { elt.detachEvent('on' + type, callback); } - else if(elt.removeEventListener) { + else if (elt.removeEventListener) { elt.removeEventListener(type, callback, false); } else { - elt['on'+type] = false; + elt['on' + type] = false; } }; // diff --git a/src/app/services/panelMove.js b/src/app/services/panelMove.js index 715c3cd4382..00e68ccd154 100644 --- a/src/app/services/panelMove.js +++ b/src/app/services/panelMove.js @@ -34,12 +34,11 @@ function (angular, _) { dragIndex = data.dragSettings.index, dropIndex = data.dropSettings.index; - // Remove panel from source row dragRow.splice(dragIndex,1); // Add to destination row - if(!_.isUndefined(dropRow)) { + if (!_.isUndefined(dropRow)) { dropRow.splice(dropIndex,0,data.dragItem); } diff --git a/src/app/services/timer.js b/src/app/services/timer.js index b713004fb80..15651538bb1 100644 --- a/src/app/services/timer.js +++ b/src/app/services/timer.js @@ -24,7 +24,7 @@ function (angular, _) { }; this.cancel_all = function() { - _.each(timers, function(t){ + _.each(timers, function(t) { $timeout.cancel(t); }); timers = []; diff --git a/src/app/services/unsavedChangesSrv.js b/src/app/services/unsavedChangesSrv.js index 9d6b7dcd4bb..16b2b07f410 100644 --- a/src/app/services/unsavedChangesSrv.js +++ b/src/app/services/unsavedChangesSrv.js @@ -3,7 +3,7 @@ define([ 'underscore', 'config', ], -function (angular, _, config) { +function(angular, _, config) { 'use strict'; if (!config.unsaved_changes_warning) { @@ -16,7 +16,7 @@ function (angular, _, config) { var self = this; var modalScope = $rootScope.$new(); - $rootScope.$on("dashboard-loaded", function(event, newDashboard ) { + $rootScope.$on("dashboard-loaded", function(event, newDashboard) { self.original = angular.copy(newDashboard); }); @@ -28,7 +28,7 @@ function (angular, _, config) { self.original = null; }); - window.onbeforeunload = function () { + window.onbeforeunload = function() { if (self.has_unsaved_changes()) { return "There are unsaved changes to this dashboard"; } @@ -44,7 +44,7 @@ function (angular, _, config) { }); }; - this.open_modal = function () { + this.open_modal = function() { var confirmModal = $modal({ template: './app/partials/unsaved-changes.html', persist: true, @@ -58,7 +58,7 @@ function (angular, _, config) { }); }; - this.has_unsaved_changes = function () { + this.has_unsaved_changes = function() { if (!self.original) { return false; } @@ -88,7 +88,7 @@ function (angular, _, config) { return false; }; - this.goto_next = function () { + this.goto_next = function() { var baseLen = $location.absUrl().length - $location.url().length; var nextUrl = self.next.substring(baseLen); $location.url(nextUrl); diff --git a/tasks/default_task.js b/tasks/default_task.js index e42843caa7c..14b483fb2ca 100644 --- a/tasks/default_task.js +++ b/tasks/default_task.js @@ -1,5 +1,5 @@ // Lint and build CSS module.exports = function(grunt) { - grunt.registerTask('default', ['jshint:source', 'jshint:tests', 'less:src', 'concat:css']); + grunt.registerTask('default', ['jscs', 'jshint', 'less:src', 'concat:css']); grunt.registerTask('test', ['default', 'karma:test']); }; diff --git a/tasks/options/jscs.js b/tasks/options/jscs.js new file mode 100644 index 00000000000..313893b440d --- /dev/null +++ b/tasks/options/jscs.js @@ -0,0 +1,22 @@ +module.exports = function(config) { + return { + src: [ + 'Gruntfile.js', + '<%= srcDir %>/app/**/*.js', + '!<%= srcDir %>/app/panels/*/{lib,leaflet}/*', + '!<%= srcDir %>/app/dashboards/*' + ], + options: { + config: ".jscs.json", + }, + }; +}; + +/* + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], + "disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "requireRightStickedOperators": ["!"], + "requireLeftStickedOperators": [","], + */ \ No newline at end of file