Feat: stop service confirm

This commit is contained in:
ayntk-ai
2024-09-04 14:34:46 +02:00
parent 9a2d5be354
commit b314b08f25
3 changed files with 55 additions and 27 deletions

View File

@@ -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());

View File

@@ -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)'],
]
]);
}
}