mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
dashboard alert box for new system upgrade
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
namespace Domain\Admin\Controllers\Dashboard;
|
||||
|
||||
use Schema;
|
||||
use ByteUnits\Metric;
|
||||
use App\Users\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
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;
|
||||
@@ -14,6 +16,10 @@ class GetDashboardDataController extends Controller
|
||||
{
|
||||
public function __invoke(): Application|ResponseFactory|Response
|
||||
{
|
||||
// Get app update data
|
||||
$shouldUpgrade = $this->getUpgradeData();
|
||||
|
||||
// Get translations data
|
||||
list($originalTranslations, $activeTranslations) = $this->countTranslations();
|
||||
|
||||
// Get bandwidth data
|
||||
@@ -42,6 +48,7 @@ class GetDashboardDataController extends Controller
|
||||
],
|
||||
],
|
||||
'app' => [
|
||||
'shouldUpgrade' => count($shouldUpgrade) > 0,
|
||||
'shouldUpgradeTranslations' => $activeTranslations !== $originalTranslations,
|
||||
'isRunningCron' => isRunningCron(),
|
||||
'license' => get_settings('license'),
|
||||
@@ -105,9 +112,6 @@ class GetDashboardDataController extends Controller
|
||||
return [$upload, $download, $uploadTotal, $downloadTotal, $storageUsage];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function countTranslations(): array
|
||||
{
|
||||
$default_translations = [
|
||||
@@ -130,4 +134,17 @@ class GetDashboardDataController extends Controller
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user