Skip to content

Commit

Permalink
wip: adminui tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
Jussi Vatjus-Anttila authored and Jussi Vatjus-Anttila committed Oct 3, 2017
1 parent f26f245 commit 97b3c89
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions app/static/admin/components/cluster.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ class ClusterStatus extends React.Component {
this.state = {
clusters: {workers: []},
memory: [], hostCpu: [],
loading: false, version: {}};
loading: false, version: {}
};
this.updateData = this.updateData.bind(this);
this.reloadIntervall = 1000;
}
componentWillUnmount() {
if(this._updateTimeout)
clearTimeout(this.updateData);
}
reload() {
this.reloadIntervall = 500;
this._cluster.restartWorkers()
.then((response) => {
//this.setState({restart: response.data});
});
})
.finally(() => {
this.reloadIntervall = 2000;
})
}
version() {
axios
Expand All @@ -28,6 +39,7 @@ class ClusterStatus extends React.Component {

updateData() {
// show the loading overlay
this._updateTimeout = undefined;
this.setState({loading: true});
// fetch your data
return this.getClusters()
Expand All @@ -39,13 +51,16 @@ class ClusterStatus extends React.Component {
this.state.memory.splice(0, 1);
this.state.hostCpu.splice(0, 1);
}
this.setState({clusters: data, memory: this.state.memory, hostCpu: this.state.hostCpu});
})
.then(() => {
// Update react-table
this.setState({loading: false});
this.setState({
clusters: data,
memory: this.state.memory,
hostCpu: this.state.hostCpu,
loading: false});
})
.then(() => setTimeout(()=> this.updateData(), 2000));
.then(() => {
this._updateTimeout = setTimeout(this.updateData, this.reloadIntervall)
});
}
getClusters() {
return this._cluster.refresh()
Expand Down

0 comments on commit 97b3c89

Please sign in to comment.