From 5976b421fed5142613a8dc4440eb50c51b6efc8d Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 18 Apr 2019 00:00:46 -0700 Subject: [PATCH] refactor: move timeInfo to DataRequestInfo (#16664) * use timeInfo from request * move timeInfo to DataRequestInfo --- packages/grafana-ui/src/types/datasource.ts | 3 ++- .../dashboard/dashgrid/PanelChrome.tsx | 18 ++++++------------ .../dashboard/state/PanelQueryRunner.ts | 3 +++ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/grafana-ui/src/types/datasource.ts b/packages/grafana-ui/src/types/datasource.ts index c71f45fdf77..726b0769dc2 100644 --- a/packages/grafana-ui/src/types/datasource.ts +++ b/packages/grafana-ui/src/types/datasource.ts @@ -223,7 +223,7 @@ export interface ScopedVars { export interface DataQueryOptions { timezone: string; range: TimeRange; - rangeRaw: RawTimeRange; + rangeRaw: RawTimeRange; // Duplicate of results in range. will be deprecated eventually targets: TQuery[]; panelId: number; dashboardId: number; @@ -238,6 +238,7 @@ export interface DataQueryOptions { * Timestamps when the query starts and stops */ export interface DataRequestInfo extends DataQueryOptions { + timeInfo?: string; // The query time description (blue text in the upper right) startTime: number; endTime?: number; } diff --git a/public/app/features/dashboard/dashgrid/PanelChrome.tsx b/public/app/features/dashboard/dashgrid/PanelChrome.tsx index 8a8b41e8352..93a5ffc0c5e 100644 --- a/public/app/features/dashboard/dashgrid/PanelChrome.tsx +++ b/public/app/features/dashboard/dashgrid/PanelChrome.tsx @@ -17,7 +17,7 @@ import config from 'app/core/config'; // Types import { DashboardModel, PanelModel } from '../state'; import { PanelPlugin } from 'app/types'; -import { TimeRange, LoadingState, PanelData } from '@grafana/ui'; +import { LoadingState, PanelData } from '@grafana/ui'; import { ScopedVars } from '@grafana/ui'; import templateSrv from 'app/features/templating/template_srv'; @@ -39,8 +39,6 @@ export interface Props { export interface State { isFirstLoad: boolean; renderCounter: number; - timeInfo?: string; - timeRange?: TimeRange; errorMessage: string | null; // Current state of all events @@ -133,11 +131,6 @@ export class PanelChrome extends PureComponent { const { panel, width } = this.props; const timeData = applyPanelTimeOverrides(panel, this.timeSrv.timeRange()); - this.setState({ - timeRange: timeData.timeRange, - timeInfo: timeData.timeInfo, - }); - // Issue Query if (this.wantsQueryExecution) { if (width < 0) { @@ -157,6 +150,7 @@ export class PanelChrome extends PureComponent { dashboardId: this.props.dashboard.id, timezone: this.props.dashboard.timezone, timeRange: timeData.timeRange, + timeInfo: timeData.timeInfo, widthPixels: width, minInterval: undefined, // Currently not passed in DataPanel? maxDataPoints: panel.maxDataPoints, @@ -201,7 +195,7 @@ export class PanelChrome extends PureComponent { renderPanel(width: number, height: number): JSX.Element { const { panel, plugin } = this.props; - const { timeRange, renderCounter, data, isFirstLoad } = this.state; + const { renderCounter, data, isFirstLoad } = this.state; const PanelComponent = plugin.reactPlugin.panel; // This is only done to increase a counter that is used by backend @@ -222,7 +216,7 @@ export class PanelChrome extends PureComponent {
{ render() { const { dashboard, panel, isFullscreen, width, height } = this.props; - const { errorMessage, timeInfo } = this.state; + const { errorMessage, data } = this.state; const { transparent } = panel; const containerClassNames = `panel-container panel-container--absolute ${transparent ? 'panel-transparent' : ''}`; @@ -253,7 +247,7 @@ export class PanelChrome extends PureComponent { { dashboardId?: number; timezone?: string; timeRange?: TimeRange; + timeInfo?: string; // String description of time range for display widthPixels: number; minInterval?: string; maxDataPoints?: number; @@ -92,6 +93,7 @@ export class PanelQueryRunner { panelId, dashboardId, timeRange, + timeInfo, cacheTimeout, widthPixels, maxDataPoints, @@ -105,6 +107,7 @@ export class PanelQueryRunner { dashboardId, range: timeRange, rangeRaw: timeRange.raw, + timeInfo, interval: '', intervalMs: 0, targets: cloneDeep(queries),