mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 21:33:08 +01:00
Added a button to start a new scan
This commit is contained in:
24
resources/js/components/Graphics/HistoryGraph.js
vendored
24
resources/js/components/Graphics/HistoryGraph.js
vendored
@@ -62,6 +62,15 @@ export default class HistoryGraph extends Component {
|
||||
display: false,
|
||||
text: 'Speedtests results for the last ' + days + ' days',
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
display: false,
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'DateTime'
|
||||
}
|
||||
}],
|
||||
},
|
||||
};
|
||||
|
||||
var pingData = {
|
||||
@@ -85,6 +94,15 @@ export default class HistoryGraph extends Component {
|
||||
display: false,
|
||||
text: 'Ping results for the last ' + days + ' days',
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
display: false,
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'DateTime'
|
||||
}
|
||||
}],
|
||||
},
|
||||
}
|
||||
|
||||
resp.data.data.forEach(e => {
|
||||
@@ -103,8 +121,8 @@ export default class HistoryGraph extends Component {
|
||||
duData.datasets[0].data.push(download);
|
||||
duData.datasets[1].data.push(upload);
|
||||
pingData.datasets[0].data.push(ping);
|
||||
duData.labels.push(new Date(e.created_at).toLocaleString());
|
||||
pingData.labels.push(new Date(e.created_at).toLocaleString());
|
||||
duData.labels.push(new Date(e.created_at).toLocaleDateString());
|
||||
pingData.labels.push(new Date(e.created_at).toLocaleDateString());
|
||||
});
|
||||
|
||||
this.setState({
|
||||
@@ -150,7 +168,7 @@ export default class HistoryGraph extends Component {
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<Container className="my-4" fluid>
|
||||
<Container className="mb-4 mt-3" fluid>
|
||||
<Row>
|
||||
<Col sm={{ span: 12 }}>
|
||||
<div className="text-center">
|
||||
|
||||
@@ -4,6 +4,8 @@ import Axios from 'axios';
|
||||
import Widget from './Widget';
|
||||
import { Container, Row, Spinner } from 'react-bootstrap';
|
||||
import { Col } from 'react-bootstrap';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
export default class LatestResults extends Component {
|
||||
constructor(props) {
|
||||
@@ -40,6 +42,25 @@ export default class LatestResults extends Component {
|
||||
})
|
||||
}
|
||||
|
||||
newScan = () => {
|
||||
var url = '/api/speedtest/run?token=' + this.state.token.access_token;
|
||||
|
||||
Axios.get(url)
|
||||
.then((resp) => {
|
||||
toast.info('A scan has been queued. This page will refresh when the scan has finished.');
|
||||
})
|
||||
.catch((err) => {
|
||||
if(err.response) {
|
||||
if(err.response.status == 429) {
|
||||
toast.error('You are doing that too much. Try again later.');
|
||||
}
|
||||
console.log(err.response);
|
||||
} else {
|
||||
console.log(err.data);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
var loading = this.state.loading;
|
||||
var data = this.state.data;
|
||||
@@ -104,10 +125,17 @@ export default class LatestResults extends Component {
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col sm={{ span: 12 }} className="text-center">
|
||||
<Col sm={{ span: 12 }} className="text-center mb-2">
|
||||
<p className="text-muted mb-0">Last scan performed at: {new Date(data.data.created_at).toLocaleString()}</p>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col sm={{ span: 12 }} className="text-center">
|
||||
<div>
|
||||
<Button variant="primary" onClick={this.newScan}>Scan again</Button>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user