|
|
|
@ -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 { getTasks, queryApi } from '../../../services/api_service'; |
|
|
|
|
import { getStaticFile, getTasks, queryApi } from '../../../services/api_service'; |
|
|
|
|
import { getDashboardByUid, getDatasources } from '../../../services/grafana_backend_service'; |
|
|
|
|
|
|
|
|
|
import { contextSrv } from 'grafana/app/core/core'; |
|
|
|
@ -195,7 +195,7 @@ export function Panel({ width, height, timeRange, eventBus }: Props) {
|
|
|
|
|
targetBlank: false, |
|
|
|
|
title: 'Select', |
|
|
|
|
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: [ |
|
|
|
|
{ |
|
|
|
|
targetBlank: false, |
|
|
|
|
title: 'CSV link', |
|
|
|
|
// TODO: config.downloadLink
|
|
|
|
|
url: 'https://chartwerk.io/', |
|
|
|
|
title: 'Download', |
|
|
|
|
url: '#', |
|
|
|
|
onClick: (event: DataLinkClickEvent) => onDownloadClick(event), |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
@ -297,7 +297,7 @@ export function Panel({ width, height, timeRange, eventBus }: Props) {
|
|
|
|
|
targetBlank: false, |
|
|
|
|
title: 'Delete', |
|
|
|
|
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]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onDeleteClick(e: DataLinkClickEvent, tasks: TaskTableRowConfig[]): void { |
|
|
|
|
function onDeleteClick(e: DataLinkClickEvent): void { |
|
|
|
|
// TODO: make DELETE request to the api
|
|
|
|
|
const rowIndex = e.origin.rowIndex; |
|
|
|
|
const filteredTasks = _.filter(tasks, (task, idx) => idx !== rowIndex); |
|
|
|
|
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 updatedQueries = _.clone(queries); |
|
|
|
|
updatedQueries[rowIndex].selected = !updatedQueries[rowIndex].selected; |
|
|
|
|