From 2576e868b528e5b812ed4e701a0238e8f3971edc Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 6 Jun 2025 18:50:32 +0200 Subject: [PATCH] feat(navbar): add Traefik dashboard availability check and server IP handling; refactor dynamic configurations loading --- app/Livewire/Server/Navbar.php | 20 +++++++++++++++++++ app/Livewire/Server/Proxy.php | 5 ----- .../Server/Proxy/DynamicConfigurations.php | 6 ++++++ .../views/livewire/server/navbar.blade.php | 10 +++++----- .../views/livewire/server/proxy.blade.php | 6 +++--- .../proxy/dynamic-configurations.blade.php | 15 +++++++------- 6 files changed, 42 insertions(+), 20 deletions(-) diff --git a/app/Livewire/Server/Navbar.php b/app/Livewire/Server/Navbar.php index b5e7f928a..6d4b88d7d 100644 --- a/app/Livewire/Server/Navbar.php +++ b/app/Livewire/Server/Navbar.php @@ -2,6 +2,7 @@ namespace App\Livewire\Server; +use App\Actions\Proxy\CheckConfiguration; use App\Actions\Proxy\CheckProxy; use App\Actions\Proxy\StartProxy; use App\Actions\Proxy\StopProxy; @@ -17,6 +18,10 @@ class Navbar extends Component public ?string $currentRoute = null; + public bool $traefikDashboardAvailable = false; + + public ?string $serverIp = null; + public function getListeners() { $teamId = auth()->user()->currentTeam()->id; @@ -30,6 +35,21 @@ class Navbar extends Component { $this->server = $server; $this->currentRoute = request()->route()->getName(); + $this->serverIp = $this->server->id === 0 ? base_ip() : $this->server->ip; + } + + public function loadProxyConfiguration() + { + try { + $proxy_settings = CheckConfiguration::run($this->server); + if (str($proxy_settings)->contains('--api.dashboard=true') && str($proxy_settings)->contains('--api.insecure=true')) { + $this->traefikDashboardAvailable = true; + } else { + $this->traefikDashboardAvailable = false; + } + } catch (\Throwable $e) { + return handleError($e, $this); + } } public function restart() diff --git a/app/Livewire/Server/Proxy.php b/app/Livewire/Server/Proxy.php index 266e6fd0b..b3dada4ab 100644 --- a/app/Livewire/Server/Proxy.php +++ b/app/Livewire/Server/Proxy.php @@ -107,11 +107,6 @@ class Proxy extends Component { try { $this->proxy_settings = CheckConfiguration::run($this->server); - if (str($this->proxy_settings)->contains('--api.dashboard=true') && str($this->proxy_settings)->contains('--api.insecure=true')) { - $this->dispatch('traefikDashboardAvailable', true); - } else { - $this->dispatch('traefikDashboardAvailable', false); - } } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Server/Proxy/DynamicConfigurations.php b/app/Livewire/Server/Proxy/DynamicConfigurations.php index bb9d0f673..6ea9e7c3d 100644 --- a/app/Livewire/Server/Proxy/DynamicConfigurations.php +++ b/app/Livewire/Server/Proxy/DynamicConfigurations.php @@ -28,6 +28,11 @@ class DynamicConfigurations extends Component 'contents.*' => 'nullable|string', ]; + public function initLoadDynamicConfigurations() + { + $this->loadDynamicConfigurations(); + } + public function loadDynamicConfigurations() { $proxy_path = $this->server->proxyPath(); @@ -43,6 +48,7 @@ class DynamicConfigurations extends Component } $this->contents = $contents; $this->dispatch('$refresh'); + $this->dispatch('success', 'Dynamic configurations loaded.'); } public function mount() diff --git a/resources/views/livewire/server/navbar.blade.php b/resources/views/livewire/server/navbar.blade.php index d620d7e8f..09920b803 100644 --- a/resources/views/livewire/server/navbar.blade.php +++ b/resources/views/livewire/server/navbar.blade.php @@ -87,11 +87,11 @@ @if (data_get($server, 'proxy.status') === 'running') -