You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB
JavaScript

import React from 'react';
import { Heading, Button } from '@chakra-ui/core';
export default class Sources extends React.Component {
constructor(props) {
super(props);
this.state = { loading: false,
fetched: false }
}
refresh = () => {
this.setState({ loading: true });
fetch('/api/refresh-sources', { method: 'POST' })
.then(x => this.setState({ loading: false, fetched: true }));
}
clearTide = () => {
this.setState({ loading: true });
fetch('/api/clear-tide', { method: 'POST' })
.then(x => this.setState({ loading: false }));
}
render() {
return (
<>
<Heading>Sources</Heading>
<Button onClick={this.refresh}>Refresh Sources</Button>
<br /><br />
<Button onClick={this.clearTide}>Clear Tide Data</Button>
<br /><br />
{this.state.loading ? 'Refreshing...' : <></>}
{this.state.fetched ? 'Finished refreshing' : <></>}
</>
);
}
}