feat: implement JSON backup export functionality with improved download handling
All checks were successful
Publish Container / publish (push) Successful in 3m25s

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Marco 2026-04-24 14:16:15 +02:00
commit bf333c4a00
7 changed files with 96 additions and 5 deletions

View file

@ -76,7 +76,7 @@ else
<p class="text-muted mb-3">Export the full database as JSON or restore a previously exported JSON backup. Restore replaces the current database only when the backup format version and database schema version are supported.</p>
<div class="d-flex flex-wrap gap-2 align-items-center mb-4">
<a class="btn btn-outline-secondary" href="/api/database-backup/export">Export JSON backup</a>
<button class="btn btn-outline-secondary" type="button" @onclick="ExportAsync">Export JSON backup</button>
<span class="small text-muted">Current database schema version: @DatabaseSchemaVersion</span>
</div>
@ -193,4 +193,20 @@ else
isRestoring = false;
}
}
private async Task ExportAsync()
{
backupStatusMessage = null;
backupErrorMessage = null;
try
{
await JS.InvokeVoidAsync("workTrackerDownloads.downloadFromUrl", "/api/database-backup/export");
backupStatusMessage = $"Backup export started at {DateTime.Now:t}.";
}
catch (JSException)
{
backupErrorMessage = "Unable to start the backup download.";
}
}
}