diff --git a/public/js/app.js b/public/js/app.js index 10f67c30..da9df9d1 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -126741,6 +126741,15 @@ var HistoryGraph = /*#__PURE__*/function (_Component) { title: { display: false, text: 'Speedtests results for the last ' + days + ' days' + }, + scales: { + xAxes: [{ + display: false, + scaleLabel: { + display: true, + labelString: 'DateTime' + } + }] } }; var pingData = { @@ -126763,6 +126772,15 @@ var HistoryGraph = /*#__PURE__*/function (_Component) { title: { display: false, text: 'Ping results for the last ' + days + ' days' + }, + scales: { + xAxes: [{ + display: false, + scaleLabel: { + display: true, + labelString: 'DateTime' + } + }] } }; resp.data.data.forEach(function (e) { @@ -126781,8 +126799,8 @@ var HistoryGraph = /*#__PURE__*/function (_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({ @@ -126845,7 +126863,7 @@ var HistoryGraph = /*#__PURE__*/function (_Component) { })); } else { return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_3__["Container"], { - className: "my-4", + className: "mb-4 mt-3", fluid: true }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_3__["Row"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_3__["Col"], { sm: { @@ -126938,6 +126956,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var _Widget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Widget */ "./resources/js/components/Graphics/Widget.js"); /* harmony import */ var react_bootstrap__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-bootstrap */ "./node_modules/react-bootstrap/esm/index.js"); +/* harmony import */ var react_toastify__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-toastify */ "./node_modules/react-toastify/esm/react-toastify.js"); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -126969,6 +126988,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope + + var LatestResults = /*#__PURE__*/function (_Component) { _inherits(LatestResults, _Component); @@ -127003,6 +127024,23 @@ var LatestResults = /*#__PURE__*/function (_Component) { }); }); + _defineProperty(_assertThisInitialized(_this), "newScan", function () { + var url = '/api/speedtest/run?token=' + _this.state.token.access_token; + axios__WEBPACK_IMPORTED_MODULE_2___default.a.get(url).then(function (resp) { + react_toastify__WEBPACK_IMPORTED_MODULE_5__["toast"].info('A scan has been queued. This page will refresh when the scan has finished.'); + })["catch"](function (err) { + if (err.response) { + if (err.response.status == 429) { + react_toastify__WEBPACK_IMPORTED_MODULE_5__["toast"].error('You are doing that too much. Try again later.'); + } + + console.log(err.response); + } else { + console.log(err.data); + } + }); + }); + _this.state = { token: _this.props.token, data: {}, @@ -127089,10 +127127,18 @@ var LatestResults = /*#__PURE__*/function (_Component) { sm: { span: 12 }, - className: "text-center" + className: "text-center mb-2" }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", { className: "text-muted mb-0" - }, "Last scan performed at: ", new Date(data.data.created_at).toLocaleString())))); + }, "Last scan performed at: ", new Date(data.data.created_at).toLocaleString()))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_4__["Row"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_4__["Col"], { + sm: { + span: 12 + }, + className: "text-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_4__["Button"], { + variant: "primary", + onClick: this.newScan + }, "Scan again"))))); } } }]); diff --git a/resources/js/components/Graphics/HistoryGraph.js b/resources/js/components/Graphics/HistoryGraph.js index a928cb39..d522e59c 100644 --- a/resources/js/components/Graphics/HistoryGraph.js +++ b/resources/js/components/Graphics/HistoryGraph.js @@ -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 ( - +
diff --git a/resources/js/components/Graphics/LatestResults.js b/resources/js/components/Graphics/LatestResults.js index fd5a2820..0e5d5846 100644 --- a/resources/js/components/Graphics/LatestResults.js +++ b/resources/js/components/Graphics/LatestResults.js @@ -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 { - +

Last scan performed at: {new Date(data.data.created_at).toLocaleString()}

+ + +
+ +
+ +
); }