This commit is contained in:
Andras Bacsai 2023-06-22 15:25:57 +02:00
parent 6aa7cbade0
commit ee211aba51
8 changed files with 56 additions and 22 deletions

View File

@ -20,7 +20,7 @@ class General extends Component
public string|null $git_commit_sha; public string|null $git_commit_sha;
public string $build_pack; public string $build_pack;
public string|null $wildcard_domain = null; 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 string|null $global_wildcard_domain = null;
public bool $is_static; public bool $is_static;
@ -81,9 +81,9 @@ public function instantSave()
protected function checkWildCardDomain() protected function checkWildCardDomain()
{ {
$coolify_instance_settings = InstanceSettings::get(); $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->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() public function mount()
{ {
@ -107,10 +107,10 @@ public function generateGlobalRandomDomain()
$this->application->save(); $this->application->save();
$this->emit('success', 'Application settings updated!'); $this->emit('success', 'Application settings updated!');
} }
public function generateProjectRandomDomain() public function generateServerRandomDomain()
{ {
// Set wildcard domain based on Project wildcard domain // Set wildcard domain based on Server wildcard domain
$url = Url::fromString($this->project_wildcard_domain); $url = Url::fromString($this->server_wildcard_domain);
$host = $url->getHost(); $host = $url->getHost();
$path = $url->getPath() === '/' ? '' : $url->getPath(); $path = $url->getPath() === '/' ? '' : $url->getPath();
$scheme = $url->getScheme(); $scheme = $url->getScheme();

View File

@ -8,22 +8,15 @@
class Edit extends Component class Edit extends Component
{ {
public Project $project; public Project $project;
public string|null $wildcard_domain = null;
protected $rules = [ protected $rules = [
'project.name' => 'required|min:3|max:255', 'project.name' => 'required|min:3|max:255',
'project.description' => 'nullable|string|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() public function submit()
{ {
$this->validate(); $this->validate();
try { try {
$this->project->settings->wildcard_domain = $this->wildcard_domain;
$this->project->settings->save();
$this->project->save(); $this->project->save();
$this->emit('saved'); $this->emit('saved');
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -11,6 +11,7 @@ class Form extends Component
public Server $server; public Server $server;
public $uptime; public $uptime;
public $dockerVersion; public $dockerVersion;
public string|null $wildcard_domain = null;
protected $rules = [ protected $rules = [
'server.name' => 'required|min:6', 'server.name' => 'required|min:6',
@ -19,7 +20,8 @@ class Form extends Component
'server.user' => 'required', 'server.user' => 'required',
'server.port' => 'required', 'server.port' => 'required',
'server.settings.is_reachable' => '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 = [ protected $validationAttributes = [
'server.name' => 'name', 'server.name' => 'name',
@ -30,6 +32,10 @@ class Form extends Component
'server.settings.is_reachable' => 'is reachable', 'server.settings.is_reachable' => 'is reachable',
'server.settings.is_part_of_swarm' => 'is part of swarm' 'server.settings.is_part_of_swarm' => 'is part of swarm'
]; ];
public function mount()
{
$this->wildcard_domain = $this->server->settings->wildcard_domain;
}
public function installDocker() public function installDocker()
{ {
$activity = resolve(InstallDocker::class)($this->server); $activity = resolve(InstallDocker::class)($this->server);
@ -81,6 +87,8 @@ public function submit()
// } // }
// return; // return;
// } // }
$this->server->settings->wildcard_domain = $this->wildcard_domain;
$this->server->settings->save();
$this->server->save(); $this->server->save();
$this->emit('success', 'Server updated successfully.'); $this->emit('success', 'Server updated successfully.');
} }

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('project_settings', function (Blueprint $table) {
$table->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');
});
}
};

View File

@ -15,11 +15,11 @@
@if ($wildcard_domain) @if ($wildcard_domain)
<div class="flex flex-row gap-2"> <div class="flex flex-row gap-2">
@if ($global_wildcard_domain) @if ($global_wildcard_domain)
<x-forms.button wire:click="generateGlobalRandomDomain">Global Wildcard <x-forms.button wire:click="generateGlobalRandomDomain">Set Global Wildcard
</x-forms.button> </x-forms.button>
@endif @endif
@if ($project_wildcard_domain) @if ($server_wildcard_domain)
<x-forms.button wire:click="generateProjectRandomDomain">Project Wildcard <x-forms.button wire:click="generateServerRandomDomain">Set Server Wildcard
</x-forms.button> </x-forms.button>
@endif @endif
</div> </div>

View File

@ -8,7 +8,6 @@
<div class="flex gap-2"> <div class="flex gap-2">
<x-forms.input label="Name" id="project.name" /> <x-forms.input label="Name" id="project.name" />
<x-forms.input label="Description" id="project.description" /> <x-forms.input label="Description" id="project.description" />
<x-forms.input label="Wildcard Domain" id="wildcard_domain" />
</div> </div>
</form> </form>
</div> </div>

View File

@ -15,6 +15,8 @@
<x-forms.input id="server.name" label="Name" required /> <x-forms.input id="server.name" label="Name" required />
<x-forms.input id="server.description" label="Description" /> <x-forms.input id="server.description" label="Description" />
@endif @endif
<x-forms.input id="wildcard_domain" label="Wildcard Domain"
helper="Wildcard domain for your applications. If you set this, you will get a random generated domain for your new applications.<br><span class='font-bold text-white'>Example</span>In case you set:<span class='text-helper'>https://example.com</span>your applications will get: <span class='text-helper'>https://randomId.example.com</span>" />
{{-- <x-forms.checkbox disabled type="checkbox" id="server.settings.is_part_of_swarm" {{-- <x-forms.checkbox disabled type="checkbox" id="server.settings.is_part_of_swarm"
label="Is it part of a Swarm cluster?" /> --}} label="Is it part of a Swarm cluster?" /> --}}

View File

@ -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}/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}', [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}', [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( Route::get(
'/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', '/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}',
[ApplicationController::class, 'deployment'] [ApplicationController::class, 'deployment']