wire up TimeRangeDropdown in HostPage
parent
16177ccafd
commit
113847f903
|
@ -1,6 +1,7 @@
|
||||||
import React, {PropTypes} from 'react';
|
import React, {PropTypes} from 'react';
|
||||||
import LayoutRenderer from '../components/LayoutRenderer';
|
import LayoutRenderer from '../components/LayoutRenderer';
|
||||||
import TimeRangeDropdown from '../../shared/components/TimeRangeDropdown';
|
import TimeRangeDropdown from '../../shared/components/TimeRangeDropdown';
|
||||||
|
import timeRanges from 'hson!../../shared/data/timeRanges.hson';
|
||||||
import {fetchLayouts} from '../apis';
|
import {fetchLayouts} from '../apis';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
@ -17,7 +18,12 @@ export const HostPage = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {layouts: []};
|
const pastHourIndex = 2;
|
||||||
|
|
||||||
|
return {
|
||||||
|
layouts: [],
|
||||||
|
timeRange: timeRanges[pastHourIndex],
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -26,10 +32,16 @@ export const HostPage = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleChooseTimeRange({lower}) {
|
||||||
|
const timeRange = timeRanges.find((range) => range.queryValue === lower);
|
||||||
|
this.setState({timeRange});
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const autoRefreshMs = 15000;
|
const autoRefreshMs = 15000;
|
||||||
const source = this.props.source.links.proxy;
|
const source = this.props.source.links.proxy;
|
||||||
const hostID = this.props.params.hostID;
|
const hostID = this.props.params.hostID;
|
||||||
|
const {timeRange} = this.state;
|
||||||
|
|
||||||
const layout = _.head(this.state.layouts);
|
const layout = _.head(this.state.layouts);
|
||||||
|
|
||||||
|
@ -65,7 +77,7 @@ export const HostPage = React.createClass({
|
||||||
<p>Uptime: <strong>2d 4h 33m</strong></p>
|
<p>Uptime: <strong>2d 4h 33m</strong></p>
|
||||||
</div>
|
</div>
|
||||||
<div className="enterprise-header__right">
|
<div className="enterprise-header__right">
|
||||||
<TimeRangeDropdown onChooseTimeRange={_.noop} selected="Past 30 minutes" />
|
<TimeRangeDropdown onChooseTimeRange={handleChooseTimeRange} selected={timeRange.inputValue} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue