diff --git a/MoonlightServers.Frontend/UI/Views/User/Manage.razor b/MoonlightServers.Frontend/UI/Views/User/Manage.razor new file mode 100644 index 0000000..3bf4796 --- /dev/null +++ b/MoonlightServers.Frontend/UI/Views/User/Manage.razor @@ -0,0 +1,156 @@ +@page "/servers/{ServerId:int}" + +@using MoonlightServers.Shared.Http.Responses.Users.Servers +@using MoonCore.Blazor.Tailwind.Components +@using MoonCore.Exceptions +@using MoonCore.Helpers + +@inject HttpApiClient ApiClient + + + @if (NotFound) + { +
Not found illustration +

Server not found

+

+ The server you requested does not exist +

+
+ } + else + { +
+
+
+ +
+ + +
+
+
+ @if (!string.IsNullOrEmpty(CurrentTask)) + { + + } + +
+ + + Start + + + +
+
+
+ +
+ +
+ } +
+ +@code +{ + [Parameter] public int ServerId { get; set; } + + private ServerDetailResponse Server; + private bool NotFound = false; + + private string CurrentTask = ""; + + private async Task Load(LazyLoader _) + { + try + { + Server = await ApiClient.GetJson( + $"api/servers/{ServerId}" + ); + } + catch (HttpApiException e) + { + if (e.Status == 404) + NotFound = false; + else + throw; + } + } + + private async Task DoSmth() + { + await AddTask("Creating storage"); + await Task.Delay(1500); + + await AddTask("Pulling docker image"); + await Task.Delay(1500); + + await AddTask("Removing container"); + await Task.Delay(1500); + + await AddTask("Creating container"); + await Task.Delay(1500); + + await AddTask("Starting container"); + await Task.Delay(1500); + } + + private async Task AddTask(string message) + { + CurrentTask = message; + await InvokeAsync(StateHasChanged); + + Task.Run(async () => + { + await Task.Delay(2000); + + if (CurrentTask != message) + return; + + CurrentTask = ""; + await InvokeAsync(StateHasChanged); + }); + } +}