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 { getTimeSrv, TimeSrv } from '../services/TimeSrv';
|
||||||
import { applyPanelTimeOverrides } from 'app/features/dashboard/utils/panel';
|
import { applyPanelTimeOverrides } from 'app/features/dashboard/utils/panel';
|
||||||
import { profiler } from 'app/core/profiler';
|
import { profiler } from 'app/core/profiler';
|
||||||
import { getProcessedDataFrames } from '../state/runRequest';
|
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import { updateLocation } from 'app/core/actions';
|
import { updateLocation } from 'app/core/actions';
|
||||||
// Types
|
// Types
|
||||||
@@ -28,6 +27,7 @@ import {
|
|||||||
PanelPluginMeta,
|
PanelPluginMeta,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
|
import { loadSnapshotData } from '../utils/loadSnapshotData';
|
||||||
|
|
||||||
const DEFAULT_PLUGIN_ERROR = 'Error in plugin';
|
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
|
// Move snapshot data into the query response
|
||||||
if (this.hasPanelSnapshot) {
|
if (this.hasPanelSnapshot) {
|
||||||
this.setState({
|
this.setState({
|
||||||
data: {
|
data: loadSnapshotData(panel, dashboard),
|
||||||
...this.state.data,
|
|
||||||
state: LoadingState.Done,
|
|
||||||
series: getProcessedDataFrames(panel.snapshotData),
|
|
||||||
},
|
|
||||||
isFirstLoad: false,
|
isFirstLoad: false,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
DataConfigSource,
|
DataConfigSource,
|
||||||
DataLink,
|
DataLink,
|
||||||
DataQuery,
|
DataQuery,
|
||||||
DataQueryResponseData,
|
|
||||||
DataTransformerConfig,
|
DataTransformerConfig,
|
||||||
eventFactory,
|
eventFactory,
|
||||||
FieldColorConfigSettings,
|
FieldColorConfigSettings,
|
||||||
@@ -24,6 +23,7 @@ import {
|
|||||||
ThresholdsMode,
|
ThresholdsMode,
|
||||||
EventBusExtended,
|
EventBusExtended,
|
||||||
EventBusSrv,
|
EventBusSrv,
|
||||||
|
DataFrameDTO,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { EDIT_PANEL_ID } from 'app/core/constants';
|
import { EDIT_PANEL_ID } from 'app/core/constants';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
@@ -129,7 +129,7 @@ export class PanelModel implements DataConfigSource {
|
|||||||
thresholds?: any;
|
thresholds?: any;
|
||||||
pluginVersion?: string;
|
pluginVersion?: string;
|
||||||
|
|
||||||
snapshotData?: DataQueryResponseData[];
|
snapshotData?: DataFrameDTO[];
|
||||||
timeFrom?: any;
|
timeFrom?: any;
|
||||||
timeShift?: any;
|
timeShift?: any;
|
||||||
hideTimeOverride?: 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