This commit is contained in:
Andras Bacsai
2024-10-17 22:08:23 +02:00
parent 9044c655b8
commit b75c2dc604
18 changed files with 62 additions and 51 deletions

View File

@@ -12,6 +12,7 @@ class GenerateConfig
public function handle(Application $application, bool $is_json = false) public function handle(Application $application, bool $is_json = false)
{ {
ray()->clearAll(); ray()->clearAll();
return $application->generateConfig(is_json: $is_json); return $application->generateConfig(is_json: $is_json);
} }
} }

View File

@@ -2,7 +2,6 @@
namespace App\Actions\Server; namespace App\Actions\Server;
use App\Models\InstanceSettings;
use App\Models\Server; use App\Models\Server;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;

View File

@@ -3,7 +3,6 @@
namespace App\Actions\Server; namespace App\Actions\Server;
use App\Models\Server; use App\Models\Server;
use Carbon\Carbon;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
class StopSentinel class StopSentinel

View File

@@ -241,7 +241,6 @@ class General extends Component
} }
} }
public function updatedApplicationBuildPack() public function updatedApplicationBuildPack()
{ {
if ($this->application->build_pack !== 'nixpacks') { if ($this->application->build_pack !== 'nixpacks') {
@@ -335,6 +334,7 @@ class General extends Component
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim(); $this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { $this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
Url::fromString($domain, ['http', 'https']); Url::fromString($domain, ['http', 'https']);
return str($domain)->trim()->lower(); return str($domain)->trim()->lower();
}); });
$this->application->fqdn = $this->application->fqdn->unique()->implode(','); $this->application->fqdn = $this->application->fqdn->unique()->implode(',');
@@ -409,11 +409,13 @@ class General extends Component
if ($originalFqdn !== $this->application->fqdn) { if ($originalFqdn !== $this->application->fqdn) {
$this->application->fqdn = $originalFqdn; $this->application->fqdn = $originalFqdn;
} }
return handleError($e, $this); return handleError($e, $this);
} finally { } finally {
$this->dispatch('configurationChanged'); $this->dispatch('configurationChanged');
} }
} }
public function downloadConfig() public function downloadConfig()
{ {
$config = GenerateConfig::run($this->application, true); $config = GenerateConfig::run($this->application, true);

View File

@@ -317,6 +317,7 @@ class PublicGitRepository extends Component
// $application->setConfig($config); // $application->setConfig($config);
// } // }
} }
return redirect()->route('project.application.configuration', [ return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
'environment_name' => $environment->name, 'environment_name' => $environment->name,

View File

@@ -21,6 +21,7 @@ class EditDomain extends Component
{ {
$this->application = ServiceApplication::find($this->applicationId); $this->application = ServiceApplication::find($this->applicationId);
} }
public function submit() public function submit()
{ {
try { try {
@@ -28,6 +29,7 @@ class EditDomain extends Component
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim(); $this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { $this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
Url::fromString($domain, ['http', 'https']); Url::fromString($domain, ['http', 'https']);
return str($domain)->trim()->lower(); return str($domain)->trim()->lower();
}); });
$this->application->fqdn = $this->application->fqdn->unique()->implode(','); $this->application->fqdn = $this->application->fqdn->unique()->implode(',');
@@ -48,6 +50,7 @@ class EditDomain extends Component
if ($originalFqdn !== $this->application->fqdn) { if ($originalFqdn !== $this->application->fqdn) {
$this->application->fqdn = $originalFqdn; $this->application->fqdn = $originalFqdn;
} }
return handleError($e, $this); return handleError($e, $this);
} }
} }

View File

@@ -39,7 +39,7 @@ class Navbar extends Component
return [ return [
"echo-private:user.{$userId},ServiceStatusChanged" => 'serviceStarted', "echo-private:user.{$userId},ServiceStatusChanged" => 'serviceStarted',
"envsUpdated" => '$refresh', 'envsUpdated' => '$refresh',
]; ];
} }

View File

@@ -30,10 +30,7 @@ class ServiceApplicationView extends Component
'application.is_stripprefix_enabled' => 'nullable|boolean', 'application.is_stripprefix_enabled' => 'nullable|boolean',
]; ];
public function updatedApplicationFqdn() public function updatedApplicationFqdn() {}
{
}
public function instantSave() public function instantSave()
{ {
@@ -82,6 +79,7 @@ class ServiceApplicationView extends Component
$this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim(); $this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim();
$this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { $this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
Url::fromString($domain, ['http', 'https']); Url::fromString($domain, ['http', 'https']);
return str($domain)->trim()->lower(); return str($domain)->trim()->lower();
}); });
$this->application->fqdn = $this->application->fqdn->unique()->implode(','); $this->application->fqdn = $this->application->fqdn->unique()->implode(',');
@@ -101,6 +99,7 @@ class ServiceApplicationView extends Component
if ($originalFqdn !== $this->application->fqdn) { if ($originalFqdn !== $this->application->fqdn) {
$this->application->fqdn = $originalFqdn; $this->application->fqdn = $originalFqdn;
} }
return handleError($e, $this); return handleError($e, $this);
} }
} }

View File

@@ -8,8 +8,11 @@ use Livewire\Component;
class UploadConfig extends Component class UploadConfig extends Component
{ {
public $config; public $config;
public $applicationId; public $applicationId;
public function mount() {
public function mount()
{
if (isDev()) { if (isDev()) {
$this->config = '{ $this->config = '{
"build_pack": "nixpacks", "build_pack": "nixpacks",
@@ -22,6 +25,7 @@ class UploadConfig extends Component
}'; }';
} }
} }
public function uploadConfig() public function uploadConfig()
{ {
try { try {
@@ -30,10 +34,12 @@ class UploadConfig extends Component
$this->dispatch('success', 'Application settings updated'); $this->dispatch('success', 'Application settings updated');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->dispatch('error', $e->getMessage()); $this->dispatch('error', $e->getMessage());
return; return;
} }
} }
public function render() public function render()
{ {
return view('livewire.project.shared.upload-config'); return view('livewire.project.shared.upload-config');

View File

@@ -29,7 +29,6 @@ class CloudflareTunnels extends Component
} }
} }
public function manualCloudflareConfig() public function manualCloudflareConfig()
{ {
$this->server->settings->is_cloudflare_tunnel = true; $this->server->settings->is_cloudflare_tunnel = true;

View File

@@ -30,6 +30,7 @@ class Delete extends Component
} }
$this->server->delete(); $this->server->delete();
DeleteServer::dispatch($this->server); DeleteServer::dispatch($this->server);
return redirect()->route('server.index'); return redirect()->route('server.index');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);

View File

@@ -47,6 +47,7 @@ class ShowPrivateKey extends Component
$this->dispatch('success', 'Server is reachable.'); $this->dispatch('success', 'Server is reachable.');
} else { } else {
$this->dispatch('error', 'Server is not reachable.<br><br>Check this <a target="_blank" class="underline" href="https://coolify.io/docs/knowledge-base/server/openssh">documentation</a> for further help.<br><br>Error: '.$error); $this->dispatch('error', 'Server is not reachable.<br><br>Check this <a target="_blank" class="underline" href="https://coolify.io/docs/knowledge-base/server/openssh">documentation</a> for further help.<br><br>Error: '.$error);
return; return;
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
@@ -56,6 +57,4 @@ class ShowPrivateKey extends Component
$this->server->refresh(); $this->server->refresh();
} }
} }
} }

View File

@@ -28,6 +28,7 @@ class Index extends Component
protected string $dynamic_config_path = '/data/coolify/proxy/dynamic'; protected string $dynamic_config_path = '/data/coolify/proxy/dynamic';
protected Server $server; protected Server $server;
public $timezones; public $timezones;
protected $rules = [ protected $rules = [
@@ -57,7 +58,6 @@ class Index extends Component
'settings.instance_timezone' => 'Instance Timezone', 'settings.instance_timezone' => 'Instance Timezone',
]; ];
public function mount() public function mount()
{ {
if (isInstanceAdmin()) { if (isInstanceAdmin()) {
@@ -171,7 +171,6 @@ class Index extends Component
} }
} }
public function render() public function render()
{ {
return view('livewire.settings.index'); return view('livewire.settings.index');

View File

@@ -51,7 +51,6 @@ class ScheduledDatabaseBackup extends BaseModel
} }
} }
return null; return null;
} }
} }

View File

@@ -528,12 +528,12 @@ $schema://$host {
Storage::disk('ssh-mux')->delete($this->muxFilename()); Storage::disk('ssh-mux')->delete($this->muxFilename());
} }
public function sentinelHeartbeat(bool $isReset = false) public function sentinelHeartbeat(bool $isReset = false)
{ {
$this->sentinel_updated_at = $isReset ? now()->subMinutes(6000) : now(); $this->sentinel_updated_at = $isReset ? now()->subMinutes(6000) : now();
$this->save(); $this->save();
} }
public function isSentinelLive() public function isSentinelLive()
{ {
return Carbon::parse($this->sentinel_updated_at)->isAfter(now()->subMinutes(4)); return Carbon::parse($this->sentinel_updated_at)->isAfter(now()->subMinutes(4));
@@ -613,6 +613,7 @@ $schema://$host {
$parsedCollection = collect($cpu)->map(function ($metric) { $parsedCollection = collect($cpu)->map(function ($metric) {
return [(int) $metric['time'], (float) $metric['percent']]; return [(int) $metric['time'], (float) $metric['percent']];
}); });
return $parsedCollection; return $parsedCollection;
} }
@@ -1092,6 +1093,7 @@ $schema://$host {
return true; return true;
} }
public function validateConnection($isManualCheck = true) public function validateConnection($isManualCheck = true)
{ {
config()->set('constants.ssh.mux_enabled', ! $isManualCheck); config()->set('constants.ssh.mux_enabled', ! $isManualCheck);

View File

@@ -109,6 +109,7 @@ class ServerSetting extends Model
if ($save) { if ($save) {
$this->save(); $this->save();
} }
return $domain; return $domain;
} }

View File

@@ -297,7 +297,7 @@ class Service extends BaseModel
'key' => 'CP_DISABLE_HTTPS', 'key' => 'CP_DISABLE_HTTPS',
'value' => data_get($disable_https, 'value'), 'value' => data_get($disable_https, 'value'),
'rules' => 'required', 'rules' => 'required',
'customHelper' => "If you want to use https, set this to 0. Variable name: CP_DISABLE_HTTPS", 'customHelper' => 'If you want to use https, set this to 0. Variable name: CP_DISABLE_HTTPS',
], ],
]); ]);
} }
@@ -1326,9 +1326,9 @@ class Service extends BaseModel
return false; return false;
} }
} }
return true; return true;
} }
); );
} }
} }

View File

@@ -335,6 +335,7 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
if (preg_match('/coolify\.traefik\.middlewares=(.*)/', $item, $matches)) { if (preg_match('/coolify\.traefik\.middlewares=(.*)/', $item, $matches)) {
return explode(',', $matches[1]); return explode(',', $matches[1]);
} }
return null; return null;
})->flatten() })->flatten()
->filter() ->filter()