|
@@ -1,28 +1,27 @@
|
|
|
import React, { PureComponent } from 'react';
|
|
import React, { PureComponent } from 'react';
|
|
|
import { hot } from 'react-hot-loader';
|
|
import { hot } from 'react-hot-loader';
|
|
|
import { connect } from 'react-redux';
|
|
import { connect } from 'react-redux';
|
|
|
-import { TimeRange, TimeZone, AbsoluteTimeRange, LoadingState } from '@grafana/ui';
|
|
|
|
|
|
|
+import { TimeZone, AbsoluteTimeRange, LoadingState } from '@grafana/ui';
|
|
|
|
|
|
|
|
import { ExploreId, ExploreItemState } from 'app/types/explore';
|
|
import { ExploreId, ExploreItemState } from 'app/types/explore';
|
|
|
import { StoreState } from 'app/types';
|
|
import { StoreState } from 'app/types';
|
|
|
|
|
|
|
|
-import { toggleGraph, changeTime } from './state/actions';
|
|
|
|
|
|
|
+import { toggleGraph, updateTimeRange } from './state/actions';
|
|
|
import Graph from './Graph';
|
|
import Graph from './Graph';
|
|
|
import Panel from './Panel';
|
|
import Panel from './Panel';
|
|
|
import { getTimeZone } from '../profile/state/selectors';
|
|
import { getTimeZone } from '../profile/state/selectors';
|
|
|
-import { toUtc, dateTime } from '@grafana/ui/src/utils/moment_wrapper';
|
|
|
|
|
|
|
|
|
|
interface GraphContainerProps {
|
|
interface GraphContainerProps {
|
|
|
exploreId: ExploreId;
|
|
exploreId: ExploreId;
|
|
|
graphResult?: any[];
|
|
graphResult?: any[];
|
|
|
loading: boolean;
|
|
loading: boolean;
|
|
|
- range: TimeRange;
|
|
|
|
|
|
|
+ absoluteRange: AbsoluteTimeRange;
|
|
|
timeZone: TimeZone;
|
|
timeZone: TimeZone;
|
|
|
showingGraph: boolean;
|
|
showingGraph: boolean;
|
|
|
showingTable: boolean;
|
|
showingTable: boolean;
|
|
|
split: boolean;
|
|
split: boolean;
|
|
|
toggleGraph: typeof toggleGraph;
|
|
toggleGraph: typeof toggleGraph;
|
|
|
- changeTime: typeof changeTime;
|
|
|
|
|
|
|
+ updateTimeRange: typeof updateTimeRange;
|
|
|
width: number;
|
|
width: number;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -31,20 +30,25 @@ export class GraphContainer extends PureComponent<GraphContainerProps> {
|
|
|
this.props.toggleGraph(this.props.exploreId, this.props.showingGraph);
|
|
this.props.toggleGraph(this.props.exploreId, this.props.showingGraph);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- onChangeTime = (absRange: AbsoluteTimeRange) => {
|
|
|
|
|
- const { exploreId, timeZone, changeTime } = this.props;
|
|
|
|
|
- const range = {
|
|
|
|
|
- from: timeZone === 'utc' ? toUtc(absRange.from) : dateTime(absRange.from),
|
|
|
|
|
- to: timeZone === 'utc' ? toUtc(absRange.to) : dateTime(absRange.to),
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ onChangeTime = (absoluteRange: AbsoluteTimeRange) => {
|
|
|
|
|
+ const { exploreId, updateTimeRange } = this.props;
|
|
|
|
|
|
|
|
- changeTime(exploreId, range);
|
|
|
|
|
|
|
+ updateTimeRange({ exploreId, absoluteRange });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- const { exploreId, graphResult, loading, showingGraph, showingTable, range, split, width, timeZone } = this.props;
|
|
|
|
|
|
|
+ const {
|
|
|
|
|
+ exploreId,
|
|
|
|
|
+ graphResult,
|
|
|
|
|
+ loading,
|
|
|
|
|
+ showingGraph,
|
|
|
|
|
+ showingTable,
|
|
|
|
|
+ absoluteRange,
|
|
|
|
|
+ split,
|
|
|
|
|
+ width,
|
|
|
|
|
+ timeZone,
|
|
|
|
|
+ } = this.props;
|
|
|
const graphHeight = showingGraph && showingTable ? 200 : 400;
|
|
const graphHeight = showingGraph && showingTable ? 200 : 400;
|
|
|
- const timeRange = { from: range.from.valueOf(), to: range.to.valueOf() };
|
|
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<Panel label="Graph" collapsible isOpen={showingGraph} loading={loading} onToggle={this.onClickGraphButton}>
|
|
<Panel label="Graph" collapsible isOpen={showingGraph} loading={loading} onToggle={this.onClickGraphButton}>
|
|
@@ -54,7 +58,7 @@ export class GraphContainer extends PureComponent<GraphContainerProps> {
|
|
|
height={graphHeight}
|
|
height={graphHeight}
|
|
|
id={`explore-graph-${exploreId}`}
|
|
id={`explore-graph-${exploreId}`}
|
|
|
onChangeTime={this.onChangeTime}
|
|
onChangeTime={this.onChangeTime}
|
|
|
- range={timeRange}
|
|
|
|
|
|
|
+ range={absoluteRange}
|
|
|
timeZone={timeZone}
|
|
timeZone={timeZone}
|
|
|
split={split}
|
|
split={split}
|
|
|
width={width}
|
|
width={width}
|
|
@@ -69,14 +73,22 @@ function mapStateToProps(state: StoreState, { exploreId }) {
|
|
|
const explore = state.explore;
|
|
const explore = state.explore;
|
|
|
const { split } = explore;
|
|
const { split } = explore;
|
|
|
const item: ExploreItemState = explore[exploreId];
|
|
const item: ExploreItemState = explore[exploreId];
|
|
|
- const { graphResult, loadingState, range, showingGraph, showingTable } = item;
|
|
|
|
|
|
|
+ const { graphResult, loadingState, showingGraph, showingTable, absoluteRange } = item;
|
|
|
const loading = loadingState === LoadingState.Loading || loadingState === LoadingState.Streaming;
|
|
const loading = loadingState === LoadingState.Loading || loadingState === LoadingState.Streaming;
|
|
|
- return { graphResult, loading, range, showingGraph, showingTable, split, timeZone: getTimeZone(state.user) };
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ graphResult,
|
|
|
|
|
+ loading,
|
|
|
|
|
+ showingGraph,
|
|
|
|
|
+ showingTable,
|
|
|
|
|
+ split,
|
|
|
|
|
+ timeZone: getTimeZone(state.user),
|
|
|
|
|
+ absoluteRange,
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
const mapDispatchToProps = {
|
|
|
toggleGraph,
|
|
toggleGraph,
|
|
|
- changeTime,
|
|
|
|
|
|
|
+ updateTimeRange,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export default hot(module)(
|
|
export default hot(module)(
|