mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Changed functions to arrow functions for only-arrow-functions rule.
This commit is contained in:
@@ -24,7 +24,7 @@ export function graphiteAddFunc($compile) {
|
||||
$input.appendTo(elem);
|
||||
$button.appendTo(elem);
|
||||
|
||||
ctrl.datasource.getFuncDefs().then(function(funcDefs) {
|
||||
ctrl.datasource.getFuncDefs().then(funcDefs => {
|
||||
const allFunctions = _.map(funcDefs, 'name').sort();
|
||||
|
||||
$scope.functionMenu = createFunctionDropDownMenu(funcDefs);
|
||||
@@ -34,12 +34,12 @@ export function graphiteAddFunc($compile) {
|
||||
source: allFunctions,
|
||||
minLength: 1,
|
||||
items: 10,
|
||||
updater: function(value) {
|
||||
updater: value => {
|
||||
let funcDef = ctrl.datasource.getFuncDef(value);
|
||||
if (!funcDef) {
|
||||
// try find close match
|
||||
value = value.toLowerCase();
|
||||
funcDef = _.find(allFunctions, function(funcName) {
|
||||
funcDef = _.find(allFunctions, funcName => {
|
||||
return funcName.toLowerCase().indexOf(value) === 0;
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ export function graphiteAddFunc($compile) {
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$apply(function() {
|
||||
$scope.$apply(() => {
|
||||
ctrl.addFunction(funcDef);
|
||||
});
|
||||
|
||||
@@ -57,20 +57,20 @@ export function graphiteAddFunc($compile) {
|
||||
},
|
||||
});
|
||||
|
||||
$button.click(function() {
|
||||
$button.click(() => {
|
||||
$button.hide();
|
||||
$input.show();
|
||||
$input.focus();
|
||||
});
|
||||
|
||||
$input.keyup(function() {
|
||||
$input.keyup(() => {
|
||||
elem.toggleClass('open', $input.val() === '');
|
||||
});
|
||||
|
||||
$input.blur(function() {
|
||||
$input.blur(() => {
|
||||
// clicking the function dropdown menu won't
|
||||
// work if you remove class at once
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
$input.val('');
|
||||
$input.hide();
|
||||
$button.show();
|
||||
@@ -82,7 +82,7 @@ export function graphiteAddFunc($compile) {
|
||||
});
|
||||
|
||||
let drop;
|
||||
const cleanUpDrop = function() {
|
||||
const cleanUpDrop = () => {
|
||||
if (drop) {
|
||||
drop.destroy();
|
||||
drop = null;
|
||||
@@ -121,7 +121,7 @@ export function graphiteAddFunc($compile) {
|
||||
});
|
||||
}
|
||||
})
|
||||
.on('mouseout', 'ul.dropdown-menu li', function() {
|
||||
.on('mouseout', 'ul.dropdown-menu li', () => {
|
||||
cleanUpDrop();
|
||||
});
|
||||
|
||||
@@ -135,7 +135,7 @@ angular.module('grafana.directives').directive('graphiteAddFunc', graphiteAddFun
|
||||
function createFunctionDropDownMenu(funcDefs) {
|
||||
const categories = {};
|
||||
|
||||
_.forEach(funcDefs, function(funcDef) {
|
||||
_.forEach(funcDefs, funcDef => {
|
||||
if (!funcDef.category) {
|
||||
return;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ function createFunctionDropDownMenu(funcDefs) {
|
||||
});
|
||||
|
||||
return _.sortBy(
|
||||
_.map(categories, function(submenu, category) {
|
||||
_.map(categories, (submenu, category) => {
|
||||
return {
|
||||
text: category,
|
||||
submenu: _.sortBy(submenu, 'text'),
|
||||
|
||||
@@ -16,7 +16,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
||||
this.funcDefs = null;
|
||||
this.funcDefsPromise = null;
|
||||
|
||||
this.getQueryOptionsInfo = function() {
|
||||
this.getQueryOptionsInfo = () => {
|
||||
return {
|
||||
maxDataPoints: true,
|
||||
cacheTimeout: true,
|
||||
@@ -70,7 +70,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
||||
}
|
||||
};
|
||||
|
||||
this.convertDataPointsToMs = function(result) {
|
||||
this.convertDataPointsToMs = result => {
|
||||
if (!result || !result.data) {
|
||||
return [];
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
||||
return result;
|
||||
};
|
||||
|
||||
this.parseTags = function(tagString) {
|
||||
this.parseTags = tagString => {
|
||||
let tags = [];
|
||||
tags = tagString.split(',');
|
||||
if (tags.length === 1) {
|
||||
@@ -106,7 +106,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
||||
maxDataPoints: 100,
|
||||
};
|
||||
|
||||
return this.query(graphiteQuery).then(function(result) {
|
||||
return this.query(graphiteQuery).then(result => {
|
||||
const list = [];
|
||||
|
||||
for (let i = 0; i < result.data.length; i++) {
|
||||
@@ -175,11 +175,11 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
||||
}
|
||||
};
|
||||
|
||||
this.targetContainsTemplate = function(target) {
|
||||
this.targetContainsTemplate = target => {
|
||||
return templateSrv.variableExists(target.target);
|
||||
};
|
||||
|
||||
this.translateTime = function(date, roundUp) {
|
||||
this.translateTime = (date, roundUp) => {
|
||||
if (_.isString(date)) {
|
||||
if (date === 'now') {
|
||||
return 'now';
|
||||
@@ -467,7 +467,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
||||
targets: [{ target: 'constantLine(100)' }],
|
||||
maxDataPoints: 300,
|
||||
};
|
||||
return this.query(query).then(function() {
|
||||
return this.query(query).then(() => {
|
||||
return { status: 'success', message: 'Data source is working' };
|
||||
});
|
||||
};
|
||||
@@ -539,7 +539,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
||||
}
|
||||
}
|
||||
|
||||
_.each(options, function(value, key) {
|
||||
_.each(options, (value, key) => {
|
||||
if (_.indexOf(graphiteOptions, key) === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
|
||||
if (!scheduledRelink) {
|
||||
scheduledRelink = true;
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
relink();
|
||||
scheduledRelink = false;
|
||||
}, 200);
|
||||
@@ -93,7 +93,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
|
||||
scheduledRelinkIfNeeded();
|
||||
|
||||
$scope.$apply(function() {
|
||||
$scope.$apply(() => {
|
||||
ctrl.targetChanged();
|
||||
});
|
||||
|
||||
@@ -113,7 +113,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
const inputElem = this;
|
||||
// happens long before the click event on the typeahead options
|
||||
// need to have long delay because the blur
|
||||
cancelBlur = setTimeout(function() {
|
||||
cancelBlur = setTimeout(() => {
|
||||
switchToLink(inputElem, paramIndex);
|
||||
}, 200);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
|
||||
let options = paramDef(paramIndex).options;
|
||||
if (paramDef(paramIndex).type === 'int') {
|
||||
options = _.map(options, function(val) {
|
||||
options = _.map(options, val => {
|
||||
return val.toString();
|
||||
});
|
||||
}
|
||||
@@ -144,7 +144,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
source: options,
|
||||
minLength: 0,
|
||||
items: 20,
|
||||
updater: function(value) {
|
||||
updater: value => {
|
||||
$input.val(value);
|
||||
switchToLink($input[0], paramIndex);
|
||||
return value;
|
||||
@@ -185,7 +185,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
defParams.push(_.assign({}, lastParam, { optional: true }));
|
||||
}
|
||||
|
||||
_.each(defParams, function(param, index) {
|
||||
_.each(defParams, (param, index) => {
|
||||
if (param.optional && func.params.length < index) {
|
||||
return false;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
function ifJustAddedFocusFirstParam() {
|
||||
if ($scope.func.added) {
|
||||
$scope.func.added = false;
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
elem
|
||||
.find('.graphite-func-param-link')
|
||||
.first()
|
||||
@@ -250,18 +250,18 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
}
|
||||
|
||||
function registerFuncControlsActions() {
|
||||
$funcControls.click(function(e) {
|
||||
$funcControls.click(e => {
|
||||
const $target = $(e.target);
|
||||
if ($target.hasClass('fa-remove')) {
|
||||
toggleFuncControls();
|
||||
$scope.$apply(function() {
|
||||
$scope.$apply(() => {
|
||||
ctrl.removeFunction($scope.func);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target.hasClass('fa-arrow-left')) {
|
||||
$scope.$apply(function() {
|
||||
$scope.$apply(() => {
|
||||
_.move(ctrl.queryModel.functions, $scope.$index, $scope.$index - 1);
|
||||
ctrl.targetChanged();
|
||||
});
|
||||
@@ -269,7 +269,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
}
|
||||
|
||||
if ($target.hasClass('fa-arrow-right')) {
|
||||
$scope.$apply(function() {
|
||||
$scope.$apply(() => {
|
||||
_.move(ctrl.queryModel.functions, $scope.$index, $scope.$index + 1);
|
||||
ctrl.targetChanged();
|
||||
});
|
||||
|
||||
@@ -1058,10 +1058,10 @@ function getFuncDef(name, idx?) {
|
||||
|
||||
function getFuncDefs(graphiteVersion, idx?) {
|
||||
const funcs = {};
|
||||
_.forEach(idx || index, function(funcDef) {
|
||||
_.forEach(idx || index, funcDef => {
|
||||
if (isVersionRelatedFunction(funcDef, graphiteVersion)) {
|
||||
funcs[funcDef.name] = _.assign({}, funcDef, {
|
||||
params: _.filter(funcDef.params, function(param) {
|
||||
params: _.filter(funcDef.params, param => {
|
||||
return isVersionRelatedFunction(param, graphiteVersion);
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -1370,7 +1370,7 @@ Lexer.prototype = {
|
||||
};
|
||||
},
|
||||
|
||||
isPunctuator: function(ch1) {
|
||||
isPunctuator: ch1 => {
|
||||
switch (ch1) {
|
||||
case '.':
|
||||
case '(':
|
||||
|
||||
Reference in New Issue
Block a user