From ca2c75ce198ded6e9d19e1d6f0dd2f0cc215a95e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 24 Sep 2023 11:10:50 +0200 Subject: [PATCH] fix: only show traefik dashboard if its available --- app/Http/Livewire/Server/Proxy.php | 7 +++++++ app/Http/Livewire/Server/Proxy/Deploy.php | 12 +++++++++--- .../views/livewire/server/proxy/deploy.blade.php | 14 ++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.php index b218e6f98..ca0235ce6 100644 --- a/app/Http/Livewire/Server/Proxy.php +++ b/app/Http/Livewire/Server/Proxy.php @@ -6,6 +6,7 @@ use App\Actions\Proxy\CheckConfiguration; use App\Actions\Proxy\SaveConfiguration; use App\Models\Server; use Livewire\Component; +use Illuminate\Support\Str; class Proxy extends Component { @@ -71,6 +72,12 @@ class Proxy extends Component { try { $this->proxy_settings = CheckConfiguration::run($this->server); + if (Str::of($this->proxy_settings)->contains('--api.dashboard=true') && Str::of($this->proxy_settings)->contains('--api.insecure=true')) { + $this->emit('traefikDashboardAvailable', true); + } else { + $this->emit('traefikDashboardAvailable', false); + } + } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Http/Livewire/Server/Proxy/Deploy.php b/app/Http/Livewire/Server/Proxy/Deploy.php index d795f37b9..85899d7b7 100644 --- a/app/Http/Livewire/Server/Proxy/Deploy.php +++ b/app/Http/Livewire/Server/Proxy/Deploy.php @@ -2,7 +2,6 @@ namespace App\Http\Livewire\Server\Proxy; -use App\Actions\Proxy\SaveConfiguration; use App\Actions\Proxy\StartProxy; use App\Models\Server; use Livewire\Component; @@ -10,9 +9,16 @@ use Livewire\Component; class Deploy extends Component { public Server $server; - public $proxy_settings = null; - protected $listeners = ['proxyStatusUpdated']; + public bool $traefikDashboardAvailable = false; + public ?string $currentRoute = null; + protected $listeners = ['proxyStatusUpdated', 'traefikDashboardAvailable']; + public function mount() { + $this->currentRoute = request()->route()->getName(); + } + public function traefikDashboardAvailable(bool $data) { + $this->traefikDashboardAvailable = $data; + } public function proxyStatusUpdated() { $this->server->refresh(); diff --git a/resources/views/livewire/server/proxy/deploy.blade.php b/resources/views/livewire/server/proxy/deploy.blade.php index 534ee7388..3c7c1f28d 100644 --- a/resources/views/livewire/server/proxy/deploy.blade.php +++ b/resources/views/livewire/server/proxy/deploy.blade.php @@ -10,12 +10,14 @@ @if ($server->isFunctional() && data_get($server, 'proxy.type') !== 'NONE') @if (data_get($server, 'proxy.status') !== 'exited')
- + @if ($currentRoute === 'server.proxy' && $traefikDashboardAvailable) + + @endif