mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DashboardSrv: export getDashboardSrv to react (#16687)
This commit is contained in:
parent
e7f56a74fc
commit
36d88cc994
@ -3,6 +3,7 @@ import { appEvents } from 'app/core/app_events';
|
|||||||
import locationUtil from 'app/core/utils/location_util';
|
import locationUtil from 'app/core/utils/location_util';
|
||||||
import { DashboardModel } from '../state/DashboardModel';
|
import { DashboardModel } from '../state/DashboardModel';
|
||||||
import { removePanel } from '../utils/panel';
|
import { removePanel } from '../utils/panel';
|
||||||
|
import { DashboardMeta } from 'app/types';
|
||||||
|
|
||||||
export class DashboardSrv {
|
export class DashboardSrv {
|
||||||
dashboard: DashboardModel;
|
dashboard: DashboardModel;
|
||||||
@ -12,9 +13,12 @@ export class DashboardSrv {
|
|||||||
appEvents.on('save-dashboard', this.saveDashboard.bind(this), $rootScope);
|
appEvents.on('save-dashboard', this.saveDashboard.bind(this), $rootScope);
|
||||||
appEvents.on('panel-change-view', this.onPanelChangeView);
|
appEvents.on('panel-change-view', this.onPanelChangeView);
|
||||||
appEvents.on('remove-panel', this.onRemovePanel);
|
appEvents.on('remove-panel', this.onRemovePanel);
|
||||||
|
|
||||||
|
// Export to react
|
||||||
|
setDashboardSrv(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
create(dashboard, meta) {
|
create(dashboard: any, meta: DashboardMeta) {
|
||||||
return new DashboardModel(dashboard, meta);
|
return new DashboardModel(dashboard, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,3 +227,17 @@ export class DashboardSrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
coreModule.service('dashboardSrv', DashboardSrv);
|
coreModule.service('dashboardSrv', DashboardSrv);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Code below is to export the service to react components
|
||||||
|
//
|
||||||
|
|
||||||
|
let singletonInstance: DashboardSrv;
|
||||||
|
|
||||||
|
export function setDashboardSrv(instance: DashboardSrv) {
|
||||||
|
singletonInstance = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDashboardSrv(): DashboardSrv {
|
||||||
|
return singletonInstance;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user