From bb6cb8edc92c37cbaae82c2024468f0d7775d49c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 3 Oct 2024 10:48:25 +0200 Subject: [PATCH] improvement: show backup button on supported db service stacks --- app/Models/ServiceDatabase.php | 8 +++++ app/Models/StandaloneClickhouse.php | 5 +++ app/Models/StandaloneDragonfly.php | 5 +++ app/Models/StandaloneKeydb.php | 5 +++ app/Models/StandaloneMariadb.php | 5 +++ app/Models/StandaloneMongodb.php | 5 +++ app/Models/StandaloneMysql.php | 5 +++ app/Models/StandalonePostgresql.php | 5 +++ app/Models/StandaloneRedis.php | 5 +++ .../project/service/configuration.blade.php | 6 ++++ .../livewire/project/service/index.blade.php | 35 ++++++++++--------- 11 files changed, 72 insertions(+), 17 deletions(-) diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php index 6b96738e8..518e3f909 100644 --- a/app/Models/ServiceDatabase.php +++ b/app/Models/ServiceDatabase.php @@ -115,4 +115,12 @@ class ServiceDatabase extends BaseModel { return $this->morphMany(ScheduledDatabaseBackup::class, 'database'); } + + public function isBackupSolutionAvailable() + { + return str($this->databaseType())->contains('mysql') || + str($this->databaseType())->contains('postgres') || + str($this->databaseType())->contains('mariadb') || + str($this->databaseType())->contains('mongodb'); + } } diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.php index ee5c3becc..e4341b1b9 100644 --- a/app/Models/StandaloneClickhouse.php +++ b/app/Models/StandaloneClickhouse.php @@ -294,4 +294,9 @@ class StandaloneClickhouse extends BaseModel return $parsedCollection->toArray(); } } + + public function isBackupSolutionAvailable() + { + return false; + } } diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.php index 361abf110..94ab2d745 100644 --- a/app/Models/StandaloneDragonfly.php +++ b/app/Models/StandaloneDragonfly.php @@ -294,4 +294,9 @@ class StandaloneDragonfly extends BaseModel return $parsedCollection->toArray(); } } + + public function isBackupSolutionAvailable() + { + return false; + } } diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.php index e05879371..335c8931c 100644 --- a/app/Models/StandaloneKeydb.php +++ b/app/Models/StandaloneKeydb.php @@ -294,4 +294,9 @@ class StandaloneKeydb extends BaseModel return $parsedCollection->toArray(); } } + + public function isBackupSolutionAvailable() + { + return false; + } } diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php index c1e6c85d7..c6c08dee5 100644 --- a/app/Models/StandaloneMariadb.php +++ b/app/Models/StandaloneMariadb.php @@ -294,4 +294,9 @@ class StandaloneMariadb extends BaseModel return $parsedCollection->toArray(); } } + + public function isBackupSolutionAvailable() + { + return true; + } } diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php index e5ed0a5f4..99893b1d1 100644 --- a/app/Models/StandaloneMongodb.php +++ b/app/Models/StandaloneMongodb.php @@ -314,4 +314,9 @@ class StandaloneMongodb extends BaseModel return $parsedCollection->toArray(); } } + + public function isBackupSolutionAvailable() + { + return true; + } } diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php index bd4a7abb7..f2a5b5c14 100644 --- a/app/Models/StandaloneMysql.php +++ b/app/Models/StandaloneMysql.php @@ -295,4 +295,9 @@ class StandaloneMysql extends BaseModel return $parsedCollection->toArray(); } } + + public function isBackupSolutionAvailable() + { + return true; + } } diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php index db771c7cd..1b18a5ca7 100644 --- a/app/Models/StandalonePostgresql.php +++ b/app/Models/StandalonePostgresql.php @@ -296,4 +296,9 @@ class StandalonePostgresql extends BaseModel return $parsedCollection->toArray(); } } + + public function isBackupSolutionAvailable() + { + return true; + } } diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php index c524d4d03..a5868e243 100644 --- a/app/Models/StandaloneRedis.php +++ b/app/Models/StandaloneRedis.php @@ -290,4 +290,9 @@ class StandaloneRedis extends BaseModel return $parsedCollection->toArray(); } } + + public function isBackupSolutionAvailable() + { + return false; + } } diff --git a/resources/views/livewire/project/service/configuration.blade.php b/resources/views/livewire/project/service/configuration.blade.php index 55d8c6b39..d7d9d21d3 100644 --- a/resources/views/livewire/project/service/configuration.blade.php +++ b/resources/views/livewire/project/service/configuration.blade.php @@ -149,6 +149,12 @@
{{ $database->status }}
+ @if ($database->isBackupSolutionAvailable()) + + Backups + + @endif Settings diff --git a/resources/views/livewire/project/service/index.blade.php b/resources/views/livewire/project/service/index.blade.php index ef148c88a..f8d5f8a43 100644 --- a/resources/views/livewire/project/service/index.blade.php +++ b/resources/views/livewire/project/service/index.blade.php @@ -10,9 +10,7 @@ General - @if (str($serviceDatabase?->databaseType())->contains('mysql') || - str($serviceDatabase?->databaseType())->contains('postgres') || - str($serviceDatabase?->databaseType())->contains('mariadb')) + @if ($serviceDatabase->isBackupSolutionAvailable()) Backups @endif @@ -28,22 +26,25 @@
@endisset @isset($serviceDatabase) - - {{ data_get_str($service, 'name')->limit(10) }} > {{ data_get_str($serviceDatabase, 'name')->limit(10) }} | Coolify - + + {{ data_get_str($service, 'name')->limit(10) }} > + {{ data_get_str($serviceDatabase, 'name')->limit(10) }} | Coolify +
-
-
-

Scheduled Backups

- - - -
- -
- @endisset - + @if ($serviceDatabase->isBackupSolutionAvailable()) +
+
+

Scheduled Backups

+ + + +
+ + @endif +
+ @endisset +