From fd5b7492f810424e3841d6644d871fe5e26f20f5 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 3 Feb 2025 23:21:09 +0100 Subject: [PATCH] chore(ui): improve valid until handling --- .../Project/Database/Postgresql/General.php | 16 +++--- .../database/postgresql/general.blade.php | 49 +++++++++---------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.php index e52d8d65e..f0e3d064e 100644 --- a/app/Livewire/Project/Database/Postgresql/General.php +++ b/app/Livewire/Project/Database/Postgresql/General.php @@ -25,6 +25,8 @@ class General extends Component public ?string $db_url_public = null; + public $certificateValidUntil = null; + public function getListeners() { return [ @@ -78,6 +80,14 @@ class General extends Component $this->db_url = $this->database->internal_db_url; $this->db_url_public = $this->database->external_db_url; $this->server = data_get($this->database, 'destination.server'); + + $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass()) + ->where('resource_id', $this->database->id) + ->first(); + + if ($existingCert) { + $this->certificateValidUntil = $existingCert->valid_until; + } } public function instantSaveAdvanced() @@ -112,12 +122,6 @@ class General extends Component public function regenerateSslCertificate() { try { - if (! $this->database->enable_ssl) { - $this->dispatch('error', 'SSL is not enabled for this database.'); - - return; - } - $server = $this->database->destination->server; $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass()) diff --git a/resources/views/livewire/project/database/postgresql/general.blade.php b/resources/views/livewire/project/database/postgresql/general.blade.php index 4ca4817ad..8b9ca45f9 100644 --- a/resources/views/livewire/project/database/postgresql/general.blade.php +++ b/resources/views/livewire/project/database/postgresql/general.blade.php @@ -75,38 +75,33 @@
-
+

SSL Configuration

@if($database->enable_ssl) - @php - $cert = \App\Models\SslCertificate::where('resource_type', $database->getMorphClass()) - ->where('resource_id', $database->id) - ->first(); - @endphp - @if($cert) - Valid until: - @if(now()->gt($cert->valid_until)) - {{ $cert->valid_until->format('d.m.Y H:i:s') }} - Expired - @elseif(now()->addDays(30)->gt($cert->valid_until)) - {{ $cert->valid_until->format('d.m.Y H:i:s') }} - Expiring soon - @else - {{ $cert->valid_until->format('d.m.Y H:i:s') }} - @endif - - @endif + @endif
- @if($database->enable_ssl) - - @endif
+ @if($database->enable_ssl) + Valid until: + @if(now()->gt($certificateValidUntil)) + {{ $certificateValidUntil->format('d.m.Y H:i:s') }} - Expired + @elseif(now()->addDays(30)->gt($certificateValidUntil)) + {{ $certificateValidUntil->format('d.m.Y H:i:s') }} - Expiring soon + @else + {{ $certificateValidUntil->format('d.m.Y H:i:s') }} + @endif + + @endif +
+
@if($database->enable_ssl)