mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Adds typings to lodash (#16590)
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
"@types/inquirer": "^0.0.43",
|
||||
"@types/jest": "^24.0.11",
|
||||
"@types/jquery": "^1.10.35",
|
||||
"@types/lodash": "4.14.123",
|
||||
"@types/node": "^8.0.31",
|
||||
"@types/papaparse": "^4.5.9",
|
||||
"@types/react": "^16.8.8",
|
||||
|
||||
@@ -72,6 +72,7 @@ export enum NullValueMode {
|
||||
}
|
||||
|
||||
export interface AnnotationEvent {
|
||||
id?: string;
|
||||
annotation?: any;
|
||||
dashboardId?: number;
|
||||
panelId?: number;
|
||||
@@ -82,5 +83,5 @@ export interface AnnotationEvent {
|
||||
title?: string;
|
||||
text?: string;
|
||||
type?: string;
|
||||
tags?: string;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import { addClassIfNoOverlayScrollbar } from 'app/core/utils/scrollbar';
|
||||
import { importPluginModule } from 'app/features/plugins/plugin_loader';
|
||||
|
||||
// add move to lodash for backward compatabiltiy
|
||||
// @ts-ignore
|
||||
_.move = (array: [], fromIndex: number, toIndex: number) => {
|
||||
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);
|
||||
return array;
|
||||
|
||||
@@ -120,12 +120,12 @@ export class FormDropdownCtrl {
|
||||
|
||||
modelChanged() {
|
||||
if (_.isObject(this.model)) {
|
||||
this.updateDisplay(this.model.text);
|
||||
this.updateDisplay((this.model as any).text);
|
||||
} else {
|
||||
// if we have text use it
|
||||
if (this.lookupText) {
|
||||
this.getOptionsInternal('').then((options: any) => {
|
||||
const item = _.find(options, { value: this.model });
|
||||
const item: any = _.find(options, { value: this.model });
|
||||
this.updateDisplay(item ? item.text : this.model);
|
||||
});
|
||||
} else {
|
||||
@@ -193,7 +193,7 @@ export class FormDropdownCtrl {
|
||||
}
|
||||
|
||||
this.$scope.$apply(() => {
|
||||
const option = _.find(this.optionCache, { text: text });
|
||||
const option: any = _.find(this.optionCache, { text: text });
|
||||
|
||||
if (option) {
|
||||
if (_.isObject(this.model)) {
|
||||
@@ -204,7 +204,7 @@ export class FormDropdownCtrl {
|
||||
this.text = option.text;
|
||||
} else if (this.allowCustom) {
|
||||
if (_.isObject(this.model)) {
|
||||
this.model.text = this.model.value = text;
|
||||
(this.model as any).text = (this.model as any).value = text;
|
||||
} else {
|
||||
this.model = text;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import coreModule from 'app/core/core_module';
|
||||
import appEvents from 'app/core/app_events';
|
||||
@@ -149,7 +148,7 @@ export class ManageDashboardsCtrl {
|
||||
let selectedDashboards = 0;
|
||||
|
||||
for (const section of this.sections) {
|
||||
selectedDashboards += _.filter(section.items, { checked: true }).length;
|
||||
selectedDashboards += _.filter(section.items, { checked: true } as any).length;
|
||||
}
|
||||
|
||||
const selectedFolders = _.filter(this.sections, { checked: true }).length;
|
||||
@@ -167,7 +166,7 @@ export class ManageDashboardsCtrl {
|
||||
if (section.checked && section.id !== 0) {
|
||||
selectedDashboards.folderUids.push(section.uid);
|
||||
} else {
|
||||
const selected = _.filter(section.items, { checked: true });
|
||||
const selected = _.filter(section.items, { checked: true } as any);
|
||||
selectedDashboards.dashboardUids.push(..._.map(selected, 'uid'));
|
||||
}
|
||||
}
|
||||
@@ -223,7 +222,7 @@ export class ManageDashboardsCtrl {
|
||||
const selectedDashboards = [];
|
||||
|
||||
for (const section of this.sections) {
|
||||
const selected = _.filter(section.items, { checked: true });
|
||||
const selected = _.filter(section.items, { checked: true } as any);
|
||||
selectedDashboards.push(..._.map(selected, 'uid'));
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ export function queryPartEditorDirective($compile, templateSrv) {
|
||||
};
|
||||
|
||||
function addElementsAndCompile() {
|
||||
_.each(partDef.params, (param, index) => {
|
||||
_.each(partDef.params, (param: any, index: number) => {
|
||||
if (param.optional && part.params.length <= index) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import { contextSrv } from 'app/core/services/context_srv';
|
||||
import config from '../../config';
|
||||
|
||||
export default function BottomSection() {
|
||||
const navTree = _.cloneDeep(config.bootData.navTree);
|
||||
const bottomNav = _.filter(navTree, item => item.hideFromMenu);
|
||||
const navTree: any = _.cloneDeep(config.bootData.navTree);
|
||||
const bottomNav: any = _.filter(navTree, item => item.hideFromMenu);
|
||||
const isSignedIn = contextSrv.isSignedIn;
|
||||
const user = contextSrv.user;
|
||||
|
||||
if (user && user.orgCount > 1) {
|
||||
const profileNode = _.find(bottomNav, { id: 'profile' });
|
||||
const profileNode: any = _.find(bottomNav, { id: 'profile' });
|
||||
if (profileNode) {
|
||||
profileNode.showOrgSwitcher = true;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
||||
};
|
||||
|
||||
function addElementsAndCompile() {
|
||||
_.each(partDef.params, (param, index) => {
|
||||
_.each(partDef.params, (param: any, index: number) => {
|
||||
if (param.optional && part.params.length <= index) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export function arrayJoin() {
|
||||
|
||||
function join_array(text) {
|
||||
if (_.isArray(text)) {
|
||||
return (text || '').join(',');
|
||||
return ((text || '') as any).join(',');
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export function metricSegment($compile, $sce, templateSrv) {
|
||||
}
|
||||
|
||||
$scope.$apply(() => {
|
||||
const selected = _.find($scope.altSegments, { value: value });
|
||||
const selected: any = _.find($scope.altSegments, { value: value });
|
||||
if (selected) {
|
||||
segment.value = selected.value;
|
||||
segment.html = selected.html || $sce.trustAsHtml(templateSrv.highlightVariablesAsHtml(selected.value));
|
||||
@@ -202,7 +202,7 @@ export function metricSegmentModel(uiSegmentSrv, $q) {
|
||||
let cachedOptions;
|
||||
|
||||
$scope.valueToSegment = value => {
|
||||
const option = _.find($scope.options, { value: value });
|
||||
const option: any = _.find($scope.options, { value: value });
|
||||
const segment = {
|
||||
cssClass: attrs.cssClass,
|
||||
custom: attrs.custom,
|
||||
@@ -236,7 +236,7 @@ export function metricSegmentModel(uiSegmentSrv, $q) {
|
||||
|
||||
$scope.onSegmentChange = () => {
|
||||
if (cachedOptions) {
|
||||
const option = _.find(cachedOptions, { text: $scope.segment.value });
|
||||
const option: any = _.find(cachedOptions, { text: $scope.segment.value });
|
||||
if (option && option.value !== $scope.property) {
|
||||
$scope.property = option.value;
|
||||
} else if (attrs.custom !== 'false') {
|
||||
|
||||
@@ -48,7 +48,7 @@ export class NavModelSrv {
|
||||
break;
|
||||
}
|
||||
|
||||
const node = _.find(children, { id: id });
|
||||
const node: any = _.find(children, { id: id });
|
||||
nav.breadcrumbs.push(node);
|
||||
nav.node = node;
|
||||
nav.main = node;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
import coreModule from 'app/core/core_module';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
// @ts-ignore
|
||||
import { IQService } from 'angular';
|
||||
@@ -41,7 +40,7 @@ export class SearchSrv {
|
||||
});
|
||||
}
|
||||
|
||||
private queryForRecentDashboards(): Promise<number[]> {
|
||||
private queryForRecentDashboards(): Promise<DashboardSearchHit[]> {
|
||||
const dashIds: number[] = _.take(impressionSrv.getDashboardOpened(), 30);
|
||||
if (dashIds.length === 0) {
|
||||
return Promise.resolve([]);
|
||||
|
||||
@@ -5,7 +5,7 @@ import moment from 'moment';
|
||||
describe('rangeUtil', () => {
|
||||
describe('Can get range grouped list of ranges', () => {
|
||||
it('when custom settings should return default range list', () => {
|
||||
const groups = rangeUtil.getRelativeTimesList({ time_options: [] }, 'Last 5 minutes');
|
||||
const groups: any = rangeUtil.getRelativeTimesList({ time_options: [] }, 'Last 5 minutes');
|
||||
expect(_.keys(groups).length).toBe(4);
|
||||
expect(groups[3][0].active).toBe(true);
|
||||
});
|
||||
|
||||
@@ -2,4 +2,4 @@ import { memoize } from 'lodash';
|
||||
import { createSelectorCreator } from 'reselect';
|
||||
|
||||
const hashFn = (...args) => args.reduce((acc, val) => acc + '-' + JSON.stringify(val), '');
|
||||
export const createLodashMemoizedSelector = createSelectorCreator(memoize, hashFn);
|
||||
export const createLodashMemoizedSelector = createSelectorCreator(memoize as any, hashFn);
|
||||
|
||||
@@ -98,7 +98,7 @@ export default class AdminEditUserCtrl {
|
||||
return;
|
||||
}
|
||||
|
||||
const orgInfo = _.find($scope.orgsSearchCache, {
|
||||
const orgInfo: any = _.find($scope.orgsSearchCache, {
|
||||
name: $scope.newOrg.name,
|
||||
});
|
||||
if (!orgInfo) {
|
||||
|
||||
@@ -129,7 +129,7 @@ export class AlertTabCtrl {
|
||||
}
|
||||
|
||||
notificationAdded() {
|
||||
const model = _.find(this.notifications, {
|
||||
const model: any = _.find(this.notifications, {
|
||||
name: this.addNotificationSegment.value,
|
||||
});
|
||||
if (!model) {
|
||||
@@ -157,8 +157,8 @@ export class AlertTabCtrl {
|
||||
removeNotification(an) {
|
||||
// remove notifiers refeered to by id and uid to support notifiers added
|
||||
// before and after we added support for uid
|
||||
_.remove(this.alert.notifications, n => n.uid === an.uid || n.id === an.id);
|
||||
_.remove(this.alertNotifications, n => n.uid === an.uid || n.id === an.id);
|
||||
_.remove(this.alert.notifications, (n: any) => n.uid === an.uid || n.id === an.id);
|
||||
_.remove(this.alertNotifications, (n: any) => n.uid === an.uid || n.id === an.id);
|
||||
}
|
||||
|
||||
initModel() {
|
||||
@@ -195,7 +195,7 @@ export class AlertTabCtrl {
|
||||
|
||||
for (const addedNotification of alert.notifications) {
|
||||
// lookup notifier type by uid
|
||||
let model = _.find(this.notifications, { uid: addedNotification.uid });
|
||||
let model: any = _.find(this.notifications, { uid: addedNotification.uid });
|
||||
|
||||
// fallback to using id if uid is missing
|
||||
if (!model) {
|
||||
|
||||
@@ -38,7 +38,7 @@ export class AnnotationsSrv {
|
||||
.all([this.getGlobalAnnotations(options), this.getAlertStates(options)])
|
||||
.then(results => {
|
||||
// combine the annotations and flatten results
|
||||
let annotations = _.flattenDeep(results[0]);
|
||||
let annotations: any[] = _.flattenDeep(results[0]);
|
||||
|
||||
// filter out annotations that do not belong to requesting panel
|
||||
annotations = _.filter(annotations, item => {
|
||||
@@ -53,7 +53,7 @@ export class AnnotationsSrv {
|
||||
annotations = makeRegions(annotations, options);
|
||||
|
||||
// look for alert state for this panel
|
||||
const alertState = _.find(results[1], { panelId: options.panel.id });
|
||||
const alertState: any = _.find(results[1], { panelId: options.panel.id });
|
||||
|
||||
return {
|
||||
annotations: annotations,
|
||||
|
||||
@@ -74,6 +74,7 @@ export class AnnotationsEditorCtrl {
|
||||
}
|
||||
|
||||
move(index, dir) {
|
||||
// @ts-ignore
|
||||
_.move(this.annotations, index, index + dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ function getRegions(events, range) {
|
||||
const regionEvents = _.filter(events, event => {
|
||||
return event.regionId;
|
||||
});
|
||||
let regions = _.groupBy(regionEvents, 'regionId');
|
||||
let regions: any = _.groupBy(regionEvents, 'regionId');
|
||||
regions = _.compact(
|
||||
_.map(regions, regionEvents => {
|
||||
const regionObj = _.head(regionEvents);
|
||||
const regionObj: any = _.head(regionEvents);
|
||||
if (regionEvents && regionEvents.length > 1) {
|
||||
regionObj.timeEnd = regionEvents[1].time;
|
||||
regionObj.isRegion = true;
|
||||
|
||||
@@ -45,7 +45,7 @@ export class AddPanelWidget extends React.Component<Props, State> {
|
||||
const copiedPanelJson = store.get(LS_PANEL_COPY_KEY);
|
||||
if (copiedPanelJson) {
|
||||
const copiedPanel = JSON.parse(copiedPanelJson);
|
||||
const pluginInfo = _.find(panels, { id: copiedPanel.type });
|
||||
const pluginInfo: any = _.find(panels, { id: copiedPanel.type });
|
||||
if (pluginInfo) {
|
||||
const pluginCopy = _.cloneDeep(pluginInfo);
|
||||
pluginCopy.name = copiedPanel.title;
|
||||
|
||||
@@ -4,7 +4,6 @@ jest.mock('app/core/store', () => {
|
||||
};
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import config from 'app/core/config';
|
||||
import { DashboardExporter } from './DashboardExporter';
|
||||
@@ -148,7 +147,7 @@ describe('given dashboard with repeated panels', () => {
|
||||
});
|
||||
|
||||
it('should add datasource to required', () => {
|
||||
const require = _.find(exported.__requires, { name: 'TestDB' });
|
||||
const require: any = _.find(exported.__requires, { name: 'TestDB' });
|
||||
expect(require.name).toBe('TestDB');
|
||||
expect(require.id).toBe('testdb');
|
||||
expect(require.type).toBe('datasource');
|
||||
@@ -156,52 +155,52 @@ describe('given dashboard with repeated panels', () => {
|
||||
});
|
||||
|
||||
it('should not add built in datasources to required', () => {
|
||||
const require = _.find(exported.__requires, { name: 'Mixed' });
|
||||
const require: any = _.find(exported.__requires, { name: 'Mixed' });
|
||||
expect(require).toBe(undefined);
|
||||
});
|
||||
|
||||
it('should add datasources used in mixed mode', () => {
|
||||
const require = _.find(exported.__requires, { name: 'OtherDB' });
|
||||
const require: any = _.find(exported.__requires, { name: 'OtherDB' });
|
||||
expect(require).not.toBe(undefined);
|
||||
});
|
||||
|
||||
it('should add graph panel to required', () => {
|
||||
const require = _.find(exported.__requires, { name: 'Graph' });
|
||||
const require: any = _.find(exported.__requires, { name: 'Graph' });
|
||||
expect(require.name).toBe('Graph');
|
||||
expect(require.id).toBe('graph');
|
||||
expect(require.version).toBe('1.1.0');
|
||||
});
|
||||
|
||||
it('should add table panel to required', () => {
|
||||
const require = _.find(exported.__requires, { name: 'Table' });
|
||||
const require: any = _.find(exported.__requires, { name: 'Table' });
|
||||
expect(require.name).toBe('Table');
|
||||
expect(require.id).toBe('table');
|
||||
expect(require.version).toBe('1.1.1');
|
||||
});
|
||||
|
||||
it('should add heatmap panel to required', () => {
|
||||
const require = _.find(exported.__requires, { name: 'Heatmap' });
|
||||
const require: any = _.find(exported.__requires, { name: 'Heatmap' });
|
||||
expect(require.name).toBe('Heatmap');
|
||||
expect(require.id).toBe('heatmap');
|
||||
expect(require.version).toBe('1.1.2');
|
||||
});
|
||||
|
||||
it('should add grafana version', () => {
|
||||
const require = _.find(exported.__requires, { name: 'Grafana' });
|
||||
const require: any = _.find(exported.__requires, { name: 'Grafana' });
|
||||
expect(require.type).toBe('grafana');
|
||||
expect(require.id).toBe('grafana');
|
||||
expect(require.version).toBe('3.0.2');
|
||||
});
|
||||
|
||||
it('should add constant template variables as inputs', () => {
|
||||
const input = _.find(exported.__inputs, { name: 'VAR_PREFIX' });
|
||||
const input: any = _.find(exported.__inputs, { name: 'VAR_PREFIX' });
|
||||
expect(input.type).toBe('constant');
|
||||
expect(input.label).toBe('prefix');
|
||||
expect(input.value).toBe('collectd');
|
||||
});
|
||||
|
||||
it('should templatize constant variables', () => {
|
||||
const variable = _.find(exported.templating.list, { name: 'prefix' });
|
||||
const variable: any = _.find(exported.templating.list, { name: 'prefix' });
|
||||
expect(variable.query).toBe('${VAR_PREFIX}');
|
||||
expect(variable.current.text).toBe('${VAR_PREFIX}');
|
||||
expect(variable.current.value).toBe('${VAR_PREFIX}');
|
||||
@@ -210,7 +209,7 @@ describe('given dashboard with repeated panels', () => {
|
||||
});
|
||||
|
||||
it('should add datasources only use via datasource variable to requires', () => {
|
||||
const require = _.find(exported.__requires, { name: 'OtherDB_2' });
|
||||
const require: any = _.find(exported.__requires, { name: 'OtherDB_2' });
|
||||
expect(require.id).toBe('other2');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
|
||||
import config from 'app/core/config';
|
||||
|
||||
@@ -55,6 +55,7 @@ export class DashLinksEditorCtrl {
|
||||
}
|
||||
|
||||
moveLink(index, dir) {
|
||||
// @ts-ignore
|
||||
_.move(this.dashboard.links, index, index + dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ export class SettingsCtrl {
|
||||
this.viewId = 'make_editable';
|
||||
}
|
||||
|
||||
const currentSection = _.find(this.sections, { id: this.viewId });
|
||||
const currentSection: any = _.find(this.sections, { id: this.viewId } as any);
|
||||
if (!currentSection) {
|
||||
this.sections.unshift({
|
||||
title: 'Not found',
|
||||
@@ -174,7 +174,7 @@ export class SettingsCtrl {
|
||||
this.viewId = 'settings';
|
||||
this.buildSectionList();
|
||||
|
||||
const currentSection = _.find(this.sections, { id: this.viewId });
|
||||
const currentSection: any = _.find(this.sections, { id: this.viewId } as any);
|
||||
this.$location.url(currentSection.url);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ export class ShareSnapshotCtrl {
|
||||
.filter(annotation => {
|
||||
return annotation.enable;
|
||||
})
|
||||
.map(annotation => {
|
||||
.map((annotation: any) => {
|
||||
return {
|
||||
name: annotation.name,
|
||||
enable: annotation.enable,
|
||||
|
||||
@@ -122,6 +122,7 @@ export class QueriesTab extends PureComponent<Props, State> {
|
||||
const { panel } = this.props;
|
||||
|
||||
const index = _.indexOf(panel.targets, query);
|
||||
// @ts-ignore
|
||||
_.move(panel.targets, index, index + direction);
|
||||
|
||||
this.forceUpdate();
|
||||
|
||||
@@ -141,8 +141,8 @@ export class ChangeTracker {
|
||||
const current = this.cleanDashboardFromIgnoredChanges(this.current.getSaveModelClone());
|
||||
const original = this.cleanDashboardFromIgnoredChanges(this.original);
|
||||
|
||||
const currentTimepicker = _.find(current.nav, { type: 'timepicker' });
|
||||
const originalTimepicker = _.find(original.nav, { type: 'timepicker' });
|
||||
const currentTimepicker: any = _.find(current.nav, { type: 'timepicker' });
|
||||
const originalTimepicker: any = _.find(original.nav, { type: 'timepicker' });
|
||||
|
||||
if (currentTimepicker && originalTimepicker) {
|
||||
currentTimepicker.now = originalTimepicker.now;
|
||||
|
||||
@@ -109,7 +109,7 @@ export class DashboardMigrator {
|
||||
|
||||
if (oldVersion < 6) {
|
||||
// move pulldowns to new schema
|
||||
const annotations = _.find(old.pulldowns, { type: 'annotations' });
|
||||
const annotations: any = _.find(old.pulldowns, { type: 'annotations' });
|
||||
|
||||
if (annotations) {
|
||||
this.dashboard.annotations = {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import { DashboardModel } from '../state/DashboardModel';
|
||||
import { PanelModel } from '../state/PanelModel';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Libaries
|
||||
import moment, { MomentInput } from 'moment';
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
|
||||
// Constants
|
||||
@@ -179,7 +178,7 @@ export class DashboardModel {
|
||||
if (!defaults.saveVariables) {
|
||||
for (let i = 0; i < copy.templating.list.length; i++) {
|
||||
const current = copy.templating.list[i];
|
||||
const original = _.find(this.originalTemplating, { name: current.name, type: current.type });
|
||||
const original: any = _.find(this.originalTemplating, { name: current.name, type: current.type });
|
||||
|
||||
if (!original) {
|
||||
continue;
|
||||
@@ -449,7 +448,7 @@ export class DashboardModel {
|
||||
}
|
||||
|
||||
repeatPanel(panel: PanelModel, panelIndex: number) {
|
||||
const variable = _.find(this.templating.list, { name: panel.repeat });
|
||||
const variable: any = _.find(this.templating.list, { name: panel.repeat } as any);
|
||||
if (!variable) {
|
||||
return;
|
||||
}
|
||||
@@ -719,7 +718,7 @@ export class DashboardModel {
|
||||
|
||||
if (row.collapsed) {
|
||||
row.collapsed = false;
|
||||
const hasRepeat = _.some(row.panels, (p: PanelModel) => p.repeat);
|
||||
const hasRepeat = _.some(row.panels as PanelModel[], (p: PanelModel) => p.repeat);
|
||||
|
||||
if (row.panels.length > 0) {
|
||||
// Use first panel to figure out if it was moved or pushed
|
||||
|
||||
@@ -3,7 +3,6 @@ import React, { ComponentClass } from 'react';
|
||||
import { hot } from 'react-hot-loader';
|
||||
// @ts-ignore
|
||||
import { connect } from 'react-redux';
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import { AutoSizer } from 'react-virtualized';
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import React, { Context } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Libraries
|
||||
import React, { PureComponent } from 'react';
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import { hot } from 'react-hot-loader';
|
||||
// @ts-ignore
|
||||
|
||||
@@ -241,7 +241,7 @@ export default class TimePicker extends PureComponent<TimePickerProps, TimePicke
|
||||
const group = timeOptions[section];
|
||||
return (
|
||||
<ul key={section}>
|
||||
{group.map(option => (
|
||||
{group.map((option: any) => (
|
||||
<li className={option.active ? 'active' : ''} key={option.display}>
|
||||
<a onClick={() => this.handleClickRelativeOption(option)}>{option.display}</a>
|
||||
</li>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { createRef } from 'react';
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import { FixedSizeList } from 'react-window';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Libraries
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
|
||||
// Services & Utils
|
||||
@@ -196,11 +195,14 @@ export function loadExploreDatasourcesAndSetDatasource(
|
||||
return dispatch => {
|
||||
const exploreDatasources: DataSourceSelectItem[] = getDatasourceSrv()
|
||||
.getExternal()
|
||||
.map((ds: any) => ({
|
||||
value: ds.name,
|
||||
name: ds.name,
|
||||
meta: ds.meta,
|
||||
}));
|
||||
.map(
|
||||
(ds: any) =>
|
||||
({
|
||||
value: ds.name,
|
||||
name: ds.name,
|
||||
meta: ds.meta,
|
||||
} as DataSourceSelectItem)
|
||||
);
|
||||
|
||||
dispatch(loadExploreDatasources({ exploreId, exploreDatasources }));
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
calculateResultsFromQueryTransactions,
|
||||
|
||||
@@ -37,7 +37,7 @@ export class PanelLinksEditorCtrl {
|
||||
|
||||
$scope.dashboardChanged = link => {
|
||||
backendSrv.search({ query: link.dashboard }).then(hits => {
|
||||
const dashboard = _.find(hits, { title: link.dashboard });
|
||||
const dashboard: any = _.find(hits, { title: link.dashboard });
|
||||
if (dashboard) {
|
||||
if (dashboard.url) {
|
||||
link.url = dashboard.url;
|
||||
|
||||
@@ -53,7 +53,7 @@ export class PluginEditCtrl {
|
||||
url: `plugins/${this.model.id}/edit?tab=config`,
|
||||
});
|
||||
|
||||
const hasDashboards = _.find(model.includes, { type: 'dashboard' });
|
||||
const hasDashboards: any = _.find(model.includes, { type: 'dashboard' });
|
||||
|
||||
if (hasDashboards) {
|
||||
this.navModel.main.children.push({
|
||||
|
||||
@@ -34,7 +34,7 @@ export function buildNavModel(ds: DataSourceSettings, plugin: PluginMeta, curren
|
||||
],
|
||||
};
|
||||
|
||||
const hasDashboards = _.find(plugin.includes, { type: 'dashboard' }) !== undefined;
|
||||
const hasDashboards: any = _.find(plugin.includes, { type: 'dashboard' }) !== undefined;
|
||||
if (hasDashboards && ds.id) {
|
||||
main.children.push({
|
||||
active: currentPage === 'datasource-dashboards',
|
||||
|
||||
@@ -64,7 +64,7 @@ export class VariableEditorCtrl {
|
||||
return false;
|
||||
}
|
||||
|
||||
const sameName = _.find($scope.variables, { name: $scope.current.name });
|
||||
const sameName: any = _.find($scope.variables, { name: $scope.current.name });
|
||||
if (sameName && sameName !== $scope.current) {
|
||||
appEvents.emit('alert-warning', ['Validation', 'Variable with the same name already exists']);
|
||||
return false;
|
||||
@@ -151,7 +151,7 @@ export class VariableEditorCtrl {
|
||||
|
||||
$scope.datasourceTypes = _($scope.datasources)
|
||||
.uniqBy('meta.id')
|
||||
.map(ds => {
|
||||
.map((ds: any) => {
|
||||
return { text: ds.meta.name, value: ds.meta.id };
|
||||
})
|
||||
.value();
|
||||
|
||||
@@ -309,7 +309,7 @@ export class TemplateSrv {
|
||||
}
|
||||
|
||||
distributeVariable(value, variable) {
|
||||
value = _.map(value, (val, index) => {
|
||||
value = _.map(value, (val: any, index: number) => {
|
||||
if (index !== 0) {
|
||||
return variable + '=' + val;
|
||||
} else {
|
||||
|
||||
@@ -200,7 +200,7 @@ export class VariableSrv {
|
||||
|
||||
return variable.setValue(selected);
|
||||
} else {
|
||||
const currentOption = _.find(variable.options, {
|
||||
const currentOption: any = _.find(variable.options, {
|
||||
text: variable.current.text,
|
||||
});
|
||||
if (currentOption) {
|
||||
@@ -222,7 +222,7 @@ export class VariableSrv {
|
||||
}
|
||||
|
||||
return promise.then(() => {
|
||||
let option = _.find(variable.options, op => {
|
||||
let option: any = _.find(variable.options, op => {
|
||||
return op.text === urlValue || op.value === urlValue;
|
||||
});
|
||||
|
||||
@@ -233,7 +233,7 @@ export class VariableSrv {
|
||||
defaultText = [];
|
||||
|
||||
for (let n = 0; n < urlValue.length; n++) {
|
||||
const t = _.find(variable.options, op => {
|
||||
const t: any = _.find(variable.options, op => {
|
||||
return op.value === urlValue[n];
|
||||
});
|
||||
|
||||
@@ -279,10 +279,10 @@ export class VariableSrv {
|
||||
}
|
||||
|
||||
setAdhocFilter(options) {
|
||||
let variable = _.find(this.variables, {
|
||||
let variable: any = _.find(this.variables, {
|
||||
type: 'adhoc',
|
||||
datasource: options.datasource,
|
||||
});
|
||||
} as any);
|
||||
if (!variable) {
|
||||
variable = this.createVariableFromModel({
|
||||
name: 'Filters',
|
||||
@@ -293,7 +293,7 @@ export class VariableSrv {
|
||||
}
|
||||
|
||||
const filters = variable.filters;
|
||||
let filter = _.find(filters, { key: options.key, value: options.value });
|
||||
let filter: any = _.find(filters, { key: options.key, value: options.value });
|
||||
|
||||
if (!filter) {
|
||||
filter = { key: options.key, value: options.value };
|
||||
|
||||
@@ -410,7 +410,7 @@ export default class CloudWatchDatasource implements DataSourceApi<CloudWatchQue
|
||||
|
||||
getExpandedVariables(target, dimensionKey, variable, templateSrv) {
|
||||
/* if the all checkbox is marked we should add all values to the targets */
|
||||
const allSelected = _.find(variable.options, { selected: true, text: 'All' });
|
||||
const allSelected: any = _.find(variable.options, { selected: true, text: 'All' });
|
||||
const selectedVariables = _.filter(variable.options, v => {
|
||||
if (allSelected) {
|
||||
return v.text !== 'All';
|
||||
@@ -427,7 +427,7 @@ export default class CloudWatchDatasource implements DataSourceApi<CloudWatchQue
|
||||
};
|
||||
});
|
||||
const useSelectedVariables =
|
||||
selectedVariables.some(s => {
|
||||
selectedVariables.some((s: any) => {
|
||||
return s.value === currentVariables[0].value;
|
||||
}) || currentVariables[0].value === '$__all';
|
||||
return (useSelectedVariables ? selectedVariables : currentVariables).map(v => {
|
||||
|
||||
@@ -33,7 +33,7 @@ export class ElasticConfigCtrl {
|
||||
this.current.database.length === 0 ||
|
||||
this.current.database.startsWith('[logstash-]')
|
||||
) {
|
||||
const def = _.find(this.indexPatternTypes, {
|
||||
const def: any = _.find(this.indexPatternTypes, {
|
||||
value: this.current.jsonData.interval,
|
||||
});
|
||||
this.current.database = def.example || 'es-index-name';
|
||||
|
||||
@@ -204,7 +204,7 @@ export class ElasticDatasource {
|
||||
// validate that the index exist and has date field
|
||||
return this.getFields({ type: 'date' }).then(
|
||||
dateFields => {
|
||||
const timeField = _.find(dateFields, { text: this.timeField });
|
||||
const timeField: any = _.find(dateFields, { text: this.timeField });
|
||||
if (!timeField) {
|
||||
return {
|
||||
status: 'error',
|
||||
|
||||
@@ -222,7 +222,7 @@ export class ElasticResponse {
|
||||
}
|
||||
|
||||
private getMetricName(metric) {
|
||||
let metricDef = _.find(queryDef.metricAggTypes, { value: metric });
|
||||
let metricDef: any = _.find(queryDef.metricAggTypes, { value: metric });
|
||||
if (!metricDef) {
|
||||
metricDef = _.find(queryDef.extendedStats, { value: metric });
|
||||
}
|
||||
@@ -258,12 +258,12 @@ export class ElasticResponse {
|
||||
|
||||
if (series.field && queryDef.isPipelineAgg(series.metric)) {
|
||||
if (series.metric && queryDef.isPipelineAggWithMultipleBucketPaths(series.metric)) {
|
||||
const agg = _.find(target.metrics, { id: series.metricId });
|
||||
const agg: any = _.find(target.metrics, { id: series.metricId });
|
||||
if (agg && agg.settings.script) {
|
||||
metricName = agg.settings.script;
|
||||
|
||||
for (const pv of agg.pipelineVariables) {
|
||||
const appliedAgg = _.find(target.metrics, { id: pv.pipelineAgg });
|
||||
const appliedAgg: any = _.find(target.metrics, { id: pv.pipelineAgg });
|
||||
if (appliedAgg) {
|
||||
metricName = metricName.replace('params.' + pv.name, queryDef.describeMetric(appliedAgg));
|
||||
}
|
||||
@@ -272,7 +272,7 @@ export class ElasticResponse {
|
||||
metricName = 'Unset';
|
||||
}
|
||||
} else {
|
||||
const appliedAgg = _.find(target.metrics, { id: series.field });
|
||||
const appliedAgg: any = _.find(target.metrics, { id: series.field });
|
||||
if (appliedAgg) {
|
||||
metricName += ' ' + queryDef.describeMetric(appliedAgg);
|
||||
} else {
|
||||
@@ -343,7 +343,7 @@ export class ElasticResponse {
|
||||
}
|
||||
|
||||
trimDatapoints(aggregations, target) {
|
||||
const histogram = _.find(target.bucketAggs, { type: 'date_histogram' });
|
||||
const histogram: any = _.find(target.bucketAggs, { type: 'date_histogram' });
|
||||
|
||||
const shouldDropFirstAndLast = histogram && histogram.settings && histogram.settings.trimEdges;
|
||||
if (shouldDropFirstAndLast) {
|
||||
|
||||
@@ -81,7 +81,7 @@ export class ElasticMetricAggCtrl {
|
||||
$scope.agg.meta,
|
||||
(memo, val, key) => {
|
||||
if (val) {
|
||||
const def = _.find($scope.extendedStats, { value: key });
|
||||
const def: any = _.find($scope.extendedStats, { value: key });
|
||||
memo.push(def.text);
|
||||
}
|
||||
return memo;
|
||||
|
||||
@@ -66,7 +66,7 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
||||
text += 'Metrics: ';
|
||||
|
||||
_.each(metricAggs, (metric, index) => {
|
||||
const aggDef = _.find(metricAggTypes, { value: metric.type });
|
||||
const aggDef: any = _.find(metricAggTypes, { value: metric.type });
|
||||
text += aggDef.text + '(';
|
||||
if (aggDef.requiresField) {
|
||||
text += metric.field;
|
||||
@@ -77,12 +77,12 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
||||
text += '), ';
|
||||
});
|
||||
|
||||
_.each(bucketAggs, (bucketAgg, index) => {
|
||||
_.each(bucketAggs, (bucketAgg: any, index: number) => {
|
||||
if (index === 0) {
|
||||
text += ' Group by: ';
|
||||
}
|
||||
|
||||
const aggDef = _.find(bucketAggTypes, { value: bucketAgg.type });
|
||||
const aggDef: any = _.find(bucketAggTypes, { value: bucketAgg.type });
|
||||
text += aggDef.text + '(';
|
||||
if (aggDef.requiresField) {
|
||||
text += bucketAgg.field;
|
||||
|
||||
@@ -224,12 +224,12 @@ export function getOrderByOptions(target) {
|
||||
}
|
||||
|
||||
export function describeOrder(order) {
|
||||
const def = _.find(orderOptions, { value: order });
|
||||
const def: any = _.find(orderOptions, { value: order });
|
||||
return def.text;
|
||||
}
|
||||
|
||||
export function describeMetric(metric) {
|
||||
const def = _.find(metricAggTypes, { value: metric.type });
|
||||
const def: any = _.find(metricAggTypes, { value: metric.type });
|
||||
if (!def.requiresField && !isPipelineAgg(metric.type)) {
|
||||
return def.text;
|
||||
}
|
||||
@@ -237,11 +237,11 @@ export function describeMetric(metric) {
|
||||
}
|
||||
|
||||
export function describeOrderBy(orderBy, target) {
|
||||
const def = _.find(orderByOptions, { value: orderBy });
|
||||
const def: any = _.find(orderByOptions, { value: orderBy });
|
||||
if (def) {
|
||||
return def.text;
|
||||
}
|
||||
const metric = _.find(target.metrics, { id: orderBy });
|
||||
const metric: any = _.find(target.metrics, { id: orderBy });
|
||||
if (metric) {
|
||||
return describeMetric(metric);
|
||||
} else {
|
||||
|
||||
@@ -144,7 +144,7 @@ export default class ResponseParser {
|
||||
}
|
||||
|
||||
static findOrCreateBucket(data, target) {
|
||||
let dataTarget = _.find(data, ['target', target]);
|
||||
let dataTarget: any = _.find(data, ['target', target]);
|
||||
if (!dataTarget) {
|
||||
dataTarget = { target: target, datapoints: [] };
|
||||
data.push(dataTarget);
|
||||
|
||||
@@ -254,7 +254,7 @@ export default class ResponseParser {
|
||||
}
|
||||
|
||||
static findOrCreateBucket(data, target): DataTarget {
|
||||
let dataTarget = _.find(data, ['target', target]);
|
||||
let dataTarget: any = _.find(data, ['target', target]);
|
||||
if (!dataTarget) {
|
||||
dataTarget = { target: target, datapoints: [], refId: '', query: '' };
|
||||
data.push(dataTarget);
|
||||
|
||||
@@ -136,7 +136,7 @@ export default class ResponseParser {
|
||||
}
|
||||
|
||||
static parseMetadata(result: any, metricName: string) {
|
||||
const metricData = _.find(result.data.value, o => {
|
||||
const metricData: any = _.find(result.data.value, o => {
|
||||
return _.get(o, 'name.value') === metricName;
|
||||
});
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ class QueryField extends React.Component<any, any> {
|
||||
|
||||
// Get the currently selected suggestion
|
||||
const flattenedSuggestions = flattenSuggestions(suggestions);
|
||||
const suggestion = _.find(
|
||||
const suggestion: any = _.find(
|
||||
flattenedSuggestions,
|
||||
suggestion => suggestion.display === item || suggestion.text === item
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ export function graphiteAddFunc($compile) {
|
||||
minLength: 1,
|
||||
items: 10,
|
||||
updater: value => {
|
||||
let funcDef = ctrl.datasource.getFuncDef(value);
|
||||
let funcDef: any = ctrl.datasource.getFuncDef(value);
|
||||
if (!funcDef) {
|
||||
// try find close match
|
||||
value = value.toLowerCase();
|
||||
|
||||
@@ -77,7 +77,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
if (index < func.def.params.length) {
|
||||
return func.def.params[index];
|
||||
}
|
||||
if (_.last(func.def.params).multiple) {
|
||||
if ((_.last(func.def.params) as any).multiple) {
|
||||
return _.assign({}, _.last(func.def.params), { optional: true });
|
||||
}
|
||||
return {};
|
||||
@@ -170,14 +170,14 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
|
||||
function addElementsAndCompile() {
|
||||
$funcLink.appendTo(elem);
|
||||
|
||||
const defParams = _.clone(func.def.params);
|
||||
const lastParam = _.last(func.def.params);
|
||||
const defParams: any = _.clone(func.def.params);
|
||||
const lastParam: any = _.last(func.def.params);
|
||||
|
||||
while (func.params.length >= defParams.length && lastParam && lastParam.multiple) {
|
||||
defParams.push(_.assign({}, lastParam, { optional: true }));
|
||||
}
|
||||
|
||||
_.each(defParams, (param, index) => {
|
||||
_.each(defParams, (param: any, index: number) => {
|
||||
if (param.optional && func.params.length < index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export default class GraphiteQuery {
|
||||
}
|
||||
|
||||
checkForSeriesByTag() {
|
||||
const seriesByTagFunc = _.find(this.functions, func => func.def.name === 'seriesByTag');
|
||||
const seriesByTagFunc: any = _.find(this.functions, func => func.def.name === 'seriesByTag');
|
||||
if (seriesByTagFunc) {
|
||||
this.seriesByTagUsed = true;
|
||||
seriesByTagFunc.hidden = true;
|
||||
@@ -135,7 +135,7 @@ export default class GraphiteQuery {
|
||||
}
|
||||
|
||||
moveAliasFuncLast() {
|
||||
const aliasFunc = _.find(this.functions, func => {
|
||||
const aliasFunc: any = _.find(this.functions, func => {
|
||||
return func.def.name.startsWith('alias');
|
||||
});
|
||||
|
||||
@@ -158,6 +158,7 @@ export default class GraphiteQuery {
|
||||
|
||||
moveFunction(func, offset) {
|
||||
const index = this.functions.indexOf(func);
|
||||
// @ts-ignore
|
||||
_.move(this.functions, index, index + offset);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ export class GraphiteQueryCtrl extends QueryCtrl {
|
||||
});
|
||||
}
|
||||
|
||||
removeTaggedEntry(altSegments) {
|
||||
removeTaggedEntry(altSegments: any[]) {
|
||||
altSegments = _.remove(altSegments, s => s.value === '_tagged');
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ export default class InfluxSeries {
|
||||
return table;
|
||||
}
|
||||
|
||||
_.each(this.series, (series, seriesIndex) => {
|
||||
_.each(this.series, (series: any, seriesIndex: number) => {
|
||||
if (seriesIndex === 0) {
|
||||
j = 0;
|
||||
// Check that the first column is indeed 'time'
|
||||
|
||||
@@ -44,7 +44,9 @@ export default class ResponseParser {
|
||||
});
|
||||
});
|
||||
|
||||
// @ts-ignore problems with typings for this _.map only accepts [] but this needs to be object
|
||||
return _.map(res, value => {
|
||||
// @ts-ignore
|
||||
return { text: value.toString() };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Libraries
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class MixedDatasource implements DataSourceApi<DataQuery> {
|
||||
|
||||
query(options: DataQueryOptions<DataQuery>) {
|
||||
const sets = _.groupBy(options.targets, 'datasource');
|
||||
const promises = _.map(sets, (targets: DataQuery[]) => {
|
||||
const promises: any = _.map(sets, (targets: DataQuery[]) => {
|
||||
const dsName = targets[0].datasource;
|
||||
if (dsName === '-- Mixed --') {
|
||||
return Promise.resolve([]);
|
||||
|
||||
@@ -59,7 +59,7 @@ export class MssqlQueryCtrl extends QueryCtrl {
|
||||
this.lastQueryMeta = null;
|
||||
this.lastQueryError = null;
|
||||
|
||||
const anySeriesFromQuery = _.find(dataList, { refId: this.target.refId });
|
||||
const anySeriesFromQuery: any = _.find(dataList, { refId: this.target.refId });
|
||||
if (anySeriesFromQuery) {
|
||||
this.lastQueryMeta = anySeriesFromQuery.meta;
|
||||
}
|
||||
|
||||
@@ -149,17 +149,17 @@ export default class MysqlQuery {
|
||||
buildValueColumn(column) {
|
||||
let query = '';
|
||||
|
||||
const columnName = _.find(column, (g: any) => g.type === 'column');
|
||||
const columnName: any = _.find(column, (g: any) => g.type === 'column');
|
||||
query = columnName.params[0];
|
||||
|
||||
const aggregate = _.find(column, (g: any) => g.type === 'aggregate');
|
||||
const aggregate: any = _.find(column, (g: any) => g.type === 'aggregate');
|
||||
|
||||
if (aggregate) {
|
||||
const func = aggregate.params[0];
|
||||
query = func + '(' + query + ')';
|
||||
}
|
||||
|
||||
const alias = _.find(column, (g: any) => g.type === 'alias');
|
||||
const alias: any = _.find(column, (g: any) => g.type === 'alias');
|
||||
if (alias) {
|
||||
query += ' AS ' + this.quoteIdentifier(alias.params[0]);
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.lastQueryMeta = null;
|
||||
this.lastQueryError = null;
|
||||
|
||||
const anySeriesFromQuery = _.find(dataList, { refId: this.target.refId });
|
||||
const anySeriesFromQuery: any = _.find(dataList, { refId: this.target.refId });
|
||||
if (anySeriesFromQuery) {
|
||||
this.lastQueryMeta = anySeriesFromQuery.meta;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export default class OpenTsDatasource {
|
||||
|
||||
return this.performTimeSeriesQuery(queries, start, end).then(response => {
|
||||
const metricToTargetMapping = this.mapMetricsToTargets(response.data, options, this.tsdbVersion);
|
||||
const result = _.map(response.data, (metricData, index) => {
|
||||
const result = _.map(response.data, (metricData: any, index: number) => {
|
||||
index = metricToTargetMapping[index];
|
||||
if (index === -1) {
|
||||
index = 0;
|
||||
@@ -347,7 +347,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, (v, k) => {
|
||||
_.each(md.dps, (v: any, k: number) => {
|
||||
if (tsdbResolution === 2) {
|
||||
dps.push([v, k * 1]);
|
||||
} else {
|
||||
@@ -466,7 +466,7 @@ export default class OpenTsDatasource {
|
||||
if (tsdbVersion === 3) {
|
||||
return metricData.query.index;
|
||||
} else {
|
||||
return _.findIndex(options.targets, target => {
|
||||
return _.findIndex(options.targets as any[], target => {
|
||||
if (target.filters && target.filters.length > 0) {
|
||||
return target.metric === metricData.metric;
|
||||
} else {
|
||||
|
||||
@@ -149,11 +149,11 @@ export default class PostgresQuery {
|
||||
buildValueColumn(column) {
|
||||
let query = '';
|
||||
|
||||
const columnName = _.find(column, (g: any) => g.type === 'column');
|
||||
const columnName: any = _.find(column, (g: any) => g.type === 'column');
|
||||
query = columnName.params[0];
|
||||
|
||||
const aggregate = _.find(column, (g: any) => g.type === 'aggregate' || g.type === 'percentile');
|
||||
const windows = _.find(column, (g: any) => g.type === 'window' || g.type === 'moving_window');
|
||||
const aggregate: any = _.find(column, (g: any) => g.type === 'aggregate' || g.type === 'percentile');
|
||||
const windows: any = _.find(column, (g: any) => g.type === 'window' || g.type === 'moving_window');
|
||||
|
||||
if (aggregate) {
|
||||
const func = aggregate.params[0];
|
||||
@@ -218,7 +218,7 @@ export default class PostgresQuery {
|
||||
}
|
||||
}
|
||||
|
||||
const alias = _.find(column, (g: any) => g.type === 'alias');
|
||||
const alias: any = _.find(column, (g: any) => g.type === 'alias');
|
||||
if (alias) {
|
||||
query += ' AS ' + this.quoteIdentifier(alias.params[0]);
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
this.lastQueryMeta = null;
|
||||
this.lastQueryError = null;
|
||||
|
||||
const anySeriesFromQuery = _.find(dataList, { refId: this.target.refId });
|
||||
const anySeriesFromQuery: any = _.find(dataList, { refId: this.target.refId });
|
||||
if (anySeriesFromQuery) {
|
||||
this.lastQueryMeta = anySeriesFromQuery.meta;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
// @ts-ignore
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-ignore
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('PrometheusDatasource', () => {
|
||||
directUrl: 'direct',
|
||||
user: 'test',
|
||||
password: 'mupp',
|
||||
jsonData: {},
|
||||
jsonData: {} as any,
|
||||
};
|
||||
|
||||
ctx.backendSrvMock = {};
|
||||
|
||||
@@ -42,7 +42,7 @@ export default class StackdriverMetricFindQuery {
|
||||
|
||||
async handleServiceQuery() {
|
||||
const metricDescriptors = await this.datasource.getMetricTypes(this.datasource.projectName);
|
||||
const services = extractServicesFromMetricDescriptors(metricDescriptors);
|
||||
const services: any[] = extractServicesFromMetricDescriptors(metricDescriptors);
|
||||
return services.map(s => ({
|
||||
text: s.serviceShortName,
|
||||
value: s.service,
|
||||
|
||||
@@ -34,7 +34,7 @@ export class StackdriverVariableQueryEditor extends PureComponent<VariableQueryP
|
||||
|
||||
async componentDidMount() {
|
||||
const metricDescriptors = await this.props.datasource.getMetricTypes(this.props.datasource.projectName);
|
||||
const services = extractServicesFromMetricDescriptors(metricDescriptors).map(m => ({
|
||||
const services = extractServicesFromMetricDescriptors(metricDescriptors).map((m: any) => ({
|
||||
value: m.service,
|
||||
name: m.serviceShortName,
|
||||
}));
|
||||
|
||||
@@ -35,7 +35,7 @@ export class QueryEditor extends PureComponent<Props> {
|
||||
|
||||
// const scenarioList = await this.backendSrv.get('/api/tsdb/testdata/scenarios');
|
||||
const scenarioList = await datasource.getScenarios();
|
||||
const current = _.find(scenarioList, { id: query.scenarioId });
|
||||
const current: any = _.find(scenarioList, { id: query.scenarioId });
|
||||
|
||||
this.setState({ scenarioList: scenarioList, current: current });
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { DataQuery } from '@grafana/ui/src/types';
|
||||
export interface TestDataQuery extends DataQuery {
|
||||
alias?: string;
|
||||
scenarioId: string;
|
||||
stringInput: string;
|
||||
points: any;
|
||||
}
|
||||
|
||||
export interface Scenario {
|
||||
|
||||
@@ -88,7 +88,7 @@ export class GraphLegend extends PureComponent<GraphLegendProps, LegendState> {
|
||||
}
|
||||
|
||||
sortLegend() {
|
||||
let seriesList = [...this.props.seriesList] || [];
|
||||
let seriesList: TimeSeries[] = [...this.props.seriesList] || [];
|
||||
if (this.props.sort) {
|
||||
seriesList = _.sortBy(seriesList, series => {
|
||||
let sort = series.stats[this.props.sort];
|
||||
@@ -96,7 +96,7 @@ export class GraphLegend extends PureComponent<GraphLegendProps, LegendState> {
|
||||
sort = -Infinity;
|
||||
}
|
||||
return sort;
|
||||
});
|
||||
}) as TimeSeries[];
|
||||
if (this.props.sortDesc) {
|
||||
seriesList = seriesList.reverse();
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ export class DataProcessor {
|
||||
}
|
||||
|
||||
const validOptions = this.getXAxisValueOptions({});
|
||||
const found = _.find(validOptions, { value: this.panel.xaxis.values[0] });
|
||||
const found: any = _.find(validOptions, { value: this.panel.xaxis.values[0] });
|
||||
if (!found) {
|
||||
this.panel.xaxis.values = ['total'];
|
||||
}
|
||||
|
||||
@@ -574,6 +574,7 @@ class GraphElement {
|
||||
return [tickIndex + 1, point[1]];
|
||||
});
|
||||
});
|
||||
// @ts-ignore, potential bug? is this _.flattenDeep?
|
||||
ticks = _.flatten(ticks, true);
|
||||
|
||||
options.xaxis = {
|
||||
|
||||
@@ -262,7 +262,7 @@ class GraphCtrl extends MetricsPanelCtrl {
|
||||
};
|
||||
|
||||
onToggleAxis = info => {
|
||||
let override = _.find(this.panel.seriesOverrides, { alias: info.alias });
|
||||
let override: any = _.find(this.panel.seriesOverrides, { alias: info.alias });
|
||||
if (!override) {
|
||||
override = { alias: info.alias };
|
||||
this.panel.seriesOverrides.push(override);
|
||||
|
||||
@@ -36,7 +36,7 @@ coreModule.directive('colorLegend', () => {
|
||||
const legendWidth = Math.floor(legendElem.outerWidth());
|
||||
|
||||
if (panel.color.mode === 'spectrum') {
|
||||
const colorScheme = _.find(ctrl.colorSchemes, {
|
||||
const colorScheme: any = _.find(ctrl.colorSchemes, {
|
||||
value: panel.color.colorScheme,
|
||||
});
|
||||
const colorScale = getColorScale(colorScheme, contextSrv.user.lightTheme, legendWidth);
|
||||
@@ -76,7 +76,7 @@ coreModule.directive('heatmapLegend', () => {
|
||||
const minValue = cardStats.min;
|
||||
|
||||
if (panel.color.mode === 'spectrum') {
|
||||
const colorScheme = _.find(ctrl.colorSchemes, {
|
||||
const colorScheme: any = _.find(ctrl.colorSchemes, {
|
||||
value: panel.color.colorScheme,
|
||||
});
|
||||
drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minValue);
|
||||
|
||||
@@ -253,7 +253,7 @@ function convertToHeatMap(seriesList, yBucketSize, xBucketSize, logBase = 1) {
|
||||
// |* | --/ |1|,
|
||||
// |____| |0|
|
||||
//
|
||||
_.forEach(heatmap, xBucket => {
|
||||
_.forEach(heatmap, (xBucket: any) => {
|
||||
if (logBase !== 1) {
|
||||
xBucket.buckets = convertToLogScaleValueBuckets(xBucket, yBucketSize, logBase);
|
||||
} else {
|
||||
|
||||
@@ -81,7 +81,7 @@ export class HeatmapTooltip {
|
||||
let boundBottom, boundTop, valuesNumber;
|
||||
const xData = data.buckets[xBucketIndex];
|
||||
// Search in special 'zero' bucket also
|
||||
const yData = _.find(xData.buckets, (bucket, bucketIndex) => {
|
||||
const yData: any = _.find(xData.buckets, (bucket, bucketIndex) => {
|
||||
return bucket.bounds.bottom === yBucketIndex || bucketIndex === yBucketIndex.toString();
|
||||
});
|
||||
|
||||
@@ -161,7 +161,7 @@ export class HeatmapTooltip {
|
||||
getXBucketIndex(x, data) {
|
||||
// First try to find X bucket by checking x pos is in the
|
||||
// [bucket.x, bucket.x + xBucketSize] interval
|
||||
const xBucket = _.find(data.buckets, bucket => {
|
||||
const xBucket: any = _.find(data.buckets, bucket => {
|
||||
return x > bucket.x && x - bucket.x <= data.xBucketSize;
|
||||
});
|
||||
return xBucket ? xBucket.x : getValueBucketBound(x, data.xBucketSize, 1);
|
||||
|
||||
@@ -529,7 +529,7 @@ export class HeatmapRenderer {
|
||||
const minValueAuto = Math.min(cardStats.min, 0);
|
||||
const maxValue = _.isNil(this.panel.color.max) ? maxValueAuto : this.panel.color.max;
|
||||
const minValue = _.isNil(this.panel.color.min) ? minValueAuto : this.panel.color.min;
|
||||
const colorScheme = _.find(this.ctrl.colorSchemes, {
|
||||
const colorScheme: any = _.find(this.ctrl.colorSchemes, {
|
||||
value: this.panel.color.colorScheme,
|
||||
});
|
||||
this.colorScale = getColorScale(colorScheme, contextSrv.user.lightTheme, maxValue, minValue);
|
||||
|
||||
@@ -52,7 +52,7 @@ export class TablePanelEditorCtrl {
|
||||
|
||||
addColumn() {
|
||||
const columns = transformers[this.panel.transform].getColumns(this.panelCtrl.dataRaw);
|
||||
const column = _.find(columns, { text: this.addColumnSegment.value });
|
||||
const column: any = _.find(columns, { text: this.addColumnSegment.value });
|
||||
|
||||
if (column) {
|
||||
this.panel.columns.push(column);
|
||||
|
||||
@@ -101,7 +101,7 @@ export class TableRenderer {
|
||||
}
|
||||
|
||||
// if is an epoch (numeric string and len > 12)
|
||||
if (_.isString(v) && !isNaN(v) && v.length > 12) {
|
||||
if (_.isString(v) && !isNaN(v as any) && v.length > 12) {
|
||||
v = parseInt(v, 10);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ transformers['table'] = {
|
||||
|
||||
return columns;
|
||||
},
|
||||
transform: (data, panel, model) => {
|
||||
transform: (data: any[], panel, model) => {
|
||||
if (!data || data.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2333,6 +2333,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-1.10.35.tgz#4e5c2b1e5b3bf0b863efb8c5e70081f52e6c9518"
|
||||
integrity sha512-SVtqEcudm7yjkTwoRA1gC6CNMhGDdMx4Pg8BPdiqI7bXXdCn1BPmtxgeWYQOgDxrq53/5YTlhq5ULxBEAlWIBg==
|
||||
|
||||
"@types/lodash@4.14.123":
|
||||
version "4.14.123"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.123.tgz#39be5d211478c8dd3bdae98ee75bb7efe4abfe4d"
|
||||
integrity sha512-pQvPkc4Nltyx7G1Ww45OjVqUsJP4UsZm+GWJpigXgkikZqJgRm4c48g027o6tdgubWHwFRF15iFd+Y4Pmqv6+Q==
|
||||
|
||||
"@types/lodash@^4.14.119":
|
||||
version "4.14.119"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.119.tgz#be847e5f4bc3e35e46d041c394ead8b603ad8b39"
|
||||
|
||||
Reference in New Issue
Block a user