mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-24 06:28:27 +01:00
Added functions to download latest zip from github
Have moved UpdateHelper into a facade
This commit is contained in:
13
app/Facades/UpdaterFacade.php
Normal file
13
app/Facades/UpdaterFacade.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class UpdaterFacade extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'updater';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,22 +3,37 @@
|
|||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use ZipArchive;
|
||||||
|
|
||||||
class UpdateHelper {
|
class UpdateHelper {
|
||||||
public static function check()
|
public $url;
|
||||||
|
public $currentVersion;
|
||||||
|
public $user;
|
||||||
|
public $repo;
|
||||||
|
public $branch;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
$this->currentVersion = config('speedtest.version');
|
||||||
|
$this->user = config('speedtest.user');
|
||||||
|
$this->repo = config('speedtest.repo');
|
||||||
|
$this->branch = config('speedtest.branch');
|
||||||
|
$this->latestVersion = 'unknown';
|
||||||
|
$this->download = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check()
|
||||||
{
|
{
|
||||||
$current = config('speedtest.version', false);
|
if($this->currentVersion === false) {
|
||||||
if($current === false) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$gitVersion = UpdateHelper::checkLatestVersion();
|
$gitVersion = $this->checkLatestVersion();
|
||||||
if($gitVersion === false) {
|
if($gitVersion === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((bool)(version_compare($current, $gitVersion['version']))) {
|
if((bool)(version_compare($this->currentVersion, $gitVersion['version']))) {
|
||||||
$changelog = UpdateHelper::getChangelog();
|
$changelog = $this->getChangelog();
|
||||||
return [
|
return [
|
||||||
'version' => $gitVersion['version'],
|
'version' => $gitVersion['version'],
|
||||||
'changelog' => $changelog[$gitVersion['version']],
|
'changelog' => $changelog[$gitVersion['version']],
|
||||||
@@ -28,18 +43,15 @@ class UpdateHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkLatestVersion()
|
public function checkLatestVersion()
|
||||||
{
|
{
|
||||||
$user = config('speedtest.user');
|
|
||||||
$repo = config('speedtest.repo');
|
|
||||||
$branch = config('speedtest.branch');
|
|
||||||
|
|
||||||
$url = 'https://raw.githubusercontent.com/'
|
$url = 'https://raw.githubusercontent.com/'
|
||||||
.$user
|
.$this->user
|
||||||
.'/'
|
.'/'
|
||||||
.$repo
|
.$this->repo
|
||||||
.'/'
|
.'/'
|
||||||
.$branch
|
.$this->branch
|
||||||
.'/config/speedtest.php';
|
.'/config/speedtest.php';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -51,27 +63,23 @@ class UpdateHelper {
|
|||||||
$pattern = "/'version' => '([0-9]{1,}\.[0-9]{1,}\.[0-9]{1,})'/";
|
$pattern = "/'version' => '([0-9]{1,}\.[0-9]{1,}\.[0-9]{1,})'/";
|
||||||
$version = [];
|
$version = [];
|
||||||
preg_match($pattern, $gitFile, $version);
|
preg_match($pattern, $gitFile, $version);
|
||||||
$version = $version[1];
|
$this->latestVersion = $version[1];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'repo' => $user . '/' . $repo,
|
'repo' => $this->user . '/' . $this->repo,
|
||||||
'branch' => $branch,
|
'branch' => $this->branch,
|
||||||
'version' => $version,
|
'version' => $this->latestVersion,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getChangelog()
|
public function getChangelog()
|
||||||
{
|
{
|
||||||
$user = config('speedtest.user');
|
|
||||||
$repo = config('speedtest.repo');
|
|
||||||
$branch = config('speedtest.branch');
|
|
||||||
|
|
||||||
$url = 'https://raw.githubusercontent.com/'
|
$url = 'https://raw.githubusercontent.com/'
|
||||||
.$user
|
.$this->user
|
||||||
.'/'
|
.'/'
|
||||||
.$repo
|
.$this->repo
|
||||||
.'/'
|
.'/'
|
||||||
.$branch
|
.$this->branch
|
||||||
.'/changelog.json';
|
.'/changelog.json';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -82,4 +90,44 @@ class UpdateHelper {
|
|||||||
|
|
||||||
return $changelog;
|
return $changelog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downloadLatest()
|
||||||
|
{
|
||||||
|
$url = 'https://github.com/'
|
||||||
|
.$this->user
|
||||||
|
.'/'
|
||||||
|
.$this->repo
|
||||||
|
.'/archive/'
|
||||||
|
.$this->branch
|
||||||
|
.'.zip';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$zip = file_get_contents($url);
|
||||||
|
$name = '/tmp/'.$this->repo.'-update.zip';
|
||||||
|
file_put_contents($name, $zip);
|
||||||
|
return true;
|
||||||
|
} catch(Exception $e) {
|
||||||
|
return $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function extractFiles()
|
||||||
|
{
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
$res = $zip->open('/tmp/'.$this->repo.'-update.zip');
|
||||||
|
if($res === true) {
|
||||||
|
$zip->extractTo('/tmp/'.$this->repo.'-update/');
|
||||||
|
$zip->close();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateFiles()
|
||||||
|
{
|
||||||
|
foreach (glob('/tmp/'.$this->repo.'-update/') as $folder) {
|
||||||
|
return $folder;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Helpers\UpdateHelper;
|
use Updater;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class UpdateController extends Controller
|
class UpdateController extends Controller
|
||||||
@@ -11,7 +11,58 @@ class UpdateController extends Controller
|
|||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'method' => 'check for updates',
|
'method' => 'check for updates',
|
||||||
'update' => UpdateHelper::check(),
|
'update' => Updater::check(),
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downloadUpdate()
|
||||||
|
{
|
||||||
|
$dl = Updater::downloadLatest();
|
||||||
|
|
||||||
|
if($dl) {
|
||||||
|
return response()->json([
|
||||||
|
'method' => 'download latest version',
|
||||||
|
'success' => true,
|
||||||
|
], 200);
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'method' => 'download latest version',
|
||||||
|
'success' => false,
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function extractUpdate()
|
||||||
|
{
|
||||||
|
$ex = Updater::extractFiles();
|
||||||
|
|
||||||
|
if($ex) {
|
||||||
|
return response()->json([
|
||||||
|
'method' => 'extract latest version',
|
||||||
|
'success' => true,
|
||||||
|
], 200);
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'method' => 'extract latest version',
|
||||||
|
'success' => false,
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function moveUpdate()
|
||||||
|
{
|
||||||
|
$cp = Updater::updateFiles();
|
||||||
|
|
||||||
|
if($cp) {
|
||||||
|
return response()->json([
|
||||||
|
'method' => 'copy latest version',
|
||||||
|
'success' => true,
|
||||||
|
], 200);
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'method' => 'copy latest version',
|
||||||
|
'success' => false,
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
31
app/Providers/UpdaterServiceProvider.php
Normal file
31
app/Providers/UpdaterServiceProvider.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Helpers\UpdateHelper;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class UpdaterServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->app->bind('updater', function() {
|
||||||
|
return new UpdateHelper();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
{
|
{
|
||||||
|
"1.2.0": [
|
||||||
|
{
|
||||||
|
"description": "Added an updating mechainism within the app.",
|
||||||
|
"link": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
"1.1.0": [
|
"1.1.0": [
|
||||||
{
|
{
|
||||||
"description": "Added a version number to the app",
|
"description": "Added a version number to the app",
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ return [
|
|||||||
// App\Providers\BroadcastServiceProvider::class,
|
// App\Providers\BroadcastServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
App\Providers\UpdaterServiceProvider::class,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ return [
|
|||||||
'URL' => Illuminate\Support\Facades\URL::class,
|
'URL' => Illuminate\Support\Facades\URL::class,
|
||||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||||
'View' => Illuminate\Support\Facades\View::class,
|
'View' => Illuminate\Support\Facades\View::class,
|
||||||
|
'Updater' => App\Facades\UpdaterFacade::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
177
public/js/app.js
vendored
177
public/js/app.js
vendored
@@ -127670,6 +127670,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");
|
||||||
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
||||||
/* harmony import */ var react_bootstrap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-bootstrap */ "./node_modules/react-bootstrap/esm/index.js");
|
/* harmony import */ var react_bootstrap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-bootstrap */ "./node_modules/react-bootstrap/esm/index.js");
|
||||||
|
/* harmony import */ var _Version__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Version */ "./resources/js/components/Home/Version.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 _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"); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
@@ -127697,35 +127698,27 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var Footer = /*#__PURE__*/function (_Component) {
|
var Footer = /*#__PURE__*/function (_Component) {
|
||||||
_inherits(Footer, _Component);
|
_inherits(Footer, _Component);
|
||||||
|
|
||||||
var _super = _createSuper(Footer);
|
var _super = _createSuper(Footer);
|
||||||
|
|
||||||
function Footer(props) {
|
function Footer() {
|
||||||
var _this;
|
|
||||||
|
|
||||||
_classCallCheck(this, Footer);
|
_classCallCheck(this, Footer);
|
||||||
|
|
||||||
_this = _super.call(this, props);
|
return _super.apply(this, arguments);
|
||||||
_this.state = {
|
|
||||||
version: document.querySelector('meta[name="version"]').content
|
|
||||||
};
|
|
||||||
return _this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(Footer, [{
|
_createClass(Footer, [{
|
||||||
key: "render",
|
key: "render",
|
||||||
value: function render() {
|
value: function render() {
|
||||||
var version = this.state.version;
|
|
||||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_2__["Container"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_2__["Row"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_2__["Col"], {
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_2__["Container"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_2__["Row"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_2__["Col"], {
|
||||||
sm: {
|
sm: {
|
||||||
span: 12
|
span: 12
|
||||||
},
|
},
|
||||||
className: "text-center"
|
className: "text-center"
|
||||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", {
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Version__WEBPACK_IMPORTED_MODULE_3__["default"], null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", {
|
||||||
className: "text-muted mb-0"
|
|
||||||
}, "Speedtest Tracker Version: ", version), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", {
|
|
||||||
className: "text-muted"
|
className: "text-muted"
|
||||||
}, "See the code on ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", {
|
}, "See the code on ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", {
|
||||||
href: "https://github.com/henrywhitaker3/Speedtest-Tracker",
|
href: "https://github.com/henrywhitaker3/Speedtest-Tracker",
|
||||||
@@ -127824,6 +127817,166 @@ if (document.getElementById('homePage')) {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ "./resources/js/components/Home/Version.js":
|
||||||
|
/*!*************************************************!*\
|
||||||
|
!*** ./resources/js/components/Home/Version.js ***!
|
||||||
|
\*************************************************/
|
||||||
|
/*! exports provided: default */
|
||||||
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Version; });
|
||||||
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js");
|
||||||
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");
|
||||||
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
||||||
|
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
|
||||||
|
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_2__);
|
||||||
|
/* harmony import */ var react_toastify__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-toastify */ "./node_modules/react-toastify/esm/react-toastify.js");
|
||||||
|
/* harmony import */ var react_bootstrap__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-bootstrap */ "./node_modules/react-bootstrap/esm/index.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"); } }
|
||||||
|
|
||||||
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||||
|
|
||||||
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||||
|
|
||||||
|
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||||
|
|
||||||
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||||
|
|
||||||
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||||
|
|
||||||
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||||
|
|
||||||
|
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; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var Version = /*#__PURE__*/function (_Component) {
|
||||||
|
_inherits(Version, _Component);
|
||||||
|
|
||||||
|
var _super = _createSuper(Version);
|
||||||
|
|
||||||
|
function Version(props) {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
_classCallCheck(this, Version);
|
||||||
|
|
||||||
|
_this = _super.call(this, props);
|
||||||
|
|
||||||
|
_defineProperty(_assertThisInitialized(_this), "checkForUpdates", function () {
|
||||||
|
var url = '/api/update/check';
|
||||||
|
axios__WEBPACK_IMPORTED_MODULE_2___default.a.get(url).then(function (resp) {
|
||||||
|
var update = resp.data.update;
|
||||||
|
|
||||||
|
if (update !== false) {
|
||||||
|
react_toastify__WEBPACK_IMPORTED_MODULE_3__["toast"].info('A new version of Speedtest Tracker is available (v' + update.version + '). Go to the bottom of the page to update.');
|
||||||
|
|
||||||
|
_this.setState({
|
||||||
|
update: update.version,
|
||||||
|
changelog: update.changelog
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})["catch"](function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
_defineProperty(_assertThisInitialized(_this), "showModal", function () {
|
||||||
|
_this.setState({
|
||||||
|
modalShow: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
_defineProperty(_assertThisInitialized(_this), "hideModal", function () {
|
||||||
|
_this.setState({
|
||||||
|
modalShow: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
_this.state = {
|
||||||
|
version: document.querySelector('meta[name="version"]').content,
|
||||||
|
update: false,
|
||||||
|
modalShow: false,
|
||||||
|
changelog: []
|
||||||
|
};
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(Version, [{
|
||||||
|
key: "componentDidMount",
|
||||||
|
value: function componentDidMount() {
|
||||||
|
this.checkForUpdates();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "render",
|
||||||
|
value: function render() {
|
||||||
|
var version = this.state.version;
|
||||||
|
var update = this.state.update;
|
||||||
|
var modalShow = this.state.modalShow;
|
||||||
|
var changelog = this.state.changelog;
|
||||||
|
|
||||||
|
if (update === false) {
|
||||||
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", {
|
||||||
|
className: "text-muted mb-0"
|
||||||
|
}, "Speedtest Tracker Version: ", version);
|
||||||
|
} else {
|
||||||
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", {
|
||||||
|
className: "text-muted mb-0 d-inline"
|
||||||
|
}, "Speedtest Tracker Version: ", version, " - "), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", {
|
||||||
|
href: "#!",
|
||||||
|
className: "mb-0 d-inline",
|
||||||
|
onClick: this.showModal
|
||||||
|
}, "New version available - v", update), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_4__["Modal"], {
|
||||||
|
show: modalShow,
|
||||||
|
onHide: this.hideModal,
|
||||||
|
animation: true
|
||||||
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_4__["Modal"].Header, {
|
||||||
|
closeButton: true
|
||||||
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_4__["Modal"].Title, null, "Update to v", update)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_4__["Modal"].Body, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", null, "Changelog:"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("ul", null, changelog.map(function (e, i) {
|
||||||
|
if (e.link == '') {
|
||||||
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("li", {
|
||||||
|
key: i
|
||||||
|
}, e.description);
|
||||||
|
} else {
|
||||||
|
/*#__PURE__*/
|
||||||
|
react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("li", {
|
||||||
|
key: i
|
||||||
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", {
|
||||||
|
href: e.link,
|
||||||
|
target: "_blank",
|
||||||
|
rel: "noopener noreferer"
|
||||||
|
}, e.description));
|
||||||
|
}
|
||||||
|
})))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return Version;
|
||||||
|
}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (document.getElementById('Version')) {
|
||||||
|
react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(Version, null), document.getElementById('Version'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ "./resources/js/components/Loader.js":
|
/***/ "./resources/js/components/Loader.js":
|
||||||
/*!*******************************************!*\
|
/*!*******************************************!*\
|
||||||
!*** ./resources/js/components/Loader.js ***!
|
!*** ./resources/js/components/Loader.js ***!
|
||||||
|
|||||||
@@ -44,4 +44,10 @@ Route::group([
|
|||||||
], function () {
|
], function () {
|
||||||
Route::get('check', 'UpdateController@checkForUpdate')
|
Route::get('check', 'UpdateController@checkForUpdate')
|
||||||
->name('update.check');
|
->name('update.check');
|
||||||
|
Route::get('download', 'UpdateController@downloadUpdate')
|
||||||
|
->name('update.download');
|
||||||
|
Route::get('extract', 'UpdateController@extractUpdate')
|
||||||
|
->name('update.extract');
|
||||||
|
Route::get('extract', 'UpdateController@moveUpdate')
|
||||||
|
->name('update.move');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user