import Paper from '@material-ui/core/Paper'; import Table from '@material-ui/core/Table'; import TableBody from '@material-ui/core/TableBody'; import TableCell from '@material-ui/core/TableCell'; import TableHead from '@material-ui/core/TableHead'; import TableRow from '@material-ui/core/TableRow'; import * as React from 'react'; import { IGlobalWindow, IWorkersState } from "./interfaces"; import Worker from "./Worker"; declare var window: IGlobalWindow; class Workers extends React.Component { private fetchLoop: ReturnType; constructor(props: any) { super(props); this.state = {records: []}; } public componentDidMount() { this.fetchWorkers(); this.setFetchWorkerLoop(); } public componentWillUnmount() { if (this.fetchLoop) { clearTimeout(this.fetchLoop); } } public setFetchWorkerLoop(): void { this.fetchLoop = setTimeout(() => { this.fetchWorkers(); this.setFetchWorkerLoop(); }, 3000); } public fetchWorkers(): void { const that = this; fetch(`${window.mountPath}/workers.json`) .then((res) => res.json()) .then((data) => { that.setState(data); }).catch((err) => { console.error(err); }); } public render() { return ( Worker ID Thread Internal Queue Executing Status Polling Models Last Heatbeated At   {this.state.records.map((record) => { return })}
) } } export default Workers;