UI options for deletion WIP
This commit is contained in:
@@ -10,7 +10,7 @@ class DeleteService
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(Service $service)
|
||||
public function handle(Service $service, bool $deleteConfigurations, bool $deleteVolumes, bool $deleteImages, bool $deleteNetworks)
|
||||
{
|
||||
try {
|
||||
$server = data_get($service, 'server');
|
||||
@@ -61,4 +61,4 @@ class DeleteService
|
||||
CleanupDocker::run($server, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Actions\Application\StopApplication;
|
||||
use App\Actions\Database\StopDatabase;
|
||||
use App\Actions\Service\DeleteService;
|
||||
use App\Actions\Service\StopService;
|
||||
use App\Actions\Server\CleanupDocker;
|
||||
use App\Models\Application;
|
||||
use App\Models\Service;
|
||||
use App\Models\StandaloneClickhouse;
|
||||
@@ -31,7 +32,11 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
|
||||
public function __construct(
|
||||
public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
|
||||
public bool $deleteConfigurations = false,
|
||||
public bool $deleteVolumes = false) {}
|
||||
public bool $deleteVolumes = false,
|
||||
public bool $deleteImages = false,
|
||||
public bool $deleteNetworks = false
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
@@ -59,19 +64,33 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->deleteVolumes && $this->resource->type() !== 'service') {
|
||||
$this->resource?->delete_volumes($persistentStorages);
|
||||
}
|
||||
if ($this->deleteConfigurations) {
|
||||
$this->resource?->delete_configurations();
|
||||
}
|
||||
|
||||
if ($this->deleteVolumes && $this->resource->type() !== 'service') {
|
||||
$this->resource?->delete_volumes($persistentStorages);
|
||||
}
|
||||
|
||||
if ($this->deleteImages) {
|
||||
// Logic to delete images
|
||||
}
|
||||
|
||||
if ($this->deleteNetworks) {
|
||||
// Logic to delete networks
|
||||
}
|
||||
|
||||
$server = data_get($this->resource, 'server');
|
||||
if ($server) {
|
||||
CleanupDocker::run($server, true);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
ray($e->getMessage());
|
||||
send_internal_notification('ContainerStoppingJob failed with: '.$e->getMessage());
|
||||
send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());
|
||||
throw $e;
|
||||
} finally {
|
||||
$this->resource->forceDelete();
|
||||
Artisan::queue('cleanup:stucked-resources');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,7 @@
|
||||
<x-forms.checkbox id="delete_configurations"
|
||||
label="Permanently delete configuration files from the server?"></x-forms.checkbox>
|
||||
<x-forms.checkbox id="delete_volumes" label="Permanently delete associated volumes?"></x-forms.checkbox>
|
||||
<x-forms.checkbox id="delete_images" label="Permanently delete associated unused images?"></x-forms.checkbox>
|
||||
<x-forms.checkbox id="delete_connected_networks" label="Permanently delete all connected networks, this includes predfined ones?"></x-forms.checkbox>
|
||||
</x-modal-confirmation>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user