mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
updates automatically handled on the background
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
APP_NAME=Laravel
|
APP_NAME=Laravel
|
||||||
APP_ENV=local
|
APP_ENV=local
|
||||||
APP_KEY=base64:zJANxvpTkxQwXRdrlTxjTYyFQ0vTv0DZRE7yNtVXmIA=
|
APP_KEY=base64:qpZihuLxIkDkK3rsQND5Ksv10zVWQ3yih2KiuY6IfXk=
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
APP_DEMO=false
|
APP_DEMO=false
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Nginx Configuration](#nginx-configuration)
|
- [Nginx Configuration](#nginx-configuration)
|
||||||
- [Apache Configuration](#apache-configuration)
|
- [Apache Configuration](#apache-configuration)
|
||||||
|
- [Updating Application](#updating-application)
|
||||||
- [Developers](#developers)
|
- [Developers](#developers)
|
||||||
- [Running Environment On Your Localhost](#running-environment-on-your-localhost)
|
- [Running Environment On Your Localhost](#running-environment-on-your-localhost)
|
||||||
- [Express Installation](#express-installation)
|
- [Express Installation](#express-installation)
|
||||||
@@ -163,6 +164,11 @@ Make sure you have enabled mod_rewrite. There is an example config for running V
|
|||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Updating Application
|
||||||
|
1. Replace all files where the app is located except `/storage` folder and `.env` file.
|
||||||
|
2. Clear the application cache (Admin / Settings / Application).
|
||||||
|
3. In 5 minutes the app update stuff automatically on the background if needed.
|
||||||
|
|
||||||
# Developers
|
# Developers
|
||||||
## Running Environment On Your Localhost
|
## Running Environment On Your Localhost
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"/chunks/not-found.js": "/chunks/not-found.js?id=9f6ce23ce5d969f1",
|
"/chunks/not-found.js": "/chunks/not-found.js?id=9f6ce23ce5d969f1",
|
||||||
"/chunks/temporary-unavailable.js": "/chunks/temporary-unavailable.js?id=f564565faa09d6d6",
|
"/chunks/temporary-unavailable.js": "/chunks/temporary-unavailable.js?id=f564565faa09d6d6",
|
||||||
"/chunks/admin.js": "/chunks/admin.js?id=8032540fddb832c5",
|
"/chunks/admin.js": "/chunks/admin.js?id=8032540fddb832c5",
|
||||||
"/chunks/dashboard.js": "/chunks/dashboard.js?id=fd1d266e493a79a8",
|
"/chunks/dashboard.js": "/chunks/dashboard.js?id=a41b0f486b1f8d36",
|
||||||
"/chunks/invoices.js": "/chunks/invoices.js?id=1416cbf6d1a593ac",
|
"/chunks/invoices.js": "/chunks/invoices.js?id=1416cbf6d1a593ac",
|
||||||
"/chunks/subscriptions.js": "/chunks/subscriptions.js?id=5bf6704f5b599f36",
|
"/chunks/subscriptions.js": "/chunks/subscriptions.js?id=5bf6704f5b599f36",
|
||||||
"/chunks/pages.js": "/chunks/pages.js?id=c8380d571e91e8be",
|
"/chunks/pages.js": "/chunks/pages.js?id=c8380d571e91e8be",
|
||||||
|
|||||||
@@ -53,16 +53,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--New language strings alert-->
|
|
||||||
<AlertBox v-if="data.app.shouldUpgrade" @click.native.once="upgradeSystem" color="green" :is-loading="isUpgradingApp">
|
|
||||||
There is a new update that needs to upgrade some stuff on your backend. Please click on this box to upgrade.
|
|
||||||
</AlertBox>
|
|
||||||
|
|
||||||
<!--New language strings alert-->
|
|
||||||
<AlertBox v-if="data.app.shouldUpgradeTranslations" @click.native.once="upgradeTranslations" color="green" :is-loading="isUpgradingLanguages">
|
|
||||||
We detect new language strings. You should <b class="dark:text-green-500 text-green-600 text-sm font-bold underline">upgrade your translations</b>. After that, you can find new translations at the bottom page of your translations in language editor. Please click on this box.
|
|
||||||
</AlertBox>
|
|
||||||
|
|
||||||
<!--Create metered plan alert-->
|
<!--Create metered plan alert-->
|
||||||
<AlertBox v-if="config.subscriptionType === 'metered' && config.isEmptyPlans" color="rose">
|
<AlertBox v-if="config.subscriptionType === 'metered' && config.isEmptyPlans" color="rose">
|
||||||
As you installed app with metered subscription type, you have to <router-link :to="{ name: 'CreateMeteredPlan' }" class="dark:text-rose-500 text-sm font-bold underline">create your plan</router-link> as soon as possible to prevent new user registration without automatically assigned subscription plan.
|
As you installed app with metered subscription type, you have to <router-link :to="{ name: 'CreateMeteredPlan' }" class="dark:text-rose-500 text-sm font-bold underline">create your plan</router-link> as soon as possible to prevent new user registration without automatically assigned subscription plan.
|
||||||
@@ -218,52 +208,10 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isUpgradingLanguages: false,
|
|
||||||
isUpgradingApp: false,
|
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
data: undefined,
|
data: undefined,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
upgradeTranslations() {
|
|
||||||
this.isUpgradingLanguages = true
|
|
||||||
|
|
||||||
axios.get('/upgrade/translations')
|
|
||||||
.then(() => {
|
|
||||||
this.data.app.shouldUpgradeTranslations = false
|
|
||||||
|
|
||||||
events.$emit('toaster', {
|
|
||||||
type: 'success',
|
|
||||||
message: this.$t('Your translations was upgraded successfully.'),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
events.$emit('alert:open', {
|
|
||||||
title: this.$t('popup_error.title'),
|
|
||||||
message: this.$t('popup_error.message'),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
upgradeSystem() {
|
|
||||||
this.isUpgradingApp = true
|
|
||||||
|
|
||||||
axios.get('/upgrade/system')
|
|
||||||
.then(() => {
|
|
||||||
this.data.app.shouldUpgrade = false
|
|
||||||
|
|
||||||
events.$emit('toaster', {
|
|
||||||
type: 'success',
|
|
||||||
message: this.$t('Your app was upgraded successfully.'),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
events.$emit('alert:open', {
|
|
||||||
title: this.$t('popup_error.title'),
|
|
||||||
message: this.$t('popup_error.message'),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
created() {
|
||||||
axios
|
axios
|
||||||
.get('/api/admin/dashboard')
|
.get('/api/admin/dashboard')
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Domain\Maintenance\Controllers\UpgradeSystemController;
|
|
||||||
use Domain\Maintenance\Controllers\MaintenanceModeController;
|
use Domain\Maintenance\Controllers\MaintenanceModeController;
|
||||||
use Domain\Maintenance\Controllers\UpgradeTranslationsController;
|
|
||||||
|
|
||||||
Route::group(['middleware' => ['auth:sanctum']], function () {
|
Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||||
Route::get('/down', [MaintenanceModeController::class, 'down']);
|
Route::get('/down', [MaintenanceModeController::class, 'down']);
|
||||||
Route::get('/up', [MaintenanceModeController::class, 'up']);
|
Route::get('/up', [MaintenanceModeController::class, 'up']);
|
||||||
|
|
||||||
Route::group(['prefix' => 'upgrade'], function () {
|
|
||||||
Route::get('/translations', UpgradeTranslationsController::class);
|
|
||||||
Route::get('/system', UpgradeSystemController::class);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ use Illuminate\Console\Scheduling\Schedule;
|
|||||||
use App\Console\Commands\SetupDevEnvironment;
|
use App\Console\Commands\SetupDevEnvironment;
|
||||||
use App\Console\Commands\SetupProdEnvironment;
|
use App\Console\Commands\SetupProdEnvironment;
|
||||||
use Support\Scheduler\Actions\ReportUsageAction;
|
use Support\Scheduler\Actions\ReportUsageAction;
|
||||||
use Support\Demo\Actions\DeleteAllSharedLinksAction;
|
use Support\Demo\Actions\DeleteAllDemoSharedLinksAction;
|
||||||
use Support\Scheduler\Actions\DeleteFailedFilesAction;
|
use Support\Scheduler\Actions\DeleteFailedFilesAction;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
|
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
|
||||||
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
|
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
|
||||||
use App\Console\Commands\GenerateDemoSubscriptionContentCommand;
|
use App\Console\Commands\GenerateDemoSubscriptionContentCommand;
|
||||||
use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction;
|
use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction;
|
||||||
|
use Support\Upgrading\Actions\UpdateSystemAction;
|
||||||
|
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
@@ -42,7 +43,7 @@ class Kernel extends ConsoleKernel
|
|||||||
|
|
||||||
if (is_demo()) {
|
if (is_demo()) {
|
||||||
$schedule->call(
|
$schedule->call(
|
||||||
fn () => resolve(DeleteAllSharedLinksAction::class)()
|
fn () => resolve(DeleteAllDemoSharedLinksAction::class)()
|
||||||
)->daily()->at('00:00');
|
)->daily()->at('00:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +55,10 @@ class Kernel extends ConsoleKernel
|
|||||||
fn () => resolve(ExpireUnfilledUploadRequestAction::class)()
|
fn () => resolve(ExpireUnfilledUploadRequestAction::class)()
|
||||||
)->hourly();
|
)->hourly();
|
||||||
|
|
||||||
|
$schedule->call(
|
||||||
|
fn () => resolve(UpdateSystemAction::class)()
|
||||||
|
)->everyMinute();
|
||||||
|
|
||||||
$schedule->call(
|
$schedule->call(
|
||||||
fn () => resolve(DeleteUnverifiedUsersAction::class)()
|
fn () => resolve(DeleteUnverifiedUsersAction::class)()
|
||||||
)->daily()->at('00:05');
|
)->daily()->at('00:05');
|
||||||
|
|||||||
@@ -1,27 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Admin\Controllers\Dashboard;
|
namespace Domain\Admin\Controllers\Dashboard;
|
||||||
|
|
||||||
use Schema;
|
|
||||||
use ByteUnits\Metric;
|
use ByteUnits\Metric;
|
||||||
use App\Users\Models\User;
|
use App\Users\Models\User;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Domain\Maintenance\Models\AppUpdate;
|
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
|
||||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
|
||||||
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
|
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
|
||||||
|
|
||||||
class GetDashboardDataController extends Controller
|
class GetDashboardDataController extends Controller
|
||||||
{
|
{
|
||||||
public function __invoke(): Application|ResponseFactory|Response
|
public function __invoke(): JsonResponse
|
||||||
{
|
{
|
||||||
// Get app update data
|
|
||||||
$shouldUpgrade = $this->getUpgradeData();
|
|
||||||
|
|
||||||
// Get translations data
|
|
||||||
list($originalTranslations, $activeTranslations) = $this->countTranslations();
|
|
||||||
|
|
||||||
// Get bandwidth data
|
// Get bandwidth data
|
||||||
list($upload, $download, $uploadTotal, $downloadTotal, $storageUsage) = $this->getDiskData();
|
list($upload, $download, $uploadTotal, $downloadTotal, $storageUsage) = $this->getDiskData();
|
||||||
|
|
||||||
@@ -31,7 +21,7 @@ class GetDashboardDataController extends Controller
|
|||||||
->where('type', 'charge')
|
->where('type', 'charge')
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
return response([
|
return response()->json([
|
||||||
'users' => [
|
'users' => [
|
||||||
'total' => User::count(),
|
'total' => User::count(),
|
||||||
'usersPremiumTotal' => Subscription::count(),
|
'usersPremiumTotal' => Subscription::count(),
|
||||||
@@ -48,8 +38,6 @@ class GetDashboardDataController extends Controller
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
'app' => [
|
'app' => [
|
||||||
'shouldUpgrade' => count($shouldUpgrade) > 0,
|
|
||||||
'shouldUpgradeTranslations' => $activeTranslations !== $originalTranslations,
|
|
||||||
'isRunningCron' => isRunningCron(),
|
'isRunningCron' => isRunningCron(),
|
||||||
'license' => get_settings('license'),
|
'license' => get_settings('license'),
|
||||||
'version' => config('vuefilemanager.version'),
|
'version' => config('vuefilemanager.version'),
|
||||||
@@ -111,40 +99,4 @@ class GetDashboardDataController extends Controller
|
|||||||
|
|
||||||
return [$upload, $download, $uploadTotal, $downloadTotal, $storageUsage];
|
return [$upload, $download, $uploadTotal, $downloadTotal, $storageUsage];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function countTranslations(): array
|
|
||||||
{
|
|
||||||
$default_translations = [
|
|
||||||
'extended' => collect([
|
|
||||||
config('language-translations.extended'),
|
|
||||||
config('language-translations.regular'),
|
|
||||||
config('custom-language-translations'),
|
|
||||||
])->collapse(),
|
|
||||||
'regular' => collect([
|
|
||||||
config('language-translations.regular'),
|
|
||||||
config('custom-language-translations'),
|
|
||||||
])->collapse(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$originalTranslationCount = count($default_translations[get_settings('license')]);
|
|
||||||
|
|
||||||
$activeTranslationsCount = DB::table('language_translations')
|
|
||||||
->where('lang', 'en')
|
|
||||||
->count();
|
|
||||||
|
|
||||||
return [$originalTranslationCount, $activeTranslationsCount];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getUpgradeData(): array
|
|
||||||
{
|
|
||||||
// Get already updated versions
|
|
||||||
$alreadyUpdated = Schema::hasTable('app_updates')
|
|
||||||
? AppUpdate::all()
|
|
||||||
->pluck('version')
|
|
||||||
->toArray()
|
|
||||||
: [];
|
|
||||||
|
|
||||||
// Get versions which has to be upgraded
|
|
||||||
return array_diff(config('vuefilemanager.updates'), $alreadyUpdated);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Domain\Localization\Actions;
|
namespace Domain\Localization\Actions;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
class DeleteLanguageStringsAction
|
class DeleteLanguageTranslationsAction
|
||||||
{
|
{
|
||||||
public function __invoke(array $list): void
|
public function __invoke(array $list): void
|
||||||
{
|
{
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Domain\Localization\Actions;
|
|
||||||
|
|
||||||
use DB;
|
|
||||||
|
|
||||||
class UpdateLanguageStringsAction
|
|
||||||
{
|
|
||||||
public function __invoke(array $list): void
|
|
||||||
{
|
|
||||||
collect($list)
|
|
||||||
->each(fn(...$item) => DB::table('language_translations')
|
|
||||||
->where('lang', 'en')
|
|
||||||
->where('key', $item[1])
|
|
||||||
->update(['value' => $item[0]])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace Domain\Localization\Actions;
|
||||||
|
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class UpdateLanguageTranslationsAction
|
||||||
|
{
|
||||||
|
public function __invoke(array $list): void
|
||||||
|
{
|
||||||
|
collect($list)
|
||||||
|
->each(
|
||||||
|
fn (...$item) => DB::table('language_translations')
|
||||||
|
->where('lang', 'en')
|
||||||
|
->where('key', $item[1])
|
||||||
|
->update(['value' => $item[0]])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Maintenance\Actions;
|
namespace Domain\Maintenance\Actions;
|
||||||
|
|
||||||
use Gate;
|
|
||||||
use Artisan;
|
use Artisan;
|
||||||
|
|
||||||
class UpgradeDatabaseAction
|
class UpgradeDatabaseAction
|
||||||
{
|
{
|
||||||
public function __invoke(): bool
|
public function __invoke(): bool
|
||||||
{
|
{
|
||||||
// Check admin permission
|
|
||||||
Gate::authorize('maintenance');
|
|
||||||
|
|
||||||
return Artisan::call('migrate', [
|
return Artisan::call('migrate', [
|
||||||
'--force' => true,
|
'--force' => true,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Domain\Maintenance\Controllers;
|
|
||||||
|
|
||||||
use Gate;
|
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Domain\Localization\Actions\UpgradeLanguageTranslationsAction;
|
|
||||||
|
|
||||||
class UpgradeTranslationsController extends Controller
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
public UpgradeLanguageTranslationsAction $upgradeLanguageTranslations,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get new language translations from default translations
|
|
||||||
* and insert it into database
|
|
||||||
*/
|
|
||||||
public function __invoke(): Response
|
|
||||||
{
|
|
||||||
// Check admin permission
|
|
||||||
Gate::authorize('maintenance');
|
|
||||||
|
|
||||||
($this->upgradeLanguageTranslations)();
|
|
||||||
|
|
||||||
return response('Done.', 201);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Domain\Settings\Requests;
|
namespace Domain\Settings\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Support\Demo\Actions;
|
namespace Support\Demo\Actions;
|
||||||
|
|
||||||
use App\Users\Models\User;
|
|
||||||
use DB;
|
use DB;
|
||||||
|
use App\Users\Models\User;
|
||||||
|
|
||||||
class DeleteAllSharedLinksAction
|
class DeleteAllDemoSharedLinksAction
|
||||||
{
|
{
|
||||||
public function __invoke()
|
public function __invoke()
|
||||||
{
|
{
|
||||||
80
src/Support/Upgrading/Actions/UpdateSystemAction.php
Normal file
80
src/Support/Upgrading/Actions/UpdateSystemAction.php
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
namespace Support\Upgrading\Actions;
|
||||||
|
|
||||||
|
use DB;
|
||||||
|
use Schema;
|
||||||
|
use Artisan;
|
||||||
|
use Domain\Maintenance\Models\AppUpdate;
|
||||||
|
use Support\Upgrading\Controllers\UpgradingVersionsController;
|
||||||
|
use Domain\Localization\Actions\UpgradeLanguageTranslationsAction;
|
||||||
|
|
||||||
|
class UpdateSystemAction extends UpgradingVersionsController
|
||||||
|
{
|
||||||
|
public function __invoke(): void
|
||||||
|
{
|
||||||
|
ini_set('max_execution_time', -1);
|
||||||
|
|
||||||
|
// Upgrade the language translations
|
||||||
|
if ($this->shouldUpdateTranslations()) {
|
||||||
|
resolve(UpgradeLanguageTranslationsAction::class)();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there are some version to upgrade
|
||||||
|
$shouldUpgradeSystem = $this->shouldUpgradeSystem();
|
||||||
|
|
||||||
|
// Upgrade the app
|
||||||
|
if (! empty($shouldUpgradeSystem)) {
|
||||||
|
foreach ($shouldUpgradeSystem as $version) {
|
||||||
|
// Get method name
|
||||||
|
$method = "upgrade_to_$version";
|
||||||
|
|
||||||
|
if (method_exists($this, $method)) {
|
||||||
|
// Run update
|
||||||
|
$this->{$method}();
|
||||||
|
|
||||||
|
// Store update record
|
||||||
|
AppUpdate::create(['version' => $version]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear config
|
||||||
|
Artisan::call('config:clear');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function shouldUpgradeSystem(): array
|
||||||
|
{
|
||||||
|
// Get already updated versions
|
||||||
|
$alreadyUpdated = Schema::hasTable('app_updates')
|
||||||
|
? AppUpdate::all()
|
||||||
|
->pluck('version')
|
||||||
|
->toArray()
|
||||||
|
: [];
|
||||||
|
|
||||||
|
// Get versions which has to be upgraded
|
||||||
|
return array_diff(config('vuefilemanager.updates'), $alreadyUpdated);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function shouldUpdateTranslations(): bool
|
||||||
|
{
|
||||||
|
$default_translations = [
|
||||||
|
'extended' => collect([
|
||||||
|
config('language-translations.extended'),
|
||||||
|
config('language-translations.regular'),
|
||||||
|
config('custom-language-translations'),
|
||||||
|
])->collapse(),
|
||||||
|
'regular' => collect([
|
||||||
|
config('language-translations.regular'),
|
||||||
|
config('custom-language-translations'),
|
||||||
|
])->collapse(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$originalTranslationCount = count($default_translations[get_settings('license')]);
|
||||||
|
|
||||||
|
$activeTranslationsCount = DB::table('language_translations')
|
||||||
|
->where('lang', 'en')
|
||||||
|
->count();
|
||||||
|
|
||||||
|
return $activeTranslationsCount !== $originalTranslationCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,69 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Maintenance\Controllers;
|
namespace Support\Upgrading\Controllers;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Domain\Localization\Actions\DeleteLanguageStringsAction;
|
|
||||||
use Domain\Localization\Actions\UpdateLanguageStringsAction;
|
|
||||||
use Schema;
|
|
||||||
use Storage;
|
|
||||||
use Artisan;
|
use Artisan;
|
||||||
|
use Storage;
|
||||||
use App\Users\Models\User;
|
use App\Users\Models\User;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Domain\Files\Models\File;
|
use Domain\Files\Models\File;
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use Domain\Folders\Models\Folder;
|
use Domain\Folders\Models\Folder;
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Domain\Maintenance\Models\AppUpdate;
|
|
||||||
use Domain\Maintenance\Actions\UpgradeDatabaseAction;
|
use Domain\Maintenance\Actions\UpgradeDatabaseAction;
|
||||||
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
|
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
|
||||||
|
use Domain\Localization\Actions\DeleteLanguageTranslationsAction;
|
||||||
|
use Domain\Localization\Actions\UpdateLanguageTranslationsAction;
|
||||||
|
|
||||||
class UpgradeSystemController extends Controller
|
class UpgradingVersionsController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public UpgradeDatabaseAction $upgradeDatabase,
|
public UpgradeDatabaseAction $upgradeDatabase,
|
||||||
public DeleteLanguageStringsAction $deleteLanguageStrings,
|
public DeleteLanguageTranslationsAction $deleteLanguageStrings,
|
||||||
public UpdateLanguageStringsAction $updateLanguageStrings,
|
public UpdateLanguageTranslationsAction $updateLanguageStrings,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __invoke(Request $request): Response
|
public function upgrade_to_2_0_10(): void
|
||||||
{
|
|
||||||
ini_set('max_execution_time', -1);
|
|
||||||
|
|
||||||
// Clear config
|
|
||||||
Artisan::call('config:clear');
|
|
||||||
|
|
||||||
// Get already updated versions
|
|
||||||
$alreadyUpdated = Schema::hasTable('app_updates')
|
|
||||||
? AppUpdate::all()
|
|
||||||
->pluck('version')
|
|
||||||
->toArray()
|
|
||||||
: [];
|
|
||||||
|
|
||||||
// Get versions which has to be upgraded
|
|
||||||
$needToUpgrade = array_diff(config('vuefilemanager.updates'), $alreadyUpdated);
|
|
||||||
|
|
||||||
// Iterate and upgrade
|
|
||||||
foreach ($needToUpgrade as $version) {
|
|
||||||
// Get method name
|
|
||||||
$method = "upgrade_to_$version";
|
|
||||||
|
|
||||||
if (method_exists($this, $method)) {
|
|
||||||
// Run update
|
|
||||||
$this->{$method}($request);
|
|
||||||
|
|
||||||
// Store update record
|
|
||||||
AppUpdate::create(['version' => $version]);
|
|
||||||
|
|
||||||
return response('Done', 201);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return response('Whooops, something went wrong!', 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function upgrade_to_2_0_10(): void
|
|
||||||
{
|
{
|
||||||
($this->upgradeDatabase)();
|
($this->upgradeDatabase)();
|
||||||
|
|
||||||
@@ -131,7 +90,7 @@ class UpgradeSystemController extends Controller
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function upgrade_to_2_0_13(): void
|
public function upgrade_to_2_0_13(): void
|
||||||
{
|
{
|
||||||
// Force plan synchronization
|
// Force plan synchronization
|
||||||
if (get_settings('license') === 'extended' && Plan::count() !== 0) {
|
if (get_settings('license') === 'extended' && Plan::count() !== 0) {
|
||||||
@@ -139,7 +98,7 @@ class UpgradeSystemController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function upgrade_to_2_0_14(): void
|
public function upgrade_to_2_0_14(): void
|
||||||
{
|
{
|
||||||
($this->upgradeDatabase)();
|
($this->upgradeDatabase)();
|
||||||
|
|
||||||
@@ -148,7 +107,7 @@ class UpgradeSystemController extends Controller
|
|||||||
->each(fn ($user) => $user->forceFill(['two_factor_confirmed_at' => now()])->save());
|
->each(fn ($user) => $user->forceFill(['two_factor_confirmed_at' => now()])->save());
|
||||||
|
|
||||||
($this->deleteLanguageStrings)([
|
($this->deleteLanguageStrings)([
|
||||||
'popup_2fa.disappear_qr'
|
'popup_2fa.disappear_qr',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
($this->updateLanguageStrings)([
|
($this->updateLanguageStrings)([
|
||||||
@@ -157,6 +157,7 @@ class UserAccountTest extends TestCase
|
|||||||
'role' => $user->role,
|
'role' => $user->role,
|
||||||
'socialite_account' => false,
|
'socialite_account' => false,
|
||||||
'two_factor_authentication' => false,
|
'two_factor_authentication' => false,
|
||||||
|
'two_factor_confirmed_at' => null,
|
||||||
'storage' => [
|
'storage' => [
|
||||||
'used' => 0,
|
'used' => 0,
|
||||||
'used_formatted' => '0%',
|
'used_formatted' => '0%',
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ class DashboardTest extends TestCase
|
|||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'app' => [
|
'app' => [
|
||||||
'shouldUpgrade' => true,
|
|
||||||
'shouldUpgradeTranslations' => true,
|
|
||||||
'earnings' => '$0.00',
|
'earnings' => '$0.00',
|
||||||
'isRunningCron' => false,
|
'isRunningCron' => false,
|
||||||
'license' => 'extended',
|
'license' => 'extended',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use DB;
|
|||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use App\Users\Models\User;
|
use App\Users\Models\User;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Support\Upgrading\Actions\UpdateSystemAction;
|
||||||
|
|
||||||
class AppUpgradeTest extends TestCase
|
class AppUpgradeTest extends TestCase
|
||||||
{
|
{
|
||||||
@@ -39,10 +40,7 @@ class AppUpgradeTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this
|
resolve(UpdateSystemAction::class)();
|
||||||
->actingAs($user)
|
|
||||||
->get('/upgrade/translations')
|
|
||||||
->assertStatus(201);
|
|
||||||
|
|
||||||
collect(['en', 'sk'])
|
collect(['en', 'sk'])
|
||||||
->map(function ($locale) {
|
->map(function ($locale) {
|
||||||
@@ -65,13 +63,7 @@ class AppUpgradeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_upgrade_app()
|
public function it_upgrade_app()
|
||||||
{
|
{
|
||||||
$user = User::factory()
|
resolve(UpdateSystemAction::class)();
|
||||||
->create(['role' => 'admin']);
|
|
||||||
|
|
||||||
$this
|
|
||||||
->actingAs($user)
|
|
||||||
->get('/upgrade/system')
|
|
||||||
->assertStatus(201);
|
|
||||||
|
|
||||||
$this->assertDatabaseHas('app_updates', [
|
$this->assertDatabaseHas('app_updates', [
|
||||||
'version' => '2_0_10',
|
'version' => '2_0_10',
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests\Support\Demo;
|
namespace Tests\Support\Demo;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
use App\Users\Models\User;
|
use App\Users\Models\User;
|
||||||
use Domain\Sharing\Models\Share;
|
use Domain\Sharing\Models\Share;
|
||||||
use Support\Demo\Actions\DeleteAllSharedLinksAction;
|
use Support\Demo\Actions\DeleteAllDemoSharedLinksAction;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class DemoTest extends TestCase
|
class DemoTest extends TestCase
|
||||||
{
|
{
|
||||||
@@ -30,7 +29,7 @@ class DemoTest extends TestCase
|
|||||||
Share::factory()
|
Share::factory()
|
||||||
->create(['user_id' => $howdy->id]);
|
->create(['user_id' => $howdy->id]);
|
||||||
|
|
||||||
resolve(DeleteAllSharedLinksAction::class)();
|
resolve(DeleteAllDemoSharedLinksAction::class)();
|
||||||
|
|
||||||
$this->assertDatabaseHas('shares', [
|
$this->assertDatabaseHas('shares', [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
|
|||||||
Reference in New Issue
Block a user