1
0
mirror of synced 2024-11-28 00:20:53 +01:00

Merge branch 'JP_April_2023' of https://github.com/asesidaa/TaikoLocalServer into Refactor

This commit is contained in:
asesidaa 2024-03-10 17:27:12 +08:00
commit 0cfa5f2033
18 changed files with 245 additions and 188 deletions

View File

@ -1,6 +1,6 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>

View File

@ -5,93 +5,91 @@
@inject NavigationManager NavigationManager
@inject IStringUtil StringUtil
<MudBreadcrumbs Items="breadcrumbs" Class="px-0"></MudBreadcrumbs>
<MudText Typo="Typo.h4">Access Code Management</MudText>
<MudText Typo="Typo.caption">User ID: @Baid</MudText>
<div class="mt-8">
@if (response is null)
@if (response is not null)
{
@if ((LoginService.LoginRequired && (!LoginService.IsLoggedIn || (LoginService.GetLoggedInUser().Baid != Baid && !LoginService.IsAdmin))) || User is null)
{
<MudGrid>
<MudItem xs="12">
<MudProgressCircular Size="Size.Large" Color="Color.Primary" />
</MudItem>
</MudGrid>
}
else
{
@if ((LoginService.LoginRequired && (!LoginService.IsLoggedIn || (LoginService.GetLoggedInUser().Baid != Baid && !LoginService.IsAdmin))) || User is null)
if (!LoginService.IsLoggedIn)
{
<MudItem xs="12">
<MudText Align="Align.Center" Class="my-8">
You are not authorized to see this page. Please log in by clicking on "Users" tab first.
</MudText>
</MudItem>
NavigationManager.NavigateTo("/Login");
}
else
{
<MudCard Outlined="true" Class="mb-6">
<MudCardContent>
<MudGrid Spacing="3">
<MudItem xs="12">
<MudText Typo="Typo.h6">Bind New Access Code</MudText>
<MudText Typo="Typo.body1">
Enter a new access code to bind to this user account.
</MudText>
<MudForm @ref="bindAccessCodeForm">
<MudGrid Spacing="2" Class="mt-4">
<MudItem xs="12" md="10">
<MudTextField @bind-value="inputAccessCode" InputType="InputType.Text" T="string"
FullWidth="true" Required="@true" RequiredError="Access Code is required" Variant="Variant.Outlined" Margin="Margin.Dense"
Label="New Access Code" />
</MudItem>
<MudItem xs="12" md="2">
<MudButton OnClick="OnBind" FullWidth="true" StartIcon="@Icons.Material.Filled.AddCard" Color="Color.Primary" Variant="Variant.Filled" Class="mt-1">Bind</MudButton>
</MudItem>
</MudGrid>
</MudForm>
</MudItem>
</MudGrid>
</MudCardContent>
</MudCard>
<MudCard Outlined="true">
<MudCardContent>
<MudGrid Spacing="3" Class="pb-2">
<MudItem xs="12">
<MudText Typo="Typo.h6">Access Codes</MudText>
</MudItem>
@for (var idx = 0; idx < User.AccessCodes.Count; idx++)
{
var accessCode = User.AccessCodes[idx];
var localIdx = idx + 1;
NavigationManager.NavigateTo("/");
}
}
else
{
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">Access Codes</MudText>
<MudText Typo="Typo.caption">User ID: @Baid</MudText>
<MudGrid Class="my-4 pb-10">
<MudItem xs="12">
<MudCard Outlined="true" Class="mb-6">
<MudCardContent>
<MudGrid Spacing="3">
<MudItem xs="12">
<div Style="border-bottom:1px solid #eee; padding: 5px 0;">
<MudGrid Spacing="2" Class="d-flex align-center">
<MudItem xs="12" md="8" Class="d-flex align-center">
<pre class="mb-0" style="font-size:16px">
@foreach (var digitGroup in StringUtil.SplitIntoGroups(accessCode, 4))
{
<span class="mr-2">@digitGroup</span>
}
</pre>
<MudText Typo="Typo.h6">Add Access Code</MudText>
<MudForm @ref="bindAccessCodeForm">
<MudGrid Spacing="2" Class="mt-4">
<MudItem xs="12" md="10">
<MudTextField @bind-value="inputAccessCode" InputType="InputType.Text" T="string"
FullWidth="true" Required="@true" RequiredError="Access Code is required" Variant="Variant.Outlined" Margin="Margin.Dense"
Label="New Access Code" />
</MudItem>
<MudItem xs="12" md="4" Class="d-flex justify-end">
<MudButton OnClick="@(_ => DeleteAccessCode(accessCode))"
Size="Size.Small" Variant="Variant.Text" StartIcon="@Icons.Material.Filled.Delete"
Color="Color.Error">
@Localizer["Delete"]
</MudButton>
<MudItem xs="12" md="2">
<MudButton OnClick="OnBind" FullWidth="true" StartIcon="@Icons.Material.Filled.AddCard" Color="Color.Primary" Variant="Variant.Filled" Class="mt-1">Add</MudButton>
</MudItem>
</MudGrid>
</MudForm>
</MudItem>
</MudGrid>
</MudCardContent>
</MudCard>
<MudCard Outlined="true">
<MudCardContent>
<MudGrid Spacing="3" Class="pb-2">
<MudItem xs="12">
<MudText Typo="Typo.h6">Access Codes</MudText>
</MudItem>
@for (var idx = 0; idx < User.AccessCodes.Count; idx++)
{
var accessCode = User.AccessCodes[idx];
var localIdx = idx + 1;
<MudItem xs="12" Class="py-0">
<div Style="border-bottom:1px solid #eee; padding: 5px 0;">
<MudGrid Spacing="2" Class="d-flex align-center">
<MudItem xs="12" md="8" Class="d-flex align-center">
<pre class="mb-0" style="font-size:16px">
@foreach (var digitGroup in StringUtil.SplitIntoGroups(accessCode, 4))
{
<span class="mr-2">@digitGroup</span>
}
</pre>
</MudItem>
<MudItem xs="12" md="4" Class="d-flex justify-end">
<MudButton OnClick="@(_ => DeleteAccessCode(accessCode))"
Size="Size.Small" Variant="Variant.Text" StartIcon="@Icons.Material.Filled.Delete"
Color="Color.Error">
@Localizer["Delete"]
</MudButton>
</MudItem>
</MudGrid>
</div>
</MudItem>
}
</MudGrid>
</MudCardContent>
</MudCard>
}
}
</div>
}
</MudGrid>
</MudCardContent>
</MudCard>
</MudItem>
</MudGrid>
}
}
else
{
<MudContainer Style="display:flex;margin:50px 0;align-items:center;justify-content:center;">
<MudProgressCircular Indeterminate="true" Size="Size.Large" Color="Color.Primary" />
</MudContainer>
}

View File

@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Http;
using System.Linq;
using TaikoWebUI.Pages.Dialogs;
using TaikoWebUI.Pages.Dialogs;
namespace TaikoWebUI.Pages;
@ -15,18 +13,27 @@ public partial class AccessCode
private User? User { get; set; } = new();
private DashboardResponse? response;
private UserSetting? userSetting;
private readonly List<BreadcrumbItem> breadcrumbs = new()
{
new BreadcrumbItem("Users", href: "/Users"),
};
private readonly List<BreadcrumbItem> breadcrumbs = new();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
await InitializeUser();
breadcrumbs.Add(new BreadcrumbItem($"User: {Baid}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem("Access Code Management", href: $"/Users/{Baid}/AccessCode", disabled: false));
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
if (LoginService.IsLoggedIn && !LoginService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem("Dashboard", href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem("Users", href: "/Users"));
};
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem("Access Codes", href: $"/Users/{Baid}/AccessCode", disabled: false));
}
private async Task InitializeUser()

View File

@ -11,11 +11,18 @@
<MudCard Outlined="true">
<MudCardHeader>
<CardHeaderContent>
<div style="display:flex;flex-wrap:wrap;gap:5px;">
<MudText Typo="Typo.h6" Style="font-weight:bold;word-break:break-all">@userSetting?.MyDonName</MudText>
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:5px;">
@if (userSetting is not null)
{
<MudText Typo="Typo.h6" Style="font-weight:bold;word-break:break-all">@userSetting?.MyDonName</MudText>
} else
{
<MudSkeleton Width="35%" Height="32px" />
}
@if (user?.IsAdmin == true)
{
<MudChip Color="Color.Secondary" Size="Size.Small">@Localizer["Admin"]</MudChip>
<MudChip Variant="Variant.Outlined" Color="Color.Info" Size="Size.Small" Icon="@Icons.Material.TwoTone.AdminPanelSettings">@Localizer["Admin"]</MudChip>
}
</div>
<MudText Typo="Typo.caption">User ID: @user?.Baid</MudText>
@ -47,11 +54,11 @@
}
@if (LoginService.LoginRequired && LoginService.IsAdmin)
{
<MudMenuItem Icon="@Icons.Material.Filled.Lock"
<MudMenuItem Icon="@Icons.Material.Filled.LockReset"
OnClick="@(_ => ResetPassword(user))"
OnTouch="@(_ => ResetPassword(user))"
IconColor="@Color.Primary">
@Localizer["Reset Password"]
@Localizer["Unregister"]
</MudMenuItem>
<MudDivider />
}

View File

@ -2,21 +2,25 @@
@inject HttpClient Client
@inject LoginService LoginService
@inject IJSRuntime JSRuntime
@inject NavigationManager NavigationManager
@page "/Users/{baid:int}/DaniDojo"
<MudBreadcrumbs Items="breadcrumbs" Class="px-0"></MudBreadcrumbs>
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Key_03"]</MudText>
<MudText Typo="Typo.caption">User ID: @Baid</MudText>
@if (LoginService.LoginRequired && (!LoginService.IsLoggedIn || (LoginService.GetLoggedInUser().Baid != Baid && !LoginService.IsAdmin)))
{
<MudItem xs="12">
<MudText Align="Align.Center" Class="my-8">
@Localizer["Key_02"]
</MudText>
</MudItem>
if (!LoginService.IsLoggedIn)
{
NavigationManager.NavigateTo("/Login");
}
else
{
NavigationManager.NavigateTo("/");
}
}
else
{

View File

@ -14,10 +14,7 @@ public partial class DaniDojo
private static Dictionary<uint, DanBestData> bestDataMap = new();
private readonly List<BreadcrumbItem> breadcrumbs = new()
{
new BreadcrumbItem("Users", href: "/Users"),
};
private readonly List<BreadcrumbItem> breadcrumbs = new();
protected override async Task OnInitializedAsync()
{
@ -33,6 +30,14 @@ public partial class DaniDojo
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
if (LoginService.IsLoggedIn && !LoginService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem("Dashboard", href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem("Users", href: "/Users"));
};
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem("Dani Dojo", href: $"/Users/{Baid}/DaniDojo", disabled: false));
}

View File

@ -2,15 +2,14 @@
@inject HttpClient Client
@inject LoginService LoginService
@inject IJSRuntime JSRuntime
@inject NavigationManager NavigationManager
@page "/Users/{baid:int}/HighScores"
<MudBreadcrumbs Items="breadcrumbs" Class="px-0"></MudBreadcrumbs>
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Key_01"]</MudText>
<MudText Typo="Typo.caption">User ID: @Baid</MudText>
<MudGrid Class="my-8">
@if (response is null)
{
@ -24,11 +23,14 @@
{
@if (LoginService.LoginRequired && (!LoginService.IsLoggedIn || (LoginService.GetLoggedInUser().Baid != Baid && !LoginService.IsAdmin)))
{
<MudItem xs="12">
<MudText Align="Align.Center" Class="my-8">
@Localizer["Key_02"]
</MudText>
</MudItem>
if (!LoginService.IsLoggedIn)
{
NavigationManager.NavigateTo("/Login");
}
else
{
NavigationManager.NavigateTo("/");
}
}
else
{

View File

@ -16,10 +16,7 @@ public partial class HighScores
private Dictionary<Difficulty, List<SongBestData>> songBestDataMap = new();
private readonly List<BreadcrumbItem> breadcrumbs = new()
{
new BreadcrumbItem("Users", href: "/Users"),
};
private readonly List<BreadcrumbItem> breadcrumbs = new();
protected override async Task OnInitializedAsync()
{
@ -48,7 +45,14 @@ public partial class HighScores
.CompareTo(GameDataService.GetMusicIndexBySongId(data2.SongId)));
}
if (LoginService.IsLoggedIn && !LoginService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem("Dashboard", href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem("Users", href: "/Users"));
};
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem("High Scores", href: $"/Users/{Baid}/HighScores", disabled: false));
}

View File

@ -5,41 +5,37 @@
@page "/Login"
<MudGrid Class="my-8">
@if (!LoginService.IsLoggedIn) // Not logged in, show login form
{
<MudContainer>
<MudGrid Justify="Justify.Center">
<MudItem xs="12" md="6" lg="4" class="mt-8">
<MudCard Elevation="0" Outlined="true">
<MudCardContent>
<MudForm @ref="loginForm">
<MudText Typo="Typo.h5" Class="mb-4">Login</MudText>
<div style="display:flex;flex-direction:column;gap:15px;">
<MudTextField @bind-value="inputAccessCode" InputType="InputType.Text" T="string"
FullWidth="true" Required="@true" RequiredError="Access code is required"
Label="Access code" Variant="Variant.Outlined" Margin="Margin.Dense" />
<MudTextField @bind-Value="inputPassword" InputType="InputType.Password"
T="string" FullWidth="true" Required="@true"
RequiredError="Password is required"
Label="Password" Variant="Variant.Outlined" Margin="Margin.Dense" />
<MudStack Row="true" Class="mt-2">
<MudButton OnClick="OnLogin" FullWidth="true" StartIcon="@Icons.Material.Filled.Login" Color="Color.Primary" Variant="Variant.Filled">Login</MudButton>
@if (!LoginService.OnlyAdmin)
{
<MudButton Href="@("/Register")" FullWidth="true" StartIcon="@Icons.Material.Filled.AddCard" Color="Color.Primary" Variant="Variant.Filled">Register</MudButton>
}
</MudStack>
</div>
</MudForm>
</MudCardContent>
</MudCard>
</MudItem>
</MudGrid>
</MudContainer>
} else
{
// Already logged in
NavigationManager.NavigateTo("/");
}
</MudGrid>
@if (!LoginService.IsLoggedIn)
{
// Not logged in, show login form
<MudContainer>
<MudGrid Justify="Justify.Center">
<MudItem xs="12" md="6" lg="4">
<MudCard Elevation="0" Outlined="true">
<MudCardHeader>
<MudText Typo="Typo.h5">@Localizer["Log In"]</MudText>
</MudCardHeader>
<MudCardContent>
<MudForm @ref="loginForm">
<div style="display:flex;flex-direction:column;gap:15px;">
<MudTextField @bind-value="inputAccessCode" InputType="InputType.Text" T="string"
FullWidth="true" Required="@true" RequiredError="Access code is required"
Label="Access Code" Variant="Variant.Outlined" Margin="Margin.Dense" />
<MudTextField @bind-Value="inputPassword" InputType="InputType.Password"
T="string" FullWidth="true" Required="@true"
RequiredError="Password is required"
Label="Password" Variant="Variant.Outlined" Margin="Margin.Dense" />
<MudButton OnClick="OnLogin" FullWidth="true" StartIcon="@Icons.Material.Filled.Login" Color="Color.Primary" Variant="Variant.Filled">@Localizer["Log In"]</MudButton>
</div>
</MudForm>
</MudCardContent>
</MudCard>
</MudItem>
</MudGrid>
</MudContainer>
} else
{
// Already logged in, redirect to Dashboard
NavigationManager.NavigateTo("/");
}

View File

@ -4,23 +4,26 @@
@inject IDialogService DialogService
@inject LoginService LoginService
@inject IJSRuntime Js
<MudBreadcrumbs Items="breadcrumbs" Class="px-0"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Profile"]</MudText>
<MudText Typo="Typo.caption">User ID: @Baid</MudText>
@inject NavigationManager NavigationManager
@if (response is not null)
{
@if (LoginService.LoginRequired && (!LoginService.IsLoggedIn || (LoginService.GetLoggedInUser().Baid != Baid && !LoginService.IsAdmin)))
{
<MudItem xs="12">
<MudText Align="Align.Center" Class="my-8">
@Localizer["Key_02"]
</MudText>
</MudItem>
if (!LoginService.IsLoggedIn)
{
NavigationManager.NavigateTo("/Login");
}
else
{
NavigationManager.NavigateTo("/");
}
}
else
{
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Profile"]</MudText>
<MudText Typo="Typo.caption">User ID: @Baid</MudText>
<MudGrid Class="my-4 pb-10">
<MudItem xs="12" md="8">
<MudPaper Elevation="0" Outlined="true">
@ -448,6 +451,12 @@
</MudGrid>
}
}
else
{
<MudContainer Style="display:flex;margin:50px 0;align-items:center;justify-content:center;">
<MudProgressCircular Indeterminate="true" Size="Size.Large" Color="Color.Primary" />
</MudContainer>
}
@code {
private async Task UpdateMyDonName()

View File

@ -1,8 +1,4 @@
using Microsoft.AspNetCore.Http;
using SharedProject.Enums;
using System.Linq;
using TaikoWebUI.Pages.Dialogs;
using static MudBlazor.CategoryTypes;
using TaikoWebUI.Pages.Dialogs;
namespace TaikoWebUI.Pages;
@ -168,10 +164,7 @@ public partial class Profile
"Not cleared", "Not Full Combo", "Not Donderful Combo"
};
private readonly List<BreadcrumbItem> breadcrumbs = new()
{
new BreadcrumbItem("Users", href: "/Users"),
};
private readonly List<BreadcrumbItem> breadcrumbs = new();
private Dictionary<Difficulty, List<SongBestData>> songBestDataMap = new();
@ -194,6 +187,14 @@ public partial class Profile
response = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
response.ThrowIfNull();
if (LoginService.IsLoggedIn && !LoginService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem("Dashboard", href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem("Users", href: "/Users"));
};
breadcrumbs.Add(new BreadcrumbItem($"{response.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem("Profile", href: $"/Users/{Baid}/Profile", disabled: false));
@ -243,6 +244,12 @@ public partial class Profile
isSavingOptions = true;
await Client.PostAsJsonAsync($"api/UserSettings/{Baid}", response);
isSavingOptions = false;
// Adjust breadcrumb if name is changed
if (response != null && response.MyDonName != null)
{
breadcrumbs[^2] = new BreadcrumbItem($"{response.MyDonName}", href: null, disabled: true);
}
}
private void UpdateScores(Difficulty difficulty)

View File

@ -7,17 +7,25 @@
@if (LoginService.OnlyAdmin || !LoginService.LoginRequired)
{
<MudText Typo="Typo.body1">Registration is currently closed.</MudText>
Console.WriteLine("Registration is disabled. Redirecting to Dashboard...");
NavigationManager.NavigateTo("/");
}
else if (LoginService.IsLoggedIn)
{
// User is already logged in. Redirect to dashboard.
NavigationManager.NavigateTo("/");
}
else
{
<MudContainer>
<MudGrid Justify="Justify.Center">
<MudItem xs="12" md="6" lg="4" class="mt-8">
<MudItem xs="12" md="6" lg="4">
<MudCard Elevation="0" Outlined="true">
<MudCardHeader>
<MudText Typo="Typo.h5">Register</MudText>
</MudCardHeader>
<MudCardContent>
<MudForm @ref="registerForm">
<MudText Typo="Typo.h5" Class="mb-4">Register</MudText>
<div style="display:flex;flex-direction:column;gap:15px;">
<MudTextField @bind-value="accessCode" InputType="InputType.Text" T="string"
FullWidth="true" Required="@true" RequiredError="Access Code is required"

View File

@ -34,14 +34,14 @@ public partial class Register
"Error",
"Only admin can log in.",
"Ok", null, null, options);
NavigationManager.NavigateTo("/Dashboard");
NavigationManager.NavigateTo("/");
break;
case 1:
await DialogService.ShowMessageBox(
"Success",
"Access code registered successfully.",
"Ok", null, null, options);
NavigationManager.NavigateTo("/Users");
NavigationManager.NavigateTo("/Login");
break;
case 2:
await DialogService.ShowMessageBox(
@ -62,7 +62,7 @@ public partial class Register
(MarkupString)
"Access code is already registered, please use set password to login.",
"Ok", null, null, options);
NavigationManager.NavigateTo("/Users");
NavigationManager.NavigateTo("/Login");
break;
case 5:
await DialogService.ShowMessageBox(

View File

@ -25,16 +25,14 @@
}
else
{
// Not admin, redirect
@if (!LoginService.IsLoggedIn) // Not logged in, show login form
{
NavigationManager.NavigateTo("/Login");
}
else
{
var user = LoginService.GetLoggedInUser(); // Logged in, show only own user
<MudItem xs="12" md="6" lg="4">
<UserCard user="user" />
</MudItem>
NavigationManager.NavigateTo("/");
}
}
}
@ -49,7 +47,7 @@
} else
{
// Loading...
@for (uint i = 0; i < 3; i++)
@for (uint i = 0; i < 6; i++)
{
<MudItem xs="12" md="6" lg="4">
<MudCard Outlined="true">

View File

@ -40,6 +40,9 @@ public class LoginService
public int Login(string inputCardNum, string inputPassword, DashboardResponse response)
{
// strip spaces or dashes from card number
inputCardNum = inputCardNum.Replace(" ", "").Replace("-", "");
foreach (var user in response.Users.Where(user => user.AccessCodes.Contains(inputCardNum)))
{
foreach (var userCredential in response.UserCredentials.Where(userCredential => userCredential.Baid == user.Baid))
@ -64,6 +67,9 @@ public class LoginService
{
if (OnlyAdmin) return 0;
// strip spaces or dashes from card number
inputCardNum = inputCardNum.Replace(" ", "").Replace("-", "");
foreach (var user in response.Users.Where(user => user.AccessCodes.Contains(inputCardNum)))
{
foreach (var userCredential in response.UserCredentials.Where(userCredential => userCredential.Baid == user.Baid))

View File

@ -5,7 +5,7 @@
@inject IJSRuntime JSRuntime
@inject IOptions<WebUiSettings> Settings
<MudMenu Icon="@Icons.Material.Filled.Language" Color="Color.Inherit">
<MudMenu Icon="@Icons.Material.Filled.Translate" Color="Color.Inherit" Size="Size.Small" Dense="true">
@foreach (var culture in SupportedCultures)
{
<MudMenuItem OnClick="() => RequestCultureChange(culture.Key)">@culture.Value</MudMenuItem>

View File

@ -21,7 +21,7 @@
@Body
<MudScrollToTop>
<MudFab Color="Color.Secondary" Icon="@Icons.Material.Filled.ArrowCircleUp" />
<MudFab Color="Color.Secondary" StartIcon="@Icons.Material.Filled.ArrowCircleUp" />
</MudScrollToTop>
</MudContainer>
</MudMainContent>

View File

@ -16,7 +16,7 @@
if (LoginService.LoginRequired && !LoginService.OnlyAdmin && !LoginService.IsLoggedIn) {
<MudDivider />
<MudNavLink Href="/Login" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Login">@Localizer["Login"]</MudNavLink>
<MudNavLink Href="/Login" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Login">@Localizer["Log In"]</MudNavLink>
<MudNavLink Href="/Register" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.AddCard">@Localizer["Register"]</MudNavLink>
}
@ -28,7 +28,7 @@
<MudNavLink Href="@($"Users/{currentUser.Baid}/HighScores")" Match="NavLinkMatch.All">@Localizer["Key_01"]</MudNavLink>
<MudNavLink Href="@($"Users/{currentUser.Baid}/DaniDojo")" Match="NavLinkMatch.All">@Localizer["Key_03"]</MudNavLink>
</MudNavGroup>
<MudNavGroup Title="Settings" Expanded="false" Icon="@Icons.Material.Filled.Settings">
<MudNavGroup Title="Settings" Expanded="_settingsOpen" Icon="@Icons.Material.Filled.Settings">
<MudNavLink OnClick="ShowQrCode">@Localizer["Show QR Code"]</MudNavLink>
<MudNavLink Href="/ChangePassword" Match="NavLinkMatch.All">@Localizer["Change Password"]</MudNavLink>
<MudNavLink Href="@($"Users/{currentUser.Baid}/AccessCode")" Match="NavLinkMatch.All">@Localizer["Manage Access Codes"]</MudNavLink>
@ -45,6 +45,9 @@
</MudNavMenu>
@code {
private bool _settingsOpen = false;
protected override void OnInitialized()
{
LoginService.LoginStatusChanged += HandleLoginStatusChanged;
@ -72,6 +75,9 @@
var options = new DialogOptions() { DisableBackdropClick = true };
DialogService.Show<UserQrCodeDialog>("QR Code", parameters, options);
// Prevent the settings menu from closing
_settingsOpen = true;
}
private async Task Logout()