Browse Source

lint:fix

pull/5/head
rozetko 2 years ago
parent
commit
e1f8b071ed
  1. 21
      src/panels/corpglory-dataexporter-panel/components/Panel.tsx
  2. 2
      src/panels/corpglory-dataexporter-panel/types.ts
  3. 2
      src/services/grafana_backend_service.ts
  4. 2
      src/utils/index.ts

21
src/panels/corpglory-dataexporter-panel/components/Panel.tsx

@ -28,7 +28,6 @@ import * as _ from 'lodash';
interface Props extends PanelProps<PanelOptions> {}
export function Panel({ width, height, timeRange }: Props) {
// TODO: Dashboard type
const [dashboard, setDashboard] = useState<any | null>(null);
const [datasources, setDatasources] = useState<DataSourceSettings[] | null>(null);
@ -45,8 +44,6 @@ export function Panel({ width, height, timeRange }: Props) {
async function getCurrentDashboard(): Promise<any> {
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)
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(() => {
@ -122,7 +114,6 @@ export function Panel({ width, height, timeRange }: Props) {
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 {

2
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 {}

2
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();

2
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 = {

Loading…
Cancel
Save