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:
Hugo Häggmark
2019-09-25 02:19:17 -07:00
committed by Torkel Ödegaard
parent e35de167f9
commit 889f8e3131
16 changed files with 111 additions and 51 deletions

View File

@@ -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}