2023-11-20 10:35:31 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project\Application;
|
2023-11-20 10:35:31 +00:00
|
|
|
|
|
|
|
use App\Models\Application;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Advanced extends Component
|
|
|
|
{
|
|
|
|
public Application $application;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-02-15 10:55:43 +00:00
|
|
|
public bool $is_force_https_enabled;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-03-04 09:46:13 +00:00
|
|
|
public bool $is_gzip_enabled;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-03-04 09:46:13 +00:00
|
|
|
public bool $is_stripprefix_enabled;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-11-20 10:35:31 +00:00
|
|
|
protected $rules = [
|
|
|
|
'application.settings.is_git_submodules_enabled' => 'boolean|required',
|
|
|
|
'application.settings.is_git_lfs_enabled' => 'boolean|required',
|
|
|
|
'application.settings.is_preview_deployments_enabled' => 'boolean|required',
|
|
|
|
'application.settings.is_auto_deploy_enabled' => 'boolean|required',
|
2024-02-15 10:55:43 +00:00
|
|
|
'is_force_https_enabled' => 'boolean|required',
|
2023-11-20 10:35:31 +00:00
|
|
|
'application.settings.is_log_drain_enabled' => 'boolean|required',
|
|
|
|
'application.settings.is_gpu_enabled' => 'boolean|required',
|
2024-01-16 14:19:14 +00:00
|
|
|
'application.settings.is_build_server_enabled' => 'boolean|required',
|
2024-02-15 10:55:43 +00:00
|
|
|
'application.settings.is_consistent_container_name_enabled' => 'boolean|required',
|
2024-05-06 09:45:22 +00:00
|
|
|
'application.settings.custom_internal_name' => 'string|nullable',
|
2024-03-04 09:46:13 +00:00
|
|
|
'application.settings.is_gzip_enabled' => 'boolean|required',
|
|
|
|
'application.settings.is_stripprefix_enabled' => 'boolean|required',
|
2023-11-20 10:35:31 +00:00
|
|
|
'application.settings.gpu_driver' => 'string|required',
|
|
|
|
'application.settings.gpu_count' => 'string|required',
|
|
|
|
'application.settings.gpu_device_ids' => 'string|required',
|
|
|
|
'application.settings.gpu_options' => 'string|required',
|
2024-04-25 09:49:34 +00:00
|
|
|
'application.settings.is_raw_compose_deployment_enabled' => 'boolean|required',
|
|
|
|
'application.settings.connect_to_docker_network' => 'boolean|required',
|
2023-11-20 10:35:31 +00:00
|
|
|
];
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-05-06 09:45:22 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
2024-03-04 10:01:14 +00:00
|
|
|
$this->is_force_https_enabled = $this->application->isForceHttpsEnabled();
|
|
|
|
$this->is_gzip_enabled = $this->application->isGzipEnabled();
|
|
|
|
$this->is_stripprefix_enabled = $this->application->isStripprefixEnabled();
|
2024-02-15 10:55:43 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-11-20 10:35:31 +00:00
|
|
|
public function instantSave()
|
|
|
|
{
|
2024-03-04 10:01:14 +00:00
|
|
|
if ($this->application->isLogDrainEnabled()) {
|
2024-06-10 20:43:34 +00:00
|
|
|
if (! $this->application->destination->server->isLogDrainEnabled()) {
|
2023-11-20 10:35:31 +00:00
|
|
|
$this->application->settings->is_log_drain_enabled = false;
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('error', 'Log drain is not enabled on this server.');
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-11-20 10:35:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2024-02-15 10:55:43 +00:00
|
|
|
if ($this->application->settings->is_force_https_enabled !== $this->is_force_https_enabled) {
|
|
|
|
$this->application->settings->is_force_https_enabled = $this->is_force_https_enabled;
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('resetDefaultLabels', false);
|
2023-11-20 10:35:31 +00:00
|
|
|
}
|
2024-03-04 09:46:13 +00:00
|
|
|
if ($this->application->settings->is_gzip_enabled !== $this->is_gzip_enabled) {
|
|
|
|
$this->application->settings->is_gzip_enabled = $this->is_gzip_enabled;
|
|
|
|
$this->dispatch('resetDefaultLabels', false);
|
|
|
|
}
|
|
|
|
if ($this->application->settings->is_stripprefix_enabled !== $this->is_stripprefix_enabled) {
|
|
|
|
$this->application->settings->is_stripprefix_enabled = $this->is_stripprefix_enabled;
|
|
|
|
$this->dispatch('resetDefaultLabels', false);
|
|
|
|
}
|
2024-04-25 09:49:34 +00:00
|
|
|
if ($this->application->settings->is_raw_compose_deployment_enabled) {
|
|
|
|
$this->application->parseRawCompose();
|
|
|
|
} else {
|
|
|
|
$this->application->parseCompose();
|
|
|
|
}
|
2023-11-20 10:35:31 +00:00
|
|
|
$this->application->settings->save();
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('success', 'Settings saved.');
|
2024-04-25 09:49:34 +00:00
|
|
|
$this->dispatch('configurationChanged');
|
2023-11-20 10:35:31 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-05-06 09:45:22 +00:00
|
|
|
public function submit()
|
|
|
|
{
|
2023-11-20 10:35:31 +00:00
|
|
|
if ($this->application->settings->gpu_count && $this->application->settings->gpu_device_ids) {
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('error', 'You cannot set both GPU count and GPU device IDs.');
|
2023-11-20 10:35:31 +00:00
|
|
|
$this->application->settings->gpu_count = null;
|
|
|
|
$this->application->settings->gpu_device_ids = null;
|
|
|
|
$this->application->settings->save();
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-11-20 10:35:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->application->settings->save();
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('success', 'Settings saved.');
|
2023-11-20 10:35:31 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-05-06 09:45:22 +00:00
|
|
|
public function saveCustomName()
|
|
|
|
{
|
|
|
|
if (isset($this->application->settings->custom_internal_name)) {
|
|
|
|
$this->application->settings->custom_internal_name = str($this->application->settings->custom_internal_name)->slug()->value();
|
|
|
|
} else {
|
|
|
|
$this->application->settings->custom_internal_name = null;
|
|
|
|
}
|
|
|
|
$this->application->settings->save();
|
|
|
|
$this->dispatch('success', 'Custom name saved.');
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-11-20 10:35:31 +00:00
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.project.application.advanced');
|
|
|
|
}
|
|
|
|
}
|