added this:any to functions and changed functions to arrowfunctions

This commit is contained in:
Patrick O'Carroll
2018-08-30 10:49:18 +02:00
parent 80d6ef535d
commit a8547ae36e
18 changed files with 53 additions and 62 deletions

View File

@@ -90,7 +90,7 @@ export function graphiteAddFunc($compile) {
};
$(elem)
.on('mouseenter', 'ul.dropdown-menu li', function() {
.on('mouseenter', 'ul.dropdown-menu li', () => {
cleanUpDrop();
var funcDef;

View File

@@ -4,7 +4,7 @@ import { isVersionGtOrEq, SemVersion } from 'app/core/utils/version';
import gfunc from './gfunc';
/** @ngInject */
export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv) {
export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, templateSrv) {
this.basicAuth = instanceSettings.basicAuth;
this.url = instanceSettings.url;
this.name = instanceSettings.name;

View File

@@ -28,7 +28,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
var paramCountAtLink = 0;
var cancelBlur = null;
function clickFuncParam(paramIndex) {
function clickFuncParam(this: any, paramIndex) {
/*jshint validthis:true */
const $link = $(this);
@@ -108,7 +108,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
}
// this = input element
function inputBlur(paramIndex) {
function inputBlur(this: any, paramIndex) {
/*jshint validthis:true */
const inputElem = this;
// happens long before the click event on the typeahead options
@@ -118,14 +118,14 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
}, 200);
}
function inputKeyPress(paramIndex, e) {
function inputKeyPress(this: any, paramIndex, e) {
/*jshint validthis:true */
if (e.which === 13) {
$(this).blur();
}
}
function inputKeyDown() {
function inputKeyDown(this: any) {
/*jshint validthis:true */
this.style.width = (3 + this.value.length) * 8 + 'px';
}

View File

@@ -964,26 +964,23 @@ export class FuncInstance {
render(metricExp) {
const str = this.def.name + '(';
const parameters = _.map(
this.params,
function(value, index) {
var paramType;
if (index < this.def.params.length) {
paramType = this.def.params[index].type;
} else if (_.get(_.last(this.def.params), 'multiple')) {
paramType = _.get(_.last(this.def.params), 'type');
}
// param types that should never be quoted
if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) {
return value;
}
// param types that might be quoted
if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+value)) {
return _.toString(+value);
}
return "'" + value + "'";
}.bind(this)
);
const parameters = _.map(this.params, (value, index) => {
var paramType;
if (index < this.def.params.length) {
paramType = this.def.params[index].type;
} else if (_.get(_.last(this.def.params), 'multiple')) {
paramType = _.get(_.last(this.def.params), 'type');
}
// param types that should never be quoted
if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) {
return value;
}
// param types that might be quoted
if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+value)) {
return _.toString(+value);
}
return "'" + value + "'";
});
// don't send any blank parameters to graphite
while (parameters[parameters.length - 1] === '') {
@@ -1017,12 +1014,9 @@ export class FuncInstance {
// handle optional parameters
// if string contains ',' and next param is optional, split and update both
if (this._hasMultipleParamsInString(strValue, index)) {
_.each(
strValue.split(','),
function(partVal, idx) {
this.updateParam(partVal.trim(), index + idx);
}.bind(this)
);
_.each(strValue.split(','), (partVal, idx) => {
this.updateParam(partVal.trim(), index + idx);
});
return;
}