mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: noImplicitAny Sub 500 errors (#18287)
This commit is contained in:
parent
7949329636
commit
7891233812
@ -175,11 +175,14 @@
|
||||
"@types/angular-route": "1.7.0",
|
||||
"@types/d3-scale-chromatic": "1.3.1",
|
||||
"@types/enzyme-adapter-react-16": "1.0.5",
|
||||
"@types/file-saver": "2.0.1",
|
||||
"@types/marked": "0.6.5",
|
||||
"@types/prismjs": "1.16.0",
|
||||
"@types/react-redux": "^7.0.8",
|
||||
"@types/react-redux": "7.0.8",
|
||||
"@types/react-table": "6.8.5",
|
||||
"@types/react-test-renderer": "16.8.2",
|
||||
"@types/redux-logger": "3.0.7",
|
||||
"@types/redux-mock-store": "1.0.1",
|
||||
"@types/reselect": "2.2.0",
|
||||
"@types/slate": "0.44.11",
|
||||
"@types/tinycolor2": "1.4.2",
|
||||
|
@ -2,8 +2,10 @@ import { coreModule, appEvents, contextSrv } from 'app/core/core';
|
||||
import { DashboardModel } from '../../state/DashboardModel';
|
||||
import $ from 'jquery';
|
||||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
import angular, { ILocationService } from 'angular';
|
||||
import config from 'app/core/config';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { DashboardSrv } from '../../services/DashboardSrv';
|
||||
|
||||
export class SettingsCtrl {
|
||||
dashboard: DashboardModel;
|
||||
@ -19,12 +21,12 @@ export class SettingsCtrl {
|
||||
|
||||
/** @ngInject */
|
||||
constructor(
|
||||
private $scope,
|
||||
private $route,
|
||||
private $location,
|
||||
private $rootScope,
|
||||
private backendSrv,
|
||||
private dashboardSrv
|
||||
private $scope: any,
|
||||
private $route: any,
|
||||
private $location: ILocationService,
|
||||
private $rootScope: any,
|
||||
private backendSrv: BackendSrv,
|
||||
private dashboardSrv: DashboardSrv
|
||||
) {
|
||||
// temp hack for annotations and variables editors
|
||||
// that rely on inherited scope
|
||||
@ -226,13 +228,13 @@ export class SettingsCtrl {
|
||||
}
|
||||
|
||||
deleteDashboardConfirmed() {
|
||||
this.backendSrv.deleteDashboard(this.dashboard.uid).then(() => {
|
||||
this.backendSrv.deleteDashboard(this.dashboard.uid, false).then(() => {
|
||||
appEvents.emit('alert-success', ['Dashboard Deleted', this.dashboard.title + ' has been deleted']);
|
||||
this.$location.url('/');
|
||||
});
|
||||
}
|
||||
|
||||
onFolderChange(folder) {
|
||||
onFolderChange(folder: { id: number; title: string }) {
|
||||
this.dashboard.meta.folderId = folder.id;
|
||||
this.dashboard.meta.folderTitle = folder.title;
|
||||
this.hasUnsavedFolderChange = true;
|
||||
|
@ -2,14 +2,14 @@ import { SaveDashboardAsModalCtrl } from './SaveDashboardAsModalCtrl';
|
||||
import { describe, it, expect } from 'test/lib/common';
|
||||
|
||||
describe('saving dashboard as', () => {
|
||||
function scenario(name, panel, verify) {
|
||||
function scenario(name: string, panel: any, verify: Function) {
|
||||
describe(name, () => {
|
||||
const json = {
|
||||
title: 'name',
|
||||
panels: [panel],
|
||||
};
|
||||
|
||||
const mockDashboardSrv = {
|
||||
const mockDashboardSrv: any = {
|
||||
getCurrent: () => {
|
||||
return {
|
||||
id: 5,
|
||||
@ -34,7 +34,7 @@ describe('saving dashboard as', () => {
|
||||
});
|
||||
}
|
||||
|
||||
scenario('default values', {}, ctx => {
|
||||
scenario('default values', {}, (ctx: any) => {
|
||||
const clone = ctx.clone;
|
||||
expect(clone.id).toBe(null);
|
||||
expect(clone.title).toBe('name Copy');
|
||||
@ -49,19 +49,23 @@ describe('saving dashboard as', () => {
|
||||
thresholds: { value: 3000 },
|
||||
};
|
||||
|
||||
scenario('should remove alert from graph panel', graphPanel, ctx => {
|
||||
scenario('should remove alert from graph panel', graphPanel, (ctx: any) => {
|
||||
expect(ctx.panel.alert).toBe(undefined);
|
||||
});
|
||||
|
||||
scenario('should remove threshold from graph panel', graphPanel, ctx => {
|
||||
scenario('should remove threshold from graph panel', graphPanel, (ctx: any) => {
|
||||
expect(ctx.panel.thresholds).toBe(undefined);
|
||||
});
|
||||
|
||||
scenario('singlestat should keep threshold', { id: 1, type: 'singlestat', thresholds: { value: 3000 } }, ctx => {
|
||||
expect(ctx.panel.thresholds).not.toBe(undefined);
|
||||
});
|
||||
scenario(
|
||||
'singlestat should keep threshold',
|
||||
{ id: 1, type: 'singlestat', thresholds: { value: 3000 } },
|
||||
(ctx: any) => {
|
||||
expect(ctx.panel.thresholds).not.toBe(undefined);
|
||||
}
|
||||
);
|
||||
|
||||
scenario('table should keep threshold', { id: 1, type: 'table', thresholds: { value: 3000 } }, ctx => {
|
||||
scenario('table should keep threshold', { id: 1, type: 'table', thresholds: { value: 3000 } }, (ctx: any) => {
|
||||
expect(ctx.panel.thresholds).not.toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,6 @@
|
||||
import coreModule from 'app/core/core_module';
|
||||
import { DashboardSrv } from '../../services/DashboardSrv';
|
||||
import { PanelModel } from '../../state/PanelModel';
|
||||
|
||||
const template = `
|
||||
<div class="modal-body">
|
||||
@ -56,7 +58,7 @@ export class SaveDashboardAsModalCtrl {
|
||||
copyTags: boolean;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private dashboardSrv) {
|
||||
constructor(private dashboardSrv: DashboardSrv) {
|
||||
const dashboard = this.dashboardSrv.getCurrent();
|
||||
this.clone = dashboard.getSaveModelClone();
|
||||
this.clone.id = null;
|
||||
@ -70,7 +72,7 @@ export class SaveDashboardAsModalCtrl {
|
||||
// remove alerts if source dashboard is already persisted
|
||||
// do not want to create alert dupes
|
||||
if (dashboard.id > 0) {
|
||||
this.clone.panels.forEach(panel => {
|
||||
this.clone.panels.forEach((panel: PanelModel) => {
|
||||
if (panel.type === 'graph' && panel.alert) {
|
||||
delete panel.thresholds;
|
||||
}
|
||||
@ -89,13 +91,13 @@ export class SaveDashboardAsModalCtrl {
|
||||
return this.dashboardSrv.save(this.clone, { folderId: this.folderId }).then(this.dismiss);
|
||||
}
|
||||
|
||||
keyDown(evt) {
|
||||
keyDown(evt: KeyboardEvent) {
|
||||
if (evt.keyCode === 13) {
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
onFolderChange(folder) {
|
||||
onFolderChange(folder: { id: any }) {
|
||||
this.folderId = folder.id;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { SaveDashboardModalCtrl } from './SaveDashboardModalCtrl';
|
||||
|
||||
const setup = (timeChanged, variableValuesChanged, cb) => {
|
||||
const setup = (timeChanged: boolean, variableValuesChanged: boolean, cb: Function) => {
|
||||
const dash = {
|
||||
hasTimeChanged: jest.fn().mockReturnValue(timeChanged),
|
||||
hasVariableValuesChanged: jest.fn().mockReturnValue(variableValuesChanged),
|
||||
@ -8,7 +8,7 @@ const setup = (timeChanged, variableValuesChanged, cb) => {
|
||||
resetOriginalVariables: jest.fn(),
|
||||
getSaveModelClone: jest.fn().mockReturnValue({}),
|
||||
};
|
||||
const dashboardSrvMock = {
|
||||
const dashboardSrvMock: any = {
|
||||
getCurrent: jest.fn().mockReturnValue(dash),
|
||||
save: jest.fn().mockReturnValue(Promise.resolve()),
|
||||
};
|
||||
@ -22,7 +22,7 @@ const setup = (timeChanged, variableValuesChanged, cb) => {
|
||||
|
||||
describe('SaveDashboardModal', () => {
|
||||
describe('Given time and template variable values have not changed', () => {
|
||||
setup(false, false, (dash, ctrl: SaveDashboardModalCtrl) => {
|
||||
setup(false, false, (dash: any, ctrl: SaveDashboardModalCtrl) => {
|
||||
it('When creating ctrl should set time and template variable values changed', () => {
|
||||
expect(ctrl.timeChange).toBeFalsy();
|
||||
expect(ctrl.variableValueChange).toBeFalsy();
|
||||
@ -31,7 +31,7 @@ describe('SaveDashboardModal', () => {
|
||||
});
|
||||
|
||||
describe('Given time and template variable values have changed', () => {
|
||||
setup(true, true, (dash, ctrl: SaveDashboardModalCtrl) => {
|
||||
setup(true, true, (dash: any, ctrl: SaveDashboardModalCtrl) => {
|
||||
it('When creating ctrl should set time and template variable values changed', () => {
|
||||
expect(ctrl.timeChange).toBeTruthy();
|
||||
expect(ctrl.variableValueChange).toBeTruthy();
|
||||
|
@ -1,4 +1,5 @@
|
||||
import coreModule from 'app/core/core_module';
|
||||
import { DashboardSrv } from '../../services/DashboardSrv';
|
||||
|
||||
const template = `
|
||||
<div class="modal-body">
|
||||
@ -71,8 +72,8 @@ export class SaveDashboardModalCtrl {
|
||||
saveTimerange = false;
|
||||
time: any;
|
||||
originalTime: any;
|
||||
current = [];
|
||||
originalCurrent = [];
|
||||
current: any[] = [];
|
||||
originalCurrent: any[] = [];
|
||||
max: number;
|
||||
saveForm: any;
|
||||
isSaving: boolean;
|
||||
@ -81,7 +82,7 @@ export class SaveDashboardModalCtrl {
|
||||
variableValueChange = false;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private dashboardSrv) {
|
||||
constructor(private dashboardSrv: DashboardSrv) {
|
||||
this.message = '';
|
||||
this.max = 64;
|
||||
this.isSaving = false;
|
||||
@ -94,7 +95,7 @@ export class SaveDashboardModalCtrl {
|
||||
return;
|
||||
}
|
||||
|
||||
const options = {
|
||||
const options: any = {
|
||||
saveVariables: this.saveVariables,
|
||||
saveTimerange: this.saveTimerange,
|
||||
message: this.message,
|
||||
@ -108,7 +109,7 @@ export class SaveDashboardModalCtrl {
|
||||
return this.dashboardSrv.save(saveModel, options).then(this.postSave.bind(this, options));
|
||||
}
|
||||
|
||||
postSave(options) {
|
||||
postSave(options: any) {
|
||||
if (options.saveVariables) {
|
||||
this.dashboardSrv.getCurrent().resetOriginalVariables();
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ describe('SaveProvisionedDashboardModalCtrl', () => {
|
||||
id: 5,
|
||||
};
|
||||
|
||||
const mockDashboardSrv = {
|
||||
const mockDashboardSrv: any = {
|
||||
getCurrent: () => {
|
||||
return {
|
||||
id: 5,
|
||||
|
@ -2,6 +2,7 @@ import angular from 'angular';
|
||||
import { saveAs } from 'file-saver';
|
||||
import coreModule from 'app/core/core_module';
|
||||
import { DashboardModel } from '../../state';
|
||||
import { DashboardSrv } from '../../services/DashboardSrv';
|
||||
|
||||
const template = `
|
||||
<div class="modal-body">
|
||||
@ -50,7 +51,7 @@ export class SaveProvisionedDashboardModalCtrl {
|
||||
dismiss: () => void;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(dashboardSrv) {
|
||||
constructor(dashboardSrv: DashboardSrv) {
|
||||
this.dashboardModel = dashboardSrv.getCurrent();
|
||||
this.dash = this.dashboardModel.getSaveModelClone();
|
||||
delete this.dash.id;
|
||||
|
@ -42,7 +42,7 @@ describe('ShareModalCtrl', () => {
|
||||
orgId: 1,
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
ctx.ctrl = new ShareModalCtrl(
|
||||
ctx.scope,
|
||||
{},
|
||||
@ -136,7 +136,7 @@ describe('ShareModalCtrl', () => {
|
||||
ctx.$location.absUrl = () => 'http://server/#!/test';
|
||||
ctx.scope.options.includeTemplateVars = true;
|
||||
|
||||
ctx.templateSrv.fillVariableValuesForUrl = params => {
|
||||
ctx.templateSrv.fillVariableValuesForUrl = (params: any) => {
|
||||
params['var-app'] = 'mupp';
|
||||
params['var-server'] = 'srv-01';
|
||||
};
|
||||
|
@ -1,10 +1,21 @@
|
||||
import angular from 'angular';
|
||||
import angular, { ILocationService } from 'angular';
|
||||
import config from 'app/core/config';
|
||||
import { dateTime } from '@grafana/data';
|
||||
import { appendQueryToUrl, toUrlParams } from 'app/core/utils/url';
|
||||
import { TimeSrv } from '../../services/TimeSrv';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { LinkSrv } from 'app/features/panel/panellinks/link_srv';
|
||||
|
||||
/** @ngInject */
|
||||
export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv, templateSrv, linkSrv) {
|
||||
export function ShareModalCtrl(
|
||||
$scope: any,
|
||||
$rootScope: any,
|
||||
$location: ILocationService,
|
||||
$timeout: any,
|
||||
timeSrv: TimeSrv,
|
||||
templateSrv: TemplateSrv,
|
||||
linkSrv: LinkSrv
|
||||
) {
|
||||
$scope.options = {
|
||||
forCurrent: true,
|
||||
includeTemplateVars: true,
|
||||
|
@ -1,9 +1,20 @@
|
||||
import angular from 'angular';
|
||||
import angular, { ILocationService } from 'angular';
|
||||
import _ from 'lodash';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { TimeSrv } from '../../services/TimeSrv';
|
||||
import { DashboardModel } from '../../state/DashboardModel';
|
||||
import { PanelModel } from '../../state/PanelModel';
|
||||
|
||||
export class ShareSnapshotCtrl {
|
||||
/** @ngInject */
|
||||
constructor($scope, $rootScope, $location, backendSrv, $timeout, timeSrv) {
|
||||
constructor(
|
||||
$scope: any,
|
||||
$rootScope: any,
|
||||
$location: ILocationService,
|
||||
backendSrv: BackendSrv,
|
||||
$timeout: any,
|
||||
timeSrv: TimeSrv
|
||||
) {
|
||||
$scope.snapshot = {
|
||||
name: $scope.dashboard.title,
|
||||
expires: 0,
|
||||
@ -26,7 +37,7 @@ export class ShareSnapshotCtrl {
|
||||
];
|
||||
|
||||
$scope.init = () => {
|
||||
backendSrv.get('/api/snapshot/shared-options').then(options => {
|
||||
backendSrv.get('/api/snapshot/shared-options').then((options: { [x: string]: any }) => {
|
||||
$scope.sharingButtonText = options['externalSnapshotName'];
|
||||
$scope.externalEnabled = options['externalEnabled'];
|
||||
});
|
||||
@ -34,7 +45,7 @@ export class ShareSnapshotCtrl {
|
||||
|
||||
$scope.apiUrl = '/api/snapshots';
|
||||
|
||||
$scope.createSnapshot = external => {
|
||||
$scope.createSnapshot = (external: any) => {
|
||||
$scope.dashboard.snapshot = {
|
||||
timestamp: new Date(),
|
||||
};
|
||||
@ -52,7 +63,7 @@ export class ShareSnapshotCtrl {
|
||||
}, $scope.snapshot.timeoutSeconds * 1000);
|
||||
};
|
||||
|
||||
$scope.saveSnapshot = external => {
|
||||
$scope.saveSnapshot = (external: any) => {
|
||||
const dash = $scope.dashboard.getSaveModelClone();
|
||||
$scope.scrubDashboard(dash);
|
||||
|
||||
@ -64,7 +75,7 @@ export class ShareSnapshotCtrl {
|
||||
};
|
||||
|
||||
backendSrv.post($scope.apiUrl, cmdData).then(
|
||||
results => {
|
||||
(results: { deleteUrl: any; url: any }) => {
|
||||
$scope.loading = false;
|
||||
$scope.deleteUrl = results.deleteUrl;
|
||||
$scope.snapshotUrl = results.url;
|
||||
@ -80,7 +91,7 @@ export class ShareSnapshotCtrl {
|
||||
return $scope.snapshotUrl;
|
||||
};
|
||||
|
||||
$scope.scrubDashboard = dash => {
|
||||
$scope.scrubDashboard = (dash: DashboardModel) => {
|
||||
// change title
|
||||
dash.title = $scope.snapshot.name;
|
||||
|
||||
@ -131,7 +142,7 @@ export class ShareSnapshotCtrl {
|
||||
|
||||
// cleanup snapshotData
|
||||
delete $scope.dashboard.snapshot;
|
||||
$scope.dashboard.forEachPanel(panel => {
|
||||
$scope.dashboard.forEachPanel((panel: PanelModel) => {
|
||||
delete panel.snapshotData;
|
||||
});
|
||||
_.each($scope.dashboard.annotations.list, annotation => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import angular from 'angular';
|
||||
import angular, { ILocationService } from 'angular';
|
||||
import _ from 'lodash';
|
||||
import { VariableSrv } from 'app/features/templating/all';
|
||||
|
||||
export class SubMenuCtrl {
|
||||
annotations: any;
|
||||
@ -7,7 +8,7 @@ export class SubMenuCtrl {
|
||||
dashboard: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private variableSrv, private $location) {
|
||||
constructor(private variableSrv: VariableSrv, private $location: ILocationService) {
|
||||
this.annotations = this.dashboard.templating.list;
|
||||
this.variables = this.variableSrv.variables;
|
||||
}
|
||||
@ -16,11 +17,11 @@ export class SubMenuCtrl {
|
||||
this.dashboard.startRefresh();
|
||||
}
|
||||
|
||||
variableUpdated(variable) {
|
||||
variableUpdated(variable: any) {
|
||||
this.variableSrv.variableUpdated(variable, true);
|
||||
}
|
||||
|
||||
openEditView(editview) {
|
||||
openEditView(editview: any) {
|
||||
const search = _.extend(this.$location.search(), { editview: editview });
|
||||
this.$location.search(search);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ export class UnsavedChangesModalCtrl {
|
||||
dismiss: () => void;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private unsavedChangesSrv) {}
|
||||
constructor(private unsavedChangesSrv: any) {}
|
||||
|
||||
discard() {
|
||||
this.dismiss();
|
||||
|
@ -1,6 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import { HistoryListCtrl } from './HistoryListCtrl';
|
||||
import { versions, compare, restore } from './__mocks__/history';
|
||||
// @ts-ignore
|
||||
import $q from 'q';
|
||||
|
||||
describe('HistoryListCtrl', () => {
|
||||
@ -10,9 +11,9 @@ describe('HistoryListCtrl', () => {
|
||||
|
||||
restore(7, RESTORE_ID);
|
||||
|
||||
let historySrv;
|
||||
let $rootScope;
|
||||
let historyListCtrl;
|
||||
let historySrv: any;
|
||||
let $rootScope: any;
|
||||
let historyListCtrl: any;
|
||||
beforeEach(() => {
|
||||
historySrv = {
|
||||
calculateDiff: jest.fn(),
|
||||
@ -25,13 +26,13 @@ describe('HistoryListCtrl', () => {
|
||||
});
|
||||
|
||||
describe('when the history list component is loaded', () => {
|
||||
let deferred;
|
||||
let deferred: any;
|
||||
|
||||
beforeEach(() => {
|
||||
deferred = $q.defer({});
|
||||
historySrv.getHistoryList = jest.fn(() => deferred.promise);
|
||||
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {}, $q, historySrv, {});
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {} as any, $q, historySrv, {});
|
||||
|
||||
historyListCtrl.dashboard = {
|
||||
id: 2,
|
||||
@ -89,7 +90,7 @@ describe('HistoryListCtrl', () => {
|
||||
|
||||
historySrv.getHistoryList = jest.fn(() => deferred.promise);
|
||||
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {}, $q, historySrv, {});
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {} as any, $q, historySrv, {});
|
||||
|
||||
deferred.reject(new Error('HistoryListError'));
|
||||
|
||||
@ -130,14 +131,14 @@ describe('HistoryListCtrl', () => {
|
||||
});
|
||||
|
||||
describe('when the user wants to compare two revisions', () => {
|
||||
let deferred;
|
||||
let deferred: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
deferred = $q.defer({});
|
||||
historySrv.getHistoryList = jest.fn(() => $q.when(versionsResponse));
|
||||
historySrv.calculateDiff = jest.fn(() => deferred.promise);
|
||||
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {}, $q, historySrv, {});
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {} as any, $q, historySrv, {});
|
||||
|
||||
historyListCtrl.dashboard = {
|
||||
id: 2,
|
||||
@ -272,14 +273,14 @@ describe('HistoryListCtrl', () => {
|
||||
});
|
||||
|
||||
describe('when the user wants to restore a revision', () => {
|
||||
let deferred;
|
||||
let deferred: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
deferred = $q.defer();
|
||||
historySrv.getHistoryList = jest.fn(() => $q.when(versionsResponse));
|
||||
historySrv.restoreDashboard = jest.fn(() => deferred.promise);
|
||||
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {}, $q, historySrv, {});
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {} as any, $q, historySrv, {});
|
||||
|
||||
historyListCtrl.dashboard = {
|
||||
id: 1,
|
||||
@ -299,7 +300,7 @@ describe('HistoryListCtrl', () => {
|
||||
deferred = $q.defer();
|
||||
historySrv.getHistoryList = jest.fn(() => $q.when(versionsResponse));
|
||||
historySrv.restoreDashboard = jest.fn(() => deferred.promise);
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {}, $q, historySrv, {});
|
||||
historyListCtrl = new HistoryListCtrl({}, $rootScope, {} as any, $q, historySrv, {});
|
||||
deferred.reject(new Error('RestoreError'));
|
||||
historyListCtrl.restoreConfirm(RESTORE_ID);
|
||||
await historyListCtrl.getLog();
|
||||
|
@ -1,10 +1,10 @@
|
||||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
import angular, { ILocationService, IQService } from 'angular';
|
||||
|
||||
import locationUtil from 'app/core/utils/location_util';
|
||||
import { DashboardModel } from '../../state/DashboardModel';
|
||||
import { HistoryListOpts, RevisionsModel, CalculateDiffOptions, HistorySrv } from './HistorySrv';
|
||||
import { dateTime, toUtc } from '@grafana/data';
|
||||
import { dateTime, toUtc, DateTimeInput } from '@grafana/data';
|
||||
|
||||
export class HistoryListCtrl {
|
||||
appending: boolean;
|
||||
@ -24,12 +24,12 @@ export class HistoryListCtrl {
|
||||
|
||||
/** @ngInject */
|
||||
constructor(
|
||||
private $route,
|
||||
private $rootScope,
|
||||
private $location,
|
||||
private $q,
|
||||
private $route: any,
|
||||
private $rootScope: any,
|
||||
private $location: ILocationService,
|
||||
private $q: IQService,
|
||||
private historySrv: HistorySrv,
|
||||
public $scope
|
||||
public $scope: any
|
||||
) {
|
||||
this.appending = false;
|
||||
this.diff = 'basic';
|
||||
@ -69,11 +69,11 @@ export class HistoryListCtrl {
|
||||
this.canCompare = selected === 2;
|
||||
}
|
||||
|
||||
formatDate(date) {
|
||||
formatDate(date: DateTimeInput) {
|
||||
return this.dashboard.formatDate(date);
|
||||
}
|
||||
|
||||
formatBasicDate(date) {
|
||||
formatBasicDate(date: DateTimeInput) {
|
||||
const now = this.dashboard.timezone === 'browser' ? dateTime() : toUtc();
|
||||
const then = this.dashboard.timezone === 'browser' ? dateTime(date) : toUtc(date);
|
||||
return then.from(now);
|
||||
@ -84,7 +84,9 @@ export class HistoryListCtrl {
|
||||
this.mode = 'compare';
|
||||
|
||||
// have it already been fetched?
|
||||
// @ts-ignore
|
||||
if (this.delta[this.diff]) {
|
||||
// @ts-ignore
|
||||
return this.$q.when(this.delta[this.diff]);
|
||||
}
|
||||
|
||||
@ -109,7 +111,8 @@ export class HistoryListCtrl {
|
||||
|
||||
return this.historySrv
|
||||
.calculateDiff(options)
|
||||
.then(response => {
|
||||
.then((response: any) => {
|
||||
// @ts-ignore
|
||||
this.delta[this.diff] = response;
|
||||
})
|
||||
.catch(() => {
|
||||
@ -130,7 +133,7 @@ export class HistoryListCtrl {
|
||||
|
||||
return this.historySrv
|
||||
.getHistoryList(this.dashboard, options)
|
||||
.then(revisions => {
|
||||
.then((revisions: any) => {
|
||||
// set formatted dates & default values
|
||||
for (const rev of revisions) {
|
||||
rev.createdDateString = this.formatDate(rev.created);
|
||||
@ -140,7 +143,7 @@ export class HistoryListCtrl {
|
||||
|
||||
this.revisions = append ? this.revisions.concat(revisions) : revisions;
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err: any) => {
|
||||
this.loading = false;
|
||||
})
|
||||
.finally(() => {
|
||||
@ -183,7 +186,7 @@ export class HistoryListCtrl {
|
||||
this.loading = true;
|
||||
return this.historySrv
|
||||
.restoreDashboard(this.dashboard, version)
|
||||
.then(response => {
|
||||
.then((response: any) => {
|
||||
this.$location.url(locationUtil.stripBaseFromUrl(response.url)).replace();
|
||||
this.$route.reload();
|
||||
this.$rootScope.appEvent('alert-success', ['Dashboard restored', 'Restored from version ' + version]);
|
||||
|
@ -7,7 +7,7 @@ describe('historySrv', () => {
|
||||
const versionsResponse = versions();
|
||||
const restoreResponse = restore;
|
||||
|
||||
const backendSrv = {
|
||||
const backendSrv: any = {
|
||||
get: jest.fn(() => Promise.resolve({})),
|
||||
post: jest.fn(() => Promise.resolve({})),
|
||||
};
|
||||
@ -23,19 +23,19 @@ describe('historySrv', () => {
|
||||
backendSrv.get = jest.fn(() => Promise.resolve(versionsResponse));
|
||||
historySrv = new HistorySrv(backendSrv);
|
||||
|
||||
return historySrv.getHistoryList(dash, historyListOpts).then(versions => {
|
||||
return historySrv.getHistoryList(dash, historyListOpts).then((versions: any) => {
|
||||
expect(versions).toEqual(versionsResponse);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an empty array when not given an id', () => {
|
||||
return historySrv.getHistoryList(emptyDash, historyListOpts).then(versions => {
|
||||
return historySrv.getHistoryList(emptyDash, historyListOpts).then((versions: any) => {
|
||||
expect(versions).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an empty array when not given a dashboard', () => {
|
||||
return historySrv.getHistoryList(null, historyListOpts).then(versions => {
|
||||
return historySrv.getHistoryList(null, historyListOpts).then((versions: any) => {
|
||||
expect(versions).toEqual([]);
|
||||
});
|
||||
});
|
||||
@ -46,7 +46,7 @@ describe('historySrv', () => {
|
||||
const version = 6;
|
||||
backendSrv.post = jest.fn(() => Promise.resolve(restoreResponse(version)));
|
||||
historySrv = new HistorySrv(backendSrv);
|
||||
return historySrv.restoreDashboard(dash, version).then(response => {
|
||||
return historySrv.restoreDashboard(dash, version).then((response: any) => {
|
||||
expect(response).toEqual(restoreResponse(version));
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import coreModule from 'app/core/core_module';
|
||||
import { DashboardModel } from '../../state/DashboardModel';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
|
||||
export interface HistoryListOpts {
|
||||
limit: number;
|
||||
@ -32,7 +33,7 @@ export interface DiffTarget {
|
||||
|
||||
export class HistorySrv {
|
||||
/** @ngInject */
|
||||
constructor(private backendSrv) {}
|
||||
constructor(private backendSrv: BackendSrv) {}
|
||||
|
||||
getHistoryList(dashboard: DashboardModel, options: HistoryListOpts) {
|
||||
const id = dashboard && dashboard.id ? dashboard.id : void 0;
|
||||
|
@ -44,11 +44,11 @@ export function versions() {
|
||||
];
|
||||
}
|
||||
|
||||
export function compare(type) {
|
||||
export function compare(type: any) {
|
||||
return type === 'basic' ? '<div></div>' : '<pre><code></code></pre>';
|
||||
}
|
||||
|
||||
export function restore(version, restoredFrom?) {
|
||||
export function restore(version: any, restoredFrom?: any): any {
|
||||
return {
|
||||
dashboard: {
|
||||
meta: {
|
||||
|
@ -38,7 +38,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: any): DashboardModel
|
||||
return new DashboardModel(data, meta);
|
||||
}
|
||||
|
||||
function dashboardPageScenario(description, scenarioFn: (ctx: ScenarioContext) => void) {
|
||||
function dashboardPageScenario(description: string, scenarioFn: (ctx: ScenarioContext) => void) {
|
||||
describe(description, () => {
|
||||
let setupFn: () => void;
|
||||
|
||||
|
@ -48,7 +48,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: any): DashboardModel
|
||||
return new DashboardModel(data, meta);
|
||||
}
|
||||
|
||||
function dashboardGridScenario(description, scenarioFn: (ctx: ScenarioContext) => void) {
|
||||
function dashboardGridScenario(description: string, scenarioFn: (ctx: ScenarioContext) => void) {
|
||||
describe(description, () => {
|
||||
let setupFn: () => void;
|
||||
|
||||
|
@ -3,6 +3,7 @@ import React, { PureComponent } from 'react';
|
||||
import { hot } from 'react-hot-loader';
|
||||
import ReactGridLayout, { ItemCallback } from 'react-grid-layout';
|
||||
import classNames from 'classnames';
|
||||
// @ts-ignore
|
||||
import sizeMe from 'react-sizeme';
|
||||
|
||||
// Types
|
||||
|
@ -34,7 +34,7 @@ export interface State {
|
||||
|
||||
export class DashboardPanel extends PureComponent<Props, State> {
|
||||
element: HTMLElement;
|
||||
specialPanels = {};
|
||||
specialPanels: { [key: string]: Function } = {};
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
@ -21,7 +21,7 @@ export class PanelResizer extends PureComponent<Props, State> {
|
||||
throttledResizeDone: () => void;
|
||||
noStyles: object = {};
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
const { panel } = this.props;
|
||||
|
||||
|
@ -32,11 +32,11 @@ interface State {
|
||||
}
|
||||
|
||||
export class EditorTabBody extends PureComponent<Props, State> {
|
||||
static defaultProps = {
|
||||
static defaultProps: Partial<Props> = {
|
||||
toolbarItems: [],
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@ -61,10 +61,10 @@ export class EditorTabBody extends PureComponent<Props, State> {
|
||||
this.setState({ isOpen: false });
|
||||
};
|
||||
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
static getDerivedStateFromProps(props: Props, state: State) {
|
||||
if (state.openView) {
|
||||
const activeToolbarItem = props.toolbarItems.find(
|
||||
item => item.title === state.openView.title && item.icon === state.openView.icon
|
||||
(item: any) => item.title === state.openView.title && item.icon === state.openView.icon
|
||||
);
|
||||
if (activeToolbarItem) {
|
||||
return {
|
||||
|
@ -20,7 +20,7 @@ export class GeneralTab extends PureComponent<Props> {
|
||||
element: any;
|
||||
component: AngularComponent;
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ export class QueriesTab extends PureComponent<Props, State> {
|
||||
return this.datasources.find(datasource => datasource.value === panel.datasource) || this.datasources[0];
|
||||
}
|
||||
|
||||
onChangeDataSource = datasource => {
|
||||
onChangeDataSource = (datasource: any) => {
|
||||
const { panel } = this.props;
|
||||
const { currentDS } = this.state;
|
||||
|
||||
@ -194,7 +194,7 @@ export class QueriesTab extends PureComponent<Props, State> {
|
||||
);
|
||||
};
|
||||
|
||||
onAddMixedQuery = datasource => {
|
||||
onAddMixedQuery = (datasource: any) => {
|
||||
this.onAddQuery({ datasource: datasource.name });
|
||||
this.setState({ isAddingMixed: false, scrollTop: this.state.scrollTop + 10000 });
|
||||
};
|
||||
@ -203,7 +203,7 @@ export class QueriesTab extends PureComponent<Props, State> {
|
||||
this.setState({ isAddingMixed: false });
|
||||
};
|
||||
|
||||
onQueryChange = (query: DataQuery, index) => {
|
||||
onQueryChange = (query: DataQuery, index: number) => {
|
||||
this.props.panel.changeQuery(query, index);
|
||||
this.forceUpdate();
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ export class QueryInspector extends PureComponent<Props, State> {
|
||||
formattedJson: any;
|
||||
clipboard: any;
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
allNodesExpanded: null,
|
||||
@ -56,7 +56,7 @@ export class QueryInspector extends PureComponent<Props, State> {
|
||||
panel.events.off('refresh', this.onPanelRefresh);
|
||||
}
|
||||
|
||||
handleMocking(response) {
|
||||
handleMocking(response: any) {
|
||||
const { mockedResponse } = this.state;
|
||||
let mockedData;
|
||||
try {
|
||||
@ -126,7 +126,7 @@ export class QueryInspector extends PureComponent<Props, State> {
|
||||
}));
|
||||
};
|
||||
|
||||
setFormattedJson = formattedJson => {
|
||||
setFormattedJson = (formattedJson: any) => {
|
||||
this.formattedJson = formattedJson;
|
||||
};
|
||||
|
||||
@ -161,7 +161,7 @@ export class QueryInspector extends PureComponent<Props, State> {
|
||||
return 1;
|
||||
};
|
||||
|
||||
setMockedResponse = evt => {
|
||||
setMockedResponse = (evt: any) => {
|
||||
const mockedResponse = evt.target.value;
|
||||
this.setState(prevState => ({
|
||||
...prevState,
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Libraries
|
||||
import React, { PureComponent, ChangeEvent, FocusEvent } from 'react';
|
||||
import React, { PureComponent, ChangeEvent, FocusEvent, ReactText } from 'react';
|
||||
|
||||
// Utils
|
||||
import { rangeUtil } from '@grafana/data';
|
||||
@ -46,13 +46,13 @@ interface State {
|
||||
relativeTime: string;
|
||||
timeShift: string;
|
||||
cacheTimeout: string;
|
||||
maxDataPoints: string;
|
||||
maxDataPoints: string | ReactText;
|
||||
interval: string;
|
||||
hideTimeOverride: boolean;
|
||||
}
|
||||
|
||||
export class QueryOptions extends PureComponent<Props, State> {
|
||||
allOptions = {
|
||||
allOptions: any = {
|
||||
cacheTimeout: {
|
||||
label: 'Cache timeout',
|
||||
placeholder: '60',
|
||||
@ -91,7 +91,7 @@ export class QueryOptions extends PureComponent<Props, State> {
|
||||
},
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@ -147,6 +147,7 @@ export class QueryOptions extends PureComponent<Props, State> {
|
||||
onDataSourceOptionBlur = (panelKey: string) => () => {
|
||||
const { panel } = this.props;
|
||||
|
||||
// @ts-ignore
|
||||
panel[panelKey] = this.state[panelKey];
|
||||
panel.refresh();
|
||||
};
|
||||
@ -172,6 +173,7 @@ export class QueryOptions extends PureComponent<Props, State> {
|
||||
{...options}
|
||||
onChange={this.onDataSourceOptionChange(panelKey)}
|
||||
onBlur={this.onDataSourceOptionBlur(panelKey)}
|
||||
// @ts-ignore
|
||||
value={this.state[panelKey]}
|
||||
/>
|
||||
);
|
||||
|
@ -14,7 +14,7 @@ describe('ChangeTracker', () => {
|
||||
let location;
|
||||
const timeout = () => {};
|
||||
let tracker: ChangeTracker;
|
||||
let dash;
|
||||
let dash: any;
|
||||
let scope;
|
||||
|
||||
beforeEach(() => {
|
||||
@ -57,7 +57,7 @@ describe('ChangeTracker', () => {
|
||||
path: jest.fn(),
|
||||
};
|
||||
|
||||
tracker = new ChangeTracker(dash, scope, undefined, location, window, timeout, contextSrv, rootScope);
|
||||
tracker = new ChangeTracker(dash, scope, undefined, location as any, window, timeout, contextSrv, rootScope);
|
||||
});
|
||||
|
||||
it('No changes should not have changes', () => {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import angular from 'angular';
|
||||
import angular, { ILocationService } from 'angular';
|
||||
import _ from 'lodash';
|
||||
import { DashboardModel } from '../state/DashboardModel';
|
||||
import { ContextSrv } from 'app/core/services/context_srv';
|
||||
|
||||
export class ChangeTracker {
|
||||
current: any;
|
||||
@ -12,14 +13,14 @@ export class ChangeTracker {
|
||||
|
||||
/** @ngInject */
|
||||
constructor(
|
||||
dashboard,
|
||||
scope,
|
||||
originalCopyDelay,
|
||||
private $location,
|
||||
$window,
|
||||
private $timeout,
|
||||
private contextSrv,
|
||||
private $rootScope
|
||||
dashboard: DashboardModel,
|
||||
scope: any,
|
||||
originalCopyDelay: any,
|
||||
private $location: ILocationService,
|
||||
$window: any,
|
||||
private $timeout: any,
|
||||
private contextSrv: ContextSrv,
|
||||
private $rootScope: any
|
||||
) {
|
||||
this.$location = $location;
|
||||
this.$window = $window;
|
||||
@ -44,7 +45,7 @@ export class ChangeTracker {
|
||||
return undefined;
|
||||
};
|
||||
|
||||
scope.$on('$locationChangeStart', (event, next) => {
|
||||
scope.$on('$locationChangeStart', (event: any, next: any) => {
|
||||
// check if we should look for changes
|
||||
if (this.originalPath === $location.path()) {
|
||||
return true;
|
||||
@ -92,7 +93,7 @@ export class ChangeTracker {
|
||||
}
|
||||
|
||||
// remove stuff that should not count in diff
|
||||
cleanDashboardFromIgnoredChanges(dashData) {
|
||||
cleanDashboardFromIgnoredChanges(dashData: any) {
|
||||
// need to new up the domain model class to get access to expand / collapse row logic
|
||||
const model = new DashboardModel(dashData);
|
||||
|
||||
|
@ -1,27 +1,31 @@
|
||||
/* tslint:disable:import-blacklist */
|
||||
import angular from 'angular';
|
||||
import angular, { IQService } from 'angular';
|
||||
import moment from 'moment';
|
||||
import _ from 'lodash';
|
||||
import $ from 'jquery';
|
||||
import kbn from 'app/core/utils/kbn';
|
||||
import { dateMath } from '@grafana/data';
|
||||
import impressionSrv from 'app/core/services/impression_srv';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { DashboardSrv } from './DashboardSrv';
|
||||
import DatasourceSrv from 'app/features/plugins/datasource_srv';
|
||||
import { UrlQueryValue } from '@grafana/runtime';
|
||||
|
||||
export class DashboardLoaderSrv {
|
||||
/** @ngInject */
|
||||
constructor(
|
||||
private backendSrv,
|
||||
private dashboardSrv,
|
||||
private datasourceSrv,
|
||||
private $http,
|
||||
private $q,
|
||||
private $timeout,
|
||||
contextSrv,
|
||||
private $routeParams,
|
||||
private $rootScope
|
||||
private backendSrv: BackendSrv,
|
||||
private dashboardSrv: DashboardSrv,
|
||||
private datasourceSrv: DatasourceSrv,
|
||||
private $http: any,
|
||||
private $q: IQService,
|
||||
private $timeout: any,
|
||||
contextSrv: any,
|
||||
private $routeParams: any,
|
||||
private $rootScope: any
|
||||
) {}
|
||||
|
||||
_dashboardLoadFailed(title, snapshot?) {
|
||||
_dashboardLoadFailed(title: string, snapshot?: boolean) {
|
||||
snapshot = snapshot || false;
|
||||
return {
|
||||
meta: {
|
||||
@ -32,11 +36,11 @@ export class DashboardLoaderSrv {
|
||||
canEdit: false,
|
||||
dashboardNotFound: true,
|
||||
},
|
||||
dashboard: { title: title },
|
||||
dashboard: { title },
|
||||
};
|
||||
}
|
||||
|
||||
loadDashboard(type, slug, uid) {
|
||||
loadDashboard(type: UrlQueryValue, slug: any, uid: any) {
|
||||
let promise;
|
||||
|
||||
if (type === 'script') {
|
||||
@ -48,7 +52,7 @@ export class DashboardLoaderSrv {
|
||||
} else {
|
||||
promise = this.backendSrv
|
||||
.getDashboardByUid(uid)
|
||||
.then(result => {
|
||||
.then((result: any) => {
|
||||
if (result.meta.isFolder) {
|
||||
this.$rootScope.appEvent('alert-error', ['Dashboard not found']);
|
||||
throw new Error('Dashboard not found');
|
||||
@ -60,7 +64,7 @@ export class DashboardLoaderSrv {
|
||||
});
|
||||
}
|
||||
|
||||
promise.then(result => {
|
||||
promise.then((result: any) => {
|
||||
if (result.meta.dashboardNotFound !== true) {
|
||||
impressionSrv.addDashboardImpression(result.dashboard.id);
|
||||
}
|
||||
@ -71,13 +75,13 @@ export class DashboardLoaderSrv {
|
||||
return promise;
|
||||
}
|
||||
|
||||
_loadScriptedDashboard(file) {
|
||||
_loadScriptedDashboard(file: string) {
|
||||
const url = 'public/dashboards/' + file.replace(/\.(?!js)/, '/') + '?' + new Date().getTime();
|
||||
|
||||
return this.$http({ url: url, method: 'GET' })
|
||||
.then(this._executeScript.bind(this))
|
||||
.then(
|
||||
result => {
|
||||
(result: any) => {
|
||||
return {
|
||||
meta: {
|
||||
fromScript: true,
|
||||
@ -88,7 +92,7 @@ export class DashboardLoaderSrv {
|
||||
dashboard: result.data,
|
||||
};
|
||||
},
|
||||
err => {
|
||||
(err: any) => {
|
||||
console.log('Script dashboard error ' + err);
|
||||
this.$rootScope.appEvent('alert-error', [
|
||||
'Script Error',
|
||||
@ -99,7 +103,7 @@ export class DashboardLoaderSrv {
|
||||
);
|
||||
}
|
||||
|
||||
_executeScript(result) {
|
||||
_executeScript(result: any) {
|
||||
const services = {
|
||||
dashboardSrv: this.dashboardSrv,
|
||||
datasourceSrv: this.datasourceSrv,
|
||||
@ -125,7 +129,7 @@ export class DashboardLoaderSrv {
|
||||
// Handle async dashboard scripts
|
||||
if (_.isFunction(scriptResult)) {
|
||||
const deferred = this.$q.defer();
|
||||
scriptResult(dashboard => {
|
||||
scriptResult((dashboard: any) => {
|
||||
this.$timeout(() => {
|
||||
deferred.resolve({ data: dashboard });
|
||||
});
|
||||
|
@ -4,12 +4,14 @@ import locationUtil from 'app/core/utils/location_util';
|
||||
import { DashboardModel } from '../state/DashboardModel';
|
||||
import { removePanel } from '../utils/panel';
|
||||
import { DashboardMeta } from 'app/types';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { ILocationService } from 'angular';
|
||||
|
||||
export class DashboardSrv {
|
||||
dashboard: DashboardModel;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private backendSrv, private $rootScope, private $location) {
|
||||
constructor(private backendSrv: BackendSrv, private $rootScope: any, private $location: ILocationService) {
|
||||
appEvents.on('save-dashboard', this.saveDashboard.bind(this), $rootScope);
|
||||
appEvents.on('panel-change-view', this.onPanelChangeView);
|
||||
appEvents.on('remove-panel', this.onRemovePanel);
|
||||
@ -35,7 +37,7 @@ export class DashboardSrv {
|
||||
removePanel(dashboard, dashboard.getPanelById(panelId), true);
|
||||
};
|
||||
|
||||
onPanelChangeView = options => {
|
||||
onPanelChangeView = (options: any) => {
|
||||
const urlParams = this.$location.search();
|
||||
|
||||
// handle toggle logic
|
||||
@ -75,7 +77,11 @@ export class DashboardSrv {
|
||||
this.$location.search(urlParams);
|
||||
};
|
||||
|
||||
handleSaveDashboardError(clone, options, err) {
|
||||
handleSaveDashboardError(
|
||||
clone: any,
|
||||
options: { overwrite?: any },
|
||||
err: { data: { status: string; message: any }; isHandled: boolean }
|
||||
) {
|
||||
options = options || {};
|
||||
options.overwrite = true;
|
||||
|
||||
@ -129,7 +135,7 @@ export class DashboardSrv {
|
||||
}
|
||||
}
|
||||
|
||||
postSave(clone, data) {
|
||||
postSave(clone: DashboardModel, data: { version: number; url: string }) {
|
||||
this.dashboard.version = data.version;
|
||||
|
||||
// important that these happens before location redirect below
|
||||
@ -146,7 +152,7 @@ export class DashboardSrv {
|
||||
return this.dashboard;
|
||||
}
|
||||
|
||||
save(clone, options) {
|
||||
save(clone: any, options: { overwrite?: any; folderId?: any }) {
|
||||
options = options || {};
|
||||
options.folderId = options.folderId >= 0 ? options.folderId : this.dashboard.meta.folderId || clone.folderId;
|
||||
|
||||
@ -156,7 +162,7 @@ export class DashboardSrv {
|
||||
.catch(this.handleSaveDashboardError.bind(this, clone, options));
|
||||
}
|
||||
|
||||
saveDashboard(options?, clone?) {
|
||||
saveDashboard(options?: { overwrite?: any; folderId?: any; makeEditable?: any }, clone?: DashboardModel) {
|
||||
if (clone) {
|
||||
this.setCurrent(this.create(clone, this.dashboard.meta));
|
||||
}
|
||||
@ -204,7 +210,7 @@ export class DashboardSrv {
|
||||
});
|
||||
}
|
||||
|
||||
starDashboard(dashboardId, isStarred) {
|
||||
starDashboard(dashboardId: string, isStarred: any) {
|
||||
let promise;
|
||||
|
||||
if (isStarred) {
|
||||
@ -217,7 +223,7 @@ export class DashboardSrv {
|
||||
});
|
||||
}
|
||||
|
||||
return promise.then(res => {
|
||||
return promise.then((res: boolean) => {
|
||||
if (this.dashboard && this.dashboard.id === dashboardId) {
|
||||
this.dashboard.meta.isStarred = res;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ describe('timeSrv', () => {
|
||||
search: jest.fn(() => ({})),
|
||||
};
|
||||
|
||||
let timeSrv;
|
||||
let timeSrv: TimeSrv;
|
||||
|
||||
const _dashboard: any = {
|
||||
time: { from: 'now-6h', to: 'now' },
|
||||
|
@ -1,9 +1,20 @@
|
||||
import angular from 'angular';
|
||||
import angular, { IQService, ILocationService } from 'angular';
|
||||
import { ChangeTracker } from './ChangeTracker';
|
||||
import { ContextSrv } from 'app/core/services/context_srv';
|
||||
import { DashboardSrv } from './DashboardSrv';
|
||||
|
||||
/** @ngInject */
|
||||
export function unsavedChangesSrv(this: any, $rootScope, $q, $location, $timeout, contextSrv, dashboardSrv, $window) {
|
||||
this.init = function(dashboard, scope) {
|
||||
export function unsavedChangesSrv(
|
||||
this: any,
|
||||
$rootScope: any,
|
||||
$q: IQService,
|
||||
$location: ILocationService,
|
||||
$timeout: any,
|
||||
contextSrv: ContextSrv,
|
||||
dashboardSrv: DashboardSrv,
|
||||
$window: any
|
||||
) {
|
||||
this.init = function(dashboard: any, scope: any) {
|
||||
this.tracker = new ChangeTracker(dashboard, scope, 1000, $location, $window, $timeout, contextSrv, $rootScope);
|
||||
return this.tracker;
|
||||
};
|
||||
|
@ -9,10 +9,10 @@ jest.mock('app/core/services/context_srv', () => ({}));
|
||||
|
||||
describe('DashboardModel', () => {
|
||||
describe('when creating dashboard with old schema', () => {
|
||||
let model;
|
||||
let graph;
|
||||
let singlestat;
|
||||
let table;
|
||||
let model: any;
|
||||
let graph: any;
|
||||
let singlestat: any;
|
||||
let table: any;
|
||||
|
||||
beforeEach(() => {
|
||||
model = new DashboardModel({
|
||||
@ -142,7 +142,7 @@ describe('DashboardModel', () => {
|
||||
});
|
||||
|
||||
describe('when migrating to the grid layout', () => {
|
||||
let model;
|
||||
let model: any;
|
||||
|
||||
beforeEach(() => {
|
||||
model = {
|
||||
@ -385,7 +385,7 @@ describe('DashboardModel', () => {
|
||||
});
|
||||
|
||||
describe('when migrating panel links', () => {
|
||||
let model;
|
||||
let model: any;
|
||||
|
||||
beforeEach(() => {
|
||||
model = new DashboardModel({
|
||||
@ -439,15 +439,16 @@ describe('DashboardModel', () => {
|
||||
});
|
||||
});
|
||||
|
||||
function createRow(options, panelDescriptions: any[]) {
|
||||
function createRow(options: any, panelDescriptions: any[]) {
|
||||
const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN;
|
||||
const { collapse, showTitle, title, repeat, repeatIteration } = options;
|
||||
let { height } = options;
|
||||
height = height * PANEL_HEIGHT_STEP;
|
||||
const panels = [];
|
||||
const panels: any[] = [];
|
||||
_.each(panelDescriptions, panelDesc => {
|
||||
const panel = { span: panelDesc[0] };
|
||||
if (panelDesc.length > 1) {
|
||||
//@ts-ignore
|
||||
panel['height'] = panelDesc[1] * PANEL_HEIGHT_STEP;
|
||||
}
|
||||
panels.push(panel);
|
||||
|
@ -48,7 +48,7 @@ export class DashboardMigrator {
|
||||
}
|
||||
}
|
||||
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
// rename panel type
|
||||
if (panel.type === 'graphite') {
|
||||
panel.type = 'graph';
|
||||
@ -95,7 +95,7 @@ export class DashboardMigrator {
|
||||
if (oldVersion < 3) {
|
||||
// ensure panel ids
|
||||
let maxId = this.dashboard.getNextPanelId();
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (!panel.id) {
|
||||
panel.id = maxId;
|
||||
maxId += 1;
|
||||
@ -106,7 +106,7 @@ export class DashboardMigrator {
|
||||
// schema version 4 changes
|
||||
if (oldVersion < 4) {
|
||||
// move aliasYAxis changes
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (panel.type !== 'graph') {
|
||||
return;
|
||||
}
|
||||
@ -151,7 +151,7 @@ export class DashboardMigrator {
|
||||
}
|
||||
|
||||
// ensure query refIds
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
_.each(panel.targets, target => {
|
||||
if (!target.refId) {
|
||||
target.refId = panel.getNextQueryLetter && panel.getNextQueryLetter();
|
||||
@ -161,7 +161,7 @@ export class DashboardMigrator {
|
||||
}
|
||||
|
||||
if (oldVersion < 8) {
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
_.each(panel.targets, target => {
|
||||
// update old influxdb query schema
|
||||
if (target.fields && target.tags && target.groupBy) {
|
||||
@ -206,7 +206,7 @@ export class DashboardMigrator {
|
||||
// schema version 9 changes
|
||||
if (oldVersion < 9) {
|
||||
// move aliasYAxis changes
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (panel.type !== 'singlestat' && panel.thresholds !== '') {
|
||||
return;
|
||||
}
|
||||
@ -225,7 +225,7 @@ export class DashboardMigrator {
|
||||
// schema version 10 changes
|
||||
if (oldVersion < 10) {
|
||||
// move aliasYAxis changes
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (panel.type !== 'table') {
|
||||
return;
|
||||
}
|
||||
@ -259,7 +259,7 @@ export class DashboardMigrator {
|
||||
|
||||
if (oldVersion < 12) {
|
||||
// update graph yaxes changes
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (panel.type !== 'graph') {
|
||||
return;
|
||||
}
|
||||
@ -308,7 +308,7 @@ export class DashboardMigrator {
|
||||
|
||||
if (oldVersion < 13) {
|
||||
// update graph yaxes changes
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (panel.type !== 'graph') {
|
||||
return;
|
||||
}
|
||||
@ -380,7 +380,7 @@ export class DashboardMigrator {
|
||||
}
|
||||
|
||||
if (oldVersion < 17) {
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (panel.minSpan) {
|
||||
const max = GRID_COLUMN_COUNT / panel.minSpan;
|
||||
const factors = getFactors(GRID_COLUMN_COUNT);
|
||||
@ -399,7 +399,7 @@ export class DashboardMigrator {
|
||||
|
||||
if (oldVersion < 18) {
|
||||
// migrate change to gauge options
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (panel['options-gauge']) {
|
||||
panel.options = panel['options-gauge'];
|
||||
panel.options.valueOptions = {
|
||||
@ -429,7 +429,7 @@ export class DashboardMigrator {
|
||||
|
||||
if (oldVersion < 19) {
|
||||
// migrate change to gauge options
|
||||
panelUpgrades.push(panel => {
|
||||
panelUpgrades.push((panel: any) => {
|
||||
if (panel.links && _.isArray(panel.links)) {
|
||||
panel.links = panel.links.map(upgradePanelLink);
|
||||
}
|
||||
@ -452,7 +452,7 @@ export class DashboardMigrator {
|
||||
}
|
||||
}
|
||||
|
||||
upgradeToGridLayout(old) {
|
||||
upgradeToGridLayout(old: any) {
|
||||
let yPos = 0;
|
||||
const widthFactor = GRID_COLUMN_COUNT / 12;
|
||||
|
||||
@ -541,7 +541,7 @@ export class DashboardMigrator {
|
||||
}
|
||||
}
|
||||
|
||||
function getGridHeight(height) {
|
||||
function getGridHeight(height: number | string) {
|
||||
if (_.isString(height)) {
|
||||
height = parseInt(height.replace('px', ''), 10);
|
||||
}
|
||||
@ -569,7 +569,7 @@ class RowArea {
|
||||
yPos: number;
|
||||
height: number;
|
||||
|
||||
constructor(height, width = GRID_COLUMN_COUNT, rowYPos = 0) {
|
||||
constructor(height: number, width = GRID_COLUMN_COUNT, rowYPos = 0) {
|
||||
this.area = new Array(width).fill(0);
|
||||
this.yPos = rowYPos;
|
||||
this.height = height;
|
||||
@ -582,7 +582,7 @@ class RowArea {
|
||||
/**
|
||||
* Update area after adding the panel.
|
||||
*/
|
||||
addPanel(gridPos) {
|
||||
addPanel(gridPos: any) {
|
||||
for (let i = gridPos.x; i < gridPos.x + gridPos.w; i++) {
|
||||
if (!this.area[i] || gridPos.y + gridPos.h - this.yPos > this.area[i]) {
|
||||
this.area[i] = gridPos.y + gridPos.h - this.yPos;
|
||||
@ -594,7 +594,7 @@ class RowArea {
|
||||
/**
|
||||
* Calculate position for the new panel in the row.
|
||||
*/
|
||||
getPanelPosition(panelHeight, panelWidth, callOnce = false) {
|
||||
getPanelPosition(panelHeight: number, panelWidth: number, callOnce = false): any {
|
||||
let startPlace, endPlace;
|
||||
let place;
|
||||
for (let i = this.area.length - 1; i >= 0; i--) {
|
||||
|
@ -5,7 +5,7 @@ import { expect } from 'test/lib/common';
|
||||
jest.mock('app/core/services/context_srv', () => ({}));
|
||||
|
||||
describe('given dashboard with panel repeat', () => {
|
||||
let dashboard;
|
||||
let dashboard: DashboardModel;
|
||||
|
||||
beforeEach(() => {
|
||||
const dashboardJSON = {
|
||||
@ -56,7 +56,7 @@ describe('given dashboard with panel repeat', () => {
|
||||
});
|
||||
|
||||
describe('given dashboard with panel repeat in horizontal direction', () => {
|
||||
let dashboard;
|
||||
let dashboard: any;
|
||||
|
||||
beforeEach(() => {
|
||||
dashboard = new DashboardModel({
|
||||
@ -188,7 +188,7 @@ describe('given dashboard with panel repeat in horizontal direction', () => {
|
||||
});
|
||||
|
||||
describe('given dashboard with panel repeat in vertical direction', () => {
|
||||
let dashboard;
|
||||
let dashboard: any;
|
||||
|
||||
beforeEach(() => {
|
||||
dashboard = new DashboardModel({
|
||||
@ -230,7 +230,7 @@ describe('given dashboard with panel repeat in vertical direction', () => {
|
||||
});
|
||||
|
||||
describe('given dashboard with row repeat and panel repeat in horizontal direction', () => {
|
||||
let dashboard, dashboardJSON;
|
||||
let dashboard: any, dashboardJSON;
|
||||
|
||||
beforeEach(() => {
|
||||
dashboardJSON = {
|
||||
@ -312,7 +312,7 @@ describe('given dashboard with row repeat and panel repeat in horizontal directi
|
||||
});
|
||||
|
||||
describe('given dashboard with row repeat', () => {
|
||||
let dashboard, dashboardJSON;
|
||||
let dashboard: any, dashboardJSON: any;
|
||||
|
||||
beforeEach(() => {
|
||||
dashboardJSON = {
|
||||
@ -519,7 +519,7 @@ describe('given dashboard with row repeat', () => {
|
||||
});
|
||||
|
||||
describe('given dashboard with row and panel repeat', () => {
|
||||
let dashboard, dashboardJSON;
|
||||
let dashboard: any, dashboardJSON: any;
|
||||
|
||||
beforeEach(() => {
|
||||
dashboardJSON = {
|
||||
|
@ -5,8 +5,8 @@ class TablePanelCtrl {}
|
||||
|
||||
describe('PanelModel', () => {
|
||||
describe('when creating new panel model', () => {
|
||||
let model;
|
||||
let modelJson;
|
||||
let model: any;
|
||||
let modelJson: any;
|
||||
let persistedOptionsMock;
|
||||
const defaultOptionsMock = {
|
||||
fieldOptions: {
|
||||
|
@ -95,7 +95,7 @@ function makeSeriesStub(refId: string) {
|
||||
fields: [{ name: 'a' }],
|
||||
rows: [],
|
||||
refId,
|
||||
};
|
||||
} as any;
|
||||
}
|
||||
|
||||
describe('stream handling', () => {
|
||||
|
@ -336,7 +336,7 @@ export function toDataQueryError(err: any): DataQueryError {
|
||||
}
|
||||
|
||||
function translateToLegacyData(data: DataQueryResponseData) {
|
||||
return data.map(v => {
|
||||
return data.map((v: any) => {
|
||||
if (isDataFrame(v)) {
|
||||
return toLegacyResponseData(v);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ export function addDashboardPermission(dashboardId: number, newItem: NewDashboar
|
||||
};
|
||||
}
|
||||
|
||||
export function importDashboard(data, dashboardTitle: string): ThunkResult<void> {
|
||||
export function importDashboard(data: any, dashboardTitle: string): ThunkResult<void> {
|
||||
return async dispatch => {
|
||||
await getBackendSrv().post('/api/dashboards/import', data);
|
||||
dispatch(notifyApp(createSuccessNotification('Dashboard Imported', dashboardTitle)));
|
||||
|
@ -87,7 +87,7 @@ function describeInitScenario(description: string, scenarioFn: ScenarioFn) {
|
||||
setupFn();
|
||||
|
||||
const store = mockStore(ctx.storeState);
|
||||
|
||||
// @ts-ignore
|
||||
await store.dispatch(initDashboard(ctx.args));
|
||||
|
||||
ctx.actions = store.getActions();
|
||||
|
@ -42,10 +42,10 @@ export class DataSourceDashboards extends PureComponent<Props> {
|
||||
|
||||
onImport = (dashboard: PluginDashboard, overwrite: boolean) => {
|
||||
const { dataSource, importDashboard } = this.props;
|
||||
const data = {
|
||||
const data: any = {
|
||||
pluginId: dashboard.pluginId,
|
||||
path: dashboard.path,
|
||||
overwrite: overwrite,
|
||||
overwrite,
|
||||
inputs: [],
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { DataSourceSettings } from '@grafana/ui';
|
||||
|
||||
export const getMockDataSources = (amount: number): DataSourceSettings[] => {
|
||||
export const getMockDataSources = (amount: number) => {
|
||||
const dataSources = [];
|
||||
|
||||
for (let i = 0; i <= amount; i++) {
|
||||
@ -22,7 +22,7 @@ export const getMockDataSources = (amount: number): DataSourceSettings[] => {
|
||||
});
|
||||
}
|
||||
|
||||
return dataSources;
|
||||
return dataSources as DataSourceSettings[];
|
||||
};
|
||||
|
||||
export const getMockDataSource = (): DataSourceSettings => {
|
||||
|
@ -1,29 +1,31 @@
|
||||
import { DataSourceSettings, DataSourcePluginMeta } from '@grafana/ui';
|
||||
import { DataSourcesState } from '../../../types/datasources';
|
||||
import { UrlQueryValue } from '@grafana/runtime';
|
||||
|
||||
export const getDataSources = state => {
|
||||
export const getDataSources = (state: DataSourcesState) => {
|
||||
const regex = new RegExp(state.searchQuery, 'i');
|
||||
|
||||
return state.dataSources.filter(dataSource => {
|
||||
return state.dataSources.filter((dataSource: DataSourceSettings) => {
|
||||
return regex.test(dataSource.name) || regex.test(dataSource.database);
|
||||
});
|
||||
};
|
||||
|
||||
export const getDataSourceTypes = state => {
|
||||
export const getDataSourceTypes = (state: DataSourcesState) => {
|
||||
const regex = new RegExp(state.dataSourceTypeSearchQuery, 'i');
|
||||
|
||||
return state.dataSourceTypes.filter(type => {
|
||||
return state.dataSourceTypes.filter((type: DataSourcePluginMeta) => {
|
||||
return regex.test(type.name);
|
||||
});
|
||||
};
|
||||
|
||||
export const getDataSource = (state, dataSourceId): DataSourceSettings | null => {
|
||||
if (state.dataSource.id === parseInt(dataSourceId, 10)) {
|
||||
export const getDataSource = (state: DataSourcesState, dataSourceId: UrlQueryValue): DataSourceSettings | null => {
|
||||
if (state.dataSource.id === parseInt(dataSourceId as string, 10)) {
|
||||
return state.dataSource;
|
||||
}
|
||||
return {} as DataSourceSettings;
|
||||
};
|
||||
|
||||
export const getDataSourceMeta = (state, type): DataSourcePluginMeta => {
|
||||
export const getDataSourceMeta = (state: DataSourcesState, type: string): DataSourcePluginMeta => {
|
||||
if (state.dataSourceMeta.id === type) {
|
||||
return state.dataSourceMeta;
|
||||
}
|
||||
@ -31,6 +33,6 @@ export const getDataSourceMeta = (state, type): DataSourcePluginMeta => {
|
||||
return {} as DataSourcePluginMeta;
|
||||
};
|
||||
|
||||
export const getDataSourcesSearchQuery = state => state.searchQuery;
|
||||
export const getDataSourcesLayoutMode = state => state.layoutMode;
|
||||
export const getDataSourcesCount = state => state.dataSourcesCount;
|
||||
export const getDataSourcesSearchQuery = (state: DataSourcesState) => state.searchQuery;
|
||||
export const getDataSourcesLayoutMode = (state: DataSourcesState) => state.layoutMode;
|
||||
export const getDataSourcesCount = (state: DataSourcesState) => state.dataSourcesCount;
|
||||
|
@ -36,7 +36,7 @@ export class AdHocFilterField<
|
||||
|
||||
componentDidUpdate(prevProps: Props) {
|
||||
if (_.isEqual(prevProps.extendedOptions, this.props.extendedOptions) === false) {
|
||||
const pairs = [];
|
||||
const pairs: any[] = [];
|
||||
|
||||
this.setState({ pairs }, () => this.props.onPairsChanged(pairs));
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import React, { Component } from 'react';
|
||||
|
||||
export default class ErrorBoundary extends Component<{}, any> {
|
||||
constructor(props) {
|
||||
constructor(props: {}) {
|
||||
super(props);
|
||||
this.state = { error: null, errorInfo: null };
|
||||
}
|
||||
|
||||
componentDidCatch(error, errorInfo) {
|
||||
componentDidCatch(error: any, errorInfo: any) {
|
||||
// Catch errors in any components below and re-render with error message
|
||||
this.setState({
|
||||
error: error,
|
||||
errorInfo: errorInfo,
|
||||
error,
|
||||
errorInfo,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ export class UnConnectedExploreToolbar extends PureComponent<Props, {}> {
|
||||
super(props);
|
||||
}
|
||||
|
||||
onChangeDatasource = async option => {
|
||||
onChangeDatasource = async (option: { value: any }) => {
|
||||
this.props.changeDatasource(this.props.exploreId, option.value);
|
||||
};
|
||||
|
||||
|
@ -14,7 +14,7 @@ import TimeSeries from 'app/core/time_series2';
|
||||
const MAX_NUMBER_OF_TIME_SERIES = 20;
|
||||
|
||||
// Copied from graph.ts
|
||||
function time_format(ticks, min, max) {
|
||||
function time_format(ticks: number, min: number, max: number) {
|
||||
if (min && max && ticks) {
|
||||
const range = max - min;
|
||||
const secPerTick = range / ticks / 1000;
|
||||
@ -39,7 +39,7 @@ function time_format(ticks, min, max) {
|
||||
return '%H:%M';
|
||||
}
|
||||
|
||||
const FLOT_OPTIONS = {
|
||||
const FLOT_OPTIONS: any = {
|
||||
legend: {
|
||||
show: false,
|
||||
},
|
||||
@ -94,9 +94,9 @@ interface GraphState {
|
||||
|
||||
export class Graph extends PureComponent<GraphProps, GraphState> {
|
||||
$el: any;
|
||||
dynamicOptions = null;
|
||||
dynamicOptions: any = null;
|
||||
|
||||
state = {
|
||||
state: GraphState = {
|
||||
hiddenSeries: [],
|
||||
showAllTimeSeries: false,
|
||||
};
|
||||
@ -130,7 +130,7 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
|
||||
this.$el.unbind('plotselected', this.onPlotSelected);
|
||||
}
|
||||
|
||||
onPlotSelected = (event: JQueryEventObject, ranges) => {
|
||||
onPlotSelected = (event: JQueryEventObject, ranges: { xaxis: { from: number; to: number } }) => {
|
||||
const { onChangeTime } = this.props;
|
||||
if (onChangeTime) {
|
||||
this.props.onChangeTime({
|
||||
|
@ -69,9 +69,10 @@ export class GraphContainer extends PureComponent<GraphContainerProps> {
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state: StoreState, { exploreId }) {
|
||||
function mapStateToProps(state: StoreState, { exploreId }: { exploreId: string }) {
|
||||
const explore = state.explore;
|
||||
const { split } = explore;
|
||||
// @ts-ignore
|
||||
const item: ExploreItemState = explore[exploreId];
|
||||
const { graphResult, loadingState, showingGraph, showingTable, absoluteRange } = item;
|
||||
const loading = loadingState === LoadingState.Loading || loadingState === LoadingState.Streaming;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function({ value }) {
|
||||
export default function({ value }: any) {
|
||||
return (
|
||||
<div>
|
||||
<pre>{JSON.stringify(value, undefined, 2)}</pre>
|
||||
|
@ -18,7 +18,7 @@ interface State {
|
||||
}
|
||||
|
||||
export class LogLabel extends PureComponent<Props, State> {
|
||||
state = {
|
||||
state: State = {
|
||||
stats: null,
|
||||
showStats: false,
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ function convertCSSToStyle(css: string): Style {
|
||||
|
||||
if (match && match[1] && match[2]) {
|
||||
const key = match[1].replace(/-(a-z)/g, (_, character) => character.toUpperCase());
|
||||
// @ts-ignore
|
||||
accumulated[key] = match[2];
|
||||
}
|
||||
|
||||
@ -33,7 +34,7 @@ interface State {
|
||||
}
|
||||
|
||||
export class LogMessageAnsi extends PureComponent<Props, State> {
|
||||
state = {
|
||||
state: State = {
|
||||
chunks: [],
|
||||
prevValue: '',
|
||||
};
|
||||
|
@ -136,7 +136,7 @@ export default class Logs extends PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
onToggleLogLevel = (rawLevel: string, hiddenRawLevels: string[]) => {
|
||||
const hiddenLogLevels: LogLevel[] = hiddenRawLevels.map(level => LogLevel[level]);
|
||||
const hiddenLogLevels: LogLevel[] = hiddenRawLevels.map((level: LogLevel) => LogLevel[level]);
|
||||
this.props.onToggleLogLevel(hiddenLogLevels);
|
||||
};
|
||||
|
||||
@ -217,12 +217,13 @@ export default class Logs extends PureComponent<Props, State> {
|
||||
<Switch label="Time" checked={showTime} onChange={this.onChangeTime} transparent />
|
||||
<Switch label="Labels" checked={showLabels} onChange={this.onChangeLabels} transparent />
|
||||
<ToggleButtonGroup label="Dedup" transparent={true}>
|
||||
{Object.keys(LogsDedupStrategy).map((dedupType, i) => (
|
||||
{Object.keys(LogsDedupStrategy).map((dedupType: string, i) => (
|
||||
<ToggleButton
|
||||
key={i}
|
||||
value={dedupType}
|
||||
onChange={this.onChangeDedup}
|
||||
selected={dedupStrategy === dedupType}
|
||||
// @ts-ignore
|
||||
tooltip={LogsDedupDescription[dedupType]}
|
||||
>
|
||||
{dedupType}
|
||||
|
@ -77,7 +77,7 @@ export class LogsContainer extends PureComponent<LogsContainerProps> {
|
||||
});
|
||||
};
|
||||
|
||||
getLogRowContext = async (row: LogRowModel, options?: any) => {
|
||||
getLogRowContext = async (row: LogRowModel, options?: any): Promise<any> => {
|
||||
const { datasourceInstance } = this.props;
|
||||
|
||||
if (datasourceInstance) {
|
||||
@ -142,8 +142,9 @@ export class LogsContainer extends PureComponent<LogsContainerProps> {
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state: StoreState, { exploreId }) {
|
||||
function mapStateToProps(state: StoreState, { exploreId }: { exploreId: string }) {
|
||||
const explore = state.explore;
|
||||
// @ts-ignore
|
||||
const item: ExploreItemState = explore[exploreId];
|
||||
const {
|
||||
logsHighlighterExpressions,
|
||||
|
@ -140,6 +140,7 @@ export class QueryRow extends PureComponent<QueryRowProps, QueryRowState> {
|
||||
<div className="query-row">
|
||||
<div className="query-row-field flex-shrink-1">
|
||||
{QueryField ? (
|
||||
//@ts-ignore
|
||||
<QueryField
|
||||
datasource={datasourceInstance}
|
||||
datasourceStatus={datasourceStatus}
|
||||
|
@ -4,7 +4,7 @@ import ElapsedTime from './ElapsedTime';
|
||||
import { LoadingState } from '@grafana/data';
|
||||
import { PanelData } from '@grafana/ui';
|
||||
|
||||
function formatLatency(value) {
|
||||
function formatLatency(value: number) {
|
||||
return `${(value / 1000).toFixed(1)}s`;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import React, { PureComponent } from 'react';
|
||||
import ReactTable from 'react-table';
|
||||
import ReactTable, { RowInfo } from 'react-table';
|
||||
|
||||
import TableModel from 'app/core/table_model';
|
||||
|
||||
@ -14,12 +14,12 @@ interface TableProps {
|
||||
onClickCell?: (columnKey: string, rowValue: string) => void;
|
||||
}
|
||||
|
||||
function prepareRows(rows, columnNames) {
|
||||
function prepareRows(rows: any[], columnNames: string[]) {
|
||||
return rows.map(cells => _.zipObject(columnNames, cells));
|
||||
}
|
||||
|
||||
export default class Table extends PureComponent<TableProps> {
|
||||
getCellProps = (state, rowInfo, column) => {
|
||||
getCellProps = (state: any, rowInfo: RowInfo, column: any) => {
|
||||
return {
|
||||
onClick: (e: React.SyntheticEvent) => {
|
||||
// Only handle click on link, not the cell
|
||||
@ -44,7 +44,7 @@ export default class Table extends PureComponent<TableProps> {
|
||||
accessor: text,
|
||||
className: VALUE_REGEX.test(text) ? 'text-right' : '',
|
||||
show: text !== 'Time',
|
||||
Cell: row => (
|
||||
Cell: (row: any) => (
|
||||
<span className={filterable ? 'link' : ''} title={text + ': ' + row.value}>
|
||||
{row.value}
|
||||
</span>
|
||||
|
@ -36,8 +36,9 @@ export class TableContainer extends PureComponent<TableContainerProps> {
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state: StoreState, { exploreId }) {
|
||||
function mapStateToProps(state: StoreState, { exploreId }: { exploreId: string }) {
|
||||
const explore = state.explore;
|
||||
// @ts-ignore
|
||||
const item: ExploreItemState = explore[exploreId];
|
||||
const { loadingState, showingTable, tableResult } = item;
|
||||
const loading =
|
||||
|
@ -1,3 +1,4 @@
|
||||
// @ts-ignore
|
||||
import Plain from 'slate-plain-serializer';
|
||||
|
||||
import BracesPlugin from './braces';
|
||||
|
@ -1,4 +1,4 @@
|
||||
const BRACES = {
|
||||
const BRACES: any = {
|
||||
'[': ']',
|
||||
'{': '}',
|
||||
'(': ')',
|
||||
@ -8,7 +8,7 @@ const NON_SELECTOR_SPACE_REGEXP = / (?![^}]+})/;
|
||||
|
||||
export default function BracesPlugin() {
|
||||
return {
|
||||
onKeyDown(event, change) {
|
||||
onKeyDown(event: any, change: { value?: any; insertText?: any; deleteBackward?: any }) {
|
||||
const { value } = change;
|
||||
if (!value.isCollapsed) {
|
||||
return undefined;
|
||||
|
@ -1,3 +1,4 @@
|
||||
// @ts-ignore
|
||||
import Plain from 'slate-plain-serializer';
|
||||
|
||||
import ClearPlugin from './clear';
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Clears the rest of the line after the caret
|
||||
export default function ClearPlugin() {
|
||||
return {
|
||||
onKeyDown(event, change) {
|
||||
onKeyDown(event: any, change: { value?: any; deleteForward?: any }) {
|
||||
const { value } = change;
|
||||
if (!value.isCollapsed) {
|
||||
return undefined;
|
||||
|
@ -1,4 +1,4 @@
|
||||
function getIndent(text) {
|
||||
function getIndent(text: any) {
|
||||
let offset = text.length - text.trimLeft().length;
|
||||
if (offset) {
|
||||
let indent = text[0];
|
||||
@ -12,7 +12,7 @@ function getIndent(text) {
|
||||
|
||||
export default function NewlinePlugin() {
|
||||
return {
|
||||
onKeyDown(event, change) {
|
||||
onKeyDown(event: any, change: { value?: any; splitBlock?: any }) {
|
||||
const { value } = change;
|
||||
if (!value.isCollapsed) {
|
||||
return undefined;
|
||||
|
@ -3,7 +3,7 @@ import Prism from 'prismjs';
|
||||
|
||||
const TOKEN_MARK = 'prism-token';
|
||||
|
||||
export function setPrismTokens(language, field, values, alias = 'variable') {
|
||||
export function setPrismTokens(language: string, field: string | number, values: any, alias = 'variable') {
|
||||
Prism.languages[language][field] = {
|
||||
alias,
|
||||
pattern: new RegExp(`(?:^|\\s)(${values.join('|')})(?:$|\\s)`),
|
||||
@ -17,7 +17,7 @@ export function setPrismTokens(language, field, values, alias = 'variable') {
|
||||
* (Adapted to handle nested grammar definitions.)
|
||||
*/
|
||||
|
||||
export default function PrismPlugin({ definition, language }) {
|
||||
export default function PrismPlugin({ definition, language }: { definition: any; language: string }) {
|
||||
if (definition) {
|
||||
// Don't override exising modified definitions
|
||||
Prism.languages[language] = Prism.languages[language] || definition;
|
||||
@ -31,7 +31,7 @@ export default function PrismPlugin({ definition, language }) {
|
||||
* @return {Element}
|
||||
*/
|
||||
|
||||
renderMark(props) {
|
||||
renderMark(props: any): JSX.Element {
|
||||
const { children, mark } = props;
|
||||
// Only apply spans to marks identified by this plugin
|
||||
if (mark.type !== TOKEN_MARK) {
|
||||
@ -48,13 +48,13 @@ export default function PrismPlugin({ definition, language }) {
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
decorateNode(node) {
|
||||
decorateNode(node: any): any[] {
|
||||
if (node.type !== 'paragraph') {
|
||||
return [];
|
||||
}
|
||||
|
||||
const texts = node.getTexts().toArray();
|
||||
const tstring = texts.map(t => t.text).join('\n');
|
||||
const tstring = texts.map((t: { text: any }) => t.text).join('\n');
|
||||
const grammar = Prism.languages[language];
|
||||
const tokens = Prism.tokenize(tstring, grammar);
|
||||
const decorations: any[] = [];
|
||||
@ -64,7 +64,7 @@ export default function PrismPlugin({ definition, language }) {
|
||||
let endOffset = 0;
|
||||
let start = 0;
|
||||
|
||||
function processToken(token, acc?) {
|
||||
function processToken(token: any, acc?: string) {
|
||||
// Accumulate token types down the tree
|
||||
const types = `${acc || ''} ${token.type || ''} ${token.alias || ''}`;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
export default function RunnerPlugin({ handler }) {
|
||||
export default function RunnerPlugin({ handler }: any) {
|
||||
return {
|
||||
onKeyDown(event) {
|
||||
onKeyDown(event: any) {
|
||||
// Handle enter
|
||||
if (handler && event.key === 'Enter' && !event.shiftKey) {
|
||||
// Submit on Enter
|
||||
|
@ -41,9 +41,9 @@ describe('processQueryResultsEpic', () => {
|
||||
it('then resetQueryErrorAction and querySuccessAction are dispatched and eventBridge emits correct message', () => {
|
||||
const { datasourceId, exploreId, state, eventBridge } = mockExploreState();
|
||||
const { latency, series, loadingState } = testContext();
|
||||
const graphResult = [];
|
||||
const graphResult: any[] = [];
|
||||
const tableResult = new TableModel();
|
||||
const logsResult = null;
|
||||
const logsResult: any = null;
|
||||
|
||||
epicTester(processQueryResultsEpic, state)
|
||||
.whenActionIsDispatched(
|
||||
@ -64,9 +64,9 @@ describe('processQueryResultsEpic', () => {
|
||||
it('then correct actions are dispatched', () => {
|
||||
const { datasourceId, exploreId, state } = mockExploreState({ scanning: true });
|
||||
const { latency, series, loadingState } = testContext();
|
||||
const graphResult = [];
|
||||
const graphResult: any[] = [];
|
||||
const tableResult = new TableModel();
|
||||
const logsResult = null;
|
||||
const logsResult: any = null;
|
||||
|
||||
epicTester(processQueryResultsEpic, state)
|
||||
.whenActionIsDispatched(
|
||||
@ -84,9 +84,9 @@ describe('processQueryResultsEpic', () => {
|
||||
it('then correct actions are dispatched', () => {
|
||||
const { datasourceId, exploreId, state } = mockExploreState({ scanning: true });
|
||||
const { latency, loadingState } = testContext();
|
||||
const graphResult = [];
|
||||
const graphResult: any[] = [];
|
||||
const tableResult = new TableModel();
|
||||
const logsResult = null;
|
||||
const logsResult: any = null;
|
||||
|
||||
epicTester(processQueryResultsEpic, state)
|
||||
.whenActionIsDispatched(
|
||||
|
@ -106,12 +106,12 @@ describe('runQueriesBatchEpic', () => {
|
||||
it('then correct actions are dispatched', () => {
|
||||
const { exploreId, state, datasourceId } = mockExploreState();
|
||||
const unsubscribe = jest.fn();
|
||||
const serieA = {
|
||||
const serieA: any = {
|
||||
fields: [],
|
||||
rows: [],
|
||||
refId: 'A',
|
||||
};
|
||||
const serieB = {
|
||||
const serieB: any = {
|
||||
fields: [],
|
||||
rows: [],
|
||||
refId: 'B',
|
||||
@ -171,12 +171,12 @@ describe('runQueriesBatchEpic', () => {
|
||||
it('then correct actions are dispatched', () => {
|
||||
const { exploreId, state, datasourceId, history } = mockExploreState();
|
||||
const unsubscribe = jest.fn();
|
||||
const serieA = {
|
||||
const serieA: any = {
|
||||
fields: [],
|
||||
rows: [],
|
||||
refId: 'A',
|
||||
};
|
||||
const serieB = {
|
||||
const serieB: any = {
|
||||
fields: [],
|
||||
rows: [],
|
||||
refId: 'B',
|
||||
|
@ -46,7 +46,7 @@ describe('runQueriesEpic', () => {
|
||||
|
||||
describe('and we have no queries', () => {
|
||||
it('then clearQueriesAction and stateSaveAction are dispatched', () => {
|
||||
const queries = [];
|
||||
const queries: any[] = [];
|
||||
const { exploreId, state } = mockExploreState({ queries });
|
||||
|
||||
epicTester(runQueriesEpic, state)
|
||||
|
@ -37,7 +37,7 @@ export const timeEpic: Epic<ActionOf<any>, ActionOf<any>, StoreState> = (
|
||||
time: range.raw,
|
||||
refresh: false,
|
||||
getTimezone: () => timeZone.raw,
|
||||
timeRangeUpdated: () => undefined,
|
||||
timeRangeUpdated: (): any => undefined,
|
||||
});
|
||||
|
||||
return changeRangeAction({ exploreId, range, absoluteRange });
|
||||
|
@ -146,7 +146,7 @@ describe('Explore item reducer', () => {
|
||||
queries,
|
||||
queryKeys,
|
||||
};
|
||||
const expectedState = {
|
||||
const expectedState: any = {
|
||||
datasourceInstance,
|
||||
StartPage,
|
||||
showingStartPage: true,
|
||||
@ -175,7 +175,7 @@ describe('Explore item reducer', () => {
|
||||
showingStartPage: true,
|
||||
range: null,
|
||||
};
|
||||
const expectedState = {
|
||||
const expectedState: any = {
|
||||
queryIntervals: {
|
||||
interval: '1s',
|
||||
intervalMs: 1000,
|
||||
|
@ -332,7 +332,7 @@ export default class AzureMonitorDatasource {
|
||||
this.apiPreviewVersion
|
||||
);
|
||||
|
||||
return this.doRequest(url).then(result => {
|
||||
return this.doRequest(url).then((result: any) => {
|
||||
return ResponseParser.parseResponseValues(result, 'name', 'properties.metricNamespaceName');
|
||||
});
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
echo -e "Collecting code stats (typescript errors & more)"
|
||||
|
||||
|
||||
ERROR_COUNT_LIMIT=1670
|
||||
ERROR_COUNT_LIMIT=800
|
||||
DIRECTIVES_LIMIT=172
|
||||
CONTROLLERS_LIMIT=139
|
||||
|
||||
|
22
yarn.lock
22
yarn.lock
@ -2974,6 +2974,11 @@
|
||||
"@types/express-serve-static-core" "*"
|
||||
"@types/serve-static" "*"
|
||||
|
||||
"@types/file-saver@^2.0.1":
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/file-saver/-/file-saver-2.0.1.tgz#e18eb8b069e442f7b956d313f4fadd3ef887354e"
|
||||
integrity sha512-g1QUuhYVVAamfCifK7oB7G3aIl4BbOyzDOqVyUfEr4tfBKrXfeH+M+Tg7HKCXSrbzxYdhyCP7z9WbKo0R2hBCw==
|
||||
|
||||
"@types/geojson@*":
|
||||
version "7946.0.7"
|
||||
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.7.tgz#c8fa532b60a0042219cdf173ca21a975ef0666ad"
|
||||
@ -3218,9 +3223,10 @@
|
||||
dependencies:
|
||||
"@types/react" "*"
|
||||
|
||||
"@types/react-redux@^7.0.8":
|
||||
"@types/react-redux@7.0.8":
|
||||
version "7.0.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.0.8.tgz#c928863058e334d41031c6bedd0f113bc514e234"
|
||||
integrity sha512-vIBC15E84ehN6RzdGwRVa41whp9e4CkfPm+WfD0r6y6vqBf4tQPKZeKEBfLLM8k79uSwQC7rh3rH/MFaN1IESQ==
|
||||
dependencies:
|
||||
"@types/hoist-non-react-statics" "^3.3.0"
|
||||
"@types/react" "*"
|
||||
@ -3234,6 +3240,13 @@
|
||||
"@types/react-dom" "*"
|
||||
"@types/react-transition-group" "*"
|
||||
|
||||
"@types/react-table@6.8.5":
|
||||
version "6.8.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-table/-/react-table-6.8.5.tgz#deb2bf2fcedcfb81e9020edbb7df0d8459ca348b"
|
||||
integrity sha512-ueCsAadG1IwuuAZM+MWf2SoxbccSWweyQa9YG6xGN5cOVK3SayPOJW4MsUHGpY0V/Q+iZWgohpasliiao29O6g==
|
||||
dependencies:
|
||||
"@types/react" "*"
|
||||
|
||||
"@types/react-test-renderer@16.8.1":
|
||||
version "16.8.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-16.8.1.tgz#96f3ce45a3a41c94eca532a99103dd3042c9d055"
|
||||
@ -3286,6 +3299,13 @@
|
||||
dependencies:
|
||||
redux "^3.6.0"
|
||||
|
||||
"@types/redux-mock-store@1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/redux-mock-store/-/redux-mock-store-1.0.1.tgz#90ca701d640aef7c007f564a9a4f8dc03180b0f7"
|
||||
integrity sha512-1egEnh2/+sRRKImnCo5EMVm0Uxu4fBHeLHk/inhSp/VpE93It8lk3gYeNfehUgXd6OzqP5LLA9kzO9x7o3WfwA==
|
||||
dependencies:
|
||||
redux "^4.0.0"
|
||||
|
||||
"@types/relateurl@*":
|
||||
version "0.2.28"
|
||||
resolved "https://registry.yarnpkg.com/@types/relateurl/-/relateurl-0.2.28.tgz#6bda7db8653fa62643f5ee69e9f69c11a392e3a6"
|
||||
|
Loading…
Reference in New Issue
Block a user