mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PanelData: Adds timeRange prop to PanelData (#19361)
* Refactor: Adds newTimeRange property to PanelData * Refactor: Handles timeRange prop after requests * Refactor: Makes timeRange mandatory * Refactor: Adds DefaultTimeRange
This commit is contained in:
committed by
Torkel Ödegaard
parent
e35de167f9
commit
889f8e3131
@@ -14,7 +14,7 @@ import templateSrv from 'app/features/templating/template_srv';
|
||||
import config from 'app/core/config';
|
||||
// Types
|
||||
import { DashboardModel, PanelModel } from '../state';
|
||||
import { LoadingState, ScopedVars, AbsoluteTimeRange, toUtc, toDataFrameDTO } from '@grafana/data';
|
||||
import { LoadingState, ScopedVars, AbsoluteTimeRange, toUtc, toDataFrameDTO, DefaultTimeRange } from '@grafana/data';
|
||||
|
||||
const DEFAULT_PLUGIN_ERROR = 'Error in plugin';
|
||||
|
||||
@@ -52,6 +52,7 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
data: {
|
||||
state: LoadingState.NotStarted,
|
||||
series: [],
|
||||
timeRange: DefaultTimeRange,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -66,6 +67,7 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
if (this.hasPanelSnapshot) {
|
||||
this.setState({
|
||||
data: {
|
||||
...this.state.data,
|
||||
state: LoadingState.Done,
|
||||
series: getProcessedDataFrames(panel.snapshotData),
|
||||
},
|
||||
@@ -241,6 +243,7 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
|
||||
const PanelComponent = plugin.panel;
|
||||
const innerPanelHeight = calculateInnerPanelHeight(panel, height);
|
||||
const timeRange = data.timeRange || this.timeSrv.timeRange();
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -249,7 +252,7 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
<PanelComponent
|
||||
id={panel.id}
|
||||
data={data}
|
||||
timeRange={data.request ? data.request.range : this.timeSrv.timeRange()}
|
||||
timeRange={timeRange}
|
||||
timeZone={this.props.dashboard.getTimezone()}
|
||||
options={panel.getOptions()}
|
||||
transparent={panel.transparent}
|
||||
|
||||
Reference in New Issue
Block a user