From b0a9245b2be01487015389944e17cc153faa8860 Mon Sep 17 00:00:00 2001 From: devfake Date: Wed, 30 Nov 2016 11:39:47 +0100 Subject: [PATCH] show update in settings --- README.md | 25 +++++++--- .../Http/Controllers/SettingController.php | 20 +++++++- backend/config/app.php | 2 + backend/routes/web.php | 2 + client/app/components/Content/Settings.vue | 26 ++++++++++ .../resources/sass/components/_content.scss | 50 ++++++++++++++++--- 6 files changed, 109 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 580e8de..db6acc4 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,14 @@ The rating based on an 3-Point system for `good`, `medium` and `bad`. ### Install -* Download Flox and `cd` into `backend` and run ```bash +git clone https://github.com/devfake/flox +cd flox/backend composer install php artisan flox:init # Enter here your database credentials php artisan flox:db # Running migrations and enter your admin credentials for the site ``` +* Give `backend/storage`, `public/assets` and `public/exports` recursive write access. * Enter your TMDb API-Key in `backend/.env` * Set your `CLIENT_URI` in `backend/.env`. If you use something like XAMPP or MAMP, the CLIENT_URI should be `/flox/public`. If you use something like Homestead, the CLIENT_URI should be `/`. ```bash @@ -49,6 +51,20 @@ If you hover over an item, you can click on `Suggestions` to search for recommen `Upcoming` will display new movies which will be released soon. TMDb do not yet support regional queries but this is coming soon. +### Update + +For each update i will make an extra [release](https://github.com/devfake/flox/releases). +These are the common steps to upgrade flox: +```bash +git fetch +git checkout x.x.x +cd backend +composer install +php artisan migrate +``` + +If you go to the settings page of your installation, flox will automatically check for new updates. + ### Export / Import Also you can make a backup of all your movies and shows in the settings page. If you click the `EXPORT MOVIES` button, there will be an download for an `json` file. This file contains all your movies and shows from your database. This backup file will also be automatically saved in your `public/exports` folder. @@ -56,8 +72,6 @@ Also you can make a backup of all your movies and shows in the settings page. If If you import an backup, all movies and shows in your database will be deleted and replaced. Be sure to make an current backup before you import. The import will download all poster images. -Export and import can also be used for the update of flox itself. Export, download a new version of flox, run all commands and import your backup. Done. - ### Translation All titles are in english by default. You can change your language by setting `TRANSLATION` in `backend/.env`. The most commons are `DE`, `IT`, `FR`, `ES` and `RU`. You can try to use your language code. @@ -89,13 +103,8 @@ You can also set options to display release date and/or genre of your own list. * Make sure you have installed `webpack` globally. * Run `npm run dev` or `npm run build`. -### Misc - -* Give `backend/storage`, `public/assets` and `public/exports` recursive write access. - ### Further Development -* Simpler workflow for update * Mark all episodes at once * Fetch new episodes (maybe option with cron to send user an info mail) * Upcoming and trending for tv shows diff --git a/backend/app/Http/Controllers/SettingController.php b/backend/app/Http/Controllers/SettingController.php index 5df7c42..2193e68 100644 --- a/backend/app/Http/Controllers/SettingController.php +++ b/backend/app/Http/Controllers/SettingController.php @@ -8,6 +8,7 @@ use App\Services\Storage; use App\Services\TMDB; use App\Setting; + use GuzzleHttp\Client; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Input; @@ -17,12 +18,14 @@ private $item; private $episodes; private $storage; + private $version; public function __construct(Item $item, Episode $episodes, Storage $storage) { $this->item = $item; $this->episodes = $episodes; $this->storage = $storage; + $this->version = config('app.version'); } /** @@ -71,6 +74,20 @@ } } + /** + * Check the latest release of flox and compare them to the local version. + * + * @return string + */ + public function checkUpdate() + { + $client = new Client(); + $response = json_decode($client->get('https://api.github.com/repos/devfake/flox/releases')->getBody()); + + $lastestVersion = $response[0]->name; + + return version_compare($this->version, $lastestVersion, '<') ? 'true' : 'false'; + } /** * Parse full genre list of all movies in database and save them. * @@ -123,7 +140,8 @@ return [ 'username' => Auth::check() ? Auth::user()->username : '', 'genre' => $genre, - 'date' => $date + 'date' => $date, + 'version' => $this->version ]; } diff --git a/backend/config/app.php b/backend/config/app.php index f338e8e..ccfde20 100644 --- a/backend/config/app.php +++ b/backend/config/app.php @@ -2,6 +2,8 @@ return [ + 'version' => '1.0.0', + 'TMDB_API_KEY' => env('TMDB_API_KEY'), 'TRANSLATION' => env('TRANSLATION'), 'LOADING_ITEMS' => env('LOADING_ITEMS'), diff --git a/backend/routes/web.php b/backend/routes/web.php index 60037dd..9af44bd 100644 --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -17,6 +17,8 @@ Route::get('/export', 'SettingController@export'); Route::post('/import', 'SettingController@import'); + Route::get('/check-update', 'SettingController@checkUpdate'); + Route::get('/sync-scout', 'SettingController@syncScout'); Route::get('/update-genre', 'SettingController@updateGenre'); Route::patch('/settings', 'SettingController@changeSettings'); diff --git a/client/app/components/Content/Settings.vue b/client/app/components/Content/Settings.vue index b9632df..b116150 100644 --- a/client/app/components/Content/Settings.vue +++ b/client/app/components/Content/Settings.vue @@ -1,6 +1,14 @@