From b314b08f2517e72dd74bc8e983e1e2ff0530a1a3 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:34:46 +0200 Subject: [PATCH] Feat: stop service confirm --- app/Actions/Service/StopService.php | 6 ++- app/Livewire/Project/Service/Navbar.php | 26 +++++----- .../livewire/project/service/navbar.blade.php | 50 ++++++++++++++----- 3 files changed, 55 insertions(+), 27 deletions(-) diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php index 6b348f830..6c0990331 100644 --- a/app/Actions/Service/StopService.php +++ b/app/Actions/Service/StopService.php @@ -10,7 +10,7 @@ class StopService { use AsAction; - public function handle(Service $service, bool $isDeleteOperation = false) + public function handle(Service $service, bool $isDeleteOperation = false, bool $dockerCleanup = true) { try { $server = $service->destination->server; @@ -24,7 +24,9 @@ class StopService if (!$isDeleteOperation) { $service->delete_connected_networks($service->uuid); - CleanupDocker::run($server, true); + if ($dockerCleanup) { + CleanupDocker::run($server, true); + } } } catch (\Exception $e) { ray($e->getMessage()); diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php index 674182df5..66d3079ec 100644 --- a/app/Livewire/Project/Service/Navbar.php +++ b/app/Livewire/Project/Service/Navbar.php @@ -20,6 +20,8 @@ class Navbar extends Component public $isDeploymentProgress = false; + public $docker_cleanup = true; + public function mount() { if (str($this->service->status())->contains('running') && is_null($this->service->config_hash)) { @@ -60,11 +62,6 @@ class Navbar extends Component $this->dispatch('success', 'Service status updated.'); } - public function render() - { - return view('livewire.project.service.navbar'); - } - public function checkDeployments() { try { @@ -95,14 +92,9 @@ class Navbar extends Component $this->dispatch('activityMonitor', $activity->id); } - public function stop(bool $forceCleanup = false) + public function stop() { - StopService::run($this->service); - if ($forceCleanup) { - $this->dispatch('success', 'Containers cleaned up.'); - } else { - $this->dispatch('success', 'Service stopped.'); - } + StopService::run($this->service, false, $this->docker_cleanup); ServiceStatusChanged::dispatch(); } @@ -121,4 +113,14 @@ class Navbar extends Component $activity = StartService::run($this->service); $this->dispatch('activityMonitor', $activity->id); } + + public function render() + { + return view('livewire.project.service.navbar', [ + 'checkboxes' => [ + ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images (the next deployment will take longer as the images have to be pulled again)'], + ] + ]); + } + } diff --git a/resources/views/livewire/project/service/navbar.blade.php b/resources/views/livewire/project/service/navbar.blade.php index 67d6a78ca..09f218c84 100644 --- a/resources/views/livewire/project/service/navbar.blade.php +++ b/resources/views/livewire/project/service/navbar.blade.php @@ -26,7 +26,18 @@ Pull Latest Images & Restart - + @@ -37,9 +48,6 @@ Stop - This service will be stopped.
- And all none persitant data will be deleted (Containers, Networks, Unused Images).
- Please think again.
@elseif (str($service->status())->contains('degraded')) - + @@ -62,9 +81,6 @@ Stop - This service will be stopped.
- And all none persitant data will be deleted (Containers, Networks, Unused Images).
- Please think again.
@elseif (str($service->status())->contains('exited')) @else - + @@ -92,10 +119,7 @@ Stop - - This service will be stopped.
- And all none persitant data will be deleted (Containers, Networks, Unused Images).
- Please think again. +