mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(backups): show exact execution times in backup tables
Closes #11316
This commit is contained in:
@@ -3178,9 +3178,9 @@ input[type="search"]::-webkit-search-results-decoration {
|
||||
}
|
||||
|
||||
.backup-executions-table-grid {
|
||||
grid-template-columns: 6.5rem minmax(7rem, 0.8fr) minmax(14rem, 1.5fr) 7rem 5rem 4rem minmax(8rem, 1fr) 5rem;
|
||||
grid-template-columns: 6.5rem minmax(7rem, 0.8fr) minmax(14rem, 1.5fr) 10rem 5rem 4rem minmax(8rem, 1fr) 5rem;
|
||||
gap: 0.75rem;
|
||||
min-width: 66rem;
|
||||
min-width: 69rem;
|
||||
}
|
||||
|
||||
.backup-executions-table-scroll {
|
||||
@@ -3192,8 +3192,8 @@ input[type="search"]::-webkit-search-results-decoration {
|
||||
}
|
||||
|
||||
.volume-backup-executions-grid {
|
||||
grid-template-columns: 7.5rem minmax(14rem, 1fr) 8.5rem 7rem 9rem minmax(9rem, 0.7fr);
|
||||
min-width: 50rem;
|
||||
grid-template-columns: 7.5rem minmax(14rem, 1fr) 11rem 7rem 9rem minmax(9rem, 0.7fr);
|
||||
min-width: 52.5rem;
|
||||
}
|
||||
|
||||
.clone-destinations-table-grid {
|
||||
@@ -3239,7 +3239,7 @@ input[type="search"]::-webkit-search-results-decoration {
|
||||
}
|
||||
|
||||
.backup-executions-table-grid {
|
||||
grid-template-columns: 7.5rem minmax(9rem, 0.8fr) minmax(14rem, 1.5fr) 8rem 6rem minmax(9rem, auto);
|
||||
grid-template-columns: 7.5rem minmax(9rem, 0.8fr) minmax(14rem, 1.5fr) 10rem 6rem minmax(9rem, auto);
|
||||
}
|
||||
|
||||
.backup-executions-table-grid > :nth-child(6),
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
<span>Availability</span>
|
||||
<span class="text-right">Actions</span>
|
||||
</div>
|
||||
@php
|
||||
$server = $this->server();
|
||||
@endphp
|
||||
@foreach ($executions as $execution)
|
||||
@php
|
||||
$executionStatus = data_get($execution, 'status');
|
||||
@@ -92,11 +95,15 @@
|
||||
title="Backup path: {{ data_get($execution, 'filename', 'N/A') }}">{{ data_get($execution, 'filename', 'N/A') }}</code>
|
||||
<x-copy-button :value="data_get($execution, 'filename', '')" label="Copy backup path" />
|
||||
</div>
|
||||
<div class="text-[11px] text-neutral-600 dark:text-fg-dim">
|
||||
<div class="text-[11px] text-neutral-600 dark:text-fg-dim"
|
||||
title="Started: {{ formatDateInServerTimezone(data_get($execution, 'created_at'), $server) }}@if ($executionStatus !== 'running') Ended: {{ formatDateInServerTimezone(data_get($execution, 'finished_at'), $server) }}@endif">
|
||||
@if ($executionStatus === 'running')
|
||||
Running now
|
||||
@else
|
||||
{{ \Carbon\Carbon::parse(data_get($execution, 'finished_at'))->diffForHumans() }}
|
||||
<div class="text-black dark:text-fg">
|
||||
{{ formatDateInServerTimezone(data_get($execution, 'finished_at'), $server) }}
|
||||
</div>
|
||||
<div>{{ \Carbon\Carbon::parse(data_get($execution, 'finished_at'))->diffForHumans() }}</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="text-[11px] text-neutral-600 dark:text-fg-dim">
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<div>
|
||||
@php
|
||||
$server = $service->server;
|
||||
@endphp
|
||||
@if ($selectedExecution)
|
||||
<x-modal-input title="Backup execution" wireOpen="executionModalOpen" :wireIgnore="false" isLarge>
|
||||
<x-slot:content><span></span></x-slot:content>
|
||||
@@ -6,7 +9,7 @@
|
||||
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<div><p class="text-xs text-neutral-500 dark:text-fg-dim">Target</p><p class="mt-1 text-sm font-medium">{{ $selectedExecution['target'] }}</p></div>
|
||||
<div><p class="text-xs text-neutral-500 dark:text-fg-dim">Status</p><p class="mt-1 text-sm font-medium">{{ str($selectedExecution['status'])->headline() }}</p></div>
|
||||
<div><p class="text-xs text-neutral-500 dark:text-fg-dim">Started</p><p class="mt-1 text-sm font-medium">{{ $selectedExecution['started_at']->diffForHumans() }}</p></div>
|
||||
<div><p class="text-xs text-neutral-500 dark:text-fg-dim">Started</p><p class="mt-1 text-sm font-medium" title="{{ $selectedExecution['started_at']->diffForHumans() }}">{{ formatDateInServerTimezone($selectedExecution['started_at'], $server) }}</p></div>
|
||||
<div><p class="text-xs text-neutral-500 dark:text-fg-dim">Size</p><p class="mt-1 text-sm font-medium">{{ $selectedExecution['size'] ? formatBytes($selectedExecution['size']) : '-' }}</p></div>
|
||||
</div>
|
||||
@if ($selectedExecution['filename'])
|
||||
@@ -32,7 +35,7 @@
|
||||
@else
|
||||
<div class="data-table relative w-full overflow-x-auto">
|
||||
<x-table.loading target="previousPage,nextPage,setPage,perPage" text="Loading executions..." />
|
||||
<div class="data-table-header grid min-w-[820px] grid-cols-[minmax(150px,1.4fr)_100px_100px_110px_110px_90px_48px]">
|
||||
<div class="data-table-header grid min-w-[900px] grid-cols-[minmax(150px,1.4fr)_100px_100px_110px_190px_90px_48px]">
|
||||
<span>Target</span><span>Type</span><span>Schedule</span><span>Status</span><span>Started</span><span>Size</span><span class="text-right">Actions</span>
|
||||
</div>
|
||||
@foreach ($executions as $execution)
|
||||
@@ -47,7 +50,7 @@
|
||||
<div wire:key="service-backup-execution-{{ $execution['id'] }}"
|
||||
wire:click="openExecution('{{ $execution['uuid'] }}')"
|
||||
wire:keydown.enter="openExecution('{{ $execution['uuid'] }}')" role="button" tabindex="0"
|
||||
class="data-table-row grid min-w-[820px] cursor-pointer grid-cols-[minmax(150px,1.4fr)_100px_100px_110px_110px_90px_48px] text-left text-[13px] text-neutral-700 dark:text-fg-dim">
|
||||
class="data-table-row grid min-w-[900px] cursor-pointer grid-cols-[minmax(150px,1.4fr)_100px_100px_110px_190px_90px_48px] text-left text-[13px] text-neutral-700 dark:text-fg-dim">
|
||||
<span class="flex min-w-0 items-center gap-2 font-medium text-neutral-950 dark:text-fg">
|
||||
<span class="truncate" title="{{ $execution['target'] }}">{{ $execution['target'] }}</span>
|
||||
<span tabindex="0" data-tooltip="{{ $execution['s3_tooltip'] }}"
|
||||
@@ -57,7 +60,10 @@
|
||||
</span>
|
||||
<span>{{ $execution['type'] }}</span><span>{{ $execution['schedule'] }}</span>
|
||||
<span><x-status-badge :status="str($execution['status'])->headline()" :type="$statusType" /></span>
|
||||
<span>{{ $execution['started_at']->diffForHumans() }}</span>
|
||||
<span>
|
||||
<span class="block">{{ formatDateInServerTimezone($execution['started_at'], $server) }}</span>
|
||||
<span class="text-[11px] text-neutral-500 dark:text-fg-faint">{{ $execution['started_at']->diffForHumans() }}</span>
|
||||
</span>
|
||||
<span>{{ $execution['size'] ? formatBytes($execution['size']) : '-' }}</span>
|
||||
<span class="flex justify-end">
|
||||
@if ($execution['download_url'])
|
||||
|
||||
+5
-3
@@ -3,6 +3,7 @@
|
||||
$executionCount = method_exists($executions, 'total') ? $executions->total() : $executions->count();
|
||||
$currentPage = method_exists($executions, 'currentPage') ? $executions->currentPage() : 1;
|
||||
$lastPage = method_exists($executions, 'lastPage') ? $executions->lastPage() : 1;
|
||||
$server = $backup->server();
|
||||
@endphp
|
||||
|
||||
<div wire:poll.5000ms="$refresh">
|
||||
@@ -82,12 +83,13 @@
|
||||
<x-forms.copy-input :text="$execution->filename ?? 'No archive name'" />
|
||||
</span>
|
||||
|
||||
<span class="text-[11px] text-neutral-500 dark:text-fg-faint">
|
||||
<span class="text-[11px] text-neutral-500 dark:text-fg-faint"
|
||||
title="Started: {{ formatDateInServerTimezone($execution->created_at, $server) }}@if ($execution->status !== 'running') Ended: {{ formatDateInServerTimezone($finishedAt, $server) }}@endif">
|
||||
@if ($execution->status === 'running')
|
||||
Running for {{ calculateDuration($execution->created_at, now()) }}
|
||||
@else
|
||||
{{ $finishedAt->diffForHumans() }}<br>
|
||||
{{ calculateDuration($execution->created_at, $finishedAt) }}
|
||||
<span class="block text-black dark:text-fg">{{ formatDateInServerTimezone($finishedAt, $server) }}</span>
|
||||
{{ $finishedAt->diffForHumans() }} · {{ calculateDuration($execution->created_at, $finishedAt) }}
|
||||
@endif
|
||||
</span>
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\Project\Database\BackupExecutions as DatabaseBackupExecutions;
|
||||
use App\Livewire\Project\Service\BackupExecutions as ServiceBackupExecutions;
|
||||
use App\Models\Environment;
|
||||
use App\Models\InstanceSettings;
|
||||
use App\Models\Project;
|
||||
use App\Models\ScheduledDatabaseBackup;
|
||||
use App\Models\ScheduledDatabaseBackupExecution;
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use App\Models\ServiceDatabase;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Livewire\Livewire;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
config(['app.maintenance.driver' => 'file']);
|
||||
Server::flushIdentityMap();
|
||||
InstanceSettings::unguarded(fn () => InstanceSettings::firstOrCreate(['id' => 0]));
|
||||
|
||||
$team = Team::factory()->create();
|
||||
$user = User::factory()->create();
|
||||
$user->teams()->attach($team, ['role' => 'owner']);
|
||||
|
||||
$server = Server::factory()->create(['team_id' => $team->id]);
|
||||
$server->settings->update(['server_timezone' => 'Europe/Budapest']);
|
||||
$destination = StandaloneDocker::where('server_id', $server->id)->firstOrFail();
|
||||
$project = Project::factory()->create(['team_id' => $team->id]);
|
||||
$environment = Environment::factory()->create(['project_id' => $project->id]);
|
||||
$this->service = Service::factory()->create([
|
||||
'server_id' => $server->id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
'environment_id' => $environment->id,
|
||||
]);
|
||||
$database = ServiceDatabase::create([
|
||||
'service_id' => $this->service->id,
|
||||
'name' => 'timestamps-db',
|
||||
'image' => 'postgres:16-alpine',
|
||||
'custom_type' => 'postgresql',
|
||||
]);
|
||||
$this->backup = ScheduledDatabaseBackup::create([
|
||||
'team_id' => $team->id,
|
||||
'frequency' => '0 0 * * *',
|
||||
'database_id' => $database->id,
|
||||
'database_type' => $database->getMorphClass(),
|
||||
]);
|
||||
|
||||
$this->travelTo(Carbon::parse('2026-10-16 14:00:00', 'UTC'));
|
||||
ScheduledDatabaseBackupExecution::create([
|
||||
'scheduled_database_backup_id' => $this->backup->id,
|
||||
'status' => 'success',
|
||||
'filename' => '/data/coolify/backups/timestamps.dmp',
|
||||
'finished_at' => Carbon::parse('2026-10-16 14:30:05', 'UTC'),
|
||||
]);
|
||||
$this->travelTo(Carbon::parse('2026-10-16 18:00:00', 'UTC'));
|
||||
|
||||
$this->actingAs($user);
|
||||
session(['currentTeam' => $team]);
|
||||
});
|
||||
|
||||
it('shows the exact finish time of database backup executions in the server timezone', function () {
|
||||
Livewire::test(DatabaseBackupExecutions::class, ['backup' => $this->backup])
|
||||
->call('refreshBackupExecutions')
|
||||
->assertSee('2026-10-16 16:30:05 CEST')
|
||||
->assertSee('Started: 2026-10-16 16:00:00 CEST', false)
|
||||
->assertSee('3 hours ago');
|
||||
});
|
||||
|
||||
it('shows the exact start time of service backup executions in the server timezone', function () {
|
||||
Livewire::test(ServiceBackupExecutions::class, ['service' => $this->service])
|
||||
->assertSee('2026-10-16 16:00:00 CEST')
|
||||
->assertSee('4 hours ago');
|
||||
});
|
||||
@@ -749,16 +749,21 @@ it('renders volume backup executions like database backup executions', function
|
||||
'team_id' => $team->id,
|
||||
'frequency' => 'daily',
|
||||
]);
|
||||
$this->travelTo(Carbon::parse('2026-10-16 14:00:00', 'UTC'));
|
||||
ScheduledVolumeBackupExecution::create([
|
||||
'scheduled_volume_backup_id' => $backup->id,
|
||||
'status' => 'success',
|
||||
'filename' => '/data/coolify/backups/volumes/test/archive.tar.gz',
|
||||
'size' => 1024,
|
||||
'finished_at' => now(),
|
||||
'finished_at' => Carbon::parse('2026-10-16 14:30:05', 'UTC'),
|
||||
]);
|
||||
$this->travelTo(Carbon::parse('2026-10-16 18:00:00', 'UTC'));
|
||||
|
||||
Livewire::test(VolumeBackups::class, ['storage' => $volume, 'resource' => $application, 'section' => 'executions'])
|
||||
->assertSet('timezone', 'Europe/Budapest')
|
||||
->assertSee('2026-10-16 16:30:05 CEST')
|
||||
->assertSee('Started: 2026-10-16 16:00:00 CEST', false)
|
||||
->assertSee('3 hours ago')
|
||||
->assertSeeInOrder([
|
||||
'Executions',
|
||||
'Status',
|
||||
|
||||
Reference in New Issue
Block a user