mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-24 05:25:00 +08:00
Add an auto refresh option to the dashboard's syncback requests modal
This commit is contained in:
parent
8e790a0e15
commit
1ce430cd2a
2 changed files with 26 additions and 0 deletions
|
@ -6,6 +6,7 @@ class Modal extends React.Component {
|
|||
this.state = {
|
||||
open: false,
|
||||
onOpen: props.onOpen || () => {},
|
||||
onClose: props.onClose || () => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +31,7 @@ class Modal extends React.Component {
|
|||
|
||||
close() {
|
||||
this.setState({open: false});
|
||||
this.state.onClose();
|
||||
}
|
||||
|
||||
// type can be 'button' or 'div'.
|
||||
|
@ -96,6 +98,7 @@ Modal.propTypes = {
|
|||
className: React.PropTypes.string,
|
||||
id: React.PropTypes.string,
|
||||
onOpen: React.PropTypes.func,
|
||||
onClose: React.PropTypes.func,
|
||||
actionElems: React.PropTypes.arrayOf(React.PropTypes.object),
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ class SyncbackRequestDetails extends React.Component {
|
|||
syncbackRequests: null,
|
||||
counts: null,
|
||||
statusFilter: 'all',
|
||||
refreshInterval: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -49,6 +50,19 @@ class SyncbackRequestDetails extends React.Component {
|
|||
this.setState({statusFilter: statusFilter});
|
||||
}
|
||||
|
||||
setAutoRefresh() {
|
||||
if (document.getElementById('syncback-requests-auto')) {
|
||||
const interval = setInterval(() => {
|
||||
this.getCounts();
|
||||
this.getDetails();
|
||||
}, 3000);
|
||||
this.setState({refreshInterval: interval});
|
||||
} else {
|
||||
clearInterval(this.state.refreshInterval);
|
||||
this.setState({refreshInterval: null});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let counts = "Loading...";
|
||||
if (this.state.counts) {
|
||||
|
@ -133,7 +147,16 @@ class SyncbackRequestDetails extends React.Component {
|
|||
this.getDetails();
|
||||
this.getCounts();
|
||||
}}
|
||||
onClose={() => {
|
||||
clearInterval(this.state.refreshInterval);
|
||||
}}
|
||||
>
|
||||
<input
|
||||
id="syncback-requests-auto"
|
||||
type="checkbox"
|
||||
onChange={() => this.setAutoRefresh.call(this)}
|
||||
/>
|
||||
Auto Refresh <br /><br />
|
||||
<h3>Recent Stats</h3>
|
||||
{counts}
|
||||
<br />
|
||||
|
|
Loading…
Add table
Reference in a new issue