mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Adding JSCS (javascript style checker)
This commit is contained in:
13
.jscs.json
Normal file
13
.jscs.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"disallowImplicitTypeConversion": ["string"],
|
||||
"disallowKeywords": ["with"],
|
||||
"disallowMultipleLineBreaks": true,
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"requireSpacesInFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"validateIndentation": 2
|
||||
}
|
@@ -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"
|
||||
}
|
||||
}
|
||||
|
@@ -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 '<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) {
|
||||
|
@@ -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',
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -49,7 +49,6 @@ function (angular, $, config, _) {
|
||||
$scope.panelMoveOver = panelMove.onOver;
|
||||
$scope.panelMoveOut = panelMove.onOut;
|
||||
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.config = config;
|
||||
|
||||
|
@@ -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 '+
|
||||
'<a href="'+link+'">'+link+'</a> in a moment','success');
|
||||
'<a href="'+link+'">'+link+'</a> 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);
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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 + ']]',
|
||||
|
@@ -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);
|
||||
});
|
||||
};
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -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();
|
||||
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
});
|
@@ -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 }]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
@@ -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();
|
||||
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
});
|
@@ -8,7 +8,6 @@ define([
|
||||
function (angular, app, _, $, gfunc) {
|
||||
'use strict';
|
||||
|
||||
|
||||
angular
|
||||
.module('kibana.directives')
|
||||
.directive('graphiteAddFunc', function($compile) {
|
||||
|
@@ -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) {
|
||||
|
@@ -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(),
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -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, _, $) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
@@ -133,5 +133,4 @@ function (angular, _, $) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
@@ -111,7 +111,6 @@ function (angular, $, _, PanelBaseCtrl) {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@@ -63,6 +63,5 @@ function (angular, app, _) {
|
||||
$rootScope.$broadcast('refresh');
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
});
|
@@ -414,6 +414,4 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
@@ -70,6 +70,5 @@ function (_, kbn) {
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
return ts;
|
||||
});
|
@@ -84,7 +84,7 @@ function (angular, app, _, require) {
|
||||
};
|
||||
});
|
||||
|
||||
module.filter('newlines', function(){
|
||||
module.filter('newlines', function() {
|
||||
return function (input) {
|
||||
return input.replace(/\n/g, '<br/>');
|
||||
};
|
||||
|
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -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
|
||||
|
@@ -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 = [];
|
||||
|
@@ -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 });
|
||||
};
|
||||
});
|
||||
});
|
||||
|
@@ -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);
|
||||
};
|
||||
|
||||
|
@@ -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;
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -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]
|
||||
});
|
||||
|
||||
|
@@ -186,7 +186,6 @@ function (angular, _, $, config, kbn, moment) {
|
||||
return clean_options;
|
||||
};
|
||||
|
||||
|
||||
return GraphiteDatasource;
|
||||
|
||||
});
|
||||
|
@@ -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;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
|
||||
});
|
||||
|
@@ -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<l; i++) {
|
||||
for (var i = 0, l = keys.length; k = keys[i], i < l; i++) {
|
||||
switch (k) {
|
||||
case 'ctrl':
|
||||
case 'control':
|
||||
@@ -185,7 +185,7 @@ function (angular) {
|
||||
}
|
||||
|
||||
if (k.length > 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;
|
||||
}
|
||||
};
|
||||
//
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@ function (angular, _) {
|
||||
};
|
||||
|
||||
this.cancel_all = function() {
|
||||
_.each(timers, function(t){
|
||||
_.each(timers, function(t) {
|
||||
$timeout.cancel(t);
|
||||
});
|
||||
timers = [];
|
||||
|
@@ -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);
|
||||
|
@@ -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']);
|
||||
};
|
||||
|
22
tasks/options/jscs.js
Normal file
22
tasks/options/jscs.js
Normal file
@@ -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": [","],
|
||||
*/
|
Reference in New Issue
Block a user