diff --git a/app/Http/Livewire/Project/Service/Index.php b/app/Http/Livewire/Project/Service/Index.php index 687732540..fba473250 100644 --- a/app/Http/Livewire/Project/Service/Index.php +++ b/app/Http/Livewire/Project/Service/Index.php @@ -13,13 +13,7 @@ class Index extends Component public $databases; public array $parameters; public array $query; - protected $rules = [ - 'service.docker_compose_raw' => 'required', - 'service.docker_compose' => 'required', - 'service.name' => 'required', - 'service.description' => 'nullable', - ]; - protected $listeners = ["saveCompose"]; + protected $listeners = ["refreshStacks","checkStatus"]; public function render() { return view('livewire.project.service.index'); @@ -32,17 +26,12 @@ class Index extends Component $this->applications = $this->service->applications->sort(); $this->databases = $this->service->databases->sort(); } - public function saveCompose($raw) - { - $this->service->docker_compose_raw = $raw; - $this->submit(); - } public function checkStatus() { dispatch_sync(new ContainerStatusJob($this->service->server)); - $this->refreshStack(); + $this->refreshStacks(); } - public function refreshStack() + public function refreshStacks() { $this->applications = $this->service->applications->sort(); $this->applications->each(function ($application) { @@ -53,21 +42,4 @@ class Index extends Component $database->refresh(); }); } - - - public function submit() - { - try { - $this->validate(); - $this->service->save(); - $this->service->parse(); - $this->service->refresh(); - $this->service->saveComposeConfigs(); - $this->refreshStack(); - $this->emit('refreshEnvs'); - $this->emit('success', 'Service saved successfully.'); - } catch (\Throwable $e) { - return handleError($e, $this); - } - } } diff --git a/app/Http/Livewire/Project/Service/Modal.php b/app/Http/Livewire/Project/Service/Modal.php index a5fd759e7..7092070f6 100644 --- a/app/Http/Livewire/Project/Service/Modal.php +++ b/app/Http/Livewire/Project/Service/Modal.php @@ -6,8 +6,8 @@ use Livewire\Component; class Modal extends Component { - public function serviceStatusUpdated() { - $this->emit('serviceStatusUpdated'); + public function checkStatus() { + $this->emit('checkStatus'); } public function render() { diff --git a/app/Http/Livewire/Project/Service/Navbar.php b/app/Http/Livewire/Project/Service/Navbar.php index 3f7679c56..d85c6f435 100644 --- a/app/Http/Livewire/Project/Service/Navbar.php +++ b/app/Http/Livewire/Project/Service/Navbar.php @@ -13,20 +13,15 @@ class Navbar extends Component public Service $service; public array $parameters; public array $query; - protected $listeners = ['serviceStatusUpdated']; public function render() { return view('livewire.project.service.navbar'); } - public function serviceStatusUpdated() + + public function checkStatus() { - $this->check_status(); - } - public function check_status() - { - dispatch_sync(new ContainerStatusJob($this->service->server)); - $this->service->refresh(); + $this->emit('checkStatus'); } public function deploy() { diff --git a/app/Http/Livewire/Project/Service/StackForm.php b/app/Http/Livewire/Project/Service/StackForm.php new file mode 100644 index 000000000..1518e3d22 --- /dev/null +++ b/app/Http/Livewire/Project/Service/StackForm.php @@ -0,0 +1,42 @@ + 'required', + 'service.docker_compose' => 'required', + 'service.name' => 'required', + 'service.description' => 'nullable', + ]; + public $service; + public function saveCompose($raw) + { + $this->service->docker_compose_raw = $raw; + $this->submit(); + } + + public function submit() + { + try { + $this->validate(); + $this->service->save(); + $this->service->parse(); + $this->service->refresh(); + $this->service->saveComposeConfigs(); + $this->emit('refreshStacks'); + $this->emit('refreshEnvs'); + $this->emit('success', 'Service saved successfully.'); + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + public function render() + { + return view('livewire.project.service.stack-form'); + } +} diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 392819440..9b4ef5699 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -29,7 +29,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted public function __construct(public Server $server) { - $this->handle(); + } public function middleware(): array @@ -44,7 +44,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted public function handle() { try { - ray("checking server status for {$this->server->name}"); + ray("checking server status for {$this->server->id}"); // ray()->clearAll(); $serverUptimeCheckNumber = $this->server->unreachable_count; $serverUptimeCheckNumberMax = 3; diff --git a/resources/views/livewire/project/service/index.blade.php b/resources/views/livewire/project/service/index.blade.php index 05a90dd5d..a966c56d4 100644 --- a/resources/views/livewire/project/service/index.blade.php +++ b/resources/views/livewire/project/service/index.blade.php @@ -1,40 +1,24 @@ -