mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Snapshots: Fixes so that dashboard snapshots show data when using Stat, Gauge, BarGauge or Table panels (#29031)
This commit is contained in:
@@ -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;
|
||||
|
||||
27
public/app/features/dashboard/utils/loadSnapshotData.ts
Normal file
27
public/app/features/dashboard/utils/loadSnapshotData.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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(),
|
||||
}),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user