|
|
|
@ -3,7 +3,7 @@ import { PanelOptions, TaskTableRowConfig, QueryTableRowConfig, DatasourceType }
|
|
|
|
|
import { convertTimestampToDate, getDashboardUid } from '../../../utils'; |
|
|
|
|
import { CLOSE_ICON_BASE_64, DOWNLOAD_ICON_BASE_64, SELECT_ICON_BASE_64, UNSELECT_ICON_BASE_64 } from '../../../icons'; |
|
|
|
|
|
|
|
|
|
import { getStaticFile, getTasks, queryApi } from '../../../services/api_service'; |
|
|
|
|
import { deleteTask, getStaticFile, getTasks, queryApi } from '../../../services/api_service'; |
|
|
|
|
import { getDashboardByUid, getDatasources } from '../../../services/grafana_backend_service'; |
|
|
|
|
|
|
|
|
|
import { contextSrv } from 'grafana/app/core/core'; |
|
|
|
@ -108,9 +108,17 @@ export function Panel({ width, height, timeRange, eventBus }: Props) {
|
|
|
|
|
}, [queries]); |
|
|
|
|
|
|
|
|
|
function refresh(): void { |
|
|
|
|
console.log('rfrsh') |
|
|
|
|
getTasks() |
|
|
|
|
.then((tasks) => setTasks(tasks)) |
|
|
|
|
.then((tasks) => { |
|
|
|
|
setTasks(tasks); |
|
|
|
|
for (let task of tasks) { |
|
|
|
|
// TODO: ExportStatus enum
|
|
|
|
|
if (task.status === 'exporting') { |
|
|
|
|
setTimeout(refresh, 1000); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.catch((err) => console.error(err)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -317,17 +325,19 @@ export function Panel({ width, height, timeRange, eventBus }: Props) {
|
|
|
|
|
return dataFrames[0]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onDeleteClick(e: DataLinkClickEvent): void { |
|
|
|
|
// TODO: make DELETE request to the api
|
|
|
|
|
async function onDeleteClick(e: DataLinkClickEvent): Promise<void> { |
|
|
|
|
const rowIndex = e.origin.rowIndex; |
|
|
|
|
|
|
|
|
|
const task = _.find(tasks, (task, idx) => idx === rowIndex); |
|
|
|
|
await deleteTask(task?.filename); |
|
|
|
|
|
|
|
|
|
const filteredTasks = _.filter(tasks, (task, idx) => idx !== rowIndex); |
|
|
|
|
setTasks(filteredTasks); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onDownloadClick(e: DataLinkClickEvent): void { |
|
|
|
|
// TODO: make DELETE request to the api
|
|
|
|
|
const rowIndex = e.origin.rowIndex; |
|
|
|
|
const task = _.find(tasks, (task, idx) => idx !== rowIndex); |
|
|
|
|
const task = _.find(tasks, (task, idx) => idx === rowIndex); |
|
|
|
|
getStaticFile(task?.filename); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|