From 5541c135df734e5ad293ececa4e899416b1c33a4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 11 Oct 2023 11:00:40 +0200 Subject: [PATCH] feat: proxy logs on the ui --- app/Http/Livewire/Server/Proxy/Logs.php | 28 ++++ app/Http/Livewire/Server/Proxy/Show.php | 5 + app/View/Components/Server/Sidebar.php | 27 ++++ .../views/components/server/sidebar.blade.php | 20 +++ .../views/livewire/server/proxy.blade.php | 130 +++++++++--------- .../livewire/server/proxy/logs.blade.php | 9 ++ .../livewire/server/proxy/show.blade.php | 7 +- routes/web.php | 3 +- 8 files changed, 160 insertions(+), 69 deletions(-) create mode 100644 app/Http/Livewire/Server/Proxy/Logs.php create mode 100644 app/View/Components/Server/Sidebar.php create mode 100644 resources/views/components/server/sidebar.blade.php create mode 100644 resources/views/livewire/server/proxy/logs.blade.php diff --git a/app/Http/Livewire/Server/Proxy/Logs.php b/app/Http/Livewire/Server/Proxy/Logs.php new file mode 100644 index 000000000..cb8c245a6 --- /dev/null +++ b/app/Http/Livewire/Server/Proxy/Logs.php @@ -0,0 +1,28 @@ +parameters = get_route_parameters(); + try { + $this->server = Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->first(); + if (is_null($this->server)) { + return redirect()->route('server.all'); + } + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + public function render() + { + return view('livewire.server.proxy.logs'); + } +} diff --git a/app/Http/Livewire/Server/Proxy/Show.php b/app/Http/Livewire/Server/Proxy/Show.php index daadf0ede..26ea54e49 100644 --- a/app/Http/Livewire/Server/Proxy/Show.php +++ b/app/Http/Livewire/Server/Proxy/Show.php @@ -9,6 +9,11 @@ class Show extends Component { public ?Server $server = null; public $parameters = []; + protected $listeners = ['proxyStatusUpdated']; + public function proxyStatusUpdated() + { + $this->server->refresh(); + } public function mount() { $this->parameters = get_route_parameters(); diff --git a/app/View/Components/Server/Sidebar.php b/app/View/Components/Server/Sidebar.php new file mode 100644 index 000000000..f968b6d0c --- /dev/null +++ b/app/View/Components/Server/Sidebar.php @@ -0,0 +1,27 @@ + + @if ($server->isFunctional()) +
+
+ + + + @if (data_get($server, 'proxy.type') !== 'NONE') + + + + @endif +
+
+ @else +
Server is not validated. Validate first.
+ @endif + diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php index f0bf00874..3c35488e2 100644 --- a/resources/views/livewire/server/proxy.blade.php +++ b/resources/views/livewire/server/proxy.blade.php @@ -1,75 +1,71 @@
- @if ($server->isFunctional()) - @if (data_get($server, 'proxy.type')) -
- @if ($selectedProxy === 'TRAEFIK_V2') -
-
-

Proxy

- Save - @if ($server->proxy->status === 'exited') - Switch Proxy - @endif + @if (data_get($server, 'proxy.type')) +
+ @if ($selectedProxy === 'TRAEFIK_V2') + +
+

Configuration

+ Save + @if ($server->proxy->status === 'exited') + Switch Proxy + @endif +
+
Traefik v2
+ @if ( + $server->proxy->last_applied_settings && + $server->proxy->last_saved_settings !== $server->proxy->last_applied_settings) +
Configuration out of sync. Restart the proxy to apply the new + configurations.
-
Traefik v2
- @if ( - $server->proxy->last_applied_settings && - $server->proxy->last_saved_settings !== $server->proxy->last_applied_settings) -
Configuration out of sync. Restart the proxy to apply the new - configurations. + @endif + +
+ +
+
+ @if ($proxy_settings) +
+ + + Reset configuration to default +
@endif - -
- -
-
- @if ($proxy_settings) -
- - - Reset configuration to default - -
- @endif -
- - @elseif($selectedProxy === 'NONE') -
-

Proxy

- Switch Proxy -
-
None
- @else -
-

Proxy

- Switch Proxy -
- @endif - @else -
-

Proxy

-
Select a proxy you would like to use on this server.
-
- - Custom (None) - - - Traefik - v2 - - - Nginx - - - Caddy -
+ + @elseif($selectedProxy === 'NONE') +
+

Configuration

+ Switch Proxy
- @endif - @else -
Server is not validated. Validate first.
+
Custom (None) Proxy Selected
+ @else +
+

Configuration

+ Switch Proxy +
+ @endif + @else +
+

Configuration

+
Select a proxy you would like to use on this server.
+
+ + Custom (None) + + + Traefik + v2 + + + Nginx + + + Caddy + +
+
@endif
diff --git a/resources/views/livewire/server/proxy/logs.blade.php b/resources/views/livewire/server/proxy/logs.blade.php new file mode 100644 index 000000000..58e718424 --- /dev/null +++ b/resources/views/livewire/server/proxy/logs.blade.php @@ -0,0 +1,9 @@ +
+ +
+ +
+ +
+
+
diff --git a/resources/views/livewire/server/proxy/show.blade.php b/resources/views/livewire/server/proxy/show.blade.php index 6a5018d0b..33b30448e 100644 --- a/resources/views/livewire/server/proxy/show.blade.php +++ b/resources/views/livewire/server/proxy/show.blade.php @@ -1,4 +1,9 @@
- +
+ +
+ +
+
diff --git a/routes/web.php b/routes/web.php index 7be6c8ac8..1a9d5851c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,7 +5,6 @@ use App\Http\Controllers\DatabaseController; use App\Http\Controllers\MagicController; use App\Http\Controllers\ProjectController; -use App\Http\Controllers\ServerController; use App\Http\Livewire\Boarding\Index as BoardingIndex; use App\Http\Livewire\Project\Service\Index as ServiceIndex; use App\Http\Livewire\Project\Service\Show as ServiceShow; @@ -17,6 +16,7 @@ use App\Http\Livewire\Server\Destination\Show as DestinationShow; use App\Http\Livewire\Server\PrivateKey\Show as PrivateKeyShow; use App\Http\Livewire\Server\Proxy\Show as ProxyShow; +use App\Http\Livewire\Server\Proxy\Logs as ProxyLogs; use App\Http\Livewire\Server\Show; use App\Http\Livewire\Subscription\Show as SubscriptionShow; use App\Http\Livewire\Waitlist\Index as WaitlistIndex; @@ -123,6 +123,7 @@ Route::get('/server/new', Create::class)->name('server.create'); Route::get('/server/{server_uuid}', Show::class)->name('server.show'); Route::get('/server/{server_uuid}/proxy', ProxyShow::class)->name('server.proxy'); + Route::get('/server/{server_uuid}/proxy/logs', ProxyLogs::class)->name('server.proxy.logs'); Route::get('/server/{server_uuid}/private-key', PrivateKeyShow::class)->name('server.private-key'); Route::get('/server/{server_uuid}/destinations', DestinationShow::class)->name('server.destinations'); });