From e1f8b071edcd14f7a8ea20ef3fadb1ae37fca967 Mon Sep 17 00:00:00 2001 From: rozetko Date: Fri, 30 Dec 2022 14:19:35 +0300 Subject: [PATCH] lint:fix --- .../components/Panel.tsx | 31 ++++++------------- .../corpglory-dataexporter-panel/types.ts | 2 +- src/services/grafana_backend_service.ts | 2 +- src/utils/index.ts | 2 +- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx index 7735c21..cf2d4b4 100644 --- a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx +++ b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx @@ -28,7 +28,6 @@ import * as _ from 'lodash'; interface Props extends PanelProps {} export function Panel({ width, height, timeRange }: Props) { - // TODO: Dashboard type const [dashboard, setDashboard] = useState(null); const [datasources, setDatasources] = useState(null); @@ -45,8 +44,6 @@ export function Panel({ width, height, timeRange }: Props) { async function getCurrentDashboard(): Promise { const currentDashboardUid = getDashboardUid(window.location.toString()); - console.log(currentDashboardUid) - return getDashboardByUid(currentDashboardUid); } @@ -78,22 +75,17 @@ export function Panel({ width, height, timeRange }: Props) { return; } - console.log(panel) - - panel.targets?.forEach( - (target: DataQuery) => { - console.log('uid',target.datasource?.uid) - const datasource = getDatasourceByUid(target.datasource?.uid); - if (!datasource) { - return; - } - queries.push({ ...target, selected: false, panel, datasource }); + panel.targets?.forEach((target: DataQuery) => { + console.log('uid', target.datasource?.uid); + const datasource = getDatasourceByUid(target.datasource?.uid); + if (!datasource) { + return; } - ); + queries.push({ ...target, selected: false, panel, datasource }); + }); - console.log('q', queries) setQueries(queries); - }) + }); }, [dashboard, datasources]); useEffect(() => { @@ -116,13 +108,12 @@ export function Panel({ width, height, timeRange }: Props) { }, []); useEffect(() => { - if(queries === null) { + if (queries === null) { return; } setQueriesDataFrame(getDataFrameForQueriesTable(queries)); }, [queries]); - function getDatasourceByUid(uid?: string): DataSourceSettings | undefined { if (_.isNil(uid)) { console.warn(`uid is required to get datasource`); @@ -170,9 +161,7 @@ export function Panel({ width, height, timeRange }: Props) { if (queries === null) { return; } - setQueries(queries.map( - (query: QueryTableRowConfig) => ({ ...query, selected: false }) - )); + setQueries(queries.map((query: QueryTableRowConfig) => ({ ...query, selected: false }))); } function openDatasourceModal(): void { diff --git a/src/panels/corpglory-dataexporter-panel/types.ts b/src/panels/corpglory-dataexporter-panel/types.ts index 6c69928..2e82846 100644 --- a/src/panels/corpglory-dataexporter-panel/types.ts +++ b/src/panels/corpglory-dataexporter-panel/types.ts @@ -1,4 +1,4 @@ -import { DataQuery, DataSourceRef, DataSourceSettings, PanelModel } from "@grafana/data"; +import { DataQuery, DataSourceRef, DataSourceSettings, PanelModel } from '@grafana/data'; export interface PanelOptions {} diff --git a/src/services/grafana_backend_service.ts b/src/services/grafana_backend_service.ts index ba753d2..565c9f0 100644 --- a/src/services/grafana_backend_service.ts +++ b/src/services/grafana_backend_service.ts @@ -1,4 +1,4 @@ -import { getBackendSrv } from "@grafana/runtime"; +import { getBackendSrv } from '@grafana/runtime'; export async function getDatasources() { const backendSrv = getBackendSrv(); diff --git a/src/utils/index.ts b/src/utils/index.ts index cc67caf..43ac013 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -13,7 +13,7 @@ export function getDashboardUid(url: string): string { } else { return matches[1]; } -}; +} export function convertTimestampToDate(timestamp: number): string { const options: Intl.DateTimeFormatOptions = {