Implemented container helper status checked. Started implementing container helper ui. Improved update modal
This commit is contained in:
@@ -2,14 +2,12 @@
|
||||
|
||||
@using System.Text.Json
|
||||
@using LucideBlazor
|
||||
@using Moonlight.Shared.Http
|
||||
@using Moonlight.Shared.Http.Events
|
||||
@using ShadcnBlazor.Buttons
|
||||
@using ShadcnBlazor.Dialogs
|
||||
@using ShadcnBlazor.Extras.AlertDialogs
|
||||
@using ShadcnBlazor.Progresses
|
||||
@using ShadcnBlazor.Spinners
|
||||
|
||||
@inject AlertDialogService AlertService
|
||||
@inject HttpClient HttpClient
|
||||
|
||||
<DialogHeader>
|
||||
@@ -62,46 +60,57 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Progress Value="@Progress"></Progress>
|
||||
</DialogFooter>
|
||||
@if (CurrentStep == Steps.Length)
|
||||
{
|
||||
<DialogFooter ClassName="justify-end">
|
||||
<Button Variant="ButtonVariant.Outline" @onclick="CloseAsync">Close</Button>
|
||||
</DialogFooter>
|
||||
}
|
||||
else
|
||||
{
|
||||
<DialogFooter>
|
||||
<Progress ClassName="my-1" Value="@Progress"></Progress>
|
||||
</DialogFooter>
|
||||
}
|
||||
|
||||
@code
|
||||
{
|
||||
private int Progress = 0;
|
||||
|
||||
private int Progress;
|
||||
private int CurrentStep;
|
||||
|
||||
private string[] Steps =
|
||||
private readonly string[] Steps =
|
||||
[
|
||||
"Preparing",
|
||||
"Updating configuration files",
|
||||
"Starting rebuild task",
|
||||
"Building docker image",
|
||||
"Redeploying container instance",
|
||||
"Waiting for container instance to start up",
|
||||
"Update complete"
|
||||
"Checking", // 0
|
||||
"Updating configuration files", // 1
|
||||
"Starting rebuild task", // 2
|
||||
"Building docker image", // 3
|
||||
"Redeploying container instance", // 4
|
||||
"Waiting for container instance to start up", // 5
|
||||
"Update complete" // 6
|
||||
];
|
||||
|
||||
private List<string?> LogLines = new();
|
||||
private readonly List<string?> LogLines = new();
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!firstRender)
|
||||
return;
|
||||
|
||||
// Checking
|
||||
CurrentStep = 0;
|
||||
Progress = 0;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
await Task.Delay(2000);
|
||||
|
||||
// Update configuration
|
||||
CurrentStep = 1;
|
||||
Progress = 20;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
await Task.Delay(2000);
|
||||
|
||||
// Starting rebuild task
|
||||
CurrentStep = 2;
|
||||
Progress = 30;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
@@ -140,20 +149,22 @@
|
||||
switch (deserializedData.Data)
|
||||
{
|
||||
case "BuildImage":
|
||||
|
||||
// Building docker image
|
||||
|
||||
CurrentStep = 3;
|
||||
Progress = 40;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
break;
|
||||
|
||||
case "ServiceDown":
|
||||
|
||||
// Redeploying container instance
|
||||
|
||||
CurrentStep = 4;
|
||||
Progress = 60;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
break;
|
||||
|
||||
case "ServiceUp":
|
||||
CurrentStep = 4;
|
||||
Progress = 80;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
break;
|
||||
}
|
||||
@@ -163,17 +174,21 @@
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
// TODO: Log
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
|
||||
// Waiting for container instance to start up
|
||||
|
||||
CurrentStep = 5;
|
||||
Progress = 90;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
// Wait some time for instance to shut down
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
|
||||
// Ping instance until its reachable again
|
||||
while (true)
|
||||
{
|
||||
@@ -186,21 +201,13 @@
|
||||
{
|
||||
// Ignored
|
||||
}
|
||||
|
||||
|
||||
await Task.Delay(3000);
|
||||
}
|
||||
|
||||
CurrentStep = 6;
|
||||
|
||||
// Update complete
|
||||
CurrentStep = 7;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user