Merge pull request #3943 from influxdata/bugfix/refresh-host-page

Fix refreshing on HostPage
pull/10616/head
Andrew Watkins 2018-07-17 11:04:01 -07:00 committed by GitHub
commit 11e5fdbb6f
1 changed files with 15 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import {EMPTY_LINKS} from 'src/dashboards/constants/dashboardHeader'
import {setAutoRefresh, delayEnablePresentationMode} from 'shared/actions/app' import {setAutoRefresh, delayEnablePresentationMode} from 'shared/actions/app'
import {ErrorHandling} from 'src/shared/decorators/errors' import {ErrorHandling} from 'src/shared/decorators/errors'
import AutoRefresh from 'src/utils/AutoRefresh'
@ErrorHandling @ErrorHandling
class HostPage extends Component { class HostPage extends Component {
@ -52,7 +53,9 @@ class HostPage extends Component {
const { const {
data: {layouts}, data: {layouts},
} = await getLayouts() } = await getLayouts()
const {location} = this.props const {location, autoRefresh} = this.props
AutoRefresh.poll(autoRefresh)
// fetching layouts and mappings can be done at the same time // fetching layouts and mappings can be done at the same time
const {host, measurements} = await this.fetchHostsAndMeasurements(layouts) const {host, measurements} = await this.fetchHostsAndMeasurements(layouts)
@ -76,6 +79,17 @@ class HostPage extends Component {
this.setState({layouts: filteredLayouts, hostLinks}) // eslint-disable-line react/no-did-mount-set-state this.setState({layouts: filteredLayouts, hostLinks}) // eslint-disable-line react/no-did-mount-set-state
} }
componentDidUpdate(prevProps) {
const {autoRefresh} = this.props
if (prevProps.autoRefresh !== autoRefresh) {
AutoRefresh.poll(autoRefresh)
}
}
componentWillUnmount() {
AutoRefresh.stopPolling()
}
handleChooseTimeRange = ({lower, upper}) => { handleChooseTimeRange = ({lower, upper}) => {
if (upper) { if (upper) {
this.setState({timeRange: {lower, upper}}) this.setState({timeRange: {lower, upper}})