const React = window.React; const Dropdown = window.Dropdown; class SyncbackRequestDetails extends React.Component { constructor(props) { super(props); this.state = { open: false, accountId: props.accountId, syncbackRequests: null, counts: null, statusFilter: 'all', }; } getDetails() { const req = new XMLHttpRequest(); const url = `${window.location.protocol}/syncback-requests/${this.state.accountId}`; req.open("GET", url, true); req.onreadystatechange = () => { if (req.readyState === XMLHttpRequest.DONE) { if (req.status === 200) { this.setState({syncbackRequests: req.responseText}); } else { console.error(req.responseText); } } } req.send(); } getCounts() { const since = Date.now() - 1000 * 60 * 60; // one hour ago const req = new XMLHttpRequest(); const url = `${window.location.protocol}/syncback-requests/${this.state.accountId}/counts?since=${since}`; req.open("GET", url, true); req.onreadystatechange = () => { if (req.readyState === XMLHttpRequest.DONE) { if (req.status === 200) { this.setState({counts: JSON.parse(req.responseText)}); } else { console.error(req.responseText); } } } req.send(); } setStatusFilter(statusFilter) { this.setState({statusFilter: statusFilter}); } open() { this.getDetails(); this.getCounts(); this.setState({open: true}); } close() { this.setState({open: false}); } render() { if (this.state.open) { let counts = Of requests created in the last hour: ... if (this.state.counts) { const total = this.state.counts.new + this.state.counts.failed + this.state.counts.succeeded; if (total === 0) { counts = "No requests made in the last hour"; } else { counts = (
Status:
|
Type | Created At |
---|