mirror of https://github.com/grafana/grafana.git
				
				
				
			Chore: some type fixes (#80094)
* some type fixes * few more fixes * more * fix unit test
This commit is contained in:
		
							parent
							
								
									fb34916d1e
								
							
						
					
					
						commit
						68ba6cc67b
					
				|  | @ -4374,12 +4374,9 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "7"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "8"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "9"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "10"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "11"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "12"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "13"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "14"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "15"] | ||||
|       [0, 0, 0, "Do not use any type assertions.", "10"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "11"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "12"] | ||||
|     ], | ||||
|     "public/app/features/trails/SelectMetricTrailView.tsx:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"], | ||||
|  | @ -5947,24 +5944,16 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Styles should be written using objects.", "0"], | ||||
|       [0, 0, 0, "Styles should be written using objects.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/datasource/tempo/traceql/autocomplete.test.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/datasource/zipkin/ConfigEditor.tsx:5381": [ | ||||
|       [0, 0, 0, "Styles should be written using objects.", "0"] | ||||
|     ], | ||||
|     "public/app/plugins/datasource/zipkin/QueryField.tsx:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "1"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "2"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/datasource/zipkin/datasource.ts:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "2"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "3"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "4"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/datasource/zipkin/utils/testResponse.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|  | @ -6003,8 +5992,7 @@ exports[`better eslint`] = { | |||
|     ], | ||||
|     "public/app/plugins/panel/alertlist/AlertListMigrationHandler.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "2"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/alertlist/UnifiedAlertList.tsx:5381": [ | ||||
|       [0, 0, 0, "Styles should be written using objects.", "0"], | ||||
|  | @ -6036,18 +6024,11 @@ exports[`better eslint`] = { | |||
|     ], | ||||
|     "public/app/plugins/panel/annolist/AnnoListPanel.test.tsx:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "2"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "3"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/annolist/AnnoListPanel.tsx:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "2"], | ||||
|       [0, 0, 0, "Styles should be written using objects.", "3"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/annolist/module.tsx:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"] | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"], | ||||
|       [0, 0, 0, "Styles should be written using objects.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/barchart/BarChartPanel.tsx:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"], | ||||
|  | @ -6094,9 +6075,6 @@ exports[`better eslint`] = { | |||
|     "public/app/plugins/panel/canvas/globalStyles.ts:5381": [ | ||||
|       [0, 0, 0, "Styles should be written using objects.", "0"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/dashlist/migrations.test.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/dashlist/styles.ts:5381": [ | ||||
|       [0, 0, 0, "Styles should be written using objects.", "0"], | ||||
|       [0, 0, 0, "Styles should be written using objects.", "1"], | ||||
|  | @ -6117,8 +6095,7 @@ exports[`better eslint`] = { | |||
|     ], | ||||
|     "public/app/plugins/panel/debug/EventBusLogger.tsx:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "1"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "2"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/gauge/GaugeMigrations.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"] | ||||
|  | @ -6168,8 +6145,7 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/geomap/utils/layers.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "1"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/geomap/utils/tooltip.ts:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"] | ||||
|  | @ -6246,9 +6222,7 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Do not use any type assertions.", "16"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/histogram/Histogram.tsx:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "1"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "2"] | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/live/LiveChannelEditor.tsx:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|  | @ -6330,13 +6304,6 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Styles should be written using objects.", "0"], | ||||
|       [0, 0, 0, "Styles should be written using objects.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/nodeGraph/usePanning.ts:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/nodeGraph/utils.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/piechart/PieChart.tsx:5381": [ | ||||
|       [0, 0, 0, "Styles should be written using objects.", "0"], | ||||
|       [0, 0, 0, "Styles should be written using objects.", "1"], | ||||
|  | @ -6349,8 +6316,7 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/stat/StatMigrations.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/state-timeline/migrations.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|  | @ -6403,14 +6369,7 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "8"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "9"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "10"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "11"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "12"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "13"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "14"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "15"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "16"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "17"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "18"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "11"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/table-old/renderer.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|  | @ -6485,17 +6444,15 @@ exports[`better eslint`] = { | |||
|     ], | ||||
|     "public/app/plugins/panel/timeseries/migrations.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "1"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "2"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "3"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "4"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "5"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "6"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "7"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "8"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "9"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "10"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "11"] | ||||
|       [0, 0, 0, "Do not use any type assertions.", "1"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "2"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "3"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "4"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "5"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "6"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "7"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "8"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "9"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/timeseries/plugins/ThresholdDragHandle.tsx:5381": [ | ||||
|       [0, 0, 0, "Styles should be written using objects.", "0"], | ||||
|  | @ -6569,14 +6526,6 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "1"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/xychart/dims.ts:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "1"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "2"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "3"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "4"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "5"] | ||||
|     ], | ||||
|     "public/app/plugins/panel/xychart/scatter.ts:5381": [ | ||||
|       [0, 0, 0, "Do not use any type assertions.", "0"], | ||||
|       [0, 0, 0, "Do not use any type assertions.", "1"], | ||||
|  | @ -6693,8 +6642,7 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "7"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "8"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "9"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "10"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "11"] | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "10"] | ||||
|     ] | ||||
|   }` | ||||
| }; | ||||
|  |  | |||
|  | @ -69,7 +69,7 @@ export class TemplateSrv implements BaseTemplateSrv { | |||
|    * | ||||
|    * Use getVariables function instead | ||||
|    */ | ||||
|   get variables(): any[] { | ||||
|   get variables(): TypedVariableModel[] { | ||||
|     deprecationWarning('template_srv.ts', 'variables', 'getVariables'); | ||||
|     return this.getVariables(); | ||||
|   } | ||||
|  | @ -84,7 +84,7 @@ export class TemplateSrv implements BaseTemplateSrv { | |||
|   } | ||||
| 
 | ||||
|   updateIndex() { | ||||
|     const existsOrEmpty = (value: any) => value || value === ''; | ||||
|     const existsOrEmpty = (value: unknown) => value || value === ''; | ||||
| 
 | ||||
|     this.index = this._variables.reduce((acc, currentValue) => { | ||||
|       if (currentValue.current && (currentValue.current.isNone || existsOrEmpty(currentValue.current.value))) { | ||||
|  | @ -360,7 +360,7 @@ export class TemplateSrv implements BaseTemplateSrv { | |||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   isAllValue(value: any) { | ||||
|   isAllValue(value: unknown) { | ||||
|     return value === ALL_VARIABLE_VALUE || (Array.isArray(value) && value[0] === ALL_VARIABLE_VALUE); | ||||
|   } | ||||
| 
 | ||||
|  |  | |||
|  | @ -409,12 +409,12 @@ function setup(value: string, offset: number, tagsV1?: string[], tagsV2?: Scope[ | |||
|         EnumMember: 2, | ||||
|       }, | ||||
|     }, | ||||
|   } as any; | ||||
|   } as unknown as typeof monacoTypes; | ||||
|   provider.editor = { | ||||
|     getModel() { | ||||
|       return model; | ||||
|     }, | ||||
|   } as any; | ||||
|   } as unknown as monacoTypes.editor.IStandaloneCodeEditor; | ||||
| 
 | ||||
|   return { provider, model } as unknown as { provider: CompletionProvider; model: monacoTypes.editor.ITextModel }; | ||||
| } | ||||
|  |  | |||
|  | @ -183,7 +183,7 @@ type OptionsState = { | |||
| // Exported for tests
 | ||||
| export function useLoadOptions(datasource: ZipkinDatasource) { | ||||
|   const isMounted = useMountedState(); | ||||
|   const [allOptions, setAllOptions] = useState({} as OptionsState); | ||||
|   const [allOptions, setAllOptions] = useState<OptionsState>({}); | ||||
| 
 | ||||
|   const [, fetchSpans] = useAsyncFn( | ||||
|     async function findSpans(service: string): Promise<void> { | ||||
|  |  | |||
|  | @ -61,7 +61,7 @@ export class ZipkinDatasource extends DataSourceApi<ZipkinQuery, ZipkinJsonData> | |||
|     return of(emptyDataQueryResponse); | ||||
|   } | ||||
| 
 | ||||
|   async metadataRequest(url: string, params?: Record<string, any>): Promise<any> { | ||||
|   async metadataRequest(url: string, params?: Record<string, unknown>) { | ||||
|     const res = await lastValueFrom(this.request(url, params, { hideFromInspector: true })); | ||||
|     return res.data; | ||||
|   } | ||||
|  | @ -100,7 +100,7 @@ export class ZipkinDatasource extends DataSourceApi<ZipkinQuery, ZipkinJsonData> | |||
| 
 | ||||
|   private request<T = any>( | ||||
|     apiUrl: string, | ||||
|     data?: any, | ||||
|     data?: unknown, | ||||
|     options?: Partial<BackendSrvRequest> | ||||
|   ): Observable<FetchResponse<T>> { | ||||
|     const params = data ? urlUtil.serializeParams(data) : ''; | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ export const alertListPanelMigrationHandler = ( | |||
|     tags: panel.options.tags ?? panel.dashboardTags ?? [], | ||||
|     stateFilter: | ||||
|       panel.options.stateFilter ?? | ||||
|       panel.stateFilter?.reduce((filterObj: any, curFilter: any) => ({ ...filterObj, [curFilter]: true }), {}) ?? | ||||
|       panel.stateFilter?.reduce((filterObj: object, curFilter: any) => ({ ...filterObj, [curFilter]: true }), {}) ?? | ||||
|       {}, | ||||
|   }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ const defaultOptions: Options = { | |||
|   tags: ['tag A', 'tag B'], | ||||
| }; | ||||
| 
 | ||||
| const defaultResult: any = { | ||||
| const defaultResult = { | ||||
|   text: 'Result text', | ||||
|   userId: 1, | ||||
|   login: 'Result login', | ||||
|  | @ -40,7 +40,7 @@ const defaultResult: any = { | |||
|   time: Date.UTC(2021, 0, 1, 0, 0, 0, 0), | ||||
|   panelId: 13, | ||||
|   dashboardId: 14, // deliberately different from panelId
 | ||||
|   id: 14, | ||||
|   id: '14', | ||||
|   uid: '7MeksYbmk', | ||||
|   dashboardUID: '7MeksYbmk', | ||||
|   url: '/d/asdkjhajksd/some-dash', | ||||
|  | @ -55,7 +55,7 @@ async function setupTestContext({ | |||
|   const getMock = jest.spyOn(backendSrv, 'get'); | ||||
|   getMock.mockResolvedValue(results); | ||||
| 
 | ||||
|   const dash: any = { uid: 'srx16xR4z', formatDate: (time: number) => new Date(time).toISOString() }; | ||||
|   const dash = { uid: 'srx16xR4z', formatDate: (time: number) => new Date(time).toISOString() }; | ||||
|   const dashSrv: any = { getCurrent: () => dash }; | ||||
|   setDashboardSrv(dashSrv); | ||||
|   const pushSpy = jest.spyOn(locationService, 'push'); | ||||
|  |  | |||
|  | @ -90,7 +90,11 @@ export class AnnoListPanel extends PureComponent<Props, State> { | |||
|     const { options } = this.props; | ||||
|     const { queryUser, queryTags } = this.state; | ||||
| 
 | ||||
|     const params: any = { | ||||
|     const params: { | ||||
|       tags: typeof options.tags; | ||||
|       limit: typeof options.limit; | ||||
|       type: string; | ||||
|     } & Record<string, unknown> = { | ||||
|       tags: options.tags, | ||||
|       limit: options.limit, | ||||
|       type: 'annotation', // Skip the Annotations that are really alerts.  (Use the alerts panel!)
 | ||||
|  | @ -139,15 +143,12 @@ export class AnnoListPanel extends PureComponent<Props, State> { | |||
|     const dashboardSrv = getDashboardSrv(); | ||||
|     const current = dashboardSrv.getCurrent(); | ||||
| 
 | ||||
|     const params: any = { | ||||
|     const params = { | ||||
|       from: this._timeOffset(anno.time, options.navigateBefore, true), | ||||
|       to: this._timeOffset(anno.timeEnd ?? anno.time, options.navigateAfter, false), | ||||
|       viewPanel: options.navigateToPanel ? anno.panelId : undefined, | ||||
|     }; | ||||
| 
 | ||||
|     if (options.navigateToPanel) { | ||||
|       params.viewPanel = anno.panelId; | ||||
|     } | ||||
| 
 | ||||
|     if (current?.uid === anno.dashboardUID) { | ||||
|       locationService.partial(params); | ||||
|       return; | ||||
|  | @ -157,8 +158,8 @@ export class AnnoListPanel extends PureComponent<Props, State> { | |||
|     if (result && result.length && result[0].uid === anno.dashboardUID) { | ||||
|       const dash = result[0]; | ||||
|       const url = new URL(dash.url, window.location.origin); | ||||
|       url.searchParams.set('from', params.from); | ||||
|       url.searchParams.set('to', params.to); | ||||
|       url.searchParams.set('from', String(params.from)); | ||||
|       url.searchParams.set('to', String(params.to)); | ||||
|       locationService.push(locationUtil.stripBaseFromUrl(url.toString())); | ||||
|       return; | ||||
|     } | ||||
|  |  | |||
|  | @ -95,9 +95,9 @@ export const plugin = new PanelPlugin<Options>(AnnoListPanel) | |||
|       }); | ||||
|   }) | ||||
|   // TODO, we should support this directly in the plugin infrastructure
 | ||||
|   .setPanelChangeHandler((panel: PanelModel<Options>, prevPluginId: string, prevOptions: unknown) => { | ||||
|   .setPanelChangeHandler((panel: PanelModel<Options>, prevPluginId, prevOptions) => { | ||||
|     if (prevPluginId === 'ryantxu-annolist-panel') { | ||||
|       return prevOptions as Options; | ||||
|       return prevOptions; | ||||
|     } | ||||
| 
 | ||||
|     return panel.options; | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ describe('dashlist migrations', () => { | |||
|     const basePanelModel = wellFormedPanelModel({}); | ||||
|     basePanelModel.pluginVersion = '5.1'; | ||||
| 
 | ||||
|     const angularPanel: PanelModel<any> & AngularModel = { | ||||
|     const angularPanel: PanelModel & AngularModel = { | ||||
|       ...basePanelModel, | ||||
|       // pluginVersion: '5.1',
 | ||||
|       starred: true, | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ export class EventBusLoggerPanel extends PureComponent<Props, State> { | |||
| 
 | ||||
|   eventObserver: PartialObserver<BusEvent> = { | ||||
|     next: (event: BusEvent) => { | ||||
|       const origin = event.origin as any; | ||||
|       const origin: any = event.origin; | ||||
|       this.history.add({ | ||||
|         key: counter++, | ||||
|         type: event.type, | ||||
|  |  | |||
|  | @ -154,6 +154,6 @@ export async function initLayer( | |||
|   return state; | ||||
| } | ||||
| 
 | ||||
| export const getMapLayerState = (l: any) => { | ||||
|   return l?.__state as MapLayerState; | ||||
| export const getMapLayerState = (l: any): MapLayerState => { | ||||
|   return l?.__state; | ||||
| }; | ||||
|  |  | |||
|  | @ -62,7 +62,7 @@ export const pointerMoveListener = (evt: MapBrowserEvent<MouseEvent>, panel: Geo | |||
|   panel.map.forEachFeatureAtPixel( | ||||
|     pixel, | ||||
|     (feature, layer, geo) => { | ||||
|       const s: MapLayerState = getMapLayerState(layer); | ||||
|       const s = getMapLayerState(layer); | ||||
|       //match hover layer to layer in layers
 | ||||
|       //check if the layer show tooltip is enabled
 | ||||
|       //then also pass the list of tooltip fields if exists
 | ||||
|  |  | |||
|  | @ -287,7 +287,9 @@ export class Histogram extends React.Component<HistogramProps, State> { | |||
|   } | ||||
| 
 | ||||
|   prepState(props: HistogramProps, withConfig = true) { | ||||
|     let state: State = null as any; | ||||
|     let state: State = { | ||||
|       alignedData: [], | ||||
|     }; | ||||
| 
 | ||||
|     const { alignedFrame } = props; | ||||
|     if (alignedFrame) { | ||||
|  |  | |||
|  | @ -184,10 +184,10 @@ function inBounds(value: number, min: number | undefined, max: number | undefine | |||
| } | ||||
| 
 | ||||
| // The issue here is that TouchEvent is undefined while using instanceof in Firefox and Safari
 | ||||
| // which will throw an exception but if it's (event as TouchEvent).changedTouches it will be undefined
 | ||||
| // which will throw an exception but if it's event.changedTouches it will be undefined
 | ||||
| // and the if check will fail so it will go to the else but will not throw an exception
 | ||||
| function getEventXY(event: Event): { x: number; y: number } { | ||||
|   if ((event as TouchEvent).changedTouches && event instanceof TouchEvent) { | ||||
|   if ('changedTouches' in event && event instanceof TouchEvent) { | ||||
|     return { x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY }; | ||||
|   } else if (event instanceof MouseEvent) { | ||||
|     return { x: event.clientX, y: event.clientY }; | ||||
|  |  | |||
|  | @ -275,6 +275,7 @@ function makeNodeDatum(options: Partial<NodeDatum> = {}) { | |||
|         config: { | ||||
|           color: { | ||||
|             fixedColor: 'green', | ||||
|             mode: 'fixed', | ||||
|           }, | ||||
|         }, | ||||
|         name: 'arc__success', | ||||
|  | @ -285,6 +286,7 @@ function makeNodeDatum(options: Partial<NodeDatum> = {}) { | |||
|         config: { | ||||
|           color: { | ||||
|             fixedColor: 'red', | ||||
|             mode: 'fixed', | ||||
|           }, | ||||
|         }, | ||||
|         name: 'arc__errors', | ||||
|  |  | |||
|  | @ -370,7 +370,7 @@ function makeNode(index: number) { | |||
| } | ||||
| 
 | ||||
| function nodesFrame() { | ||||
|   const fields: any = { | ||||
|   const fields = { | ||||
|     [NodeGraphDataFrameFieldNames.id]: { | ||||
|       values: [], | ||||
|       type: FieldType.string, | ||||
|  | @ -394,17 +394,17 @@ function nodesFrame() { | |||
|     [NodeGraphDataFrameFieldNames.arc + 'success']: { | ||||
|       values: [], | ||||
|       type: FieldType.number, | ||||
|       config: { color: { fixedColor: 'green' } }, | ||||
|       config: { color: { mode: FieldColorModeId.Fixed, fixedColor: 'green' } }, | ||||
|     }, | ||||
|     [NodeGraphDataFrameFieldNames.arc + 'errors']: { | ||||
|       values: [], | ||||
|       type: FieldType.number, | ||||
|       config: { color: { fixedColor: 'red' } }, | ||||
|       config: { color: { mode: FieldColorModeId.Fixed, fixedColor: 'red' } }, | ||||
|     }, | ||||
|     [NodeGraphDataFrameFieldNames.color]: { | ||||
|       values: [], | ||||
|       type: FieldType.number, | ||||
|       config: { color: { mode: 'continuous-GrYlRd' } }, | ||||
|       config: { color: { mode: FieldColorModeId.ContinuousGrYlRd } }, | ||||
|     }, | ||||
|     [NodeGraphDataFrameFieldNames.icon]: { | ||||
|       values: [], | ||||
|  | @ -418,8 +418,8 @@ function nodesFrame() { | |||
| 
 | ||||
|   return new MutableDataFrame({ | ||||
|     name: 'nodes', | ||||
|     fields: Object.keys(fields).map((key) => ({ | ||||
|       ...fields[key], | ||||
|     fields: Object.entries(fields).map(([key, value]) => ({ | ||||
|       ...value, | ||||
|       name: key, | ||||
|     })), | ||||
|   }); | ||||
|  | @ -440,7 +440,7 @@ export function makeEdgesDataFrame( | |||
| } | ||||
| 
 | ||||
| function edgesFrame() { | ||||
|   const fields: any = { | ||||
|   const fields = { | ||||
|     [NodeGraphDataFrameFieldNames.id]: { | ||||
|       values: [], | ||||
|       type: FieldType.string, | ||||
|  | @ -465,8 +465,8 @@ function edgesFrame() { | |||
| 
 | ||||
|   return new MutableDataFrame({ | ||||
|     name: 'edges', | ||||
|     fields: Object.keys(fields).map((key) => ({ | ||||
|       ...fields[key], | ||||
|     fields: Object.entries(fields).map(([key, value]) => ({ | ||||
|       ...value, | ||||
|       name: key, | ||||
|     })), | ||||
|   }); | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import { Options } from './panelcfg.gen'; | |||
| 
 | ||||
| // This is called when the panel changes from another panel
 | ||||
| export const statPanelChangedHandler = ( | ||||
|   panel: PanelModel<Partial<Options>> | any, | ||||
|   panel: PanelModel<Partial<Options>>, | ||||
|   prevPluginId: string, | ||||
|   prevOptions: any | ||||
| ) => { | ||||
|  |  | |||
|  | @ -1,7 +1,9 @@ | |||
| import { IScope, IAngularStatic } from 'angular'; | ||||
| import $ from 'jquery'; | ||||
| import { defaults } from 'lodash'; | ||||
| 
 | ||||
| import { isTableData, PanelEvents, PanelPlugin } from '@grafana/data'; | ||||
| import { AnnotationsSrv } from 'app/angular/services/annotations_srv'; | ||||
| import config from 'app/core/config'; | ||||
| import { applyFilterFromTable } from 'app/features/variables/adhoc/actions'; | ||||
| import { MetricsPanelCtrl } from 'app/plugins/sdk'; | ||||
|  | @ -56,9 +58,9 @@ export class TablePanelCtrl extends MetricsPanelCtrl { | |||
|   static $inject = ['$scope', '$injector', 'annotationsSrv', '$sanitize']; | ||||
| 
 | ||||
|   constructor( | ||||
|     $scope: any, | ||||
|     $injector: any, | ||||
|     private annotationsSrv: any, | ||||
|     $scope: IScope, | ||||
|     $injector: IAngularStatic['injector'], | ||||
|     private annotationsSrv: AnnotationsSrv, | ||||
|     private $sanitize: any | ||||
|   ) { | ||||
|     super($scope, $injector); | ||||
|  | @ -101,12 +103,11 @@ export class TablePanelCtrl extends MetricsPanelCtrl { | |||
|           panel: this.panel, | ||||
|           range: this.range, | ||||
|         }) | ||||
|         .then((anno: any) => { | ||||
|         .then((anno) => { | ||||
|           this.loading = false; | ||||
|           this.dataRaw = anno; | ||||
|           this.pageIndex = 0; | ||||
|           this.render(); | ||||
|           return { data: this.dataRaw }; // Not used
 | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|  | @ -170,7 +171,7 @@ export class TablePanelCtrl extends MetricsPanelCtrl { | |||
|     this.render(); | ||||
|   } | ||||
| 
 | ||||
|   link(scope: any, elem: JQuery, attrs: any, ctrl: TablePanelCtrl) { | ||||
|   link(scope: IScope, elem: JQuery, attrs: any, ctrl: TablePanelCtrl) { | ||||
|     let data: any; | ||||
|     const panel = ctrl.panel; | ||||
|     let pageCount = 0; | ||||
|  | @ -191,7 +192,7 @@ export class TablePanelCtrl extends MetricsPanelCtrl { | |||
|       tbodyElem.html(ctrl.renderer.render(ctrl.pageIndex)); | ||||
|     } | ||||
| 
 | ||||
|     function switchPage(e: any) { | ||||
|     function switchPage(e: JQueryEventObject) { | ||||
|       const el = $(e.currentTarget); | ||||
|       ctrl.pageIndex = parseInt(el.text(), 10) - 1; | ||||
|       renderPanel(); | ||||
|  | @ -263,7 +264,7 @@ export class TablePanelCtrl extends MetricsPanelCtrl { | |||
|       unbindDestroy(); | ||||
|     }); | ||||
| 
 | ||||
|     ctrl.events.on(PanelEvents.render, (renderData: any) => { | ||||
|     ctrl.events.on(PanelEvents.render, (renderData: unknown) => { | ||||
|       data = renderData || data; | ||||
|       if (data) { | ||||
|         renderPanel(); | ||||
|  |  | |||
|  | @ -399,7 +399,7 @@ export function graphToTimeseriesOptions(angular: any): { | |||
| 
 | ||||
|   // timeRegions migration
 | ||||
|   if (angular.timeRegions?.length) { | ||||
|     let regions: any[] = angular.timeRegions.map((old: GraphTimeRegionConfig, idx: number) => ({ | ||||
|     let regions = angular.timeRegions.map((old: GraphTimeRegionConfig, idx: number) => ({ | ||||
|       name: `T${idx + 1}`, | ||||
|       color: old.colorMode !== 'custom' ? old.colorMode : old.fillColor, | ||||
|       line: old.line, | ||||
|  | @ -684,7 +684,7 @@ function validNumber(val: unknown): number | undefined { | |||
|   return undefined; | ||||
| } | ||||
| 
 | ||||
| function getReducersFromLegend(obj: Record<string, any>): string[] { | ||||
| function getReducersFromLegend(obj: Record<string, unknown>): string[] { | ||||
|   const ids: string[] = []; | ||||
|   for (const key of Object.keys(obj)) { | ||||
|     const r = fieldReducers.getIfExists(key); | ||||
|  |  | |||
|  | @ -45,7 +45,7 @@ export const AutoEditor = ({ value, onChange, context }: StandardEditorProps<XYD | |||
|     }; | ||||
|     const frame = context.data ? context.data[value?.frame ?? 0] : undefined; | ||||
|     if (frame) { | ||||
|       const xName = dims.x ? getFieldDisplayName(dims.x, dims.frame, context.data) : undefined; | ||||
|       const xName = 'x' in dims ? getFieldDisplayName(dims.x, dims.frame, context.data) : undefined; | ||||
|       for (let field of frame.fields) { | ||||
|         if (isGraphable(field)) { | ||||
|           const name = getFieldDisplayName(field, frame, context.data); | ||||
|  |  | |||
|  | @ -15,18 +15,21 @@ export interface XYDimensions { | |||
|   frame: DataFrame; // matches order from configs, excluds non-graphable values
 | ||||
|   x: Field; | ||||
|   fields: XYFieldMatchers; | ||||
|   error?: DimensionError; | ||||
|   hasData?: boolean; | ||||
|   hasTime?: boolean; | ||||
| } | ||||
| 
 | ||||
| export interface XYDimensionsError { | ||||
|   error: DimensionError; | ||||
| } | ||||
| 
 | ||||
| export function isGraphable(field: Field) { | ||||
|   return field.type === FieldType.number; | ||||
| } | ||||
| 
 | ||||
| export function getXYDimensions(cfg?: XYDimensionConfig, data?: DataFrame[]): XYDimensions { | ||||
| export function getXYDimensions(cfg?: XYDimensionConfig, data?: DataFrame[]): XYDimensions | XYDimensionsError { | ||||
|   if (!data || !data.length) { | ||||
|     return { error: DimensionError.NoData } as XYDimensions; | ||||
|     return { error: DimensionError.NoData }; | ||||
|   } | ||||
|   if (!cfg) { | ||||
|     cfg = { | ||||
|  | @ -36,7 +39,7 @@ export function getXYDimensions(cfg?: XYDimensionConfig, data?: DataFrame[]): XY | |||
| 
 | ||||
|   let frame = data[cfg.frame ?? 0]; | ||||
|   if (!frame) { | ||||
|     return { error: DimensionError.BadFrameSelection } as XYDimensions; | ||||
|     return { error: DimensionError.BadFrameSelection }; | ||||
|   } | ||||
| 
 | ||||
|   let xIndex = -1; | ||||
|  | @ -99,5 +102,5 @@ function getSimpleFieldNotMatcher(f: Field): FieldMatcher { | |||
|     return () => false; | ||||
|   } | ||||
|   const m = getSimpleFieldMatcher(f); | ||||
|   return (field) => !m(field, undefined as any, undefined as any); | ||||
|   return (field) => !m(field, { fields: [], length: 0 }, []); | ||||
| } | ||||
|  |  | |||
|  | @ -101,7 +101,7 @@ export function ControllerTestContext(this: any) { | |||
|     }); | ||||
|   }; | ||||
| 
 | ||||
|   this.setIsUtc = (isUtc: any = false) => { | ||||
|   this.setIsUtc = (isUtc = false) => { | ||||
|     self.isUtc = isUtc; | ||||
|   }; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue