Initial commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
@using MudBlazor
|
||||
@using RobotNet10.ScriptEngine.Shared
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">Restore Backup</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
@if (Backups == null || Backups.Length == 0)
|
||||
{
|
||||
<MudText>No backups available.</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudSelect @bind-Value="SelectedBackup"
|
||||
Label="Select Backup"
|
||||
Variant="Variant.Outlined"
|
||||
FullWidth="true">
|
||||
@foreach (var backup in Backups)
|
||||
{
|
||||
<MudSelectItem Value="@backup.FileName">
|
||||
@backup.FileName - @backup.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss") (@FormatSize(backup.Size))
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Cancel</MudButton>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
OnClick="Submit"
|
||||
Disabled="@(Backups == null || Backups.Length == 0 || string.IsNullOrWhiteSpace(SelectedBackup))">
|
||||
Restore
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] IMudDialogInstance Dialog { get; set; } = null!;
|
||||
[Parameter] public ScriptBackupInfo[] Backups { get; set; } = Array.Empty<ScriptBackupInfo>();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user