mirror of
https://github.com/grafana/grafana.git
synced 2025-01-26 16:27:02 -06:00
noImplicitAny: time region manager etc. (#17729)
* Fix errors * Wrong branch * minor type fix
This commit is contained in:
parent
75c29566a6
commit
1b17b7893f
@ -50,6 +50,7 @@ export interface DateTimeDuration {
|
||||
|
||||
export interface DateTime extends Object {
|
||||
add: (amount?: DateTimeInput, unit?: DurationUnit) => DateTime;
|
||||
set: (unit: DurationUnit, amount: DateTimeInput) => void;
|
||||
diff: (amount: DateTimeInput, unit?: DurationUnit, truncate?: boolean) => number;
|
||||
endOf: (unitOfTime: DurationUnit) => DateTime;
|
||||
format: (formatInput?: FormatInput) => string;
|
||||
@ -63,9 +64,11 @@ export interface DateTime extends Object {
|
||||
subtract: (amount?: DateTimeInput, unit?: DurationUnit) => DateTime;
|
||||
toDate: () => Date;
|
||||
toISOString: () => string;
|
||||
isoWeekday: (day?: number | string) => number | string;
|
||||
valueOf: () => number;
|
||||
unix: () => number;
|
||||
utc: () => DateTime;
|
||||
hour?: () => number;
|
||||
}
|
||||
|
||||
export const setLocale = (language: string) => {
|
||||
|
@ -2,6 +2,7 @@ import 'vendor/flot/jquery.flot';
|
||||
import $ from 'jquery';
|
||||
import _ from 'lodash';
|
||||
import { getColorFromHexRgbOrName } from '@grafana/ui';
|
||||
import { PanelCtrl } from 'app/features/panel/panel_ctrl';
|
||||
|
||||
export class ThresholdManager {
|
||||
plot: any;
|
||||
@ -11,9 +12,9 @@ export class ThresholdManager {
|
||||
needsCleanup: boolean;
|
||||
hasSecondYAxis: any;
|
||||
|
||||
constructor(private panelCtrl) {}
|
||||
constructor(private panelCtrl: PanelCtrl) {}
|
||||
|
||||
getHandleHtml(handleIndex, model, valueStr) {
|
||||
getHandleHtml(handleIndex: any, model: { colorMode: string }, valueStr: any) {
|
||||
let stateClass = model.colorMode;
|
||||
if (model.colorMode === 'custom') {
|
||||
stateClass = 'critical';
|
||||
@ -30,17 +31,17 @@ export class ThresholdManager {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
initDragging(evt) {
|
||||
initDragging(evt: any) {
|
||||
const handleElem = $(evt.currentTarget).parents('.alert-handle-wrapper');
|
||||
const handleIndex = $(evt.currentTarget).data('handleIndex');
|
||||
|
||||
let lastY = null;
|
||||
let posTop;
|
||||
let lastY: number = null;
|
||||
let posTop: number;
|
||||
const plot = this.plot;
|
||||
const panelCtrl = this.panelCtrl;
|
||||
const model = this.thresholds[handleIndex];
|
||||
|
||||
function dragging(evt) {
|
||||
function dragging(evt: any) {
|
||||
if (lastY === null) {
|
||||
lastY = evt.clientY;
|
||||
} else {
|
||||
@ -84,7 +85,7 @@ export class ThresholdManager {
|
||||
this.needsCleanup = false;
|
||||
}
|
||||
|
||||
renderHandle(handleIndex, defaultHandleTopPos) {
|
||||
renderHandle(handleIndex: number, defaultHandleTopPos: number) {
|
||||
const model = this.thresholds[handleIndex];
|
||||
const value = model.value;
|
||||
let valueStr = value;
|
||||
@ -107,10 +108,11 @@ export class ThresholdManager {
|
||||
}
|
||||
|
||||
shouldDrawHandles() {
|
||||
// @ts-ignore
|
||||
return !this.hasSecondYAxis && this.panelCtrl.editingThresholds && this.panelCtrl.panel.thresholds.length > 0;
|
||||
}
|
||||
|
||||
prepare(elem, data) {
|
||||
prepare(elem: JQuery, data: any[]) {
|
||||
this.hasSecondYAxis = false;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if (data[i].yaxis > 1) {
|
||||
@ -127,7 +129,7 @@ export class ThresholdManager {
|
||||
}
|
||||
}
|
||||
|
||||
draw(plot) {
|
||||
draw(plot: any) {
|
||||
this.thresholds = this.panelCtrl.panel.thresholds;
|
||||
this.plot = plot;
|
||||
this.placeholder = plot.getPlaceholder();
|
||||
@ -154,7 +156,7 @@ export class ThresholdManager {
|
||||
this.needsCleanup = true;
|
||||
}
|
||||
|
||||
addFlotOptions(options, panel) {
|
||||
addFlotOptions(options: any, panel: any) {
|
||||
if (!panel.thresholds || panel.thresholds.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import 'vendor/flot/jquery.flot';
|
||||
import _ from 'lodash';
|
||||
import { GrafanaThemeType, getColorFromHexRgbOrName } from '@grafana/ui';
|
||||
import { dateTime } from '@grafana/ui/src/utils/moment_wrapper';
|
||||
import { GrafanaThemeType, getColorFromHexRgbOrName, AbsoluteTimeRange } from '@grafana/ui';
|
||||
import { dateTime, DateTime } from '@grafana/ui/src/utils/moment_wrapper';
|
||||
|
||||
type TimeRegionColorDefinition = {
|
||||
fill: string;
|
||||
line: string;
|
||||
};
|
||||
|
||||
export const colorModes = {
|
||||
export const colorModes: any = {
|
||||
gray: {
|
||||
themeDependent: true,
|
||||
title: 'Gray',
|
||||
@ -88,9 +88,15 @@ export class TimeRegionManager {
|
||||
to: dateTime(this.panelCtrl.range.to).utc(),
|
||||
};
|
||||
|
||||
let i, hRange, timeRegion, regions, fromStart, fromEnd, timeRegionColor: TimeRegionColorDefinition;
|
||||
let i: number,
|
||||
hRange: { from: any; to: any },
|
||||
timeRegion: any,
|
||||
regions: AbsoluteTimeRange[],
|
||||
fromStart: DateTime,
|
||||
fromEnd: DateTime,
|
||||
timeRegionColor: TimeRegionColorDefinition;
|
||||
|
||||
const timeRegionsCopy = panel.timeRegions.map(a => ({ ...a }));
|
||||
const timeRegionsCopy = panel.timeRegions.map((a: any) => ({ ...a }));
|
||||
|
||||
for (i = 0; i < timeRegionsCopy.length; i++) {
|
||||
timeRegion = timeRegionsCopy[i];
|
||||
@ -222,9 +228,9 @@ export class TimeRegionManager {
|
||||
}
|
||||
}
|
||||
|
||||
parseTimeRange(str) {
|
||||
parseTimeRange(str: string) {
|
||||
const timeRegex = /^([\d]+):?(\d{2})?/;
|
||||
const result = { h: null, m: null };
|
||||
const result: any = { h: null, m: null };
|
||||
const match = timeRegex.exec(str);
|
||||
|
||||
if (!match) {
|
||||
|
@ -8,7 +8,7 @@ export class TimeRegionFormCtrl {
|
||||
colorModes: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope) {
|
||||
constructor($scope: any) {
|
||||
this.panel = this.panelCtrl.panel;
|
||||
|
||||
const unbindDestroy = $scope.$on('$destroy', () => {
|
||||
@ -42,20 +42,20 @@ export class TimeRegionFormCtrl {
|
||||
this.panelCtrl.render();
|
||||
}
|
||||
|
||||
removeTimeRegion(index) {
|
||||
removeTimeRegion(index: number) {
|
||||
this.panel.timeRegions.splice(index, 1);
|
||||
this.panelCtrl.render();
|
||||
}
|
||||
|
||||
onFillColorChange(index) {
|
||||
return newColor => {
|
||||
onFillColorChange(index: number) {
|
||||
return (newColor: string) => {
|
||||
this.panel.timeRegions[index].fillColor = newColor;
|
||||
this.render();
|
||||
};
|
||||
}
|
||||
|
||||
onLineColorChange(index) {
|
||||
return newColor => {
|
||||
onLineColorChange(index: number) {
|
||||
return (newColor: string) => {
|
||||
this.panel.timeRegions[index].lineColor = newColor;
|
||||
this.render();
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
import kbn from 'app/core/utils/kbn';
|
||||
|
||||
export class AxesEditorCtrl {
|
||||
panel: any;
|
||||
panelCtrl: any;
|
||||
@ -9,7 +8,7 @@ export class AxesEditorCtrl {
|
||||
yBucketBoundModes: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, uiSegmentSrv) {
|
||||
constructor($scope: any, uiSegmentSrv: any) {
|
||||
$scope.editor = this;
|
||||
this.panelCtrl = $scope.ctrl;
|
||||
this.panel = this.panelCtrl.panel;
|
||||
@ -36,7 +35,7 @@ export class AxesEditorCtrl {
|
||||
};
|
||||
}
|
||||
|
||||
setUnitFormat(subItem) {
|
||||
setUnitFormat(subItem: any) {
|
||||
this.panel.yAxis.format = subItem.value;
|
||||
this.panelCtrl.render();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user