Started implementing setup wizard backend for initial instance configuration. Adjusted ui
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
@using LucideBlazor
|
||||
@using Moonlight.Shared.Http.Requests.Seup
|
||||
@using ShadcnBlazor.Cards
|
||||
@using ShadcnBlazor.Spinners
|
||||
@using ShadcnBlazor.Buttons
|
||||
@using ShadcnBlazor.Inputs
|
||||
@using ShadcnBlazor.Labels
|
||||
|
||||
@inject HttpClient HttpClient
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<div class="h-screen w-full flex items-center justify-center">
|
||||
<Card ClassName="w-full max-w-[calc(100%-2rem)] lg:max-w-xl grid gap-4 p-6">
|
||||
@if (!IsLoaded)
|
||||
@if (IsLoaded)
|
||||
{
|
||||
<div class="space-y-6">
|
||||
@if (CurrentStep == 0)
|
||||
@@ -43,14 +47,14 @@
|
||||
<div class="grid gap-2">
|
||||
<Label for="username">Username</Label>
|
||||
<InputField
|
||||
@bind-Value="Username"
|
||||
@bind-Value="SetupDto.AdminUsername"
|
||||
id="username"
|
||||
placeholder="someoneelse"/>
|
||||
</div>
|
||||
<div class="grid gap-2">
|
||||
<Label for="email">Email</Label>
|
||||
<InputField
|
||||
@bind-Value="Email"
|
||||
@bind-Value="SetupDto.AdminEmail"
|
||||
id="email"
|
||||
Type="email"
|
||||
placeholder="a@cool.email"/>
|
||||
@@ -58,7 +62,7 @@
|
||||
<div class="grid gap-2">
|
||||
<Label for="password">Password</Label>
|
||||
<InputField
|
||||
@bind-Value="Password"
|
||||
@bind-Value="SetupDto.AdminPassword"
|
||||
id="password"
|
||||
Type="password"
|
||||
placeholder="......."/>
|
||||
@@ -114,7 +118,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<Button>
|
||||
<Button @onclick="ApplyAsync">
|
||||
Finish
|
||||
<RocketIcon />
|
||||
</Button>
|
||||
@@ -134,14 +138,35 @@
|
||||
|
||||
@code
|
||||
{
|
||||
private bool IsLoaded = false;
|
||||
private bool IsLoaded;
|
||||
|
||||
private int CurrentStep = 0;
|
||||
private int StepCount = 3;
|
||||
|
||||
private string Email;
|
||||
private string Username;
|
||||
private string Password;
|
||||
private ApplySetupDto SetupDto = new();
|
||||
|
||||
private void Navigate(int diff) => CurrentStep += diff;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if(!firstRender)
|
||||
return;
|
||||
|
||||
var response = await HttpClient.GetAsync("api/admin/setup");
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
Navigation.NavigateTo("/", true);
|
||||
return;
|
||||
}
|
||||
|
||||
IsLoaded = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task ApplyAsync()
|
||||
{
|
||||
await HttpClient.PostAsJsonAsync("api/admin/setup", SetupDto);
|
||||
Navigation.NavigateTo("/", true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user