Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Feat: recent backups UI

ayntk-ai62ecc45f2167
diff --git a/app/Livewire/Project/Database/BackupExecutions.php b/app/Livewire/Project/Database/BackupExecutions.php
index de1bac36fc..79c1fcffc7 100644
--- a/app/Livewire/Project/Database/BackupExecutions.php
+++ b/app/Livewire/Project/Database/BackupExecutions.php
@@ -8,9 +8,8 @@ use Livewire\Component;
class BackupExecutions extends Component
{
public ?ScheduledDatabaseBackup $backup = null;
-
+ public $database;
public $executions = [];
-
public $setDeletableBackup;
public function getListeners()
@@ -61,4 +60,50 @@ class BackupExecutions extends Component
$this->executions = $this->backup->executions()->get()->sortBy('created_at');
}
}
+
+ public function mount(ScheduledDatabaseBackup $backup)
+ {
+ $this->backup = $backup;
+ $this->database = $backup->database;
+ $this->refreshBackupExecutions();
+ }
+
+ public function server()
+ {
+ if ($this->database) {
+ $server = null;
+
+ if ($this->database instanceof \App\Models\ServiceDatabase) {
+ $server = $this->database->service->destination->server;
+ } elseif ($this->database->destination && $this->database->destination->server) {
+ $server = $this->database->destination->server;
+ }
+ if ($server) {
+ return $server;
+ }
+ }
+ return null;
+ }
+
+ public function getServerTimezone()
+ {
+ $server = $this->server();
+ if (!$server) {
+ return 'UTC';
+ }
+ $serverTimezone = $server->settings->server_timezone;
+ return $serverTimezone;
+ }
+
+ public function formatDateInServerTimezone($date)
+ {
+ $serverTimezone = $this->getServerTimezone();
+ $dateObj = new \DateTime($date);
+ try {
+ $dateObj->setTimezone(new \DateTimeZone($serverTimezone));
+ } catch (\Exception $e) {
+ $dateObj->setTimezone(new \DateTimeZone('UTC'));
+ }
+ return $dateObj->format('Y-m-d H:i:s T');
+ }
}
diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.php
index 644ac9fa40..483fecc349 100644
--- a/resources/views/livewire/project/database/backup-executions.blade.php
+++ b/resources/views/livewire/project/database/backup-executions.blade.php
@@ -19,7 +19,7 @@
@endif
<div>Database: {{ data_get($execution, 'database_name', 'N/A') }}</div>
<div>Status: {{ data_get($execution, 'status') }}</div>
- <div>Started At: {{ data_get($execution, 'created_at') }}</div>
+ <div>Started At: {{ $this->formatDateInServerTimezone(data_get($execution, 'created_at')) }}</div>
@if (data_get($execution, 'message'))
<div>Message: {{ data_get($execution, 'message') }}</div>
@endif
@@ -54,4 +54,4 @@
</script>
@endisset
-</div>
+</div>
\ No newline at end of file