mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 13:23:04 +01:00
Grab all stats data in one go
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Actions\GetFailedSpeedtestData;
|
||||
use App\Actions\GetLatestSpeedtestData;
|
||||
use App\Actions\GetSpeedtestTimeData;
|
||||
use App\Helpers\SettingsHelper;
|
||||
use Illuminate\Http\Request;
|
||||
use Validator;
|
||||
|
||||
@@ -28,6 +29,7 @@ class HomepageDataController extends Controller
|
||||
'latest' => run(GetLatestSpeedtestData::class),
|
||||
'time' => run(GetSpeedtestTimeData::class),
|
||||
'fail' => run(GetFailedSpeedtestData::class),
|
||||
'config' => SettingsHelper::getConfig(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
291
public/js/app.js
vendored
291
public/js/app.js
vendored
@@ -134704,19 +134704,88 @@ var HistoryGraph = /*#__PURE__*/function (_Component) {
|
||||
|
||||
_this = _super.call(this, props);
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
|
||||
_this.getData();
|
||||
_defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {});
|
||||
|
||||
var _int = setInterval(_this.getData, 10000);
|
||||
_defineProperty(_assertThisInitialized(_this), "updateDays", function (e) {
|
||||
var days = e.target.value;
|
||||
|
||||
_this.setState({
|
||||
interval: _int
|
||||
});
|
||||
if (days) {
|
||||
react_toastify__WEBPACK_IMPORTED_MODULE_5__["toast"].info('Showing results for the last ' + days + ' days');
|
||||
|
||||
_this.props.updateDays(days);
|
||||
}
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "getDLULPing", function (days) {
|
||||
var url = 'api/speedtest/time/' + days;
|
||||
axios__WEBPACK_IMPORTED_MODULE_2___default.a.get(url).then(function (resp) {
|
||||
_this.state = {
|
||||
days: props.days,
|
||||
time: props.dlUl,
|
||||
fail: props.fail,
|
||||
config: props.config,
|
||||
duData: {},
|
||||
duOptions: {},
|
||||
pingData: {},
|
||||
pingOptions: {},
|
||||
failData: {},
|
||||
failOptions: {},
|
||||
loading: true,
|
||||
interval: null,
|
||||
graph_ul_dl_enabled: true,
|
||||
graph_ul_dl_width: 6,
|
||||
graph_failure_enabled: true,
|
||||
graph_failure_width: 6,
|
||||
graph_ping_enabled: true,
|
||||
graph_ping_width: 6,
|
||||
firstUpdate: false
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(HistoryGraph, [{
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
if (this.state.time != this.props.dlUl || this.state.fail != this.props.fail || this.state.config != this.props.config || this.state.days != this.props.days) {
|
||||
this.setState({
|
||||
time: this.props.dlUl,
|
||||
fail: this.props.fail,
|
||||
config: this.props.config,
|
||||
days: this.props.days
|
||||
});
|
||||
|
||||
if (this.state.config !== null) {
|
||||
this.processData();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.state.firstUpdate && this.state.config !== null) {
|
||||
this.processData();
|
||||
this.setState({
|
||||
firstUpdate: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "processData",
|
||||
value: function processData() {
|
||||
this.processConfig();
|
||||
this.processDlUlPing();
|
||||
this.processFailure();
|
||||
}
|
||||
}, {
|
||||
key: "processConfig",
|
||||
value: function processConfig() {
|
||||
this.setState({
|
||||
graph_ul_dl_enabled: Boolean(Number(this.state.config.graphs.download_upload_graph_enabled.value)),
|
||||
graph_ul_dl_width: this.state.config.graphs.download_upload_graph_width.value,
|
||||
graph_ping_enabled: Boolean(Number(this.state.config.graphs.ping_graph_enabled.value)),
|
||||
graph_ping_width: this.state.config.graphs.ping_graph_width.value,
|
||||
graph_failure_enabled: Boolean(Number(this.state.config.graphs.failure_graph_enabled.value)),
|
||||
graph_failure_width: this.state.config.graphs.failure_graph_width.value
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "processDlUlPing",
|
||||
value: function processDlUlPing() {
|
||||
var days = this.state.days;
|
||||
var duData = {
|
||||
labels: [],
|
||||
datasets: [{
|
||||
@@ -134800,7 +134869,7 @@ var HistoryGraph = /*#__PURE__*/function (_Component) {
|
||||
}
|
||||
}
|
||||
};
|
||||
resp.data.data.forEach(function (e) {
|
||||
this.state.time.forEach(function (e) {
|
||||
var download = {
|
||||
t: new Date(e.created_at),
|
||||
y: e.download
|
||||
@@ -134819,22 +134888,18 @@ var HistoryGraph = /*#__PURE__*/function (_Component) {
|
||||
duData.labels.push(new Date(e.created_at).toLocaleString());
|
||||
pingData.labels.push(new Date(e.created_at).toLocaleString());
|
||||
});
|
||||
|
||||
_this.setState({
|
||||
this.setState({
|
||||
duData: duData,
|
||||
duOptions: duOptions,
|
||||
pingData: pingData,
|
||||
pingOptions: pingOptions,
|
||||
loading: false
|
||||
});
|
||||
})["catch"](function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "getFailure", function (days) {
|
||||
var url = 'api/speedtest/fail/' + days;
|
||||
axios__WEBPACK_IMPORTED_MODULE_2___default.a.get(url).then(function (resp) {
|
||||
}
|
||||
}, {
|
||||
key: "processFailure",
|
||||
value: function processFailure() {
|
||||
var days = this.state.days;
|
||||
var failData = {
|
||||
labels: [],
|
||||
datasets: [{
|
||||
@@ -134866,7 +134931,7 @@ var HistoryGraph = /*#__PURE__*/function (_Component) {
|
||||
}]
|
||||
}
|
||||
};
|
||||
resp.data.data.forEach(function (e) {
|
||||
this.state.fail.forEach(function (e) {
|
||||
var success = {
|
||||
x: e.date,
|
||||
y: e.success
|
||||
@@ -134883,82 +134948,10 @@ var HistoryGraph = /*#__PURE__*/function (_Component) {
|
||||
day: '2-digit'
|
||||
}));
|
||||
});
|
||||
|
||||
_this.setState({
|
||||
this.setState({
|
||||
failData: failData,
|
||||
failOptions: failOptions
|
||||
});
|
||||
})["catch"](function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "getData", function () {
|
||||
var days = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.days;
|
||||
axios__WEBPACK_IMPORTED_MODULE_2___default.a.get('api/settings/config').then(function (resp) {
|
||||
var data = resp.data.graphs;
|
||||
|
||||
_this.setState({
|
||||
graph_ul_dl_enabled: Boolean(Number(data.download_upload_graph_enabled.value)),
|
||||
graph_ul_dl_width: data.download_upload_graph_width.value,
|
||||
graph_ping_enabled: Boolean(Number(data.ping_graph_enabled.value)),
|
||||
graph_ping_width: data.ping_graph_width.value,
|
||||
graph_failure_enabled: Boolean(Number(data.failure_graph_enabled.value)),
|
||||
graph_failure_width: data.failure_graph_width.value
|
||||
});
|
||||
|
||||
_this.getDLULPing(days);
|
||||
|
||||
_this.getFailure(days);
|
||||
})["catch"](function (err) {
|
||||
console.log('Couldn\'t get the site config');
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "updateDays", function (e) {
|
||||
var days = e.target.value;
|
||||
|
||||
if (days) {
|
||||
_this.getData(days);
|
||||
|
||||
clearInterval(_this.state["int"]);
|
||||
|
||||
var _int2 = setInterval(_this.getData, 10000);
|
||||
|
||||
react_toastify__WEBPACK_IMPORTED_MODULE_5__["toast"].info('Showing results for the last ' + days + ' days');
|
||||
|
||||
_this.setState({
|
||||
days: days,
|
||||
interval: _int2
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_this.state = {
|
||||
days: 7,
|
||||
duData: {},
|
||||
duOptions: {},
|
||||
pingData: {},
|
||||
pingOptions: {},
|
||||
failData: {},
|
||||
failOptions: {},
|
||||
loading: true,
|
||||
interval: null,
|
||||
graph_ul_dl_enabled: true,
|
||||
graph_ul_dl_width: 6,
|
||||
graph_failure_enabled: true,
|
||||
graph_failure_width: 6,
|
||||
graph_ping_enabled: true,
|
||||
graph_ping_width: 6
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(HistoryGraph, [{
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
clearInterval(this.state.interval);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
@@ -135187,32 +135180,6 @@ var LatestResults = /*#__PURE__*/function (_Component) {
|
||||
|
||||
_this = _super.call(this, props);
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
|
||||
_this.getData();
|
||||
|
||||
var _int = setInterval(_this.getData, 10000);
|
||||
|
||||
_this.setState({
|
||||
interval: _int
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "getData", function () {
|
||||
var url = 'api/speedtest/latest';
|
||||
axios__WEBPACK_IMPORTED_MODULE_2___default.a.get(url).then(function (resp) {
|
||||
_this.setState({
|
||||
data: resp.data,
|
||||
loading: false
|
||||
});
|
||||
})["catch"](function (err) {
|
||||
_this.setState({
|
||||
data: false
|
||||
});
|
||||
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "newScan", function () {
|
||||
var url = 'api/speedtest/run?token=' + window.token;
|
||||
axios__WEBPACK_IMPORTED_MODULE_2___default.a.get(url).then(function (resp) {
|
||||
@@ -135231,7 +135198,7 @@ var LatestResults = /*#__PURE__*/function (_Component) {
|
||||
});
|
||||
|
||||
_this.state = {
|
||||
data: {},
|
||||
data: props.data,
|
||||
interval: null,
|
||||
loading: true
|
||||
};
|
||||
@@ -135239,6 +135206,16 @@ var LatestResults = /*#__PURE__*/function (_Component) {
|
||||
}
|
||||
|
||||
_createClass(LatestResults, [{
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
if (this.state.data !== this.props.data) {
|
||||
this.setState({
|
||||
data: this.props.data,
|
||||
loading: false
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
clearInterval(this.state.interval);
|
||||
@@ -136022,6 +135999,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _Login__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Login */ "./resources/js/components/Login.js");
|
||||
/* harmony import */ var _Authentication_Authentication__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Authentication/Authentication */ "./resources/js/components/Authentication/Authentication.js");
|
||||
/* harmony import */ var _Navbar__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Navbar */ "./resources/js/components/Navbar.js");
|
||||
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
|
||||
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_10__);
|
||||
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"); } }
|
||||
@@ -136044,6 +136023,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -136060,18 +136042,79 @@ var HomePage = /*#__PURE__*/function (_Component) {
|
||||
|
||||
var _super = _createSuper(HomePage);
|
||||
|
||||
function HomePage() {
|
||||
function HomePage(props) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, HomePage);
|
||||
|
||||
return _super.apply(this, arguments);
|
||||
_this = _super.call(this, props);
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
|
||||
_this.getData();
|
||||
|
||||
var interval = setInterval(_this.getData, 10000);
|
||||
|
||||
_this.setState({
|
||||
interval: interval
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "updateDays", function (days) {
|
||||
_this.setState({
|
||||
days: days
|
||||
});
|
||||
|
||||
_this.getData();
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "getData", function () {
|
||||
axios__WEBPACK_IMPORTED_MODULE_10___default.a.get('api/speedtest/home/' + _this.state.days).then(function (resp) {
|
||||
_this.setState({
|
||||
latest: resp.data.latest,
|
||||
time: resp.data.time,
|
||||
fail: resp.data.fail,
|
||||
config: resp.data.config
|
||||
});
|
||||
})["catch"](function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
_this.state = {
|
||||
latest: null,
|
||||
time: null,
|
||||
fail: null,
|
||||
config: null,
|
||||
days: 7,
|
||||
interval: null
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(HomePage, [{
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
clearInterval(this.state.interval);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var latest = this.state.latest;
|
||||
var time = this.state.time;
|
||||
var fail = this.state.fail;
|
||||
var config = this.state.config;
|
||||
var days = this.state.days;
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Navbar__WEBPACK_IMPORTED_MODULE_9__["default"], null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
|
||||
className: "my-4"
|
||||
}, window.config.auth == true && window.authenticated == false && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Login__WEBPACK_IMPORTED_MODULE_7__["default"], null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Graphics_LatestResults__WEBPACK_IMPORTED_MODULE_3__["default"], null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Graphics_HistoryGraph__WEBPACK_IMPORTED_MODULE_2__["default"], null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Footer__WEBPACK_IMPORTED_MODULE_4__["default"], null));
|
||||
}, window.config.auth == true && window.authenticated == false && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Login__WEBPACK_IMPORTED_MODULE_7__["default"], null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Graphics_LatestResults__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
||||
data: latest
|
||||
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Graphics_HistoryGraph__WEBPACK_IMPORTED_MODULE_2__["default"], {
|
||||
updateDays: this.updateDays,
|
||||
dlUl: time,
|
||||
fail: fail,
|
||||
config: config,
|
||||
days: days
|
||||
})), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Footer__WEBPACK_IMPORTED_MODULE_4__["default"], null));
|
||||
}
|
||||
}]);
|
||||
|
||||
|
||||
113
resources/js/components/Graphics/HistoryGraph.js
vendored
113
resources/js/components/Graphics/HistoryGraph.js
vendored
@@ -11,7 +11,10 @@ export default class HistoryGraph extends Component {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
days: 7,
|
||||
days: props.days,
|
||||
time: props.dlUl,
|
||||
fail: props.fail,
|
||||
config: props.config,
|
||||
duData: {},
|
||||
duOptions: {},
|
||||
pingData: {},
|
||||
@@ -26,26 +29,63 @@ export default class HistoryGraph extends Component {
|
||||
graph_failure_width: 6,
|
||||
graph_ping_enabled: true,
|
||||
graph_ping_width: 6,
|
||||
firstUpdate: false,
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
this.getData();
|
||||
var int = setInterval(this.getData, 10000);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if(
|
||||
this.state.time != this.props.dlUl ||
|
||||
this.state.fail != this.props.fail ||
|
||||
this.state.config != this.props.config ||
|
||||
this.state.days != this.props.days
|
||||
) {
|
||||
this.setState({
|
||||
interval: int,
|
||||
time: this.props.dlUl,
|
||||
fail: this.props.fail,
|
||||
config: this.props.config,
|
||||
days: this.props.days
|
||||
});
|
||||
|
||||
if(this.state.config !== null) {
|
||||
this.processData();
|
||||
}
|
||||
}
|
||||
|
||||
if(
|
||||
!this.state.firstUpdate &&
|
||||
this.state.config !== null
|
||||
) {
|
||||
this.processData();
|
||||
this.setState({
|
||||
firstUpdate: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
processData() {
|
||||
this.processConfig();
|
||||
this.processDlUlPing();
|
||||
this.processFailure();
|
||||
}
|
||||
|
||||
processConfig() {
|
||||
this.setState({
|
||||
graph_ul_dl_enabled: Boolean(Number(this.state.config.graphs.download_upload_graph_enabled.value)),
|
||||
graph_ul_dl_width: this.state.config.graphs.download_upload_graph_width.value,
|
||||
graph_ping_enabled: Boolean(Number(this.state.config.graphs.ping_graph_enabled.value)),
|
||||
graph_ping_width: this.state.config.graphs.ping_graph_width.value,
|
||||
graph_failure_enabled: Boolean(Number(this.state.config.graphs.failure_graph_enabled.value)),
|
||||
graph_failure_width: this.state.config.graphs.failure_graph_width.value,
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.state.interval);
|
||||
}
|
||||
processDlUlPing() {
|
||||
let days = this.state.days;
|
||||
|
||||
getDLULPing = (days) => {
|
||||
var url = 'api/speedtest/time/' + days;
|
||||
|
||||
Axios.get(url)
|
||||
.then((resp) => {
|
||||
var duData = {
|
||||
labels: [],
|
||||
datasets:[
|
||||
@@ -132,7 +172,7 @@ export default class HistoryGraph extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
resp.data.data.forEach(e => {
|
||||
this.state.time.forEach(e => {
|
||||
var download = {
|
||||
t: new Date(e.created_at),
|
||||
y: e.download,
|
||||
@@ -159,16 +199,11 @@ export default class HistoryGraph extends Component {
|
||||
pingOptions: pingOptions,
|
||||
loading: false,
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
getFailure = (days) => {
|
||||
var url = 'api/speedtest/fail/' + days;
|
||||
Axios.get(url)
|
||||
.then((resp) => {
|
||||
processFailure() {
|
||||
let days = this.state.days;
|
||||
|
||||
var failData = {
|
||||
labels: [],
|
||||
datasets: [
|
||||
@@ -202,7 +237,7 @@ export default class HistoryGraph extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
resp.data.data.forEach(e => {
|
||||
this.state.fail.forEach(e => {
|
||||
var success = {x: e.date, y: e.success};
|
||||
var fail = {x: e.date, y: e.failure};
|
||||
failData.datasets[0].data.push(success);
|
||||
@@ -214,45 +249,13 @@ export default class HistoryGraph extends Component {
|
||||
failData: failData,
|
||||
failOptions: failOptions
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
getData = (days = this.state.days) => {
|
||||
Axios.get('api/settings/config')
|
||||
.then((resp) => {
|
||||
var data = resp.data.graphs;
|
||||
this.setState({
|
||||
graph_ul_dl_enabled: Boolean(Number(data.download_upload_graph_enabled.value)),
|
||||
graph_ul_dl_width: data.download_upload_graph_width.value,
|
||||
graph_ping_enabled: Boolean(Number(data.ping_graph_enabled.value)),
|
||||
graph_ping_width: data.ping_graph_width.value,
|
||||
graph_failure_enabled: Boolean(Number(data.failure_graph_enabled.value)),
|
||||
graph_failure_width: data.failure_graph_width.value,
|
||||
});
|
||||
|
||||
this.getDLULPing(days);
|
||||
this.getFailure(days);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Couldn\'t get the site config');
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
updateDays = (e) => {
|
||||
var days = e.target.value;
|
||||
if(days) {
|
||||
this.getData(days);
|
||||
clearInterval(this.state.int);
|
||||
var int = setInterval(this.getData, 10000);
|
||||
toast.info('Showing results for the last ' + days + ' days');
|
||||
this.setState({
|
||||
days: days,
|
||||
interval: int
|
||||
});
|
||||
this.props.updateDays(days);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,42 +12,25 @@ export default class LatestResults extends Component {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
data: {},
|
||||
data: props.data,
|
||||
interval: null,
|
||||
loading: true,
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
this.getData();
|
||||
var int = setInterval(this.getData, 10000);
|
||||
componentDidUpdate() {
|
||||
if(this.state.data !== this.props.data) {
|
||||
this.setState({
|
||||
interval: int,
|
||||
data: this.props.data,
|
||||
loading: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.state.interval);
|
||||
}
|
||||
|
||||
getData = () => {
|
||||
var url = 'api/speedtest/latest';
|
||||
|
||||
Axios.get(url)
|
||||
.then((resp) => {
|
||||
this.setState({
|
||||
data: resp.data,
|
||||
loading: false
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setState({
|
||||
data: false
|
||||
});
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
newScan = () => {
|
||||
var url = 'api/speedtest/run?token=' + window.token;
|
||||
|
||||
|
||||
56
resources/js/components/Home/HomePage.js
vendored
56
resources/js/components/Home/HomePage.js
vendored
@@ -8,10 +8,62 @@ import TestsTable from '../Graphics/TestsTable';
|
||||
import Login from '../Login';
|
||||
import Authentication from '../Authentication/Authentication';
|
||||
import Navbar from '../Navbar';
|
||||
import axios from 'axios';
|
||||
|
||||
export default class HomePage extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
latest: null,
|
||||
time: null,
|
||||
fail: null,
|
||||
config: null,
|
||||
days: 7,
|
||||
interval: null,
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
this.getData();
|
||||
var interval = setInterval(this.getData, 10000);
|
||||
this.setState({
|
||||
interval: interval,
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.state.interval);
|
||||
}
|
||||
|
||||
updateDays = (days) => {
|
||||
this.setState({ days: days });
|
||||
this.getData();
|
||||
}
|
||||
|
||||
|
||||
getData = () => {
|
||||
axios.get('api/speedtest/home/' + this.state.days)
|
||||
.then((resp) => {
|
||||
this.setState({
|
||||
latest: resp.data.latest,
|
||||
time: resp.data.time,
|
||||
fail: resp.data.fail,
|
||||
config: resp.data.config
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
let latest = this.state.latest;
|
||||
let time = this.state.time;
|
||||
let fail = this.state.fail;
|
||||
let config = this.state.config;
|
||||
let days = this.state.days;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Navbar />
|
||||
@@ -19,8 +71,8 @@ export default class HomePage extends Component {
|
||||
{(window.config.auth == true && window.authenticated == false) &&
|
||||
<Login />
|
||||
}
|
||||
<LatestResults />
|
||||
<HistoryGraph />
|
||||
<LatestResults data={latest} />
|
||||
<HistoryGraph updateDays={this.updateDays} dlUl={time} fail={fail} config={config} days={days} />
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\BackupController;
|
||||
use App\Http\Controllers\HomepageDataController;
|
||||
use App\Http\Controllers\SettingsController;
|
||||
use App\Http\Controllers\SpeedtestController;
|
||||
use App\Http\Controllers\UpdateController;
|
||||
use App\Speedtest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@@ -18,34 +23,36 @@ use Illuminate\Support\Facades\Route;
|
||||
*/
|
||||
|
||||
Route::group([
|
||||
'middleware' => [ 'api' ],
|
||||
'middleware' => ['api'],
|
||||
'prefix' => 'speedtest'
|
||||
], function($router) {
|
||||
Route::get('/', 'SpeedtestController@index')
|
||||
], function ($router) {
|
||||
Route::get('/', [SpeedtestController::class, 'index'])
|
||||
->name('speedtest.index');
|
||||
Route::get('latest', 'SpeedtestController@latest')
|
||||
Route::get('latest', [SpeedtestController::class, 'latest'])
|
||||
->name('speedtest.latest');
|
||||
Route::get('time/{time}', 'SpeedtestController@time')
|
||||
Route::get('time/{time}', [SpeedtestController::class, 'time'])
|
||||
->name('speedtest.time');
|
||||
Route::get('fail/{time}', 'SpeedtestController@fail')
|
||||
Route::get('fail/{time}', [SpeedtestController::class, 'fail'])
|
||||
->name('speedtest.fail');
|
||||
Route::get('run', 'SpeedtestController@run')
|
||||
Route::get('run', [SpeedtestController::class, 'run'])
|
||||
->name('speedtest.run');
|
||||
Route::get('home/{time}', HomepageDataController::class)
|
||||
->name('speedtest.home');
|
||||
|
||||
Route::group([
|
||||
'prefix' => 'delete'
|
||||
], function () {
|
||||
Route::delete('all', 'SpeedtestController@deleteAll');
|
||||
Route::delete('{speedtest}', 'SpeedtestController@delete');
|
||||
Route::delete('all', [SpeedtestController::class, 'deleteAll']);
|
||||
Route::delete('{speedtest}', [SpeedtestController::class, 'delete']);
|
||||
});
|
||||
});
|
||||
|
||||
Route::group([
|
||||
'middleware' => 'api'
|
||||
], function () {
|
||||
Route::get('backup', 'BackupController@backup')
|
||||
Route::get('backup', [BackupController::class, 'backup'])
|
||||
->name('data.backup');
|
||||
Route::post('restore', 'BackupController@restore')
|
||||
Route::post('restore', [BackupController::class, 'restore'])
|
||||
->name('data.restore');
|
||||
});
|
||||
|
||||
@@ -53,15 +60,15 @@ Route::group([
|
||||
'middleware' => 'api',
|
||||
'prefix' => 'update',
|
||||
], function () {
|
||||
Route::get('changelog', 'UpdateController@changelog')
|
||||
Route::get('changelog', [UpdateController::class, 'changelog'])
|
||||
->name('update.changelog');
|
||||
Route::get('check', 'UpdateController@checkForUpdate')
|
||||
Route::get('check', [UpdateController::class, 'checkForUpdate'])
|
||||
->name('update.check');
|
||||
Route::get('download', 'UpdateController@downloadUpdate')
|
||||
Route::get('download', [UpdateController::class, 'downloadUpdate'])
|
||||
->name('update.download');
|
||||
Route::get('extract', 'UpdateController@extractUpdate')
|
||||
Route::get('extract', [UpdateController::class, 'extractUpdate'])
|
||||
->name('update.extract');
|
||||
Route::get('move', 'UpdateController@moveUpdate')
|
||||
Route::get('move', [UpdateController::class, 'moveUpdate'])
|
||||
->name('update.move');
|
||||
});
|
||||
|
||||
@@ -69,19 +76,19 @@ Route::group([
|
||||
'middleware' => 'api',
|
||||
'prefix' => 'settings'
|
||||
], function () {
|
||||
Route::get('/config', 'SettingsController@config')
|
||||
Route::get('/config', [SettingsController::class, 'config'])
|
||||
->name('settings.config');
|
||||
Route::get('/test-notification', 'IntegrationsController@testNotification')
|
||||
->name('settings.test_notification');
|
||||
Route::get('/test-healthchecks/{method}', 'IntegrationsController@testHealthchecks')
|
||||
->name('settings.test_notification');
|
||||
Route::get('/', 'SettingsController@index')
|
||||
Route::get('/', [SettingsController::class, 'index'])
|
||||
->name('settings.index');
|
||||
Route::put('/', 'SettingsController@store')
|
||||
Route::put('/', [SettingsController::class, 'store'])
|
||||
->name('settings.store');
|
||||
Route::post('/', 'SettingsController@store')
|
||||
Route::post('/', [SettingsController::class, 'store'])
|
||||
->name('settings.update');
|
||||
Route::post('/bulk', 'SettingsController@bulkStore')
|
||||
Route::post('/bulk', [SettingsController::class, 'bulkStore'])
|
||||
->name('settings.bulk.update');
|
||||
});
|
||||
|
||||
@@ -91,21 +98,21 @@ Route::group(
|
||||
'prefix' => 'auth'
|
||||
],
|
||||
function ($router) {
|
||||
Route::post('register', 'AuthController@register')->name('auth.register');
|
||||
Route::post('login', 'AuthController@login')->middleware('throttle:60,1')->name('auth.login');
|
||||
Route::get('logout', 'AuthController@logout')->name('auth.logout');
|
||||
Route::get('refresh', 'AuthController@refresh')->middleware('throttle:60,1')->name('auth.refresh');
|
||||
Route::get('me', 'AuthController@me')->middleware('session_active')->name('auth.me');
|
||||
Route::post('change-password', 'AuthController@changePassword')->middleware('session_active')->name('auth.change_password');
|
||||
Route::post('register', [AuthController::class, 'register'])->name('auth.register');
|
||||
Route::post('login', [AuthController::class, 'login'])->middleware('throttle:60,1')->name('auth.login');
|
||||
Route::get('logout', [AuthController::class, 'logout'])->name('auth.logout');
|
||||
Route::get('refresh', [AuthController::class, 'refresh'])->middleware('throttle:60,1')->name('auth.refresh');
|
||||
Route::get('me', [AuthController::class, 'me'])->middleware('session_active')->name('auth.me');
|
||||
Route::post('change-password', [AuthController::class, 'changePassword'])->middleware('session_active')->name('auth.change_password');
|
||||
|
||||
Route::group(
|
||||
[
|
||||
'middleware' => ['api', 'session_active'],
|
||||
'prefix' => 'sessions'
|
||||
],
|
||||
function($router) {
|
||||
Route::get('/', 'AuthController@getSessions')->name('auth.sessions.all');
|
||||
Route::delete('/{id}', 'AuthController@deleteSession')->name('auth.sessions.delete');
|
||||
function ($router) {
|
||||
Route::get('/', [AuthController::class, 'getSessions'])->name('auth.sessions.all');
|
||||
Route::delete('/{id}', [AuthController::class, 'deleteSession'])->name('auth.sessions.delete');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user