From ee211aba5140b227a80ba4fb01bd1c8ac38fffa5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 22 Jun 2023 15:25:57 +0200 Subject: [PATCH] wip --- .../Livewire/Project/Application/General.php | 12 +++---- app/Http/Livewire/Project/Edit.php | 9 +---- app/Http/Livewire/Server/Form.php | 10 +++++- ...3_06_22_131459_move_wildcard_to_server.php | 34 +++++++++++++++++++ .../project/application/general.blade.php | 6 ++-- .../views/livewire/project/edit.blade.php | 1 - .../views/livewire/server/form.blade.php | 2 ++ routes/web.php | 4 +-- 8 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 database/migrations/2023_06_22_131459_move_wildcard_to_server.php diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index eeef8020b..c7f84258d 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -20,7 +20,7 @@ class General extends Component public string|null $git_commit_sha; public string $build_pack; public string|null $wildcard_domain = null; - public string|null $project_wildcard_domain = null; + public string|null $server_wildcard_domain = null; public string|null $global_wildcard_domain = null; public bool $is_static; @@ -81,9 +81,9 @@ public function instantSave() protected function checkWildCardDomain() { $coolify_instance_settings = InstanceSettings::get(); - $this->project_wildcard_domain = data_get($this->application, 'environment.project.settings.wildcard_domain'); + $this->server_wildcard_domain = data_get($this->application, 'destination.server.settings.wildcard_domain'); $this->global_wildcard_domain = data_get($coolify_instance_settings, 'wildcard_domain'); - $this->wildcard_domain = $this->project_wildcard_domain ?? $this->global_wildcard_domain ?? null; + $this->wildcard_domain = $this->server_wildcard_domain ?? $this->global_wildcard_domain ?? null; } public function mount() { @@ -107,10 +107,10 @@ public function generateGlobalRandomDomain() $this->application->save(); $this->emit('success', 'Application settings updated!'); } - public function generateProjectRandomDomain() + public function generateServerRandomDomain() { - // Set wildcard domain based on Project wildcard domain - $url = Url::fromString($this->project_wildcard_domain); + // Set wildcard domain based on Server wildcard domain + $url = Url::fromString($this->server_wildcard_domain); $host = $url->getHost(); $path = $url->getPath() === '/' ? '' : $url->getPath(); $scheme = $url->getScheme(); diff --git a/app/Http/Livewire/Project/Edit.php b/app/Http/Livewire/Project/Edit.php index 79652607c..60702ca3e 100644 --- a/app/Http/Livewire/Project/Edit.php +++ b/app/Http/Livewire/Project/Edit.php @@ -8,22 +8,15 @@ class Edit extends Component { public Project $project; - public string|null $wildcard_domain = null; protected $rules = [ 'project.name' => 'required|min:3|max:255', 'project.description' => 'nullable|string|max:255', - 'wildcard_domain' => 'nullable|string|max:255', ]; - public function mount() - { - $this->wildcard_domain = $this->project->settings->wildcard_domain; - } + public function submit() { $this->validate(); try { - $this->project->settings->wildcard_domain = $this->wildcard_domain; - $this->project->settings->save(); $this->project->save(); $this->emit('saved'); } catch (\Exception $e) { diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index 2c4f2260f..961fde6a8 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -11,6 +11,7 @@ class Form extends Component public Server $server; public $uptime; public $dockerVersion; + public string|null $wildcard_domain = null; protected $rules = [ 'server.name' => 'required|min:6', @@ -19,7 +20,8 @@ class Form extends Component 'server.user' => 'required', 'server.port' => 'required', 'server.settings.is_reachable' => 'required', - 'server.settings.is_part_of_swarm' => 'required' + 'server.settings.is_part_of_swarm' => 'required', + 'wildcard_domain' => 'nullable|string' ]; protected $validationAttributes = [ 'server.name' => 'name', @@ -30,6 +32,10 @@ class Form extends Component 'server.settings.is_reachable' => 'is reachable', 'server.settings.is_part_of_swarm' => 'is part of swarm' ]; + public function mount() + { + $this->wildcard_domain = $this->server->settings->wildcard_domain; + } public function installDocker() { $activity = resolve(InstallDocker::class)($this->server); @@ -81,6 +87,8 @@ public function submit() // } // return; // } + $this->server->settings->wildcard_domain = $this->wildcard_domain; + $this->server->settings->save(); $this->server->save(); $this->emit('success', 'Server updated successfully.'); } diff --git a/database/migrations/2023_06_22_131459_move_wildcard_to_server.php b/database/migrations/2023_06_22_131459_move_wildcard_to_server.php new file mode 100644 index 000000000..cd258fbea --- /dev/null +++ b/database/migrations/2023_06_22_131459_move_wildcard_to_server.php @@ -0,0 +1,34 @@ +dropColumn('wildcard_domain'); + }); + Schema::table('server_settings', function (Blueprint $table) { + $table->string('wildcard_domain')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('project_settings', function (Blueprint $table) { + $table->string('wildcard_domain')->nullable(); + }); + Schema::table('server_settings', function (Blueprint $table) { + $table->dropColumn('wildcard_domain'); + }); + } +}; diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index ec8ee781f..9db650e24 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -15,11 +15,11 @@ @if ($wildcard_domain)
@if ($global_wildcard_domain) - Global Wildcard + Set Global Wildcard @endif - @if ($project_wildcard_domain) - Project Wildcard + @if ($server_wildcard_domain) + Set Server Wildcard @endif
diff --git a/resources/views/livewire/project/edit.blade.php b/resources/views/livewire/project/edit.blade.php index ad58e3c59..dfcab8d22 100644 --- a/resources/views/livewire/project/edit.blade.php +++ b/resources/views/livewire/project/edit.blade.php @@ -8,7 +8,6 @@
-
diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index 8f1aeeb5a..9e0372c02 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -15,6 +15,8 @@ @endif + {{-- --}} diff --git a/routes/web.php b/routes/web.php index 49d82dc77..61abd0e8d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -52,9 +52,7 @@ Route::get('/project/{project_uuid}/{environment_name}/new', [ProjectController::class, 'new'])->name('project.resources.new'); Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources'); Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ApplicationController::class, 'configuration'])->name('project.application.configuration'); - - Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', [ApplicationController::class, 'deployments'])->name('project.application.deployments'); - + Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', [ApplicationController::class, 'deployments'])->name('project.application.deployments'); Route::get( '/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', [ApplicationController::class, 'deployment']