|
|
@ -8,7 +8,7 @@ import { getDashboardByUid, getDatasources } from '../../../services/grafana_bac |
|
|
|
|
|
|
|
|
|
|
|
import { contextSrv } from 'grafana/app/core/core'; |
|
|
|
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 { |
|
|
|
import { |
|
|
|
PanelProps, |
|
|
|
PanelProps, |
|
|
|
toDataFrame, |
|
|
|
toDataFrame, |
|
|
@ -20,6 +20,7 @@ import { |
|
|
|
PanelModel, |
|
|
|
PanelModel, |
|
|
|
DataQuery, |
|
|
|
DataQuery, |
|
|
|
DataSourceSettings, |
|
|
|
DataSourceSettings, |
|
|
|
|
|
|
|
TimeRange, |
|
|
|
} from '@grafana/data'; |
|
|
|
} from '@grafana/data'; |
|
|
|
import { RefreshEvent } from '@grafana/runtime'; |
|
|
|
import { RefreshEvent } from '@grafana/runtime'; |
|
|
|
|
|
|
|
|
|
|
@ -41,6 +42,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { |
|
|
|
|
|
|
|
|
|
|
|
const [isModalOpen, setModalVisibility] = useState<boolean>(false); |
|
|
|
const [isModalOpen, setModalVisibility] = useState<boolean>(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [selectedTimeRange, setTimeRange] = useState<TimeRange>(timeRange); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
async function getCurrentDashboard(): Promise<any> { |
|
|
|
async function getCurrentDashboard(): Promise<any> { |
|
|
|
const currentDashboardUid = getDashboardUid(window.location.toString()); |
|
|
|
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
|
|
|
|
}, [dashboard, datasources]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (tasks === null) { |
|
|
|
// if (tasks === null) {
|
|
|
|
return; |
|
|
|
// return;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
const dataFrame = getDataFrameForTaskTable(tasks); |
|
|
|
const dataFrame = getDataFrameForTaskTable([]); |
|
|
|
setTasksDataFrame(dataFrame); |
|
|
|
setTasksDataFrame(dataFrame); |
|
|
|
}, [tasks]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
}, [tasks]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
|
|
|
|
|
|
|
@ -143,9 +146,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { |
|
|
|
|
|
|
|
|
|
|
|
async function onAddTaskClick(): Promise<void> { |
|
|
|
async function onAddTaskClick(): Promise<void> { |
|
|
|
const selectedQueries = _.filter(queries, (query: QueryTableRowConfig) => query.selected); |
|
|
|
const selectedQueries = _.filter(queries, (query: QueryTableRowConfig) => query.selected); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: timerange picker
|
|
|
|
// 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
|
|
|
|
// TODO: move this function to API Service
|
|
|
|
await queryApi('/task', { |
|
|
|
await queryApi('/task', { |
|
|
|
method: 'POST', |
|
|
|
method: 'POST', |
|
|
@ -375,7 +377,13 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<Table width={width / 2 - 20} height={height - 40} data={queriesDataFrame} /> |
|
|
|
<Table width={width / 2 - 20} height={height - 40} data={queriesDataFrame} /> |
|
|
|
<HorizontalGroup justify="flex-end"> |
|
|
|
<HorizontalGroup justify="flex-end" spacing="md"> |
|
|
|
|
|
|
|
<TimeRangeInput |
|
|
|
|
|
|
|
value={selectedTimeRange} |
|
|
|
|
|
|
|
onChange={(newTimeRange) => { |
|
|
|
|
|
|
|
setTimeRange(newTimeRange); |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
variant="primary" |
|
|
|
variant="primary" |
|
|
|
aria-label="Add task button" |
|
|
|
aria-label="Add task button" |
|
|
|