feat(ui): Hub Navigation, Profile Dashboard and Auth Stability Fixes (#31)
This PR implements the Hub Navigation system and the Profile Dashboard, while resolving critical session synchronization issues. ### Key Changes - **Hub Navigation**: Introduced `MainHubLayout` with a premium glassmorphism sidebar, providing access to Dashboard, Library, Concepts Map, and Profile. - **Profile Dashboard**: Implemented a high-fidelity Profile page (#27) with learning metrics, AI token usage tracking, and system rank visualization. - **Stability Fixes**: - Resolved an infinite network loop on the `/profile` page by implementing request deduplication and in-memory caching in `IdentityService`. - Added environment-aware guards to prevent illegal JavaScript interop calls during server-side prerendering. - Implemented automatic session invalidation on `401 Unauthorized` responses to handle stale authentication states gracefully. - **Reader Integration**: Added a "Return to Dashboard" option in the reader toolbar (#26). Closes #26 Closes #27 Reviewed-on: #31 Co-authored-by: Marek Jasiński <jasins.marek@gmail.com> Co-committed-by: Marek Jasiński <jasins.marek@gmail.com>
This commit was merged in pull request #31.
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
@inherits LayoutComponentBase
|
||||
@using NexusReader.UI.Shared.Components.Molecules
|
||||
@using NexusReader.UI.Shared.Components.Atoms
|
||||
@using NexusReader.Application.Abstractions.Services
|
||||
@using NexusReader.UI.Shared.Services
|
||||
|
||||
<div class="hub-container">
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<aside class="hub-sidebar">
|
||||
<div class="sidebar-header">
|
||||
<div class="logo">
|
||||
<NexusIcon Name="diamond" Size="24" Class="logo-icon" />
|
||||
<span class="logo-text">Nexus</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="sidebar-nav">
|
||||
<NavLink class="nav-item" href="/" Match="NavLinkMatch.All">
|
||||
<div class="nav-icon">
|
||||
<NexusIcon Name="home" Size="18" />
|
||||
</div>
|
||||
<span class="nav-text">Dashboard</span>
|
||||
</NavLink>
|
||||
<NavLink class="nav-item" href="/library">
|
||||
<div class="nav-icon">
|
||||
<NexusIcon Name="book-open" Size="18" />
|
||||
</div>
|
||||
<span class="nav-text">Library</span>
|
||||
</NavLink>
|
||||
<NavLink class="nav-item" href="/concepts-map">
|
||||
<div class="nav-icon">
|
||||
<NexusIcon Name="map" Size="18" />
|
||||
</div>
|
||||
<span class="nav-text">Concepts Map</span>
|
||||
</NavLink>
|
||||
<NavLink class="nav-item" href="/profile">
|
||||
<div class="nav-icon">
|
||||
<NexusIcon Name="message-square" Size="18" />
|
||||
</div>
|
||||
<span class="nav-text">Profile</span>
|
||||
</NavLink>
|
||||
<NavLink class="nav-item" href="/settings">
|
||||
<div class="nav-icon">
|
||||
<NexusIcon Name="settings" Size="18" />
|
||||
</div>
|
||||
<span class="nav-text">Settings</span>
|
||||
</NavLink>
|
||||
<NavLink class="nav-item" href="/concenters">
|
||||
<div class="nav-icon">
|
||||
<NexusIcon Name="target" Size="18" />
|
||||
</div>
|
||||
<span class="nav-text">Concenters</span>
|
||||
</NavLink>
|
||||
</nav>
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<div class="user-brief">
|
||||
<div class="user-avatar">
|
||||
@context.User.Identity?.Name?[0].ToString().ToUpper()
|
||||
</div>
|
||||
<div class="user-details">
|
||||
<span class="user-name">@context.User.Identity?.Name</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="logout-btn" @onclick="HandleLogout" title="Logout">
|
||||
<NexusIcon Name="log-out" Size="18" />
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
|
||||
<main class="hub-main">
|
||||
<div class="hub-content">
|
||||
@Body
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Inject] private AuthenticationStateProvider AuthStateProvider { get; set; } = default!;
|
||||
[Inject] private IIdentityService IdentityService { get; set; } = default!;
|
||||
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||
|
||||
private bool _isSyncing = false;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (_isSyncing) return;
|
||||
|
||||
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||
if (!authState.User.Identity?.IsAuthenticated ?? true)
|
||||
{
|
||||
_isSyncing = true;
|
||||
// Try to sync with server cookie
|
||||
await IdentityService.GetProfileAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleLogout()
|
||||
{
|
||||
await IdentityService.LogoutAsync();
|
||||
NavigationManager.NavigateTo("/", true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
.hub-container {
|
||||
display: flex;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: #121212;
|
||||
color: #e0e0e0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
::deep .hub-sidebar {
|
||||
width: 260px;
|
||||
height: 100%;
|
||||
background: #161616;
|
||||
border-right: 1px solid rgba(255, 255, 255, 0.05);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 100;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
::deep .sidebar-header {
|
||||
padding: 2.5rem 1.5rem;
|
||||
}
|
||||
|
||||
::deep .logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
::deep .logo-icon {
|
||||
color: var(--nexus-neon);
|
||||
filter: drop-shadow(0 0 10px rgba(0, 255, 153, 0.4));
|
||||
}
|
||||
|
||||
::deep .logo-text {
|
||||
font-family: var(--nexus-font-serif);
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
::deep .sidebar-nav {
|
||||
flex: 1;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
::deep .nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.5rem;
|
||||
color: #A0A0A0;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s ease;
|
||||
border-left: 3px solid transparent;
|
||||
font-family: var(--nexus-font-sans);
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
::deep .nav-item:hover {
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
::deep .nav-item.active {
|
||||
color: #ffffff;
|
||||
background: rgba(0, 255, 153, 0.03);
|
||||
border-left: 3px solid var(--nexus-neon);
|
||||
}
|
||||
|
||||
::deep .nav-item.active .nav-icon {
|
||||
color: var(--nexus-neon);
|
||||
}
|
||||
|
||||
::deep .nav-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
::deep .nav-item:hover .nav-icon,
|
||||
::deep .nav-item.active .nav-icon {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
::deep .sidebar-footer {
|
||||
padding: 1.25rem 1.5rem;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.05);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
::deep .user-brief {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
::deep .user-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: #222;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #A0A0A0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
::deep .user-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
::deep .user-name {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
color: #A0A0A0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
::deep .logout-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
padding: 0.4rem;
|
||||
border-radius: 6px;
|
||||
transition: all 0.2s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
::deep .logout-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hub-main {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
background: radial-gradient(circle at center, #1a1a1a 0%, #121212 100%);
|
||||
}
|
||||
|
||||
.hub-content {
|
||||
padding: 2.5rem;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
::deep .hub-loading {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
::deep .nexus-loader {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 2px solid rgba(0, 255, 153, 0.1);
|
||||
border-top-color: var(--nexus-neon);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||||
filter: drop-shadow(0 0 5px var(--nexus-neon));
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
|
||||
+22
-24
@@ -10,19 +10,23 @@
|
||||
@inject IJSRuntime JS
|
||||
@inject IIdentityService IdentityService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject Microsoft.Extensions.Logging.ILogger<MainLayout> Logger
|
||||
@inject Microsoft.Extensions.Logging.ILogger<ReaderLayout> Logger
|
||||
@implements IDisposable
|
||||
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<div class="app-container @_platformClass @(FocusMode.IsFocusModeActive ? "focus-mode-active" : "")">
|
||||
<div class="reader-pane">
|
||||
<main>
|
||||
@Body
|
||||
</main>
|
||||
<div class="app-container @_platformClass @(FocusMode.IsFocusModeActive ? "focus-mode-active" : "")">
|
||||
<div class="reader-pane">
|
||||
<main>
|
||||
@Body
|
||||
</main>
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<ReaderFooter />
|
||||
</div>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
</div>
|
||||
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<div class="resizer" id="sidebar-resizer"></div>
|
||||
|
||||
<div class="intelligence-sidebar">
|
||||
@@ -34,9 +38,6 @@
|
||||
Class="@($"neon-glow {(QuizService.HasNewQuiz ? "quiz-available" : "")}")" />
|
||||
<span>Asystent AI</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<button class="close-btn">×</button>
|
||||
</div>
|
||||
|
||||
@@ -49,18 +50,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Authorized>
|
||||
<Authorizing>
|
||||
<div class="app-preloader">
|
||||
<div class="preloader-spinner"></div>
|
||||
<div class="preloader-text">Weryfikacja...</div>
|
||||
</div>
|
||||
</Authorizing>
|
||||
<NotAuthorized>
|
||||
@Body
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
</Authorized>
|
||||
<Authorizing>
|
||||
<div class="app-preloader">
|
||||
<div class="preloader-spinner"></div>
|
||||
<div class="preloader-text">Weryfikacja...</div>
|
||||
</div>
|
||||
</Authorizing>
|
||||
</AuthorizeView>
|
||||
</div>
|
||||
|
||||
<div id="blazor-error-ui" data-nosnippet>
|
||||
An unhandled error has occurred.
|
||||
Reference in New Issue
Block a user