Added update model with progress animations. Backend not implemented

This commit is contained in:
2025-12-27 23:33:33 +01:00
parent 1581276854
commit ec6782160c
2 changed files with 128 additions and 1 deletions

View File

@@ -0,0 +1,119 @@
@inherits ShadcnBlazor.Extras.Dialogs.DialogBase
@using LucideBlazor
@using ShadcnBlazor.Dialogs
@using ShadcnBlazor.Extras.AlertDialogs
@using ShadcnBlazor.Progresses
@using ShadcnBlazor.Spinners
@inject AlertDialogService AlertService
<DialogHeader>
<DialogTitle>
Updating...
</DialogTitle>
</DialogHeader>
<div class="text-base flex flex-col p-2 gap-y-0.5">
@for (var i = 0; i < Steps.Length; i++)
{
if (CurrentStep == i)
{
<div class="flex flex-row items-center gap-x-2">
<Spinner ClassName="size-4" />
<span>
@Steps[i]
</span>
</div>
}
else
{
if (i < CurrentStep)
{
<div class="flex flex-row items-center gap-x-2">
<CheckIcon ClassName="text-green-500 size-4" />
<span>
@Steps[i]
</span>
</div>
}
else
{
<div class="text-muted-foreground flex flex-row items-center gap-x-2">
<span class="size-4"></span>
@Steps[i]
</div>
}
}
}
</div>
<DialogFooter>
<Progress Value="@Progress"></Progress>
</DialogFooter>
@code
{
private int Progress = 0;
private int CurrentStep;
private string[] Steps =
[
"Preparing",
"Updating configuration files",
"Building docker image",
"Redeploying container instance",
"Waiting for container instance to start up",
"Update complete"
];
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return;
CurrentStep = 0;
Progress = 0;
await InvokeAsync(StateHasChanged);
await Task.Delay(2000);
CurrentStep = 1;
Progress = 20;
await InvokeAsync(StateHasChanged);
await Task.Delay(6000);
CurrentStep = 2;
Progress = 40;
await InvokeAsync(StateHasChanged);
await Task.Delay(2000);
CurrentStep = 3;
Progress = 60;
await InvokeAsync(StateHasChanged);
await Task.Delay(4000);
CurrentStep = 4;
Progress = 80;
await InvokeAsync(StateHasChanged);
await Task.Delay(4000);
CurrentStep = 5;
Progress = 100;
await InvokeAsync(StateHasChanged);
await Task.Delay(1000);
await AlertService.SuccessAsync(
"Update completed",
"Update successfully completed. Please refresh the page to load new frontend changes"
);
await CloseAsync();
}
}