From 33b037dcb1770cb1ec9eb26cef2218903e68083c Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 17 Jul 2018 10:35:33 -0700 Subject: [PATCH] Fix refreshing on HostPage --- ui/src/hosts/containers/HostPage.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ui/src/hosts/containers/HostPage.js b/ui/src/hosts/containers/HostPage.js index f2812c6381..8c3496b9bf 100644 --- a/ui/src/hosts/containers/HostPage.js +++ b/ui/src/hosts/containers/HostPage.js @@ -20,6 +20,7 @@ import {EMPTY_LINKS} from 'src/dashboards/constants/dashboardHeader' import {setAutoRefresh, delayEnablePresentationMode} from 'shared/actions/app' import {ErrorHandling} from 'src/shared/decorators/errors' +import AutoRefresh from 'src/utils/AutoRefresh' @ErrorHandling class HostPage extends Component { @@ -52,7 +53,9 @@ class HostPage extends Component { const { data: {layouts}, } = 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 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 } + componentDidUpdate(prevProps) { + const {autoRefresh} = this.props + if (prevProps.autoRefresh !== autoRefresh) { + AutoRefresh.poll(autoRefresh) + } + } + + componentWillUnmount() { + AutoRefresh.stopPolling() + } + handleChooseTimeRange = ({lower, upper}) => { if (upper) { this.setState({timeRange: {lower, upper}})