Adjust breadcrumbs, login redirects
This commit is contained in:
parent
8901e92e55
commit
e6270013ff
@ -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()
|
||||
|
@ -11,8 +11,14 @@
|
||||
<MudCard Outlined="true">
|
||||
<MudCardHeader>
|
||||
<CardHeaderContent>
|
||||
<div style="display:flex;flex-wrap:wrap;gap:5px;">
|
||||
<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>
|
||||
@ -47,11 +53,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 />
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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">
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"WebUiSettings": {
|
||||
"LoginRequired": "false",
|
||||
"LoginRequired": "true",
|
||||
"OnlyAdmin": "false",
|
||||
"BoundAccessCodeUpperLimit": "3",
|
||||
"RegisterWithLastPlayTime": "false",
|
||||
|
Loading…
Reference in New Issue
Block a user