diff --git a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx index 9c7494a..e55ae90 100644 --- a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx +++ b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx @@ -8,7 +8,7 @@ import { getDashboardByUid, getDatasources } from '../../../services/grafana_bac import { contextSrv } from 'grafana/app/core/core'; -import { Table, Button, HorizontalGroup, Modal, LoadingPlaceholder } from '@grafana/ui'; +import { Table, Button, HorizontalGroup, Modal, LoadingPlaceholder, TimeRangeInput } from '@grafana/ui'; import { PanelProps, toDataFrame, @@ -20,6 +20,7 @@ import { PanelModel, DataQuery, DataSourceSettings, + TimeRange, } from '@grafana/data'; import { RefreshEvent } from '@grafana/runtime'; @@ -41,6 +42,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { const [isModalOpen, setModalVisibility] = useState(false); + const [selectedTimeRange, setTimeRange] = useState(timeRange); + useEffect(() => { async function getCurrentDashboard(): Promise { const currentDashboardUid = getDashboardUid(window.location.toString()); @@ -90,10 +93,10 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { }, [dashboard, datasources]); // eslint-disable-line react-hooks/exhaustive-deps useEffect(() => { - if (tasks === null) { - return; - } - const dataFrame = getDataFrameForTaskTable(tasks); + // if (tasks === null) { + // return; + // } + const dataFrame = getDataFrameForTaskTable([]); setTasksDataFrame(dataFrame); }, [tasks]); // eslint-disable-line react-hooks/exhaustive-deps @@ -143,9 +146,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { async function onAddTaskClick(): Promise { const selectedQueries = _.filter(queries, (query: QueryTableRowConfig) => query.selected); - // TODO: timerange picker - const timerange: [number, number] = [timeRange.from.unix(), timeRange.to.unix()]; + const timerange: [number, number] = [selectedTimeRange.from.unix(), selectedTimeRange.to.unix()]; // TODO: move this function to API Service await queryApi('/task', { method: 'POST', @@ -375,7 +377,13 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { ) : (
- + + { + setTimeRange(newTimeRange); + }} + />