Initial commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
@using MudBlazor
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">Create Backup</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="BackupName"
|
||||
Label="Backup Name"
|
||||
Placeholder="Enter backup name"
|
||||
Required="true"
|
||||
RequiredError="Backup name is required"
|
||||
HelperText="Leave empty to use default timestamp name"
|
||||
Variant="Variant.Outlined"
|
||||
FullWidth="true"
|
||||
@onkeydown="HandleKeyDown" />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Cancel</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="Submit">Create</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] IMudDialogInstance Dialog { get; set; } = null!;
|
||||
|
||||
private string BackupName { get; set; } = string.Empty;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
// Default name based on current date/time: yyyy-MM-dd_HHmm
|
||||
BackupName = DateTime.Now.ToString("yyyy-MM-dd_HHmm");
|
||||
}
|
||||
|
||||
private void Cancel() => Dialog.Cancel();
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
var name = BackupName?.Trim() ?? string.Empty;
|
||||
|
||||
// If empty, use default timestamp
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
name = DateTime.Now.ToString("yyyy-MM-dd_HHmm");
|
||||
}
|
||||
|
||||
Dialog.Close(DialogResult.Ok(name));
|
||||
}
|
||||
|
||||
private void HandleKeyDown(KeyboardEventArgs e)
|
||||
{
|
||||
if (e.Key == "Enter")
|
||||
{
|
||||
Submit();
|
||||
}
|
||||
else if (e.Key == "Escape")
|
||||
{
|
||||
Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user