You've already forked Atomcms-edit
Remove all auto-update functionality (commands, services, widgets, blades, translations)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace App\Filament\Pages\Monitoring;
|
||||
|
||||
use App\Actions\Commandocentrum\EmulatorControlAction;
|
||||
use App\Actions\Commandocentrum\NitroControlAction;
|
||||
use App\Enums\AlertSeverity;
|
||||
use App\Models\Miscellaneous\WebsitePermission;
|
||||
use App\Models\StaffActivity;
|
||||
@@ -16,7 +15,6 @@ use App\Services\Diagnostics\DiagnosticRunner;
|
||||
use App\Services\GitHubService;
|
||||
use App\Services\RconService;
|
||||
use App\Services\SettingsService;
|
||||
use App\Services\UpdateHistoryService;
|
||||
use BackedEnum;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
@@ -106,21 +104,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
'emulator_database_username' => $this->getSetting('emulator_database_username', ''),
|
||||
'emulator_database_password' => $this->getSetting('emulator_database_password', ''),
|
||||
'emulator_version' => $this->getSetting('emulator_version', 'Onbekend'),
|
||||
'auto_update_enabled' => $this->getSettingBool('auto_update_enabled'),
|
||||
'auto_update_schedule' => $this->getSetting('auto_update_schedule', '03:00'),
|
||||
'auto_update_days' => $this->getSetting('auto_update_days', '0,6'),
|
||||
'nitro_client_path' => $this->getSetting('nitro_client_path', $paths['nitro_client_path']),
|
||||
'nitro_renderer_path' => $this->getSetting('nitro_renderer_path', $paths['nitro_renderer_path']),
|
||||
'nitro_build_path' => $this->getSetting('nitro_build_path', $paths['nitro_build_path']),
|
||||
'nitro_webroot' => $this->getSetting('nitro_webroot', $paths['nitro_webroot']),
|
||||
'gamedata_path' => $this->getSetting('gamedata_path', $paths['gamedata_path']),
|
||||
'nitro_github_branch' => $this->getSetting('nitro_github_branch', 'main'),
|
||||
'nitro_github_url' => $this->getSetting('nitro_github_url', ''),
|
||||
'nitro_site_url' => $this->getSetting('nitro_site_url', $this->getCurrentSiteUrl()),
|
||||
'nitro_auto_update_configs' => $this->getSettingBool('nitro_auto_update_configs'),
|
||||
'nitro_auto_update_enabled' => $this->getSettingBool('nitro_auto_update_enabled'),
|
||||
'nitro_auto_update_schedule' => $this->getSetting('nitro_auto_update_schedule', '03:00'),
|
||||
'nitro_auto_update_days' => $this->getSetting('nitro_auto_update_days', '0,6'),
|
||||
'hotel_alert_message' => '',
|
||||
];
|
||||
}
|
||||
@@ -233,92 +216,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
->content(fn () => $this->renderEmulatorInfoView()),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.emulator_updates'))
|
||||
->description(__('commandocentrum.emulator_updates_desc'))
|
||||
->icon('heroicon-o-arrow-down-circle')
|
||||
->afterHeader([
|
||||
Action::make('check_updates')
|
||||
->label(__('commandocentrum.check_updates'))
|
||||
->color('info')
|
||||
->action('checkEmulatorUpdates'),
|
||||
Action::make('build_emulator')
|
||||
->label('🔨 ' . __('commandocentrum.build'))
|
||||
->color('success')
|
||||
->action('buildEmulator'),
|
||||
Action::make('run_sql')
|
||||
->label(__('commandocentrum.sql_updates'))
|
||||
->color('purple')
|
||||
->action('runSqlUpdates'),
|
||||
Action::make('save_emulator')
|
||||
->label(__('commandocentrum.save'))
|
||||
->color('primary')
|
||||
->action('saveEmulator'),
|
||||
])
|
||||
->schema([
|
||||
Placeholder::make('emulator_settings')
|
||||
->label('')
|
||||
->content(fn () => $this->renderEmulatorSettingsView()),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.emulator_backups'))
|
||||
->description(__('commandocentrum.emulator_backups_desc'))
|
||||
->icon('heroicon-s-archive-box')
|
||||
->schema([
|
||||
Placeholder::make('backups_list')
|
||||
->label('')
|
||||
->content(fn () => $this->renderBackupsListView()),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.nitro_client'))
|
||||
->description(__('commandocentrum.nitro_client_desc'))
|
||||
->icon('heroicon-o-cloud-arrow-down')
|
||||
->afterHeader([
|
||||
Action::make('detect_paths')
|
||||
->label('🔍 ' . __('commandocentrum.auto_detect'))
|
||||
->color('success')
|
||||
->action('detectAndSavePaths'),
|
||||
Action::make('check_nitro')
|
||||
->label(__('commandocentrum.check'))
|
||||
->color('info')
|
||||
->action('checkNitroUpdates'),
|
||||
Action::make('build_nitro')
|
||||
->label(__('commandocentrum.build'))
|
||||
->color('pink')
|
||||
->action('buildNitro'),
|
||||
Action::make('generate_configs')
|
||||
->label(__('commandocentrum.generate_configs'))
|
||||
->color('indigo')
|
||||
->action('generateNitroConfigs'),
|
||||
Action::make('save_nitro')
|
||||
->label(__('commandocentrum.save'))
|
||||
->color('primary')
|
||||
->action('saveNitro'),
|
||||
])
|
||||
->schema([
|
||||
Placeholder::make('nitro_settings')
|
||||
->label('')
|
||||
->content(fn () => $this->renderNitroSettingsView()),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.auto_updates'))
|
||||
->description(__('commandocentrum.auto_updates_desc'))
|
||||
->icon('heroicon-o-clock')
|
||||
->columns(2)
|
||||
->afterHeader([
|
||||
Action::make('save_auto')
|
||||
->label(__('commandocentrum.save'))
|
||||
->color('primary')
|
||||
->action('saveAutoUpdate'),
|
||||
])
|
||||
->schema([
|
||||
Toggle::make('auto_update_enabled')
|
||||
->label(__('commandocentrum.enable_auto_updates')),
|
||||
TextInput::make('auto_update_schedule')
|
||||
->label(__('commandocentrum.schedule')),
|
||||
TextInput::make('auto_update_days')
|
||||
->label(__('commandocentrum.days')),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.clothing_sync'))
|
||||
->description(__('commandocentrum.clothing_sync_desc'))
|
||||
->icon('heroicon-o-user')
|
||||
@@ -367,15 +264,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
->helperText(__('commandocentrum.discord_ranks_helper')),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.update_history'))
|
||||
->description(__('commandocentrum.update_history_desc'))
|
||||
->icon('heroicon-o-clock')
|
||||
->schema([
|
||||
Placeholder::make('history')
|
||||
->label('')
|
||||
->content(fn () => $this->renderUpdateHistoryView()),
|
||||
]),
|
||||
|
||||
Section::make(__('commandocentrum.social_login'))
|
||||
->description(__('commandocentrum.social_login_desc'))
|
||||
->icon('heroicon-o-user-circle')
|
||||
@@ -491,100 +379,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
]);
|
||||
}
|
||||
|
||||
private function renderEmulatorSettingsView(): View
|
||||
{
|
||||
return view('filament.components.commandocentrum.emulator-settings', [
|
||||
'emulatorBranchesHtml' => $this->getEmulatorBranchesHtml(),
|
||||
'emulatorStatusHtml' => $this->renderEmulatorStatusView()->render(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function renderEmulatorStatusView(): View
|
||||
{
|
||||
$serviceName = $this->getSetting('emulator_service_name', 'arcturus');
|
||||
$jarPath = $this->getSetting('emulator_jar_path', '/var/www/Emulator');
|
||||
$sourcePath = $this->getSetting('emulator_source_path', '/var/www/emulator-source');
|
||||
$githubUrl = $this->getSetting('emulator_github_url', '');
|
||||
$branch = $this->getSetting('emulator_github_branch', 'main');
|
||||
|
||||
$jarExists = $this->fileExists($jarPath);
|
||||
$sourceExists = $this->fileExists($sourcePath);
|
||||
$sourceCommit = $this->getGitCommit($sourcePath);
|
||||
$remoteVersion = $githubUrl !== '' && $githubUrl !== '0' ? $this->getRemoteCommit($githubUrl, $branch) : 'N/A';
|
||||
|
||||
$canBuild = false;
|
||||
$checkDirs = [
|
||||
$sourcePath,
|
||||
$sourcePath . '/Emulator',
|
||||
$sourcePath . '/Emulator/Emulator',
|
||||
$sourcePath . '/emulator',
|
||||
$sourcePath . '/emulator/emulator',
|
||||
];
|
||||
foreach ($checkDirs as $dir) {
|
||||
$check = $this->runCommand('test -f ' . escapeshellarg($dir . '/pom.xml') . ' && echo yes');
|
||||
if ($check && trim($check) === 'yes') {
|
||||
$canBuild = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return view('filament.components.commandocentrum.emulator-status', [
|
||||
'emulatorOnline' => $this->getEmulatorStatusText() === 'Online',
|
||||
'jarExists' => $jarExists,
|
||||
'serviceName' => $serviceName,
|
||||
'sourceCommit' => $sourceCommit,
|
||||
'remoteVersion' => $remoteVersion,
|
||||
'canBuild' => $canBuild,
|
||||
'jarPath' => $jarPath,
|
||||
'sourcePath' => $sourcePath,
|
||||
]);
|
||||
}
|
||||
|
||||
private function renderNitroSettingsView(): View
|
||||
{
|
||||
return view('filament.components.commandocentrum.nitro-settings', [
|
||||
'nitroBranchesHtml' => $this->getNitroBranchesHtml(),
|
||||
'nitroStatusHtml' => $this->renderNitroStatusView()->render(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function renderNitroStatusView(): View
|
||||
{
|
||||
$clientPath = $this->getSetting('nitro_client_path', '/var/www/nitro-client');
|
||||
$rendererPath = $this->getSetting('nitro_renderer_path', '/var/www/nitro-renderer');
|
||||
$webroot = $this->getSetting('nitro_webroot', '/var/www/Client');
|
||||
$clientGithubUrl = $this->getSetting('nitro_github_url', '');
|
||||
$rendererGithubUrl = $this->getSetting('nitro_renderer_github_url', 'https://github.com/duckietm/Nitro_Render_V3');
|
||||
|
||||
$clientCommit = $this->getGitCommit($clientPath);
|
||||
$rendererCommit = $this->getGitCommit($rendererPath);
|
||||
$clientRemote = $clientGithubUrl !== '' && $clientGithubUrl !== '0' ? $this->getRemoteCommit($clientGithubUrl, $this->getSetting('nitro_github_branch', 'main')) : 'N/A';
|
||||
$rendererRemote = $rendererGithubUrl !== '' && $rendererGithubUrl !== '0' ? $this->getRemoteCommit($rendererGithubUrl, $this->getSetting('nitro_renderer_github_branch', 'main')) : 'N/A';
|
||||
|
||||
return view('filament.components.commandocentrum.nitro-status', [
|
||||
'clientExists' => $this->checkPathExists($clientPath),
|
||||
'rendererExists' => $this->checkPathExists($rendererPath),
|
||||
'webrootExists' => $this->checkPathExists($webroot),
|
||||
'clientCommit' => $clientCommit,
|
||||
'rendererCommit' => $rendererCommit,
|
||||
'clientRemote' => $clientRemote,
|
||||
'rendererRemote' => $rendererRemote,
|
||||
]);
|
||||
}
|
||||
|
||||
private function renderBackupsListView(): View
|
||||
{
|
||||
try {
|
||||
$backups = app(EmulatorControlAction::class)->getBackups();
|
||||
} catch (Exception) {
|
||||
$backups = [];
|
||||
}
|
||||
|
||||
return view('filament.components.commandocentrum.backups-list', [
|
||||
'backups' => $backups,
|
||||
]);
|
||||
}
|
||||
|
||||
private function renderClothingStatusView(): View
|
||||
{
|
||||
try {
|
||||
@@ -614,19 +408,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
]);
|
||||
}
|
||||
|
||||
private function renderUpdateHistoryView(): View
|
||||
{
|
||||
try {
|
||||
$history = app(UpdateHistoryService::class)->getRecent(10);
|
||||
} catch (Exception) {
|
||||
$history = [];
|
||||
}
|
||||
|
||||
return view('filament.components.commandocentrum.update-history', [
|
||||
'history' => $history,
|
||||
]);
|
||||
}
|
||||
|
||||
private function getSetting(string $key, string $default = ''): string
|
||||
{
|
||||
try {
|
||||
@@ -878,33 +659,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
}
|
||||
}
|
||||
|
||||
public function checkEmulatorUpdates(): void
|
||||
{
|
||||
$result = app(EmulatorControlAction::class)->update();
|
||||
$this->notify($result['success'] ?? false ? __('commandocentrum.success') : __('commandocentrum.error'), $result['message'] ?? $result['error'] ?? __('commandocentrum.unknown'), ($result['success'] ?? false) ? 'success' : 'danger');
|
||||
Cache::forget('all_updates_check');
|
||||
$this->fillForm();
|
||||
}
|
||||
|
||||
public function buildEmulator(): void
|
||||
{
|
||||
$result = app(EmulatorControlAction::class)->build();
|
||||
$this->notify($result['success'] ?? false ? __('commandocentrum.success') : __('commandocentrum.error'), $result['message'] ?? $result['error'] ?? __('commandocentrum.unknown'), ($result['success'] ?? false) ? 'success' : 'danger');
|
||||
}
|
||||
|
||||
public function runSqlUpdates(): void
|
||||
{
|
||||
$result = app(EmulatorControlAction::class)->runSqlUpdates();
|
||||
$this->notify($result['success'] ?? false ? __('commandocentrum.success') : __('commandocentrum.error'), $result['message'] ?? __('commandocentrum.unknown'), ($result['success'] ?? false) ? 'success' : 'danger');
|
||||
}
|
||||
|
||||
public function restoreBackup(string $backupName): void
|
||||
{
|
||||
$result = app(EmulatorControlAction::class)->restoreBackup($backupName);
|
||||
$this->notify($result['success'] ? __('commandocentrum.success') : __('commandocentrum.error'), $result['message'] ?? $result['error'] ?? __('commandocentrum.unknown'), $result['success'] ? 'success' : 'danger');
|
||||
$this->fillForm();
|
||||
}
|
||||
|
||||
public function saveEmulator(): void
|
||||
{
|
||||
try {
|
||||
@@ -924,38 +678,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
}
|
||||
}
|
||||
|
||||
public function checkNitroUpdates(): void
|
||||
{
|
||||
$clientPath = $this->getSetting('nitro_client_path', '/var/www/nitro-client');
|
||||
$rendererPath = $this->getSetting('nitro_renderer_path', '/var/www/nitro-renderer');
|
||||
$branch = $this->getSetting('nitro_github_branch', 'main');
|
||||
|
||||
$result = app(NitroControlAction::class)->pullUpdates($clientPath, $rendererPath, $branch);
|
||||
$this->notify(__('commandocentrum.success'), $result['message'], 'success');
|
||||
$this->fillForm();
|
||||
}
|
||||
|
||||
public function buildNitro(): void
|
||||
{
|
||||
$clientPath = $this->getSetting('nitro_client_path', '/var/www/nitro-client');
|
||||
$rendererPath = $this->getSetting('nitro_renderer_path', '/var/www/nitro-renderer');
|
||||
$branch = $this->getSetting('nitro_github_branch', 'main');
|
||||
|
||||
$result = app(NitroControlAction::class)->build($clientPath, $rendererPath, $branch);
|
||||
$this->notify($result['success'] ? __('commandocentrum.success') : __('commandocentrum.warning'), $result['message'], $result['success'] ? 'success' : 'warning');
|
||||
}
|
||||
|
||||
public function generateNitroConfigs(): void
|
||||
{
|
||||
$siteUrl = $this->getSetting('nitro_site_url', $this->getCurrentSiteUrl());
|
||||
$webroot = $this->getSetting('nitro_webroot', '/var/www/Client');
|
||||
$gamedataPath = $this->getSetting('gamedata_path', '/var/www/Gamedata');
|
||||
|
||||
$result = app(NitroControlAction::class)->generateConfigs($siteUrl, $webroot, $gamedataPath);
|
||||
$this->notify($result['success'] ? __('commandocentrum.success') : __('commandocentrum.error'), $result['message'], $result['success'] ? 'success' : 'danger');
|
||||
$this->fillForm();
|
||||
}
|
||||
|
||||
public function syncClothing(): void
|
||||
{
|
||||
try {
|
||||
@@ -972,58 +694,6 @@ final class Commandocentrum extends Page implements HasForms
|
||||
}
|
||||
}
|
||||
|
||||
public function detectAndSavePaths(): void
|
||||
{
|
||||
try {
|
||||
$paths = $this->autoDetectPaths();
|
||||
$settings = app(SettingsService::class);
|
||||
|
||||
$settings->set('nitro_client_path', $paths['nitro_client_path']);
|
||||
$settings->set('nitro_renderer_path', $paths['nitro_renderer_path']);
|
||||
$settings->set('nitro_build_path', $paths['nitro_build_path']);
|
||||
$settings->set('nitro_webroot', $paths['nitro_webroot']);
|
||||
$settings->set('gamedata_path', $paths['gamedata_path']);
|
||||
$settings->set('emulator_jar_path', $paths['emulator_jar_path']);
|
||||
$settings->set('emulator_source_path', $paths['emulator_source_path']);
|
||||
|
||||
$this->fillForm();
|
||||
$this->notify(__('commandocentrum.success'), __('commandocentrum.paths_detected'), 'success');
|
||||
} catch (Exception $e) {
|
||||
$this->notify(__('commandocentrum.error'), $e->getMessage(), 'danger');
|
||||
}
|
||||
}
|
||||
|
||||
public function saveNitro(): void
|
||||
{
|
||||
try {
|
||||
$settings = app(SettingsService::class);
|
||||
$settings->set('nitro_client_path', $this->data['nitro_client_path'] ?? '/var/www/atomcms/nitro-client');
|
||||
$settings->set('nitro_renderer_path', $this->data['nitro_renderer_path'] ?? '/var/www/atomcms/nitro-renderer');
|
||||
$settings->set('nitro_build_path', $this->data['nitro_build_path'] ?? '/var/www/atomcms/nitro-client/dist');
|
||||
$settings->set('nitro_webroot', $this->data['nitro_webroot'] ?? '/var/www/Client');
|
||||
$settings->set('gamedata_path', $this->data['gamedata_path'] ?? '/var/www/Gamedata');
|
||||
$settings->set('nitro_github_url', $this->data['nitro_github_url'] ?? '');
|
||||
$settings->set('nitro_github_branch', $this->data['nitro_github_branch'] ?? 'main');
|
||||
$settings->set('nitro_site_url', $this->data['nitro_site_url'] ?? '');
|
||||
$this->notify(__('commandocentrum.success'), __('commandocentrum.nitro_settings_saved'), 'success');
|
||||
} catch (Exception $e) {
|
||||
$this->notify(__('commandocentrum.error'), $e->getMessage(), 'danger');
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAutoUpdate(): void
|
||||
{
|
||||
try {
|
||||
$settings = app(SettingsService::class);
|
||||
$settings->set('auto_update_enabled', ($this->data['auto_update_enabled'] ?? false) ? '1' : '0');
|
||||
$settings->set('auto_update_schedule', $this->data['auto_update_schedule'] ?? '03:00');
|
||||
$settings->set('auto_update_days', $this->data['auto_update_days'] ?? '0,6');
|
||||
$this->notify(__('commandocentrum.success'), __('commandocentrum.auto_update_saved'), 'success');
|
||||
} catch (Exception $e) {
|
||||
$this->notify(__('commandocentrum.error'), $e->getMessage(), 'danger');
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAlerts(): void
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace App\Filament\Resources\Miscellaneous\AlertLogResource;
|
||||
|
||||
use App\Models\Miscellaneous\AlertLog;
|
||||
use App\Services\EmulatorUpdateService;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -136,14 +135,12 @@ class AlertLogResource extends Resource
|
||||
->icon('heroicon-o-trash')
|
||||
->color('gray')
|
||||
->action(function () {
|
||||
$updateService = new EmulatorUpdateService;
|
||||
$result = $updateService->clearAllLogs();
|
||||
Cache::flush();
|
||||
AlertLog::truncate();
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('🗑️ Alle Logs Geleegd!')
|
||||
->body($result['message'])
|
||||
->body('Alle logs zijn gewist.')
|
||||
->send();
|
||||
})
|
||||
->requiresConfirmation(),
|
||||
|
||||
@@ -1,343 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Services\EmulatorUpdateService;
|
||||
use App\Services\NitroUpdateService;
|
||||
use App\Services\RconService;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateCheckerWidget extends Widget
|
||||
{
|
||||
#[\Override]
|
||||
protected string $view = 'filament.widgets.update-checker';
|
||||
|
||||
#[\Override]
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
|
||||
#[\Override]
|
||||
protected static ?int $sort = 0;
|
||||
|
||||
public ?string $emulatorVersion = null;
|
||||
|
||||
public ?string $latestEmulatorVersion = null;
|
||||
|
||||
public bool $emulatorUpdate = false;
|
||||
|
||||
public ?string $nitroVersion = null;
|
||||
|
||||
public ?string $latestNitroVersion = null;
|
||||
|
||||
public bool $nitroUpdate = false;
|
||||
|
||||
public int $onlineUsers = 0;
|
||||
|
||||
public string $dbSize = '0 MB';
|
||||
|
||||
public bool $hasAnyUpdate = false;
|
||||
|
||||
public int $sqlApplied = 0;
|
||||
|
||||
public int $sqlPending = 0;
|
||||
|
||||
public bool $sqlTableExists = false;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->emulatorVersion = setting('emulator_version', '?');
|
||||
$this->nitroVersion = setting('nitro_client_version', '?');
|
||||
|
||||
try {
|
||||
$this->onlineUsers = (int) DB::connection('mysql')->table('users')->where('online', '1')->count();
|
||||
$sizeResult = DB::connection('mysql')->select('SELECT ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) as db_size FROM information_schema.tables WHERE table_schema = DATABASE()');
|
||||
$this->dbSize = ($sizeResult[0]->db_size ?? '0') . ' MB';
|
||||
} catch (\Exception) {
|
||||
$this->dbSize = '? MB';
|
||||
}
|
||||
|
||||
$this->loadSqlStatus();
|
||||
|
||||
$cached = Cache::get('all_updates_check');
|
||||
|
||||
if ($cached !== null) {
|
||||
$this->emulatorUpdate = $cached['emulator'] ?? false;
|
||||
$this->latestEmulatorVersion = $cached['emulator_version'] ?? null;
|
||||
$this->nitroUpdate = $cached['nitro'] ?? false;
|
||||
$this->latestNitroVersion = $cached['nitro_version'] ?? null;
|
||||
$this->hasAnyUpdate = $this->emulatorUpdate || $this->nitroUpdate;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->performCheck();
|
||||
}
|
||||
|
||||
private function loadSqlStatus(): void
|
||||
{
|
||||
try {
|
||||
$updateService = new EmulatorUpdateService;
|
||||
$sqlDiagnosis = $updateService->diagnoseSqlUpdates();
|
||||
|
||||
$this->sqlTableExists = $sqlDiagnosis['table_exists'] ?? false;
|
||||
$this->sqlApplied = $sqlDiagnosis['applied_count'] ?? 0;
|
||||
$this->sqlPending = $sqlDiagnosis['pending_count'] ?? 0;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('[UpdateChecker] SQL status failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function performCheck(): void
|
||||
{
|
||||
try {
|
||||
$updateService = new EmulatorUpdateService;
|
||||
$check = $updateService->checkForUpdates();
|
||||
$this->emulatorUpdate = $check['update_available'] ?? false;
|
||||
$this->latestEmulatorVersion = $check['latest_version'] ?? null;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('[UpdateChecker] Emulator check failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
$nitroService = new NitroUpdateService;
|
||||
$nitroCheck = $nitroService->checkForUpdates();
|
||||
$this->nitroUpdate = $nitroCheck['has_updates'] ?? false;
|
||||
if ($this->nitroUpdate) {
|
||||
$parts = [];
|
||||
if ($nitroCheck['client_update'] ?? false) {
|
||||
$parts[] = 'Client';
|
||||
}
|
||||
if ($nitroCheck['renderer_update'] ?? false) {
|
||||
$parts[] = 'Renderer';
|
||||
}
|
||||
$this->latestNitroVersion = implode(' + ', $parts);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('[UpdateChecker] Nitro check failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
$this->hasAnyUpdate = $this->emulatorUpdate || $this->nitroUpdate;
|
||||
|
||||
Cache::put('all_updates_check', [
|
||||
'emulator' => $this->emulatorUpdate,
|
||||
'emulator_version' => $this->latestEmulatorVersion,
|
||||
'nitro' => $this->nitroUpdate,
|
||||
'nitro_version' => $this->latestNitroVersion,
|
||||
], now()->addMinutes(15));
|
||||
}
|
||||
|
||||
public function forceCheck(): void
|
||||
{
|
||||
try {
|
||||
Cache::forget('all_updates_check');
|
||||
$updateService = new EmulatorUpdateService;
|
||||
$updateService->resetInstalledDate();
|
||||
$this->performCheck();
|
||||
|
||||
if ($this->hasAnyUpdate) {
|
||||
Notification::make()->success()->title('Updates Gevonden!')->body('Klik op "Alles Updaten" om te installeren')->send();
|
||||
} else {
|
||||
Notification::make()->info()->title('Geen Updates')->body('Alles is al up-to-date')->send();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()->danger()->title('Fout')->body($e->getMessage())->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function repairSystem(): void
|
||||
{
|
||||
try {
|
||||
Cache::forget('all_updates_check');
|
||||
|
||||
$messages = [];
|
||||
$errors = [];
|
||||
|
||||
try {
|
||||
$emuService = new EmulatorUpdateService;
|
||||
$repairResult = $emuService->repairEmulator();
|
||||
|
||||
if ($repairResult['success']) {
|
||||
$messages[] = '🖥️ Emulator: ' . ($repairResult['message'] ?? 'Gerepareerd');
|
||||
} else {
|
||||
$errors[] = 'Emulator: ' . ($repairResult['error'] ?? 'Onbekende fout');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errors[] = 'Emulator: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$nitroService = new NitroUpdateService;
|
||||
$repairResult = $nitroService->repair();
|
||||
|
||||
if ($repairResult['success']) {
|
||||
$messages[] = '🎮 Nitro: ' . ($repairResult['message'] ?? 'Gerepareerd');
|
||||
} else {
|
||||
$errors[] = 'Nitro: ' . ($repairResult['error'] ?? 'Onbekende fout');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errors[] = 'Nitro: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
if ($messages !== []) {
|
||||
Notification::make()->success()->title('Reparatie Voltooid!')->body(implode(' | ', $messages))->send();
|
||||
}
|
||||
|
||||
if ($errors !== []) {
|
||||
Notification::make()->danger()->title('Reparatie Fout')->body(implode(' | ', $errors))->send();
|
||||
}
|
||||
|
||||
Cache::forget('all_updates_check');
|
||||
$this->mount();
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()->danger()->title('Fout')->body($e->getMessage())->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function diagnoseSystem(): void
|
||||
{
|
||||
try {
|
||||
$emuService = new EmulatorUpdateService;
|
||||
$nitroService = new NitroUpdateService;
|
||||
|
||||
$emuDiagnosis = $emuService->diagnose();
|
||||
$nitroDiagnosis = $nitroService->diagnose();
|
||||
|
||||
$issues = array_merge(
|
||||
$emuDiagnosis['issues'] ?? [],
|
||||
$nitroDiagnosis['issues'] ?? [],
|
||||
);
|
||||
|
||||
$recommendations = array_merge(
|
||||
$emuDiagnosis['recommendations'] ?? [],
|
||||
$nitroDiagnosis['recommendations'] ?? [],
|
||||
);
|
||||
|
||||
if ($issues === []) {
|
||||
Notification::make()->info()->title('Diagnose')->body('Geen problemen gevonden')->send();
|
||||
} else {
|
||||
$body = 'Problemen: ' . implode(', ', $issues);
|
||||
if ($recommendations !== []) {
|
||||
$body .= "\n\nAanbevelingen: " . implode(', ', $recommendations);
|
||||
}
|
||||
Notification::make()->warning()->title('Diagnose Resultaat')->body($body)->send();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()->danger()->title('Fout')->body($e->getMessage())->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAll(): void
|
||||
{
|
||||
try {
|
||||
Cache::forget('all_updates_check');
|
||||
Cache::forget('website_settings');
|
||||
|
||||
$messages = [];
|
||||
$errors = [];
|
||||
$updateService = new EmulatorUpdateService;
|
||||
|
||||
try {
|
||||
$result = $updateService->updateEmulator();
|
||||
if ($result['success']) {
|
||||
$messages[] = '🖥️ ' . ($result['message'] ?? 'Emulator geüpdatet');
|
||||
} else {
|
||||
$error = $result['error'] ?? '';
|
||||
if (str_contains($error, 'al up-to-date')) {
|
||||
$messages[] = '🖥️ Emulator al up-to-date';
|
||||
} else {
|
||||
$errors[] = 'Emulator: ' . $error;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errors[] = 'Emulator: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$nitroService = new NitroUpdateService;
|
||||
$nitroCheck = $nitroService->checkForUpdates();
|
||||
|
||||
if ($nitroCheck['has_updates'] ?? false) {
|
||||
$result = $nitroService->updateNitro();
|
||||
if ($result['success']) {
|
||||
$parts = [];
|
||||
if ($result['renderer_updated'] ?? false) {
|
||||
$parts[] = 'Renderer';
|
||||
}
|
||||
if ($result['client_updated'] ?? false) {
|
||||
$parts[] = 'Client';
|
||||
}
|
||||
if ($result['built'] ?? false) {
|
||||
$parts[] = 'Build';
|
||||
}
|
||||
if ($result['deployed'] ?? false) {
|
||||
$parts[] = 'Deploy';
|
||||
}
|
||||
if ($parts !== []) {
|
||||
$messages[] = '🎮 Nitro: ' . implode(', ', $parts);
|
||||
}
|
||||
} elseif (! empty($result['errors'] ?? [])) {
|
||||
$errors = array_merge($errors, $result['errors']);
|
||||
}
|
||||
} else {
|
||||
$messages[] = '🎮 Nitro al up-to-date';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errors[] = 'Nitro: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$sqlResult = $updateService->runSqlUpdates();
|
||||
if ($sqlResult['sql_updated'] ?? false) {
|
||||
$count = count($sqlResult['files_run'] ?? []);
|
||||
if ($count > 0) {
|
||||
$messages[] = "📊 {$count} SQL updates";
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errors[] = 'SQL: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
$updateService->restartEmulator();
|
||||
$messages[] = '🔄 Emulator herstart';
|
||||
} catch (\Exception $e) {
|
||||
Log::error('[UpdateChecker] Restart failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
$rcon = new RconService;
|
||||
$rcon->sendCommand('updatecatalog');
|
||||
$rcon->sendCommand('updatewordfilter');
|
||||
$messages[] = '📚 Catalogus + filter vernieuwd';
|
||||
} catch (\Exception $e) {
|
||||
Log::error('[UpdateChecker] RCON failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
if ($messages !== []) {
|
||||
Notification::make()->success()->title('Updates Voltooid!')->body(implode(' | ', $messages))->send();
|
||||
}
|
||||
|
||||
if ($errors !== []) {
|
||||
Notification::make()->danger()->title('Sommige Updates Mislukt')->body(implode(' | ', $errors))->send();
|
||||
}
|
||||
|
||||
if ($messages === [] && $errors === []) {
|
||||
Notification::make()->info()->title('Geen Updates')->body('Alles was al up-to-date')->send();
|
||||
}
|
||||
|
||||
Cache::forget('all_updates_check');
|
||||
$this->mount();
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()->danger()->title('Fout')->body($e->getMessage())->send();
|
||||
}
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function canView(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user