@using MudBlazor
@using RobotNet10.ScriptEngine.Shared
Restore Backup
@if (Backups == null || Backups.Length == 0)
{
No backups available.
}
else
{
@foreach (var backup in Backups)
{
@backup.FileName - @backup.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss") (@FormatSize(backup.Size))
}
}
Cancel
Restore
@code {
[CascadingParameter] IMudDialogInstance Dialog { get; set; } = null!;
[Parameter] public ScriptBackupInfo[] Backups { get; set; } = Array.Empty();
private string? SelectedBackup { get; set; }
protected override void OnInitialized()
{
// Select first backup by default (newest)
if (Backups != null && Backups.Length > 0)
{
SelectedBackup = Backups[0].FileName;
}
}
private string FormatSize(long size)
{
if (size < 1024) return $"{size} B";
if (size < 1024 * 1024) return $"{size / 1024.0:F2} KB";
return $"{size / (1024.0 * 1024.0):F2} MB";
}
private void Cancel() => Dialog.Cancel();
private void Submit()
{
if (string.IsNullOrWhiteSpace(SelectedBackup))
{
return;
}
Dialog.Close(DialogResult.Ok(SelectedBackup));
}
}