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 $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 @@ class General extends Component
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 @@ class General extends Component
$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();

View File

@@ -8,22 +8,15 @@ use Livewire\Component;
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) {

View File

@@ -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 @@ class Form extends Component
// }
// return;
// }
$this->server->settings->wildcard_domain = $this->wildcard_domain;
$this->server->settings->save();
$this->server->save();
$this->emit('success', 'Server updated successfully.');
}