|
|
|
@ -28,7 +28,6 @@ import * as _ from 'lodash';
|
|
|
|
|
interface Props extends PanelProps<PanelOptions> {} |
|
|
|
|
|
|
|
|
|
export function Panel({ width, height, timeRange }: Props) { |
|
|
|
|
|
|
|
|
|
// TODO: Dashboard type
|
|
|
|
|
const [dashboard, setDashboard] = useState<any | null>(null); |
|
|
|
|
const [datasources, setDatasources] = useState<DataSourceSettings[] | null>(null); |
|
|
|
@ -45,8 +44,6 @@ export function Panel({ width, height, timeRange }: Props) {
|
|
|
|
|
async function getCurrentDashboard(): Promise<any> { |
|
|
|
|
const currentDashboardUid = getDashboardUid(window.location.toString()); |
|
|
|
|
|
|
|
|
|
console.log(currentDashboardUid) |
|
|
|
|
|
|
|
|
|
return getDashboardByUid(currentDashboardUid); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -78,22 +75,17 @@ export function Panel({ width, height, timeRange }: Props) {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log(panel) |
|
|
|
|
|
|
|
|
|
panel.targets?.forEach( |
|
|
|
|
(target: DataQuery) => { |
|
|
|
|
console.log('uid',target.datasource?.uid) |
|
|
|
|
panel.targets?.forEach((target: DataQuery) => { |
|
|
|
|
console.log('uid', target.datasource?.uid); |
|
|
|
|
const datasource = getDatasourceByUid(target.datasource?.uid); |
|
|
|
|
if (!datasource) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queries.push({ ...target, selected: false, panel, datasource }); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
console.log('q', queries) |
|
|
|
|
setQueries(queries); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
}, [dashboard, datasources]); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
@ -122,7 +114,6 @@ export function Panel({ width, height, timeRange }: Props) {
|
|
|
|
|
setQueriesDataFrame(getDataFrameForQueriesTable(queries)); |
|
|
|
|
}, [queries]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getDatasourceByUid(uid?: string): DataSourceSettings | undefined { |
|
|
|
|
if (_.isNil(uid)) { |
|
|
|
|
console.warn(`uid is required to get datasource`); |
|
|
|
@ -170,9 +161,7 @@ export function Panel({ width, height, timeRange }: Props) {
|
|
|
|
|
if (queries === null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
setQueries(queries.map( |
|
|
|
|
(query: QueryTableRowConfig) => ({ ...query, selected: false }) |
|
|
|
|
)); |
|
|
|
|
setQueries(queries.map((query: QueryTableRowConfig) => ({ ...query, selected: false }))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function openDatasourceModal(): void { |
|
|
|
|