mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Remove unreachable dashboards from datasource code (#96886)
This commit is contained in:
parent
26be86ee15
commit
c63305a700
@ -52,8 +52,6 @@ export class DashboardLoaderSrv {
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
return this._dashboardLoadFailed('Snapshot not found', true);
|
return this._dashboardLoadFailed('Snapshot not found', true);
|
||||||
});
|
});
|
||||||
} else if (type === 'ds' && slug) {
|
|
||||||
promise = this._loadFromDatasource(slug); // explore dashboards as code
|
|
||||||
} else if (type === 'public' && uid) {
|
} else if (type === 'public' && uid) {
|
||||||
promise = backendSrv
|
promise = backendSrv
|
||||||
.getPublicDashboardByUid(uid)
|
.getPublicDashboardByUid(uid)
|
||||||
@ -147,44 +145,6 @@ export class DashboardLoaderSrv {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a temporary solution to load dashboards dynamically from a datasource
|
|
||||||
* Eventually this should become a plugin type or a special handler in the dashboard
|
|
||||||
* loading code
|
|
||||||
*/
|
|
||||||
async _loadFromDatasource(dsid: string) {
|
|
||||||
const ds = await getDatasourceSrv().get(dsid);
|
|
||||||
if (!ds) {
|
|
||||||
return Promise.reject('can not find datasource: ' + dsid);
|
|
||||||
}
|
|
||||||
|
|
||||||
const params = new URLSearchParams(window.location.search);
|
|
||||||
const path = params.get('path');
|
|
||||||
if (!path) {
|
|
||||||
return Promise.reject('expecting path parameter');
|
|
||||||
}
|
|
||||||
|
|
||||||
const queryParams: { [key: string]: string } = {};
|
|
||||||
|
|
||||||
params.forEach((value, key) => {
|
|
||||||
queryParams[key] = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
return getBackendSrv()
|
|
||||||
.get(`/api/datasources/uid/${ds.uid}/resources/${path}`, queryParams)
|
|
||||||
.then((data) => {
|
|
||||||
return {
|
|
||||||
meta: {
|
|
||||||
fromScript: true,
|
|
||||||
canDelete: false,
|
|
||||||
canSave: false,
|
|
||||||
canStar: false,
|
|
||||||
},
|
|
||||||
dashboard: data,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_executeScript(result: any) {
|
_executeScript(result: any) {
|
||||||
const services = {
|
const services = {
|
||||||
dashboardSrv: getDashboardSrv(),
|
dashboardSrv: getDashboardSrv(),
|
||||||
|
Loading…
Reference in New Issue
Block a user