mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00
Dashboards: load from storage (#51949)
This commit is contained in:
@ -2,8 +2,10 @@ import { DataSourceInstanceSettings, locationUtil } from '@grafana/data';
|
||||
import { getDataSourceSrv, locationService, getBackendSrv, isFetchError } from '@grafana/runtime';
|
||||
import { notifyApp } from 'app/core/actions';
|
||||
import { createErrorNotification } from 'app/core/copy/appNotification';
|
||||
import { SaveDashboardCommand } from 'app/features/dashboard/components/SaveDashboard/types';
|
||||
import { dashboardWatcher } from 'app/features/live/dashboard/dashboardWatcher';
|
||||
import { DashboardDataDTO, DashboardDTO, FolderInfo, PermissionLevelString, ThunkResult } from 'app/types';
|
||||
import { getGrafanaStorage } from 'app/features/storage/storage';
|
||||
import { DashboardDTO, FolderInfo, PermissionLevelString, ThunkResult } from 'app/types';
|
||||
|
||||
import { LibraryElementExport } from '../../dashboard/components/DashExportModal/DashboardExporter';
|
||||
import { getLibraryPanel } from '../../library-panels/state/api';
|
||||
@ -262,16 +264,13 @@ export function deleteFoldersAndDashboards(folderUids: string[], dashboardUids:
|
||||
return executeInOrder(tasks);
|
||||
}
|
||||
|
||||
export interface SaveDashboardOptions {
|
||||
dashboard: DashboardDataDTO;
|
||||
message?: string;
|
||||
folderId?: number;
|
||||
overwrite?: boolean;
|
||||
}
|
||||
|
||||
export function saveDashboard(options: SaveDashboardOptions) {
|
||||
export function saveDashboard(options: SaveDashboardCommand) {
|
||||
dashboardWatcher.ignoreNextSave();
|
||||
|
||||
if (options.dashboard.uid.indexOf('/') > 0) {
|
||||
return getGrafanaStorage().saveDashboard(options);
|
||||
}
|
||||
|
||||
return getBackendSrv().post('/api/dashboards/db/', {
|
||||
dashboard: options.dashboard,
|
||||
message: options.message ?? '',
|
||||
|
Reference in New Issue
Block a user