fix: Traefik start on new server validation

fix: Multiple server selection ui flow
This commit is contained in:
Andras Bacsai
2025-05-26 21:06:00 +02:00
parent 6ea6d2742b
commit be0453d9df
5 changed files with 14 additions and 57 deletions

View File

@@ -24,6 +24,7 @@ class Configuration extends Component
return [
"echo-private:team.{$teamId},ServiceChecked" => '$refresh',
'buildPackUpdated' => '$refresh',
'refresh' => '$refresh',
];
}

View File

@@ -26,6 +26,7 @@ class Destination extends Component
return [
"echo-private:team.{$teamId},ApplicationStatusChanged" => 'loadData',
'refresh' => 'mount',
];
}
@@ -114,6 +115,7 @@ class Destination extends Component
$this->resource->additional_networks()->detach($network_id, ['server_id' => $server_id]);
$this->resource->additional_networks()->attach($main_destination->id, ['server_id' => $main_destination->server->id]);
$this->refreshServers();
$this->resource->refresh();
}
public function refreshServers()
@@ -126,7 +128,7 @@ class Destination extends Component
public function addServer(int $network_id, int $server_id)
{
$this->resource->additional_networks()->attach($network_id, ['server_id' => $server_id]);
$this->loadData();
$this->dispatch('refresh');
}
public function removeServer(int $network_id, int $server_id, $password)
@@ -141,7 +143,7 @@ class Destination extends Component
}
if ($this->resource->destination->server->id == $server_id && $this->resource->destination->id == $network_id) {
$this->dispatch('error', 'You cannot remove this destination server.', 'You are trying to remove the main server.');
$this->dispatch('error', 'You are trying to remove the main server.');
return;
}
@@ -149,6 +151,7 @@ class Destination extends Component
StopApplicationOneServer::run($this->resource, $server);
$this->resource->additional_networks()->detach($network_id, ['server_id' => $server_id]);
$this->loadData();
$this->dispatch('refresh');
ApplicationStatusChanged::dispatch(data_get($this->resource, 'environment.project.team.id'));
} catch (\Exception $e) {
return handleError($e, $this);

View File

@@ -2,8 +2,6 @@
namespace App\Livewire\Server;
use App\Actions\Proxy\CheckProxy;
use App\Actions\Proxy\StartProxy;
use App\Models\Server;
use Livewire\Component;
@@ -39,7 +37,6 @@ class ValidateAndInstall extends Component
'validateOS',
'validateDockerEngine',
'validateDockerVersion',
'startProxy',
'refresh' => '$refresh',
];
@@ -64,25 +61,6 @@ class ValidateAndInstall extends Component
$this->init();
}
public function startProxy()
{
try {
$shouldStart = CheckProxy::run($this->server);
if ($shouldStart) {
$proxy = StartProxy::run($this->server, false);
if ($proxy === 'OK') {
$this->proxy_started = true;
} else {
throw new \Exception('Proxy could not be started.');
}
} else {
$this->proxy_started = true;
}
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function validateConnection()
{
['uptime' => $this->uptime, 'error' => $error] = $this->server->validateConnection();
@@ -172,7 +150,6 @@ class ValidateAndInstall extends Component
if ($this->server->isBuildServer()) {
return;
}
$this->dispatch('startProxy');
}
public function render()

View File

@@ -34,7 +34,7 @@
@if ($resource?->additional_networks?->count() > 0 && data_get($resource, 'build_pack') !== 'dockercompose')
<h3>Additional Server(s)</h3>
@foreach ($resource->additional_networks as $destination)
<div class="flex flex-col gap-2">
<div class="flex flex-col gap-2" wire:key="destination-{{ $destination->id }}">
<div class="relative flex flex-col w-full box">
@if (str(data_get($destination, 'pivot.status'))->startsWith('running'))
<div title="{{ data_get($destination, 'pivot.status') }}"

View File

@@ -86,8 +86,8 @@
</g>
</svg></div>
@isset($docker_version)
@if($docker_version)
<div class="flex w-64 gap-2">Minimum Docker version: <svg class="w-5 h-5 text-success"
@if ($docker_version)
<div class="flex w-64 gap-2">Minimum Docker version: <svg class="w-5 h-5 text-success"
viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
<g fill="currentColor">
<path
@@ -98,39 +98,15 @@
</g>
</svg></div>
@else
<div class="flex w-64 gap-2">Minimum Docker version: <svg class="w-5 h-5 text-error"
viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor"
d="M208.49 191.51a12 12 0 0 1-17 17L128 145l-63.51 63.49a12 12 0 0 1-17-17L111 128L47.51 64.49a12 12 0 0 1 17-17L128 111l63.51-63.52a12 12 0 0 1 17 17L145 128Z" />
</svg></div>
<div class="flex w-64 gap-2">Minimum Docker version: <svg class="w-5 h-5 text-error"
viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor"
d="M208.49 191.51a12 12 0 0 1-17 17L128 145l-63.51 63.49a12 12 0 0 1-17-17L111 128L47.51 64.49a12 12 0 0 1 17-17L128 111l63.51-63.52a12 12 0 0 1 17 17L145 128Z" />
</svg></div>
@endif
@else
<div class="w-64"><x-loading text="Minimum Docker version:" /></div>
@endisset
@if (!$server->isBuildServer())
@if ($proxy_started)
<div class="flex w-64 gap-2">Proxy started: <svg class="w-5 h-5 text-success"
viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
<g fill="currentColor">
<path
d="m237.66 85.26l-128.4 128.4a8 8 0 0 1-11.32 0l-71.6-72a8 8 0 0 1 0-11.31l24-24a8 8 0 0 1 11.32 0l36.68 35.32a8 8 0 0 0 11.32 0l92.68-91.32a8 8 0 0 1 11.32 0l24 23.6a8 8 0 0 1 0 11.31"
opacity=".2" />
<path
d="m243.28 68.24l-24-23.56a16 16 0 0 0-22.58 0L104 136l-.11-.11l-36.64-35.27a16 16 0 0 0-22.57.06l-24 24a16 16 0 0 0 0 22.61l71.62 72a16 16 0 0 0 22.63 0l128.4-128.38a16 16 0 0 0-.05-22.67M103.62 208L32 136l24-24l.11.11l36.64 35.27a16 16 0 0 0 22.52 0L208.06 56L232 79.6Z" />
</g>
</svg></div>
@else
@if ($error)
<div class="flex w-64 gap-2">Proxy started: <svg class="w-5 h-5 text-error"
viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor"
d="M208.49 191.51a12 12 0 0 1-17 17L128 145l-63.51 63.49a12 12 0 0 1-17-17L111 128L47.51 64.49a12 12 0 0 1 17-17L128 111l63.51-63.52a12 12 0 0 1 17 17L145 128Z" />
</svg></div>
@else
<div class="w-64"><x-loading text="Proxy started:" /></div>
@endif
@endif
@endif
@else
@if ($error)
<div class="flex w-64 gap-2">Docker Compose is installed: <svg class="w-5 h-5 text-error"