Commit 0f3bebb3 by Torkel Ödegaard Committed by GitHub

Snapshots: Fixes so that dashboard snapshots show data when using Stat, Gauge,…

Snapshots: Fixes so that dashboard snapshots show data when using Stat, Gauge, BarGauge or Table panels (#29031)
parent 9d58a4fc
......@@ -9,7 +9,6 @@ import { ErrorBoundary } from '@grafana/ui';
import { getTimeSrv, TimeSrv } from '../services/TimeSrv';
import { applyPanelTimeOverrides } from 'app/features/dashboard/utils/panel';
import { profiler } from 'app/core/profiler';
import { getProcessedDataFrames } from '../state/runRequest';
import config from 'app/core/config';
import { updateLocation } from 'app/core/actions';
// Types
......@@ -28,6 +27,7 @@ import {
PanelPluginMeta,
} from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { loadSnapshotData } from '../utils/loadSnapshotData';
const DEFAULT_PLUGIN_ERROR = 'Error in plugin';
......@@ -83,11 +83,7 @@ export class PanelChrome extends PureComponent<Props, State> {
// Move snapshot data into the query response
if (this.hasPanelSnapshot) {
this.setState({
data: {
...this.state.data,
state: LoadingState.Done,
series: getProcessedDataFrames(panel.snapshotData),
},
data: loadSnapshotData(panel, dashboard),
isFirstLoad: false,
});
return;
......
......@@ -9,7 +9,6 @@ import {
DataConfigSource,
DataLink,
DataQuery,
DataQueryResponseData,
DataTransformerConfig,
eventFactory,
FieldColorConfigSettings,
......@@ -24,6 +23,7 @@ import {
ThresholdsMode,
EventBusExtended,
EventBusSrv,
DataFrameDTO,
} from '@grafana/data';
import { EDIT_PANEL_ID } from 'app/core/constants';
import config from 'app/core/config';
......@@ -129,7 +129,7 @@ export class PanelModel implements DataConfigSource {
thresholds?: any;
pluginVersion?: string;
snapshotData?: DataQueryResponseData[];
snapshotData?: DataFrameDTO[];
timeFrom?: any;
timeShift?: any;
hideTimeOverride?: any;
......
import { applyFieldOverrides, DefaultTimeRange, LoadingState, PanelData } from '@grafana/data';
import { config } from 'app/core/config';
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
import { DashboardModel, PanelModel } from '../state';
import { getProcessedDataFrames } from '../state/runRequest';
export function loadSnapshotData(panel: PanelModel, dashboard: DashboardModel): PanelData {
const data = getProcessedDataFrames(panel.snapshotData);
return {
timeRange: DefaultTimeRange,
state: LoadingState.Done,
series: applyFieldOverrides({
data,
fieldConfig: {
defaults: {},
overrides: [],
},
autoMinMax: true,
replaceVariables: panel.replaceVariables,
getDataSourceSettingsByUid: getDatasourceSrv().getDataSourceSettingsByUid.bind(getDatasourceSrv()),
fieldConfigRegistry: panel.plugin!.fieldConfigRegistry,
theme: config.theme,
timeZone: dashboard.getTimezone(),
}),
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment