|
|
@ -3,7 +3,7 @@ import { PanelOptions, TaskTableRowConfig, QueryTableRowConfig, DatasourceType } |
|
|
|
import { convertTimestampToDate, getDashboardUid } from '../../../utils'; |
|
|
|
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 { CLOSE_ICON_BASE_64, DOWNLOAD_ICON_BASE_64, SELECT_ICON_BASE_64, UNSELECT_ICON_BASE_64 } from '../../../icons'; |
|
|
|
|
|
|
|
|
|
|
|
import { getTasks, queryApi } from '../../../services/api_service'; |
|
|
|
import { getStaticFile, getTasks, queryApi } from '../../../services/api_service'; |
|
|
|
import { getDashboardByUid, getDatasources } from '../../../services/grafana_backend_service'; |
|
|
|
import { getDashboardByUid, getDatasources } from '../../../services/grafana_backend_service'; |
|
|
|
|
|
|
|
|
|
|
|
import { contextSrv } from 'grafana/app/core/core'; |
|
|
|
import { contextSrv } from 'grafana/app/core/core'; |
|
|
@ -195,7 +195,7 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { |
|
|
|
targetBlank: false, |
|
|
|
targetBlank: false, |
|
|
|
title: 'Select', |
|
|
|
title: 'Select', |
|
|
|
url: '#', |
|
|
|
url: '#', |
|
|
|
onClick: (event: DataLinkClickEvent) => onDatasourceSelectClick(event, configs), |
|
|
|
onClick: (event: DataLinkClickEvent) => onDatasourceSelectClick(event), |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
@ -276,9 +276,9 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { |
|
|
|
links: [ |
|
|
|
links: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
targetBlank: false, |
|
|
|
targetBlank: false, |
|
|
|
title: 'CSV link', |
|
|
|
title: 'Download', |
|
|
|
// TODO: config.downloadLink
|
|
|
|
url: '#', |
|
|
|
url: 'https://chartwerk.io/', |
|
|
|
onClick: (event: DataLinkClickEvent) => onDownloadClick(event), |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
@ -297,7 +297,7 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { |
|
|
|
targetBlank: false, |
|
|
|
targetBlank: false, |
|
|
|
title: 'Delete', |
|
|
|
title: 'Delete', |
|
|
|
url: '#', |
|
|
|
url: '#', |
|
|
|
onClick: (event: DataLinkClickEvent) => onDeleteClick(event, configs), |
|
|
|
onClick: (event: DataLinkClickEvent) => onDeleteClick(event), |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
@ -317,14 +317,24 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { |
|
|
|
return dataFrames[0]; |
|
|
|
return dataFrames[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onDeleteClick(e: DataLinkClickEvent, tasks: TaskTableRowConfig[]): void { |
|
|
|
function onDeleteClick(e: DataLinkClickEvent): void { |
|
|
|
// TODO: make DELETE request to the api
|
|
|
|
// TODO: make DELETE request to the api
|
|
|
|
const rowIndex = e.origin.rowIndex; |
|
|
|
const rowIndex = e.origin.rowIndex; |
|
|
|
const filteredTasks = _.filter(tasks, (task, idx) => idx !== rowIndex); |
|
|
|
const filteredTasks = _.filter(tasks, (task, idx) => idx !== rowIndex); |
|
|
|
setTasks(filteredTasks); |
|
|
|
setTasks(filteredTasks); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onDatasourceSelectClick(e: DataLinkClickEvent, queries: QueryTableRowConfig[]): void { |
|
|
|
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); |
|
|
|
|
|
|
|
getStaticFile(task?.filename); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onDatasourceSelectClick(e: DataLinkClickEvent): void { |
|
|
|
|
|
|
|
if (queries === null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
const rowIndex = e.origin.rowIndex; |
|
|
|
const rowIndex = e.origin.rowIndex; |
|
|
|
const updatedQueries = _.clone(queries); |
|
|
|
const updatedQueries = _.clone(queries); |
|
|
|
updatedQueries[rowIndex].selected = !updatedQueries[rowIndex].selected; |
|
|
|
updatedQueries[rowIndex].selected = !updatedQueries[rowIndex].selected; |
|
|
|