Changed functions to arrow functions for only-arrow-functions rule.

This commit is contained in:
Patrick O'Carroll
2018-09-04 14:27:03 +02:00
parent 5c0fbbf7c8
commit 19b7ad61dd
50 changed files with 289 additions and 288 deletions

View File

@@ -19,7 +19,7 @@ export class CloudWatchQueryParameter {
export class CloudWatchQueryParameterCtrl {
/** @ngInject */
constructor($scope, templateSrv, uiSegmentSrv, datasourceSrv, $q) {
$scope.init = function() {
$scope.init = () => {
const target = $scope.target;
target.namespace = target.namespace || '';
target.metricName = target.metricName || '';
@@ -38,7 +38,7 @@ export class CloudWatchQueryParameterCtrl {
$scope.dimSegments = _.reduce(
$scope.target.dimensions,
function(memo, value, key) {
(memo, value, key) => {
memo.push(uiSegmentSrv.newKey(key));
memo.push(uiSegmentSrv.newOperator('='));
memo.push(uiSegmentSrv.newKeyValue(value));
@@ -47,7 +47,7 @@ export class CloudWatchQueryParameterCtrl {
[]
);
$scope.statSegments = _.map($scope.target.statistics, function(stat) {
$scope.statSegments = _.map($scope.target.statistics, stat => {
return uiSegmentSrv.getSegmentForValue(stat);
});
@@ -67,15 +67,15 @@ export class CloudWatchQueryParameterCtrl {
}
if (!$scope.onChange) {
$scope.onChange = function() {};
$scope.onChange = () => {};
}
};
$scope.getStatSegments = function() {
$scope.getStatSegments = () => {
return $q.when(
_.flatten([
angular.copy($scope.removeStatSegment),
_.map($scope.datasource.standardStatistics, function(s) {
_.map($scope.datasource.standardStatistics, s => {
return uiSegmentSrv.getSegmentForValue(s);
}),
uiSegmentSrv.getSegmentForValue('pNN.NN'),
@@ -83,7 +83,7 @@ export class CloudWatchQueryParameterCtrl {
);
};
$scope.statSegmentChanged = function(segment, index) {
$scope.statSegmentChanged = (segment, index) => {
if (segment.value === $scope.removeStatSegment.value) {
$scope.statSegments.splice(index, 1);
} else {
@@ -92,7 +92,7 @@ export class CloudWatchQueryParameterCtrl {
$scope.target.statistics = _.reduce(
$scope.statSegments,
function(memo, seg) {
(memo, seg) => {
if (!seg.fake) {
memo.push(seg.value);
}
@@ -105,7 +105,7 @@ export class CloudWatchQueryParameterCtrl {
$scope.onChange();
};
$scope.ensurePlusButton = function(segments) {
$scope.ensurePlusButton = segments => {
const count = segments.length;
const lastSegment = segments[Math.max(count - 1, 0)];
@@ -114,7 +114,7 @@ export class CloudWatchQueryParameterCtrl {
}
};
$scope.getDimSegments = function(segment, $index) {
$scope.getDimSegments = (segment, $index) => {
if (segment.type === 'operator') {
return $q.when([]);
}
@@ -135,7 +135,7 @@ export class CloudWatchQueryParameterCtrl {
);
}
return query.then($scope.transformToSegments(true)).then(function(results) {
return query.then($scope.transformToSegments(true)).then(results => {
if (segment.type === 'key') {
results.splice(0, 0, angular.copy($scope.removeDimSegment));
}
@@ -143,7 +143,7 @@ export class CloudWatchQueryParameterCtrl {
});
};
$scope.dimSegmentChanged = function(segment, index) {
$scope.dimSegmentChanged = (segment, index) => {
$scope.dimSegments[index] = segment;
if (segment.value === $scope.removeDimSegment.value) {
@@ -160,7 +160,7 @@ export class CloudWatchQueryParameterCtrl {
$scope.onChange();
};
$scope.syncDimSegmentsWithModel = function() {
$scope.syncDimSegmentsWithModel = () => {
const dims = {};
const length = $scope.dimSegments.length;
@@ -175,44 +175,44 @@ export class CloudWatchQueryParameterCtrl {
$scope.target.dimensions = dims;
};
$scope.getRegions = function() {
$scope.getRegions = () => {
return $scope.datasource
.metricFindQuery('regions()')
.then(function(results) {
.then(results => {
results.unshift({ text: 'default' });
return results;
})
.then($scope.transformToSegments(true));
};
$scope.getNamespaces = function() {
$scope.getNamespaces = () => {
return $scope.datasource.metricFindQuery('namespaces()').then($scope.transformToSegments(true));
};
$scope.getMetrics = function() {
$scope.getMetrics = () => {
return $scope.datasource
.metricFindQuery('metrics(' + $scope.target.namespace + ',' + $scope.target.region + ')')
.then($scope.transformToSegments(true));
};
$scope.regionChanged = function() {
$scope.regionChanged = () => {
$scope.target.region = $scope.regionSegment.value;
$scope.onChange();
};
$scope.namespaceChanged = function() {
$scope.namespaceChanged = () => {
$scope.target.namespace = $scope.namespaceSegment.value;
$scope.onChange();
};
$scope.metricChanged = function() {
$scope.metricChanged = () => {
$scope.target.metricName = $scope.metricSegment.value;
$scope.onChange();
};
$scope.transformToSegments = function(addTemplateVars) {
return function(results) {
const segments = _.map(results, function(segment) {
$scope.transformToSegments = addTemplateVars => {
return results => {
const segments = _.map(results, segment => {
return uiSegmentSrv.newSegment({
value: segment.text,
expandable: segment.expandable,
@@ -220,7 +220,7 @@ export class CloudWatchQueryParameterCtrl {
});
if (addTemplateVars) {
_.each(templateSrv.variables, function(variable) {
_.each(templateSrv.variables, variable => {
segments.unshift(
uiSegmentSrv.newSegment({
type: 'template',