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:
parent
5c0fbbf7c8
commit
19b7ad61dd
@ -28,7 +28,7 @@ export class GrafanaCtrl {
|
||||
setBackendSrv(backendSrv);
|
||||
createStore({ backendSrv, datasourceSrv });
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.init = () => {
|
||||
$scope.contextSrv = contextSrv;
|
||||
$scope.appSubUrl = config.appSubUrl;
|
||||
$scope._ = _;
|
||||
@ -43,7 +43,7 @@ export class GrafanaCtrl {
|
||||
|
||||
$rootScope.colors = colors;
|
||||
|
||||
$scope.initDashboard = function(dashboardData, viewScope) {
|
||||
$scope.initDashboard = (dashboardData, viewScope) => {
|
||||
$scope.appEvent('dashboard-fetch-end', dashboardData);
|
||||
$controller('DashboardCtrl', { $scope: viewScope }).init(dashboardData);
|
||||
};
|
||||
@ -60,7 +60,7 @@ export class GrafanaCtrl {
|
||||
callerScope.$on('$destroy', unbind);
|
||||
};
|
||||
|
||||
$rootScope.appEvent = function(name, payload) {
|
||||
$rootScope.appEvent = (name, payload) => {
|
||||
$rootScope.$emit(name, payload);
|
||||
appEvents.emit(name, payload);
|
||||
};
|
||||
@ -103,7 +103,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
const body = $('body');
|
||||
|
||||
// see https://github.com/zenorocha/clipboard.js/issues/155
|
||||
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
|
||||
$.fn.modal.Constructor.prototype.enforceFocus = () => {};
|
||||
|
||||
$('.preloader').remove();
|
||||
|
||||
@ -123,9 +123,12 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
body.toggleClass('sidemenu-hidden');
|
||||
});
|
||||
|
||||
scope.$watch(() => playlistSrv.isPlaying, function(newValue) {
|
||||
elem.toggleClass('view-mode--playlist', newValue === true);
|
||||
});
|
||||
scope.$watch(
|
||||
() => playlistSrv.isPlaying,
|
||||
newValue => {
|
||||
elem.toggleClass('view-mode--playlist', newValue === true);
|
||||
}
|
||||
);
|
||||
|
||||
// check if we are in server side render
|
||||
if (document.cookie.indexOf('renderKey') !== -1) {
|
||||
@ -135,7 +138,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
// tooltip removal fix
|
||||
// manage page classes
|
||||
let pageClass;
|
||||
scope.$on('$routeChangeSuccess', function(evt, data) {
|
||||
scope.$on('$routeChangeSuccess', (evt, data) => {
|
||||
if (pageClass) {
|
||||
body.removeClass(pageClass);
|
||||
}
|
||||
@ -236,7 +239,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
});
|
||||
|
||||
// handle document clicks that should hide things
|
||||
body.click(function(evt) {
|
||||
body.click(evt => {
|
||||
const target = $(evt.target);
|
||||
if (target.parents().length === 0) {
|
||||
return;
|
||||
@ -248,7 +251,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
if (clickAutoHide.length) {
|
||||
const clickAutoHideParent = clickAutoHide.parent();
|
||||
clickAutoHide.detach();
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
clickAutoHideParent.append(clickAutoHide);
|
||||
}, 100);
|
||||
}
|
||||
@ -260,7 +263,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
// hide search
|
||||
if (body.find('.search-container').length > 0) {
|
||||
if (target.parents('.search-results-container, .search-field-wrapper').length === 0) {
|
||||
scope.$apply(function() {
|
||||
scope.$apply(() => {
|
||||
scope.appEvent('hide-dash-search');
|
||||
});
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ export function infoPopover() {
|
||||
restrict: 'E',
|
||||
template: '<i class="fa fa-info-circle"></i>',
|
||||
transclude: true,
|
||||
link: function(scope, elem, attrs, ctrl, transclude) {
|
||||
link: (scope, elem, attrs, ctrl, transclude) => {
|
||||
const offset = attrs.offset || '0 -10px';
|
||||
const position = attrs.position || 'right middle';
|
||||
let classes = 'drop-help drop-hide-out-of-bounds';
|
||||
@ -23,7 +23,7 @@ export function infoPopover() {
|
||||
elem.addClass('gf-form-help-icon--' + attrs.mode);
|
||||
}
|
||||
|
||||
transclude(function(clone, newScope) {
|
||||
transclude((clone, newScope) => {
|
||||
const content = document.createElement('div');
|
||||
content.className = 'markdown-html';
|
||||
|
||||
@ -54,7 +54,7 @@ export function infoPopover() {
|
||||
scope.$applyAsync(() => {
|
||||
const drop = new Drop(dropOptions);
|
||||
|
||||
const unbind = scope.$on('$destroy', function() {
|
||||
const unbind = scope.$on('$destroy', () => {
|
||||
drop.destroy();
|
||||
unbind();
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ export function layoutMode($rootScope) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {},
|
||||
link: function(scope, elem) {
|
||||
link: (scope, elem) => {
|
||||
const layout = store.get('grafana.list.layout.mode') || 'grid';
|
||||
let className = 'card-list-layout-' + layout;
|
||||
elem.addClass(className);
|
||||
|
@ -30,7 +30,7 @@ export function navbarDirective() {
|
||||
scope: {
|
||||
model: '=',
|
||||
},
|
||||
link: function(scope, elem) {},
|
||||
link: (scope, elem) => {},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -89,20 +89,20 @@ export function queryPartEditorDirective($compile, templateSrv) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typeaheadSource = function(query, callback) {
|
||||
const typeaheadSource = (query, callback) => {
|
||||
if (param.options) {
|
||||
let options = param.options;
|
||||
if (param.type === 'int') {
|
||||
options = _.map(options, function(val) {
|
||||
options = _.map(options, val => {
|
||||
return val.toString();
|
||||
});
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
$scope.$apply(function() {
|
||||
$scope.handleEvent({ $event: { name: 'get-param-options' } }).then(function(result) {
|
||||
const dynamicOptions = _.map(result, function(op) {
|
||||
$scope.$apply(() => {
|
||||
$scope.handleEvent({ $event: { name: 'get-param-options' } }).then(result => {
|
||||
const dynamicOptions = _.map(result, op => {
|
||||
return op.value;
|
||||
});
|
||||
callback(dynamicOptions);
|
||||
@ -116,8 +116,8 @@ export function queryPartEditorDirective($compile, templateSrv) {
|
||||
source: typeaheadSource,
|
||||
minLength: 0,
|
||||
items: 1000,
|
||||
updater: function(value) {
|
||||
setTimeout(function() {
|
||||
updater: value => {
|
||||
setTimeout(() => {
|
||||
inputBlur.call($input[0], paramIndex);
|
||||
}, 0);
|
||||
return value;
|
||||
@ -136,18 +136,18 @@ export function queryPartEditorDirective($compile, templateSrv) {
|
||||
}
|
||||
}
|
||||
|
||||
$scope.showActionsMenu = function() {
|
||||
$scope.showActionsMenu = () => {
|
||||
$scope.handleEvent({ $event: { name: 'get-part-actions' } }).then(res => {
|
||||
$scope.partActions = res;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.triggerPartAction = function(action) {
|
||||
$scope.triggerPartAction = action => {
|
||||
$scope.handleEvent({ $event: { name: 'action', action: action } });
|
||||
};
|
||||
|
||||
function addElementsAndCompile() {
|
||||
_.each(partDef.params, function(param, index) {
|
||||
_.each(partDef.params, (param, index) => {
|
||||
if (param.optional && part.params.length <= index) {
|
||||
return;
|
||||
}
|
||||
|
@ -71,14 +71,14 @@ export function sideMenuDirective() {
|
||||
bindToController: true,
|
||||
controllerAs: 'ctrl',
|
||||
scope: {},
|
||||
link: function(scope, elem) {
|
||||
link: (scope, elem) => {
|
||||
// hack to hide dropdown menu
|
||||
elem.on('click.dropdown', '.dropdown-menu a', function(evt) {
|
||||
elem.on('click.dropdown', '.dropdown-menu a', evt => {
|
||||
const menu = $(evt.target).parents('.dropdown-menu');
|
||||
const parent = menu.parent();
|
||||
menu.detach();
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
parent.append(menu);
|
||||
}, 100);
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ export class InspectCtrl {
|
||||
}
|
||||
|
||||
if (model.error.config && model.error.config.params) {
|
||||
$scope.request_parameters = _.map(model.error.config.params, function(value, key) {
|
||||
$scope.request_parameters = _.map(model.error.config.params, (value, key) => {
|
||||
return { key: key, value: value };
|
||||
});
|
||||
}
|
||||
@ -45,7 +45,7 @@ export class InspectCtrl {
|
||||
if (_.isString(model.error.config.data)) {
|
||||
$scope.request_parameters = this.getParametersFromQueryString(model.error.config.data);
|
||||
} else {
|
||||
$scope.request_parameters = _.map(model.error.config.data, function(value, key) {
|
||||
$scope.request_parameters = _.map(model.error.config.data, (value, key) => {
|
||||
return { key: key, value: angular.toJson(value, true) };
|
||||
});
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ export class JsonEditorCtrl {
|
||||
$scope.canUpdate = $scope.updateHandler !== void 0 && $scope.contextSrv.isEditor;
|
||||
$scope.canCopy = $scope.enableCopy;
|
||||
|
||||
$scope.update = function() {
|
||||
$scope.update = () => {
|
||||
const newObject = angular.fromJson($scope.json);
|
||||
$scope.updateHandler(newObject, $scope.object);
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ export function arrayJoin() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: 'ngModel',
|
||||
link: function(scope, element, attr, ngModel) {
|
||||
link: (scope, element, attr, ngModel) => {
|
||||
function split_array(text) {
|
||||
return (text || '').split(',');
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export function annotationTooltipDirective($sanitize, dashboardSrv, contextSrv,
|
||||
event: '=',
|
||||
onEdit: '&',
|
||||
},
|
||||
link: function(scope, element) {
|
||||
link: (scope, element) => {
|
||||
const event = scope.event;
|
||||
let title = event.title;
|
||||
let text = event.text;
|
||||
|
@ -26,14 +26,14 @@ export class LinkSrv {
|
||||
addParamsToUrl(url, params) {
|
||||
const paramsArray = [];
|
||||
|
||||
_.each(params, function(value, key) {
|
||||
_.each(params, (value, key) => {
|
||||
if (value === null) {
|
||||
return;
|
||||
}
|
||||
if (value === true) {
|
||||
paramsArray.push(key);
|
||||
} else if (_.isArray(value)) {
|
||||
_.each(value, function(instance) {
|
||||
_.each(value, instance => {
|
||||
paramsArray.push(key + '=' + encodeURIComponent(instance));
|
||||
});
|
||||
} else {
|
||||
|
@ -77,7 +77,7 @@ export class DatasourceSrv {
|
||||
|
||||
this.addDataSourceVariables(sources);
|
||||
|
||||
_.each(config.datasources, function(value) {
|
||||
_.each(config.datasources, value => {
|
||||
if (value.meta && value.meta.annotations) {
|
||||
sources.push(value);
|
||||
}
|
||||
@ -97,7 +97,7 @@ export class DatasourceSrv {
|
||||
getMetricSources(options) {
|
||||
const metricSources = [];
|
||||
|
||||
_.each(config.datasources, function(value, key) {
|
||||
_.each(config.datasources, (value, key) => {
|
||||
if (value.meta && value.meta.metrics) {
|
||||
let metricSource = { value: key, name: key, meta: value.meta, sort: key };
|
||||
|
||||
@ -121,7 +121,7 @@ export class DatasourceSrv {
|
||||
this.addDataSourceVariables(metricSources);
|
||||
}
|
||||
|
||||
metricSources.sort(function(a, b) {
|
||||
metricSources.sort((a, b) => {
|
||||
if (a.sort.toLowerCase() > b.sort.toLowerCase()) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ System.config({
|
||||
});
|
||||
|
||||
function exposeToPlugin(name: string, component: any) {
|
||||
System.registerDynamic(name, [], true, function(require, exports, module) {
|
||||
System.registerDynamic(name, [], true, (require, exports, module) => {
|
||||
module.exports = component;
|
||||
});
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -23,36 +23,36 @@ export class ElasticBucketAggCtrl {
|
||||
|
||||
$scope.orderByOptions = [];
|
||||
|
||||
$scope.getBucketAggTypes = function() {
|
||||
$scope.getBucketAggTypes = () => {
|
||||
return queryDef.bucketAggTypes;
|
||||
};
|
||||
|
||||
$scope.getOrderOptions = function() {
|
||||
$scope.getOrderOptions = () => {
|
||||
return queryDef.orderOptions;
|
||||
};
|
||||
|
||||
$scope.getSizeOptions = function() {
|
||||
$scope.getSizeOptions = () => {
|
||||
return queryDef.sizeOptions;
|
||||
};
|
||||
|
||||
$rootScope.onAppEvent(
|
||||
'elastic-query-updated',
|
||||
function() {
|
||||
() => {
|
||||
$scope.validateModel();
|
||||
},
|
||||
$scope
|
||||
);
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.init = () => {
|
||||
$scope.agg = bucketAggs[$scope.index];
|
||||
$scope.validateModel();
|
||||
};
|
||||
|
||||
$scope.onChangeInternal = function() {
|
||||
$scope.onChangeInternal = () => {
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.onTypeChanged = function() {
|
||||
$scope.onTypeChanged = () => {
|
||||
$scope.agg.settings = {};
|
||||
$scope.showOptions = false;
|
||||
|
||||
@ -79,7 +79,7 @@ export class ElasticBucketAggCtrl {
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.validateModel = function() {
|
||||
$scope.validateModel = () => {
|
||||
$scope.index = _.indexOf(bucketAggs, $scope.agg);
|
||||
$scope.isFirst = $scope.index === 0;
|
||||
$scope.bucketAggCount = bucketAggs.length;
|
||||
@ -114,7 +114,7 @@ export class ElasticBucketAggCtrl {
|
||||
settings.filters = settings.filters || [{ query: '*' }];
|
||||
settingsLinkText = _.reduce(
|
||||
settings.filters,
|
||||
function(memo, value, index) {
|
||||
(memo, value, index) => {
|
||||
memo += 'Q' + (index + 1) + ' = ' + value.query + ' ';
|
||||
return memo;
|
||||
},
|
||||
@ -168,23 +168,23 @@ export class ElasticBucketAggCtrl {
|
||||
return true;
|
||||
};
|
||||
|
||||
$scope.addFiltersQuery = function() {
|
||||
$scope.addFiltersQuery = () => {
|
||||
$scope.agg.settings.filters.push({ query: '*' });
|
||||
};
|
||||
|
||||
$scope.removeFiltersQuery = function(filter) {
|
||||
$scope.removeFiltersQuery = filter => {
|
||||
$scope.agg.settings.filters = _.without($scope.agg.settings.filters, filter);
|
||||
};
|
||||
|
||||
$scope.toggleOptions = function() {
|
||||
$scope.toggleOptions = () => {
|
||||
$scope.showOptions = !$scope.showOptions;
|
||||
};
|
||||
|
||||
$scope.getOrderByOptions = function() {
|
||||
$scope.getOrderByOptions = () => {
|
||||
return queryDef.getOrderByOptions($scope.target);
|
||||
};
|
||||
|
||||
$scope.getFieldsInternal = function() {
|
||||
$scope.getFieldsInternal = () => {
|
||||
if ($scope.agg.type === 'date_histogram') {
|
||||
return $scope.getFields({ $fieldType: 'date' });
|
||||
} else {
|
||||
@ -192,11 +192,11 @@ export class ElasticBucketAggCtrl {
|
||||
}
|
||||
};
|
||||
|
||||
$scope.getIntervalOptions = function() {
|
||||
$scope.getIntervalOptions = () => {
|
||||
return $q.when(uiSegmentSrv.transformToSegments(true, 'interval')(queryDef.intervalOptions));
|
||||
};
|
||||
|
||||
$scope.addBucketAgg = function() {
|
||||
$scope.addBucketAgg = () => {
|
||||
// if last is date histogram add it before
|
||||
const lastBucket = bucketAggs[bucketAggs.length - 1];
|
||||
let addIndex = bucketAggs.length - 1;
|
||||
@ -207,7 +207,7 @@ export class ElasticBucketAggCtrl {
|
||||
|
||||
const id = _.reduce(
|
||||
$scope.target.bucketAggs.concat($scope.target.metrics),
|
||||
function(max, val) {
|
||||
(max, val) => {
|
||||
return parseInt(val.id) > max ? parseInt(val.id) : max;
|
||||
},
|
||||
0
|
||||
@ -217,7 +217,7 @@ export class ElasticBucketAggCtrl {
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.removeBucketAgg = function() {
|
||||
$scope.removeBucketAgg = () => {
|
||||
bucketAggs.splice($scope.index, 1);
|
||||
$scope.onChange();
|
||||
};
|
||||
|
@ -59,12 +59,12 @@ export class ElasticDatasource {
|
||||
const range = this.timeSrv.timeRange();
|
||||
const indexList = this.indexPattern.getIndexList(range.from.valueOf(), range.to.valueOf());
|
||||
if (_.isArray(indexList) && indexList.length) {
|
||||
return this.request('GET', indexList[0] + url).then(function(results) {
|
||||
return this.request('GET', indexList[0] + url).then(results => {
|
||||
results.data.$$config = results.config;
|
||||
return results.data;
|
||||
});
|
||||
} else {
|
||||
return this.request('GET', this.indexPattern.getIndexForToday() + url).then(function(results) {
|
||||
return this.request('GET', this.indexPattern.getIndexForToday() + url).then(results => {
|
||||
results.data.$$config = results.config;
|
||||
return results.data;
|
||||
});
|
||||
@ -73,7 +73,7 @@ export class ElasticDatasource {
|
||||
|
||||
private post(url, data) {
|
||||
return this.request('POST', url, data)
|
||||
.then(function(results) {
|
||||
.then(results => {
|
||||
results.data.$$config = results.config;
|
||||
return results.data;
|
||||
})
|
||||
@ -145,7 +145,7 @@ export class ElasticDatasource {
|
||||
const list = [];
|
||||
const hits = res.responses[0].hits.hits;
|
||||
|
||||
const getFieldFromSource = function(source, fieldName) {
|
||||
const getFieldFromSource = (source, fieldName) => {
|
||||
if (!fieldName) {
|
||||
return;
|
||||
}
|
||||
@ -213,7 +213,7 @@ export class ElasticDatasource {
|
||||
}
|
||||
return { status: 'success', message: 'Index OK. Time field name OK.' };
|
||||
},
|
||||
function(err) {
|
||||
err => {
|
||||
console.log(err);
|
||||
if (err.data && err.data.error) {
|
||||
let message = angular.toJson(err.data.error);
|
||||
@ -274,13 +274,13 @@ export class ElasticDatasource {
|
||||
payload = payload.replace(/\$timeTo/g, options.range.to.valueOf());
|
||||
payload = this.templateSrv.replace(payload, options.scopedVars);
|
||||
|
||||
return this.post('_msearch', payload).then(function(res) {
|
||||
return this.post('_msearch', payload).then(res => {
|
||||
return new ElasticResponse(sentTargets, res).getTimeSeries();
|
||||
});
|
||||
}
|
||||
|
||||
getFields(query) {
|
||||
return this.get('/_mapping').then(function(result) {
|
||||
return this.get('/_mapping').then(result => {
|
||||
const typeMap = {
|
||||
float: 'number',
|
||||
double: 'number',
|
||||
@ -352,7 +352,7 @@ export class ElasticDatasource {
|
||||
}
|
||||
|
||||
// transform to array
|
||||
return _.map(fields, function(value) {
|
||||
return _.map(fields, value => {
|
||||
return value;
|
||||
});
|
||||
});
|
||||
@ -368,13 +368,13 @@ export class ElasticDatasource {
|
||||
esQuery = esQuery.replace(/\$timeTo/g, range.to.valueOf());
|
||||
esQuery = header + '\n' + esQuery + '\n';
|
||||
|
||||
return this.post('_msearch?search_type=' + searchType, esQuery).then(function(res) {
|
||||
return this.post('_msearch?search_type=' + searchType, esQuery).then(res => {
|
||||
if (!res.responses[0].aggregations) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const buckets = res.responses[0].aggregations['1'].buckets;
|
||||
return _.map(buckets, function(bucket) {
|
||||
return _.map(buckets, bucket => {
|
||||
return {
|
||||
text: bucket.key_as_string || bucket.key,
|
||||
value: bucket.key,
|
||||
|
@ -227,7 +227,7 @@ export class ElasticResponse {
|
||||
if (target.alias) {
|
||||
const regex = /\{\{([\s\S]+?)\}\}/g;
|
||||
|
||||
return target.alias.replace(regex, function(match, g1, g2) {
|
||||
return target.alias.replace(regex, (match, g1, g2) => {
|
||||
const group = g1 || g2;
|
||||
|
||||
if (group.indexOf('term ') === 0) {
|
||||
|
@ -25,19 +25,19 @@ export class ElasticMetricAggCtrl {
|
||||
$scope.pipelineAggOptions = [];
|
||||
$scope.modelSettingsValues = {};
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.init = () => {
|
||||
$scope.agg = metricAggs[$scope.index];
|
||||
$scope.validateModel();
|
||||
$scope.updatePipelineAggOptions();
|
||||
};
|
||||
|
||||
$scope.updatePipelineAggOptions = function() {
|
||||
$scope.updatePipelineAggOptions = () => {
|
||||
$scope.pipelineAggOptions = queryDef.getPipelineAggOptions($scope.target);
|
||||
};
|
||||
|
||||
$rootScope.onAppEvent(
|
||||
'elastic-query-updated',
|
||||
function() {
|
||||
() => {
|
||||
$scope.index = _.indexOf(metricAggs, $scope.agg);
|
||||
$scope.updatePipelineAggOptions();
|
||||
$scope.validateModel();
|
||||
@ -45,7 +45,7 @@ export class ElasticMetricAggCtrl {
|
||||
$scope
|
||||
);
|
||||
|
||||
$scope.validateModel = function() {
|
||||
$scope.validateModel = () => {
|
||||
$scope.isFirst = $scope.index === 0;
|
||||
$scope.isSingle = metricAggs.length === 1;
|
||||
$scope.settingsLinkText = '';
|
||||
@ -57,7 +57,7 @@ export class ElasticMetricAggCtrl {
|
||||
|
||||
const pipelineOptions = queryDef.getPipelineOptions($scope.agg);
|
||||
if (pipelineOptions.length > 0) {
|
||||
_.each(pipelineOptions, function(opt) {
|
||||
_.each(pipelineOptions, opt => {
|
||||
$scope.agg.settings[opt.text] = $scope.agg.settings[opt.text] || opt.default;
|
||||
});
|
||||
$scope.settingsLinkText = 'Options';
|
||||
@ -84,7 +84,7 @@ export class ElasticMetricAggCtrl {
|
||||
|
||||
const stats = _.reduce(
|
||||
$scope.agg.meta,
|
||||
function(memo, val, key) {
|
||||
(memo, val, key) => {
|
||||
if (val) {
|
||||
const def = _.find($scope.extendedStats, { value: key });
|
||||
memo.push(def.text);
|
||||
@ -128,16 +128,16 @@ export class ElasticMetricAggCtrl {
|
||||
}
|
||||
};
|
||||
|
||||
$scope.toggleOptions = function() {
|
||||
$scope.toggleOptions = () => {
|
||||
$scope.showOptions = !$scope.showOptions;
|
||||
$scope.updatePipelineAggOptions();
|
||||
};
|
||||
|
||||
$scope.onChangeInternal = function() {
|
||||
$scope.onChangeInternal = () => {
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.updateMovingAvgModelSettings = function() {
|
||||
$scope.updateMovingAvgModelSettings = () => {
|
||||
const modelSettingsKeys = [];
|
||||
const modelSettings = queryDef.getMovingAvgSettings($scope.agg.settings.model, false);
|
||||
for (let i = 0; i < modelSettings.length; i++) {
|
||||
@ -151,12 +151,12 @@ export class ElasticMetricAggCtrl {
|
||||
}
|
||||
};
|
||||
|
||||
$scope.onChangeClearInternal = function() {
|
||||
$scope.onChangeClearInternal = () => {
|
||||
delete $scope.agg.settings.minimize;
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.onTypeChange = function() {
|
||||
$scope.onTypeChange = () => {
|
||||
$scope.agg.settings = {};
|
||||
$scope.agg.meta = {};
|
||||
$scope.showOptions = false;
|
||||
@ -164,19 +164,19 @@ export class ElasticMetricAggCtrl {
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.getFieldsInternal = function() {
|
||||
$scope.getFieldsInternal = () => {
|
||||
if ($scope.agg.type === 'cardinality') {
|
||||
return $scope.getFields();
|
||||
}
|
||||
return $scope.getFields({ $fieldType: 'number' });
|
||||
};
|
||||
|
||||
$scope.addMetricAgg = function() {
|
||||
$scope.addMetricAgg = () => {
|
||||
const addIndex = metricAggs.length;
|
||||
|
||||
const id = _.reduce(
|
||||
$scope.target.bucketAggs.concat($scope.target.metrics),
|
||||
function(max, val) {
|
||||
(max, val) => {
|
||||
return parseInt(val.id) > max ? parseInt(val.id) : max;
|
||||
},
|
||||
0
|
||||
@ -186,12 +186,12 @@ export class ElasticMetricAggCtrl {
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.removeMetricAgg = function() {
|
||||
$scope.removeMetricAgg = () => {
|
||||
metricAggs.splice($scope.index, 1);
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.toggleShowMetric = function() {
|
||||
$scope.toggleShowMetric = () => {
|
||||
$scope.agg.hide = !$scope.agg.hide;
|
||||
if (!$scope.agg.hide) {
|
||||
delete $scope.agg.hide;
|
||||
|
@ -145,7 +145,7 @@ export const movingAvgModelSettings = {
|
||||
};
|
||||
|
||||
export function getMetricAggTypes(esVersion) {
|
||||
return _.filter(metricAggTypes, function(f) {
|
||||
return _.filter(metricAggTypes, f => {
|
||||
if (f.minVersion) {
|
||||
return f.minVersion <= esVersion;
|
||||
} else {
|
||||
@ -173,7 +173,7 @@ export function isPipelineAgg(metricType) {
|
||||
|
||||
export function getPipelineAggOptions(targets) {
|
||||
const result = [];
|
||||
_.each(targets.metrics, function(metric) {
|
||||
_.each(targets.metrics, metric => {
|
||||
if (!isPipelineAgg(metric.type)) {
|
||||
result.push({ text: describeMetric(metric), value: metric.id });
|
||||
}
|
||||
@ -185,7 +185,7 @@ export function getPipelineAggOptions(targets) {
|
||||
export function getMovingAvgSettings(model, filtered) {
|
||||
const filteredResult = [];
|
||||
if (filtered) {
|
||||
_.each(movingAvgModelSettings[model], function(setting) {
|
||||
_.each(movingAvgModelSettings[model], setting => {
|
||||
if (!setting.isCheckbox) {
|
||||
filteredResult.push(setting);
|
||||
}
|
||||
@ -197,7 +197,7 @@ export function getMovingAvgSettings(model, filtered) {
|
||||
|
||||
export function getOrderByOptions(target) {
|
||||
const metricRefs = [];
|
||||
_.each(target.metrics, function(metric) {
|
||||
_.each(target.metrics, metric => {
|
||||
if (metric.type !== 'count') {
|
||||
metricRefs.push({ text: describeMetric(metric), value: metric.id });
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ export default class GraphiteQuery {
|
||||
|
||||
return _.reduce(
|
||||
arr,
|
||||
function(result, segment) {
|
||||
(result, segment) => {
|
||||
return result ? result + '.' + segment.value : segment.value;
|
||||
},
|
||||
''
|
||||
@ -133,7 +133,7 @@ export default class GraphiteQuery {
|
||||
}
|
||||
|
||||
moveAliasFuncLast() {
|
||||
const aliasFunc = _.find(this.functions, function(func) {
|
||||
const aliasFunc = _.find(this.functions, func => {
|
||||
return func.def.name.startsWith('alias');
|
||||
});
|
||||
|
||||
|
@ -1370,7 +1370,7 @@ Lexer.prototype = {
|
||||
};
|
||||
},
|
||||
|
||||
isPunctuator: function(ch1) {
|
||||
isPunctuator: ch1 => {
|
||||
switch (ch1) {
|
||||
case '.':
|
||||
case '(':
|
||||
|
@ -23,7 +23,7 @@ export default class InfluxDatasource {
|
||||
/** @ngInject */
|
||||
constructor(instanceSettings, private $q, private backendSrv, private templateSrv) {
|
||||
this.type = 'influxdb';
|
||||
this.urls = _.map(instanceSettings.url.split(','), function(url) {
|
||||
this.urls = _.map(instanceSettings.url.split(','), url => {
|
||||
return url.trim();
|
||||
});
|
||||
|
||||
@ -274,7 +274,7 @@ export default class InfluxDatasource {
|
||||
result => {
|
||||
return result.data;
|
||||
},
|
||||
function(err) {
|
||||
err => {
|
||||
if (err.status !== 0 || err.status >= 300) {
|
||||
if (err.data && err.data.error) {
|
||||
throw {
|
||||
|
@ -27,15 +27,15 @@ export default class InfluxQuery {
|
||||
}
|
||||
|
||||
updateProjection() {
|
||||
this.selectModels = _.map(this.target.select, function(parts: any) {
|
||||
this.selectModels = _.map(this.target.select, (parts: any) => {
|
||||
return _.map(parts, queryPart.create);
|
||||
});
|
||||
this.groupByParts = _.map(this.target.groupBy, queryPart.create);
|
||||
}
|
||||
|
||||
updatePersistedParts() {
|
||||
this.target.select = _.map(this.selectModels, function(selectParts) {
|
||||
return _.map(selectParts, function(part: any) {
|
||||
this.target.select = _.map(this.selectModels, selectParts => {
|
||||
return _.map(selectParts, (part: any) => {
|
||||
return { type: part.def.type, params: part.params };
|
||||
});
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ export default class InfluxSeries {
|
||||
|
||||
_.each(this.series, series => {
|
||||
const columns = series.columns.length;
|
||||
const tags = _.map(series.tags, function(value, key) {
|
||||
const tags = _.map(series.tags, (value, key) => {
|
||||
return key + ': ' + value;
|
||||
});
|
||||
|
||||
@ -57,7 +57,7 @@ export default class InfluxSeries {
|
||||
const regex = /\$(\w+)|\[\[([\s\S]+?)\]\]/g;
|
||||
const segments = series.name.split('.');
|
||||
|
||||
return this.alias.replace(regex, function(match, g1, g2) {
|
||||
return this.alias.replace(regex, (match, g1, g2) => {
|
||||
const group = g1 || g2;
|
||||
const segIndex = parseInt(group, 10);
|
||||
|
||||
@ -124,10 +124,10 @@ export default class InfluxSeries {
|
||||
// Remove empty values, then split in different tags for comma separated values
|
||||
tags: _.flatten(
|
||||
tagsCol
|
||||
.filter(function(t) {
|
||||
.filter(t => {
|
||||
return value[t];
|
||||
})
|
||||
.map(function(t) {
|
||||
.map(t => {
|
||||
return value[t].split(',');
|
||||
})
|
||||
),
|
||||
@ -158,7 +158,7 @@ export default class InfluxSeries {
|
||||
table.columns.push({ text: 'Time', type: 'time' });
|
||||
j++;
|
||||
}
|
||||
_.each(_.keys(series.tags), function(key) {
|
||||
_.each(_.keys(series.tags), key => {
|
||||
table.columns.push({ text: key });
|
||||
});
|
||||
for (; j < series.columns.length; j++) {
|
||||
|
@ -84,7 +84,7 @@ export class InfluxQueryBuilder {
|
||||
if (this.target.tags && this.target.tags.length > 0) {
|
||||
const whereConditions = _.reduce(
|
||||
this.target.tags,
|
||||
function(memo, tag) {
|
||||
(memo, tag) => {
|
||||
// do not add a condition for the key we want to explore for
|
||||
if (tag.key === withKey) {
|
||||
return memo;
|
||||
|
@ -70,7 +70,7 @@ export class InfluxQueryCtrl extends QueryCtrl {
|
||||
const categories = queryPart.getCategories();
|
||||
this.selectMenu = _.reduce(
|
||||
categories,
|
||||
function(memo, cat, key) {
|
||||
(memo, cat, key) => {
|
||||
const menu = {
|
||||
text: key,
|
||||
submenu: cat.map(item => {
|
||||
|
@ -126,7 +126,7 @@ function addAliasStrategy(selectParts, partModel) {
|
||||
|
||||
function addFieldStrategy(selectParts, partModel, query) {
|
||||
// copy all parts
|
||||
const parts = _.map(selectParts, function(part: any) {
|
||||
const parts = _.map(selectParts, (part: any) => {
|
||||
return createPart({ type: part.def.type, params: _.clone(part.params) });
|
||||
});
|
||||
|
||||
@ -453,7 +453,7 @@ register({
|
||||
|
||||
export default {
|
||||
create: createPart,
|
||||
getCategories: function() {
|
||||
getCategories: () => {
|
||||
return categories;
|
||||
},
|
||||
replaceAggregationAdd: replaceAggregationAddStrategy,
|
||||
|
@ -13,14 +13,14 @@ class MixedDatasource {
|
||||
return this.$q([]);
|
||||
}
|
||||
|
||||
return this.datasourceSrv.get(dsName).then(function(ds) {
|
||||
return this.datasourceSrv.get(dsName).then(ds => {
|
||||
const opt = angular.copy(options);
|
||||
opt.targets = targets;
|
||||
return ds.query(opt);
|
||||
});
|
||||
});
|
||||
|
||||
return this.$q.all(promises).then(function(results) {
|
||||
return this.$q.all(promises).then(results => {
|
||||
return { data: _.flatten(_.map(results, 'data')) };
|
||||
});
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export class MssqlDatasource {
|
||||
return value;
|
||||
}
|
||||
|
||||
const quotedValues = _.map(value, function(val) {
|
||||
const quotedValues = _.map(value, val => {
|
||||
if (typeof value === 'number') {
|
||||
return value;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export class MysqlDatasource {
|
||||
return value;
|
||||
}
|
||||
|
||||
const quotedValues = _.map(value, function(val) {
|
||||
const quotedValues = _.map(value, val => {
|
||||
if (typeof value === 'number') {
|
||||
return value;
|
||||
}
|
||||
|
@ -56,19 +56,19 @@ export default class OpenTsDatasource {
|
||||
}
|
||||
|
||||
const groupByTags = {};
|
||||
_.each(queries, function(query) {
|
||||
_.each(queries, query => {
|
||||
if (query.filters && query.filters.length > 0) {
|
||||
_.each(query.filters, function(val) {
|
||||
_.each(query.filters, val => {
|
||||
groupByTags[val.tagk] = true;
|
||||
});
|
||||
} else {
|
||||
_.each(query.tags, function(val, key) {
|
||||
_.each(query.tags, (val, key) => {
|
||||
groupByTags[key] = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
options.targets = _.filter(options.targets, function(query) {
|
||||
options.targets = _.filter(options.targets, query => {
|
||||
return query.hide !== true;
|
||||
});
|
||||
|
||||
@ -97,28 +97,26 @@ export default class OpenTsDatasource {
|
||||
|
||||
const queries = _.compact(qs);
|
||||
|
||||
return this.performTimeSeriesQuery(queries, start, end).then(
|
||||
function(results) {
|
||||
if (results.data[0]) {
|
||||
let annotationObject = results.data[0].annotations;
|
||||
if (options.annotation.isGlobal) {
|
||||
annotationObject = results.data[0].globalAnnotations;
|
||||
}
|
||||
if (annotationObject) {
|
||||
_.each(annotationObject, function(annotation) {
|
||||
const event = {
|
||||
text: annotation.description,
|
||||
time: Math.floor(annotation.startTime) * 1000,
|
||||
annotation: options.annotation,
|
||||
};
|
||||
|
||||
eventList.push(event);
|
||||
});
|
||||
}
|
||||
return this.performTimeSeriesQuery(queries, start, end).then(results => {
|
||||
if (results.data[0]) {
|
||||
let annotationObject = results.data[0].annotations;
|
||||
if (options.annotation.isGlobal) {
|
||||
annotationObject = results.data[0].globalAnnotations;
|
||||
}
|
||||
return eventList;
|
||||
}.bind(this)
|
||||
);
|
||||
if (annotationObject) {
|
||||
_.each(annotationObject, annotation => {
|
||||
const event = {
|
||||
text: annotation.description,
|
||||
time: Math.floor(annotation.startTime) * 1000,
|
||||
annotation: options.annotation,
|
||||
};
|
||||
|
||||
eventList.push(event);
|
||||
});
|
||||
}
|
||||
}
|
||||
return eventList;
|
||||
});
|
||||
}
|
||||
|
||||
targetContainsTemplate(target) {
|
||||
@ -177,7 +175,7 @@ export default class OpenTsDatasource {
|
||||
|
||||
_saveTagKeys(metricData) {
|
||||
const tagKeys = Object.keys(metricData.tags);
|
||||
_.each(metricData.aggregateTags, function(tag) {
|
||||
_.each(metricData.aggregateTags, tag => {
|
||||
tagKeys.push(tag);
|
||||
});
|
||||
|
||||
@ -185,7 +183,7 @@ export default class OpenTsDatasource {
|
||||
}
|
||||
|
||||
_performSuggestQuery(query, type) {
|
||||
return this._get('/api/suggest', { type: type, q: query, max: 1000 }).then(function(result) {
|
||||
return this._get('/api/suggest', { type: type, q: query, max: 1000 }).then(result => {
|
||||
return result.data;
|
||||
});
|
||||
}
|
||||
@ -195,7 +193,7 @@ export default class OpenTsDatasource {
|
||||
return this.$q.when([]);
|
||||
}
|
||||
|
||||
const keysArray = keys.split(',').map(function(key) {
|
||||
const keysArray = keys.split(',').map(key => {
|
||||
return key.trim();
|
||||
});
|
||||
const key = keysArray[0];
|
||||
@ -207,10 +205,10 @@ export default class OpenTsDatasource {
|
||||
|
||||
const m = metric + '{' + keysQuery + '}';
|
||||
|
||||
return this._get('/api/search/lookup', { m: m, limit: 3000 }).then(function(result) {
|
||||
return this._get('/api/search/lookup', { m: m, limit: 3000 }).then(result => {
|
||||
result = result.data.results;
|
||||
const tagvs = [];
|
||||
_.each(result, function(r) {
|
||||
_.each(result, r => {
|
||||
if (tagvs.indexOf(r.tags[key]) === -1) {
|
||||
tagvs.push(r.tags[key]);
|
||||
}
|
||||
@ -224,11 +222,11 @@ export default class OpenTsDatasource {
|
||||
return this.$q.when([]);
|
||||
}
|
||||
|
||||
return this._get('/api/search/lookup', { m: metric, limit: 1000 }).then(function(result) {
|
||||
return this._get('/api/search/lookup', { m: metric, limit: 1000 }).then(result => {
|
||||
result = result.data.results;
|
||||
const tagks = [];
|
||||
_.each(result, function(r) {
|
||||
_.each(r.tags, function(tagv, tagk) {
|
||||
_.each(result, r => {
|
||||
_.each(r.tags, (tagv, tagk) => {
|
||||
if (tagks.indexOf(tagk) === -1) {
|
||||
tagks.push(tagk);
|
||||
}
|
||||
@ -271,8 +269,8 @@ export default class OpenTsDatasource {
|
||||
return this.$q.reject(err);
|
||||
}
|
||||
|
||||
const responseTransform = function(result) {
|
||||
return _.map(result, function(value) {
|
||||
const responseTransform = result => {
|
||||
return _.map(result, value => {
|
||||
return { text: value };
|
||||
});
|
||||
};
|
||||
@ -312,7 +310,7 @@ export default class OpenTsDatasource {
|
||||
}
|
||||
|
||||
testDatasource() {
|
||||
return this._performSuggestQuery('cpu', 'metrics').then(function() {
|
||||
return this._performSuggestQuery('cpu', 'metrics').then(() => {
|
||||
return { status: 'success', message: 'Data source is working' };
|
||||
});
|
||||
}
|
||||
@ -322,7 +320,7 @@ export default class OpenTsDatasource {
|
||||
return this.aggregatorsPromise;
|
||||
}
|
||||
|
||||
this.aggregatorsPromise = this._get('/api/aggregators').then(function(result) {
|
||||
this.aggregatorsPromise = this._get('/api/aggregators').then(result => {
|
||||
if (result.data && _.isArray(result.data)) {
|
||||
return result.data.sort();
|
||||
}
|
||||
@ -336,7 +334,7 @@ export default class OpenTsDatasource {
|
||||
return this.filterTypesPromise;
|
||||
}
|
||||
|
||||
this.filterTypesPromise = this._get('/api/config/filters').then(function(result) {
|
||||
this.filterTypesPromise = this._get('/api/config/filters').then(result => {
|
||||
if (result.data) {
|
||||
return Object.keys(result.data).sort();
|
||||
}
|
||||
@ -351,7 +349,7 @@ export default class OpenTsDatasource {
|
||||
|
||||
// TSDB returns datapoints has a hash of ts => value.
|
||||
// Can't use _.pairs(invert()) because it stringifies keys/values
|
||||
_.each(md.dps, function(v, k) {
|
||||
_.each(md.dps, (v, k) => {
|
||||
if (tsdbResolution === 2) {
|
||||
dps.push([v, k * 1]);
|
||||
} else {
|
||||
@ -365,7 +363,7 @@ export default class OpenTsDatasource {
|
||||
createMetricLabel(md, target, groupByTags, options) {
|
||||
if (target.alias) {
|
||||
const scopedVars = _.clone(options.scopedVars || {});
|
||||
_.each(md.tags, function(value, key) {
|
||||
_.each(md.tags, (value, key) => {
|
||||
scopedVars['tag_' + key] = { value: value };
|
||||
});
|
||||
return this.templateSrv.replace(target.alias, scopedVars);
|
||||
@ -375,7 +373,7 @@ export default class OpenTsDatasource {
|
||||
const tagData = [];
|
||||
|
||||
if (!_.isEmpty(md.tags)) {
|
||||
_.each(_.toPairs(md.tags), function(tag) {
|
||||
_.each(_.toPairs(md.tags), tag => {
|
||||
if (_.has(groupByTags, tag[0])) {
|
||||
tagData.push(tag[0] + '=' + tag[1]);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ export class OpenTsQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
|
||||
getTextValues(metricFindResult) {
|
||||
return _.map(metricFindResult, function(value) {
|
||||
return _.map(metricFindResult, value => {
|
||||
return value.text;
|
||||
});
|
||||
}
|
||||
|
@ -526,13 +526,13 @@ export class PrometheusDatasource {
|
||||
const query = this.createQuery({ expr, interval: step }, queryOptions, start, end);
|
||||
|
||||
const self = this;
|
||||
return this.performTimeSeriesQuery(query, query.start, query.end).then(function(results) {
|
||||
return this.performTimeSeriesQuery(query, query.start, query.end).then(results => {
|
||||
const eventList = [];
|
||||
tagKeys = tagKeys.split(',');
|
||||
|
||||
_.each(results.data.data.result, function(series) {
|
||||
_.each(results.data.data.result, series => {
|
||||
const tags = _.chain(series.metric)
|
||||
.filter(function(v, k) {
|
||||
.filter((v, k) => {
|
||||
return _.includes(tagKeys, k);
|
||||
})
|
||||
.value();
|
||||
|
@ -46,8 +46,8 @@ export default class PrometheusMetricFindQuery {
|
||||
// return label values globally
|
||||
url = '/api/v1/label/' + label + '/values';
|
||||
|
||||
return this.datasource.metadataRequest(url).then(function(result) {
|
||||
return _.map(result.data.data, function(value) {
|
||||
return this.datasource.metadataRequest(url).then(result => {
|
||||
return _.map(result.data.data, value => {
|
||||
return { text: value };
|
||||
});
|
||||
});
|
||||
@ -56,14 +56,14 @@ export default class PrometheusMetricFindQuery {
|
||||
const end = this.datasource.getPrometheusTime(this.range.to, true);
|
||||
url = '/api/v1/series?match[]=' + encodeURIComponent(metric) + '&start=' + start + '&end=' + end;
|
||||
|
||||
return this.datasource.metadataRequest(url).then(function(result) {
|
||||
const _labels = _.map(result.data.data, function(metric) {
|
||||
return this.datasource.metadataRequest(url).then(result => {
|
||||
const _labels = _.map(result.data.data, metric => {
|
||||
return metric[label] || '';
|
||||
}).filter(function(label) {
|
||||
}).filter(label => {
|
||||
return label !== '';
|
||||
});
|
||||
|
||||
return _.uniq(_labels).map(function(metric) {
|
||||
return _.uniq(_labels).map(metric => {
|
||||
return {
|
||||
text: metric,
|
||||
expandable: true,
|
||||
@ -76,13 +76,13 @@ export default class PrometheusMetricFindQuery {
|
||||
metricNameQuery(metricFilterPattern) {
|
||||
const url = '/api/v1/label/__name__/values';
|
||||
|
||||
return this.datasource.metadataRequest(url).then(function(result) {
|
||||
return this.datasource.metadataRequest(url).then(result => {
|
||||
return _.chain(result.data.data)
|
||||
.filter(function(metricName) {
|
||||
.filter(metricName => {
|
||||
const r = new RegExp(metricFilterPattern);
|
||||
return r.test(metricName);
|
||||
})
|
||||
.map(function(matchedMetricName) {
|
||||
.map(matchedMetricName => {
|
||||
return {
|
||||
text: matchedMetricName,
|
||||
expandable: true,
|
||||
@ -94,13 +94,13 @@ export default class PrometheusMetricFindQuery {
|
||||
|
||||
queryResultQuery(query) {
|
||||
const end = this.datasource.getPrometheusTime(this.range.to, true);
|
||||
return this.datasource.performInstantQuery({ expr: query }, end).then(function(result) {
|
||||
return _.map(result.data.data.result, function(metricData) {
|
||||
return this.datasource.performInstantQuery({ expr: query }, end).then(result => {
|
||||
return _.map(result.data.data.result, metricData => {
|
||||
let text = metricData.metric.__name__ || '';
|
||||
delete metricData.metric.__name__;
|
||||
text +=
|
||||
'{' +
|
||||
_.map(metricData.metric, function(v, k) {
|
||||
_.map(metricData.metric, (v, k) => {
|
||||
return k + '="' + v + '"';
|
||||
}).join(',') +
|
||||
'}';
|
||||
@ -120,7 +120,7 @@ export default class PrometheusMetricFindQuery {
|
||||
const url = '/api/v1/series?match[]=' + encodeURIComponent(query) + '&start=' + start + '&end=' + end;
|
||||
|
||||
const self = this;
|
||||
return this.datasource.metadataRequest(url).then(function(result) {
|
||||
return this.datasource.metadataRequest(url).then(result => {
|
||||
return _.map(result.data.data, metric => {
|
||||
return {
|
||||
text: self.datasource.getOriginalMetricName(metric),
|
||||
|
@ -27,7 +27,7 @@ class PrometheusQueryCtrl extends QueryCtrl {
|
||||
target.format = target.format || this.getDefaultFormat();
|
||||
|
||||
this.metric = '';
|
||||
this.resolutions = _.map([1, 2, 3, 4, 5, 10], function(f) {
|
||||
this.resolutions = _.map([1, 2, 3, 4, 5, 10], f => {
|
||||
return { factor: f, label: '1/' + f };
|
||||
});
|
||||
|
||||
|
@ -81,7 +81,7 @@ export class ResultTransformer {
|
||||
}
|
||||
|
||||
// Collect all labels across all metrics
|
||||
_.each(md, function(series) {
|
||||
_.each(md, series => {
|
||||
for (const label in series.metric) {
|
||||
if (!metricLabels.hasOwnProperty(label)) {
|
||||
metricLabels[label] = 1;
|
||||
@ -92,7 +92,7 @@ export class ResultTransformer {
|
||||
// Sort metric labels, create columns for them and record their index
|
||||
const sortedLabels = _.keys(metricLabels).sort();
|
||||
table.columns.push({ text: 'Time', type: 'time' });
|
||||
_.each(sortedLabels, function(label, labelIndex) {
|
||||
_.each(sortedLabels, (label, labelIndex) => {
|
||||
metricLabels[label] = labelIndex + 1;
|
||||
table.columns.push({ text: label, filterable: !label.startsWith('__') });
|
||||
});
|
||||
@ -100,7 +100,7 @@ export class ResultTransformer {
|
||||
table.columns.push({ text: valueText });
|
||||
|
||||
// Populate rows, set value to empty string when label not present.
|
||||
_.each(md, function(series) {
|
||||
_.each(md, series => {
|
||||
if (series.value) {
|
||||
series.values = [series.value];
|
||||
}
|
||||
@ -150,7 +150,7 @@ export class ResultTransformer {
|
||||
|
||||
renderTemplate(aliasPattern, aliasData) {
|
||||
const aliasRegex = /\{\{\s*(.+?)\s*\}\}/g;
|
||||
return aliasPattern.replace(aliasRegex, function(match, g1) {
|
||||
return aliasPattern.replace(aliasRegex, (match, g1) => {
|
||||
if (aliasData[g1]) {
|
||||
return aliasData[g1];
|
||||
}
|
||||
@ -161,7 +161,7 @@ export class ResultTransformer {
|
||||
getOriginalMetricName(labelData) {
|
||||
const metricName = labelData.__name__ || '';
|
||||
delete labelData.__name__;
|
||||
const labelPart = _.map(_.toPairs(labelData), function(label) {
|
||||
const labelPart = _.map(_.toPairs(labelData), label => {
|
||||
return label[0] + '="' + label[1] + '"';
|
||||
}).join(',');
|
||||
return metricName + '{' + labelPart + '}';
|
||||
|
@ -464,7 +464,7 @@ class GraphElement {
|
||||
}
|
||||
|
||||
addXSeriesAxis(options) {
|
||||
const ticks = _.map(this.data, function(series, index) {
|
||||
const ticks = _.map(this.data, (series, index) => {
|
||||
return [index + 1, series.alias];
|
||||
});
|
||||
|
||||
@ -533,8 +533,8 @@ class GraphElement {
|
||||
}
|
||||
|
||||
addXTableAxis(options) {
|
||||
let ticks = _.map(this.data, function(series, seriesIndex) {
|
||||
return _.map(series.datapoints, function(point, pointIndex) {
|
||||
let ticks = _.map(this.data, (series, seriesIndex) => {
|
||||
return _.map(series.datapoints, (point, pointIndex) => {
|
||||
const tickIndex = seriesIndex * series.datapoints.length + pointIndex;
|
||||
return [tickIndex + 1, point[1]];
|
||||
});
|
||||
@ -627,10 +627,10 @@ class GraphElement {
|
||||
}
|
||||
}
|
||||
|
||||
axis.transform = function(v) {
|
||||
axis.transform = v => {
|
||||
return v < Number.MIN_VALUE ? null : Math.log(v) / Math.log(axis.logBase);
|
||||
};
|
||||
axis.inverseTransform = function(v) {
|
||||
axis.inverseTransform = v => {
|
||||
return Math.pow(axis.logBase, v);
|
||||
};
|
||||
|
||||
@ -701,7 +701,7 @@ class GraphElement {
|
||||
}
|
||||
|
||||
configureAxisMode(axis, format) {
|
||||
axis.tickFormatter = function(val, axis) {
|
||||
axis.tickFormatter = (val, axis) => {
|
||||
if (!kbn.valueFormats[format]) {
|
||||
throw new Error(`Unit '${format}' is not supported`);
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ export default function GraphTooltip(this: any, elem, dashboard, scope, getSerie
|
||||
|
||||
const $tooltip = $('<div class="graph-tooltip">');
|
||||
|
||||
this.destroy = function() {
|
||||
this.destroy = () => {
|
||||
$tooltip.remove();
|
||||
};
|
||||
|
||||
this.findHoverIndexFromDataPoints = function(posX, series, last) {
|
||||
this.findHoverIndexFromDataPoints = (posX, series, last) => {
|
||||
const ps = series.datapoints.pointsize;
|
||||
const initial = last * ps;
|
||||
const len = series.datapoints.points.length;
|
||||
@ -30,7 +30,7 @@ export default function GraphTooltip(this: any, elem, dashboard, scope, getSerie
|
||||
return j / ps - 1;
|
||||
};
|
||||
|
||||
this.findHoverIndexFromData = function(posX, series) {
|
||||
this.findHoverIndexFromData = (posX, series) => {
|
||||
let lower = 0;
|
||||
let upper = series.data.length - 1;
|
||||
let middle;
|
||||
@ -49,7 +49,7 @@ export default function GraphTooltip(this: any, elem, dashboard, scope, getSerie
|
||||
}
|
||||
};
|
||||
|
||||
this.renderAndShow = function(absoluteTime, innerHtml, pos, xMode) {
|
||||
this.renderAndShow = (absoluteTime, innerHtml, pos, xMode) => {
|
||||
if (xMode === 'time') {
|
||||
innerHtml = '<div class="graph-tooltip-time">' + absoluteTime + '</div>' + innerHtml;
|
||||
}
|
||||
@ -147,7 +147,7 @@ export default function GraphTooltip(this: any, elem, dashboard, scope, getSerie
|
||||
return results;
|
||||
};
|
||||
|
||||
elem.mouseleave(function() {
|
||||
elem.mouseleave(() => {
|
||||
if (panel.tooltip.shared) {
|
||||
const plot = elem.data().plot;
|
||||
if (plot) {
|
||||
@ -158,7 +158,7 @@ export default function GraphTooltip(this: any, elem, dashboard, scope, getSerie
|
||||
appEvents.emit('graph-hover-clear');
|
||||
});
|
||||
|
||||
elem.bind('plothover', function(event, pos, item) {
|
||||
elem.bind('plothover', (event, pos, item) => {
|
||||
self.show(pos, item);
|
||||
|
||||
// broadcast to other graph panels that we are hovering!
|
||||
@ -166,17 +166,17 @@ export default function GraphTooltip(this: any, elem, dashboard, scope, getSerie
|
||||
appEvents.emit('graph-hover', { pos: pos, panel: panel });
|
||||
});
|
||||
|
||||
elem.bind('plotclick', function(event, pos, item) {
|
||||
elem.bind('plotclick', (event, pos, item) => {
|
||||
appEvents.emit('graph-click', { pos: pos, panel: panel, item: item });
|
||||
});
|
||||
|
||||
this.clear = function(plot) {
|
||||
this.clear = plot => {
|
||||
$tooltip.detach();
|
||||
plot.clearCrosshair();
|
||||
plot.unhighlight();
|
||||
};
|
||||
|
||||
this.show = function(pos, item) {
|
||||
this.show = (pos, item) => {
|
||||
const plot = elem.data().plot;
|
||||
const plotData = plot.getData();
|
||||
const xAxes = plot.getXAxes();
|
||||
@ -232,11 +232,11 @@ export default function GraphTooltip(this: any, elem, dashboard, scope, getSerie
|
||||
// Dynamically reorder the hovercard for the current time point if the
|
||||
// option is enabled.
|
||||
if (panel.tooltip.sort === 2) {
|
||||
seriesHoverInfo.sort(function(a, b) {
|
||||
seriesHoverInfo.sort((a, b) => {
|
||||
return b.value - a.value;
|
||||
});
|
||||
} else if (panel.tooltip.sort === 1) {
|
||||
seriesHoverInfo.sort(function(a, b) {
|
||||
seriesHoverInfo.sort((a, b) => {
|
||||
return a.value - b.value;
|
||||
});
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ export function createAnnotationToolip(element, event, plot) {
|
||||
injector.invoke([
|
||||
'$compile',
|
||||
'$rootScope',
|
||||
function($compile, $rootScope) {
|
||||
($compile, $rootScope) => {
|
||||
const eventManager = plot.getOptions().events.manager;
|
||||
const tmpScope = $rootScope.$new(true);
|
||||
tmpScope.event = event;
|
||||
tmpScope.onEdit = function() {
|
||||
tmpScope.onEdit = () => {
|
||||
eventManager.editEvent(event);
|
||||
};
|
||||
|
||||
@ -38,8 +38,8 @@ export function createAnnotationToolip(element, event, plot) {
|
||||
|
||||
drop.open();
|
||||
|
||||
drop.on('close', function() {
|
||||
setTimeout(function() {
|
||||
drop.on('close', () => {
|
||||
setTimeout(() => {
|
||||
drop.destroy();
|
||||
});
|
||||
});
|
||||
@ -65,7 +65,7 @@ export function createEditPopover(element, event, plot) {
|
||||
markerElementToAttachTo = element;
|
||||
|
||||
// wait for element to be attached and positioned
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
const injector = angular.element(document).injector();
|
||||
const content = document.createElement('div');
|
||||
content.innerHTML = '<event-editor panel-ctrl="panelCtrl" event="event" close="close()"></event-editor>';
|
||||
@ -73,13 +73,13 @@ export function createEditPopover(element, event, plot) {
|
||||
injector.invoke([
|
||||
'$compile',
|
||||
'$rootScope',
|
||||
function($compile, $rootScope) {
|
||||
($compile, $rootScope) => {
|
||||
const scope = $rootScope.$new(true);
|
||||
let drop;
|
||||
|
||||
scope.event = event;
|
||||
scope.panelCtrl = eventManager.panelCtrl;
|
||||
scope.close = function() {
|
||||
scope.close = () => {
|
||||
drop.close();
|
||||
};
|
||||
|
||||
@ -100,9 +100,9 @@ export function createEditPopover(element, event, plot) {
|
||||
drop.open();
|
||||
eventManager.editorOpened();
|
||||
|
||||
drop.on('close', function() {
|
||||
drop.on('close', () => {
|
||||
// need timeout here in order call drop.destroy
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
eventManager.editorClosed();
|
||||
scope.$destroy();
|
||||
drop.destroy();
|
||||
@ -428,7 +428,7 @@ export class EventMarkers {
|
||||
createEditPopover(marker, event.editModel, that._plot);
|
||||
}
|
||||
|
||||
const mouseleave = function() {
|
||||
const mouseleave = () => {
|
||||
that._plot.clearSelection();
|
||||
};
|
||||
|
||||
@ -443,10 +443,10 @@ export class EventMarkers {
|
||||
function drawFunc(obj) {
|
||||
obj.show();
|
||||
},
|
||||
function(obj) {
|
||||
obj => {
|
||||
obj.remove();
|
||||
},
|
||||
function(obj, position) {
|
||||
(obj, position) => {
|
||||
obj.css({
|
||||
top: position.top,
|
||||
left: position.left,
|
||||
@ -549,7 +549,7 @@ export class EventMarkers {
|
||||
createEditPopover(region, event.editModel, that._plot);
|
||||
}
|
||||
|
||||
const mouseleave = function() {
|
||||
const mouseleave = () => {
|
||||
that._plot.clearSelection();
|
||||
};
|
||||
|
||||
@ -563,10 +563,10 @@ export class EventMarkers {
|
||||
function drawFunc(obj) {
|
||||
obj.show();
|
||||
},
|
||||
function(obj) {
|
||||
obj => {
|
||||
obj.remove();
|
||||
},
|
||||
function(obj, position) {
|
||||
(obj, position) => {
|
||||
obj.css({
|
||||
top: position.top,
|
||||
left: position.left,
|
||||
@ -601,11 +601,11 @@ export function init(this: any, plot) {
|
||||
const that = this;
|
||||
const eventMarkers = new EventMarkers(plot);
|
||||
|
||||
plot.getEvents = function() {
|
||||
plot.getEvents = () => {
|
||||
return eventMarkers._events;
|
||||
};
|
||||
|
||||
plot.hideEvents = function() {
|
||||
plot.hideEvents = () => {
|
||||
$.each(eventMarkers._events, (index, event) => {
|
||||
event
|
||||
.visual()
|
||||
@ -614,7 +614,7 @@ export function init(this: any, plot) {
|
||||
});
|
||||
};
|
||||
|
||||
plot.showEvents = function() {
|
||||
plot.showEvents = () => {
|
||||
plot.hideEvents();
|
||||
$.each(eventMarkers._events, (index, event) => {
|
||||
event.hide();
|
||||
@ -624,20 +624,20 @@ export function init(this: any, plot) {
|
||||
};
|
||||
|
||||
// change events on an existing plot
|
||||
plot.setEvents = function(events) {
|
||||
plot.setEvents = events => {
|
||||
if (eventMarkers.eventsEnabled) {
|
||||
eventMarkers.setupEvents(events);
|
||||
}
|
||||
};
|
||||
|
||||
plot.hooks.processOptions.push(function(plot, options) {
|
||||
plot.hooks.processOptions.push((plot, options) => {
|
||||
// enable the plugin
|
||||
if (options.events.data != null) {
|
||||
eventMarkers.eventsEnabled = true;
|
||||
}
|
||||
});
|
||||
|
||||
plot.hooks.draw.push(function(plot) {
|
||||
plot.hooks.draw.push(plot => {
|
||||
const options = plot.getOptions();
|
||||
|
||||
if (eventMarkers.eventsEnabled) {
|
||||
|
@ -5,9 +5,9 @@ import baron from 'baron';
|
||||
|
||||
const module = angular.module('grafana.directives');
|
||||
|
||||
module.directive('graphLegend', function(popoverSrv, $timeout) {
|
||||
module.directive('graphLegend', (popoverSrv, $timeout) => {
|
||||
return {
|
||||
link: function(scope, elem) {
|
||||
link: (scope, elem) => {
|
||||
let firstRender = true;
|
||||
const ctrl = scope.ctrl;
|
||||
const panel = ctrl.panel;
|
||||
@ -18,7 +18,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
|
||||
const legendRightDefaultWidth = 10;
|
||||
const legendElem = elem.parent();
|
||||
|
||||
scope.$on('$destroy', function() {
|
||||
scope.$on('$destroy', () => {
|
||||
destroyScrollbar();
|
||||
});
|
||||
|
||||
@ -44,7 +44,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
|
||||
const index = getSeriesIndexForElement(el);
|
||||
const series = seriesList[index];
|
||||
|
||||
$timeout(function() {
|
||||
$timeout(() => {
|
||||
popoverSrv.show({
|
||||
element: el[0],
|
||||
position: 'bottom left',
|
||||
@ -55,10 +55,10 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
|
||||
openOn: 'hover',
|
||||
model: {
|
||||
series: series,
|
||||
toggleAxis: function() {
|
||||
toggleAxis: () => {
|
||||
ctrl.toggleAxis(series);
|
||||
},
|
||||
colorSelected: function(color) {
|
||||
colorSelected: color => {
|
||||
ctrl.changeSeriesColor(series, color);
|
||||
},
|
||||
},
|
||||
@ -154,7 +154,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) {
|
||||
}
|
||||
|
||||
if (panel.legend.sort) {
|
||||
seriesList = _.sortBy(seriesList, function(series) {
|
||||
seriesList = _.sortBy(seriesList, series => {
|
||||
let sort = series.stats[panel.legend.sort];
|
||||
if (sort === null) {
|
||||
sort = -Infinity;
|
||||
|
@ -7,13 +7,13 @@ export function SeriesOverridesCtrl($scope, $element, popoverSrv) {
|
||||
$scope.currentOverrides = [];
|
||||
$scope.override = $scope.override || {};
|
||||
|
||||
$scope.addOverrideOption = function(name, propertyName, values) {
|
||||
$scope.addOverrideOption = (name, propertyName, values) => {
|
||||
const option = {
|
||||
text: name,
|
||||
propertyName: propertyName,
|
||||
index: $scope.overrideMenu.lenght,
|
||||
values: values,
|
||||
submenu: _.map(values, function(value) {
|
||||
submenu: _.map(values, value => {
|
||||
return { text: String(value), value: value };
|
||||
}),
|
||||
};
|
||||
@ -21,7 +21,7 @@ export function SeriesOverridesCtrl($scope, $element, popoverSrv) {
|
||||
$scope.overrideMenu.push(option);
|
||||
};
|
||||
|
||||
$scope.setOverride = function(item, subItem) {
|
||||
$scope.setOverride = (item, subItem) => {
|
||||
// handle color overrides
|
||||
if (item.propertyName === 'color') {
|
||||
$scope.openColorSelector($scope.override['color']);
|
||||
@ -41,13 +41,13 @@ export function SeriesOverridesCtrl($scope, $element, popoverSrv) {
|
||||
$scope.ctrl.render();
|
||||
};
|
||||
|
||||
$scope.colorSelected = function(color) {
|
||||
$scope.colorSelected = color => {
|
||||
$scope.override['color'] = color;
|
||||
$scope.updateCurrentOverrides();
|
||||
$scope.ctrl.render();
|
||||
};
|
||||
|
||||
$scope.openColorSelector = function(color) {
|
||||
$scope.openColorSelector = color => {
|
||||
const fakeSeries = { color: color };
|
||||
popoverSrv.show({
|
||||
element: $element.find('.dropdown')[0],
|
||||
@ -59,27 +59,27 @@ export function SeriesOverridesCtrl($scope, $element, popoverSrv) {
|
||||
colorSelected: $scope.colorSelected,
|
||||
series: fakeSeries,
|
||||
},
|
||||
onClose: function() {
|
||||
onClose: () => {
|
||||
$scope.ctrl.render();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
$scope.removeOverride = function(option) {
|
||||
$scope.removeOverride = option => {
|
||||
delete $scope.override[option.propertyName];
|
||||
$scope.updateCurrentOverrides();
|
||||
$scope.ctrl.refresh();
|
||||
};
|
||||
|
||||
$scope.getSeriesNames = function() {
|
||||
return _.map($scope.ctrl.seriesList, function(series) {
|
||||
$scope.getSeriesNames = () => {
|
||||
return _.map($scope.ctrl.seriesList, series => {
|
||||
return series.alias;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateCurrentOverrides = function() {
|
||||
$scope.updateCurrentOverrides = () => {
|
||||
$scope.currentOverrides = [];
|
||||
_.each($scope.overrideMenu, function(option) {
|
||||
_.each($scope.overrideMenu, option => {
|
||||
const value = $scope.override[option.propertyName];
|
||||
if (_.isUndefined(value)) {
|
||||
return;
|
||||
|
@ -61,7 +61,7 @@ export class ThresholdManager {
|
||||
handleElem.off('mouseleave', dragging);
|
||||
|
||||
// trigger digest and render
|
||||
panelCtrl.$scope.$apply(function() {
|
||||
panelCtrl.$scope.$apply(() => {
|
||||
panelCtrl.render();
|
||||
panelCtrl.events.emit('threshold-changed', {
|
||||
threshold: model,
|
||||
|
@ -138,7 +138,7 @@ const template = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
coreModule.directive('graphThresholdForm', function() {
|
||||
coreModule.directive('graphThresholdForm', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: template,
|
||||
|
@ -16,17 +16,17 @@ const LEGEND_VALUE_MARGIN = 0;
|
||||
/**
|
||||
* Color legend for heatmap editor.
|
||||
*/
|
||||
module.directive('colorLegend', function() {
|
||||
module.directive('colorLegend', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: '<div class="heatmap-color-legend"><svg width="16.5rem" height="24px"></svg></div>',
|
||||
link: function(scope, elem, attrs) {
|
||||
link: (scope, elem, attrs) => {
|
||||
const ctrl = scope.ctrl;
|
||||
const panel = scope.ctrl.panel;
|
||||
|
||||
render();
|
||||
|
||||
ctrl.events.on('render', function() {
|
||||
ctrl.events.on('render', () => {
|
||||
render();
|
||||
});
|
||||
|
||||
@ -52,16 +52,16 @@ module.directive('colorLegend', function() {
|
||||
/**
|
||||
* Heatmap legend with scale values.
|
||||
*/
|
||||
module.directive('heatmapLegend', function() {
|
||||
module.directive('heatmapLegend', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: `<div class="heatmap-color-legend"><svg width="${LEGEND_WIDTH_PX}px" height="${LEGEND_HEIGHT_PX}px"></svg></div>`,
|
||||
link: function(scope, elem, attrs) {
|
||||
link: (scope, elem, attrs) => {
|
||||
const ctrl = scope.ctrl;
|
||||
const panel = scope.ctrl.panel;
|
||||
|
||||
render();
|
||||
ctrl.events.on('render', function() {
|
||||
ctrl.events.on('render', () => {
|
||||
render();
|
||||
});
|
||||
|
||||
|
@ -267,7 +267,7 @@ export class HeatmapTooltip {
|
||||
|
||||
countValueFormatter(decimals, scaledDecimals = null) {
|
||||
const format = 'short';
|
||||
return function(value) {
|
||||
return value => {
|
||||
return kbn.valueFormats[format](value, decimals, scaledDecimals);
|
||||
};
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ export class HeatmapRenderer {
|
||||
|
||||
tickValueFormatter(decimals, scaledDecimals = null) {
|
||||
const format = this.panel.yAxis.format;
|
||||
return function(value) {
|
||||
return value => {
|
||||
try {
|
||||
return format !== 'none' ? kbn.valueFormats[format](value, decimals, scaledDecimals) : value;
|
||||
} catch (err) {
|
||||
|
@ -528,7 +528,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
||||
},
|
||||
value: {
|
||||
color: panel.colorValue ? getColorForValue(data, data.valueRounded) : null,
|
||||
formatter: function() {
|
||||
formatter: () => {
|
||||
return getValueText();
|
||||
},
|
||||
font: {
|
||||
@ -617,7 +617,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
||||
data = ctrl.data;
|
||||
|
||||
// get thresholds
|
||||
data.thresholds = panel.thresholds.split(',').map(function(strVale) {
|
||||
data.thresholds = panel.thresholds.split(',').map(strVale => {
|
||||
return Number(strVale.trim());
|
||||
});
|
||||
data.colorMap = panel.colors;
|
||||
@ -662,16 +662,16 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
||||
// drilldown link tooltip
|
||||
const drilldownTooltip = $('<div id="tooltip" class="">hello</div>"');
|
||||
|
||||
elem.mouseleave(function() {
|
||||
elem.mouseleave(() => {
|
||||
if (panel.links.length === 0) {
|
||||
return;
|
||||
}
|
||||
$timeout(function() {
|
||||
$timeout(() => {
|
||||
drilldownTooltip.detach();
|
||||
});
|
||||
});
|
||||
|
||||
elem.click(function(evt) {
|
||||
elem.click(evt => {
|
||||
if (!linkInfo) {
|
||||
return;
|
||||
}
|
||||
@ -688,7 +688,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
||||
if (linkInfo.href.indexOf('http') === 0) {
|
||||
window.location.href = linkInfo.href;
|
||||
} else {
|
||||
$timeout(function() {
|
||||
$timeout(() => {
|
||||
$location.url(linkInfo.href);
|
||||
});
|
||||
}
|
||||
@ -696,7 +696,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
||||
drilldownTooltip.detach();
|
||||
});
|
||||
|
||||
elem.mousemove(function(e) {
|
||||
elem.mousemove(e => {
|
||||
if (!linkInfo) {
|
||||
return;
|
||||
}
|
||||
@ -708,7 +708,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
||||
|
||||
hookupDrilldownLinkTooltip();
|
||||
|
||||
this.events.on('render', function() {
|
||||
this.events.on('render', () => {
|
||||
render();
|
||||
ctrl.renderingCompleted();
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ export class ColumnOptionsCtrl {
|
||||
if (!this.panelCtrl.table) {
|
||||
return [];
|
||||
}
|
||||
return _.map(this.panelCtrl.table.columns, function(col: any) {
|
||||
return _.map(this.panelCtrl.table.columns, (col: any) => {
|
||||
return col.text;
|
||||
});
|
||||
};
|
||||
|
@ -257,13 +257,13 @@ class TablePanelCtrl extends MetricsPanelCtrl {
|
||||
elem.on('click', '.table-panel-page-link', switchPage);
|
||||
elem.on('click', '.table-panel-filter-link', addFilterClicked);
|
||||
|
||||
const unbindDestroy = scope.$on('$destroy', function() {
|
||||
const unbindDestroy = scope.$on('$destroy', () => {
|
||||
elem.off('click', '.table-panel-page-link');
|
||||
elem.off('click', '.table-panel-filter-link');
|
||||
unbindDestroy();
|
||||
});
|
||||
|
||||
ctrl.events.on('render', function(renderData) {
|
||||
ctrl.events.on('render', renderData => {
|
||||
data = renderData || data;
|
||||
if (data) {
|
||||
renderPanel();
|
||||
|
@ -7,10 +7,10 @@ const transformers = {};
|
||||
|
||||
transformers['timeseries_to_rows'] = {
|
||||
description: 'Time series to rows',
|
||||
getColumns: function() {
|
||||
getColumns: () => {
|
||||
return [];
|
||||
},
|
||||
transform: function(data, panel, model) {
|
||||
transform: (data, panel, model) => {
|
||||
model.columns = [{ text: 'Time', type: 'date' }, { text: 'Metric' }, { text: 'Value' }];
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
@ -25,10 +25,10 @@ transformers['timeseries_to_rows'] = {
|
||||
|
||||
transformers['timeseries_to_columns'] = {
|
||||
description: 'Time series to columns',
|
||||
getColumns: function() {
|
||||
getColumns: () => {
|
||||
return [];
|
||||
},
|
||||
transform: function(data, panel, model) {
|
||||
transform: (data, panel, model) => {
|
||||
model.columns.push({ text: 'Time', type: 'date' });
|
||||
|
||||
// group by time
|
||||
@ -67,7 +67,7 @@ transformers['timeseries_to_columns'] = {
|
||||
|
||||
transformers['timeseries_aggregations'] = {
|
||||
description: 'Time series aggregations',
|
||||
getColumns: function() {
|
||||
getColumns: () => {
|
||||
return [
|
||||
{ text: 'Avg', value: 'avg' },
|
||||
{ text: 'Min', value: 'min' },
|
||||
@ -77,7 +77,7 @@ transformers['timeseries_aggregations'] = {
|
||||
{ text: 'Count', value: 'count' },
|
||||
];
|
||||
},
|
||||
transform: function(data, panel, model) {
|
||||
transform: (data, panel, model) => {
|
||||
let i, y;
|
||||
model.columns.push({ text: 'Metric' });
|
||||
|
||||
@ -105,10 +105,10 @@ transformers['timeseries_aggregations'] = {
|
||||
|
||||
transformers['annotations'] = {
|
||||
description: 'Annotations',
|
||||
getColumns: function() {
|
||||
getColumns: () => {
|
||||
return [];
|
||||
},
|
||||
transform: function(data, panel, model) {
|
||||
transform: (data, panel, model) => {
|
||||
model.columns.push({ text: 'Time', type: 'date' });
|
||||
model.columns.push({ text: 'Title' });
|
||||
model.columns.push({ text: 'Text' });
|
||||
@ -127,7 +127,7 @@ transformers['annotations'] = {
|
||||
|
||||
transformers['table'] = {
|
||||
description: 'Table',
|
||||
getColumns: function(data) {
|
||||
getColumns: data => {
|
||||
if (!data || data.length === 0) {
|
||||
return [];
|
||||
}
|
||||
@ -154,7 +154,7 @@ transformers['table'] = {
|
||||
|
||||
return columns;
|
||||
},
|
||||
transform: function(data, panel, model) {
|
||||
transform: (data, panel, model) => {
|
||||
if (!data || data.length === 0) {
|
||||
return;
|
||||
}
|
||||
@ -264,7 +264,7 @@ transformers['table'] = {
|
||||
|
||||
transformers['json'] = {
|
||||
description: 'JSON Data',
|
||||
getColumns: function(data) {
|
||||
getColumns: data => {
|
||||
if (!data || data.length === 0) {
|
||||
return [];
|
||||
}
|
||||
@ -287,11 +287,11 @@ transformers['json'] = {
|
||||
}
|
||||
}
|
||||
|
||||
return _.map(names, function(value, key) {
|
||||
return _.map(names, (value, key) => {
|
||||
return { text: key, value: key };
|
||||
});
|
||||
},
|
||||
transform: function(data, panel, model) {
|
||||
transform: (data, panel, model) => {
|
||||
let i, y, z;
|
||||
|
||||
for (const column of panel.columns) {
|
||||
|
Loading…
Reference in New Issue
Block a user