From 05a643436ae4bafc1e4f31cf0bf1a5cbc9fb71d1 Mon Sep 17 00:00:00 2001 From: rozetko Date: Wed, 18 Jan 2023 19:45:21 +0300 Subject: [PATCH 1/2] upd DashboardQuery type --- src/panels/corpglory-dataexporter-panel/components/Panel.tsx | 5 ++--- src/panels/corpglory-dataexporter-panel/types.ts | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx index e2b1b17..e537936 100644 --- a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx +++ b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx @@ -100,12 +100,11 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { } 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 }); + queries.push({ selected: false, target, panel, datasource }); }); setQueries(queries); @@ -246,7 +245,7 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { { name: 'RefId', type: FieldType.string, - values: _.map(queries, (query) => query.refId), + values: _.map(queries, (query) => query.target.refId), }, { name: 'Datasource', diff --git a/src/panels/corpglory-dataexporter-panel/types.ts b/src/panels/corpglory-dataexporter-panel/types.ts index edacd6f..1af9a8d 100644 --- a/src/panels/corpglory-dataexporter-panel/types.ts +++ b/src/panels/corpglory-dataexporter-panel/types.ts @@ -43,8 +43,9 @@ export type ExportTask = { id?: string; }; -export type DashboardQuery = DataQuery & { +export type DashboardQuery = { selected: boolean; + target: DataQuery; panel: PanelModel; datasource: DataSourceSettings; }; From a9184050f42e98bb2730922426be119b84ef63d7 Mon Sep 17 00:00:00 2001 From: rozetko Date: Thu, 19 Jan 2023 14:40:36 +0300 Subject: [PATCH 2/2] pass timezone to the api --- .../components/Panel.tsx | 11 +++++++---- src/utils/index.ts | 13 ++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx index e537936..cb45844 100644 --- a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx +++ b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx @@ -1,6 +1,6 @@ import { PanelOptions, ExportTask, DashboardQuery, DatasourceType, ExportStatus, PanelStatus } from '../types'; -import { convertTimestampToDate, getDashboardUid } from '../../../utils'; +import { convertTimestampToDate, convertTimeZoneTypeToName, getDashboardUid } from '../../../utils'; import { CLOSE_ICON_BASE_64, DOWNLOAD_ICON_BASE_64, SELECT_ICON_BASE_64, UNSELECT_ICON_BASE_64 } from '../../../icons'; import { deleteTask, getStaticFile, getTasks, queryApi } from '../../../services/api_service'; @@ -43,7 +43,7 @@ const APP_ID = 'corpglory-dataexporter-app'; interface Props extends PanelProps {} -export function Panel({ width, height, timeRange, eventBus }: Props) { +export function Panel({ width, height, timeRange, eventBus, timeZone }: Props) { // TODO: Dashboard type const [dashboard, setDashboard] = useState(null); const [datasources, setDatasources] = useState(null); @@ -60,6 +60,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { const [panelStatus, setPanelStatus] = useState(PanelStatus.LOADING); + const timeZoneName = convertTimeZoneTypeToName(timeZone); + if (contextSrv.user.orgRole !== OrgRole.Admin) { // TODO: it shouldn't be overriten setPanelStatus(PanelStatus.PERMISSION_ERROR); @@ -166,7 +168,7 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { return datasource; } - async function onAddTaskClick(): Promise { + async function onAddTaskClick(timeZoneName: string): Promise { const selectedQueries = _.filter(queries, (query: DashboardQuery) => query.selected); const timerange: [number, number] = [selectedTimeRange.from.unix(), selectedTimeRange.to.unix()]; @@ -185,6 +187,7 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { data: { task, url: window.location.toString(), + timeZoneName, }, }); @@ -437,7 +440,7 @@ export function Panel({ width, height, timeRange, eventBus }: Props) {