|
|
|
@ -26,7 +26,6 @@ import { |
|
|
|
|
UserActionEvent, |
|
|
|
|
GroupByVariable, |
|
|
|
|
AdHocFiltersVariable, |
|
|
|
|
SceneFlexLayout, |
|
|
|
|
} from '@grafana/scenes'; |
|
|
|
|
import { DashboardModel, PanelModel } from 'app/features/dashboard/state'; |
|
|
|
|
import { trackDashboardLoaded } from 'app/features/dashboard/utils/tracking'; |
|
|
|
@ -52,6 +51,7 @@ import { createPanelDataProvider } from '../utils/createPanelDataProvider'; |
|
|
|
|
import { DashboardInteractions } from '../utils/interactions'; |
|
|
|
|
import { |
|
|
|
|
getCurrentValueForOldIntervalModel, |
|
|
|
|
getDashboardSceneFor, |
|
|
|
|
getIntervalsFromQueryString, |
|
|
|
|
getVizPanelKeyForPanelId, |
|
|
|
|
} from '../utils/utils'; |
|
|
|
@ -285,6 +285,7 @@ export function createDashboardSceneFromDashboardModel(oldModel: DashboardModel) |
|
|
|
|
body: new SceneGridLayout({ |
|
|
|
|
isLazy: true, |
|
|
|
|
children: createSceneObjectsForPanels(oldModel.panels), |
|
|
|
|
$behaviors: [trackIfEmpty], |
|
|
|
|
}), |
|
|
|
|
$timeRange: new SceneTimeRange({ |
|
|
|
|
from: oldModel.time.from, |
|
|
|
@ -303,7 +304,6 @@ export function createDashboardSceneFromDashboardModel(oldModel: DashboardModel) |
|
|
|
|
registerDashboardMacro, |
|
|
|
|
registerDashboardSceneTracking(oldModel), |
|
|
|
|
registerPanelInteractionsReporter, |
|
|
|
|
trackIfIsEmpty, |
|
|
|
|
new behaviors.LiveNowTimer(oldModel.liveNow), |
|
|
|
|
], |
|
|
|
|
$data: new DashboardDataLayerSet({ annotationLayers, alertStatesLayer }), |
|
|
|
@ -570,21 +570,6 @@ function registerPanelInteractionsReporter(scene: DashboardScene) { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function trackIfIsEmpty(parent: DashboardScene) { |
|
|
|
|
updateIsEmpty(parent); |
|
|
|
|
|
|
|
|
|
parent.state.body.subscribeToState(() => { |
|
|
|
|
updateIsEmpty(parent); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateIsEmpty(parent: DashboardScene) { |
|
|
|
|
const { body } = parent.state; |
|
|
|
|
if (body instanceof SceneFlexLayout || body instanceof SceneGridLayout) { |
|
|
|
|
parent.setState({ isEmpty: body.state.children.length === 0 }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const convertSnapshotData = (snapshotData: DataFrameDTO[]): DataFrameJSON[] => { |
|
|
|
|
return snapshotData.map((data) => { |
|
|
|
|
return { |
|
|
|
@ -619,3 +604,17 @@ export const convertOldSnapshotToScenesSnapshot = (panel: PanelModel) => { |
|
|
|
|
panel.snapshotData = []; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function trackIfEmpty(grid: SceneGridLayout) { |
|
|
|
|
getDashboardSceneFor(grid).setState({ isEmpty: grid.state.children.length === 0 }); |
|
|
|
|
|
|
|
|
|
const sub = grid.subscribeToState((n, p) => { |
|
|
|
|
if (n.children.length !== p.children.length || n.children !== p.children) { |
|
|
|
|
getDashboardSceneFor(grid).setState({ isEmpty: n.children.length === 0 }); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return () => { |
|
|
|
|
sub.unsubscribe(); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|