2024-05-17 00:32:46 +02:00
|
|
|
@inject AuthService AuthService
|
2024-03-09 07:07:34 +01:00
|
|
|
@inject NavigationManager NavigationManager
|
|
|
|
@inject IDialogService DialogService
|
|
|
|
|
|
|
|
@using TaikoWebUI.Pages.Dialogs;
|
|
|
|
|
|
|
|
<MudNavMenu Rounded="true" Class="pa-2" Margin="Margin.Dense" Color="Color.Primary">
|
2024-05-01 17:13:47 +02:00
|
|
|
<MudNavLink Href="/" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Dashboard">@Localizer["Dashboard"]</MudNavLink>
|
2024-05-17 00:32:46 +02:00
|
|
|
@if (AuthService.IsAdmin || !AuthService.LoginRequired)
|
2024-03-09 07:07:34 +01:00
|
|
|
{
|
|
|
|
<MudNavLink Href="/Users" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.People">@Localizer["Users"]</MudNavLink>
|
|
|
|
}
|
|
|
|
|
|
|
|
@{
|
2024-05-17 00:32:46 +02:00
|
|
|
var baid = AuthService.GetLoggedInBaid();
|
|
|
|
|
|
|
|
if (AuthService.LoginRequired && !AuthService.OnlyAdmin && !AuthService.IsLoggedIn) {
|
2024-03-09 07:07:34 +01:00
|
|
|
<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>
|
|
|
|
}
|
|
|
|
|
2024-05-17 00:32:46 +02:00
|
|
|
if (AuthService.IsLoggedIn)
|
2024-03-09 07:07:34 +01:00
|
|
|
{
|
|
|
|
<MudDivider />
|
2024-05-17 00:32:46 +02:00
|
|
|
<MudNavLink Href="@($"Users/{baid}/Profile")" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Person">@Localizer["Profile"]</MudNavLink>
|
2024-05-01 17:13:47 +02:00
|
|
|
<MudNavGroup Title=@Localizer["Play Data"] Expanded="true" Icon="@Icons.Material.Filled.EmojiEvents">
|
2024-05-17 00:32:46 +02:00
|
|
|
<MudNavLink Href="@($"Users/{baid}/Songs")" Match="NavLinkMatch.All">@Localizer["Song List"]</MudNavLink>
|
|
|
|
<MudNavLink Href="@($"Users/{baid}/HighScores")" Match="NavLinkMatch.All">@Localizer["High Scores"]</MudNavLink>
|
|
|
|
<MudNavLink Href="@($"Users/{baid}/PlayHistory")" Match="NavLinkMatch.All">@Localizer["Play History"]</MudNavLink>
|
|
|
|
<MudNavLink Href="@($"Users/{baid}/DaniDojo")" Match="NavLinkMatch.All">@Localizer["Dani Dojo"]</MudNavLink>
|
2024-03-09 07:07:34 +01:00
|
|
|
</MudNavGroup>
|
2024-05-17 00:32:46 +02:00
|
|
|
<MudNavGroup Title=@Localizer["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>
|
2024-05-17 00:32:46 +02:00
|
|
|
<MudNavLink Href="@($"Users/{baid}/AccessCode")" Match="NavLinkMatch.All">@Localizer["Access Codes"]</MudNavLink>
|
2024-03-09 07:07:34 +01:00
|
|
|
</MudNavGroup>
|
|
|
|
}
|
|
|
|
|
2024-05-17 00:32:46 +02:00
|
|
|
if (AuthService.IsLoggedIn)
|
2024-03-09 07:07:34 +01:00
|
|
|
{
|
|
|
|
<MudDivider />
|
|
|
|
<MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Logout" IconColor="Color.Error" OnClick="Logout">@Localizer["Log Out"]</MudNavLink>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</MudNavMenu>
|
|
|
|
|
|
|
|
@code {
|
2024-05-17 00:32:46 +02:00
|
|
|
private bool settingsOpen = false;
|
2024-03-10 00:29:17 +01:00
|
|
|
|
2024-03-09 07:07:34 +01:00
|
|
|
protected override void OnInitialized()
|
|
|
|
{
|
2024-05-17 00:32:46 +02:00
|
|
|
AuthService.LoginStatusChanged += HandleAuthStatusChanged;
|
2024-03-09 07:07:34 +01:00
|
|
|
}
|
|
|
|
|
2024-05-17 00:32:46 +02:00
|
|
|
private void HandleAuthStatusChanged(object? sender, EventArgs e)
|
2024-03-09 07:07:34 +01:00
|
|
|
{
|
|
|
|
StateHasChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
|
|
{
|
|
|
|
if (firstRender)
|
|
|
|
{
|
2024-05-17 00:32:46 +02:00
|
|
|
AuthService.LoginStatusChanged += HandleAuthStatusChanged;
|
2024-03-09 07:07:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-17 00:32:46 +02:00
|
|
|
private async Task ShowQrCode()
|
2024-03-09 07:07:34 +01:00
|
|
|
{
|
2024-05-17 00:32:46 +02:00
|
|
|
var user = await AuthService.GetLoggedInUser();
|
|
|
|
if (user == null) return;
|
|
|
|
|
2024-03-09 07:07:34 +01:00
|
|
|
var parameters = new DialogParameters
|
|
|
|
{
|
2024-05-17 00:32:46 +02:00
|
|
|
["user"] = user
|
2024-03-09 07:07:34 +01:00
|
|
|
};
|
|
|
|
|
2024-05-17 00:32:46 +02:00
|
|
|
var options = new DialogOptions { DisableBackdropClick = true };
|
|
|
|
await DialogService.ShowAsync<UserQrCodeDialog>(Localizer["QR Code"], parameters, options);
|
2024-03-10 00:29:17 +01:00
|
|
|
|
|
|
|
// Prevent the settings menu from closing
|
2024-05-17 00:32:46 +02:00
|
|
|
settingsOpen = true;
|
2024-03-09 07:07:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private async Task Logout()
|
|
|
|
{
|
|
|
|
var result = await DialogService.ShowMessageBox(
|
2024-06-05 15:29:46 +02:00
|
|
|
Localizer["Log Out"],
|
|
|
|
Localizer["Log Out Confirm"],
|
|
|
|
yesText: Localizer["Log Out"],
|
|
|
|
noText: Localizer["Cancel"]);
|
2024-03-09 07:07:34 +01:00
|
|
|
|
|
|
|
if (result == true)
|
|
|
|
{
|
2024-05-17 00:32:46 +02:00
|
|
|
await AuthService.Logout();
|
2024-03-09 07:07:34 +01:00
|
|
|
NavigationManager.NavigateTo("/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|