From 1304631aad873c36886aea52eb1cbbd3827f97ae Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 22 Jun 2023 21:17:53 +0200 Subject: [PATCH] fixes --- app/Http/Livewire/Server/Form.php | 7 +- app/Http/Livewire/Server/PrivateKey.php | 3 + app/Http/Livewire/Server/Proxy.php | 1 + .../views/livewire/server/proxy.blade.php | 71 ++++++++++--------- 4 files changed, 47 insertions(+), 35 deletions(-) diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index 961fde6a8..d5e5c613d 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -44,7 +44,7 @@ public function installDocker() public function validateServer() { try { - $this->uptime = instant_remote_process(['uptime'], $this->server, false); + $this->uptime = instant_remote_process(['uptime'], $this->server); if ($this->uptime) { $this->server->settings->is_reachable = true; $this->server->settings->save(); @@ -61,7 +61,10 @@ public function validateServer() $this->emit('serverValidated'); } } catch (\Exception $e) { - return general_error_handler(err: $e, that: $this); + $this->server->settings->is_reachable = false; + $this->server->settings->is_usable = false; + $this->server->settings->save(); + return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this); } } public function delete() diff --git a/app/Http/Livewire/Server/PrivateKey.php b/app/Http/Livewire/Server/PrivateKey.php index e295b1616..acfd864d5 100644 --- a/app/Http/Livewire/Server/PrivateKey.php +++ b/app/Http/Livewire/Server/PrivateKey.php @@ -21,6 +21,9 @@ public function checkConnection() Toaster::success('Server is reachable with this private key.'); } } catch (\Exception $e) { + $this->server->settings->is_reachable = false; + $this->server->settings->is_usable = false; + $this->server->settings->save(); return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this); } } diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.php index 6c34fd682..7049cd173 100644 --- a/app/Http/Livewire/Server/Proxy.php +++ b/app/Http/Livewire/Server/Proxy.php @@ -66,6 +66,7 @@ public function saveConfiguration() $this->server->proxy->last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value; $this->server->proxy->redirect_url = $this->redirect_url; $this->server->save(); + instant_remote_process([ "echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml", ], $this->server); diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php index 03e7f1874..c009183c4 100644 --- a/resources/views/livewire/server/proxy.blade.php +++ b/resources/views/livewire/server/proxy.blade.php @@ -7,41 +7,46 @@
- @isset($proxy_settings) - @if ($selectedProxy->value === 'TRAEFIK_V2') -
-
-

Proxy

- 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 to get the new configs. +
+ @if ($proxy_settings) + @if ($selectedProxy->value === 'TRAEFIK_V2') + +
+

Proxy

+ Save + @if ($server->proxy->status === 'exited') + Switch Proxy + @endif +
- @endif - @if ($server->id !== 0) - - @endif -
- -
-
- - - Reset configuration to default - -
- +
Traefik v2
+ @if ( + $server->proxy->last_applied_settings && + $server->proxy->last_saved_settings !== $server->proxy->last_applied_settings) +
Configuration out of sync. Restart to get the new + configs. +
+ @endif + @if ($server->id !== 0) + + @endif +
+ +
+
+ + + Reset configuration to default + +
+ + @endif + @else +
Server is not validated. Validate first.
@endif - @endisset +
@else