From df796dffa2598354b7edcf3965dd00d45787eebf Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 8 Aug 2024 01:02:48 +0200
Subject: [PATCH 001/101] fix delte networks and unused images of services when
deleted
---
app/Actions/Service/DeleteService.php | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php
index 194cf4db9..b043082ac 100644
--- a/app/Actions/Service/DeleteService.php
+++ b/app/Actions/Service/DeleteService.php
@@ -3,6 +3,7 @@
namespace App\Actions\Service;
use App\Models\Service;
+use App\Actions\Server\CleanupDocker;
use Lorisleiva\Actions\Concerns\AsAction;
class DeleteService
@@ -33,6 +34,11 @@ class DeleteService
foreach ($storagesToDelete as $storage) {
$commands[] = "docker volume rm -f $storage->name";
}
+
+ $uuid = $service->uuid;
+ instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
+ instant_remote_process(["docker network rm {$uuid}"], $server, false);
+
$commands[] = "docker rm -f $service->uuid";
instant_remote_process($commands, $server, false);
@@ -50,6 +56,9 @@ class DeleteService
$task->delete();
}
$service->tags()->detach();
+ $service->forceDelete();
+
+ CleanupDocker::run($server, true);
}
}
}
From 070daee28e8f5c91401c37c778b919f1270042a0 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 8 Aug 2024 01:19:17 +0200
Subject: [PATCH 002/101] remove networks and cleanup unused images when
stoping dockercompose build pack containers
---
app/Actions/Application/StopApplication.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/Actions/Application/StopApplication.php b/app/Actions/Application/StopApplication.php
index 1f05e29ac..70575c821 100644
--- a/app/Actions/Application/StopApplication.php
+++ b/app/Actions/Application/StopApplication.php
@@ -3,6 +3,7 @@
namespace App\Actions\Application;
use App\Models\Application;
+use App\Actions\Server\CleanupDocker;
use Lorisleiva\Actions\Concerns\AsAction;
class StopApplication
@@ -13,7 +14,6 @@ class StopApplication
{
if ($application->destination->server->isSwarm()) {
instant_remote_process(["docker stack rm {$application->uuid}"], $application->destination->server);
-
return;
}
@@ -23,7 +23,7 @@ class StopApplication
$servers->push($server);
});
foreach ($servers as $server) {
- if (! $server->isFunctional()) {
+ if (!$server->isFunctional()) {
return 'Server is not functional';
}
if ($previewDeployments) {
@@ -44,10 +44,11 @@ class StopApplication
}
}
if ($application->build_pack === 'dockercompose') {
- // remove network
$uuid = $application->uuid;
instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
instant_remote_process(["docker network rm {$uuid}"], $server, false);
+
+ CleanupDocker::run($server, true);
}
}
}
From 4d0acee95cf32173411523429598bb21774e1ca8 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 8 Aug 2024 12:31:37 +0200
Subject: [PATCH 003/101] UI options for deletion WIP
---
app/Actions/Service/DeleteService.php | 4 +--
app/Jobs/DeleteResourceJob.php | 31 +++++++++++++++----
.../livewire/project/shared/danger.blade.php | 4 ++-
3 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php
index b043082ac..7c8eaf75d 100644
--- a/app/Actions/Service/DeleteService.php
+++ b/app/Actions/Service/DeleteService.php
@@ -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);
}
}
-}
+}
\ No newline at end of file
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index dbf44dd5d..36f673986 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -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');
}
}
-}
+}
\ No newline at end of file
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 276061a8e..20bd7310b 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -12,5 +12,7 @@
+
+
-
+
\ No newline at end of file
From 0135e2b5c02095aa43e67c370c70747a96cf7f83 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 00:30:11 +0200
Subject: [PATCH 004/101] add logic
---
app/Actions/Application/StopApplication.php | 3 +-
app/Actions/Service/DeleteService.php | 34 +++++++---
app/Jobs/DeleteResourceJob.php | 28 ++++----
app/Livewire/Project/Shared/Danger.php | 12 +++-
app/Models/Application.php | 68 +++++++++++--------
app/Models/ServiceApplication.php | 4 +-
.../livewire/project/shared/danger.blade.php | 9 ++-
7 files changed, 94 insertions(+), 64 deletions(-)
diff --git a/app/Actions/Application/StopApplication.php b/app/Actions/Application/StopApplication.php
index c81e90518..73abeba7a 100644
--- a/app/Actions/Application/StopApplication.php
+++ b/app/Actions/Application/StopApplication.php
@@ -43,8 +43,7 @@ class StopApplication
}
if ($application->build_pack === 'dockercompose') {
$uuid = $application->uuid;
- instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
- instant_remote_process(["docker network rm {$uuid}"], $server, false);
+ $application->delete_connected_networks($uuid);
CleanupDocker::run($server, true);
}
diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php
index 7c8eaf75d..f32a44262 100644
--- a/app/Actions/Service/DeleteService.php
+++ b/app/Actions/Service/DeleteService.php
@@ -10,14 +10,16 @@ class DeleteService
{
use AsAction;
- public function handle(Service $service, bool $deleteConfigurations, bool $deleteVolumes, bool $deleteImages, bool $deleteNetworks)
+ public function handle(Service $service, bool $deleteConfigurations, bool $deleteVolumes, bool $deleteImages, bool $deleteConnectedNetworks)
{
try {
$server = data_get($service, 'server');
+
if ($server->isFunctional()) {
$storagesToDelete = collect([]);
$service->environment_variables()->delete();
+
$commands = [];
foreach ($service->applications()->get() as $application) {
$storages = $application->persistentStorages()->get();
@@ -31,21 +33,34 @@ class DeleteService
$storagesToDelete->push($storage);
}
}
- foreach ($storagesToDelete as $storage) {
- $commands[] = "docker volume rm -f $storage->name";
+
+ // Delete volumes if the flag is set
+ if ($deleteVolumes) {
+ foreach ($service->applications()->get() as $application) {
+ $persistentStorages = $application->persistentStorages()->get();
+ $application->delete_volumes($persistentStorages);
+ }
}
- $uuid = $service->uuid;
- instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
- instant_remote_process(["docker network rm {$uuid}"], $server, false);
+ // Delete networks if the flag is set
+ if ($deleteConnectedNetworks) {
+ $uuid = $service->uuid;
+ $service->delete_connected_networks($uuid);
+ }
+ // Command to remove the service itself
$commands[] = "docker rm -f $service->uuid";
+ // Execute all commands
instant_remote_process($commands, $server, false);
}
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
} finally {
+ // Delete configurations if the flag is set
+ if ($deleteConfigurations) {
+ $service->delete_configurations();
+ }
foreach ($service->applications()->get() as $application) {
$application->forceDelete();
}
@@ -58,7 +73,10 @@ class DeleteService
$service->tags()->detach();
$service->forceDelete();
- CleanupDocker::run($server, true);
+ // Run cleanup if images need to be deleted
+ if ($deleteImages) {
+ CleanupDocker::run($server, true);
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index 36f673986..68036ee4a 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -31,10 +31,10 @@ 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 $deleteImages = false,
- public bool $deleteNetworks = false
+ public bool $deleteConfigurations,
+ public bool $deleteVolumes,
+ public bool $deleteImages,
+ public bool $deleteConnectedNetworks
) {
}
@@ -60,7 +60,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
break;
case 'service':
StopService::run($this->resource);
- DeleteService::run($this->resource);
+ DeleteService::run($this->resource, $this->deleteConfigurations, $this->deleteVolumes, $this->deleteImages, $this->deleteConnectedNetworks);
break;
}
@@ -72,20 +72,16 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
$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) {
+ if ($this->deleteImages && $server) {
CleanupDocker::run($server, true);
}
+
+ if ($this->deleteConnectedNetworks) {
+ $uuid = $this->resource->uuid; // Get the UUID from the resource
+ $this->resource?->delete_connected_networks($uuid); // Pass the UUID to the method
+ }
} catch (\Throwable $e) {
- ray($e->getMessage());
send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());
throw $e;
} finally {
@@ -93,4 +89,4 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
Artisan::queue('cleanup:stucked-resources');
}
}
-}
\ No newline at end of file
+}
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index 5f0178be4..cff1d453a 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -18,6 +18,10 @@ class Danger extends Component
public bool $delete_volumes = true;
+ public bool $delete_images = true;
+
+ public bool $delete_connected_networks = true;
+
public ?string $modalId = null;
public function mount()
@@ -33,7 +37,13 @@ class Danger extends Component
try {
// $this->authorize('delete', $this->resource);
$this->resource->delete();
- DeleteResourceJob::dispatch($this->resource, $this->delete_configurations, $this->delete_volumes);
+ DeleteResourceJob::dispatch(
+ $this->resource,
+ $this->delete_configurations,
+ $this->delete_volumes,
+ $this->delete_images,
+ $this->delete_connected_networks
+ );
return redirect()->route('project.resource.index', [
'project_uuid' => $this->projectUuid,
diff --git a/app/Models/Application.php b/app/Models/Application.php
index e2871da4b..324713bbf 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -152,7 +152,7 @@ class Application extends BaseModel
$workdir = $this->workdir();
if (str($workdir)->endsWith($this->uuid)) {
ray('Deleting workdir');
- instant_remote_process(['rm -rf '.$this->workdir()], $server, false);
+ instant_remote_process(['rm -rf ' . $this->workdir()], $server, false);
}
}
@@ -173,6 +173,15 @@ class Application extends BaseModel
}
}
+ public function delete_connected_networks($uuid)
+ {
+ $server = data_get($this, 'destination.server');
+ ray($uuid);
+ instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
+ instant_remote_process(["docker network rm {$uuid}"], $server, false);
+ }
+
+
public function additional_servers()
{
return $this->belongsToMany(Server::class, 'additional_destinations')
@@ -280,7 +289,7 @@ class Application extends BaseModel
public function publishDirectory(): Attribute
{
return Attribute::make(
- set: fn ($value) => $value ? '/'.ltrim($value, '/') : null,
+ set: fn ($value) => $value ? '/' . ltrim($value, '/') : null,
);
}
@@ -288,7 +297,7 @@ class Application extends BaseModel
{
return Attribute::make(
get: function () {
- if (! is_null($this->source?->html_url) && ! is_null($this->git_repository) && ! is_null($this->git_branch)) {
+ if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) {
if (str($this->git_repository)->contains('bitbucket')) {
return "{$this->source->html_url}/{$this->git_repository}/src/{$this->git_branch}";
}
@@ -315,7 +324,7 @@ class Application extends BaseModel
{
return Attribute::make(
get: function () {
- if (! is_null($this->source?->html_url) && ! is_null($this->git_repository) && ! is_null($this->git_branch)) {
+ if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) {
return "{$this->source->html_url}/{$this->git_repository}/settings/hooks";
}
// Convert the SSH URL to HTTPS URL
@@ -334,7 +343,7 @@ class Application extends BaseModel
{
return Attribute::make(
get: function () {
- if (! is_null($this->source?->html_url) && ! is_null($this->git_repository) && ! is_null($this->git_branch)) {
+ if (!is_null($this->source?->html_url) && !is_null($this->git_repository) && !is_null($this->git_branch)) {
return "{$this->source->html_url}/{$this->git_repository}/commits/{$this->git_branch}";
}
// Convert the SSH URL to HTTPS URL
@@ -351,7 +360,7 @@ class Application extends BaseModel
public function gitCommitLink($link): string
{
- if (! is_null(data_get($this, 'source.html_url')) && ! is_null(data_get($this, 'git_repository')) && ! is_null(data_get($this, 'git_branch'))) {
+ if (!is_null(data_get($this, 'source.html_url')) && !is_null(data_get($this, 'git_repository')) && !is_null(data_get($this, 'git_branch'))) {
if (str($this->source->html_url)->contains('bitbucket')) {
return "{$this->source->html_url}/{$this->git_repository}/commits/{$link}";
}
@@ -362,7 +371,7 @@ class Application extends BaseModel
$git_repository = str_replace('.git', '', $this->git_repository);
$url = Url::fromString($git_repository);
$url = $url->withUserInfo('');
- $url = $url->withPath($url->getPath().'/commits/'.$link);
+ $url = $url->withPath($url->getPath() . '/commits/' . $link);
return $url->__toString();
}
@@ -432,7 +441,7 @@ class Application extends BaseModel
public function baseDirectory(): Attribute
{
return Attribute::make(
- set: fn ($value) => '/'.ltrim($value, '/'),
+ set: fn ($value) => '/' . ltrim($value, '/'),
);
}
@@ -775,7 +784,7 @@ class Application extends BaseModel
public function workdir()
{
- return application_configuration_dir()."/{$this->uuid}";
+ return application_configuration_dir() . "/{$this->uuid}";
}
public function isLogDrainEnabled()
@@ -785,7 +794,7 @@ class Application extends BaseModel
public function isConfigurationChanged(bool $save = false)
{
- $newConfigHash = $this->fqdn.$this->git_repository.$this->git_branch.$this->git_commit_sha.$this->build_pack.$this->static_image.$this->install_command.$this->build_command.$this->start_command.$this->ports_exposes.$this->ports_mappings.$this->base_directory.$this->publish_directory.$this->dockerfile.$this->dockerfile_location.$this->custom_labels.$this->custom_docker_run_options.$this->dockerfile_target_build.$this->redirect;
+ $newConfigHash = $this->fqdn . $this->git_repository . $this->git_branch . $this->git_commit_sha . $this->build_pack . $this->static_image . $this->install_command . $this->build_command . $this->start_command . $this->ports_exposes . $this->ports_mappings . $this->base_directory . $this->publish_directory . $this->dockerfile . $this->dockerfile_location . $this->custom_labels . $this->custom_docker_run_options . $this->dockerfile_target_build . $this->redirect;
if ($this->pull_request_id === 0 || $this->pull_request_id === null) {
$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());
} else {
@@ -839,7 +848,7 @@ class Application extends BaseModel
public function dirOnServer()
{
- return application_configuration_dir()."/{$this->uuid}";
+ return application_configuration_dir() . "/{$this->uuid}";
}
public function setGitImportSettings(string $deployment_uuid, string $git_clone_command, bool $public = false)
@@ -885,7 +894,7 @@ class Application extends BaseModel
if ($this->source->is_public) {
$fullRepoUrl = "{$this->source->html_url}/{$customRepository}";
$git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$customRepository} {$baseDir}";
- if (! $only_checkout) {
+ if (!$only_checkout) {
$git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command, public: true);
}
if ($exec_in_docker) {
@@ -902,7 +911,7 @@ class Application extends BaseModel
$git_clone_command = "{$git_clone_command} $source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$customRepository} {$baseDir}";
$fullRepoUrl = "$source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$customRepository}";
}
- if (! $only_checkout) {
+ if (!$only_checkout) {
$git_clone_command = $this->setGitImportSettings($deployment_uuid, $git_clone_command, public: false);
}
if ($exec_in_docker) {
@@ -963,7 +972,7 @@ class Application extends BaseModel
} else {
$commands->push("echo 'Checking out $branch'");
}
- $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name);
+ $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && " . $this->buildGitCheckoutCommand($pr_branch_name);
} elseif ($git_type === 'github' || $git_type === 'gitea') {
$branch = "pull/{$pull_request_id}/head:$pr_branch_name";
if ($exec_in_docker) {
@@ -971,14 +980,14 @@ class Application extends BaseModel
} else {
$commands->push("echo 'Checking out $branch'");
}
- $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name);
+ $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && " . $this->buildGitCheckoutCommand($pr_branch_name);
} elseif ($git_type === 'bitbucket') {
if ($exec_in_docker) {
$commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'"));
} else {
$commands->push("echo 'Checking out $branch'");
}
- $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" ".$this->buildGitCheckoutCommand($commit);
+ $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" " . $this->buildGitCheckoutCommand($commit);
}
}
@@ -1007,7 +1016,7 @@ class Application extends BaseModel
} else {
$commands->push("echo 'Checking out $branch'");
}
- $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name);
+ $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && " . $this->buildGitCheckoutCommand($pr_branch_name);
} elseif ($git_type === 'github' || $git_type === 'gitea') {
$branch = "pull/{$pull_request_id}/head:$pr_branch_name";
if ($exec_in_docker) {
@@ -1015,14 +1024,14 @@ class Application extends BaseModel
} else {
$commands->push("echo 'Checking out $branch'");
}
- $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && ".$this->buildGitCheckoutCommand($pr_branch_name);
+ $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git fetch origin $branch && " . $this->buildGitCheckoutCommand($pr_branch_name);
} elseif ($git_type === 'bitbucket') {
if ($exec_in_docker) {
$commands->push(executeInDocker($deployment_uuid, "echo 'Checking out $branch'"));
} else {
$commands->push("echo 'Checking out $branch'");
}
- $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" ".$this->buildGitCheckoutCommand($commit);
+ $git_clone_command = "{$git_clone_command} && cd {$baseDir} && GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" " . $this->buildGitCheckoutCommand($commit);
}
}
@@ -1074,20 +1083,20 @@ class Application extends BaseModel
}
if ($source->startsWith('.')) {
$source = $source->after('.');
- $source = $workdir.$source;
+ $source = $workdir . $source;
}
$commands->push("mkdir -p $source > /dev/null 2>&1 || true");
}
}
}
$labels = collect(data_get($service, 'labels', []));
- if (! $labels->contains('coolify.managed')) {
+ if (!$labels->contains('coolify.managed')) {
$labels->push('coolify.managed=true');
}
- if (! $labels->contains('coolify.applicationId')) {
- $labels->push('coolify.applicationId='.$this->id);
+ if (!$labels->contains('coolify.applicationId')) {
+ $labels->push('coolify.applicationId=' . $this->id);
}
- if (! $labels->contains('coolify.type')) {
+ if (!$labels->contains('coolify.type')) {
$labels->push('coolify.type=application');
}
data_set($service, 'labels', $labels->toArray());
@@ -1161,7 +1170,7 @@ class Application extends BaseModel
$jsonNames = $json->keys()->toArray();
$diff = array_diff($jsonNames, $names);
$json = $json->filter(function ($value, $key) use ($diff) {
- return ! in_array($key, $diff);
+ return !in_array($key, $diff);
});
if ($json) {
$this->docker_compose_domains = json_encode($json);
@@ -1178,13 +1187,12 @@ class Application extends BaseModel
} else {
throw new \RuntimeException("Docker Compose file not found at: $workdir$composeFile Check if you used the right extension (.yaml or .yml) in the compose file name.");
}
-
}
public function parseContainerLabels(?ApplicationPreview $preview = null)
{
$customLabels = data_get($this, 'custom_labels');
- if (! $customLabels) {
+ if (!$customLabels) {
return;
}
if (base64_encode(base64_decode($customLabels, true)) !== $customLabels) {
@@ -1267,10 +1275,10 @@ class Application extends BaseModel
continue;
}
if (isset($healthcheckCommand) && str_contains($trimmedLine, '\\')) {
- $healthcheckCommand .= ' '.trim($trimmedLine, '\\ ');
+ $healthcheckCommand .= ' ' . trim($trimmedLine, '\\ ');
}
- if (isset($healthcheckCommand) && ! str_contains($trimmedLine, '\\') && ! empty($healthcheckCommand)) {
- $healthcheckCommand .= ' '.$trimmedLine;
+ if (isset($healthcheckCommand) && !str_contains($trimmedLine, '\\') && !empty($healthcheckCommand)) {
+ $healthcheckCommand .= ' ' . $trimmedLine;
break;
}
}
diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.php
index 6690f254e..9df825869 100644
--- a/app/Models/ServiceApplication.php
+++ b/app/Models/ServiceApplication.php
@@ -23,7 +23,7 @@ class ServiceApplication extends BaseModel
public function restart()
{
- $container_id = $this->name.'-'.$this->service->uuid;
+ $container_id = $this->name . '-' . $this->service->uuid;
instant_remote_process(["docker restart {$container_id}"], $this->service->server);
}
@@ -59,7 +59,7 @@ class ServiceApplication extends BaseModel
public function workdir()
{
- return service_configuration_dir()."/{$this->service->uuid}";
+ return service_configuration_dir() . "/{$this->service->uuid}";
}
public function serviceType()
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 20bd7310b..f9eaec30f 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -9,10 +9,9 @@
This resource will be deleted. It is not reversible. Please think
again.
Actions
-
-
-
-
+
+
+
+
\ No newline at end of file
From 70aa05bde96a7a9a26d40903fc3dc81d3ba6e074 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 00:42:23 +0200
Subject: [PATCH 005/101] order in importance
---
resources/views/livewire/project/shared/danger.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index f9eaec30f..6d00f357c 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -9,9 +9,9 @@
This resource will be deleted. It is not reversible. Please think
again.
Actions
-
-
+
+
\ No newline at end of file
From 51071da7006c7b15cc8f6828a8586d6678a072a4 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 01:00:07 +0200
Subject: [PATCH 006/101] fix order
---
app/Jobs/DeleteResourceJob.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index 68036ee4a..50e0e646e 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -64,13 +64,12 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
break;
}
- if ($this->deleteConfigurations) {
- $this->resource?->delete_configurations();
- }
-
if ($this->deleteVolumes && $this->resource->type() !== 'service') {
$this->resource?->delete_volumes($persistentStorages);
}
+ if ($this->deleteConfigurations) {
+ $this->resource?->delete_configurations();
+ }
$server = data_get($this->resource, 'server');
if ($this->deleteImages && $server) {
From 86a087056e289873b474dacf0dd063b2b5e285cd Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 02:11:42 +0200
Subject: [PATCH 007/101] fix volume deletion for services
---
app/Actions/Service/DeleteService.php | 46 ++++++++++---------
.../livewire/project/shared/danger.blade.php | 2 +-
2 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php
index f32a44262..13b5cc50b 100644
--- a/app/Actions/Service/DeleteService.php
+++ b/app/Actions/Service/DeleteService.php
@@ -14,12 +14,10 @@ class DeleteService
{
try {
$server = data_get($service, 'server');
-
- if ($server->isFunctional()) {
+ if ($deleteVolumes && $server->isFunctional()) {
$storagesToDelete = collect([]);
$service->environment_variables()->delete();
-
$commands = [];
foreach ($service->applications()->get() as $application) {
$storages = $application->persistentStorages()->get();
@@ -33,27 +31,33 @@ class DeleteService
$storagesToDelete->push($storage);
}
}
-
- // Delete volumes if the flag is set
- if ($deleteVolumes) {
- foreach ($service->applications()->get() as $application) {
- $persistentStorages = $application->persistentStorages()->get();
- $application->delete_volumes($persistentStorages);
- }
+ foreach ($storagesToDelete as $storage) {
+ $commands[] = "docker volume rm -f $storage->name";
}
- // Delete networks if the flag is set
- if ($deleteConnectedNetworks) {
- $uuid = $service->uuid;
- $service->delete_connected_networks($uuid);
- }
-
- // Command to remove the service itself
- $commands[] = "docker rm -f $service->uuid";
-
// Execute all commands
- instant_remote_process($commands, $server, false);
+ if (!empty($commands)) {
+ foreach ($commands as $command) {
+ $result = instant_remote_process([$command], $server, false);
+ if ($result !== 0) {
+ ray("Failed to execute: $command");
+ }
+ }
+ }
}
+
+ // Delete networks if the flag is set
+ if ($deleteConnectedNetworks) {
+ $uuid = $service->uuid;
+ $service->delete_connected_networks($uuid);
+ }
+
+ // Command to remove the service itself
+ $commands[] = "docker rm -f $service->uuid";
+
+ // Execute all commands
+ instant_remote_process($commands, $server, false);
+
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
} finally {
@@ -79,4 +83,4 @@ class DeleteService
}
}
}
-}
+}
\ No newline at end of file
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 6d00f357c..174731eea 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -10,7 +10,7 @@
again.
Actions
-
+
From e67e03f73f2c8405b9bb96d6c1adb3f27c1b7e48 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 02:15:40 +0200
Subject: [PATCH 008/101] added comments and removed temp ones
---
app/Actions/Service/DeleteService.php | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php
index 13b5cc50b..521a70e83 100644
--- a/app/Actions/Service/DeleteService.php
+++ b/app/Actions/Service/DeleteService.php
@@ -35,7 +35,7 @@ class DeleteService
$commands[] = "docker volume rm -f $storage->name";
}
- // Execute all commands
+ // Execute volume deletion first, this must be done first otherwise volumes will not be deleted.
if (!empty($commands)) {
foreach ($commands as $command) {
$result = instant_remote_process([$command], $server, false);
@@ -46,22 +46,18 @@ class DeleteService
}
}
- // Delete networks if the flag is set
if ($deleteConnectedNetworks) {
$uuid = $service->uuid;
$service->delete_connected_networks($uuid);
}
- // Command to remove the service itself
$commands[] = "docker rm -f $service->uuid";
- // Execute all commands
+ // Executing remaining commands
instant_remote_process($commands, $server, false);
-
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
} finally {
- // Delete configurations if the flag is set
if ($deleteConfigurations) {
$service->delete_configurations();
}
@@ -77,10 +73,9 @@ class DeleteService
$service->tags()->detach();
$service->forceDelete();
- // Run cleanup if images need to be deleted
if ($deleteImages) {
CleanupDocker::run($server, true);
}
}
}
-}
\ No newline at end of file
+}
From 7722809c52a04f052bfd1d2632daaf88ca0527a7 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 02:20:32 +0200
Subject: [PATCH 009/101] typo
---
resources/views/livewire/project/shared/danger.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 174731eea..1e1365749 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -10,7 +10,7 @@
again.
Actions
-
+
From 53dff4ca4f6f34f2d47de2db4e9c960275da1a34 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 02:58:59 +0200
Subject: [PATCH 010/101] simplify uuid variabel
---
app/Actions/Service/DeleteService.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php
index 521a70e83..186200993 100644
--- a/app/Actions/Service/DeleteService.php
+++ b/app/Actions/Service/DeleteService.php
@@ -47,14 +47,14 @@ class DeleteService
}
if ($deleteConnectedNetworks) {
- $uuid = $service->uuid;
- $service->delete_connected_networks($uuid);
+ $service->delete_connected_networks($service->uuid);
}
$commands[] = "docker rm -f $service->uuid";
// Executing remaining commands
instant_remote_process($commands, $server, false);
+
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
} finally {
From d980c7a4254900d4c98fefd84f2cc257e2128356 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 02:59:41 +0200
Subject: [PATCH 011/101] only run network removal on stop service if it is not
a deletion operation
---
app/Actions/Service/StopService.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php
index 3dd91b4e2..e7d108528 100644
--- a/app/Actions/Service/StopService.php
+++ b/app/Actions/Service/StopService.php
@@ -9,14 +9,14 @@ class StopService
{
use AsAction;
- public function handle(Service $service)
+ public function handle(Service $service, bool $isDeleteOperation = false)
{
try {
$server = $service->destination->server;
- if (! $server->isFunctional()) {
+ if (!$server->isFunctional()) {
return 'Server is not functional';
}
- ray('Stopping service: '.$service->name);
+ ray('Stopping service: ' . $service->name);
$applications = $service->applications()->get();
foreach ($applications as $application) {
instant_remote_process(command: ["docker stop --time=30 {$application->name}-{$service->uuid}"], server: $server, throwError: false);
@@ -31,13 +31,15 @@ class StopService
instant_remote_process(command: ["docker rm -f {$db->name}-{$service->uuid}"], server: $server, throwError: false);
$db->update(['status' => 'exited']);
}
- instant_remote_process(["docker network disconnect {$service->uuid} coolify-proxy"], $service->server);
- instant_remote_process(["docker network rm {$service->uuid}"], $service->server);
+
+ if (!$isDeleteOperation) {
+ // Only run this if not a delete operation
+ $service->delete_connected_networks($service->uuid);
+ }
} catch (\Exception $e) {
ray($e->getMessage());
return $e->getMessage();
}
-
}
}
From 97c2bedda27f9078c794ac952332681f1b2e5024 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 03:00:30 +0200
Subject: [PATCH 012/101] add delete_connected_networks function to
services.php
---
app/Models/Application.php | 2 --
app/Models/Service.php | 15 +++++++++++----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 324713bbf..d88e94e19 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -151,7 +151,6 @@ class Application extends BaseModel
$server = data_get($this, 'destination.server');
$workdir = $this->workdir();
if (str($workdir)->endsWith($this->uuid)) {
- ray('Deleting workdir');
instant_remote_process(['rm -rf ' . $this->workdir()], $server, false);
}
}
@@ -176,7 +175,6 @@ class Application extends BaseModel
public function delete_connected_networks($uuid)
{
$server = data_get($this, 'destination.server');
- ray($uuid);
instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
instant_remote_process(["docker network rm {$uuid}"], $server, false);
}
diff --git a/app/Models/Service.php b/app/Models/Service.php
index 33238281e..f56d05af1 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -56,7 +56,7 @@ class Service extends BaseModel
$databaseStorages = $this->databases()->get()->pluck('persistentStorages')->flatten()->sortBy('id');
$storages = $applicationStorages->merge($databaseStorages)->implode('updated_at');
- $newConfigHash = $images.$domains.$images.$storages;
+ $newConfigHash = $images . $domains . $images . $storages;
$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());
$newConfigHash = md5($newConfigHash);
$oldConfigHash = data_get($this, 'config_hash');
@@ -121,13 +121,20 @@ class Service extends BaseModel
public function delete_configurations()
{
- $server = data_get($this, 'server');
+ $server = data_get($this, 'destination.server');
$workdir = $this->workdir();
if (str($workdir)->endsWith($this->uuid)) {
- instant_remote_process(['rm -rf '.$this->workdir()], $server, false);
+ instant_remote_process(['rm -rf ' . $this->workdir()], $server, false);
}
}
+ public function delete_connected_networks($uuid)
+ {
+ $server = data_get($this, 'destination.server');
+ instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
+ instant_remote_process(["docker network rm {$uuid}"], $server, false);
+ }
+
public function status()
{
$applications = $this->applications;
@@ -907,7 +914,7 @@ class Service extends BaseModel
public function workdir()
{
- return service_configuration_dir()."/{$this->uuid}";
+ return service_configuration_dir() . "/{$this->uuid}";
}
public function saveComposeConfigs()
From 5595853379307589cf0b50dc4c573028ded651df Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 03:03:40 +0200
Subject: [PATCH 013/101] WIP database network, image removal
---
app/Jobs/DeleteResourceJob.php | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index 50e0e646e..6e102266a 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -57,9 +57,19 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
case 'standalone-clickhouse':
$persistentStorages = $this->resource?->persistentStorages()?->get();
StopDatabase::run($this->resource);
+ // TODO
+ // DBs do not have a network normally?
+ //if ($this->deleteConnectedNetworks) {
+ // $this->resource?->delete_connected_networks($this->resource->uuid);
+ // }
+ // }
+ // $server = data_get($this->resource, 'server');
+ // if ($this->deleteImages && $server) {
+ // CleanupDocker::run($server, true);
+ // }
break;
case 'service':
- StopService::run($this->resource);
+ StopService::run($this->resource, true);
DeleteService::run($this->resource, $this->deleteConfigurations, $this->deleteVolumes, $this->deleteImages, $this->deleteConnectedNetworks);
break;
}
@@ -77,8 +87,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
}
if ($this->deleteConnectedNetworks) {
- $uuid = $this->resource->uuid; // Get the UUID from the resource
- $this->resource?->delete_connected_networks($uuid); // Pass the UUID to the method
+ $this->resource?->delete_connected_networks($this->resource->uuid);
}
} catch (\Throwable $e) {
send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());
From d177e49e62abfee19f4da56f8c01b6b29ab3974f Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 18:43:13 +0200
Subject: [PATCH 014/101] updated warning message and formating
---
.../livewire/project/service/navbar.blade.php | 208 +++++++++---------
1 file changed, 100 insertions(+), 108 deletions(-)
diff --git a/resources/views/livewire/project/service/navbar.blade.php b/resources/views/livewire/project/service/navbar.blade.php
index 125f9121a..67d6a78ca 100644
--- a/resources/views/livewire/project/service/navbar.blade.php
+++ b/resources/views/livewire/project/service/navbar.blade.php
@@ -10,130 +10,122 @@
-
+
Configuration
@if (str($service->status())->contains('running'))
-
-
-
-
-
-
+
+
+
+
+
+
+
+ Pull Latest Images & Restart
+
+
+
+
+
+
+
+
+
- Pull Latest Images & Restart
-
-
-
-
-
-
-
-
-
-
- Stop
-
- This service will be stopped. Please think again.
-
+ 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'))
-
-
-
-
-
-
+
+
+
+
+
+
+
+ Restart Degraded Services
+
+
+
+
+
+
+
+
+
- Restart Degraded Services
-
-
-
-
-
-
-
-
-
-
- Stop
-
- This service will be stopped. Please think again.
-
+ 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'))
-
-
-
-
-
- Force Cleanup Containers
-
-
-
-
-
-
- Deploy
-
+
+
+
+
+
+ Force Cleanup Containers
+
+
+
+
+
+
+ Deploy
+
@else
-
-
-
-
-
-
-
-
-
- Stop
-
- This service will be stopped. Please think again.
-
-
-
-
-
+
+
+
+
+
+
+
+
- Deploy
-
+ Stop
+
+ This service will be stopped.
+
And all none persitant data will be deleted (Containers, Networks, Unused Images).
+ Please think again.
+
+
+
+
+
+
+ Deploy
+
@endif
@script
-
+
@endscript
From 72bcf03cbb942b49891e4683b3479cbf5441382d Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 18:59:41 +0200
Subject: [PATCH 015/101] graceful service container stop
---
app/Actions/Service/StopService.php | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php
index e7d108528..933eca7d4 100644
--- a/app/Actions/Service/StopService.php
+++ b/app/Actions/Service/StopService.php
@@ -3,6 +3,7 @@
namespace App\Actions\Service;
use App\Models\Service;
+use App\Actions\Server\CleanupDocker;
use Lorisleiva\Actions\Concerns\AsAction;
class StopService
@@ -19,27 +20,38 @@ class StopService
ray('Stopping service: ' . $service->name);
$applications = $service->applications()->get();
foreach ($applications as $application) {
- instant_remote_process(command: ["docker stop --time=30 {$application->name}-{$service->uuid}"], server: $server, throwError: false);
- instant_remote_process(command: ["docker rm {$application->name}-{$service->uuid}"], server: $server, throwError: false);
- instant_remote_process(command: ["docker rm -f {$application->name}-{$service->uuid}"], server: $server, throwError: false);
+ $this->stopContainer("{$application->name}-{$service->uuid}", $server, 600);
$application->update(['status' => 'exited']);
}
$dbs = $service->databases()->get();
foreach ($dbs as $db) {
- instant_remote_process(command: ["docker stop --time=30 {$db->name}-{$service->uuid}"], server: $server, throwError: false);
- instant_remote_process(command: ["docker rm {$db->name}-{$service->uuid}"], server: $server, throwError: false);
- instant_remote_process(command: ["docker rm -f {$db->name}-{$service->uuid}"], server: $server, throwError: false);
+ $this->stopContainer("{$db->name}-{$service->uuid}", $server, 600);
$db->update(['status' => 'exited']);
}
if (!$isDeleteOperation) {
- // Only run this if not a delete operation
+ // Only run if not a deletion operation as for deletion we can specify if we want to delete networks or not
$service->delete_connected_networks($service->uuid);
+ CleanupDocker::run($server, true);
}
} catch (\Exception $e) {
ray($e->getMessage());
-
return $e->getMessage();
}
}
+
+ private function stopContainer(string $containerName, $server, int $timeout = 600)
+ {
+ try {
+ instant_remote_process(command: ["docker stop --time=$timeout $containerName"], server: $server, throwError: false);
+ $isRunning = instant_remote_process(command: ["docker inspect -f '{{.State.Running}}' $containerName"], server: $server, throwError: false);
+
+ if (trim($isRunning) === 'true') {
+ instant_remote_process(command: ["docker kill $containerName"], server: $server, throwError: false);
+ }
+ } catch (\Exception $error) {
+ }
+
+ instant_remote_process(command: ["docker rm -f $containerName"], server: $server, throwError: false);
+ }
}
From 1cfddfd529025e8623cd8ca9b2cdba334fbf8a3f Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 19:17:58 +0200
Subject: [PATCH 016/101] fix stop large amount of containers
---
app/Actions/Service/StopService.php | 76 +++++++++++++++++++++--------
1 file changed, 57 insertions(+), 19 deletions(-)
diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php
index 933eca7d4..035781885 100644
--- a/app/Actions/Service/StopService.php
+++ b/app/Actions/Service/StopService.php
@@ -5,6 +5,8 @@ namespace App\Actions\Service;
use App\Models\Service;
use App\Actions\Server\CleanupDocker;
use Lorisleiva\Actions\Concerns\AsAction;
+use Illuminate\Support\Facades\Process;
+use Illuminate\Process\InvokedProcess;
class StopService
{
@@ -18,19 +20,12 @@ class StopService
return 'Server is not functional';
}
ray('Stopping service: ' . $service->name);
- $applications = $service->applications()->get();
- foreach ($applications as $application) {
- $this->stopContainer("{$application->name}-{$service->uuid}", $server, 600);
- $application->update(['status' => 'exited']);
- }
- $dbs = $service->databases()->get();
- foreach ($dbs as $db) {
- $this->stopContainer("{$db->name}-{$service->uuid}", $server, 600);
- $db->update(['status' => 'exited']);
- }
+
+ $containersToStop = $this->getContainersToStop($service);
+
+ $this->stopContainers($containersToStop, $server);
if (!$isDeleteOperation) {
- // Only run if not a deletion operation as for deletion we can specify if we want to delete networks or not
$service->delete_connected_networks($service->uuid);
CleanupDocker::run($server, true);
}
@@ -40,18 +35,61 @@ class StopService
}
}
- private function stopContainer(string $containerName, $server, int $timeout = 600)
+ private function getContainersToStop(Service $service): array
{
- try {
- instant_remote_process(command: ["docker stop --time=$timeout $containerName"], server: $server, throwError: false);
- $isRunning = instant_remote_process(command: ["docker inspect -f '{{.State.Running}}' $containerName"], server: $server, throwError: false);
+ $containersToStop = [];
+ $applications = $service->applications()->get();
+ foreach ($applications as $application) {
+ $containersToStop[] = "{$application->name}-{$service->uuid}";
+ }
+ $dbs = $service->databases()->get();
+ foreach ($dbs as $db) {
+ $containersToStop[] = "{$db->name}-{$service->uuid}";
+ }
+ return $containersToStop;
+ }
- if (trim($isRunning) === 'true') {
- instant_remote_process(command: ["docker kill $containerName"], server: $server, throwError: false);
- }
- } catch (\Exception $error) {
+ private function stopContainers(array $containerNames, $server, int $timeout = 300)
+ {
+ $processes = [];
+ foreach ($containerNames as $containerName) {
+ $processes[$containerName] = $this->stopContainer($containerName, $server, $timeout);
}
+ $startTime = time();
+ while (count($processes) > 0) {
+ $finishedProcesses = array_filter($processes, function ($process) {
+ return !$process->running();
+ });
+ foreach ($finishedProcesses as $containerName => $process) {
+ unset($processes[$containerName]);
+ $this->removeContainer($containerName, $server);
+ }
+
+ if (time() - $startTime >= $timeout) {
+ $this->forceStopRemainingContainers(array_keys($processes), $server);
+ break;
+ }
+
+ usleep(100000);
+ }
+ }
+
+ private function stopContainer(string $containerName, $server, int $timeout): InvokedProcess
+ {
+ return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
+ }
+
+ private function removeContainer(string $containerName, $server)
+ {
instant_remote_process(command: ["docker rm -f $containerName"], server: $server, throwError: false);
}
+
+ private function forceStopRemainingContainers(array $containerNames, $server)
+ {
+ foreach ($containerNames as $containerName) {
+ instant_remote_process(command: ["docker kill $containerName"], server: $server, throwError: false);
+ $this->removeContainer($containerName, $server);
+ }
+ }
}
From a4bb87d13b5ac132c634feec986537aab93b3ad1 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 19:22:14 +0200
Subject: [PATCH 017/101] simplify DeleteService.php
---
app/Actions/Service/DeleteService.php | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php
index 186200993..238e6b954 100644
--- a/app/Actions/Service/DeleteService.php
+++ b/app/Actions/Service/DeleteService.php
@@ -50,11 +50,7 @@ class DeleteService
$service->delete_connected_networks($service->uuid);
}
- $commands[] = "docker rm -f $service->uuid";
-
- // Executing remaining commands
- instant_remote_process($commands, $server, false);
-
+ instant_remote_process(["docker rm -f $service->uuid"], $server, throwError: false);
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
} finally {
From 450351921eeae0f98f6b2ba157a16b8cf83e561b Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 19:39:21 +0200
Subject: [PATCH 018/101] added public functions
---
app/Models/Application.php | 55 ++++++++++++++++++++++++++++++++++++++
app/Models/Service.php | 55 ++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+)
diff --git a/app/Models/Application.php b/app/Models/Application.php
index d88e94e19..2873ee7da 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -8,6 +8,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
+use Illuminate\Support\Facades\Process;
+use Illuminate\Process\InvokedProcess;
use OpenApi\Attributes as OA;
use RuntimeException;
use Spatie\Activitylog\Models\Activity;
@@ -146,6 +148,59 @@ class Application extends BaseModel
return Application::whereRelation('environment.project.team', 'id', $teamId)->orderBy('name');
}
+ public function getContainersToStop(bool $previewDeployments = false): array
+ {
+ $containers = $previewDeployments
+ ? getCurrentApplicationContainerStatus($this->destination->server, $this->id, includePullrequests: true)
+ : getCurrentApplicationContainerStatus($this->destination->server, $this->id, 0);
+
+ return $containers->pluck('Names')->toArray();
+ }
+
+ public function stopContainers(array $containerNames, $server, int $timeout = 600)
+ {
+ $processes = [];
+ foreach ($containerNames as $containerName) {
+ $processes[$containerName] = $this->stopContainer($containerName, $server, $timeout);
+ }
+
+ $startTime = time();
+ while (count($processes) > 0) {
+ $finishedProcesses = array_filter($processes, function ($process) {
+ return !$process->running();
+ });
+ foreach ($finishedProcesses as $containerName => $process) {
+ unset($processes[$containerName]);
+ $this->removeContainer($containerName, $server);
+ }
+
+ if (time() - $startTime >= $timeout) {
+ $this->forceStopRemainingContainers(array_keys($processes), $server);
+ break;
+ }
+
+ usleep(100000);
+ }
+ }
+
+ public function stopContainer(string $containerName, $server, int $timeout): InvokedProcess
+ {
+ return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
+ }
+
+ public function removeContainer(string $containerName, $server)
+ {
+ instant_remote_process(command: ["docker rm -f $containerName"], server: $server, throwError: false);
+ }
+
+ public function forceStopRemainingContainers(array $containerNames, $server)
+ {
+ foreach ($containerNames as $containerName) {
+ instant_remote_process(command: ["docker kill $containerName"], server: $server, throwError: false);
+ $this->removeContainer($containerName, $server);
+ }
+ }
+
public function delete_configurations()
{
$server = data_get($this, 'destination.server');
diff --git a/app/Models/Service.php b/app/Models/Service.php
index f56d05af1..14213ee9a 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Process;
+use Illuminate\Process\InvokedProcess;
use OpenApi\Attributes as OA;
use Spatie\Url\Url;
use Symfony\Component\Yaml\Yaml;
@@ -119,6 +121,59 @@ class Service extends BaseModel
return $this->morphToMany(Tag::class, 'taggable');
}
+ public function getContainersToStop(bool $previewDeployments = false): array
+ {
+ $containers = $previewDeployments
+ ? getCurrentApplicationContainerStatus($this->destination->server, $this->id, includePullrequests: true)
+ : getCurrentApplicationContainerStatus($this->destination->server, $this->id, 0);
+
+ return $containers->pluck('Names')->toArray();
+ }
+
+ public function stopContainers(array $containerNames, $server, int $timeout = 600)
+ {
+ $processes = [];
+ foreach ($containerNames as $containerName) {
+ $processes[$containerName] = $this->stopContainer($containerName, $server, $timeout);
+ }
+
+ $startTime = time();
+ while (count($processes) > 0) {
+ $finishedProcesses = array_filter($processes, function ($process) {
+ return !$process->running();
+ });
+ foreach ($finishedProcesses as $containerName => $process) {
+ unset($processes[$containerName]);
+ $this->removeContainer($containerName, $server);
+ }
+
+ if (time() - $startTime >= $timeout) {
+ $this->forceStopRemainingContainers(array_keys($processes), $server);
+ break;
+ }
+
+ usleep(100000);
+ }
+ }
+
+ public function stopContainer(string $containerName, $server, int $timeout): InvokedProcess
+ {
+ return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
+ }
+
+ public function removeContainer(string $containerName, $server)
+ {
+ instant_remote_process(command: ["docker rm -f $containerName"], server: $server, throwError: false);
+ }
+
+ public function forceStopRemainingContainers(array $containerNames, $server)
+ {
+ foreach ($containerNames as $containerName) {
+ instant_remote_process(command: ["docker kill $containerName"], server: $server, throwError: false);
+ $this->removeContainer($containerName, $server);
+ }
+ }
+
public function delete_configurations()
{
$server = data_get($this, 'destination.server');
From 41be1f7666c67ce53afdf994427a9489d6d5fe96 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 19:39:43 +0200
Subject: [PATCH 019/101] use public function
---
app/Actions/Application/StopApplication.php | 45 +++++---------
app/Actions/Service/StopService.php | 65 +--------------------
2 files changed, 18 insertions(+), 92 deletions(-)
diff --git a/app/Actions/Application/StopApplication.php b/app/Actions/Application/StopApplication.php
index 73abeba7a..5f5846f55 100644
--- a/app/Actions/Application/StopApplication.php
+++ b/app/Actions/Application/StopApplication.php
@@ -12,41 +12,28 @@ class StopApplication
public function handle(Application $application, bool $previewDeployments = false)
{
- if ($application->destination->server->isSwarm()) {
- instant_remote_process(["docker stack rm {$application->uuid}"], $application->destination->server);
- return;
- }
-
- $servers = collect([]);
- $servers->push($application->destination->server);
- $application->additional_servers->map(function ($server) use ($servers) {
- $servers->push($server);
- });
- foreach ($servers as $server) {
+ try {
+ $server = $application->destination->server;
if (!$server->isFunctional()) {
return 'Server is not functional';
}
- if ($previewDeployments) {
- $containers = getCurrentApplicationContainerStatus($server, $application->id, includePullrequests: true);
- } else {
- $containers = getCurrentApplicationContainerStatus($server, $application->id, 0);
- }
- if ($containers->count() > 0) {
- foreach ($containers as $container) {
- $containerName = data_get($container, 'Names');
- if ($containerName) {
- instant_remote_process(command: ["docker stop --time=30 $containerName"], server: $server, throwError: false);
- instant_remote_process(command: ["docker rm $containerName"], server: $server, throwError: false);
- instant_remote_process(command: ["docker rm -f {$containerName}"], server: $server, throwError: false);
- }
- }
- }
- if ($application->build_pack === 'dockercompose') {
- $uuid = $application->uuid;
- $application->delete_connected_networks($uuid);
+ ray('Stopping application: ' . $application->name);
+ if ($server->isSwarm()) {
+ instant_remote_process(["docker stack rm {$application->uuid}"], $server);
+ return;
+ }
+
+ $containersToStop = $application->getContainersToStop($previewDeployments);
+ $application->stopContainers($containersToStop, $server);
+
+ if ($application->build_pack === 'dockercompose') {
+ $application->delete_connected_networks($application->uuid);
CleanupDocker::run($server, true);
}
+ } catch (\Exception $e) {
+ ray($e->getMessage());
+ return $e->getMessage();
}
}
}
diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php
index 035781885..6b348f830 100644
--- a/app/Actions/Service/StopService.php
+++ b/app/Actions/Service/StopService.php
@@ -5,8 +5,6 @@ namespace App\Actions\Service;
use App\Models\Service;
use App\Actions\Server\CleanupDocker;
use Lorisleiva\Actions\Concerns\AsAction;
-use Illuminate\Support\Facades\Process;
-use Illuminate\Process\InvokedProcess;
class StopService
{
@@ -21,9 +19,8 @@ class StopService
}
ray('Stopping service: ' . $service->name);
- $containersToStop = $this->getContainersToStop($service);
-
- $this->stopContainers($containersToStop, $server);
+ $containersToStop = $service->getContainersToStop();
+ $service->stopContainers($containersToStop, $server);
if (!$isDeleteOperation) {
$service->delete_connected_networks($service->uuid);
@@ -34,62 +31,4 @@ class StopService
return $e->getMessage();
}
}
-
- private function getContainersToStop(Service $service): array
- {
- $containersToStop = [];
- $applications = $service->applications()->get();
- foreach ($applications as $application) {
- $containersToStop[] = "{$application->name}-{$service->uuid}";
- }
- $dbs = $service->databases()->get();
- foreach ($dbs as $db) {
- $containersToStop[] = "{$db->name}-{$service->uuid}";
- }
- return $containersToStop;
- }
-
- private function stopContainers(array $containerNames, $server, int $timeout = 300)
- {
- $processes = [];
- foreach ($containerNames as $containerName) {
- $processes[$containerName] = $this->stopContainer($containerName, $server, $timeout);
- }
-
- $startTime = time();
- while (count($processes) > 0) {
- $finishedProcesses = array_filter($processes, function ($process) {
- return !$process->running();
- });
- foreach ($finishedProcesses as $containerName => $process) {
- unset($processes[$containerName]);
- $this->removeContainer($containerName, $server);
- }
-
- if (time() - $startTime >= $timeout) {
- $this->forceStopRemainingContainers(array_keys($processes), $server);
- break;
- }
-
- usleep(100000);
- }
- }
-
- private function stopContainer(string $containerName, $server, int $timeout): InvokedProcess
- {
- return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
- }
-
- private function removeContainer(string $containerName, $server)
- {
- instant_remote_process(command: ["docker rm -f $containerName"], server: $server, throwError: false);
- }
-
- private function forceStopRemainingContainers(array $containerNames, $server)
- {
- foreach ($containerNames as $containerName) {
- instant_remote_process(command: ["docker kill $containerName"], server: $server, throwError: false);
- $this->removeContainer($containerName, $server);
- }
- }
}
From 2ca6ffb84e59d3221fb5a6c4d320fae5c091988d Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 19:57:53 +0200
Subject: [PATCH 020/101] fix public function service.php
---
app/Actions/Service/StopService.php | 2 +-
app/Models/Service.php | 25 +++++++++++++++----------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php
index 6b348f830..85c61dc83 100644
--- a/app/Actions/Service/StopService.php
+++ b/app/Actions/Service/StopService.php
@@ -31,4 +31,4 @@ class StopService
return $e->getMessage();
}
}
-}
+}
\ No newline at end of file
diff --git a/app/Models/Service.php b/app/Models/Service.php
index 14213ee9a..64796283c 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -121,20 +121,25 @@ class Service extends BaseModel
return $this->morphToMany(Tag::class, 'taggable');
}
- public function getContainersToStop(bool $previewDeployments = false): array
+ public function getContainersToStop(): array
{
- $containers = $previewDeployments
- ? getCurrentApplicationContainerStatus($this->destination->server, $this->id, includePullrequests: true)
- : getCurrentApplicationContainerStatus($this->destination->server, $this->id, 0);
-
- return $containers->pluck('Names')->toArray();
+ $containersToStop = [];
+ $applications = $this->applications()->get();
+ foreach ($applications as $application) {
+ $containersToStop[] = "{$application->name}-{$this->uuid}";
+ }
+ $dbs = $this->databases()->get();
+ foreach ($dbs as $db) {
+ $containersToStop[] = "{$db->name}-{$this->uuid}";
+ }
+ return $containersToStop;
}
- public function stopContainers(array $containerNames, $server, int $timeout = 600)
+ public function stopContainers(array $containerNames, $server, int $timeout = 300)
{
$processes = [];
foreach ($containerNames as $containerName) {
- $processes[$containerName] = $this->stopContainer($containerName, $server, $timeout);
+ $processes[$containerName] = $this->stopContainer($containerName, $timeout);
}
$startTime = time();
@@ -142,7 +147,7 @@ class Service extends BaseModel
$finishedProcesses = array_filter($processes, function ($process) {
return !$process->running();
});
- foreach ($finishedProcesses as $containerName => $process) {
+ foreach (array_keys($finishedProcesses) as $containerName) {
unset($processes[$containerName]);
$this->removeContainer($containerName, $server);
}
@@ -156,7 +161,7 @@ class Service extends BaseModel
}
}
- public function stopContainer(string $containerName, $server, int $timeout): InvokedProcess
+ public function stopContainer(string $containerName, int $timeout): InvokedProcess
{
return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
}
From c566152f3777a53e4e86dd7713a08599e889f3a5 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 20:28:57 +0200
Subject: [PATCH 021/101] improve graceful_shutdown_container
---
app/Jobs/ApplicationDeploymentJob.php | 45 ++++++++++++++++++++-------
1 file changed, 33 insertions(+), 12 deletions(-)
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 473cbc679..42c1ba43c 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -28,6 +28,7 @@ use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Collection;
use Illuminate\Support\Sleep;
use Illuminate\Support\Str;
+use Illuminate\Support\Facades\Process;
use RuntimeException;
use Symfony\Component\Yaml\Yaml;
use Throwable;
@@ -894,7 +895,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$envs->push("COOLIFY_FQDN={$this->application->fqdn}");
}
if ($this->application->environment_variables->where('key', 'COOLIFY_URL')->isEmpty()) {
- $url = str($this->application->fqdn)->replace('http://', '')->replace('https://', '');
+ $url = str_replace('http://', '', $this->application->fqdn);
+ $url = str_replace('https://', '', $url);
$envs->push("COOLIFY_URL={$url}");
}
if ($this->application->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
@@ -2027,24 +2029,43 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
$this->application_deployment_queue->addLogEntry('Building docker image completed.');
}
- /**
- * @param int $timeout in seconds
- */
- private function graceful_shutdown_container(string $containerName, int $timeout = 30)
+ private function graceful_shutdown_container(string $containerName, int $timeout = 300)
{
try {
- $this->execute_remote_command(
- ["docker stop --time=$timeout $containerName", 'hidden' => true, 'ignore_errors' => true],
- ["docker rm $containerName", 'hidden' => true, 'ignore_errors' => true]
- );
+ $process = Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
+
+ $startTime = time();
+ while ($process->running()) {
+ if (time() - $startTime >= $timeout) {
+ $this->execute_remote_command(
+ ["docker kill $containerName", 'hidden' => true, 'ignore_errors' => true]
+ );
+ break;
+ }
+ usleep(100000);
+ }
+
+ $isRunning = $this->execute_remote_command(
+ ["docker inspect -f '{{.State.Running}}' $containerName", 'hidden' => true, 'ignore_errors' => true]
+ ) === 'true';
+
+ if ($isRunning) {
+ $this->execute_remote_command(
+ ["docker kill $containerName", 'hidden' => true, 'ignore_errors' => true]
+ );
+ }
} catch (\Exception $error) {
- // report error if needed
+ $this->application_deployment_queue->addLogEntry("Error stopping container $containerName: " . $error->getMessage(), 'stderr');
}
+ $this->remove_container($containerName);
+ }
+
+ private function remove_container(string $containerName)
+ {
$this->execute_remote_command(
["docker rm -f $containerName", 'hidden' => true, 'ignore_errors' => true]
);
-
}
private function stop_running_container(bool $force = false)
@@ -2057,7 +2078,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
$containers = getCurrentApplicationContainerStatus($this->server, $this->application->id, $this->pull_request_id);
if ($this->pull_request_id === 0) {
$containers = $containers->filter(function ($container) {
- return data_get($container, 'Names') !== $this->container_name && data_get($container, 'Names') !== $this->container_name.'-pr-'.$this->pull_request_id;
+ return data_get($container, 'Names') !== $this->container_name && data_get($container, 'Names') !== $this->container_name . '-pr-' . $this->pull_request_id;
});
}
$containers->each(function ($container) {
From 16a5c601e3f93d8a8fc43672958299f6bacbcd7a Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 22:15:45 +0200
Subject: [PATCH 022/101] graceful db stop and db deletion fixes
---
app/Actions/Database/StopDatabase.php | 50 ++++++++++++++++++++++++---
app/Actions/Service/StopService.php | 2 +-
app/Jobs/DeleteResourceJob.php | 16 ++-------
3 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/app/Actions/Database/StopDatabase.php b/app/Actions/Database/StopDatabase.php
index d562ec56f..29ce794cf 100644
--- a/app/Actions/Database/StopDatabase.php
+++ b/app/Actions/Database/StopDatabase.php
@@ -10,25 +10,65 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
+use Illuminate\Support\Facades\Process;
use Lorisleiva\Actions\Concerns\AsAction;
+use App\Actions\Server\CleanupDocker;
class StopDatabase
{
use AsAction;
- public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $database)
+ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $database, bool $isDeleteOperation = false)
{
$server = $database->destination->server;
- if (! $server->isFunctional()) {
+ if (!$server->isFunctional()) {
return 'Server is not functional';
}
- instant_remote_process(command: ["docker stop --time=30 $database->uuid"], server: $server, throwError: false);
- instant_remote_process(command: ["docker rm $database->uuid"], server: $server, throwError: false);
- instant_remote_process(command: ["docker rm -f $database->uuid"], server: $server, throwError: false);
+ $this->stopContainer($database, $database->uuid, 300);
+ if (!$isDeleteOperation) {
+ $this->deleteConnectedNetworks($database->uuid, $server); //Probably not needed as DBs do not have a network normally
+ CleanupDocker::run($server, true);
+ }
if ($database->is_public) {
StopDatabaseProxy::run($database);
}
+
+ return 'Database stopped successfully';
+ }
+
+ private function stopContainer($database, string $containerName, int $timeout = 300): void
+ {
+ $server = $database->destination->server;
+
+ $process = Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
+
+ $startTime = time();
+ while ($process->running()) {
+ if (time() - $startTime >= $timeout) {
+ $this->forceStopContainer($containerName, $server);
+ break;
+ }
+ usleep(100000);
+ }
+
+ $this->removeContainer($containerName, $server);
+ }
+
+ private function forceStopContainer(string $containerName, $server): void
+ {
+ instant_remote_process(command: ["docker kill $containerName"], server: $server, throwError: false);
+ }
+
+ private function removeContainer(string $containerName, $server): void
+ {
+ instant_remote_process(command: ["docker rm -f $containerName"], server: $server, throwError: false);
+ }
+
+ private function deleteConnectedNetworks($uuid, $server)
+ {
+ instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false);
+ instant_remote_process(["docker network rm {$uuid}"], $server, false);
}
}
diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php
index 85c61dc83..6b348f830 100644
--- a/app/Actions/Service/StopService.php
+++ b/app/Actions/Service/StopService.php
@@ -31,4 +31,4 @@ class StopService
return $e->getMessage();
}
}
-}
\ No newline at end of file
+}
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index 6e102266a..1f4e835e9 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -56,17 +56,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
case 'standalone-dragonfly':
case 'standalone-clickhouse':
$persistentStorages = $this->resource?->persistentStorages()?->get();
- StopDatabase::run($this->resource);
- // TODO
- // DBs do not have a network normally?
- //if ($this->deleteConnectedNetworks) {
- // $this->resource?->delete_connected_networks($this->resource->uuid);
- // }
- // }
- // $server = data_get($this->resource, 'server');
- // if ($this->deleteImages && $server) {
- // CleanupDocker::run($server, true);
- // }
+ StopDatabase::run($this->resource, true);
break;
case 'service':
StopService::run($this->resource, true);
@@ -80,10 +70,10 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
if ($this->deleteConfigurations) {
$this->resource?->delete_configurations();
}
-
+
$server = data_get($this->resource, 'server');
if ($this->deleteImages && $server) {
- CleanupDocker::run($server, true);
+ CleanupDocker::run($server, true); //this is run for DBs but it does not work for DBs
}
if ($this->deleteConnectedNetworks) {
From 7d1179e7c89bf38d5607c8f52ff1b6eb559e6d70 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 22:25:39 +0200
Subject: [PATCH 023/101] fix cleanup images for databases
---
app/Jobs/DeleteResourceJob.php | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index 1f4e835e9..b0983bc47 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -69,11 +69,21 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
}
if ($this->deleteConfigurations) {
$this->resource?->delete_configurations();
+ ray('Iam am running now, Configurations should disapear right?');
}
- $server = data_get($this->resource, 'server');
- if ($this->deleteImages && $server) {
- CleanupDocker::run($server, true); //this is run for DBs but it does not work for DBs
+ $isDatabase = $this->resource instanceof StandalonePostgresql
+ || $this->resource instanceof StandaloneRedis
+ || $this->resource instanceof StandaloneMongodb
+ || $this->resource instanceof StandaloneMysql
+ || $this->resource instanceof StandaloneMariadb
+ || $this->resource instanceof StandaloneKeydb
+ || $this->resource instanceof StandaloneDragonfly
+ || $this->resource instanceof StandaloneClickhouse;
+ $server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server');
+ if (($this->deleteImages || $isDatabase) && $server) {
+ CleanupDocker::run($server, true);
+ ray('I am running now, images should disappear right?');
}
if ($this->deleteConnectedNetworks) {
From 840e225aa86befa895a41a789106fe317e85d66d Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 22:43:18 +0200
Subject: [PATCH 024/101] formatting and waring text
---
app/Jobs/DeleteResourceJob.php | 4 +-
app/Models/ServiceDatabase.php | 4 +-
.../project/database/heading.blade.php | 128 ++++++++----------
3 files changed, 63 insertions(+), 73 deletions(-)
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index b0983bc47..b8a8756cb 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -69,9 +69,8 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
}
if ($this->deleteConfigurations) {
$this->resource?->delete_configurations();
- ray('Iam am running now, Configurations should disapear right?');
}
-
+
$isDatabase = $this->resource instanceof StandalonePostgresql
|| $this->resource instanceof StandaloneRedis
|| $this->resource instanceof StandaloneMongodb
@@ -83,7 +82,6 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
$server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server');
if (($this->deleteImages || $isDatabase) && $server) {
CleanupDocker::run($server, true);
- ray('I am running now, images should disappear right?');
}
if ($this->deleteConnectedNetworks) {
diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php
index 4a749913e..7bbcb4f4e 100644
--- a/app/Models/ServiceDatabase.php
+++ b/app/Models/ServiceDatabase.php
@@ -21,7 +21,7 @@ class ServiceDatabase extends BaseModel
public function restart()
{
- $container_id = $this->name.'-'.$this->service->uuid;
+ $container_id = $this->name . '-' . $this->service->uuid;
remote_process(["docker restart {$container_id}"], $this->service->server);
}
@@ -78,7 +78,7 @@ class ServiceDatabase extends BaseModel
public function workdir()
{
- return service_configuration_dir()."/{$this->service->uuid}";
+ return service_configuration_dir() . "/{$this->service->uuid}";
}
public function service()
diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.php
index cee1f0520..73824421d 100644
--- a/resources/views/livewire/project/database/heading.blade.php
+++ b/resources/views/livewire/project/database/heading.blade.php
@@ -7,88 +7,80 @@
-
+
\ No newline at end of file
From b5360e5e7518b3f804301d255f87fe7958eec23e Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 23:12:30 +0200
Subject: [PATCH 025/101] improve CleanupDocker.php
---
app/Actions/Server/CleanupDocker.php | 35 ++++++++++++++++++++++------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/app/Actions/Server/CleanupDocker.php b/app/Actions/Server/CleanupDocker.php
index 0009e001d..82515ab6b 100644
--- a/app/Actions/Server/CleanupDocker.php
+++ b/app/Actions/Server/CleanupDocker.php
@@ -11,15 +11,36 @@ class CleanupDocker
public function handle(Server $server, bool $force = true)
{
- // cleanup docker images, containers, and builder caches
+ $commonCommands = [
+ 'docker container prune -f --filter "label=coolify.managed=true"',
+ 'docker image prune -f',
+ 'docker builder prune -f',
+ 'docker network prune -f',
+ ];
+
+ $forceCommands = [
+ 'docker container rm $(docker container ls -aq --filter status=exited --filter status=created)',
+ 'docker image prune -af',
+ 'docker builder prune -af',
+ 'docker system prune -af',
+ 'docker network prune -f',
+ ];
+
+ $additionalCommands = [
+ 'docker rmi $(docker images -f "dangling=true" -q)',
+ 'docker network rm $(docker network ls -q -f "unused=true")',
+ 'docker system prune -f',
+ ];
+
if ($force) {
- instant_remote_process(['docker image prune -af'], $server, false);
- instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false);
- instant_remote_process(['docker builder prune -af'], $server, false);
+ $commands = array_merge($forceCommands, $commonCommands, $additionalCommands);
+ $commands[] = 'docker rm $(docker ps -a -q --filter status=exited --filter status=created)';
} else {
- instant_remote_process(['docker image prune -f'], $server, false);
- instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false);
- instant_remote_process(['docker builder prune -f'], $server, false);
+ $commands = array_merge($commonCommands, $additionalCommands);
+ }
+
+ foreach ($commands as $command) {
+ instant_remote_process([$command], $server, false);
}
}
}
From 5b54dc8792f884e28a7a5b7606086fb880c5cf77 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 9 Aug 2024 23:25:57 +0200
Subject: [PATCH 026/101] Revert "improve CleanupDocker.php"
This reverts commit b5360e5e7518b3f804301d255f87fe7958eec23e.
---
app/Actions/Server/CleanupDocker.php | 35 ++++++----------------------
1 file changed, 7 insertions(+), 28 deletions(-)
diff --git a/app/Actions/Server/CleanupDocker.php b/app/Actions/Server/CleanupDocker.php
index 82515ab6b..0009e001d 100644
--- a/app/Actions/Server/CleanupDocker.php
+++ b/app/Actions/Server/CleanupDocker.php
@@ -11,36 +11,15 @@ class CleanupDocker
public function handle(Server $server, bool $force = true)
{
- $commonCommands = [
- 'docker container prune -f --filter "label=coolify.managed=true"',
- 'docker image prune -f',
- 'docker builder prune -f',
- 'docker network prune -f',
- ];
-
- $forceCommands = [
- 'docker container rm $(docker container ls -aq --filter status=exited --filter status=created)',
- 'docker image prune -af',
- 'docker builder prune -af',
- 'docker system prune -af',
- 'docker network prune -f',
- ];
-
- $additionalCommands = [
- 'docker rmi $(docker images -f "dangling=true" -q)',
- 'docker network rm $(docker network ls -q -f "unused=true")',
- 'docker system prune -f',
- ];
-
+ // cleanup docker images, containers, and builder caches
if ($force) {
- $commands = array_merge($forceCommands, $commonCommands, $additionalCommands);
- $commands[] = 'docker rm $(docker ps -a -q --filter status=exited --filter status=created)';
+ instant_remote_process(['docker image prune -af'], $server, false);
+ instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false);
+ instant_remote_process(['docker builder prune -af'], $server, false);
} else {
- $commands = array_merge($commonCommands, $additionalCommands);
- }
-
- foreach ($commands as $command) {
- instant_remote_process([$command], $server, false);
+ instant_remote_process(['docker image prune -f'], $server, false);
+ instant_remote_process(['docker container prune -f --filter "label=coolify.managed=true"'], $server, false);
+ instant_remote_process(['docker builder prune -f'], $server, false);
}
}
}
From 2a581147aa72c56aae32c731f0f51c81eb8d1e6e Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 27 Aug 2024 12:43:59 +0200
Subject: [PATCH 027/101] new confirm delete dialog
---
.../components/modal-confirmation.blade.php | 109 ++++--------------
.../livewire/project/shared/danger.blade.php | 72 ++++++++++--
2 files changed, 86 insertions(+), 95 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 7910d2eb2..56abba71d 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -1,62 +1,41 @@
@props([
'title' => 'Are you sure?',
'isErrorButton' => false,
- 'buttonTitle' => 'REWRITE THIS BUTTON TITLE PLEASSSSEEEE',
+ 'buttonTitle' => 'Confirm Action',
'buttonFullWidth' => false,
'customButton' => null,
'disabled' => false,
'action' => 'delete',
'content' => null,
])
-
@if ($customButton)
- @if ($buttonFullWidth)
-
- {{ $customButton }}
-
- @else
-
- {{ $customButton }}
-
- @endif
+
+ {{ $customButton }}
+
@else
@if ($content)
{{ $content }}
@else
- @if ($disabled)
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @elseif ($isErrorButton)
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @else
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @endif
+
+ {{ $buttonTitle }}
+
@endif
@endif
@@ -64,7 +43,7 @@
class="fixed top-0 lg:pt-10 left-0 z-[99] flex items-start justify-center w-screen h-screen" x-cloak>
{{ $title }}
- {{--
-
-
-
- --}}
{{ $slot }}
-
-
Cancel
-
-
- @if ($attributes->whereStartsWith('wire:click')->first())
- @if ($isErrorButton)
-
Continue
-
- @else
-
Continue
-
- @endif
- @elseif ($attributes->whereStartsWith('@click')->first())
- @if ($isErrorButton)
-
get('@click') }}">Continue
-
- @else
-
get('@click') }}">Continue
-
- @endif
- @elseif ($action)
- @if ($isErrorButton)
-
Continue
-
- @else
-
Continue
-
- @endif
- @endif
-
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 1e1365749..1b24d0593 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -5,13 +5,69 @@
This will stop your containers, delete all related data, etc. Beware! There is no coming
back!
+
- This resource will be deleted. It is not reversible. Please think
- again.
- Actions
-
-
-
-
+
+
+
+
Select the actions you want to perform:
+
+
+
+
+
+ Cancel
+
+ Continue
+
+
+
+
+
+
+
+
Warning
+
This operation is not reversible. Please proceed with caution.
+
+
The following actions will be performed:
+
+
Please type DELETE to confirm this destructive action:
+
+
+ Back
+
+ Permanently Delete
+
+
+
+
-
\ No newline at end of file
+
From ac50d8b4d8f4c9e34ff300a080825e9383433854 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 27 Aug 2024 12:57:03 +0200
Subject: [PATCH 028/101] fix styling
---
resources/views/livewire/project/shared/danger.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 1b24d0593..c021208f0 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -26,10 +26,10 @@
Cancel
Continue
@@ -55,7 +55,7 @@
Please type DELETE to confirm this destructive action:
-
+
Back
Date: Tue, 27 Aug 2024 13:44:12 +0200
Subject: [PATCH 029/101] confirm with password
---
app/Livewire/Project/Shared/Danger.php | 9 +-
.../livewire/project/shared/danger.blade.php | 152 ++++++++++--------
2 files changed, 93 insertions(+), 68 deletions(-)
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index cff1d453a..5a49460da 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -5,6 +5,8 @@ namespace App\Livewire\Project\Shared;
use App\Jobs\DeleteResourceJob;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;
class Danger extends Component
{
@@ -32,8 +34,13 @@ class Danger extends Component
$this->environmentName = data_get($parameters, 'environment_name');
}
- public function delete()
+ public function delete($selectedActions, $password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
+
try {
// $this->authorize('delete', $this->resource);
$this->resource->delete();
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index c021208f0..11521a8c6 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -1,73 +1,91 @@
-
-
Danger Zone
-
Woah. I hope you know what are you doing.
-
Delete Resource
-
This will stop your containers, delete all related data, etc. Beware! There is no coming
- back!
-
+
+
Danger Zone
-
-
-
-
-
Select the actions you want to perform:
-
-
-
-
-
- Cancel
-
- Continue
-
-
+
+
+
+
Delete Resource
+
Once you delete a resource, there is no going back. Please be certain.
+
+
+
+
+
Select the actions you want to perform:
+
+
+
+
+
+ Cancel
+
+ Continue
+
+
+
-
-
-
-
Warning
-
This operation is not reversible. Please proceed with caution.
+
+
+
+
Warning
+
This operation is not reversible. Please proceed with caution.
+
+
The following actions will be performed:
+
+
Please type DELETE to confirm this destructive action:
+
+
+ Back
+
+ Permanently Delete
+
+
+
+
+
+
+
+
Final Confirmation
+
Please enter your password to confirm this destructive action.
+
+
+
+ Your Password
+
+
+
+
+ Back
+
+ Confirm Deletion
+
+
+
-
The following actions will be performed:
-
-
Please type DELETE to confirm this destructive action:
-
-
- Back
-
- Permanently Delete
-
-
-
+
-
+
From 472667624821eb783db40b7287f54a72015c9fdb Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 27 Aug 2024 14:19:37 +0200
Subject: [PATCH 030/101] make things more clear
---
app/Actions/Service/DeleteService.php | 4 ++--
app/Jobs/DeleteResourceJob.php | 6 ++---
app/Livewire/Project/Shared/Danger.php | 4 ++--
.../components/modal-confirmation.blade.php | 18 ++++++---------
.../livewire/project/shared/danger.blade.php | 22 +++++++++++++------
5 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php
index 238e6b954..93c79383e 100644
--- a/app/Actions/Service/DeleteService.php
+++ b/app/Actions/Service/DeleteService.php
@@ -10,7 +10,7 @@ class DeleteService
{
use AsAction;
- public function handle(Service $service, bool $deleteConfigurations, bool $deleteVolumes, bool $deleteImages, bool $deleteConnectedNetworks)
+ public function handle(Service $service, bool $deleteConfigurations, bool $deleteVolumes, bool $dockerCleanup, bool $deleteConnectedNetworks)
{
try {
$server = data_get($service, 'server');
@@ -69,7 +69,7 @@ class DeleteService
$service->tags()->detach();
$service->forceDelete();
- if ($deleteImages) {
+ if ($dockerCleanup) {
CleanupDocker::run($server, true);
}
}
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index b8a8756cb..1ebbf4681 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -33,7 +33,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
public bool $deleteConfigurations,
public bool $deleteVolumes,
- public bool $deleteImages,
+ public bool $dockerCleanup,
public bool $deleteConnectedNetworks
) {
}
@@ -60,7 +60,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
break;
case 'service':
StopService::run($this->resource, true);
- DeleteService::run($this->resource, $this->deleteConfigurations, $this->deleteVolumes, $this->deleteImages, $this->deleteConnectedNetworks);
+ DeleteService::run($this->resource, $this->deleteConfigurations, $this->deleteVolumes, $this->dockerCleanup, $this->deleteConnectedNetworks);
break;
}
@@ -80,7 +80,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
|| $this->resource instanceof StandaloneDragonfly
|| $this->resource instanceof StandaloneClickhouse;
$server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server');
- if (($this->deleteImages || $isDatabase) && $server) {
+ if (($this->dockerCleanup || $isDatabase) && $server) {
CleanupDocker::run($server, true);
}
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index 5a49460da..1fe7ec21a 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -20,7 +20,7 @@ class Danger extends Component
public bool $delete_volumes = true;
- public bool $delete_images = true;
+ public bool $docker_cleanup = true;
public bool $delete_connected_networks = true;
@@ -48,7 +48,7 @@ class Danger extends Component
$this->resource,
$this->delete_configurations,
$this->delete_volumes,
- $this->delete_images,
+ $this->docker_cleanup,
$this->delete_connected_networks
);
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 56abba71d..46910310c 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -8,15 +8,7 @@
'action' => 'delete',
'content' => null,
])
-
@if ($customButton)
@@ -32,7 +24,6 @@
@click="modalOpen=true"
class="{{ $buttonFullWidth ? 'w-full' : '' }} {{ $isErrorButton ? 'bg-red-500 hover:bg-red-600 text-white' : '' }}"
:disabled="$disabled"
- wire:target
>
{{ $buttonTitle }}
@@ -43,7 +34,7 @@
class="fixed top-0 lg:pt-10 left-0 z-[99] flex items-start justify-center w-screen h-screen" x-cloak>
{{ $slot }}
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 11521a8c6..d7360310f 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -14,23 +14,25 @@
>
-
Select the actions you want to perform:
+
+
Select the actions you want to perform:
+
-
+
Cancel
-
+
Continue
@@ -44,6 +46,12 @@
The following actions will be performed:
+
+
+
+
+ All containers of this resource will be stopped and permanently deleted.
+
From 8d2a02dc3c138fe4ec02d417a057a07b4123c70a Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 27 Aug 2024 14:29:47 +0200
Subject: [PATCH 031/101] change title of confirmation popup
---
resources/views/components/modal-confirmation.blade.php | 2 +-
resources/views/livewire/project/shared/danger.blade.php | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 46910310c..5859a2f00 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -1,5 +1,5 @@
@props([
- 'title' => 'Are you sure?',
+ 'title' => null,
'isErrorButton' => false,
'buttonTitle' => 'Confirm Action',
'buttonFullWidth' => false,
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index d7360310f..cae7c1dd9 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -11,6 +11,7 @@
isError
type="button"
buttonTitle="Delete this resource"
+ title="Resource Deletion"
>
+
+
@if ($customButton)
-
- {{ $customButton }}
-
+ @if ($buttonFullWidth)
+
+ {{ $customButton }}
+
@else
- @if ($content)
-
- {{ $content }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
+
+ {{ $customButton }}
+
+ @endif
+ @else
+ @if ($content)
+
+ {{ $content }}
+
+ @else
+ @if ($disabled)
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @elseif ($isErrorButton)
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @else
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @endif
+ @endif
@endif
-
-
-
+
+
+
{{ $title }}
-
-
-
+ {{--
+
+
-
+ --}}
- {{ $slot }}
+ @if(!empty($checkboxes))
+
+
+
+
Select the actions you want to perform:
+
+ @foreach($checkboxes as $index => $checkbox)
+
+ @endforeach
+ {{--
$wire[action])" type="button">
+ Continue
+ --}}
+
+ @else
+
+ @endif
+
+
+
+
+
Warning
+
This operation is not reversible. Please proceed with caution.
+
+
The following actions will be performed:
+
+
+
+
+
+ All containers of this resource will be stopped and permanently deleted.
+
+
+
+
+
+
+
+
+
+
+
Please type DELETE to confirm this destructive action:
+
+
+
+
+
+
+
Final Confirmation
+
Please enter your password to confirm this destructive action.
+
+
+
+ Your Password
+
+
+
+
+
+
+
+ 1 ? step-- : modalOpen = false" x-text="step > 1 ? 'Back' : 'Cancel'" class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300">
+
+ Continue
+
+
+ Confirm
+
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index cae7c1dd9..c9bbc2ed0 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -1,100 +1,27 @@
-
-
Danger Zone
-
-
-
-
-
Delete Resource
-
Once you delete a resource, there is no going back. Please be certain.
-
-
-
-
-
-
-
Select the actions you want to perform:
-
-
-
-
-
-
- Cancel
-
- Continue
-
-
-
-
-
-
-
-
Warning
-
This operation is not reversible. Please proceed with caution.
-
-
The following actions will be performed:
-
-
-
-
-
- All containers of this resource will be stopped and permanently deleted.
-
-
-
-
-
-
-
-
-
-
-
Please type DELETE to confirm this destructive action:
-
-
- Back
-
- Permanently Delete
-
-
-
-
-
-
-
-
Final Confirmation
-
Please enter your password to confirm this destructive action.
-
-
-
- Your Password
-
-
-
-
- Back
-
- Confirm Deletion
-
-
-
-
-
-
+
+
Danger Zone
+
Woah. I hope you know what are you doing.
+
Delete Resource
+
This will stop your containers, delete all related data, etc. Beware! There is no coming
+ back!
+
+ This resource will be deleted. It is not reversible. Please think again.
+
From 141752b9ad8ad72aec6ff295041bf42b53f9b07c Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 28 Aug 2024 13:11:42 +0200
Subject: [PATCH 033/101] fix checkbox actions default display
---
.../views/components/modal-confirmation.blade.php | 13 ++++++++-----
.../views/livewire/project/shared/danger.blade.php | 8 ++++----
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index eefb7d547..71b5d370b 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -17,7 +17,7 @@
Select the actions you want to perform:
@foreach($checkboxes as $index => $checkbox)
-
+
@endforeach
- {{--
$wire[action])" type="button">
- Continue
- --}}
@else
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index c9bbc2ed0..722d75c99 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -16,10 +16,10 @@
['id' => 'docker_cleanup', 'model' => 'docker_cleanup', 'label' => 'Run Docker cleanup (remove builder cache and unused images)?']
]"
:checkboxActions="[
- 'delete_volumes' => $delete_volumes ? 'All associated volumes of this resource will be deleted.' : null,
- 'delete_connected_networks' => $delete_connected_networks ? 'All connected networks of this resource will be deleted (predefined networks are not deleted).' : null,
- 'delete_configurations' => $delete_configurations ? 'All configuration files of this resource will be deleted on the server.' : null,
- 'docker_cleanup' => $docker_cleanup ? 'Docker cleanup will be executed which removes builder cache and unused images.' : null
+ 'delete_volumes' => 'All associated volumes of this resource will be deleted.',
+ 'delete_connected_networks' => 'All connected networks of this resource will be deleted (predefined networks are not deleted).',
+ 'delete_configurations' => 'All configuration files of this resource will be deleted on the server.',
+ 'docker_cleanup' => 'Docker cleanup will be executed which removes builder cache and unused images.'
]"
>
This resource will be deleted. It is not reversible.
Please think again.
From 1b51d46b3d2789d68024206a8618c995aa9c8699 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 28 Aug 2024 13:31:09 +0200
Subject: [PATCH 034/101] more props, nav button fixes
---
.../components/modal-confirmation.blade.php | 72 ++++++++++++++-----
.../livewire/project/shared/danger.blade.php | 4 ++
2 files changed, 59 insertions(+), 17 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 71b5d370b..dcd14c0d2 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -16,11 +16,12 @@
{{ $title }}
- {{--
- --}}
+
@if(!empty($checkboxes))
@@ -106,10 +107,11 @@
@endforeach
@else
-
+
@endif
+ @if($confirmWithText)
Warning
@@ -117,12 +119,14 @@
The following actions will be performed:
+ @endif
+ @if($confirmWithPassword)
+ @endif
- 1 ? step-- : modalOpen = false" x-text="step > 1 ? 'Back' : 'Cancel'" class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300">
-
- Continue
-
-
- Confirm
-
+ 1 ? step-- : modalOpen = false"
+ x-text="(step === 1 && {{ json_encode(empty($checkboxes)) }}) || step === 1 ? 'Cancel' : 'Back'"
+ class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300"
+ >
+
+
+
+ Continue Permanent Deletion
+
+
+
+
+
+ Delete Permanently
+
+
+
+
+
+ Confirm Permanent Deletion
+
+
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 722d75c99..a86142138 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -21,6 +21,10 @@
'delete_configurations' => 'All configuration files of this resource will be deleted on the server.',
'docker_cleanup' => 'Docker cleanup will be executed which removes builder cache and unused images.'
]"
+ :actions="[
+ 'All containers of this resource will be stopped and permanently deleted.'
+ ]"
+ {{-- :confirmWithPassword="false" --}}
>
This resource will be deleted. It is not reversible. Please think again.
From a2651ab3c1bc62298066e62e1ab17eef64228f44 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 28 Aug 2024 13:38:37 +0200
Subject: [PATCH 035/101] reset modal on cancel, fix back button when there is
no prior step
---
.../components/modal-confirmation.blade.php | 57 +++++++++++++++----
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index dcd14c0d2..658ca9df4 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -17,6 +17,7 @@
+}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }" class="relative w-auto h-auto">
@if ($customButton)
@if ($buttonFullWidth)
@@ -76,12 +83,31 @@
@endif
@endif
-
-
-
+
+
+
{{ $title }}
-
@@ -159,11 +185,22 @@
-
1 ? step-- : modalOpen = false"
- x-text="(step === 1 && {{ json_encode(empty($checkboxes)) }}) || step === 1 ? 'Cancel' : 'Back'"
- class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300"
- >
+
+
+ Back
+
+
+
+
+ Cancel
+
+
Date: Wed, 28 Aug 2024 13:41:24 +0200
Subject: [PATCH 036/101] improve button text
---
resources/views/components/modal-confirmation.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 658ca9df4..99872ae49 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -209,7 +209,7 @@
class="w-auto"
isError
>
- Continue Permanent Deletion
+ Continue Deletion
From 62b790085597a99e65d9102a0aea8f859943138d Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 28 Aug 2024 15:40:39 +0200
Subject: [PATCH 037/101] more props and more fixes
---
.../components/modal-confirmation.blade.php | 98 ++++++++++++++++---
1 file changed, 82 insertions(+), 16 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 99872ae49..df9cd77e7 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -11,18 +11,28 @@
'checkboxActions' => [],
'actions' => [],
'confirmWithText' => true,
+'confirmText' => 'DELETE',
'confirmWithPassword' => true,
+'step1ButtonText' => 'Continue Deletion',
+'step2ButtonText' => 'Delete Permanently',
+'step3ButtonText' => 'Confirm Permanent Deletion',
])
@if ($customButton)
@@ -132,13 +153,10 @@
>
@endforeach
- @else
-
@endif
- @if($confirmWithText)
-
+
Warning
This operation is not reversible. Please proceed with caution.
@@ -162,10 +180,50 @@
-
Please type DELETE to confirm this destructive action:
-
+ @if($confirmWithText)
+
+
Confirm Actions
+
Please confirm the actions by entering the text seen below
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Confirmation Text
+
+
+
+ @endif
- @endif
@if($confirmWithPassword)
@@ -209,29 +267,29 @@
class="w-auto"
isError
>
- Continue Deletion
+
- Delete Permanently
+
- Confirm Permanent Deletion
+
@@ -239,3 +297,11 @@
+
+
From 354c74e92084c4f144da0b63b5823d29a4431cc6 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 29 Aug 2024 12:37:19 +0200
Subject: [PATCH 038/101] fix
---
.../components/modal-confirmation.blade.php | 21 +++++++++++--------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index df9cd77e7..5d65b5511 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -33,6 +33,7 @@
confirmWithText: @js($confirmWithText),
confirmWithPassword: @js($confirmWithPassword),
copied: false,
+ action: @js($action),
getActionText(action) {
return this.checkboxActions[action] || action;
},
@@ -161,7 +162,7 @@
Warning
This operation is not reversible. Please proceed with caution.
-
The following actions will be performed:
+
The following actions will be performed:
@@ -171,13 +172,15 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@if($confirmWithText)
@@ -300,7 +303,7 @@
+
From 182af1ec1892d96658cf1aac97ca708189882eed Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 29 Aug 2024 18:01:16 +0200
Subject: [PATCH 040/101] Fix application delete
---
app/Livewire/Project/Shared/Danger.php | 38 ++++++++++++++-----
.../components/modal-confirmation.blade.php | 6 +--
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index 1fe7ec21a..85eeb8249 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -3,6 +3,9 @@
namespace App\Livewire\Project\Shared;
use App\Jobs\DeleteResourceJob;
+use App\Models\Service;
+use App\Models\ServiceDatabase;
+use App\Models\ServiceApplication;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
use Illuminate\Support\Facades\Hash;
@@ -11,36 +14,48 @@ use Illuminate\Support\Facades\Auth;
class Danger extends Component
{
public $resource;
-
+ public $service;
+ public $resourceName;
public $projectUuid;
-
public $environmentName;
-
public bool $delete_configurations = true;
-
public bool $delete_volumes = true;
-
public bool $docker_cleanup = true;
-
public bool $delete_connected_networks = true;
-
public ?string $modalId = null;
+ public string $resourceDomain = '';
public function mount()
{
- $this->modalId = new Cuid2;
$parameters = get_route_parameters();
+ $this->modalId = new Cuid2;
$this->projectUuid = data_get($parameters, 'project_uuid');
$this->environmentName = data_get($parameters, 'environment_name');
+
+ // Determine the resource name based on the available properties
+ if ($this->resource) {
+ $this->resourceName = $this->resource->name ?? 'Resource';
+ } elseif ($this->service) {
+ $this->resourceName = $this->service->name ?? 'Service'; //this does not get the name of the service
+ } else {
+ $this->resourceName = 'Unknown Resource'; //service is here?
+ }
+
+ ray($this->resourceName);
}
- public function delete($selectedActions, $password)
+ public function delete($password)
{
if (!Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return;
}
+ if (!$this->resource) {
+ $this->addError('resource', 'Resource not found.');
+ return;
+ }
+
try {
// $this->authorize('delete', $this->resource);
$this->resource->delete();
@@ -60,4 +75,9 @@ class Danger extends Component
return handleError($e, $this);
}
}
+
+ public function render()
+ {
+ return view('livewire.project.shared.danger');
+ }
}
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 44a1d5d93..1a20b72d8 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -11,7 +11,7 @@
'checkboxActions' => [],
'actions' => [],
'confirmWithText' => true,
-'confirmText' => 'DELETE',
+'confirmText' => 'Confirm Deletion',
'confirmWithPassword' => true,
'step1ButtonText' => 'Continue Deletion',
'step2ButtonText' => 'Delete Permanently',
@@ -49,9 +49,9 @@
step3ButtonText: @js($step3ButtonText),
executeAction() {
if (this.confirmWithPassword) {
- $wire.call(this.action, this.selectedActions, this.password);
+ $wire.call(this.action, this.password);
} else {
- $wire.call(this.action, this.selectedActions);
+ $wire.call(this.action);
}
this.modalOpen = false;
this.resetModal();
From d984bec17515bcb18c8130734a3ffa17b8597231 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 29 Aug 2024 18:08:58 +0200
Subject: [PATCH 041/101] Ajust text
---
resources/views/components/modal-confirmation.blade.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 1a20b72d8..ce5d7177d 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -195,7 +195,7 @@
@if($confirmWithText)
Confirm Actions
-
Please confirm the actions by entering the text seen below
+
Please confirm the execution of the actions by entering the Resource Name below
- Confirmation Text
+ Resource Name
@endif
From 6820fcc084d7d5dae6c31c56a6d5284fd04492b4 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 29 Aug 2024 18:53:49 +0200
Subject: [PATCH 042/101] Fix name for services and DBs
---
app/Livewire/Project/Shared/Danger.php | 69 ++++++++++--
.../components/modal-confirmation.blade.php | 103 ++++--------------
2 files changed, 76 insertions(+), 96 deletions(-)
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index 85eeb8249..18a9e5d6b 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -32,16 +32,61 @@ class Danger extends Component
$this->projectUuid = data_get($parameters, 'project_uuid');
$this->environmentName = data_get($parameters, 'environment_name');
- // Determine the resource name based on the available properties
- if ($this->resource) {
- $this->resourceName = $this->resource->name ?? 'Resource';
- } elseif ($this->service) {
- $this->resourceName = $this->service->name ?? 'Service'; //this does not get the name of the service
- } else {
- $this->resourceName = 'Unknown Resource'; //service is here?
+ ray('Mount method called');
+
+ if ($this->resource === null) {
+ if (isset($parameters['service_uuid'])) {
+ $this->resource = Service::where('uuid', $parameters['service_uuid'])->first();
+ } elseif (isset($parameters['stack_service_uuid'])) {
+ $this->resource = ServiceApplication::where('uuid', $parameters['stack_service_uuid'])->first()
+ ?? ServiceDatabase::where('uuid', $parameters['stack_service_uuid'])->first();
+ }
+ }
+
+ ray('Resource:', $this->resource);
+
+ if ($this->resource === null) {
+ ray('Resource is null');
+ $this->resourceName = 'Unknown Resource';
+ return;
+ }
+
+ if (!method_exists($this->resource, 'type')) {
+ ray('Resource does not have type() method');
+ $this->resourceName = 'Unknown Resource';
+ return;
+ }
+
+ ray('Resource type:', $this->resource->type());
+
+ switch ($this->resource->type()) {
+ case 'application':
+ $this->resourceName = $this->resource->name ?? 'Application';
+ break;
+ case 'standalone-postgresql':
+ case 'standalone-redis':
+ case 'standalone-mongodb':
+ case 'standalone-mysql':
+ case 'standalone-mariadb':
+ case 'standalone-keydb':
+ case 'standalone-dragonfly':
+ case 'standalone-clickhouse':
+ $this->resourceName = $this->resource->name ?? 'Database';
+ break;
+ case 'service':
+ $this->resourceName = $this->resource->name ?? 'Service';
+ break;
+ case 'service-application':
+ $this->resourceName = $this->resource->name ?? 'Service Application';
+ break;
+ case 'service-database':
+ $this->resourceName = $this->resource->name ?? 'Service Database';
+ break;
+ default:
+ $this->resourceName = 'Unknown Resource';
}
- ray($this->resourceName);
+ ray('Final resource name:', $this->resourceName);
}
public function delete($password)
@@ -76,8 +121,8 @@ class Danger extends Component
}
}
- public function render()
- {
- return view('livewire.project.shared.danger');
- }
+ // public function render()
+ // {
+ // return view('livewire.project.shared.danger');
+ // }
}
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index ce5d7177d..2b86fe475 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -114,34 +114,13 @@
@endif
@endif
-
-
-
+
+
+
{{ $title }}
-
-
+
+
@@ -154,13 +133,7 @@
Select the actions you want to perform:
@foreach($checkboxes as $index => $checkbox)
-
+
@endforeach
@endif
@@ -196,20 +169,10 @@
@endif
@@ -256,51 +214,30 @@
-
+
Back
-
+
Cancel
-
+
-
+
-
+
-
+
-
+
-
+
@@ -309,5 +246,3 @@
-
-
From da0398f35d9f040e9c5e6609dab66bb31cc79bdf Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 29 Aug 2024 21:47:17 +0200
Subject: [PATCH 043/101] remove unused code
---
app/Livewire/Project/Shared/Danger.php | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index 18a9e5d6b..ea489ef5e 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -14,7 +14,6 @@ use Illuminate\Support\Facades\Auth;
class Danger extends Component
{
public $resource;
- public $service;
public $resourceName;
public $projectUuid;
public $environmentName;
@@ -31,9 +30,9 @@ class Danger extends Component
$this->modalId = new Cuid2;
$this->projectUuid = data_get($parameters, 'project_uuid');
$this->environmentName = data_get($parameters, 'environment_name');
-
+
ray('Mount method called');
-
+
if ($this->resource === null) {
if (isset($parameters['service_uuid'])) {
$this->resource = Service::where('uuid', $parameters['service_uuid'])->first();
@@ -42,23 +41,23 @@ class Danger extends Component
?? ServiceDatabase::where('uuid', $parameters['stack_service_uuid'])->first();
}
}
-
+
ray('Resource:', $this->resource);
-
+
if ($this->resource === null) {
ray('Resource is null');
$this->resourceName = 'Unknown Resource';
return;
}
-
+
if (!method_exists($this->resource, 'type')) {
ray('Resource does not have type() method');
$this->resourceName = 'Unknown Resource';
return;
}
-
+
ray('Resource type:', $this->resource->type());
-
+
switch ($this->resource->type()) {
case 'application':
$this->resourceName = $this->resource->name ?? 'Application';
@@ -102,7 +101,6 @@ class Danger extends Component
}
try {
- // $this->authorize('delete', $this->resource);
$this->resource->delete();
DeleteResourceJob::dispatch(
$this->resource,
@@ -120,9 +118,4 @@ class Danger extends Component
return handleError($e, $this);
}
}
-
- // public function render()
- // {
- // return view('livewire.project.shared.danger');
- // }
}
From 9136d7acdc4550eb9087bc72011dd220e5996326 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 30 Aug 2024 20:00:04 +0200
Subject: [PATCH 044/101] WIP more delete confirmations
---
app/Livewire/Project/DeleteEnvironment.php | 3 +++
app/Livewire/Project/DeleteProject.php | 3 +++
.../project/delete-environment.blade.php | 15 +++++++++++++--
.../livewire/project/delete-project.blade.php | 16 +++++++++++++---
4 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/app/Livewire/Project/DeleteEnvironment.php b/app/Livewire/Project/DeleteEnvironment.php
index 22478916f..e01741770 100644
--- a/app/Livewire/Project/DeleteEnvironment.php
+++ b/app/Livewire/Project/DeleteEnvironment.php
@@ -13,9 +13,12 @@ class DeleteEnvironment extends Component
public bool $disabled = false;
+ public string $environmentName = '';
+
public function mount()
{
$this->parameters = get_route_parameters();
+ $this->environmentName = Environment::findOrFail($this->environment_id)->name;
}
public function delete()
diff --git a/app/Livewire/Project/DeleteProject.php b/app/Livewire/Project/DeleteProject.php
index 499b86e3e..360fad10a 100644
--- a/app/Livewire/Project/DeleteProject.php
+++ b/app/Livewire/Project/DeleteProject.php
@@ -13,9 +13,12 @@ class DeleteProject extends Component
public bool $disabled = false;
+ public string $projectName = '';
+
public function mount()
{
$this->parameters = get_route_parameters();
+ $this->projectName = Project::findOrFail($this->project_id)->name;
}
public function delete()
diff --git a/resources/views/livewire/project/delete-environment.blade.php b/resources/views/livewire/project/delete-environment.blade.php
index 30b8235da..956ecb92e 100644
--- a/resources/views/livewire/project/delete-environment.blade.php
+++ b/resources/views/livewire/project/delete-environment.blade.php
@@ -1,3 +1,14 @@
-
- This environment will be deleted. It is not reversible. Please think again.
+
diff --git a/resources/views/livewire/project/delete-project.blade.php b/resources/views/livewire/project/delete-project.blade.php
index b49ab4033..b8e996f56 100644
--- a/resources/views/livewire/project/delete-project.blade.php
+++ b/resources/views/livewire/project/delete-project.blade.php
@@ -1,3 +1,13 @@
-
- This project will be deleted. It is not reversible. Please think again.
-
+
From b807601d194f0ac7e6a2ef48acce5e323f878569 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 30 Aug 2024 20:08:14 +0200
Subject: [PATCH 045/101] delete user confirm
---
resources/views/livewire/team/admin-view.blade.php | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/resources/views/livewire/team/admin-view.blade.php b/resources/views/livewire/team/admin-view.blade.php
index 5035addec..0e9429eb4 100644
--- a/resources/views/livewire/team/admin-view.blade.php
+++ b/resources/views/livewire/team/admin-view.blade.php
@@ -15,7 +15,15 @@
{{ $user->email }}
-
+
This will delete all resources (application, databases, services, configurations, servers,
private keys, tags, etc.) from Coolify and from the server (if it's reachable) .
From bff6964d4aa7c7793a24af5683d1cab6a214a307 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Fri, 30 Aug 2024 20:33:12 +0200
Subject: [PATCH 046/101] scheduled task deletion
---
app/Livewire/Project/Shared/ScheduledTask/Show.php | 7 +++++--
.../project/shared/scheduled-task/show.blade.php | 14 +++++++++++---
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/app/Livewire/Project/Shared/ScheduledTask/Show.php b/app/Livewire/Project/Shared/ScheduledTask/Show.php
index 8be4ff643..37f50dd32 100644
--- a/app/Livewire/Project/Shared/ScheduledTask/Show.php
+++ b/app/Livewire/Project/Shared/ScheduledTask/Show.php
@@ -20,6 +20,8 @@ class Show extends Component
public string $type;
+ public string $scheduledTaskName;
+
protected $rules = [
'task.enabled' => 'required|boolean',
'task.name' => 'required|string',
@@ -49,6 +51,7 @@ class Show extends Component
$this->modalId = new Cuid2;
$this->task = ModelsScheduledTask::where('uuid', request()->route('task_uuid'))->first();
+ $this->scheduledTaskName = $this->task->name;
}
public function instantSave()
@@ -75,9 +78,9 @@ class Show extends Component
$this->task->delete();
if ($this->type == 'application') {
- return redirect()->route('project.application.configuration', $this->parameters);
+ return redirect()->route('project.application.configuration', $this->parameters, $this->scheduledTaskName);
} else {
- return redirect()->route('project.service.configuration', $this->parameters);
+ return redirect()->route('project.service.configuration', $this->parameters, $this->scheduledTaskName);
}
} catch (\Exception $e) {
return handleError($e);
diff --git a/resources/views/livewire/project/shared/scheduled-task/show.blade.php b/resources/views/livewire/project/shared/scheduled-task/show.blade.php
index b69463a0e..bc2ede3a3 100644
--- a/resources/views/livewire/project/shared/scheduled-task/show.blade.php
+++ b/resources/views/livewire/project/shared/scheduled-task/show.blade.php
@@ -16,9 +16,17 @@
Save
-
- You will delete scheduled task {{ $task->name }} .
-
+
From 73dfdb83a70ff9e6e3d1d97ab710a0542026eb8a Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 12:55:17 +0200
Subject: [PATCH 047/101] fix rendering bug, more props
---
.../components/modal-confirmation.blade.php | 84 +++++++++++--------
1 file changed, 47 insertions(+), 37 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 2b86fe475..acf641203 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -5,13 +5,14 @@
'buttonFullWidth' => false,
'customButton' => null,
'disabled' => false,
-'action' => 'delete',
+'submitAction' => 'delete',
'content' => null,
'checkboxes' => [],
-'checkboxActions' => [],
'actions' => [],
'confirmWithText' => true,
'confirmText' => 'Confirm Deletion',
+'confirmationLabel' => 'Please confirm the execution of the actions by entering the Name below',
+'shortConfirmationLabel' => 'Name',
'confirmWithPassword' => true,
'step1ButtonText' => 'Continue Deletion',
'step2ButtonText' => 'Delete Permanently',
@@ -23,38 +24,47 @@
step: {{ !empty($checkboxes) ? 1 : ($confirmWithPassword ? 2 : 3) }},
initialStep: {{ !empty($checkboxes) ? 1 : ($confirmWithPassword ? 2 : 3) }},
finalStep: {{ $confirmWithPassword ? 3 : (!empty($checkboxes) || $confirmWithText ? 2 : 1) }},
- selectedActions: @js(collect($checkboxes)->where('model', true)->pluck('id')->toArray()),
deleteText: '',
password: '',
- checkboxActions: @js($checkboxActions),
actions: @js($actions),
confirmText: @js($confirmText),
userConfirmText: '',
confirmWithText: @js($confirmWithText),
confirmWithPassword: @js($confirmWithPassword),
copied: false,
- action: @js($action),
- getActionText(action) {
- return this.checkboxActions[action] || action;
- },
+ submitAction: @js($submitAction),
+ passwordError: '',
+ selectedActions: [],
resetModal() {
this.step = this.initialStep;
- this.selectedActions = @js(collect($checkboxes)->where('model', true)->pluck('id')->toArray());
this.deleteText = '';
this.password = '';
this.userConfirmText = '';
+ this.passwordError = '';
},
step1ButtonText: @js($step1ButtonText),
step2ButtonText: @js($step2ButtonText),
step3ButtonText: @js($step3ButtonText),
- executeAction() {
- if (this.confirmWithPassword) {
- $wire.call(this.action, this.password);
- } else {
- $wire.call(this.action);
+ validatePassword() {
+ this.passwordError = '';
+ if (this.confirmWithPassword && !this.password) {
+ this.passwordError = 'Password is required.';
+ return false;
+ }
+ return true;
+ },
+ submitForm() {
+ if (this.validatePassword()) {
+ $wire.call(this.submitAction, this.password, this.selectedActions)
+ .then(result => {
+ if (result === true) {
+ this.modalOpen = false;
+ this.resetModal();
+ } else if (typeof result === 'string') {
+ this.passwordError = result;
+ }
+ });
}
- this.modalOpen = false;
- this.resetModal();
},
copyConfirmText() {
navigator.clipboard.writeText(this.confirmText);
@@ -62,8 +72,9 @@
setTimeout(() => {
this.copied = false;
}, 2000);
- }
-}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }" class="relative w-auto h-auto">
+ },
+
+}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }" class="relative w-auto h-auto" @password-error.window="passwordError = $event.detail">
@if ($customButton)
@if ($buttonFullWidth)
@@ -144,31 +155,29 @@
Warning
This operation is not reversible. Please proceed with caution.
- The following actions will be performed:
+ The following actions will be performed:
-
+ @foreach($actions as $action)
-
+ {{ $action }}
-
-
-
-
-
-
-
-
-
-
-
+ @endforeach
+ @foreach($checkboxes as $checkbox)
+
+
+
+
+ {{ $checkbox['label'] }}
+
+ @endforeach
@if($confirmWithText)
@@ -206,7 +215,8 @@
Your Password
-
+
+
@endif
@@ -225,7 +235,7 @@
-
+
@@ -237,7 +247,7 @@
-
+
From 76cb473db80528056a25b22bb10b2ab50385596b Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 13:06:55 +0200
Subject: [PATCH 048/101] fix default checkbox state
---
.../components/modal-confirmation.blade.php | 33 ++++++++++++++-----
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index acf641203..0896a1bc8 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -34,7 +34,7 @@
copied: false,
submitAction: @js($submitAction),
passwordError: '',
- selectedActions: [],
+ selectedActions: @js(collect($checkboxes)->pluck('id')->all()),
resetModal() {
this.step = this.initialStep;
this.deleteText = '';
@@ -73,7 +73,14 @@
this.copied = false;
}, 2000);
},
-
+ toggleAction(id) {
+ const index = this.selectedActions.indexOf(id);
+ if (index > -1) {
+ this.selectedActions.splice(index, 1);
+ } else {
+ this.selectedActions.push(id);
+ }
+ }
}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }" class="relative w-auto h-auto" @password-error.window="passwordError = $event.detail">
@if ($customButton)
@if ($buttonFullWidth)
@@ -144,7 +151,13 @@
Select the actions you want to perform:
@foreach($checkboxes as $index => $checkbox)
-
+
@endforeach
@endif
@@ -166,12 +179,14 @@
@endforeach
@foreach($checkboxes as $checkbox)
-
-
-
-
- {{ $checkbox['label'] }}
-
+
+
+
+
+
+ {{ $checkbox['label'] }}
+
+
@endforeach
@if($confirmWithText)
From bcfca40f3a7c979fed16c26742d797c61553cea6 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 13:10:45 +0200
Subject: [PATCH 049/101] rest checkboxes on close
---
resources/views/components/modal-confirmation.blade.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 0896a1bc8..02283a1a6 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -41,6 +41,7 @@
this.password = '';
this.userConfirmText = '';
this.passwordError = '';
+ this.selectedActions = @js(collect($checkboxes)->pluck('id')->all());
},
step1ButtonText: @js($step1ButtonText),
step2ButtonText: @js($step2ButtonText),
@@ -157,6 +158,7 @@
:label="$checkbox['label']"
x-on:change="toggleAction('{{ $checkbox['id'] }}')"
:checked="true"
+ x-bind:checked="selectedActions.includes('{{ $checkbox['id'] }}')"
>
@endforeach
From b118a627d001caef33a1be4bf918b817edb75b4f Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 13:41:08 +0200
Subject: [PATCH 050/101] fix password validation and password error
---
.../components/modal-confirmation.blade.php | 48 +++++++++++--------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 02283a1a6..f8b0c4a26 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -40,32 +40,34 @@
this.deleteText = '';
this.password = '';
this.userConfirmText = '';
- this.passwordError = '';
this.selectedActions = @js(collect($checkboxes)->pluck('id')->all());
+ $wire.$refresh();
},
step1ButtonText: @js($step1ButtonText),
step2ButtonText: @js($step2ButtonText),
step3ButtonText: @js($step3ButtonText),
validatePassword() {
- this.passwordError = '';
if (this.confirmWithPassword && !this.password) {
- this.passwordError = 'Password is required.';
- return false;
+ return 'Password is required.';
}
- return true;
+ return '';
},
submitForm() {
- if (this.validatePassword()) {
- $wire.call(this.submitAction, this.password, this.selectedActions)
- .then(result => {
- if (result === true) {
- this.modalOpen = false;
- this.resetModal();
- } else if (typeof result === 'string') {
- this.passwordError = result;
- }
- });
+ if (this.confirmWithPassword) {
+ this.passwordError = this.validatePassword();
+ if (this.passwordError) {
+ return;
+ }
}
+ $wire.call(this.submitAction, this.password, this.selectedActions)
+ .then(result => {
+ if (result === true) {
+ this.modalOpen = false;
+ this.resetModal();
+ } else if (typeof result === 'string') {
+ this.passwordError = result;
+ }
+ });
},
copyConfirmText() {
navigator.clipboard.writeText(this.confirmText);
@@ -82,7 +84,7 @@
this.selectedActions.push(id);
}
}
-}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }" class="relative w-auto h-auto" @password-error.window="passwordError = $event.detail">
+}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }" class="relative w-auto h-auto">
@if ($customButton)
@if ($buttonFullWidth)
@@ -134,7 +136,7 @@
@endif
-
+
{{ $title }}
@@ -234,6 +236,9 @@
+ @error('password')
+
{{ $message }}
+ @enderror
@endif
@@ -263,8 +268,13 @@
-
-
+
+
From a3dd48de1d88afdfa7ecaabd37cf99fe5571072d Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 14:51:59 +0200
Subject: [PATCH 051/101] destination and dashboard confirmation
---
app/Livewire/Dashboard.php | 2 +-
app/Livewire/Destination/Form.php | 10 +++++--
.../components/modal-confirmation.blade.php | 28 +++++++++----------
resources/views/livewire/dashboard.blade.php | 23 +++++++++++++--
.../views/livewire/destination/form.blade.php | 16 +++++++++--
5 files changed, 55 insertions(+), 24 deletions(-)
diff --git a/app/Livewire/Dashboard.php b/app/Livewire/Dashboard.php
index 1abd28c3c..1fe8b496d 100644
--- a/app/Livewire/Dashboard.php
+++ b/app/Livewire/Dashboard.php
@@ -30,10 +30,10 @@ class Dashboard extends Component
public function cleanup_queue()
{
- $this->dispatch('success', 'Cleanup started.');
Artisan::queue('cleanup:application-deployment-queue', [
'--team-id' => currentTeam()->id,
]);
+ return redirect()->route('dashboard')->with('success', 'Cleanup started.');
}
public function get_deployments()
diff --git a/app/Livewire/Destination/Form.php b/app/Livewire/Destination/Form.php
index 7125f2120..f58538dc1 100644
--- a/app/Livewire/Destination/Form.php
+++ b/app/Livewire/Destination/Form.php
@@ -1,7 +1,8 @@
destination->save();
}
- public function delete()
+ public function delete($password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
+
try {
if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') {
if ($this->destination->attachedTo()) {
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index f8b0c4a26..a1a2ef3c8 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -10,7 +10,7 @@
'checkboxes' => [],
'actions' => [],
'confirmWithText' => true,
-'confirmText' => 'Confirm Deletion',
+'confirmationText' => 'Confirm Deletion',
'confirmationLabel' => 'Please confirm the execution of the actions by entering the Name below',
'shortConfirmationLabel' => 'Name',
'confirmWithPassword' => true,
@@ -27,8 +27,8 @@
deleteText: '',
password: '',
actions: @js($actions),
- confirmText: @js($confirmText),
- userConfirmText: '',
+ confirmationText: @js($confirmationText),
+ userConfirmationText: '',
confirmWithText: @js($confirmWithText),
confirmWithPassword: @js($confirmWithPassword),
copied: false,
@@ -39,7 +39,7 @@
this.step = this.initialStep;
this.deleteText = '';
this.password = '';
- this.userConfirmText = '';
+ this.userConfirmationText = '';
this.selectedActions = @js(collect($checkboxes)->pluck('id')->all());
$wire.$refresh();
},
@@ -69,8 +69,8 @@
}
});
},
- copyConfirmText() {
- navigator.clipboard.writeText(this.confirmText);
+ copyConfirmationText() {
+ navigator.clipboard.writeText(this.confirmationText);
this.copied = true;
setTimeout(() => {
this.copied = false;
@@ -199,8 +199,8 @@
{{ $confirmationLabel }}
-
+
{{ $shortConfirmationLabel }}
-
+
@endif
- @if($confirmWithPassword)
-
+
Final Confirmation
Please enter your password to confirm this destructive action.
@@ -241,7 +240,6 @@
@enderror
- @endif
@@ -263,14 +261,14 @@
-
+
0)
@endif
-
- This will clean up the deployment queue. Please think again.
-
+
+
+
+ @if (session('success'))
+
+ {{ session('success') }}
+
+ @endif
@forelse ($deployments_per_server as $server_name => $deployments)
@@ -168,4 +183,6 @@
}
{{-- Get IPTABLES --}}
+
+
diff --git a/resources/views/livewire/destination/form.blade.php b/resources/views/livewire/destination/form.blade.php
index 96f478866..06ca4eb13 100644
--- a/resources/views/livewire/destination/form.blade.php
+++ b/resources/views/livewire/destination/form.blade.php
@@ -6,9 +6,19 @@
Save
@if ($destination->network !== 'coolify')
-
- This destination will be deleted. It is not reversible. Please think again.
-
+
@endif
From 830c047ccfabbefc4324c987d028aefe739a540a Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 15:06:07 +0200
Subject: [PATCH 052/101] delete environment confirmation
---
app/Livewire/Project/DeleteEnvironment.php | 8 +++++++-
.../livewire/project/delete-environment.blade.php | 10 ++++------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/app/Livewire/Project/DeleteEnvironment.php b/app/Livewire/Project/DeleteEnvironment.php
index e01741770..7c60c6404 100644
--- a/app/Livewire/Project/DeleteEnvironment.php
+++ b/app/Livewire/Project/DeleteEnvironment.php
@@ -3,6 +3,8 @@
namespace App\Livewire\Project;
use App\Models\Environment;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
use Livewire\Component;
class DeleteEnvironment extends Component
@@ -21,8 +23,12 @@ class DeleteEnvironment extends Component
$this->environmentName = Environment::findOrFail($this->environment_id)->name;
}
- public function delete()
+ public function delete($password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
$this->validate([
'environment_id' => 'required|int',
]);
diff --git a/resources/views/livewire/project/delete-environment.blade.php b/resources/views/livewire/project/delete-environment.blade.php
index 956ecb92e..d405d66c1 100644
--- a/resources/views/livewire/project/delete-environment.blade.php
+++ b/resources/views/livewire/project/delete-environment.blade.php
@@ -1,14 +1,12 @@
-
+/>
From b656cabb33fc260d92fa2bf363402cd327d93edb Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 15:07:50 +0200
Subject: [PATCH 053/101] delete project confirmation
---
app/Livewire/Project/DeleteProject.php | 8 +++++++-
resources/views/livewire/project/delete-project.blade.php | 5 ++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/app/Livewire/Project/DeleteProject.php b/app/Livewire/Project/DeleteProject.php
index 360fad10a..75060f8f3 100644
--- a/app/Livewire/Project/DeleteProject.php
+++ b/app/Livewire/Project/DeleteProject.php
@@ -3,6 +3,8 @@
namespace App\Livewire\Project;
use App\Models\Project;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
use Livewire\Component;
class DeleteProject extends Component
@@ -21,8 +23,12 @@ class DeleteProject extends Component
$this->projectName = Project::findOrFail($this->project_id)->name;
}
- public function delete()
+ public function delete($password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
$this->validate([
'project_id' => 'required|int',
]);
diff --git a/resources/views/livewire/project/delete-project.blade.php b/resources/views/livewire/project/delete-project.blade.php
index b8e996f56..990caaf92 100644
--- a/resources/views/livewire/project/delete-project.blade.php
+++ b/resources/views/livewire/project/delete-project.blade.php
@@ -2,12 +2,11 @@
title="Confirm Project Deletion?"
buttonTitle="Delete Project"
isErrorButton
- action="delete_project"
+ submitAction="delete"
:actions="['This will delete the selected project.']"
confirmationLabel="Please confirm the execution of the actions by entering the Project Name below"
shortConfirmationLabel="Project Name"
- submitAction="delete_project"
buttonTitle="Delete Project"
- confirmText="{{ $projectName }}"
+ confirmationText="{{ $projectName }}"
step3ButtonText="Permanently Delete Project"
/>
From 2adac01034780449832ee1efd14963256542739c Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 16:12:08 +0200
Subject: [PATCH 054/101] confirm danger
---
.../livewire/project/shared/danger.blade.php | 40 +++++++++----------
1 file changed, 18 insertions(+), 22 deletions(-)
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index a86142138..a2b0d0a93 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -2,30 +2,26 @@
Danger Zone
Woah. I hope you know what are you doing.
Delete Resource
-
This will stop your containers, delete all related data, etc. Beware! There is no coming
- back!
-
+
This will stop your containers, delete all related data, etc. Beware! There is no coming back!
'delete_volumes', 'model' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
+ ['id' => 'delete_connected_networks', 'model' => 'delete_connected_networks', 'label' => 'All connected networks with this resource will be permanently deleted (predefined networks will not be deleted)'],
+ ['id' => 'delete_configurations', 'model' => 'delete_configurations', 'label' => 'All configuration files will be permanently deleted form the server'],
+ ['id' => 'docker_cleanup', 'model' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images']
+ ]"
:actions="[
'All containers of this resource will be stopped and permanently deleted.'
- ]"
- {{-- :confirmWithPassword="false" --}}
- >
- This resource will be deleted. It is not reversible. Please think again.
-
+ ]"
+ confirmationText="{{ $resourceName }}"
+ confirmationLabel="Please confirm the execution of the actions by entering the Resource Name below"
+ shortConfirmationLabel="Resource Name"
+ step3ButtonText="Permanently Delete Resource"
+ />
From 3b3bc6c33b346e47a4fe904b2161e63591b70356 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 16:19:39 +0200
Subject: [PATCH 055/101] fix default checkbox state false or true
---
app/Livewire/Project/Shared/Danger.php | 12 ++++++++++++
.../views/components/modal-confirmation.blade.php | 8 ++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index ea489ef5e..d0f05d0ec 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -118,4 +118,16 @@ class Danger extends Component
return handleError($e, $this);
}
}
+
+ public function render()
+ {
+ return view('livewire.project.shared.danger', [
+ 'checkboxes' => [
+ ['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
+ ['id' => 'delete_connected_networks', 'label' => 'All connected networks with this resource will be permanently deleted (predefined networks will not be deleted)'],
+ ['id' => 'delete_configurations', 'label' => 'All configuration files will be permanently deleted form the server'],
+ ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images']
+ ]
+ ]);
+ }
}
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index a1a2ef3c8..060e627c6 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -34,13 +34,13 @@
copied: false,
submitAction: @js($submitAction),
passwordError: '',
- selectedActions: @js(collect($checkboxes)->pluck('id')->all()),
+ selectedActions: @js(collect($checkboxes)->pluck('id')->filter(fn($id) => $this->$id)->values()->all()),
resetModal() {
this.step = this.initialStep;
this.deleteText = '';
this.password = '';
this.userConfirmationText = '';
- this.selectedActions = @js(collect($checkboxes)->pluck('id')->all());
+ this.selectedActions = @js(collect($checkboxes)->pluck('id')->filter(fn($id) => $this->$id)->values()->all());
$wire.$refresh();
},
step1ButtonText: @js($step1ButtonText),
@@ -156,10 +156,10 @@
@foreach($checkboxes as $index => $checkbox)
@endforeach
From 38845d7eb004e0d12b327f634898a10bd54785f3 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 18:29:19 +0200
Subject: [PATCH 056/101] confirm backup and delete all backups of the job
---
app/Livewire/Project/Database/BackupEdit.php | 42 ++++++++++++++++++-
.../project/database/backup-edit.blade.php | 17 +++++---
2 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/app/Livewire/Project/Database/BackupEdit.php b/app/Livewire/Project/Database/BackupEdit.php
index 59f2f9a39..35ca2c7ec 100644
--- a/app/Livewire/Project/Database/BackupEdit.php
+++ b/app/Livewire/Project/Database/BackupEdit.php
@@ -5,6 +5,8 @@ namespace App\Livewire\Project\Database;
use App\Models\ScheduledDatabaseBackup;
use Livewire\Component;
use Spatie\Url\Url;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;
class BackupEdit extends Component
{
@@ -12,6 +14,8 @@ class BackupEdit extends Component
public $s3s;
+ public bool $delete_associated_backups = false;
+
public ?string $status = null;
public array $parameters;
@@ -46,16 +50,26 @@ class BackupEdit extends Component
}
}
- public function delete()
+ public function delete($password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
+
try {
+ if ($this->delete_associated_backups) {
+ $this->deleteAllBackups();
+ }
+
$this->backup->delete();
+
if ($this->backup->database->getMorphClass() === 'App\Models\ServiceDatabase') {
$previousUrl = url()->previous();
$url = Url::fromString($previousUrl);
$url = $url->withoutQueryParameter('selectedBackupId');
$url = $url->withFragment('backups');
- $url = $url->getPath()."#{$url->getFragment()}";
+ $url = $url->getPath() . "#{$url->getFragment()}";
return redirect($url);
} else {
@@ -104,4 +118,28 @@ class BackupEdit extends Component
$this->dispatch('error', $e->getMessage());
}
}
+
+ public function deleteAllBackups()
+ {
+ $executions = $this->backup->executions;
+
+ foreach ($executions as $execution) {
+ if ($this->backup->database->getMorphClass() === 'App\Models\ServiceDatabase') {
+ delete_backup_locally($execution->filename, $this->backup->database->service->destination->server);
+ } else {
+ delete_backup_locally($execution->filename, $this->backup->database->destination->server);
+ }
+ $execution->delete();
+ }
+ }
+
+ public function render()
+ {
+ //Add delete backup form S3 storage and delete backup for SFTP... when it is implemented
+ return view('livewire.project.database.backup-edit', [
+ 'checkboxes' => [
+ ['id' => 'delete_associated_backups', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from local storage.']
+ ]
+ ]);
+ }
}
diff --git a/resources/views/livewire/project/database/backup-edit.blade.php b/resources/views/livewire/project/database/backup-edit.blade.php
index 462d696fa..a737ec091 100644
--- a/resources/views/livewire/project/database/backup-edit.blade.php
+++ b/resources/views/livewire/project/database/backup-edit.blade.php
@@ -8,12 +8,17 @@
@endif
@if ($backup->database_id !== 0)
-
-
- Delete
-
- This will stop the scheduled backup for this database. Please think again.
-
+
@endif
From d2a0621f93b245aa2a3de3755c07a4679507ab9d Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 18:38:57 +0200
Subject: [PATCH 057/101] delete backup folder if empty
---
app/Livewire/Project/Database/BackupEdit.php | 35 +++++++++++++++++---
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/app/Livewire/Project/Database/BackupEdit.php b/app/Livewire/Project/Database/BackupEdit.php
index 35ca2c7ec..9ef6cb9ed 100644
--- a/app/Livewire/Project/Database/BackupEdit.php
+++ b/app/Livewire/Project/Database/BackupEdit.php
@@ -59,7 +59,7 @@ class BackupEdit extends Component
try {
if ($this->delete_associated_backups) {
- $this->deleteAllBackups();
+ $this->deleteAssociatedBackups();
}
$this->backup->delete();
@@ -119,18 +119,45 @@ class BackupEdit extends Component
}
}
- public function deleteAllBackups()
+ public function deleteAssociatedBackups()
{
$executions = $this->backup->executions;
+ $backupFolder = null;
foreach ($executions as $execution) {
if ($this->backup->database->getMorphClass() === 'App\Models\ServiceDatabase') {
- delete_backup_locally($execution->filename, $this->backup->database->service->destination->server);
+ $server = $this->backup->database->service->destination->server;
} else {
- delete_backup_locally($execution->filename, $this->backup->database->destination->server);
+ $server = $this->backup->database->destination->server;
}
+
+ if (!$backupFolder) {
+ $backupFolder = dirname($execution->filename);
+ }
+
+ delete_backup_locally($execution->filename, $server);
$execution->delete();
}
+
+ if ($backupFolder) {
+ $this->deleteEmptyBackupFolder($backupFolder, $server);
+ }
+ }
+
+ private function deleteEmptyBackupFolder($folderPath, $server)
+ {
+ $checkEmpty = instant_remote_process(["[ -z \"$(ls -A '$folderPath')\" ] && echo 'empty' || echo 'not empty'"], $server);
+
+ if (trim($checkEmpty) === 'empty') {
+ instant_remote_process(["rmdir '$folderPath'"], $server);
+
+ $parentFolder = dirname($folderPath);
+ $checkParentEmpty = instant_remote_process(["[ -z \"$(ls -A '$parentFolder')\" ] && echo 'empty' || echo 'not empty'"], $server);
+
+ if (trim($checkParentEmpty) === 'empty') {
+ instant_remote_process(["rmdir '$parentFolder'"], $server);
+ }
+ }
}
public function render()
From f8226cf892f47a7ed72554a4240a3488c1be523a Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 19:31:01 +0200
Subject: [PATCH 058/101] confirm backup deletion
---
.../Project/Database/BackupExecutions.php | 43 ++++++++++++++++---
.../database/backup-executions.blade.php | 21 ++++++---
2 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/app/Livewire/Project/Database/BackupExecutions.php b/app/Livewire/Project/Database/BackupExecutions.php
index de1bac36f..b6827895f 100644
--- a/app/Livewire/Project/Database/BackupExecutions.php
+++ b/app/Livewire/Project/Database/BackupExecutions.php
@@ -4,6 +4,9 @@ namespace App\Livewire\Project\Database;
use App\Models\ScheduledDatabaseBackup;
use Livewire\Component;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;
+use Livewire\Attributes\On;
class BackupExecutions extends Component
{
@@ -13,9 +16,12 @@ class BackupExecutions extends Component
public $setDeletableBackup;
+ public $delete_backup_s3 = true;
+ public $delete_backup_sftp = true;
+
public function getListeners()
{
- $userId = auth()->user()->id;
+ $userId = Auth::id();
return [
"echo-private:team.{$userId},BackupCreated" => 'refreshBackupExecutions',
@@ -32,19 +38,34 @@ class BackupExecutions extends Component
}
}
- public function deleteBackup($exeuctionId)
+ #[On('deleteBackup')]
+ public function deleteBackup($executionId, $password)
{
- $execution = $this->backup->executions()->where('id', $exeuctionId)->first();
- if (is_null($execution)) {
- $this->dispatch('error', 'Backup execution not found.');
-
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
return;
}
+
+ $execution = $this->backup->executions()->where('id', $executionId)->first();
+ if (is_null($execution)) {
+ $this->dispatch('error', 'Backup execution not found.');
+ return;
+ }
+
if ($execution->scheduledDatabaseBackup->database->getMorphClass() === 'App\Models\ServiceDatabase') {
delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->service->destination->server);
} else {
delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->destination->server);
}
+
+ if ($this->delete_backup_s3) {
+ // Add logic to delete from S3
+ }
+
+ if ($this->delete_backup_sftp) {
+ // Add logic to delete from SFTP
+ }
+
$execution->delete();
$this->dispatch('success', 'Backup deleted.');
$this->refreshBackupExecutions();
@@ -61,4 +82,14 @@ class BackupExecutions extends Component
$this->executions = $this->backup->executions()->get()->sortBy('created_at');
}
}
+
+ public function render()
+ {
+ return view('livewire.project.database.backup-executions', [
+ 'checkboxes' => [
+ ['id' => 'delete_backup_s3', 'label' => 'Delete the selected backup permanently form S3 Storage'],
+ ['id' => 'delete_backup_sftp', 'label' => 'Delete the selected backup permanently form SFTP Storage'],
+ ]
+ ]);
+ }
}
diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.php
index 644ac9fa4..978198b72 100644
--- a/resources/views/livewire/project/database/backup-executions.blade.php
+++ b/resources/views/livewire/project/database/backup-executions.blade.php
@@ -34,12 +34,21 @@
Download
@endif
-
-
- Delete
-
- This will delete this backup. It is not reversible. Please think again.
-
+
From f857bbc437179006dcf5ca15e8cab0de8c83194d Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 19:31:23 +0200
Subject: [PATCH 059/101] fix submit action
---
.../views/components/modal-confirmation.blade.php | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 060e627c6..49ce0212e 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -59,7 +59,15 @@
return;
}
}
- $wire.call(this.submitAction, this.password, this.selectedActions)
+
+ const methodName = this.submitAction.split('(')[0];
+ const paramsMatch = this.submitAction.match(/\((.*?)\)/);
+ const params = paramsMatch ? paramsMatch[1].split(',').map(param => param.trim()) : [];
+
+ params.push(this.password);
+ params.push(this.selectedActions);
+
+ $wire[methodName](...params)
.then(result => {
if (result === true) {
this.modalOpen = false;
From 776d41613d579ae861bde95154bf381495237d43 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 20:55:43 +0200
Subject: [PATCH 060/101] Fix 3 risk levels
---
.../components/modal-confirmation.blade.php | 21 ++++++++++++-------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 49ce0212e..9e3abac31 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -21,9 +21,9 @@
+
Warning
This operation is not reversible. Please proceed with caution.
@@ -269,17 +269,22 @@
-
-
+
+
-
+
From a97ccd206c2d66f73e605d533ed1998f8b5d00cf Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 20:55:56 +0200
Subject: [PATCH 061/101] confirm init script
---
.../project/database/init-script.blade.php | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/resources/views/livewire/project/database/init-script.blade.php b/resources/views/livewire/project/database/init-script.blade.php
index f3f699791..41584c633 100644
--- a/resources/views/livewire/project/database/init-script.blade.php
+++ b/resources/views/livewire/project/database/init-script.blade.php
@@ -2,9 +2,20 @@
Save
-
- This script will be deleted. It is not reversible. Please think again.
-
+
From 843e3fb59927621eeaaac76c8b64baa3a9f25833 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Sat, 31 Aug 2024 21:10:44 +0200
Subject: [PATCH 062/101] fix checkboxes in danger
---
resources/views/livewire/project/shared/danger.blade.php | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index a2b0d0a93..de7148ee3 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -10,12 +10,7 @@
type="button"
submitAction="delete"
buttonTitle="Delete Resource"
- :checkboxes="[
- ['id' => 'delete_volumes', 'model' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
- ['id' => 'delete_connected_networks', 'model' => 'delete_connected_networks', 'label' => 'All connected networks with this resource will be permanently deleted (predefined networks will not be deleted)'],
- ['id' => 'delete_configurations', 'model' => 'delete_configurations', 'label' => 'All configuration files will be permanently deleted form the server'],
- ['id' => 'docker_cleanup', 'model' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images']
- ]"
+ :checkboxes="$checkboxes"
:actions="[
'All containers of this resource will be stopped and permanently deleted.'
]"
From dfd218ec064790d214bc57d3d9b3840f35b6a379 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 19:27:21 +0200
Subject: [PATCH 063/101] fixes here and there
---
app/Livewire/Destination/Form.php | 11 +---
app/Livewire/Project/Database/BackupEdit.php | 28 ++++++++--
app/Livewire/Project/DeleteEnvironment.php | 8 +--
app/Livewire/Project/DeleteProject.php | 8 +--
.../components/modal-confirmation.blade.php | 55 +++++++------------
resources/views/livewire/dashboard.blade.php | 7 +--
.../views/livewire/destination/form.blade.php | 5 +-
.../project/database/backup-edit.blade.php | 4 +-
.../database/backup-executions.blade.php | 1 -
.../project/delete-environment.blade.php | 4 +-
.../livewire/project/delete-project.blade.php | 6 +-
11 files changed, 58 insertions(+), 79 deletions(-)
diff --git a/app/Livewire/Destination/Form.php b/app/Livewire/Destination/Form.php
index f58538dc1..5b3115dea 100644
--- a/app/Livewire/Destination/Form.php
+++ b/app/Livewire/Destination/Form.php
@@ -1,8 +1,6 @@
destination->save();
}
- public function delete($password)
+ public function delete()
{
- if (!Hash::check($password, Auth::user()->password)) {
- $this->addError('password', 'The provided password is incorrect.');
- return;
- }
-
try {
if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') {
if ($this->destination->attachedTo()) {
@@ -44,7 +37,7 @@ class Form extends Component
}
$this->destination->delete();
- return redirect()->route('dashboard');
+ return redirect()->route('destination.all');
} catch (\Throwable $e) {
return handleError($e, $this);
}
diff --git a/app/Livewire/Project/Database/BackupEdit.php b/app/Livewire/Project/Database/BackupEdit.php
index 9ef6cb9ed..9efb2d9fc 100644
--- a/app/Livewire/Project/Database/BackupEdit.php
+++ b/app/Livewire/Project/Database/BackupEdit.php
@@ -14,7 +14,9 @@ class BackupEdit extends Component
public $s3s;
- public bool $delete_associated_backups = false;
+ public bool $delete_associated_backups_locally = false;
+ public bool $delete_associated_backups_s3 = false;
+ public bool $delete_associated_backups_sftp = false;
public ?string $status = null;
@@ -58,8 +60,11 @@ class BackupEdit extends Component
}
try {
- if ($this->delete_associated_backups) {
- $this->deleteAssociatedBackups();
+ if ($this->delete_associated_backups_locally) {
+ $this->deleteAssociatedBackupsLocally();
+ }
+ if ($this->delete_associated_backups_s3) {
+ $this->deleteAssociatedBackupsS3();
}
$this->backup->delete();
@@ -119,7 +124,7 @@ class BackupEdit extends Component
}
}
- public function deleteAssociatedBackups()
+ public function deleteAssociatedBackupsLocally()
{
$executions = $this->backup->executions;
$backupFolder = null;
@@ -144,6 +149,16 @@ class BackupEdit extends Component
}
}
+ public function deleteAssociatedBackupsS3()
+ {
+ //Add function to delete backups from S3
+ }
+
+ public function deleteAssociatedBackupsSftp()
+ {
+ //Add function to delete backups from SFTP
+ }
+
private function deleteEmptyBackupFolder($folderPath, $server)
{
$checkEmpty = instant_remote_process(["[ -z \"$(ls -A '$folderPath')\" ] && echo 'empty' || echo 'not empty'"], $server);
@@ -162,10 +177,11 @@ class BackupEdit extends Component
public function render()
{
- //Add delete backup form S3 storage and delete backup for SFTP... when it is implemented
return view('livewire.project.database.backup-edit', [
'checkboxes' => [
- ['id' => 'delete_associated_backups', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from local storage.']
+ ['id' => 'delete_associated_backups_locally', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from local storage.'],
+ // ['id' => 'delete_associated_backups_s3', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from the selected S3 Storage.']
+ // ['id' => 'delete_associated_backups_sftp', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from the selected SFTP Storage.']
]
]);
}
diff --git a/app/Livewire/Project/DeleteEnvironment.php b/app/Livewire/Project/DeleteEnvironment.php
index 7c60c6404..e01741770 100644
--- a/app/Livewire/Project/DeleteEnvironment.php
+++ b/app/Livewire/Project/DeleteEnvironment.php
@@ -3,8 +3,6 @@
namespace App\Livewire\Project;
use App\Models\Environment;
-use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\Hash;
use Livewire\Component;
class DeleteEnvironment extends Component
@@ -23,12 +21,8 @@ class DeleteEnvironment extends Component
$this->environmentName = Environment::findOrFail($this->environment_id)->name;
}
- public function delete($password)
+ public function delete()
{
- if (!Hash::check($password, Auth::user()->password)) {
- $this->addError('password', 'The provided password is incorrect.');
- return;
- }
$this->validate([
'environment_id' => 'required|int',
]);
diff --git a/app/Livewire/Project/DeleteProject.php b/app/Livewire/Project/DeleteProject.php
index 75060f8f3..360fad10a 100644
--- a/app/Livewire/Project/DeleteProject.php
+++ b/app/Livewire/Project/DeleteProject.php
@@ -3,8 +3,6 @@
namespace App\Livewire\Project;
use App\Models\Project;
-use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\Hash;
use Livewire\Component;
class DeleteProject extends Component
@@ -23,12 +21,8 @@ class DeleteProject extends Component
$this->projectName = Project::findOrFail($this->project_id)->name;
}
- public function delete($password)
+ public function delete()
{
- if (!Hash::check($password, Auth::user()->password)) {
- $this->addError('password', 'The provided password is incorrect.');
- return;
- }
$this->validate([
'project_id' => 'required|int',
]);
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 9e3abac31..a726406cd 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -64,7 +64,9 @@
const paramsMatch = this.submitAction.match(/\((.*?)\)/);
const params = paramsMatch ? paramsMatch[1].split(',').map(param => param.trim()) : [];
- params.push(this.password);
+ if (this.confirmWithPassword) {
+ params.push(this.password);
+ }
params.push(this.selectedActions);
$wire[methodName](...params)
@@ -162,14 +164,7 @@
Select the actions you want to perform:
@foreach($checkboxes as $index => $checkbox)
-
+
@endforeach
@endif
@@ -183,22 +178,22 @@
The following actions will be performed:
@foreach($actions as $action)
+
+
+
+
+ {{ $action }}
+
+ @endforeach
+ @foreach($checkboxes as $checkbox)
+
- {{ $action }}
+ {{ $checkbox['label'] }}
- @endforeach
- @foreach($checkboxes as $checkbox)
-
-
-
-
-
- {{ $checkbox['label'] }}
-
-
+
@endforeach
@if($confirmWithText)
@@ -244,7 +239,7 @@
@error('password')
-
{{ $message }}
+
{{ $message }}
@enderror
@@ -263,29 +258,19 @@
-
+
-
-
+
+
-
+
diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php
index e4c0c3ad2..c1a8cad01 100644
--- a/resources/views/livewire/dashboard.blade.php
+++ b/resources/views/livewire/dashboard.blade.php
@@ -123,15 +123,14 @@
@endif
diff --git a/resources/views/livewire/destination/form.blade.php b/resources/views/livewire/destination/form.blade.php
index 06ca4eb13..d6894060b 100644
--- a/resources/views/livewire/destination/form.blade.php
+++ b/resources/views/livewire/destination/form.blade.php
@@ -15,9 +15,8 @@
confirmationText="{{ $destination->name }}"
confirmationLabel="Please confirm the execution of the actions by entering the Destination Name below"
shortConfirmationLabel="Destination Name"
- buttonTitle="Delete Destination"
- step3ButtonText="Permanently Delete Destination"
- :confirmWithPassword="true"
+ :confirmWithPassword="false"
+ step2ButtonText="Permanently Delete Destination"
/>
@endif
diff --git a/resources/views/livewire/project/database/backup-edit.blade.php b/resources/views/livewire/project/database/backup-edit.blade.php
index a737ec091..81ecbbe74 100644
--- a/resources/views/livewire/project/database/backup-edit.blade.php
+++ b/resources/views/livewire/project/database/backup-edit.blade.php
@@ -10,14 +10,14 @@
@if ($backup->database_id !== 0)
@endif
diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.php
index 978198b72..d7f74664f 100644
--- a/resources/views/livewire/project/database/backup-executions.blade.php
+++ b/resources/views/livewire/project/database/backup-executions.blade.php
@@ -38,7 +38,6 @@
title="Confirm Backup Deletion?"
buttonTitle="Delete"
isErrorButton
- type="button"
submitAction="deleteBackup({{ data_get($execution, 'id') }})"
{{-- :checkboxes="$checkboxes" --}}
:actions="[
diff --git a/resources/views/livewire/project/delete-environment.blade.php b/resources/views/livewire/project/delete-environment.blade.php
index d405d66c1..f932ae4f7 100644
--- a/resources/views/livewire/project/delete-environment.blade.php
+++ b/resources/views/livewire/project/delete-environment.blade.php
@@ -6,7 +6,7 @@
:actions="['This will delete the selected environment.']"
confirmationLabel="Please confirm the execution of the actions by entering the Environment Name below"
shortConfirmationLabel="Environment Name"
- buttonTitle="Delete Environment"
confirmationText="{{ $environmentName }}"
- step3ButtonText="Permanently Delete Environment"
+ :confirmWithPassword="false"
+ step2ButtonText="Permanently Delete Environment"
/>
diff --git a/resources/views/livewire/project/delete-project.blade.php b/resources/views/livewire/project/delete-project.blade.php
index 990caaf92..8ce822145 100644
--- a/resources/views/livewire/project/delete-project.blade.php
+++ b/resources/views/livewire/project/delete-project.blade.php
@@ -3,10 +3,10 @@
buttonTitle="Delete Project"
isErrorButton
submitAction="delete"
- :actions="['This will delete the selected project.']"
+ :actions="['This will delete the selected project', 'All Environments inside the project will be deleted as well.']"
confirmationLabel="Please confirm the execution of the actions by entering the Project Name below"
shortConfirmationLabel="Project Name"
- buttonTitle="Delete Project"
confirmationText="{{ $projectName }}"
- step3ButtonText="Permanently Delete Project"
+ :confirmWithPassword="false"
+ step2ButtonText="Permanently Delete Project"
/>
From 1b0c5f8d6983d98e09dbd26715d745abdbec2f6c Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 19:49:57 +0200
Subject: [PATCH 064/101] css fix for long text
---
.../components/modal-confirmation.blade.php | 21 ++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index a726406cd..729541c0e 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -147,11 +147,18 @@
-
+
-
{{ $title }}
-
-
+ {{ $title }}
+
+
@@ -179,7 +186,7 @@
@foreach($actions as $action)
-
+
{{ $action }}
@@ -188,7 +195,7 @@
@foreach($checkboxes as $checkbox)
-
+
{{ $checkbox['label'] }}
@@ -245,7 +252,7 @@
-
+
Back
From 5944ee55248d204394e403a3bb053b63045d4d99 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 21:22:31 +0200
Subject: [PATCH 065/101] fix close modal on submit
---
resources/views/components/modal-confirmation.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 729541c0e..c2f3f19a9 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -271,13 +271,13 @@
-
+
-
+
From a4d1ae1341b7463ee1395c87f95d7d2273c24b36 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 21:54:21 +0200
Subject: [PATCH 066/101] Feat: ability to hide labels
---
.../views/components/forms/checkbox.blade.php | 12 ++++++++++++
.../views/components/modal-confirmation.blade.php | 15 ++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/resources/views/components/forms/checkbox.blade.php b/resources/views/components/forms/checkbox.blade.php
index f3e3d5c9e..11e913845 100644
--- a/resources/views/components/forms/checkbox.blade.php
+++ b/resources/views/components/forms/checkbox.blade.php
@@ -1,4 +1,15 @@
+@props([
+ 'id',
+ 'label' => null,
+ 'helper' => null,
+ 'disabled' => false,
+ 'instantSave' => false,
+ 'value' => null,
+ 'hideLabel' => false,
+])
+
@foreach($checkboxes as $index => $checkbox)
-
+
+
+ {{ $checkbox['label'] }}
+
+
+
@endforeach
@endif
From ff1e08cf8bd9f68a64e1e6604932bdbc4c94d5e7 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 23:25:18 +0200
Subject: [PATCH 067/101] add toast dispatching
---
app/Livewire/Dashboard.php | 1 -
.../components/modal-confirmation.blade.php | 45 ++++++++++---------
resources/views/livewire/dashboard.blade.php | 10 ++---
3 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/app/Livewire/Dashboard.php b/app/Livewire/Dashboard.php
index 1fe8b496d..215d3b16c 100644
--- a/app/Livewire/Dashboard.php
+++ b/app/Livewire/Dashboard.php
@@ -33,7 +33,6 @@ class Dashboard extends Component
Artisan::queue('cleanup:application-deployment-queue', [
'--team-id' => currentTeam()->id,
]);
- return redirect()->route('dashboard')->with('success', 'Cleanup started.');
}
public function get_deployments()
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 72cf70758..ccf4fa07c 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -17,6 +17,9 @@
'step1ButtonText' => 'Continue Deletion',
'step2ButtonText' => 'Delete Permanently',
'step3ButtonText' => 'Confirm Permanent Deletion',
+'dispatchEvent' => false,
+'dispatchEventType' => 'success',
+'dispatchEventMessage' => '',
])
-
+
{{ $title }}
@@ -175,15 +174,7 @@
{{ $checkbox['label'] }}
-
+
@endforeach
@@ -284,13 +275,27 @@
-
+ {
+ if (dispatchEvent) {
+ $wire.dispatch(dispatchEventType, dispatchEventMessage);
+ }
+ modalOpen = false;
+ resetModal();
+ })">
-
+ {
+ if (dispatchEvent) {
+ $wire.dispatch(dispatchEventType, dispatchEventMessage);
+ }
+ modalOpen = false;
+ resetModal();
+ })">
diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php
index c1a8cad01..89ef7b2fd 100644
--- a/resources/views/livewire/dashboard.blade.php
+++ b/resources/views/livewire/dashboard.blade.php
@@ -131,15 +131,11 @@
:confirmWithText="false"
:confirmWithPassword="false"
step2ButtonText="Permanently Cleanup Deployment Queues"
+ :dispatchEvent="true"
+ dispatchEventType="success"
+ dispatchEventMessage="Deployment Queues cleanup started."
/>
-
- @if (session('success'))
-
- {{ session('success') }}
-
- @endif
-
@forelse ($deployments_per_server as $server_name => $deployments)
{{ $server_name }}
From 70043c24cfd4e915259127fe82efc2584f9a0635 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 23:30:47 +0200
Subject: [PATCH 068/101] 100000000x Speed improvement first toast then submit
in the background
---
.../components/modal-confirmation.blade.php | 26 +++++++++----------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index ccf4fa07c..8e2b06b45 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -276,26 +276,24 @@
{
- if (dispatchEvent) {
- $wire.dispatch(dispatchEventType, dispatchEventMessage);
- }
- modalOpen = false;
- resetModal();
- })">
+ if (dispatchEvent) {
+ $wire.dispatch(dispatchEventType, dispatchEventMessage);
+ }
+ modalOpen = false;
+ resetModal();
+ confirmWithPassword ? step++ : submitForm()">
{
- if (dispatchEvent) {
- $wire.dispatch(dispatchEventType, dispatchEventMessage);
- }
- modalOpen = false;
- resetModal();
- })">
+ if (dispatchEvent) {
+ $wire.dispatch(dispatchEventType, dispatchEventMessage);
+ }
+ modalOpen = false;
+ resetModal();
+ submitForm()">
From c24fec9c453c58c69f8e5c390b188fc09ce126df Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 23:48:05 +0200
Subject: [PATCH 069/101] fix step and password error
---
.../components/modal-confirmation.blade.php | 29 ++++++++++++-------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 8e2b06b45..edbb949ba 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -62,7 +62,7 @@
if (this.confirmWithPassword) {
this.passwordError = this.validatePassword();
if (this.passwordError) {
- return;
+ return Promise.resolve(this.passwordError);
}
}
@@ -78,10 +78,9 @@
return $wire[methodName](...params)
.then(result => {
if (result === true) {
- this.modalOpen = false;
- this.resetModal();
+ return true;
} else if (typeof result === 'string') {
- this.passwordError = result;
+ return result;
}
});
},
@@ -279,9 +278,13 @@
if (dispatchEvent) {
$wire.dispatch(dispatchEventType, dispatchEventMessage);
}
- modalOpen = false;
- resetModal();
- confirmWithPassword ? step++ : submitForm()">
+ if (confirmWithPassword) {
+ step++;
+ } else {
+ modalOpen = false;
+ resetModal();
+ submitForm();
+ }">
@@ -291,9 +294,15 @@
if (dispatchEvent) {
$wire.dispatch(dispatchEventType, dispatchEventMessage);
}
- modalOpen = false;
- resetModal();
- submitForm()">
+ submitForm().then((result) => {
+ if (result === true) {
+ modalOpen = false;
+ resetModal();
+ } else {
+ passwordError = result;
+ }
+ });
+ ">
From c3188958b453e7c5ff0a61cff91c49f139e923eb Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 23:54:16 +0200
Subject: [PATCH 070/101] Feat: DB start, stop confirm
---
.../project/database/heading.blade.php | 28 +++++++++++++++----
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.php
index 73824421d..594bc12d3 100644
--- a/resources/views/livewire/project/database/heading.blade.php
+++ b/resources/views/livewire/project/database/heading.blade.php
@@ -29,7 +29,17 @@
@if (!str($database->status)->startsWith('exited'))
-
+
@@ -39,9 +49,18 @@
Restart
- This database will be restarted. Please think again.
-
+
@@ -52,9 +71,6 @@
Stop
- This database will be stopped.
- And all none persitant data will be deleted (Containers, Networks, Unused Images).
- Please think again.
@else
From 3d1c73070336ed82dcdbb8a91f262bebf79eb813 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Mon, 2 Sep 2024 23:58:48 +0200
Subject: [PATCH 071/101] Feat: del init script
---
.../views/livewire/project/database/init-script.blade.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/resources/views/livewire/project/database/init-script.blade.php b/resources/views/livewire/project/database/init-script.blade.php
index 41584c633..e72b13fa9 100644
--- a/resources/views/livewire/project/database/init-script.blade.php
+++ b/resources/views/livewire/project/database/init-script.blade.php
@@ -2,13 +2,14 @@
Save
-
Date: Tue, 3 Sep 2024 00:01:24 +0200
Subject: [PATCH 072/101] made wording more clear
---
resources/views/components/modal-confirmation.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index edbb949ba..179651463 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -183,7 +183,7 @@
Warning
-
This operation is not reversible. Please proceed with caution.
+
This operation is permanent and cannot be undone. Please think again before proceeding!
The following actions will be performed:
From 20558d438aad42135f2d073c4ec9caddfbd1a4ef Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 3 Sep 2024 00:30:15 +0200
Subject: [PATCH 073/101] remove ray
---
app/Livewire/Project/Shared/Danger.php | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index d0f05d0ec..862061640 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -31,8 +31,6 @@ class Danger extends Component
$this->projectUuid = data_get($parameters, 'project_uuid');
$this->environmentName = data_get($parameters, 'environment_name');
- ray('Mount method called');
-
if ($this->resource === null) {
if (isset($parameters['service_uuid'])) {
$this->resource = Service::where('uuid', $parameters['service_uuid'])->first();
@@ -42,22 +40,16 @@ class Danger extends Component
}
}
- ray('Resource:', $this->resource);
-
if ($this->resource === null) {
- ray('Resource is null');
$this->resourceName = 'Unknown Resource';
return;
}
if (!method_exists($this->resource, 'type')) {
- ray('Resource does not have type() method');
$this->resourceName = 'Unknown Resource';
return;
}
- ray('Resource type:', $this->resource->type());
-
switch ($this->resource->type()) {
case 'application':
$this->resourceName = $this->resource->name ?? 'Application';
@@ -84,8 +76,6 @@ class Danger extends Component
default:
$this->resourceName = 'Unknown Resource';
}
-
- ray('Final resource name:', $this->resourceName);
}
public function delete($password)
From 3d21f1a2a4da92016e619f6845a98f2c37ba1c8f Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 3 Sep 2024 14:59:01 +0200
Subject: [PATCH 074/101] fix checkbox hide label
---
resources/views/components/forms/checkbox.blade.php | 2 +-
resources/views/components/modal-confirmation.blade.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/components/forms/checkbox.blade.php b/resources/views/components/forms/checkbox.blade.php
index 11e913845..84c6b7e32 100644
--- a/resources/views/components/forms/checkbox.blade.php
+++ b/resources/views/components/forms/checkbox.blade.php
@@ -9,7 +9,7 @@
])
- @if($hideLabel)
+ @if(!$hideLabel)
@if ($label)
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index 179651463..e31284e7c 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -173,7 +173,7 @@
{{ $checkbox['label'] }}
-
+
@endforeach
From f29bc52fa554f161a9a5a5b845a9736633d62150 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 3 Sep 2024 15:59:30 +0200
Subject: [PATCH 075/101] Feat: general confirm
---
.../project/application/general.blade.php | 31 ++++++++++++++-----
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php
index 389c9b000..e21f2a38a 100644
--- a/resources/views/livewire/project/application/general.blade.php
+++ b/resources/views/livewire/project/application/general.blade.php
@@ -68,11 +68,20 @@
Redirect to www.
Redirect to non-www.
-
+
Set Direction
- This will reset the container labels. Are you sure?
@endif
@@ -297,12 +306,18 @@
helper="If you know what are you doing, you can enable this to edit the labels directly. Coolify won't update labels automatically. Be careful, it could break the proxy configuration after you restart the container."
id="application.settings.is_container_label_readonly_enabled" instantSave>
-
- Are you sure you want to reset the labels to Coolify generated labels? It could break the proxy
- configuration after you restart the container.
-
-
+
@endif
Pre/Post Deployment Commands
From d5b7e9ed830fc27b86e6dccffa2bebf7ed1092b0 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 3 Sep 2024 16:43:50 +0200
Subject: [PATCH 076/101] Feat: preview deployments and typos
---
.../project/application/previews.blade.php | 33 ++++++++++++++-----
.../project/database/heading.blade.php | 2 +-
.../project/database/init-script.blade.php | 2 +-
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/resources/views/livewire/project/application/previews.blade.php b/resources/views/livewire/project/application/previews.blade.php
index e15aa7816..efd281a77 100644
--- a/resources/views/livewire/project/application/previews.blade.php
+++ b/resources/views/livewire/project/application/previews.blade.php
@@ -152,8 +152,17 @@
@endif
@if (data_get($preview, 'status') !== 'exited')
-
+
Stop
- This will stop the preview deployment. Please think again.
@endif
-
- This will delete the preview deployment. Please think again.
-
-
+
@endforeach
diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.php
index 594bc12d3..a9e208856 100644
--- a/resources/views/livewire/project/database/heading.blade.php
+++ b/resources/views/livewire/project/database/heading.blade.php
@@ -33,7 +33,7 @@
title="Confirm Database Restart?"
buttonTitle="Restart"
submitAction="restart"
- :actions="['This database will be restarted.', 'If the database is currently in active use data could be lost.']"
+ :actions="['This database will be restarted.', 'If the database is currently in use data could be lost.']"
:confirmWithText="false"
:confirmWithPassword="false"
step2ButtonText="Restart Database"
diff --git a/resources/views/livewire/project/database/init-script.blade.php b/resources/views/livewire/project/database/init-script.blade.php
index e72b13fa9..fc1f88196 100644
--- a/resources/views/livewire/project/database/init-script.blade.php
+++ b/resources/views/livewire/project/database/init-script.blade.php
@@ -9,7 +9,7 @@
submitAction="delete"
:actions="[
'The init-script of this database will be permanently deleted.',
- 'If you are actively using this init-script, it could cause errors on redeployments.'
+ 'If you are actively using this init-script, it could cause errors on redeployment.'
]"
confirmationText="{{ $filename }}"
confirmationLabel="Please confirm the execution of the actions by entering the init-script name below"
From d94e39ccc773fe92c74575ba9aabcf72589df4e0 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 3 Sep 2024 16:59:51 +0200
Subject: [PATCH 077/101] Feat: service confirmation
---
.../Project/Service/Configuration.php | 4 +--
.../project/database/heading.blade.php | 2 +-
.../project/service/configuration.blade.php | 28 ++++++++++++-------
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/app/Livewire/Project/Service/Configuration.php b/app/Livewire/Project/Service/Configuration.php
index c82012aaa..a55af5777 100644
--- a/app/Livewire/Project/Service/Configuration.php
+++ b/app/Livewire/Project/Service/Configuration.php
@@ -51,7 +51,7 @@ class Configuration extends Component
$application = $this->service->applications->find($id);
if ($application) {
$application->restart();
- $this->dispatch('success', 'Application restarted successfully.');
+ $this->dispatch('success', 'Service application restarted successfully.');
}
} catch (\Exception $e) {
return handleError($e, $this);
@@ -64,7 +64,7 @@ class Configuration extends Component
$database = $this->service->databases->find($id);
if ($database) {
$database->restart();
- $this->dispatch('success', 'Database restarted successfully.');
+ $this->dispatch('success', 'Service database restarted successfully.');
}
} catch (\Exception $e) {
return handleError($e, $this);
diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.php
index a9e208856..07d52034f 100644
--- a/resources/views/livewire/project/database/heading.blade.php
+++ b/resources/views/livewire/project/database/heading.blade.php
@@ -33,7 +33,7 @@
title="Confirm Database Restart?"
buttonTitle="Restart"
submitAction="restart"
- :actions="['This database will be restarted.', 'If the database is currently in use data could be lost.']"
+ :actions="['This database will be unavailable during the restart.', 'If the database is currently in use data could be lost.']"
:confirmWithText="false"
:confirmWithPassword="false"
step2ButtonText="Restart Database"
diff --git a/resources/views/livewire/project/service/configuration.blade.php b/resources/views/livewire/project/service/configuration.blade.php
index 5c6fe87fd..89e070d6c 100644
--- a/resources/views/livewire/project/service/configuration.blade.php
+++ b/resources/views/livewire/project/service/configuration.blade.php
@@ -111,11 +111,15 @@
Settings
@if (str($application->status)->contains('running'))
-
- This application will be unavailable during the restart. Please think
- again.
-
+
@endif
@@ -155,11 +159,15 @@
Settings
@if (str($database->status)->contains('running'))
-
- This database will be unavailable during the restart. Please think
- again.
-
+
@endif
From 9a2d5be354807f227f2137383a5decefbd9364dc Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Tue, 3 Sep 2024 18:31:06 +0200
Subject: [PATCH 078/101] Feat: confirm file storage
---
app/Livewire/Project/Shared/Danger.php | 5 +-
.../project/service/file-storage.blade.php | 74 ++++++++++++-------
.../livewire/project/shared/danger.blade.php | 1 -
3 files changed, 53 insertions(+), 27 deletions(-)
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index 862061640..609d61698 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -116,7 +116,10 @@ class Danger extends Component
['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
['id' => 'delete_connected_networks', 'label' => 'All connected networks with this resource will be permanently deleted (predefined networks will not be deleted)'],
['id' => 'delete_configurations', 'label' => 'All configuration files will be permanently deleted form the server'],
- ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images']
+ ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images'],
+ // ['id' => 'delete_associated_backups_locally', 'label' => 'All backups associated with this Ressource will be permanently deleted from local storage.'],
+ // ['id' => 'delete_associated_backups_s3', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected S3 Storage.'],
+ // ['id' => 'delete_associated_backups_sftp', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected SFTP Storage.']
]
]);
}
diff --git a/resources/views/livewire/project/service/file-storage.blade.php b/resources/views/livewire/project/service/file-storage.blade.php
index 96590cada..ccb50deb4 100644
--- a/resources/views/livewire/project/service/file-storage.blade.php
+++ b/resources/views/livewire/project/service/file-storage.blade.php
@@ -13,33 +13,57 @@
@else
@if ($isDisabled)
@@ -79,10 +89,20 @@
Lock
-
- You will delete environment variable {{ $env->key }} .
-
+
@else
Update
@@ -90,10 +110,20 @@
Lock
-
- You will delete environment variable {{ $env->key }} .
-
+
@endif
@endif
From bbbd5cbaa168fc36082a6a80f3da66b5d4b82114 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 19:44:10 +0200
Subject: [PATCH 084/101] Feat: confirm scheduled tasks
---
.../shared/scheduled-task/show.blade.php | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/resources/views/livewire/project/shared/scheduled-task/show.blade.php b/resources/views/livewire/project/shared/scheduled-task/show.blade.php
index bc2ede3a3..b4845fb25 100644
--- a/resources/views/livewire/project/shared/scheduled-task/show.blade.php
+++ b/resources/views/livewire/project/shared/scheduled-task/show.blade.php
@@ -17,15 +17,16 @@
Save
From 93a4a3e09cbed313b94bb8e83fd68d4e9dd9b0e1 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 19:58:36 +0200
Subject: [PATCH 085/101] Feat: confirm API token
---
.../livewire/security/api-tokens.blade.php | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/resources/views/livewire/security/api-tokens.blade.php b/resources/views/livewire/security/api-tokens.blade.php
index 3a5d4560c..16e853c39 100644
--- a/resources/views/livewire/security/api-tokens.blade.php
+++ b/resources/views/livewire/security/api-tokens.blade.php
@@ -56,12 +56,18 @@
@endif
-
-
- Revoke token
-
- This API Token will be deleted and anything using it will fail. Please think again.
-
+
@empty
From 9515bc6162ef0cb972a8a49c601939b31196d66b Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 20:02:01 +0200
Subject: [PATCH 086/101] Feat: confirm private key
---
.../views/livewire/security/api-tokens.blade.php | 2 +-
.../livewire/security/private-key/show.blade.php | 15 ++++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/resources/views/livewire/security/api-tokens.blade.php b/resources/views/livewire/security/api-tokens.blade.php
index 16e853c39..48f68d9d7 100644
--- a/resources/views/livewire/security/api-tokens.blade.php
+++ b/resources/views/livewire/security/api-tokens.blade.php
@@ -61,7 +61,7 @@
isErrorButton
buttonTitle="Revoke token"
submitAction="revoke({{ data_get($token, 'id') }})"
- :actions="['This API Token will be revoked and deleted.', 'Any API call made with this token will fail.']"
+ :actions="['This API Token will be revoked and permanently deleted.', 'Any API call made with this token will fail.']"
confirmationText="{{ $token->name }}"
confirmationLabel="Please confirm the execution of the actions by entering the API Token Description below"
shortConfirmationLabel="API Token Description"
diff --git a/resources/views/livewire/security/private-key/show.blade.php b/resources/views/livewire/security/private-key/show.blade.php
index 97def5317..642580fba 100644
--- a/resources/views/livewire/security/private-key/show.blade.php
+++ b/resources/views/livewire/security/private-key/show.blade.php
@@ -11,9 +11,18 @@
Save
@if (data_get($private_key, 'id') > 0)
-
- This private key will be deleted. It is not reversible. Please think again.
-
+
@endif
From 371fe5391192878fb54c6b05ff4474827ee4f83f Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 20:06:22 +0200
Subject: [PATCH 087/101] Feat: confirm server deletion
---
app/Livewire/Server/Delete.php | 8 +++++-
.../views/livewire/server/delete.blade.php | 28 +++++++++++++++----
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/app/Livewire/Server/Delete.php b/app/Livewire/Server/Delete.php
index 3beec0c91..08e91a4c7 100644
--- a/app/Livewire/Server/Delete.php
+++ b/app/Livewire/Server/Delete.php
@@ -4,6 +4,8 @@ namespace App\Livewire\Server;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Component;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;
class Delete extends Component
{
@@ -11,8 +13,12 @@ class Delete extends Component
public $server;
- public function delete()
+ public function delete($password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
try {
$this->authorize('delete', $this->server);
if ($this->server->hasDefinedResources()) {
diff --git a/resources/views/livewire/server/delete.blade.php b/resources/views/livewire/server/delete.blade.php
index 4d46e1fc9..91539b197 100644
--- a/resources/views/livewire/server/delete.blade.php
+++ b/resources/views/livewire/server/delete.blade.php
@@ -8,13 +8,29 @@
@if ($server->definedResources()->count() > 0)
You need to delete all resources before deleting this server.
-
- This server will be deleted. It is not reversible. Please think again.
-
+
@else
-
- This server will be deleted. It is not reversible. Please think again.
-
+
@endif
@endif
From 505127dae5e7c0def800b0bbd0615078b0ec38dd Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 20:11:04 +0200
Subject: [PATCH 088/101] Feat: confirm server settings
---
resources/views/livewire/server/form.blade.php | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php
index 3c137df91..95fd3f255 100644
--- a/resources/views/livewire/server/form.blade.php
+++ b/resources/views/livewire/server/form.blade.php
@@ -3,11 +3,15 @@
General
@if ($server->id === 0)
-
- You could lose a lot of functionalities if you change the server details of the server where Coolify
- is
- running on. Please think again.
-
+
@else
Save
@if ($server->isFunctional())
From 3e04a7958ea16700c44081dcaccd9cff0ab443e8 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 20:41:17 +0200
Subject: [PATCH 089/101] Feat/Fix: Proxy stop and restart confirmation
---
app/Livewire/Server/Proxy/Deploy.php | 48 ++++++++++++++-----
.../livewire/server/proxy/deploy.blade.php | 28 ++++++++---
2 files changed, 58 insertions(+), 18 deletions(-)
diff --git a/app/Livewire/Server/Proxy/Deploy.php b/app/Livewire/Server/Proxy/Deploy.php
index 2279951ee..f7318c8f4 100644
--- a/app/Livewire/Server/Proxy/Deploy.php
+++ b/app/Livewire/Server/Proxy/Deploy.php
@@ -7,6 +7,8 @@ use App\Actions\Proxy\StartProxy;
use App\Events\ProxyStatusChanged;
use App\Models\Server;
use Livewire\Component;
+use Illuminate\Support\Facades\Process;
+use Illuminate\Process\InvokedProcess;
class Deploy extends Component
{
@@ -94,21 +96,43 @@ class Deploy extends Component
public function stop(bool $forceStop = true)
{
try {
- if ($this->server->isSwarm()) {
- instant_remote_process([
- 'docker service rm coolify-proxy_traefik',
- ], $this->server);
- } else {
- instant_remote_process([
- 'docker rm -f coolify-proxy',
- ], $this->server);
+ $containerName = $this->server->isSwarm() ? 'coolify-proxy_traefik' : 'coolify-proxy';
+ $timeout = 30;
+
+ $process = $this->stopContainer($containerName, $timeout);
+
+ $startTime = time();
+ while ($process->running()) {
+ if (time() - $startTime >= $timeout) {
+ $this->forceStopContainer($containerName);
+ break;
+ }
+ usleep(100000);
}
- $this->server->proxy->status = 'exited';
- $this->server->proxy->force_stop = $forceStop;
- $this->server->save();
- $this->dispatch('proxyStatusUpdated');
+
+ $this->removeContainer($containerName);
} catch (\Throwable $e) {
return handleError($e, $this);
+ } finally {
+ $this->server->proxy->force_stop = $forceStop;
+ $this->server->proxy->status = 'exited';
+ $this->server->save();
+ $this->dispatch('proxyStatusUpdated');
}
}
+
+ private function stopContainer(string $containerName, int $timeout): InvokedProcess
+ {
+ return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
+ }
+
+ private function forceStopContainer(string $containerName)
+ {
+ instant_remote_process(["docker kill $containerName"], $this->server, throwError: false);
+ }
+
+ private function removeContainer(string $containerName)
+ {
+ instant_remote_process(["docker rm -f $containerName"], $this->server, throwError: false);
+ }
}
diff --git a/resources/views/livewire/server/proxy/deploy.blade.php b/resources/views/livewire/server/proxy/deploy.blade.php
index dba4ce80c..cee78d7a0 100644
--- a/resources/views/livewire/server/proxy/deploy.blade.php
+++ b/resources/views/livewire/server/proxy/deploy.blade.php
@@ -24,7 +24,17 @@
@endif
-
+
Restart Proxy
- This proxy will be stopped and started. It is not reversible. All resources will be unavailable
- during the restart. Please think again.
-
+
Stop Proxy
- This proxy will be stopped. It is not reversible. All resources will be unavailable.
- Please think again.
@else
From 9105c1aa51dbb46299cf72bc833b3029209485c3 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 21:00:58 +0200
Subject: [PATCH 090/101] Feat: GH app deletion confirmation
---
.../livewire/source/github/change.blade.php | 45 +++++++++++++++----
1 file changed, 36 insertions(+), 9 deletions(-)
diff --git a/resources/views/livewire/source/github/change.blade.php b/resources/views/livewire/source/github/change.blade.php
index a87eec191..a20dd2b88 100644
--- a/resources/views/livewire/source/github/change.blade.php
+++ b/resources/views/livewire/source/github/change.blade.php
@@ -14,13 +14,31 @@
@endif
@if ($applications->count() > 0)
-
- This source will be deleted. It is not reversible. Please think again.
-
+
@else
-
- This source will be deleted. It is not reversible. Please think again.
-
+
@endif
@@ -160,9 +178,18 @@
GitHub App
-
- This source will be deleted. It is not reversible. Please think again.
-
+
From 44f3f6001ea9c6385736aafdf4b35bee3cb5f16c Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 21:04:43 +0200
Subject: [PATCH 091/101] Feat: Redeploy all confirmation
---
resources/views/livewire/tags/index.blade.php | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/resources/views/livewire/tags/index.blade.php b/resources/views/livewire/tags/index.blade.php
index b38ce3f95..88c47cb7d 100644
--- a/resources/views/livewire/tags/index.blade.php
+++ b/resources/views/livewire/tags/index.blade.php
@@ -20,9 +20,18 @@
-
- All resources will be redeployed.
-
+
@foreach ($applications as $application)
From f4263ee02246ca9430b59db085391d63572a1f5e Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 21:14:18 +0200
Subject: [PATCH 092/101] Feat: User deletion confirmation
---
app/Livewire/Team/AdminView.php | 8 +++++++-
resources/views/livewire/tags/show.blade.php | 15 ++++++++++++---
.../views/livewire/team/admin-view.blade.php | 19 +++++++------------
3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/app/Livewire/Team/AdminView.php b/app/Livewire/Team/AdminView.php
index 97d4fcdbf..ee5e673a5 100644
--- a/app/Livewire/Team/AdminView.php
+++ b/app/Livewire/Team/AdminView.php
@@ -5,6 +5,8 @@ namespace App\Livewire\Team;
use App\Models\Team;
use App\Models\User;
use Livewire\Component;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
class AdminView extends Component
{
@@ -73,8 +75,12 @@ class AdminView extends Component
$team->delete();
}
- public function delete($id)
+ public function delete($id, $password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
if (! auth()->user()->isInstanceAdmin()) {
return $this->dispatch('error', 'You are not authorized to delete users');
}
diff --git a/resources/views/livewire/tags/show.blade.php b/resources/views/livewire/tags/show.blade.php
index 0c6c35a16..0b743a3e5 100644
--- a/resources/views/livewire/tags/show.blade.php
+++ b/resources/views/livewire/tags/show.blade.php
@@ -24,9 +24,18 @@
-
- All resources will be redeployed.
-
+
@foreach ($applications as $application)
diff --git a/resources/views/livewire/team/admin-view.blade.php b/resources/views/livewire/team/admin-view.blade.php
index 0e9429eb4..c03789fbd 100644
--- a/resources/views/livewire/team/admin-view.blade.php
+++ b/resources/views/livewire/team/admin-view.blade.php
@@ -16,21 +16,16 @@
- This will delete all resources (application, databases, services, configurations, servers,
- private keys, tags, etc.) from Coolify and from the server (if it's reachable) .
-
- It is not reversible.
- Think twice!
-
+ step3ButtonText="Permanently Delete User"
+ />
@empty
From 2b5df8d2fdec31683b4b96280302e255a35a67c6 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 21:15:46 +0200
Subject: [PATCH 093/101] Feat: Team deletion confirmation
---
resources/views/livewire/team/index.blade.php | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/resources/views/livewire/team/index.blade.php b/resources/views/livewire/team/index.blade.php
index 40c81766c..f7a61cf21 100644
--- a/resources/views/livewire/team/index.blade.php
+++ b/resources/views/livewire/team/index.blade.php
@@ -31,9 +31,18 @@
@else
@if (currentTeam()->isEmpty())
This will delete your team. Beware! There is no coming back!
-
- This team be deleted. It is not reversible. Please think again.
-
+
@else
You need to delete the following resources to be able to delete the team:
From a7b78dcf4121ef250f635410a9f5cf5d74daeaf6 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 21:29:32 +0200
Subject: [PATCH 094/101] Feat: Backup job confirmation
---
resources/views/livewire/storage/form.blade.php | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/resources/views/livewire/storage/form.blade.php b/resources/views/livewire/storage/form.blade.php
index 1a2c99696..8ea10fba6 100644
--- a/resources/views/livewire/storage/form.blade.php
+++ b/resources/views/livewire/storage/form.blade.php
@@ -16,9 +16,18 @@
Validate Connection
-
- This storage will be deleted. It is not reversible. Your data won't be touched! Please think again.
-
+
From 08df81440878cebf1e44013490bafc14a7bb88d7 Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Wed, 4 Sep 2024 22:33:47 +0200
Subject: [PATCH 095/101] Feat: delete volume confirmation
---
app/Livewire/Project/Shared/Storages/Show.php | 10 +++++++++-
.../project/shared/storages/show.blade.php | 18 +++++++++++-------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/app/Livewire/Project/Shared/Storages/Show.php b/app/Livewire/Project/Shared/Storages/Show.php
index 08f51ce08..d350df212 100644
--- a/app/Livewire/Project/Shared/Storages/Show.php
+++ b/app/Livewire/Project/Shared/Storages/Show.php
@@ -3,6 +3,8 @@
namespace App\Livewire\Project\Shared\Storages;
use App\Models\LocalPersistentVolume;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class Show extends Component
@@ -36,8 +38,14 @@ class Show extends Component
$this->dispatch('success', 'Storage updated successfully');
}
- public function delete()
+ public function delete($password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
+
+ // Test deletion in more detail
$this->storage->delete();
$this->dispatch('refreshStorages');
}
diff --git a/resources/views/livewire/project/shared/storages/show.blade.php b/resources/views/livewire/project/shared/storages/show.blade.php
index d6ee66ab7..2e43861ab 100644
--- a/resources/views/livewire/project/shared/storages/show.blade.php
+++ b/resources/views/livewire/project/shared/storages/show.blade.php
@@ -46,13 +46,17 @@
Update
-
- This storage will be deleted {{ $storage->name }} .
- It
- is
- not
- reversible. Please think again.
-
+
@endif
From fc3c69f687c2db10386bb0e572a1e71c4d4a68ed Mon Sep 17 00:00:00 2001
From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com>
Date: Thu, 5 Sep 2024 17:54:32 +0200
Subject: [PATCH 096/101] Feat: more conformations and fixes
---
app/Actions/Service/StopService.php | 1 -
app/Jobs/DeleteResourceJob.php | 3 +
app/Livewire/NavbarDeleteTeam.php | 16 +++-
app/Livewire/Project/Application/Previews.php | 85 +++++++++++++++----
app/Livewire/Project/Service/FileStorage.php | 20 ++++-
.../Service/ServiceApplicationView.php | 33 +++++--
app/Livewire/Project/Shared/Destination.php | 9 +-
app/Livewire/Project/Shared/Storages/Show.php | 1 -
.../livewire/navbar-delete-team.blade.php | 14 ++-
.../project/application/previews.blade.php | 5 --
.../service-application-view.blade.php | 20 +++--
.../project/shared/destination.blade.php | 15 ++--
12 files changed, 174 insertions(+), 48 deletions(-)
diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php
index 6c0990331..d69898a58 100644
--- a/app/Actions/Service/StopService.php
+++ b/app/Actions/Service/StopService.php
@@ -17,7 +17,6 @@ class StopService
if (!$server->isFunctional()) {
return 'Server is not functional';
}
- ray('Stopping service: ' . $service->name);
$containersToStop = $service->getContainersToStop();
$service->stopContainers($containersToStop, $server);
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index 1ebbf4681..8f7dd806a 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -92,6 +92,9 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
throw $e;
} finally {
$this->resource->forceDelete();
+ if ($this->dockerCleanup) {
+ CleanupDocker::run($server, true);
+ }
Artisan::queue('cleanup:stucked-resources');
}
}
diff --git a/app/Livewire/NavbarDeleteTeam.php b/app/Livewire/NavbarDeleteTeam.php
index ec196c154..6b3ea3fd4 100644
--- a/app/Livewire/NavbarDeleteTeam.php
+++ b/app/Livewire/NavbarDeleteTeam.php
@@ -4,11 +4,25 @@ namespace App\Livewire;
use Illuminate\Support\Facades\DB;
use Livewire\Component;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
class NavbarDeleteTeam extends Component
{
- public function delete()
+ public $team;
+
+ public function mount()
{
+ $this->team = currentTeam()->name;
+ }
+
+ public function delete($password)
+ {
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
+
$currentTeam = currentTeam();
$currentTeam->delete();
diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php
index 30bc0a9d1..78fab7e44 100644
--- a/app/Livewire/Project/Application/Previews.php
+++ b/app/Livewire/Project/Application/Previews.php
@@ -9,6 +9,8 @@ use Illuminate\Support\Collection;
use Livewire\Component;
use Spatie\Url\Url;
use Visus\Cuid2\Cuid2;
+use Illuminate\Process\InvokedProcess;
+use Illuminate\Support\Facades\Process;
class Previews extends Component
{
@@ -177,17 +179,20 @@ class Previews extends Component
public function stop(int $pull_request_id)
{
try {
+ $server = $this->application->destination->server;
+ $timeout = 300;
+
if ($this->application->destination->server->isSwarm()) {
- instant_remote_process(["docker stack rm {$this->application->uuid}-{$pull_request_id}"], $this->application->destination->server);
+ instant_remote_process(["docker stack rm {$this->application->uuid}-{$pull_request_id}"], $server);
} else {
- $containers = getCurrentApplicationContainerStatus($this->application->destination->server, $this->application->id, $pull_request_id);
- foreach ($containers as $container) {
- $name = str_replace('/', '', $container['Names']);
- instant_remote_process(["docker rm -f $name"], $this->application->destination->server, throwError: false);
- }
+ $containers = getCurrentApplicationContainerStatus($server, $this->application->id, $pull_request_id)->toArray();
+ $this->stopContainers($containers, $server, $timeout);
}
- GetContainersStatus::dispatchSync($this->application->destination->server)->onQueue('high');
- $this->dispatch('reloadWindow');
+
+ GetContainersStatus::run($server);
+ $this->application->refresh();
+ $this->dispatch('containerStatusUpdated');
+ $this->dispatch('success', 'Preview Deployment stopped.');
} catch (\Throwable $e) {
return handleError($e, $this);
}
@@ -196,16 +201,21 @@ class Previews extends Component
public function delete(int $pull_request_id)
{
try {
+ $server = $this->application->destination->server;
+ $timeout = 300;
+
if ($this->application->destination->server->isSwarm()) {
- instant_remote_process(["docker stack rm {$this->application->uuid}-{$pull_request_id}"], $this->application->destination->server);
+ instant_remote_process(["docker stack rm {$this->application->uuid}-{$pull_request_id}"], $server);
} else {
- $containers = getCurrentApplicationContainerStatus($this->application->destination->server, $this->application->id, $pull_request_id);
- foreach ($containers as $container) {
- $name = str_replace('/', '', $container['Names']);
- instant_remote_process(["docker rm -f $name"], $this->application->destination->server, throwError: false);
- }
+ $containers = getCurrentApplicationContainerStatus($server, $this->application->id, $pull_request_id)->toArray();
+ $this->stopContainers($containers, $server, $timeout);
}
- ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->first()->delete();
+
+ ApplicationPreview::where('application_id', $this->application->id)
+ ->where('pull_request_id', $pull_request_id)
+ ->first()
+ ->delete();
+
$this->application->refresh();
$this->dispatch('update_links');
$this->dispatch('success', 'Preview deleted.');
@@ -213,4 +223,49 @@ class Previews extends Component
return handleError($e, $this);
}
}
+
+ private function stopContainers(array $containers, $server, int $timeout)
+ {
+ $processes = [];
+ foreach ($containers as $container) {
+ $containerName = str_replace('/', '', $container['Names']);
+ $processes[$containerName] = $this->stopContainer($containerName, $timeout);
+ }
+
+ $startTime = time();
+ while (count($processes) > 0) {
+ $finishedProcesses = array_filter($processes, function ($process) {
+ return !$process->running();
+ });
+ foreach (array_keys($finishedProcesses) as $containerName) {
+ unset($processes[$containerName]);
+ $this->removeContainer($containerName, $server);
+ }
+
+ if (time() - $startTime >= $timeout) {
+ $this->forceStopRemainingContainers(array_keys($processes), $server);
+ break;
+ }
+
+ usleep(100000);
+ }
+ }
+
+ private function stopContainer(string $containerName, int $timeout): InvokedProcess
+ {
+ return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
+ }
+
+ private function removeContainer(string $containerName, $server)
+ {
+ instant_remote_process(["docker rm -f $containerName"], $server, throwError: false);
+ }
+
+ private function forceStopRemainingContainers(array $containerNames, $server)
+ {
+ foreach ($containerNames as $containerName) {
+ instant_remote_process(["docker kill $containerName"], $server, throwError: false);
+ $this->removeContainer($containerName, $server);
+ }
+ }
}
diff --git a/app/Livewire/Project/Service/FileStorage.php b/app/Livewire/Project/Service/FileStorage.php
index 2d9c95daa..9f0d94aad 100644
--- a/app/Livewire/Project/Service/FileStorage.php
+++ b/app/Livewire/Project/Service/FileStorage.php
@@ -15,6 +15,8 @@ use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Livewire\Component;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;
class FileStorage extends Component
{
@@ -77,8 +79,13 @@ class FileStorage extends Component
}
}
- public function delete()
+ public function delete($password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
+
try {
$message = 'File deleted.';
if ($this->fileStorage->is_directory) {
@@ -121,8 +128,15 @@ class FileStorage extends Component
$this->submit();
}
- public function render()
+ public function render()
{
- return view('livewire.project.service.file-storage');
+ return view('livewire.project.service.file-storage', [
+ 'directoryDeletionCheckboxes' => [
+ ['id' => 'permanently_delete', 'label' => 'The selected directory and all its contents will be permantely deleted form the server.'],
+ ],
+ 'fileDeletionCheckboxes' => [
+ ['id' => 'permanently_delete', 'label' => 'The selected file will be permanently deleted form the server.'],
+ ]
+ ]);
}
}
diff --git a/app/Livewire/Project/Service/ServiceApplicationView.php b/app/Livewire/Project/Service/ServiceApplicationView.php
index e7d00c3dd..feb6e7982 100644
--- a/app/Livewire/Project/Service/ServiceApplicationView.php
+++ b/app/Livewire/Project/Service/ServiceApplicationView.php
@@ -4,6 +4,8 @@ namespace App\Livewire\Project\Service;
use App\Models\ServiceApplication;
use Livewire\Component;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;
class ServiceApplicationView extends Component
{
@@ -11,6 +13,10 @@ class ServiceApplicationView extends Component
public $parameters;
+ public $docker_cleanup = true;
+ public $delete_volumes = true;
+
+
protected $rules = [
'application.human_name' => 'nullable',
'application.description' => 'nullable',
@@ -23,12 +29,7 @@ class ServiceApplicationView extends Component
'application.is_stripprefix_enabled' => 'nullable|boolean',
];
- public function render()
- {
- return view('livewire.project.service.service-application-view');
- }
-
- public function updatedApplicationFqdn()
+ public function updatedApplicationFqdn()
{
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
@@ -56,8 +57,13 @@ class ServiceApplicationView extends Component
$this->dispatch('success', 'You need to restart the service for the changes to take effect.');
}
- public function delete()
+ public function delete($password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
+
try {
$this->application->delete();
$this->dispatch('success', 'Application deleted.');
@@ -91,4 +97,17 @@ class ServiceApplicationView extends Component
$this->dispatch('generateDockerCompose');
}
}
+
+ public function render()
+ {
+ return view('livewire.project.service.service-application-view', [
+ 'checkboxes' => [
+ ['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
+ ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images'],
+ // ['id' => 'delete_associated_backups_locally', 'label' => 'All backups associated with this Ressource will be permanently deleted from local storage.'],
+ // ['id' => 'delete_associated_backups_s3', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected S3 Storage.'],
+ // ['id' => 'delete_associated_backups_sftp', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected SFTP Storage.']
+ ]
+ ]);
+ }
}
diff --git a/app/Livewire/Project/Shared/Destination.php b/app/Livewire/Project/Shared/Destination.php
index a2c018beb..1be724568 100644
--- a/app/Livewire/Project/Shared/Destination.php
+++ b/app/Livewire/Project/Shared/Destination.php
@@ -10,6 +10,8 @@ use App\Models\Server;
use App\Models\StandaloneDocker;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;
class Destination extends Component
{
@@ -115,8 +117,13 @@ class Destination extends Component
ApplicationStatusChanged::dispatch(data_get($this->resource, 'environment.project.team.id'));
}
- public function removeServer(int $network_id, int $server_id)
+ public function removeServer(int $network_id, int $server_id, $password)
{
+ if (!Hash::check($password, Auth::user()->password)) {
+ $this->addError('password', 'The provided password is incorrect.');
+ return;
+ }
+
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.');
diff --git a/app/Livewire/Project/Shared/Storages/Show.php b/app/Livewire/Project/Shared/Storages/Show.php
index d350df212..a0cb54aa0 100644
--- a/app/Livewire/Project/Shared/Storages/Show.php
+++ b/app/Livewire/Project/Shared/Storages/Show.php
@@ -45,7 +45,6 @@ class Show extends Component
return;
}
- // Test deletion in more detail
$this->storage->delete();
$this->dispatch('refreshStorages');
}
diff --git a/resources/views/livewire/navbar-delete-team.blade.php b/resources/views/livewire/navbar-delete-team.blade.php
index b660a0dd4..39f23abea 100644
--- a/resources/views/livewire/navbar-delete-team.blade.php
+++ b/resources/views/livewire/navbar-delete-team.blade.php
@@ -1,5 +1,13 @@
-
- This team be deleted. It is not reversible. Please think again.
-
+
diff --git a/resources/views/livewire/project/application/previews.blade.php b/resources/views/livewire/project/application/previews.blade.php
index efd281a77..876aba17a 100644
--- a/resources/views/livewire/project/application/previews.blade.php
+++ b/resources/views/livewire/project/application/previews.blade.php
@@ -160,8 +160,6 @@
:confirmWithText="false"
:confirmWithPassword="false"
step2ButtonText="Stop Preview Deployment"
- :dispatchEvent="true"
- dispatchEventType="stopEvent"
>
diff --git a/resources/views/livewire/project/service/service-application-view.blade.php b/resources/views/livewire/project/service/service-application-view.blade.php
index 069f049fd..6ef7d91c1 100644
--- a/resources/views/livewire/project/service/service-application-view.blade.php
+++ b/resources/views/livewire/project/service/service-application-view.blade.php
@@ -7,12 +7,20 @@
{{ Str::headline($application->name) }}
@endif
Save
-
-
- Delete
-
- This will delete this service application. It is not reversible. Please think again.
-
+
diff --git a/resources/views/livewire/project/shared/destination.blade.php b/resources/views/livewire/project/shared/destination.blade.php
index 5eb57ad81..7d1196877 100644
--- a/resources/views/livewire/project/shared/destination.blade.php
+++ b/resources/views/livewire/project/shared/destination.blade.php
@@ -66,11 +66,16 @@
wire:click="stop('{{ data_get($destination, 'server.id') }}')">Stop
@endif
- This will stop the running application in this server and remove it as a deployment
- destination. Please think again.
-
+ title="Confirm server removal?"
+ isErrorButton
+ buttonTitle="Remove Server"
+ submitAction="removeServer({{ data_get($destination, 'id') }},{{ data_get($destination, 'server.id') }})"
+ :actions="['This will stop the all running applications on this server and remove it as a deployment destination.']"
+ confirmationText="{{ data_get($destination, 'server.name') }}"
+ confirmationLabel="Please confirm the execution of the actions by entering the Server Name below"
+ shortConfirmationLabel="Server Name"
+ step3ButtonText="Permanently Remove Server"
+ />
@endforeach
From 182087cf1bd611e505f37791272e420a59a21ecf Mon Sep 17 00:00:00 2001
From: Andras Bacsai
Date: Wed, 18 Sep 2024 21:18:47 +0200
Subject: [PATCH 097/101] a few changes here and there
---
app/Actions/Database/StopDatabase.php | 7 +-
app/Jobs/DeleteResourceJob.php | 9 +-
app/Livewire/Project/Application/Heading.php | 2 +-
app/Livewire/Project/Service/Navbar.php | 6 +-
app/Livewire/Project/Shared/Danger.php | 35 +-
.../components/modal-confirmation.blade.php | 319 ++++++++++--------
.../livewire/project/shared/danger.blade.php | 22 +-
7 files changed, 218 insertions(+), 182 deletions(-)
diff --git a/app/Actions/Database/StopDatabase.php b/app/Actions/Database/StopDatabase.php
index f90851c93..0f074bea9 100644
--- a/app/Actions/Database/StopDatabase.php
+++ b/app/Actions/Database/StopDatabase.php
@@ -2,6 +2,7 @@
namespace App\Actions\Database;
+use App\Actions\Server\CleanupDocker;
use App\Models\StandaloneClickhouse;
use App\Models\StandaloneDragonfly;
use App\Models\StandaloneKeydb;
@@ -12,7 +13,6 @@ use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Illuminate\Support\Facades\Process;
use Lorisleiva\Actions\Concerns\AsAction;
-use App\Actions\Server\CleanupDocker;
class StopDatabase
{
@@ -21,13 +21,12 @@ class StopDatabase
public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $database, bool $isDeleteOperation = false, bool $dockerCleanup = true)
{
$server = $database->destination->server;
- if (!$server->isFunctional()) {
+ if (! $server->isFunctional()) {
return 'Server is not functional';
}
$this->stopContainer($database, $database->uuid, 300);
- if (!$isDeleteOperation) {
- $this->deleteConnectedNetworks($database->uuid, $server); //Probably not needed as DBs do not have a network normally
+ if (! $isDeleteOperation) {
if ($dockerCleanup) {
CleanupDocker::run($server, true);
}
diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php
index 8f7dd806a..37300593e 100644
--- a/app/Jobs/DeleteResourceJob.php
+++ b/app/Jobs/DeleteResourceJob.php
@@ -4,9 +4,9 @@ namespace App\Jobs;
use App\Actions\Application\StopApplication;
use App\Actions\Database\StopDatabase;
+use App\Actions\Server\CleanupDocker;
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;
@@ -35,8 +35,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
public bool $deleteVolumes,
public bool $dockerCleanup,
public bool $deleteConnectedNetworks
- ) {
- }
+ ) {}
public function handle()
{
@@ -84,11 +83,11 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue
CleanupDocker::run($server, true);
}
- if ($this->deleteConnectedNetworks) {
+ if ($this->deleteConnectedNetworks && ! $isDatabase) {
$this->resource?->delete_connected_networks($this->resource->uuid);
}
} catch (\Throwable $e) {
- send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());
+ send_internal_notification('ContainerStoppingJob failed with: '.$e->getMessage());
throw $e;
} finally {
$this->resource->forceDelete();
diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php
index 4677ff7a2..f84b49c3f 100644
--- a/app/Livewire/Project/Application/Heading.php
+++ b/app/Livewire/Project/Application/Heading.php
@@ -143,7 +143,7 @@ class Heading extends Component
return view('livewire.project.application.heading', [
'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/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php
index 51f38d2db..2e3002852 100644
--- a/app/Livewire/Project/Service/Navbar.php
+++ b/app/Livewire/Project/Service/Navbar.php
@@ -21,6 +21,7 @@ class Navbar extends Component
public $isDeploymentProgress = false;
public $docker_cleanup = true;
+
public $title = 'Configuration';
public function mount()
@@ -119,9 +120,8 @@ class Navbar extends Component
{
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)'],
- ]
+ ['id' => 'docker_cleanup', 'label' => 'Cleanup docker build cache and unused images (next deployment could take longer).'],
+ ],
]);
}
-
}
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index 609d61698..f437b910e 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -4,24 +4,33 @@ namespace App\Livewire\Project\Shared;
use App\Jobs\DeleteResourceJob;
use App\Models\Service;
-use App\Models\ServiceDatabase;
use App\Models\ServiceApplication;
+use App\Models\ServiceDatabase;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
-use Illuminate\Support\Facades\Hash;
-use Illuminate\Support\Facades\Auth;
class Danger extends Component
{
public $resource;
+
public $resourceName;
+
public $projectUuid;
+
public $environmentName;
+
public bool $delete_configurations = true;
+
public bool $delete_volumes = true;
+
public bool $docker_cleanup = true;
+
public bool $delete_connected_networks = true;
+
public ?string $modalId = null;
+
public string $resourceDomain = '';
public function mount()
@@ -42,11 +51,13 @@ class Danger extends Component
if ($this->resource === null) {
$this->resourceName = 'Unknown Resource';
+
return;
}
- if (!method_exists($this->resource, 'type')) {
+ if (! method_exists($this->resource, 'type')) {
$this->resourceName = 'Unknown Resource';
+
return;
}
@@ -80,13 +91,15 @@ class Danger extends Component
public function delete($password)
{
- if (!Hash::check($password, Auth::user()->password)) {
+ if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
+
return;
}
- if (!$this->resource) {
+ if (! $this->resource) {
$this->addError('resource', 'Resource not found.');
+
return;
}
@@ -113,14 +126,14 @@ class Danger extends Component
{
return view('livewire.project.shared.danger', [
'checkboxes' => [
- ['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
- ['id' => 'delete_connected_networks', 'label' => 'All connected networks with this resource will be permanently deleted (predefined networks will not be deleted)'],
- ['id' => 'delete_configurations', 'label' => 'All configuration files will be permanently deleted form the server'],
- ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images'],
+ ['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted.'],
+ ['id' => 'delete_connected_networks', 'label' => 'All connected networks with this resource will be permanently deleted (except the predefined networks).'],
+ ['id' => 'delete_configurations', 'label' => 'All configuration files will be permanently deleted form the server.'],
+ ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images.'],
// ['id' => 'delete_associated_backups_locally', 'label' => 'All backups associated with this Ressource will be permanently deleted from local storage.'],
// ['id' => 'delete_associated_backups_s3', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected S3 Storage.'],
// ['id' => 'delete_associated_backups_sftp', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected SFTP Storage.']
- ]
+ ],
]);
}
}
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index e31284e7c..249820e9a 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -1,25 +1,25 @@
@props([
-'title' => 'Are you sure?',
-'isErrorButton' => false,
-'buttonTitle' => 'Confirm Action',
-'buttonFullWidth' => false,
-'customButton' => null,
-'disabled' => false,
-'submitAction' => 'delete',
-'content' => null,
-'checkboxes' => [],
-'actions' => [],
-'confirmWithText' => true,
-'confirmationText' => 'Confirm Deletion',
-'confirmationLabel' => 'Please confirm the execution of the actions by entering the Name below',
-'shortConfirmationLabel' => 'Name',
-'confirmWithPassword' => true,
-'step1ButtonText' => 'Continue Deletion',
-'step2ButtonText' => 'Delete Permanently',
-'step3ButtonText' => 'Confirm Permanent Deletion',
-'dispatchEvent' => false,
-'dispatchEventType' => 'success',
-'dispatchEventMessage' => '',
+ 'title' => 'Are you sure?',
+ 'isErrorButton' => false,
+ 'buttonTitle' => 'Confirm Action',
+ 'buttonFullWidth' => false,
+ 'customButton' => null,
+ 'disabled' => false,
+ 'submitAction' => 'delete',
+ 'content' => null,
+ 'checkboxes' => [],
+ 'actions' => [],
+ 'confirmWithText' => true,
+ 'confirmationText' => 'Confirm Deletion',
+ 'confirmationLabel' => 'Please confirm the execution of the actions by entering the NAME below',
+ 'shortConfirmationLabel' => 'Name',
+ 'confirmWithPassword' => true,
+ 'step1ButtonText' => 'Continue',
+ 'step2ButtonText' => 'Confirm',
+ 'step3ButtonText' => 'Delete Permanently',
+ 'dispatchEvent' => false,
+ 'dispatchEventType' => 'success',
+ 'dispatchEventMessage' => '',
])
+}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }"
+ class="relative w-auto h-auto">
@if ($customButton)
- @if ($buttonFullWidth)
-
- {{ $customButton }}
-
+ @if ($buttonFullWidth)
+
+ {{ $customButton }}
+
+ @else
+
+ {{ $customButton }}
+
+ @endif
@else
-
- {{ $customButton }}
-
- @endif
- @else
- @if ($content)
-
- {{ $content }}
-
- @else
- @if ($disabled)
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @elseif ($isErrorButton)
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @else
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @endif
- @endif
+ @if ($content)
+
+ {{ $content }}
+
+ @else
+ @if ($disabled)
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @elseif ($isErrorButton)
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @else
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @endif
+ @endif
@endif
-
-
-
-
-
{{ $title }}
-
-
+
+
+
+
-
- @if(!empty($checkboxes))
-
-
-
-
Select the actions you want to perform:
+
+ @if (!empty($checkboxes))
+
+
+
+
Select the actions you want to perform:
+
+ @foreach ($checkboxes as $index => $checkbox)
+
+
+ {{ $checkbox['label'] }}
+
+
+
+ @endforeach
- @foreach($checkboxes as $index => $checkbox)
-
-
- {{ $checkbox['label'] }}
-
-
-
- @endforeach
-
@endif
-
+
Warning
-
This operation is permanent and cannot be undone. Please think again before proceeding!
+
This operation is permanent and cannot be undone. Please think again before proceeding!
+
-
The following actions will be performed:
+
The following actions will be performed:
- @foreach($actions as $action)
-
-
-
-
- {{ $action }}
-
- @endforeach
- @foreach($checkboxes as $checkbox)
-
+ @foreach ($actions as $action)
-
-
+
+
- {{ $checkbox['label'] }}
+ {{ $action }}
-
+ @endforeach
+ @foreach ($checkboxes as $checkbox)
+
+
+
+
+
+ {{ $checkbox['label'] }}
+
+
@endforeach
- @if($confirmWithText)
-
-
Confirm Actions
-
{{ $confirmationLabel }}
+ @if ($confirmWithText)
+
+
Confirm Actions
+
{{ $confirmationLabel }}
-
-
-
- {{ $shortConfirmationLabel }}
-
-
-
@endif
-
+
Final Confirmation
Please enter your password to confirm this destructive action.
-
-
+
+
Your Password
-
-
+
+
@error('password')
-
{{ $message }}
+
{{ $message }}
@enderror
-
+
Back
-
+
Cancel
@@ -274,7 +306,9 @@
-
- Danger Zone
Woah. I hope you know what are you doing.
Delete Resource
- This will stop your containers, delete all related data, etc. Beware! There is no coming back!
-
+ This will stop your containers, delete all related data, etc. Beware! There is no coming back!
+
+
From 532f5e351ec9d7620bc8e4b04476d1081732e992 Mon Sep 17 00:00:00 2001
From: Andras Bacsai
Date: Wed, 18 Sep 2024 21:24:42 +0200
Subject: [PATCH 098/101] fixes
---
app/Livewire/Project/Application/Heading.php | 2 +-
app/Livewire/Project/Database/Heading.php | 4 ++--
.../Service/ServiceApplicationView.php | 17 ++++++++--------
.../project/application/heading.blade.php | 20 +++++++------------
4 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php
index f84b49c3f..88f6ca6d3 100644
--- a/app/Livewire/Project/Application/Heading.php
+++ b/app/Livewire/Project/Application/Heading.php
@@ -142,7 +142,7 @@ class Heading extends Component
{
return view('livewire.project.application.heading', [
'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)'],
+ ['id' => 'docker_cleanup', 'label' => 'Cleanup docker build cache and unused images (next deployment could take longer).'],
],
]);
}
diff --git a/app/Livewire/Project/Database/Heading.php b/app/Livewire/Project/Database/Heading.php
index 4eca89cb6..765213f60 100644
--- a/app/Livewire/Project/Database/Heading.php
+++ b/app/Livewire/Project/Database/Heading.php
@@ -78,8 +78,8 @@ class Heading extends Component
{
return view('livewire.project.database.heading', [
'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)'],
- ]
+ ['id' => 'docker_cleanup', 'label' => 'Cleanup docker build cache and unused images (next deployment could take longer).'],
+ ],
]);
}
}
diff --git a/app/Livewire/Project/Service/ServiceApplicationView.php b/app/Livewire/Project/Service/ServiceApplicationView.php
index feb6e7982..f6355b6b5 100644
--- a/app/Livewire/Project/Service/ServiceApplicationView.php
+++ b/app/Livewire/Project/Service/ServiceApplicationView.php
@@ -3,9 +3,9 @@
namespace App\Livewire\Project\Service;
use App\Models\ServiceApplication;
-use Livewire\Component;
-use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
+use Livewire\Component;
class ServiceApplicationView extends Component
{
@@ -14,8 +14,8 @@ class ServiceApplicationView extends Component
public $parameters;
public $docker_cleanup = true;
+
public $delete_volumes = true;
-
protected $rules = [
'application.human_name' => 'nullable',
@@ -29,7 +29,7 @@ class ServiceApplicationView extends Component
'application.is_stripprefix_enabled' => 'nullable|boolean',
];
- public function updatedApplicationFqdn()
+ public function updatedApplicationFqdn()
{
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
@@ -59,8 +59,9 @@ class ServiceApplicationView extends Component
public function delete($password)
{
- if (!Hash::check($password, Auth::user()->password)) {
+ if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
+
return;
}
@@ -102,12 +103,12 @@ class ServiceApplicationView extends Component
{
return view('livewire.project.service.service-application-view', [
'checkboxes' => [
- ['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
- ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images'],
+ ['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted.'],
+ ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images.'],
// ['id' => 'delete_associated_backups_locally', 'label' => 'All backups associated with this Ressource will be permanently deleted from local storage.'],
// ['id' => 'delete_associated_backups_s3', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected S3 Storage.'],
// ['id' => 'delete_associated_backups_sftp', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected SFTP Storage.']
- ]
+ ],
]);
}
}
diff --git a/resources/views/livewire/project/application/heading.blade.php b/resources/views/livewire/project/application/heading.blade.php
index 7aceaec44..04b65eef9 100644
--- a/resources/views/livewire/project/application/heading.blade.php
+++ b/resources/views/livewire/project/application/heading.blade.php
@@ -72,19 +72,13 @@
@endif
@endif
-
+
Date: Thu, 19 Sep 2024 10:27:44 +0200
Subject: [PATCH 099/101] refactor: Update Docker cleanup label in Heading.php
and Navbar.php
---
app/Livewire/Project/Application/Heading.php | 4 +-
app/Livewire/Project/Service/Navbar.php | 6 +-
.../Service/ServiceApplicationView.php | 17 +-
app/Livewire/Project/Shared/Danger.php | 35 +-
lang/en.json | 8 +-
.../components/modal-confirmation.blade.php | 308 ++++++++++--------
.../livewire/project/service/navbar.blade.php | 206 ++++++------
.../livewire/project/shared/danger.blade.php | 22 +-
8 files changed, 317 insertions(+), 289 deletions(-)
diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php
index 4677ff7a2..1082b48cd 100644
--- a/app/Livewire/Project/Application/Heading.php
+++ b/app/Livewire/Project/Application/Heading.php
@@ -142,8 +142,8 @@ class Heading extends Component
{
return view('livewire.project.application.heading', [
'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)'],
- ]
+ ['id' => 'docker_cleanup', 'label' => __('resource.docker_cleanup')],
+ ],
]);
}
}
diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php
index 51f38d2db..f6caa481e 100644
--- a/app/Livewire/Project/Service/Navbar.php
+++ b/app/Livewire/Project/Service/Navbar.php
@@ -21,6 +21,7 @@ class Navbar extends Component
public $isDeploymentProgress = false;
public $docker_cleanup = true;
+
public $title = 'Configuration';
public function mount()
@@ -119,9 +120,8 @@ class Navbar extends Component
{
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)'],
- ]
+ ['id' => 'docker_cleanup', 'label' => __('resource.docker_cleanup')],
+ ],
]);
}
-
}
diff --git a/app/Livewire/Project/Service/ServiceApplicationView.php b/app/Livewire/Project/Service/ServiceApplicationView.php
index feb6e7982..56b506043 100644
--- a/app/Livewire/Project/Service/ServiceApplicationView.php
+++ b/app/Livewire/Project/Service/ServiceApplicationView.php
@@ -3,9 +3,9 @@
namespace App\Livewire\Project\Service;
use App\Models\ServiceApplication;
-use Livewire\Component;
-use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
+use Livewire\Component;
class ServiceApplicationView extends Component
{
@@ -14,8 +14,8 @@ class ServiceApplicationView extends Component
public $parameters;
public $docker_cleanup = true;
+
public $delete_volumes = true;
-
protected $rules = [
'application.human_name' => 'nullable',
@@ -29,7 +29,7 @@ class ServiceApplicationView extends Component
'application.is_stripprefix_enabled' => 'nullable|boolean',
];
- public function updatedApplicationFqdn()
+ public function updatedApplicationFqdn()
{
$this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim();
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
@@ -59,8 +59,9 @@ class ServiceApplicationView extends Component
public function delete($password)
{
- if (!Hash::check($password, Auth::user()->password)) {
+ if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
+
return;
}
@@ -102,12 +103,12 @@ class ServiceApplicationView extends Component
{
return view('livewire.project.service.service-application-view', [
'checkboxes' => [
- ['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
- ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images'],
+ ['id' => 'delete_volumes', 'label' => __('resource.delete_volumes')],
+ ['id' => 'docker_cleanup', 'label' => __('resource.docker_cleanup')],
// ['id' => 'delete_associated_backups_locally', 'label' => 'All backups associated with this Ressource will be permanently deleted from local storage.'],
// ['id' => 'delete_associated_backups_s3', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected S3 Storage.'],
// ['id' => 'delete_associated_backups_sftp', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected SFTP Storage.']
- ]
+ ],
]);
}
}
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index 609d61698..543e64539 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -4,24 +4,33 @@ namespace App\Livewire\Project\Shared;
use App\Jobs\DeleteResourceJob;
use App\Models\Service;
-use App\Models\ServiceDatabase;
use App\Models\ServiceApplication;
+use App\Models\ServiceDatabase;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Hash;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
-use Illuminate\Support\Facades\Hash;
-use Illuminate\Support\Facades\Auth;
class Danger extends Component
{
public $resource;
+
public $resourceName;
+
public $projectUuid;
+
public $environmentName;
+
public bool $delete_configurations = true;
+
public bool $delete_volumes = true;
+
public bool $docker_cleanup = true;
+
public bool $delete_connected_networks = true;
+
public ?string $modalId = null;
+
public string $resourceDomain = '';
public function mount()
@@ -42,11 +51,13 @@ class Danger extends Component
if ($this->resource === null) {
$this->resourceName = 'Unknown Resource';
+
return;
}
- if (!method_exists($this->resource, 'type')) {
+ if (! method_exists($this->resource, 'type')) {
$this->resourceName = 'Unknown Resource';
+
return;
}
@@ -80,13 +91,15 @@ class Danger extends Component
public function delete($password)
{
- if (!Hash::check($password, Auth::user()->password)) {
+ if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
+
return;
}
- if (!$this->resource) {
+ if (! $this->resource) {
$this->addError('resource', 'Resource not found.');
+
return;
}
@@ -113,14 +126,14 @@ class Danger extends Component
{
return view('livewire.project.shared.danger', [
'checkboxes' => [
- ['id' => 'delete_volumes', 'label' => 'All associated volumes with this resource will be permanently deleted'],
- ['id' => 'delete_connected_networks', 'label' => 'All connected networks with this resource will be permanently deleted (predefined networks will not be deleted)'],
- ['id' => 'delete_configurations', 'label' => 'All configuration files will be permanently deleted form the server'],
- ['id' => 'docker_cleanup', 'label' => 'Docker cleanup will be run on the server which removes builder cache and unused images'],
+ ['id' => 'delete_volumes', 'label' => __('resource.delete_volumes')],
+ ['id' => 'delete_connected_networks', 'label' => __('resource.delete_connected_networks')],
+ ['id' => 'delete_configurations', 'label' => __('resource.delete_configurations')],
+ ['id' => 'docker_cleanup', 'label' => __('resource.docker_cleanup')],
// ['id' => 'delete_associated_backups_locally', 'label' => 'All backups associated with this Ressource will be permanently deleted from local storage.'],
// ['id' => 'delete_associated_backups_s3', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected S3 Storage.'],
// ['id' => 'delete_associated_backups_sftp', 'label' => 'All backups associated with this Ressource will be permanently deleted from the selected SFTP Storage.']
- ]
+ ],
]);
}
}
diff --git a/lang/en.json b/lang/en.json
index 461a96e9a..e1603c303 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -26,5 +26,11 @@
"input.code": "One-time code",
"input.recovery_code": "Recovery code",
"button.save": "Save",
- "repository.url": "Examples For Public repositories, use https://... . For Private repositories, use git@... . https://github.com/coollabsio/coolify-examples main branch will be selected https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify nodejs-fastify branch will be selected. https://gitea.com/sedlav/expressjs.git main branch will be selected. https://gitlab.com/andrasbacsai/nodejs-example.git main branch will be selected."
+ "repository.url": "Examples For Public repositories, use https://... . For Private repositories, use git@... . https://github.com/coollabsio/coolify-examples main branch will be selected https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify nodejs-fastify branch will be selected. https://gitea.com/sedlav/expressjs.git main branch will be selected. https://gitlab.com/andrasbacsai/nodejs-example.git main branch will be selected.",
+ "service.stop": "This service will be stopped.",
+ "resource.docker_cleanup": "Run Docker Cleanup (remove unused images and builder cache).",
+ "resource.non_persistent": "All non-persistent data will be deleted.",
+ "resource.delete_volumes": "All volumes associated with this resource will be permanently deleted.",
+ "resource.delete_connected_networks": "All non-predefined networks associated with this resource will be permanently deleted.",
+ "resource.delete_configurations": "All configuration files will be permanently deleted from the server."
}
diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php
index e31284e7c..529b4f0d2 100644
--- a/resources/views/components/modal-confirmation.blade.php
+++ b/resources/views/components/modal-confirmation.blade.php
@@ -1,25 +1,25 @@
@props([
-'title' => 'Are you sure?',
-'isErrorButton' => false,
-'buttonTitle' => 'Confirm Action',
-'buttonFullWidth' => false,
-'customButton' => null,
-'disabled' => false,
-'submitAction' => 'delete',
-'content' => null,
-'checkboxes' => [],
-'actions' => [],
-'confirmWithText' => true,
-'confirmationText' => 'Confirm Deletion',
-'confirmationLabel' => 'Please confirm the execution of the actions by entering the Name below',
-'shortConfirmationLabel' => 'Name',
-'confirmWithPassword' => true,
-'step1ButtonText' => 'Continue Deletion',
-'step2ButtonText' => 'Delete Permanently',
-'step3ButtonText' => 'Confirm Permanent Deletion',
-'dispatchEvent' => false,
-'dispatchEventType' => 'success',
-'dispatchEventMessage' => '',
+ 'title' => 'Are you sure?',
+ 'isErrorButton' => false,
+ 'buttonTitle' => 'Confirm Action',
+ 'buttonFullWidth' => false,
+ 'customButton' => null,
+ 'disabled' => false,
+ 'submitAction' => 'delete',
+ 'content' => null,
+ 'checkboxes' => [],
+ 'actions' => [],
+ 'confirmWithText' => true,
+ 'confirmationText' => 'Confirm Deletion',
+ 'confirmationLabel' => 'Please confirm the execution of the actions by entering the Name below',
+ 'shortConfirmationLabel' => 'Name',
+ 'confirmWithPassword' => true,
+ 'step1ButtonText' => 'Continue',
+ 'step2ButtonText' => 'Continue',
+ 'step3ButtonText' => 'Confirm',
+ 'dispatchEvent' => false,
+ 'dispatchEventType' => 'success',
+ 'dispatchEventMessage' => '',
])
+}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }"
+ class="relative w-auto h-auto">
@if ($customButton)
- @if ($buttonFullWidth)
-
- {{ $customButton }}
-
+ @if ($buttonFullWidth)
+
+ {{ $customButton }}
+
+ @else
+
+ {{ $customButton }}
+
+ @endif
@else
-
- {{ $customButton }}
-
- @endif
- @else
- @if ($content)
-
- {{ $content }}
-
- @else
- @if ($disabled)
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @elseif ($isErrorButton)
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @else
- @if ($buttonFullWidth)
-
- {{ $buttonTitle }}
-
- @else
-
- {{ $buttonTitle }}
-
- @endif
- @endif
- @endif
+ @if ($content)
+
+ {{ $content }}
+
+ @else
+ @if ($disabled)
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @elseif ($isErrorButton)
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @else
+ @if ($buttonFullWidth)
+
+ {{ $buttonTitle }}
+
+ @else
+
+ {{ $buttonTitle }}
+
+ @endif
+ @endif
+ @endif
@endif
-
-
-
+
+
+
- @if(!empty($checkboxes))
-
-
-
-
Select the actions you want to perform:
+ @if (!empty($checkboxes))
+
+
+
+
Actions
+
+ @foreach ($checkboxes as $index => $checkbox)
+
+
+ {{ $checkbox['label'] }}
+
+
+
+ @endforeach
- @foreach($checkboxes as $index => $checkbox)
-
-
- {{ $checkbox['label'] }}
-
-
-
- @endforeach
-
@endif
-
+
Warning
-
This operation is permanent and cannot be undone. Please think again before proceeding!
+
This operation is permanent and cannot be undone. Please think again before proceeding!
+
The following actions will be performed:
- @foreach($actions as $action)
-
-
-
-
- {{ $action }}
-
- @endforeach
- @foreach($checkboxes as $checkbox)
-
+ @foreach ($actions as $action)
-
-
+
+
- {{ $checkbox['label'] }}
+ {{ $action }}
-
+ @endforeach
+ @foreach ($checkboxes as $checkbox)
+
+
+
+
+
+ {{ $checkbox['label'] }}
+
+
@endforeach
- @if($confirmWithText)
-
-
Confirm Actions
-
{{ $confirmationLabel }}
+ @if ($confirmWithText)
+
+
Confirm Actions
+
{{ $confirmationLabel }}
-
-
-
- {{ $shortConfirmationLabel }}
-
-
-
@endif
-
+
Final Confirmation
Please enter your password to confirm this destructive action.
-
-
+
+
Your Password
-
+
@error('password')
-
{{ $message }}
+
{{ $message }}
@enderror
@@ -262,7 +294,8 @@
-
+
Cancel
@@ -274,7 +307,9 @@
-
-
@if (str($service->status())->contains('running'))
-
-
-
-
-
-
-
- Pull Latest Images & Restart
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
- Stop
-
-
+ Pull Latest Images & Restart
+
+
+
+
+
+
+
+
+
+
+ Stop
+
+
@elseif (str($service->status())->contains('degraded'))
-
-
-
-
-
-
-
- Restart Degraded Services
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
- Stop
-
-
+ Restart Degraded Services
+
+
+
+
+
+
+
+
+
+
+ Stop
+
+
@elseif (str($service->status())->contains('exited'))
@@ -108,59 +95,54 @@
Deploy
@else
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ Stop
+
+
+
+
+
+
- Stop
-
-
-
-
-
-
-
- Deploy
-
+ Deploy
+
@endif
@script
-
+
@endscript
diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php
index 61a891e69..9d6d902f1 100644
--- a/resources/views/livewire/project/shared/danger.blade.php
+++ b/resources/views/livewire/project/shared/danger.blade.php
@@ -2,20 +2,10 @@
Danger Zone
Woah. I hope you know what are you doing.
Delete Resource
-
This will stop your containers, delete all related data, etc. Beware! There is no coming back!
-
+
This will stop your containers, delete all related data, etc. Beware! There is no coming back!
+
+
From 430fdcf2e9465d64c02d67452204a917a886c499 Mon Sep 17 00:00:00 2001
From: Andras Bacsai
Date: Thu, 19 Sep 2024 10:35:54 +0200
Subject: [PATCH 100/101] chore: Update version numbers to 4.0.0-beta.342
---
config/sentry.php | 2 +-
config/version.php | 2 +-
versions.json | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/config/sentry.php b/config/sentry.php
index 471a1e0fc..c65d3d1ff 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -7,7 +7,7 @@ return [
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
- 'release' => '4.0.0-beta.341',
+ 'release' => '4.0.0-beta.342',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),
diff --git a/config/version.php b/config/version.php
index 32eb01cd0..633c71d60 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,3 +1,3 @@
Date: Thu, 19 Sep 2024 10:57:34 +0200
Subject: [PATCH 101/101] refactor: Remove commented out code in Navbar.php
---
app/Livewire/Project/Service/Navbar.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php
index f6caa481e..42c9357fd 100644
--- a/app/Livewire/Project/Service/Navbar.php
+++ b/app/Livewire/Project/Service/Navbar.php
@@ -44,7 +44,7 @@ class Navbar extends Component
public function serviceStarted()
{
- $this->dispatch('success', 'Service status changed.');
+ // $this->dispatch('success', 'Service status changed.');
if (is_null($this->service->config_hash) || $this->service->isConfigurationChanged()) {
$this->service->isConfigurationChanged(true);
$this->dispatch('configurationChanged');