Преглед на файлове

Adding JSCS (javascript style checker)

Torkel Ödegaard преди 11 години
родител
ревизия
ce8bdabab8
променени са 41 файла, в които са добавени 395 реда и са изтрити 383 реда
  1. 13 0
      .jscs.json
  2. 2 3
      package.json
  3. 6 6
      src/app/components/kbn.js
  4. 0 1
      src/app/components/require.config.js
  5. 1 1
      src/app/components/underscore.extended.js
  6. 0 1
      src/app/controllers/dash.js
  7. 5 7
      src/app/controllers/dashLoader.js
  8. 0 2
      src/app/controllers/graphiteImport.js
  9. 1 1
      src/app/controllers/graphiteTarget.js
  10. 8 5
      src/app/controllers/influxTargetCtrl.js
  11. 8 9
      src/app/controllers/metricKeys.js
  12. 29 30
      src/app/controllers/pulldown.js
  13. 2 2
      src/app/controllers/search.js
  14. 10 11
      src/app/controllers/submenuCtrl.js
  15. 0 1
      src/app/directives/addGraphiteFunc.js
  16. 1 1
      src/app/directives/dashUpload.js
  17. 5 5
      src/app/directives/grafanaGraph.js
  18. 5 6
      src/app/directives/graphiteFuncEditor.js
  19. 0 1
      src/app/directives/influxdbFuncEditor.js
  20. 0 1
      src/app/directives/kibanaPanel.js
  21. 0 1
      src/app/panels/annotations/module.js
  22. 0 2
      src/app/panels/graph/module.js
  23. 0 1
      src/app/panels/graph/timeSeries.js
  24. 1 1
      src/app/panels/text/module.js
  25. 1 3
      src/app/panels/timepicker/module.js
  26. 1 1
      src/app/services/alertSrv.js
  27. 3 3
      src/app/services/dashboard.js
  28. 43 43
      src/app/services/dashboard/dashboardKeyBindings.js
  29. 1 1
      src/app/services/datasourceSrv.js
  30. 88 88
      src/app/services/filterSrv.js
  31. 44 45
      src/app/services/graphite/gfunc.js
  32. 0 1
      src/app/services/graphite/graphiteDatasource.js
  33. 1 3
      src/app/services/graphite/lexer.js
  34. 4 4
      src/app/services/graphite/parser.js
  35. 4 5
      src/app/services/influxdb/influxdbDatasource.js
  36. 77 77
      src/app/services/keyboardManager.js
  37. 1 2
      src/app/services/panelMove.js
  38. 1 1
      src/app/services/timer.js
  39. 6 6
      src/app/services/unsavedChangesSrv.js
  40. 1 1
      tasks/default_task.js
  41. 22 0
      tasks/options/jscs.js

+ 13 - 0
.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
+}

+ 2 - 3
package.json

@@ -22,7 +22,7 @@
     "grunt-string-replace": "~0.2.4",
     "grunt-string-replace": "~0.2.4",
     "grunt-contrib-htmlmin": "~0.1.3",
     "grunt-contrib-htmlmin": "~0.1.3",
     "grunt-contrib-requirejs": "~0.4.1",
     "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-compress": "~0.5.2",
     "grunt-contrib-uglify": "~0.2.4",
     "grunt-contrib-uglify": "~0.2.4",
     "load-grunt-tasks": "~0.2.0",
     "load-grunt-tasks": "~0.2.0",
@@ -46,7 +46,6 @@
     "grunt-cli": "~0.1.13",
     "grunt-cli": "~0.1.13",
     "jshint-stylish": "~0.1.5",
     "jshint-stylish": "~0.1.5",
     "grunt-contrib-concat": "^0.4.0",
     "grunt-contrib-concat": "^0.4.0",
-    "grunt-angular-templates": "^0.5.5",
     "grunt-usemin": "^2.1.1",
     "grunt-usemin": "^2.1.1",
     "grunt-filerev": "^0.2.1"
     "grunt-filerev": "^0.2.1"
   },
   },
@@ -59,6 +58,6 @@
   },
   },
   "license": "Apache License",
   "license": "Apache License",
   "dependencies": {
   "dependencies": {
-
+    "grunt-jscs-checker": "^0.4.4"
   }
   }
 }
 }

+ 6 - 6
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);
     var numyears = Math.floor(seconds / 31536000);
     if(numyears){
     if(numyears){
       return numyears + 'y';
       return numyears + 'y';
@@ -191,7 +191,7 @@ function($, _, moment) {
 
 
   kbn.parseDateMath = function(mathString, time, roundUp) {
   kbn.parseDateMath = function(mathString, time, roundUp) {
     var dateTime = moment(time);
     var dateTime = moment(time);
-    for (var i = 0; i < mathString.length; ) {
+    for (var i = 0; i < mathString.length;) {
       var c = mathString.charAt(i++),
       var c = mathString.charAt(i++),
         type,
         type,
         num,
         num,
@@ -296,10 +296,10 @@ function($, _, moment) {
 
 
   kbn.query_color_dot = function (color, diameter) {
   kbn.query_color_dot = function (color, diameter) {
     return '<div class="icon-circle" style="' + [
     return '<div class="icon-circle" style="' + [
-        'display:inline-block',
-        'color:' + color,
-        'font-size:' + diameter + 'px',
-      ].join(';') + '"></div>';
+      'display:inline-block',
+      'color:' + color,
+      'font-size:' + diameter + 'px',
+    ].join(';') + '"></div>';
   };
   };
 
 
   kbn.byteFormat = function(size, decimals) {
   kbn.byteFormat = function(size, decimals) {

+ 0 - 1
src/app/components/require.config.js

@@ -41,7 +41,6 @@ require.config({
     'jquery.flot.time':       '../vendor/jquery/jquery.flot.time',
     'jquery.flot.time':       '../vendor/jquery/jquery.flot.time',
     'jquery.flot.byte':       '../vendor/jquery/jquery.flot.byte',
     'jquery.flot.byte':       '../vendor/jquery/jquery.flot.byte',
 
 
-
     modernizr:                '../vendor/modernizr-2.6.1',
     modernizr:                '../vendor/modernizr-2.6.1',
     elasticjs:                '../vendor/elasticjs/elastic-angular-client',
     elasticjs:                '../vendor/elasticjs/elastic-angular-client',
 
 

+ 1 - 1
src/app/components/underscore.extended.js

@@ -11,7 +11,7 @@ function () {
   */
   */
   _.mixin({
   _.mixin({
     move: function (array, fromIndex, toIndex) {
     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;
       return array;
     },
     },
     remove: function (array, index) {
     remove: function (array, index) {

+ 0 - 1
src/app/controllers/dash.js

@@ -49,7 +49,6 @@ function (angular, $, config, _) {
     $scope.panelMoveOver = panelMove.onOver;
     $scope.panelMoveOver = panelMove.onOver;
     $scope.panelMoveOut = panelMove.onOut;
     $scope.panelMoveOut = panelMove.onOut;
 
 
-
     $scope.init = function() {
     $scope.init = function() {
       $scope.config = config;
       $scope.config = config;
 
 

+ 5 - 7
src/app/controllers/dashLoader.js

@@ -105,12 +105,11 @@ function (angular, _, moment) {
     };
     };
 
 
     $scope.save_gist = function() {
     $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;
           $scope.gist.last = link;
           alertSrv.set('Gist saved','You will be able to access your exported dashboard file at '+
           alertSrv.set('Gist saved','You will be able to access your exported dashboard file at '+
-            '<a href="'+link+'">'+link+'</a> in a moment','success');
+          '<a href="'+link+'">'+link+'</a> in a moment','success');
         } else {
         } else {
           alertSrv.set('Save failed','Gist could not be saved','error',5000);
           alertSrv.set('Save failed','Gist could not be saved','error',5000);
         }
         }
@@ -118,9 +117,8 @@ function (angular, _, moment) {
     };
     };
 
 
     $scope.gist_dblist = function(id) {
     $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;
           $scope.gist.files = files;
         } else {
         } else {
           alertSrv.set('Gist Failed','Could not retrieve dashboard list from gist','error',5000);
           alertSrv.set('Gist Failed','Could not retrieve dashboard list from gist','error',5000);

+ 0 - 2
src/app/controllers/graphiteImport.js

@@ -16,7 +16,6 @@ function (angular, app, _) {
       $scope.setDatasource(null);
       $scope.setDatasource(null);
     };
     };
 
 
-
     $scope.setDatasource = function(datasource) {
     $scope.setDatasource = function(datasource) {
       $scope.datasource = datasourceSrv.get(datasource);
       $scope.datasource = datasourceSrv.get(datasource);
 
 
@@ -26,7 +25,6 @@ function (angular, app, _) {
       }
       }
     };
     };
 
 
-
     $scope.listAll = function(query) {
     $scope.listAll = function(query) {
       delete $scope.error;
       delete $scope.error;
 
 

+ 1 - 1
src/app/controllers/graphiteTarget.js

@@ -165,7 +165,7 @@ function (angular, _, config, gfunc, Parser) {
             segment.html = segment.val = segment.text;
             segment.html = segment.val = segment.text;
           });
           });
 
 
-          _.each($scope.filter.templateParameters, function( templateParameter ) {
+          _.each($scope.filter.templateParameters, function(templateParameter) {
             segments.unshift({
             segments.unshift({
               type: 'template',
               type: 'template',
               html: '[[' + templateParameter.name + ']]',
               html: '[[' + templateParameter.name + ']]',

+ 8 - 5
src/app/controllers/influxTargetCtrl.js

@@ -16,13 +16,16 @@ function (angular) {
 
 
       $scope.rawQuery = false;
       $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.operators = ['=', '=~', '>', '<', '!~', '<>'];
       $scope.oldSeries = $scope.target.series;
       $scope.oldSeries = $scope.target.series;
-      $scope.$on('typeahead-updated', function(){
+      $scope.$on('typeahead-updated', function() {
         $timeout($scope.get_data);
         $timeout($scope.get_data);
       });
       });
     };
     };

+ 8 - 9
src/app/controllers/metricKeys.js

@@ -53,7 +53,7 @@ function (angular, _, config) {
       $scope.infoText = "Fetching all metrics from graphite...";
       $scope.infoText = "Fetching all metrics from graphite...";
 
 
       getFromEachGraphite('/metrics/index.json', saveMetricsArray)
       getFromEachGraphite('/metrics/index.json', saveMetricsArray)
-        .then( function() {
+        .then(function() {
           $scope.infoText = "Indexing complete!";
           $scope.infoText = "Indexing complete!";
         }).then(null, function(err) {
         }).then(null, function(err) {
           $scope.errorText = err;
           $scope.errorText = err;
@@ -61,12 +61,12 @@ function (angular, _, config) {
     };
     };
 
 
     function getFromEachGraphite(request, data_callback, error_callback) {
     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) {
     function saveMetricsArray(data, currentIndex) {
@@ -86,7 +86,6 @@ function (angular, _, config) {
         });
         });
     }
     }
 
 
-
     function deleteIndex()
     function deleteIndex()
     {
     {
       var deferred = $q.defer();
       var deferred = $q.defer();
@@ -119,7 +118,7 @@ function (angular, _, config) {
                 type : "nGram",
                 type : "nGram",
                 min_gram : "3",
                 min_gram : "3",
                 max_gram : "8",
                 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)
     function loadMetricsRecursive(metricPath)
     {
     {
-      return getFromEachGraphite( '/metrics/find/?query=' + metricPath, receiveMetric );
+      return getFromEachGraphite('/metrics/find/?query=' + metricPath, receiveMetric);
     }
     }
 
 
   });
   });

+ 29 - 30
src/app/controllers/pulldown.js

@@ -9,35 +9,34 @@ function (angular, app, _) {
   var module = angular.module('kibana.controllers');
   var module = angular.module('kibana.controllers');
 
 
   module.controller('PulldownCtrl', function($scope, $rootScope, $timeout) {
   module.controller('PulldownCtrl', function($scope, $rootScope, $timeout) {
-      var _d = {
-        collapse: false,
-        notice: false,
-        enable: true
-      };
-
-      _.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.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();
-
-    }
-  );
+    var _d = {
+      collapse: false,
+      notice: false,
+      enable: true
+    };
+
+    _.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.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();
+
+  });
 
 
 });
 });

+ 2 - 2
src/app/controllers/search.js

@@ -41,7 +41,7 @@ function (angular, _, config, $) {
         var selectedDash = $scope.results.dashboards[$scope.selectedIndex];
         var selectedDash = $scope.results.dashboards[$scope.selectedIndex];
         if (selectedDash) {
         if (selectedDash) {
           $location.path("/dashboard/elasticsearch/" + encodeURIComponent(selectedDash._id));
           $location.path("/dashboard/elasticsearch/" + encodeURIComponent(selectedDash._id));
-          setTimeout(function(){
+          setTimeout(function() {
             $('body').click(); // hack to force dropdown to close;
             $('body').click(); // hack to force dropdown to close;
           });
           });
         }
         }
@@ -162,7 +162,7 @@ function (angular, _, config, $) {
             type: 'graphite',
             type: 'graphite',
             title: 'test',
             title: 'test',
             span: 12,
             span: 12,
-            targets: [ { target: metricId } ]
+            targets: [{ target: metricId }]
           }
           }
         ]
         ]
       });
       });

+ 10 - 11
src/app/controllers/submenuCtrl.js

@@ -9,20 +9,19 @@ function (angular, app, _) {
   var module = angular.module('kibana.controllers');
   var module = angular.module('kibana.controllers');
 
 
   module.controller('SubmenuCtrl', function($scope) {
   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();
 
 
-    }
-  );
+  });
 
 
 });
 });

+ 0 - 1
src/app/directives/addGraphiteFunc.js

@@ -8,7 +8,6 @@ define([
 function (angular, app, _, $, gfunc) {
 function (angular, app, _, $, gfunc) {
   'use strict';
   'use strict';
 
 
-
   angular
   angular
     .module('kibana.directives')
     .module('kibana.directives')
     .directive('graphiteAddFunc', function($compile) {
     .directive('graphiteAddFunc', function($compile) {

+ 1 - 1
src/app/directives/dashUpload.js

@@ -6,7 +6,7 @@ function (angular) {
 
 
   var module = angular.module('kibana.directives');
   var module = angular.module('kibana.directives');
 
 
-  module.directive('dashUpload', function(timer, dashboard, alertSrv){
+  module.directive('dashUpload', function(timer, dashboard, alertSrv) {
     return {
     return {
       restrict: 'A',
       restrict: 'A',
       link: function(scope) {
       link: function(scope) {

+ 5 - 5
src/app/directives/grafanaGraph.js

@@ -388,11 +388,11 @@ function (angular, $, kbn, moment, _) {
         }
         }
 
 
         elem.bind("plotselected", function (event, ranges) {
         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(),
+            });
           });
           });
         });
         });
       }
       }

+ 5 - 6
src/app/directives/graphiteFuncEditor.js

@@ -75,11 +75,11 @@ function (angular, _, $) {
 
 
             if ($input.val() !== '' || func.def.params[paramIndex].optional) {
             if ($input.val() !== '' || func.def.params[paramIndex].optional) {
               $link.text($input.val());
               $link.text($input.val());
-              
+
               func.updateParam($input.val(), paramIndex);
               func.updateParam($input.val(), paramIndex);
               scheduledRelinkIfNeeded();
               scheduledRelinkIfNeeded();
-              
-              $scope.$apply($scope.targetChanged);              
+
+              $scope.$apply($scope.targetChanged);
             }
             }
 
 
             $input.hide();
             $input.hide();
@@ -104,7 +104,7 @@ function (angular, _, $) {
 
 
             var options = funcDef.params[paramIndex].options;
             var options = funcDef.params[paramIndex].options;
             if (funcDef.params[paramIndex].type === 'int') {
             if (funcDef.params[paramIndex].type === 'int') {
-              options = _.map(options, function(val) { return val.toString(); } );
+              options = _.map(options, function(val) { return val.toString(); });
             }
             }
 
 
             $input.typeahead({
             $input.typeahead({
@@ -230,7 +230,7 @@ function (angular, _, $) {
             addElementsAndCompile();
             addElementsAndCompile();
             ifJustAddedFocusFistParam();
             ifJustAddedFocusFistParam();
             registerFuncControlsToggle();
             registerFuncControlsToggle();
-            registerFuncControlsActions();            
+            registerFuncControlsActions();
           }
           }
 
 
           relink();
           relink();
@@ -239,5 +239,4 @@ function (angular, _, $) {
 
 
     });
     });
 
 
-
 });
 });

+ 0 - 1
src/app/directives/influxdbFuncEditor.js

@@ -133,5 +133,4 @@ function (angular, _, $) {
 
 
     });
     });
 
 
-
 });
 });

+ 0 - 1
src/app/directives/kibanaPanel.js

@@ -111,7 +111,6 @@ function (angular, $, _, PanelBaseCtrl) {
             });
             });
           });
           });
 
 
-
         }
         }
       };
       };
     });
     });

+ 0 - 1
src/app/panels/annotations/module.js

@@ -63,6 +63,5 @@ function (angular, app, _) {
       $rootScope.$broadcast('refresh');
       $rootScope.$broadcast('refresh');
     };
     };
 
 
-
   });
   });
 });
 });

+ 0 - 2
src/app/panels/graph/module.js

@@ -414,6 +414,4 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
 
 
   });
   });
 
 
-
 });
 });
-

+ 0 - 1
src/app/panels/graph/timeSeries.js

@@ -70,6 +70,5 @@ function (_, kbn) {
     return result;
     return result;
   };
   };
 
 
-
   return ts;
   return ts;
 });
 });

+ 1 - 1
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 function (input) {
       return input.replace(/\n/g, '<br/>');
       return input.replace(/\n/g, '<br/>');
     };
     };

+ 1 - 3
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"
         " or if you're using time stamped indices, you need one of these"
     };
     };
 
 
-
     // Set and populate defaults
     // Set and populate defaults
     var _d = {
     var _d = {
       status        : "Stable",
       status        : "Stable",
@@ -156,7 +155,7 @@ function (angular, app, _, moment, kbn) {
 
 
     var pad = function(n, width, z) {
     var pad = function(n, width, z) {
       z = z || '0';
       z = z || '0';
-      n = n + '';
+      n = n.toString();
       return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
       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();
       return moment(new Date(date.getTime() + date.getTimezoneOffset() * 60000)).toDate();
     };
     };
 
 
-
   });
   });
 });
 });

+ 1 - 1
src/app/services/alertSrv.js

@@ -21,7 +21,7 @@ function (angular, _) {
           severity: severity || 'info',
           severity: severity || 'info',
         },
         },
         _ca = angular.toJson(_a),
         _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
       // 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
       // Why do this instead of skipping the add because it resets the timer

+ 3 - 3
src/app/services/dashboard.js

@@ -28,8 +28,8 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
       failover: false,
       failover: false,
       panel_hints: true,
       panel_hints: true,
       rows: [],
       rows: [],
-      pulldowns: [ { type: 'templating' },  { type: 'annotations' } ],
-      nav: [ { type: 'timepicker' } ],
+      pulldowns: [{ type: 'templating' },  { type: 'annotations' }],
+      nav: [{ type: 'timepicker' }],
       services: {},
       services: {},
       loader: {
       loader: {
         save_gist: false,
         save_gist: false,
@@ -59,7 +59,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
     this.last = {};
     this.last = {};
     this.availablePanels = [];
     this.availablePanels = [];
 
 
-    $rootScope.$on('$routeChangeSuccess',function(){
+    $rootScope.$on('$routeChangeSuccess',function() {
       // Clear the current dashboard to prevent reloading
       // Clear the current dashboard to prevent reloading
       self.current = {};
       self.current = {};
       self.indices = [];
       self.indices = [];

+ 43 - 43
src/app/services/dashboard/dashboardKeyBindings.js

@@ -10,49 +10,49 @@ function(angular, $) {
 
 
   module.service('dashboardKeybindings', function($rootScope, keyboardManager, dashboard) {
   module.service('dashboardKeybindings', function($rootScope, keyboardManager, dashboard) {
     this.shortcuts = function() {
     this.shortcuts = function() {
-       $rootScope.$on('panel-fullscreen-enter', function() {
-         $rootScope.fullscreen = true;
-       });
-
-       $rootScope.$on('panel-fullscreen-exit', function() {
-         $rootScope.fullscreen = false;
-       });
-
-       $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+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+r', function() {
-         dashboard.refresh();
-       }, { 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 });
+      $rootScope.$on('panel-fullscreen-enter', function() {
+        $rootScope.fullscreen = true;
+      });
+
+      $rootScope.$on('panel-fullscreen-exit', function() {
+        $rootScope.fullscreen = false;
+      });
+
+      $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+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+r', function() {
+        dashboard.refresh();
+      }, { 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 });
     };
     };
   });
   });
 });
 });

+ 1 - 1
src/app/services/datasourceSrv.js

@@ -13,7 +13,7 @@ function (angular, _, config) {
   module.service('datasourceSrv', function($q, $http, GraphiteDatasource, InfluxDatasource) {
   module.service('datasourceSrv', function($q, $http, GraphiteDatasource, InfluxDatasource) {
 
 
     this.init = function() {
     this.init = function() {
-      var defaultDatasource = _.findWhere(_.values(config.datasources), { default: true } );
+      var defaultDatasource = _.findWhere(_.values(config.datasources), { default: true });
       this.default = this.datasourceFactory(defaultDatasource);
       this.default = this.datasourceFactory(defaultDatasource);
     };
     };
 
 

+ 88 - 88
src/app/services/filterSrv.js

@@ -9,102 +9,102 @@ define([
   var module = angular.module('kibana.services');
   var module = angular.module('kibana.services');
 
 
   module.factory('filterSrv', function(dashboard, $rootScope, $timeout, $routeParams) {
   module.factory('filterSrv', function(dashboard, $rootScope, $timeout, $routeParams) {
-  // defaults
-  var _d = {
-    templateParameters: [],
-    time: {}
-  };
-
-  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 };
+    // defaults
+    var _d = {
+      templateParameters: [],
+      time: {}
+    };
+
+    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 };
+            }
           }
           }
+          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;
-        }
-        _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;
-      }
 
 
-      return _.template(target, this._templateData, this.templateSettings);
-    },
+        return _.template(target, this._templateData, this.templateSettings);
+      },
 
 
-    setTime: function(time) {
-      _.extend(this.time, time);
+      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;
-      }
+        // 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);
-    },
+        $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);
-      }
+      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;
   });
   });
 
 
 });
 });

+ 44 - 45
src/app/services/graphite/gfunc.js

@@ -27,7 +27,7 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: 'scaleToSeconds',
     name: 'scaleToSeconds',
     category: categories.Transform,
     category: categories.Transform,
-    params: [ { name: 'seconds', type: 'int' } ],
+    params: [{ name: 'seconds', type: 'int' }],
     defaultParams: [1],
     defaultParams: [1],
   });
   });
 
 
@@ -39,21 +39,21 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: "holtWintersConfidenceBands",
     name: "holtWintersConfidenceBands",
     category: categories.Calculate,
     category: categories.Calculate,
-    params: [ { name: "delta", type: 'int' } ],
+    params: [{ name: "delta", type: 'int' }],
     defaultParams: [3]
     defaultParams: [3]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: "holtWintersAberration",
     name: "holtWintersAberration",
     category: categories.Calculate,
     category: categories.Calculate,
-    params: [ { name: "delta", type: 'int' } ],
+    params: [{ name: "delta", type: 'int' }],
     defaultParams: [3]
     defaultParams: [3]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: "nPercentile",
     name: "nPercentile",
     category: categories.Calculate,
     category: categories.Calculate,
-    params: [ { name: "Nth percentile", type: 'int' } ],
+    params: [{ name: "Nth percentile", type: 'int' }],
     defaultParams: [95]
     defaultParams: [95]
   });
   });
 
 
@@ -82,14 +82,14 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: 'percentileOfSeries',
     name: 'percentileOfSeries',
     category: categories.Combine,
     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"]
     defaultParams: [95, "false"]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'sumSeriesWithWildcards',
     name: 'sumSeriesWithWildcards',
     category: categories.Combine,
     category: categories.Combine,
-    params: [ { name: "node", type: "int" } ],
+    params: [{ name: "node", type: "int" }],
     defaultParams: [3]
     defaultParams: [3]
   });
   });
 
 
@@ -108,28 +108,28 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: 'averageSeriesWithWildcards',
     name: 'averageSeriesWithWildcards',
     category: categories.Combine,
     category: categories.Combine,
-    params: [ { name: "node", type: "int" } ],
+    params: [{ name: "node", type: "int" }],
     defaultParams: [3]
     defaultParams: [3]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: "alias",
     name: "alias",
     category: categories.Special,
     category: categories.Special,
-    params: [ { name: "alias", type: 'string' } ],
+    params: [{ name: "alias", type: 'string' }],
     defaultParams: ['alias']
     defaultParams: ['alias']
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: "aliasSub",
     name: "aliasSub",
     category: categories.Special,
     category: categories.Special,
-    params: [ { name: "search", type: 'string' }, { name: "replace", type: 'string' } ],
+    params: [{ name: "search", type: 'string' }, { name: "replace", type: 'string' }],
     defaultParams: ['', '']
     defaultParams: ['', '']
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: "stacked",
     name: "stacked",
     category: categories.Special,
     category: categories.Special,
-    params: [ { name: "stack", type: 'string' } ],
+    params: [{ name: "stack", type: 'string' }],
     defaultParams: ['stacked']
     defaultParams: ['stacked']
   });
   });
 
 
@@ -212,7 +212,7 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: 'randomWalk',
     name: 'randomWalk',
     category: categories.Special,
     category: categories.Special,
-    params: [ { name: "name", type: "string", } ],
+    params: [{ name: "name", type: "string", }],
     defaultParams: ['randomWalk']
     defaultParams: ['randomWalk']
   });
   });
 
 
@@ -224,7 +224,7 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: 'constantLine',
     name: 'constantLine',
     category: categories.Special,
     category: categories.Special,
-    params: [ { name: "value", type: "int", } ],
+    params: [{ name: "value", type: "int", }],
     defaultParams: [10]
     defaultParams: [10]
   });
   });
 
 
@@ -236,28 +236,28 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: 'keepLastValue',
     name: 'keepLastValue',
     category: categories.Special,
     category: categories.Special,
-    params: [ { name: "n", type: "int", } ],
+    params: [{ name: "n", type: "int", }],
     defaultParams: [100]
     defaultParams: [100]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'scale',
     name: 'scale',
     category: categories.Transform,
     category: categories.Transform,
-    params: [ { name: "factor", type: "int", } ],
+    params: [{ name: "factor", type: "int", }],
     defaultParams: [1]
     defaultParams: [1]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'offset',
     name: 'offset',
     category: categories.Transform,
     category: categories.Transform,
-    params: [ { name: "amount", type: "int", } ],
+    params: [{ name: "amount", type: "int", }],
     defaultParams: [10]
     defaultParams: [10]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'transformNull',
     name: 'transformNull',
     category: categories.Transform,
     category: categories.Transform,
-    params: [ { name: "amount", type: "int", } ],
+    params: [{ name: "amount", type: "int", }],
     defaultParams: [0]
     defaultParams: [0]
   });
   });
 
 
@@ -274,28 +274,28 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: 'nonNegativeDerivative',
     name: 'nonNegativeDerivative',
     category: categories.Transform,
     category: categories.Transform,
-    params: [ { name: "max value or 0", type: "int", } ],
+    params: [{ name: "max value or 0", type: "int", }],
     defaultParams: [0]
     defaultParams: [0]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'timeShift',
     name: 'timeShift',
     category: categories.Transform,
     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']
     defaultParams: ['1d']
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'summarize',
     name: 'summarize',
     category: categories.Transform,
     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']
     defaultParams: ['1h', 'sum']
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'smartSummarize',
     name: 'smartSummarize',
     category: categories.Transform,
     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']
     defaultParams: ['1h', 'sum']
   });
   });
 
 
@@ -307,169 +307,168 @@ function (_) {
   addFuncDef({
   addFuncDef({
     name: 'hitcount',
     name: 'hitcount',
     category: categories.Transform,
     category: categories.Transform,
-    params: [ { name: "interval", type: "string" }],
+    params: [{ name: "interval", type: "string" }],
     defaultParams: ['10s']
     defaultParams: ['10s']
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'log',
     name: 'log',
     category: categories.Transform,
     category: categories.Transform,
-    params: [ { name: "base", type: "int" }],
+    params: [{ name: "base", type: "int" }],
     defaultParams: ['10']
     defaultParams: ['10']
   });
   });
 
 
-
   addFuncDef({
   addFuncDef({
     name: 'averageAbove',
     name: 'averageAbove',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int", } ],
+    params: [{ name: "n", type: "int", }],
     defaultParams: [25]
     defaultParams: [25]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'averageBelow',
     name: 'averageBelow',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int", } ],
+    params: [{ name: "n", type: "int", }],
     defaultParams: [25]
     defaultParams: [25]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'currentAbove',
     name: 'currentAbove',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int", } ],
+    params: [{ name: "n", type: "int", }],
     defaultParams: [25]
     defaultParams: [25]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'currentBelow',
     name: 'currentBelow',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int", } ],
+    params: [{ name: "n", type: "int", }],
     defaultParams: [25]
     defaultParams: [25]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'maximumAbove',
     name: 'maximumAbove',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "value", type: "int" } ],
+    params: [{ name: "value", type: "int" }],
     defaultParams: [0]
     defaultParams: [0]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'maximumBelow',
     name: 'maximumBelow',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "value", type: "int" } ],
+    params: [{ name: "value", type: "int" }],
     defaultParams: [0]
     defaultParams: [0]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'minimumAbove',
     name: 'minimumAbove',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "value", type: "int" } ],
+    params: [{ name: "value", type: "int" }],
     defaultParams: [0]
     defaultParams: [0]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'limit',
     name: 'limit',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int" } ],
+    params: [{ name: "n", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'mostDeviant',
     name: 'mostDeviant',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int" } ],
+    params: [{ name: "n", type: "int" }],
     defaultParams: [10]
     defaultParams: [10]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: "exclude",
     name: "exclude",
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "exclude", type: 'string' } ],
+    params: [{ name: "exclude", type: 'string' }],
     defaultParams: ['exclude']
     defaultParams: ['exclude']
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'highestCurrent',
     name: 'highestCurrent',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "count", type: "int" } ],
+    params: [{ name: "count", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'highestMax',
     name: 'highestMax',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "count", type: "int" } ],
+    params: [{ name: "count", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'lowestCurrent',
     name: 'lowestCurrent',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "count", type: "int" } ],
+    params: [{ name: "count", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'movingAverage',
     name: 'movingAverage',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "window size", type: "int" } ],
+    params: [{ name: "window size", type: "int" }],
     defaultParams: [10]
     defaultParams: [10]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'movingMedian',
     name: 'movingMedian',
     category: categories.Filter,
     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']
     defaultParams: ['1min']
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'stdev',
     name: 'stdev',
     category: categories.Filter,
     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]
     defaultParams: [5,0.1]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'highestAverage',
     name: 'highestAverage',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "count", type: "int" } ],
+    params: [{ name: "count", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'lowestAverage',
     name: 'lowestAverage',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "count", type: "int" } ],
+    params: [{ name: "count", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'removeAbovePercentile',
     name: 'removeAbovePercentile',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int" } ],
+    params: [{ name: "n", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'removeAboveValue',
     name: 'removeAboveValue',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int" } ],
+    params: [{ name: "n", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'removeBelowPercentile',
     name: 'removeBelowPercentile',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int" } ],
+    params: [{ name: "n", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 
   addFuncDef({
   addFuncDef({
     name: 'removeBelowValue',
     name: 'removeBelowValue',
     category: categories.Filter,
     category: categories.Filter,
-    params: [ { name: "n", type: "int" } ],
+    params: [{ name: "n", type: "int" }],
     defaultParams: [5]
     defaultParams: [5]
   });
   });
 
 

+ 0 - 1
src/app/services/graphite/graphiteDatasource.js

@@ -186,7 +186,6 @@ function (angular, _, $, config, kbn, moment) {
       return clean_options;
       return clean_options;
     };
     };
 
 
-
     return GraphiteDatasource;
     return GraphiteDatasource;
 
 
   });
   });

+ 1 - 3
src/app/services/graphite/lexer.js

@@ -157,7 +157,7 @@ define([
     tokenize: function() {
     tokenize: function() {
       var list = [];
       var list = [];
       var token;
       var token;
-      while(token = this.next()) {
+      while (token = this.next()) {
         list.push(token);
         list.push(token);
       }
       }
       return list;
       return list;
@@ -721,5 +721,3 @@ define([
   return Lexer;
   return Lexer;
 
 
 });
 });
-
-

+ 4 - 4
src/app/services/graphite/parser.js

@@ -20,7 +20,7 @@ define([
       try {
       try {
         return this.functionCall() || this.metricExpression();
         return this.functionCall() || this.metricExpression();
       }
       }
-      catch(e) {
+      catch (e) {
         return {
         return {
           type: 'error',
           type: 'error',
           message: e.message,
           message: e.message,
@@ -34,7 +34,7 @@ define([
 
 
         var curlySegment = "";
         var curlySegment = "";
 
 
-        while(!this.match('') && !this.match('}')) {
+        while (!this.match('') && !this.match('}')) {
           curlySegment += this.consumeToken().value;
           curlySegment += this.consumeToken().value;
         }
         }
 
 
@@ -108,7 +108,7 @@ define([
 
 
       node.segments.push(this.metricSegment());
       node.segments.push(this.metricSegment());
 
 
-      while(this.match('.')) {
+      while (this.match('.')) {
         this.consumeToken();
         this.consumeToken();
 
 
         var segment = this.metricSegment();
         var segment = this.metricSegment();
@@ -204,7 +204,7 @@ define([
     // returns token value and incre
     // returns token value and incre
     consumeToken: function() {
     consumeToken: function() {
       this.index++;
       this.index++;
-      return this.tokens[this.index-1];
+      return this.tokens[this.index - 1];
     },
     },
 
 
     matchToken: function(type, index) {
     matchToken: function(type, index) {

+ 4 - 5
src/app/services/influxdb/influxdbDatasource.js

@@ -44,7 +44,7 @@ function (angular, _, kbn) {
           var orderIndex = lowerCaseQueryElements.indexOf("order");
           var orderIndex = lowerCaseQueryElements.indexOf("order");
 
 
           if (whereIndex !== -1) {
           if (whereIndex !== -1) {
-            queryElements.splice(whereIndex+1, 0, timeFilter, "and");
+            queryElements.splice(whereIndex + 1, 0, timeFilter, "and");
           }
           }
           else {
           else {
             if (groupByIndex !== -1) {
             if (groupByIndex !== -1) {
@@ -122,7 +122,7 @@ function (angular, _, kbn) {
       try {
       try {
         interpolated = filterSrv.applyTemplateToTarget(query);
         interpolated = filterSrv.applyTemplateToTarget(query);
       }
       }
-      catch(err) {
+      catch (err) {
         return $q.reject(err);
         return $q.reject(err);
       }
       }
 
 
@@ -193,12 +193,12 @@ function (angular, _, kbn) {
           var datapoints = [];
           var datapoints = [];
           var value;
           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];
             value = isNaN(series.points[i][index]) ? null : series.points[i][index];
             datapoints[i] = [value, series.points[i][timeCol]];
             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 (date.getTime() / 1000).toFixed(0) + 's';
     }
     }
 
 
-
     return InfluxDatasource;
     return InfluxDatasource;
 
 
   });
   });

+ 77 - 77
src/app/services/keyboardManager.js

@@ -28,7 +28,7 @@ function (angular) {
       label = label.toLowerCase();
       label = label.toLowerCase();
       elt   = opt.target;
       elt   = opt.target;
 
 
-      if(typeof opt.target === 'string') {
+      if (typeof opt.target === 'string') {
         elt = document.getElementById(opt.target);
         elt = document.getElementById(opt.target);
       }
       }
 
 
@@ -75,79 +75,79 @@ function (angular) {
         var kp = 0;
         var kp = 0;
         // Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
         // Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
         var shift_nums = {
         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
         // Special Keys - and their codes
         var special_keys = {
         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
         // Some modifiers key
         var modifiers = {
         var modifiers = {
@@ -169,7 +169,7 @@ function (angular) {
           }
           }
         };
         };
         // Foreach keys in label (split on +)
         // Foreach keys in label (split on +)
-        for(var i=0, l=keys.length; k=keys[i],i<l; i++) {
+        for (var i = 0, l = keys.length; k = keys[i], i < l; i++) {
           switch (k) {
           switch (k) {
           case 'ctrl':
           case 'ctrl':
           case 'control':
           case 'control':
@@ -185,7 +185,7 @@ function (angular) {
           }
           }
 
 
           if (k.length > 1) { // If it is a special key
           if (k.length > 1) { // If it is a special key
-            if(special_keys[k] === code) {
+            if (special_keys[k] === code) {
               kp++;
               kp++;
             }
             }
           } else if (opt['keyCode']) { // If a specific key is set into the config
           } else if (opt['keyCode']) { // If a specific key is set into the config
@@ -193,13 +193,13 @@ function (angular) {
               kp++;
               kp++;
             }
             }
           } else { // The special keys did not match
           } else { // The special keys did not match
-            if(character === k) {
+            if (character === k) {
               kp++;
               kp++;
             }
             }
             else {
             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];
                 character = shift_nums[character];
-                if(character === k) {
+                if (character === k) {
                   kp++;
                   kp++;
                 }
                 }
               }
               }
@@ -207,7 +207,7 @@ function (angular) {
           }
           }
         }
         }
 
 
-        if(kp === keys.length &&
+        if (kp === keys.length &&
           modifiers.ctrl.pressed === modifiers.ctrl.wanted &&
           modifiers.ctrl.pressed === modifiers.ctrl.wanted &&
           modifiers.shift.pressed === modifiers.shift.wanted &&
           modifiers.shift.pressed === modifiers.shift.wanted &&
           modifiers.alt.pressed === modifiers.alt.wanted &&
           modifiers.alt.pressed === modifiers.alt.wanted &&
@@ -216,7 +216,7 @@ function (angular) {
             callback(e);
             callback(e);
           }, 1);
           }, 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 is supported by IE - this will kill the bubbling process.
             e.cancelBubble = true;
             e.cancelBubble = true;
             e.returnValue = false;
             e.returnValue = false;
@@ -238,10 +238,10 @@ function (angular) {
         'event':    opt['type']
         'event':    opt['type']
       };
       };
       //Attach the function with the event
       //Attach the function with the event
-      if(elt.addEventListener) {
+      if (elt.addEventListener) {
         elt.addEventListener(opt['type'], fct, false);
         elt.addEventListener(opt['type'], fct, false);
       }
       }
-      else if(elt.attachEvent) {
+      else if (elt.attachEvent) {
         elt.attachEvent('on' + opt['type'], fct);
         elt.attachEvent('on' + opt['type'], fct);
       }
       }
       else {
       else {
@@ -255,7 +255,7 @@ function (angular) {
       var binding = keyboardManagerService.keyboardEvent[label];
       var binding = keyboardManagerService.keyboardEvent[label];
       delete(keyboardManagerService.keyboardEvent[label]);
       delete(keyboardManagerService.keyboardEvent[label]);
 
 
-      if(!binding) {
+      if (!binding) {
         return;
         return;
       }
       }
 
 
@@ -263,14 +263,14 @@ function (angular) {
       elt     = binding['target'],
       elt     = binding['target'],
       callback  = binding['callback'];
       callback  = binding['callback'];
 
 
-      if(elt.detachEvent) {
+      if (elt.detachEvent) {
         elt.detachEvent('on' + type, callback);
         elt.detachEvent('on' + type, callback);
       }
       }
-      else if(elt.removeEventListener) {
+      else if (elt.removeEventListener) {
         elt.removeEventListener(type, callback, false);
         elt.removeEventListener(type, callback, false);
       }
       }
       else {
       else {
-        elt['on'+type] = false;
+        elt['on' + type] = false;
       }
       }
     };
     };
     //
     //

+ 1 - 2
src/app/services/panelMove.js

@@ -34,12 +34,11 @@ function (angular, _) {
         dragIndex = data.dragSettings.index,
         dragIndex = data.dragSettings.index,
         dropIndex =  data.dropSettings.index;
         dropIndex =  data.dropSettings.index;
 
 
-
       // Remove panel from source row
       // Remove panel from source row
       dragRow.splice(dragIndex,1);
       dragRow.splice(dragIndex,1);
 
 
       // Add to destination row
       // Add to destination row
-      if(!_.isUndefined(dropRow)) {
+      if (!_.isUndefined(dropRow)) {
         dropRow.splice(dropIndex,0,data.dragItem);
         dropRow.splice(dropIndex,0,data.dragItem);
       }
       }
 
 

+ 1 - 1
src/app/services/timer.js

@@ -24,7 +24,7 @@ function (angular, _) {
     };
     };
 
 
     this.cancel_all = function() {
     this.cancel_all = function() {
-      _.each(timers, function(t){
+      _.each(timers, function(t) {
         $timeout.cancel(t);
         $timeout.cancel(t);
       });
       });
       timers = [];
       timers = [];

+ 6 - 6
src/app/services/unsavedChangesSrv.js

@@ -3,7 +3,7 @@ define([
   'underscore',
   'underscore',
   'config',
   'config',
 ],
 ],
-function (angular, _, config) {
+function(angular, _, config) {
   'use strict';
   'use strict';
 
 
   if (!config.unsaved_changes_warning) {
   if (!config.unsaved_changes_warning) {
@@ -16,7 +16,7 @@ function (angular, _, config) {
     var self = this;
     var self = this;
     var modalScope = $rootScope.$new();
     var modalScope = $rootScope.$new();
 
 
-    $rootScope.$on("dashboard-loaded", function(event, newDashboard ) {
+    $rootScope.$on("dashboard-loaded", function(event, newDashboard) {
       self.original = angular.copy(newDashboard);
       self.original = angular.copy(newDashboard);
     });
     });
 
 
@@ -28,7 +28,7 @@ function (angular, _, config) {
       self.original = null;
       self.original = null;
     });
     });
 
 
-    window.onbeforeunload = function () {
+    window.onbeforeunload = function() {
       if (self.has_unsaved_changes()) {
       if (self.has_unsaved_changes()) {
         return "There are unsaved changes to this dashboard";
         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({
       var confirmModal = $modal({
           template: './app/partials/unsaved-changes.html',
           template: './app/partials/unsaved-changes.html',
           persist: true,
           persist: true,
@@ -58,7 +58,7 @@ function (angular, _, config) {
       });
       });
     };
     };
 
 
-    this.has_unsaved_changes = function () {
+    this.has_unsaved_changes = function() {
       if (!self.original) {
       if (!self.original) {
         return false;
         return false;
       }
       }
@@ -88,7 +88,7 @@ function (angular, _, config) {
       return false;
       return false;
     };
     };
 
 
-    this.goto_next = function () {
+    this.goto_next = function() {
       var baseLen = $location.absUrl().length - $location.url().length;
       var baseLen = $location.absUrl().length - $location.url().length;
       var nextUrl = self.next.substring(baseLen);
       var nextUrl = self.next.substring(baseLen);
       $location.url(nextUrl);
       $location.url(nextUrl);

+ 1 - 1
tasks/default_task.js

@@ -1,5 +1,5 @@
 // Lint and build CSS
 // Lint and build CSS
 module.exports = function(grunt) {
 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']);
   grunt.registerTask('test', ['default', 'karma:test']);
 };
 };

+ 22 - 0
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": [","],
+   */