mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
noImplicitAny: Lower count to about 3450 (#17799)
This commit is contained in:
committed by
Torkel Ödegaard
parent
8fcc370fe9
commit
0b9de3f761
@@ -4,6 +4,8 @@ import { PanelCtrl } from 'app/plugins/sdk';
|
||||
|
||||
import * as dateMath from '@grafana/ui/src/utils/datemath';
|
||||
import { dateTime } from '@grafana/ui/src/utils/moment_wrapper';
|
||||
import { auto } from 'angular';
|
||||
import { BackendSrv } from '@grafana/runtime';
|
||||
|
||||
class AlertListPanel extends PanelCtrl {
|
||||
static templateUrl = 'module.html';
|
||||
@@ -24,7 +26,7 @@ class AlertListPanel extends PanelCtrl {
|
||||
templateSrv: string;
|
||||
|
||||
// Set and populate defaults
|
||||
panelDefaults = {
|
||||
panelDefaults: any = {
|
||||
show: 'current',
|
||||
limit: 10,
|
||||
stateFilter: [],
|
||||
@@ -36,7 +38,7 @@ class AlertListPanel extends PanelCtrl {
|
||||
};
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, $injector, private backendSrv) {
|
||||
constructor($scope: any, $injector: auto.IInjectorService, private backendSrv: BackendSrv) {
|
||||
super($scope, $injector);
|
||||
_.defaults(this.panel, this.panelDefaults);
|
||||
|
||||
@@ -49,9 +51,10 @@ class AlertListPanel extends PanelCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
sortResult(alerts) {
|
||||
sortResult(alerts: any[]) {
|
||||
if (this.panel.sortOrder === 3) {
|
||||
return _.sortBy(alerts, a => {
|
||||
// @ts-ignore
|
||||
return alertDef.alertStateSortScore[a.state];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ export class BarGaugePanelEditor extends PureComponent<PanelEditorProps<BarGauge
|
||||
});
|
||||
};
|
||||
|
||||
onOrientationChange = ({ value }) => this.props.onOptionsChange({ ...this.props.options, orientation: value });
|
||||
onDisplayModeChange = ({ value }) => this.props.onOptionsChange({ ...this.props.options, displayMode: value });
|
||||
onOrientationChange = ({ value }: any) => this.props.onOptionsChange({ ...this.props.options, orientation: value });
|
||||
onDisplayModeChange = ({ value }: any) => this.props.onOptionsChange({ ...this.props.options, displayMode: value });
|
||||
|
||||
render() {
|
||||
const { options } = this.props;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import _ from 'lodash';
|
||||
import { PanelCtrl } from 'app/plugins/sdk';
|
||||
import impressionSrv from 'app/core/services/impression_srv';
|
||||
import { auto } from 'angular';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { DashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
|
||||
|
||||
class DashListCtrl extends PanelCtrl {
|
||||
static templateUrl = 'module.html';
|
||||
@@ -9,7 +12,7 @@ class DashListCtrl extends PanelCtrl {
|
||||
groups: any[];
|
||||
modes: any[];
|
||||
|
||||
panelDefaults = {
|
||||
panelDefaults: any = {
|
||||
query: '',
|
||||
limit: 10,
|
||||
tags: [],
|
||||
@@ -21,7 +24,12 @@ class DashListCtrl extends PanelCtrl {
|
||||
};
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, $injector, private backendSrv, private dashboardSrv) {
|
||||
constructor(
|
||||
$scope: any,
|
||||
$injector: auto.IInjectorService,
|
||||
private backendSrv: BackendSrv,
|
||||
private dashboardSrv: DashboardSrv
|
||||
) {
|
||||
super($scope, $injector);
|
||||
_.defaults(this.panel, this.panelDefaults);
|
||||
|
||||
@@ -105,8 +113,8 @@ class DashListCtrl extends PanelCtrl {
|
||||
});
|
||||
}
|
||||
|
||||
starDashboard(dash, evt) {
|
||||
this.dashboardSrv.starDashboard(dash.id, dash.isStarred).then(newState => {
|
||||
starDashboard(dash: any, evt: any) {
|
||||
this.dashboardSrv.starDashboard(dash.id, dash.isStarred).then((newState: any) => {
|
||||
dash.isStarred = newState;
|
||||
});
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ export class GettingStarted extends PureComponent<PanelProps, State> {
|
||||
check: () => {
|
||||
return getBackendSrv()
|
||||
.get('/api/org/users')
|
||||
.then(res => {
|
||||
.then((res: any) => {
|
||||
return res.length > 1;
|
||||
});
|
||||
},
|
||||
@@ -93,7 +93,7 @@ export class GettingStarted extends PureComponent<PanelProps, State> {
|
||||
check: () => {
|
||||
return getBackendSrv()
|
||||
.get('/api/plugins', { embedded: 0, core: 0 })
|
||||
.then(plugins => {
|
||||
.then((plugins: any[]) => {
|
||||
return plugins.length > 0;
|
||||
});
|
||||
},
|
||||
@@ -108,7 +108,7 @@ export class GettingStarted extends PureComponent<PanelProps, State> {
|
||||
});
|
||||
}
|
||||
|
||||
nextStep() {
|
||||
nextStep(): any {
|
||||
if (this.stepIndex === this.steps.length - 1) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class GraphContextMenuCtrl {
|
||||
|
||||
isVisible: boolean;
|
||||
|
||||
constructor($scope) {
|
||||
constructor($scope: any) {
|
||||
this.isVisible = false;
|
||||
this.menuItems = [];
|
||||
this.scope = $scope;
|
||||
|
||||
@@ -4,21 +4,22 @@ import { TimeSeries } from 'app/core/core';
|
||||
import { CustomScrollbar } from '@grafana/ui';
|
||||
import { LegendItem, LEGEND_STATS } from './LegendSeriesItem';
|
||||
|
||||
type Sort = 'min' | 'max' | 'avg' | 'current' | 'total';
|
||||
interface LegendProps {
|
||||
seriesList: TimeSeries[];
|
||||
optionalClass?: string;
|
||||
}
|
||||
|
||||
interface LegendEventHandlers {
|
||||
onToggleSeries?: (hiddenSeries) => void;
|
||||
onToggleSort?: (sortBy, sortDesc) => void;
|
||||
onToggleSeries?: (hiddenSeries: any) => void;
|
||||
onToggleSort?: (sortBy: any, sortDesc: any) => void;
|
||||
onToggleAxis?: (series: TimeSeries) => void;
|
||||
onColorChange?: (series: TimeSeries, color: string) => void;
|
||||
}
|
||||
|
||||
interface LegendComponentEventHandlers {
|
||||
onToggleSeries?: (series, event) => void;
|
||||
onToggleSort?: (sortBy, sortDesc) => void;
|
||||
onToggleSeries?: (series: TimeSeries, event: any) => void;
|
||||
onToggleSort?: (sortBy: Sort, sortDesc: any) => void;
|
||||
onToggleAxis?: (series: TimeSeries) => void;
|
||||
onColorChange?: (series: TimeSeries, color: string) => void;
|
||||
}
|
||||
@@ -42,7 +43,7 @@ interface LegendValuesProps {
|
||||
}
|
||||
|
||||
interface LegendSortProps {
|
||||
sort?: 'min' | 'max' | 'avg' | 'current' | 'total';
|
||||
sort?: Sort;
|
||||
sortDesc?: boolean;
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ export class GraphLegend extends PureComponent<GraphLegendProps, LegendState> {
|
||||
onColorChange: () => {},
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: GraphLegendProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
hiddenSeries: this.props.hiddenSeries,
|
||||
@@ -104,7 +105,7 @@ export class GraphLegend extends PureComponent<GraphLegendProps, LegendState> {
|
||||
return seriesList;
|
||||
}
|
||||
|
||||
onToggleSeries = (series, event) => {
|
||||
onToggleSeries = (series: TimeSeries, event: any) => {
|
||||
let hiddenSeries = { ...this.state.hiddenSeries };
|
||||
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
||||
if (hiddenSeries[series.alias]) {
|
||||
@@ -119,7 +120,7 @@ export class GraphLegend extends PureComponent<GraphLegendProps, LegendState> {
|
||||
this.props.onToggleSeries(hiddenSeries);
|
||||
};
|
||||
|
||||
toggleSeriesExclusiveMode(series) {
|
||||
toggleSeriesExclusiveMode(series: TimeSeries) {
|
||||
const hiddenSeries = { ...this.state.hiddenSeries };
|
||||
|
||||
if (hiddenSeries[series.alias]) {
|
||||
@@ -226,7 +227,7 @@ class LegendSeriesList extends PureComponent<LegendComponentProps> {
|
||||
}
|
||||
|
||||
class LegendTable extends PureComponent<Partial<LegendComponentProps>> {
|
||||
onToggleSort = stat => {
|
||||
onToggleSort = (stat: Sort) => {
|
||||
let sortDesc = this.props.sortDesc;
|
||||
let sortBy = this.props.sort;
|
||||
if (stat !== sortBy) {
|
||||
@@ -247,7 +248,7 @@ class LegendTable extends PureComponent<Partial<LegendComponentProps>> {
|
||||
render() {
|
||||
const seriesList = this.props.seriesList;
|
||||
const { values, min, max, avg, current, total, sort, sortDesc, hiddenSeries } = this.props;
|
||||
const seriesValuesProps = { values, min, max, avg, current, total };
|
||||
const seriesValuesProps: any = { values, min, max, avg, current, total };
|
||||
return (
|
||||
<table>
|
||||
<colgroup>
|
||||
|
||||
@@ -9,9 +9,9 @@ export interface LegendLabelProps {
|
||||
series: TimeSeries;
|
||||
asTable?: boolean;
|
||||
hidden?: boolean;
|
||||
onLabelClick?: (series, event) => void;
|
||||
onColorChange?: (series, color: string) => void;
|
||||
onToggleAxis?: (series) => void;
|
||||
onLabelClick?: (series: any, event: any) => void;
|
||||
onColorChange?: (series: any, color: string) => void;
|
||||
onToggleAxis?: (series: any) => void;
|
||||
}
|
||||
|
||||
export interface LegendValuesProps {
|
||||
@@ -38,14 +38,14 @@ export class LegendItem extends PureComponent<LegendItemProps, LegendItemState>
|
||||
onToggleAxis: () => {},
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: LegendItemProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
yaxis: this.props.series.yaxis,
|
||||
};
|
||||
}
|
||||
|
||||
onLabelClick = e => this.props.onLabelClick(this.props.series, e);
|
||||
onLabelClick = (e: any) => this.props.onLabelClick(this.props.series, e);
|
||||
|
||||
onToggleAxis = () => {
|
||||
const yaxis = this.state.yaxis === 2 ? 1 : 2;
|
||||
@@ -54,7 +54,7 @@ export class LegendItem extends PureComponent<LegendItemProps, LegendItemState>
|
||||
this.props.onToggleAxis(info);
|
||||
};
|
||||
|
||||
onColorChange = color => {
|
||||
onColorChange = (color: string) => {
|
||||
this.props.onColorChange(this.props.series, color);
|
||||
// Because of PureComponent nature it makes only shallow props comparison and changing of series.color doesn't run
|
||||
// component re-render. In this case we can't rely on color, selected by user, because it may be overwritten
|
||||
@@ -66,6 +66,7 @@ export class LegendItem extends PureComponent<LegendItemProps, LegendItemState>
|
||||
const { series, asTable } = this.props;
|
||||
const legendValueItems = [];
|
||||
for (const valueName of LEGEND_STATS) {
|
||||
// @ts-ignore
|
||||
if (this.props[valueName]) {
|
||||
const valueFormatted = series.formatValue(series.stats[valueName]);
|
||||
legendValueItems.push(
|
||||
@@ -116,11 +117,11 @@ interface LegendSeriesLabelProps {
|
||||
label: string;
|
||||
color: string;
|
||||
yaxis?: number;
|
||||
onLabelClick?: (event) => void;
|
||||
onLabelClick?: (event: any) => void;
|
||||
}
|
||||
|
||||
class LegendSeriesLabel extends PureComponent<LegendSeriesLabelProps & LegendSeriesIconProps> {
|
||||
static defaultProps = {
|
||||
static defaultProps: Partial<LegendSeriesLabelProps> = {
|
||||
yaxis: undefined,
|
||||
onLabelClick: () => {},
|
||||
};
|
||||
@@ -154,12 +155,12 @@ interface LegendSeriesIconState {
|
||||
color: string;
|
||||
}
|
||||
|
||||
function SeriesIcon({ color }) {
|
||||
function SeriesIcon({ color }: { color: string }) {
|
||||
return <i className="fa fa-minus pointer" style={{ color }} />;
|
||||
}
|
||||
|
||||
class LegendSeriesIcon extends PureComponent<LegendSeriesIconProps, LegendSeriesIconState> {
|
||||
static defaultProps = {
|
||||
static defaultProps: Partial<LegendSeriesIconProps> = {
|
||||
yaxis: undefined,
|
||||
onColorChange: () => {},
|
||||
onToggleAxis: () => {},
|
||||
|
||||
Reference in New Issue
Block a user