2024-03-09 07:07:34 +01:00
|
|
|
@inject LoginService LoginService
|
|
|
|
@inject NavigationManager NavigationManager
|
|
|
|
@inject IDialogService DialogService
|
|
|
|
|
|
|
|
@using TaikoWebUI.Pages.Dialogs;
|
|
|
|
|
|
|
|
<MudNavMenu Rounded="true" Class="pa-2" Margin="Margin.Dense" Color="Color.Primary">
|
2024-01-21 18:13:13 +01:00
|
|
|
<MudNavLink Href="/" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Dashboard">@Localizer["dashboard"]</MudNavLink>
|
2024-03-09 07:07:34 +01:00
|
|
|
@if (LoginService.IsAdmin || !LoginService.LoginRequired)
|
|
|
|
{
|
|
|
|
<MudNavLink Href="/Users" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.People">@Localizer["Users"]</MudNavLink>
|
|
|
|
}
|
|
|
|
|
|
|
|
@{
|
|
|
|
var currentUser = LoginService.GetLoggedInUser();
|
|
|
|
|
|
|
|
if (LoginService.LoginRequired && !LoginService.OnlyAdmin && !LoginService.IsLoggedIn) {
|
|
|
|
<MudDivider />
|
2024-03-09 19:45:20 +01:00
|
|
|
<MudNavLink Href="/Login" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Login">@Localizer["Log In"]</MudNavLink>
|
2024-03-09 07:07:34 +01:00
|
|
|
<MudNavLink Href="/Register" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.AddCard">@Localizer["Register"]</MudNavLink>
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LoginService.IsLoggedIn && currentUser != null)
|
|
|
|
{
|
|
|
|
<MudDivider />
|
|
|
|
<MudNavLink Href="@($"Users/{currentUser.Baid}/Profile")" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Person">@Localizer["Profile"]</MudNavLink>
|
2024-03-09 07:46:48 +01:00
|
|
|
<MudNavGroup Title="Play Data" Expanded="true" Icon="@Icons.Material.Filled.EmojiEvents">
|
2024-03-10 04:48:26 +01:00
|
|
|
<MudNavLink Href="@($"Users/{currentUser.Baid}/Songs")" Match="NavLinkMatch.All">@Localizer["Key_01"]</MudNavLink>
|
2024-03-17 20:46:47 +01:00
|
|
|
<MudNavLink Href="@($"Users/{currentUser.Baid}/HighScores")" Match="NavLinkMatch.All">@Localizer["High Scores"]</MudNavLink>
|
2024-03-09 07:07:34 +01:00
|
|
|
<MudNavLink Href="@($"Users/{currentUser.Baid}/DaniDojo")" Match="NavLinkMatch.All">@Localizer["Key_03"]</MudNavLink>
|
|
|
|
</MudNavGroup>
|
2024-03-10 00:29:17 +01:00
|
|
|
<MudNavGroup Title="Settings" Expanded="_settingsOpen" Icon="@Icons.Material.Filled.Settings">
|
2024-03-09 07:07:34 +01:00
|
|
|
<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>
|
|
|
|
</MudNavGroup>
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LoginService.IsLoggedIn)
|
|
|
|
{
|
|
|
|
<MudDivider />
|
|
|
|
<MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Logout" IconColor="Color.Error" OnClick="Logout">@Localizer["Log Out"]</MudNavLink>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</MudNavMenu>
|
|
|
|
|
|
|
|
@code {
|
2024-03-10 00:29:17 +01:00
|
|
|
private bool _settingsOpen = false;
|
|
|
|
|
2024-03-09 07:07:34 +01:00
|
|
|
protected override void OnInitialized()
|
|
|
|
{
|
|
|
|
LoginService.LoginStatusChanged += HandleLoginStatusChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleLoginStatusChanged(object? sender, EventArgs e)
|
|
|
|
{
|
|
|
|
StateHasChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
|
|
{
|
|
|
|
if (firstRender)
|
|
|
|
{
|
|
|
|
LoginService.LoginStatusChanged += HandleLoginStatusChanged;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ShowQrCode()
|
|
|
|
{
|
|
|
|
var parameters = new DialogParameters
|
|
|
|
{
|
|
|
|
["user"] = LoginService.GetLoggedInUser()
|
|
|
|
};
|
|
|
|
|
|
|
|
var options = new DialogOptions() { DisableBackdropClick = true };
|
|
|
|
DialogService.Show<UserQrCodeDialog>("QR Code", parameters, options);
|
2024-03-10 00:29:17 +01:00
|
|
|
|
|
|
|
// Prevent the settings menu from closing
|
|
|
|
_settingsOpen = true;
|
2024-03-09 07:07:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private async Task Logout()
|
|
|
|
{
|
|
|
|
var result = await DialogService.ShowMessageBox(
|
|
|
|
"Log Out",
|
|
|
|
"Are you sure you want to log out?",
|
|
|
|
yesText: "Log Out",
|
|
|
|
noText: "Cancel");
|
|
|
|
|
|
|
|
if (result == true)
|
|
|
|
{
|
|
|
|
LoginService.Logout();
|
|
|
|
NavigationManager.NavigateTo("/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|