diff --git a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx index 9c7494a..1af10d9 100644 --- a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx +++ b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx @@ -7,8 +7,18 @@ import { deleteTask, getStaticFile, getTasks, queryApi } from '../../../services import { getDashboardByUid, getDatasources } from '../../../services/grafana_backend_service'; import { contextSrv } from 'grafana/app/core/core'; +import { css } from '@emotion/css'; -import { Table, Button, HorizontalGroup, Modal, LoadingPlaceholder } from '@grafana/ui'; +import { + Table, + Button, + HorizontalGroup, + VerticalGroup, + Modal, + LoadingPlaceholder, + TimeRangeInput, + useStyles2, +} from '@grafana/ui'; import { PanelProps, toDataFrame, @@ -20,6 +30,7 @@ import { PanelModel, DataQuery, DataSourceSettings, + TimeRange, } from '@grafana/data'; import { RefreshEvent } from '@grafana/runtime'; @@ -41,6 +52,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()); @@ -143,9 +156,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', @@ -350,6 +362,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { setQueries(updatedQueries); } + const styles = useStyles2(getStyles); + return (
{tasksDataFrame === null ? ( @@ -368,25 +382,39 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { > Add Task - + {queriesDataFrame === null ? ( // TODO: if datasource responds with error, display the error ) : (
- - - - + + + { + setTimeRange(newTimeRange); + }} + /> + +
+ + + + )} @@ -396,3 +424,13 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { ); } + +const getStyles = () => ({ + calendarModal: css` + section { + position: fixed; + top: 20%; + z-index: 1061; + } + `, +});