refactor(frontend): decouple app shell from PrimeNG layout system (#307)

* refactor(layout): decouple shell from PrimeNG

* fix(frontend): review fixes for layout decoupling

- Rewrite layout service spec to match new API surface
- Remove dead ToastModule import from AppLayoutComponent
- Add missing type="button" to profile and logout buttons
- Add missing i18n keys to all non-English locales

* chore(frontend): Layout shell consistency

* chore(frontend): shell and routing improvements

* chore(frontend): remove stray shimmer effect

* chore(frontend): code cleanup

* chore(ui): Fix navitem types consistency

* chore(frontend): simplify layout structure + imports

* chore(frontend): remove empty files

* chore(frontend): Menu component cleanup

* chore(frontend): remove nav translation layer

* chore(frontend): revert stray artwork change

* chore(frontend): revert author animation tweak

* chore(frontend): review fixes

* fix(frontend): restore topbar template after rebase conflict
This commit is contained in:
Alex
2026-04-22 17:26:57 -04:00
committed by Zach Yale
parent 61b9b53a60
commit 55a6343f65
110 changed files with 1688 additions and 1518 deletions
@@ -0,0 +1,313 @@
<ng-container *transloco="let t; prefix: 'layout.topbar'">
<div class="layout-topbar">
<a class="layout-topbar-logo topbar-logo" routerLink="">
<!--
<svg class="logo-icon half-title" viewBox="0 0 126 126" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path
d="M59 4.79297C71.5051 11.5557 80 24.7854 80 40C80 40.5959 79.987 41.1888 79.9609 41.7783C79.8609 44.0406 81.7355 46 84 46C106.091 46 124 63.9086 124 86C124 108.091 106.091 126 84 126H10C4.47715 126 0 121.523 0 116V39.0068L0.0126953 38.9941C0.357624 25.0252 7.86506 12.8347 19 5.95215V63.832C19 64.8345 20.0676 65.4391 20.9121 64.9902L21.0771 64.8867L38.2227 52.3428C38.6819 52.0068 39.3064 52.0068 39.7656 52.3428L56.9229 64.8945L57.0879 64.998C57.9324 65.447 59 64.8423 59 63.8398V4.79297Z"/>
<path
d="M40 0C43.8745 0 47.6199 0.552381 51.1631 1.58008V50.9697L44.3926 46.0176L44.0879 45.8037C40.9061 43.6679 36.7098 43.7393 33.5957 46.0176L26.8369 50.9619V2.21875C30.9593 0.782634 35.3881 0 40 0Z"
fill="white"/>
</svg>
-->
<span class="logo-text">Grimmory</span>
</a>
<button
type="button"
class="layout-menu-button"
[attr.aria-label]="t('toggleNavigation')"
(click)="toggleMenu()"
[ngClass]="{ 'rotate-right': !isMenuVisible, 'rotate-left': isMenuVisible }"
>
<i class="pi pi-bars" aria-hidden="true"></i>
</button>
<div class="topbar-content">
<app-book-searcher class="topbar-search"></app-book-searcher>
<ul class="topbar-items topbar-desktop-items">
<div class="topbar-action-group">
@if (user(); as currentUser) {
@if (currentUser.permissions.canAccessBookdrop || currentUser.permissions.admin) {
<li>
<button type="button" class="topbar-item" (click)="navigateToBookdrop()" [pTooltip]="t('bookdrop')" tooltipPosition="bottom">
<i class="pi pi-inbox topbar-icon"></i>
</button>
</li>
}
@if (currentUser.permissions.canManageLibrary || currentUser.permissions.admin) {
<li>
<button type="button" class="topbar-item" (click)="openLibraryCreatorDialog()" [pTooltip]="t('createNewLibrary')" tooltipPosition="bottom">
<i class="pi pi-plus-circle topbar-icon"></i>
</button>
</li>
}
@if (currentUser.permissions.canUpload || currentUser.permissions.admin) {
<li>
<button type="button" class="topbar-item" (click)="openFileUploadDialog()" [pTooltip]="t('uploadBook')" tooltipPosition="bottom">
<i class="pi pi-upload topbar-icon"></i>
</button>
</li>
}
}
@if (hasStatsAccess) {
<li>
<button
type="button"
class="topbar-item"
(click)="shouldShowStatsMenu ? statsMenu?.toggle($event) : handleStatsButtonClick()"
[pTooltip]="statsTooltip"
tooltipPosition="bottom">
<svg class="multi-color-chart-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 1.25rem; height: 1.25rem;">
<rect x="2" y="13" width="4" height="9" rx="1" fill="#ef4444"/>
<rect x="7.5" y="3" width="4" height="19" rx="1" fill="#f59e0b"/>
<rect x="13" y="9" width="4" height="13" rx="1" fill="#3b82f6"/>
<rect x="18.5" y="5" width="4" height="17" rx="1" fill="#10b981"/>
</svg>
</button>
@if (shouldShowStatsMenu) {
<p-menu #statsMenu [model]="statsMenuItems" [popup]="true" appendTo="body"/>
}
</li>
}
@if (user(); as currentUser) {
@if (currentUser.permissions.canManageLibrary || currentUser.permissions.admin) {
<li>
<button type="button" class="topbar-item" (click)="navigateToMetadataManager()" [pTooltip]="t('metadataManager')" tooltipPosition="bottom">
<i class="pi pi-sparkles topbar-icon"></i>
</button>
</li>
}
}
<li>
<button type="button" class="topbar-item" (click)="navigateToSettings()" [pTooltip]="t('settings')" tooltipPosition="bottom">
<i class="pi pi-cog topbar-icon"></i>
</button>
</li>
</div>
<p-divider layout="vertical"/>
<div class="topbar-action-group">
<li class="topbar-item-relative">
<button
type="button"
class="topbar-item"
(click)="notificationPopover.toggle($event)"
>
<i
class="pi"
[ngClass]="iconClass"
[ngStyle]="{ color: iconColor }"
style="font-size: 1.25rem"
[class.pulsating]="iconPulsating"
[attr.aria-label]="t('notificationAriaLabel')"
></i>
</button>
@if (shouldShowNotificationBadge) {
<span class="notification-badge">{{ completedTaskCount }}</span>
}
<p-popover #notificationPopover>
<app-unified-notification-popover-component></app-unified-notification-popover-component>
</p-popover>
</li>
<li class="topbar-item-relative">
<button
type="button"
class="topbar-item"
(click)="langMenu.toggle($event)"
[pTooltip]="t('language')"
tooltipPosition="bottom">
<i class="pi pi-language topbar-icon"></i>
</button>
<p-menu #langMenu [model]="langMenuItems" [popup]="true" appendTo="body"/>
</li>
<li class="topbar-item-relative">
<button type="button"
class="topbar-item config-item"
enterActiveClass="animate-scalein"
enterFromClass="hidden"
leaveActiveClass="animate-fadeout"
leaveToClass="hidden"
pStyleClass="@next" [hideOnOutsideClick]="true">
<i class="pi pi-palette"></i>
</button>
<app-theme-configurator></app-theme-configurator>
</li>
</div>
<p-divider layout="vertical"/>
<div class="topbar-action-group">
<li>
<a class="topbar-item"
href="https://grimmory.org/docs/getting-started"
target="_blank"
rel="noopener noreferrer"
[pTooltip]="t('documentation')"
tooltipPosition="bottom">
<i class="pi pi-info-circle topbar-icon"></i>
</a>
</li>
<!-- Show Profile only to non-demo users -->
@if (user(); as currentUser) {
@if (!currentUser.permissions.demoUser) {
<li>
<button type="button" class="topbar-item" (click)="openUserProfileDialog()" [pTooltip]="t('profile')" tooltipPosition="bottom">
<i class="pi pi-user topbar-icon"></i>
</button>
</li>
}
}
<li>
<button type="button" class="topbar-item" (click)="logout()" [pTooltip]="t('logout')" tooltipPosition="left">
<i class="pi pi-sign-out topbar-icon"></i>
</button>
</li>
</div>
</ul>
<!-- Trigger Button -->
<div class="mobile-trigger">
<button
type="button"
class="mobile-menu-trigger"
[attr.aria-label]="t('toggleNavigation')"
(click)="mobileMenu.toggle($event)"
>
<i class="pi pi-ellipsis-v" aria-hidden="true"></i>
</button>
<p-popover #mobileMenu>
<ul class="mobile-menu-list">
@if (user(); as currentUser) {
@if (currentUser.permissions.canAccessBookdrop || currentUser.permissions.admin) {
<li>
<button
class="mobile-menu-item"
(click)="navigateToBookdrop(); mobileMenu.hide()"
>
<i class="pi pi-inbox topbar-icon"></i>
{{ t('bookdrop') }}
</button>
</li>
}
@if (currentUser.permissions.canManageLibrary || currentUser.permissions.admin) {
<li>
<button
class="mobile-menu-item"
(click)="openLibraryCreatorDialog(); mobileMenu.hide()"
>
<i class="pi pi-plus-circle topbar-icon"></i>
{{ t('createLibrary') }}
</button>
</li>
}
@if (currentUser.permissions.canUpload || currentUser.permissions.admin) {
<li>
<button
class="mobile-menu-item"
(click)="openFileUploadDialog(); mobileMenu.hide()"
>
<i class="pi pi-upload topbar-icon"></i>
{{ t('uploadBook') }}
</button>
</li>
}
@if (currentUser.permissions.canAccessLibraryStats || currentUser.permissions.admin) {
<li>
<button
class="mobile-menu-item"
(click)="navigateToStats(); mobileMenu.hide()"
>
<i class="pi pi-chart-line topbar-icon"></i>
{{ t('libraryStats') }}
</button>
</li>
}
@if (currentUser.permissions.canAccessUserStats || currentUser.permissions.admin) {
<li>
<button
class="mobile-menu-item"
(click)="navigateToUserStats(); mobileMenu.hide()"
>
<i class="pi pi-users topbar-icon"></i>
{{ t('readingStats') }}
</button>
</li>
}
@if (currentUser.permissions.canManageLibrary || currentUser.permissions.admin) {
<li>
<button
class="mobile-menu-item"
(click)="navigateToMetadataManager(); mobileMenu.hide()"
>
<i class="pi pi-sparkles topbar-icon"></i>
{{ t('metadataManager') }}
</button>
</li>
}
}
<li>
<button
class="mobile-menu-item"
(click)="navigateToSettings(); mobileMenu.hide()"
>
<i class="pi pi-cog topbar-icon"></i>
{{ t('settings') }}
</button>
</li>
<li>
<a
class="mobile-menu-item"
href="https://grimmory.org/docs/getting-started"
target="_blank"
rel="noopener noreferrer">
<i class="pi pi-info-circle topbar-icon"></i>
{{ t('documentation') }}
</a>
</li>
<li>
<button
type="button"
class="mobile-menu-item"
(click)="langMenuMobile.toggle($event)"
>
<i class="pi pi-language topbar-icon"></i>
{{ t('language') }}
</button>
<p-menu #langMenuMobile [model]="langMenuItems" [popup]="true"/>
</li>
@if (user(); as currentUser) {
@if (!currentUser.permissions.demoUser) {
<li>
<button
class="mobile-menu-item"
(click)="openUserProfileDialog(); mobileMenu.hide()"
>
<i class="pi pi-user topbar-icon"></i>
{{ t('profile') }}
</button>
</li>
}
}
<li>
<button
class="mobile-menu-item"
(click)="logout(); mobileMenu.hide()"
>
<i class="pi pi-sign-out topbar-icon"></i>
{{ t('logout') }}
</button>
</li>
</ul>
</p-popover>
</div>
</div>
</div>
</ng-container>
@@ -0,0 +1,261 @@
.topbar-logo {
padding-left: 1.25rem;
padding-right: 6rem;
gap: 0.5rem;
}
.logo-text {
font-size: 1.875rem;
line-height: 2.25rem;
margin: 0;
}
.topbar-content {
display: flex;
align-items: center;
width: 100%;
min-width: 0;
gap: 1rem;
@media (width <= 767px) {
gap: 0.5rem;
}
}
.topbar-search {
flex-grow: 1;
min-width: 0;
}
.topbar-desktop-items {
display: none;
align-items: center;
gap: 0.75rem;
margin-left: auto;
padding-left: 1rem;
@media (width >= 768px) {
display: flex;
}
}
.topbar-action-group {
display: flex;
gap: 1rem;
}
.topbar-icon {
color: var(--surface-100);
}
.topbar-item-relative {
position: relative;
}
.heart-button {
overflow: visible;
cursor: pointer;
position: relative;
&:hover .heart-icon {
animation: heartbeat 0.6s ease-in-out;
filter: drop-shadow(0 0 8px rgb(236 72 153 / 80%));
}
&:hover .heart-ripple {
animation: ripple-burst 1.2s ease-out infinite;
}
&:hover .heart-ripple-delayed {
animation-delay: 0.4s;
}
}
.heart-ripple {
position: absolute;
z-index: -1;
inset: 0;
border-radius: 50%;
border: 1.5px solid #ec4899;
opacity: 0;
pointer-events: none;
}
.heart-orbit {
position: absolute;
z-index: 11;
width: 4px;
height: 4px;
border-radius: 50%;
pointer-events: none;
top: calc(50% - 2px);
left: calc(50% - 2px);
}
.heart-orbit-1 {
background: #f472b6;
box-shadow: 0 0 10px #f472b6, 0 0 4px #f472b6;
animation: orbit-1 2.5s linear infinite;
}
.heart-orbit-2 {
background: #a78bfa;
box-shadow: 0 0 10px #a78bfa, 0 0 4px #a78bfa;
animation: orbit-2 3.2s linear infinite reverse;
}
.heart-orbit-3 {
background: #38bdf8;
box-shadow: 0 0 10px #38bdf8, 0 0 4px #38bdf8;
animation: orbit-3 4s linear infinite;
}
.heart-icon {
z-index: 10;
color: #e8366d !important;
font-size: 1.05rem;
animation: heart-float 2.5s ease-in-out infinite;
filter: drop-shadow(0 0 6px rgb(232 54 109 / 80%));
transition: filter 0.3s;
}
.heart-button-static {
.heart-icon {
animation: none;
filter: none;
}
&:hover .heart-icon {
animation: none;
filter: none;
}
}
.mobile-trigger {
display: none;
position: relative;
margin-left: auto;
@media (width <= 767px) {
display: block;
}
}
.mobile-menu-list {
display: flex;
flex-direction: column;
gap: 0.25rem;
width: 12rem;
}
.mobile-menu-item {
display: flex;
align-items: center;
gap: 0.5rem;
width: 100%;
text-align: left;
padding: 0.5rem;
border-radius: 0.25rem;
background: none;
border: none;
color: inherit;
font: inherit;
cursor: pointer;
text-decoration: none;
&:hover {
background: var(--surface-700);
}
}
.highlight {
color: red !important;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.spin {
animation: spin 1.5s linear infinite;
}
@keyframes orbit-1 {
0% { transform: rotate(0deg) translateX(16px) rotate(0deg); }
100% { transform: rotate(360deg) translateX(16px) rotate(-360deg); }
}
@keyframes orbit-2 {
0% { transform: rotate(120deg) translateX(14px) rotate(-120deg); }
100% { transform: rotate(480deg) translateX(14px) rotate(-480deg); }
}
@keyframes orbit-3 {
0% { transform: rotate(240deg) translateX(18px) rotate(-240deg); }
100% { transform: rotate(600deg) translateX(18px) rotate(-600deg); }
}
@keyframes ripple-burst {
0% {
transform: scale(0.8);
opacity: 0.6;
}
100% {
transform: scale(2.2);
opacity: 0;
}
}
@keyframes heart-float {
0%, 100% { transform: translateY(1px); }
50% { transform: translateY(-1px); }
}
@keyframes heartbeat {
0% { transform: scale(1); }
25% { transform: scale(1.35); }
40% { transform: scale(0.95); }
55% { transform: scale(1.2); }
100% { transform: scale(1); }
}
@keyframes pulsate {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.25);
opacity: 0.8;
}
100% {
transform: scale(1);
opacity: 1;
}
}
.pulsating {
animation: pulsate 1.5s infinite ease-in-out;
}
.notification-badge {
position: absolute;
top: -0.4rem;
right: -0.4rem;
background-color: red;
color: white;
border-radius: 50%;
width: 1.2rem;
height: 1.2rem;
font-size: 0.75rem;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
user-select: none;
}
@@ -0,0 +1,17 @@
import {describe, it} from 'vitest';
// NOTE(frontend-seam): Real topbar coverage needs a dedicated host harness for view queries,
// timer-driven pulse behavior, router navigation, auth/logout, user-permission signals,
// metadata/bookdrop streams, menu overlays, and transloco language switching. In the current
// shape those concerns are fused tightly enough that a shallow spec would be noisy and dishonest.
describe.skip('AppTopBarComponent', () => {
it('needs a host-view seam to verify menu visibility, pulse state, and notification/task aggregation', () => {
// TODO(seam): Cover timer-driven pulse resets, task counts, and bookdrop visibility after
// the component exposes a narrower facade over its view and timer dependencies.
});
it('needs a navigation and language seam to verify route actions and active language switching', () => {
// TODO(seam): Cover router commands, stats menu composition, and localStorage language writes
// once those side effects can be driven without mocking the entire topbar runtime.
});
});
@@ -0,0 +1,313 @@
import { Component, effect, inject, OnDestroy, ViewChild } from '@angular/core';
import { LayoutService } from '../layout.service';
import { Router, RouterLink } from '@angular/router';
import { TooltipModule } from 'primeng/tooltip';
import { FormsModule } from '@angular/forms';
import { InputTextModule } from 'primeng/inputtext';
import { BookSearcherComponent } from '../../../features/book/components/book-searcher/book-searcher.component';
import { NgClass, NgStyle } from '@angular/common';
import { NotificationEventService } from '../../websocket/notification-event.service';
import { StyleClass } from 'primeng/styleclass';
import { Divider } from 'primeng/divider';
import { ThemeConfiguratorComponent } from '../theme-configurator/theme-configurator.component';
import { AuthService } from '../../service/auth.service';
import { UserService } from '../../../features/settings/user-management/user.service';
import { Popover } from 'primeng/popover';
import { MetadataProgressService } from '../../service/metadata-progress.service';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { MetadataBatchProgressNotification } from '../../model/metadata-batch-progress.model';
import { BookdropFileService } from '../../../features/bookdrop/service/bookdrop-file.service';
import { DialogLauncherService } from '../../services/dialog-launcher.service';
import { UnifiedNotificationBoxComponent } from '../../components/unified-notification-popover/unified-notification-popover-component';
import { Severity, LogNotification } from '../../websocket/model/log-notification.model';
import { Menu } from 'primeng/menu';
import { TranslocoDirective, TranslocoService } from '@jsverse/transloco';
import { AVAILABLE_LANGS, LANG_LABELS } from '../../../core/config/transloco-loader';
import { LANG_STORAGE_KEY } from '../../../core/config/language-initializer';
import type { MenuItem } from 'primeng/api';
@Component({
selector: 'app-topbar',
templateUrl: './app.topbar.component.html',
styleUrls: ['./app.topbar.component.scss'],
imports: [
RouterLink,
TooltipModule,
FormsModule,
InputTextModule,
BookSearcherComponent,
ThemeConfiguratorComponent,
StyleClass,
NgClass,
Divider,
Popover,
UnifiedNotificationBoxComponent,
NgStyle,
Menu,
TranslocoDirective,
],
})
export class AppTopBarComponent implements OnDestroy {
public readonly layoutService = inject(LayoutService);
protected readonly userService = inject(UserService);
protected readonly user = this.userService.currentUser;
private readonly notificationService = inject(NotificationEventService);
private readonly router = inject(Router);
private readonly authService = inject(AuthService);
private readonly metadataProgressService = inject(MetadataProgressService);
private readonly bookdropFileService = inject(BookdropFileService);
private readonly dialogLauncher = inject(DialogLauncherService);
private readonly translocoService = inject(TranslocoService);
statsMenuItems: MenuItem[] = [];
@ViewChild('statsMenu') statsMenu?: Menu;
isMenuVisible = true;
progressHighlight = false;
completedTaskCount = 0;
hasActiveOrCompletedTasks = false;
showPulse = false;
hasAnyTasks = false;
hasPendingBookdropFiles = false;
private eventTimer: number | undefined;
private destroy$ = new Subject<void>();
private latestTasks: Record<string, MetadataBatchProgressNotification> = {};
private latestHasPendingFiles = false;
private latestNotificationSeverity?: Severity;
activeLang = this.translocoService.getActiveLang();
langMenuItems: MenuItem[] = [];
constructor() {
this.langMenuItems = this.buildLanguageActions(this.activeLang);
this.subscribeToMetadataProgress();
this.subscribeToNotifications();
this.metadataProgressService.activeTasks$
.pipe(takeUntil(this.destroy$))
.subscribe((tasks) => {
this.latestTasks = tasks;
this.hasAnyTasks = Object.keys(tasks).length > 0;
this.updateCompletedTaskCount();
this.updateTaskVisibility(tasks);
});
this.bookdropFileService.hasPendingFiles$
.pipe(takeUntil(this.destroy$))
.subscribe((hasPending) => {
this.latestHasPendingFiles = hasPending;
this.hasPendingBookdropFiles = hasPending;
this.updateCompletedTaskCount();
this.updateTaskVisibilityWithBookdrop();
});
effect(() => {
this.user();
this.initializeStatsMenu();
});
this.translocoService.langChanges$
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.initializeStatsMenu();
});
}
ngOnDestroy(): void {
clearTimeout(this.eventTimer);
this.destroy$.next();
this.destroy$.complete();
}
toggleMenu() {
this.isMenuVisible = !this.isMenuVisible;
this.layoutService.onMenuToggle();
}
openLibraryCreatorDialog(): void {
this.dialogLauncher.openLibraryCreateDialog();
}
openFileUploadDialog(): void {
this.dialogLauncher.openFileUploadDialog();
}
openUserProfileDialog(): void {
this.dialogLauncher.openUserProfileDialog();
}
navigateToSettings() {
this.router.navigate(['/settings']);
}
navigateToBookdrop() {
this.router.navigate(['/bookdrop']);
}
navigateToMetadataManager() {
this.router.navigate(['/metadata-manager']);
}
navigateToStats() {
this.router.navigate(['/library-stats']);
}
navigateToUserStats() {
this.router.navigate(['/reading-stats']);
}
switchLanguage(lang: string) {
if (lang === this.activeLang) return;
this.translocoService.load(lang).subscribe(() => {
this.translocoService.setActiveLang(lang);
localStorage.setItem(LANG_STORAGE_KEY, lang);
this.activeLang = lang;
this.langMenuItems = this.buildLanguageActions(lang);
});
}
logout() {
this.authService.logout();
}
handleStatsButtonClick() {
if (this.statsMenuItems.length === 0) {
return;
}
if (this.statsMenuItems.length === 1) {
this.statsMenuItems[0].command?.({});
}
}
private subscribeToMetadataProgress() {
this.metadataProgressService.progressUpdates$
.pipe(takeUntil(this.destroy$))
.subscribe((progress) => {
this.progressHighlight = progress.status === 'IN_PROGRESS';
});
}
private subscribeToNotifications() {
this.notificationService.latestNotification$
.pipe(takeUntil(this.destroy$))
.subscribe((notification: LogNotification) => {
this.latestNotificationSeverity = notification.severity;
this.triggerPulseEffect();
});
}
private triggerPulseEffect() {
this.showPulse = true;
clearTimeout(this.eventTimer);
this.eventTimer = setTimeout(() => {
this.showPulse = false;
}, 4000) as unknown as number;
}
private updateCompletedTaskCount() {
const completedMetadataTasks = Object.values(this.latestTasks).length;
const bookdropFileTaskCount = this.latestHasPendingFiles ? 1 : 0;
this.completedTaskCount = completedMetadataTasks + bookdropFileTaskCount;
}
private updateTaskVisibility(tasks: Record<string, MetadataBatchProgressNotification>) {
this.hasActiveOrCompletedTasks =
this.progressHighlight || this.completedTaskCount > 0 || Object.keys(tasks).length > 0;
this.updateTaskVisibilityWithBookdrop();
}
private updateTaskVisibilityWithBookdrop() {
this.hasActiveOrCompletedTasks = this.hasActiveOrCompletedTasks || this.hasPendingBookdropFiles;
}
private initializeStatsMenu() {
const user = this.user();
const actions: MenuItem[] = [];
if (user?.permissions?.canAccessLibraryStats || user?.permissions?.admin) {
actions.push({
label: this.translocoService.translate('layout.topbar.libraryStats'),
icon: 'pi pi-chart-line',
command: () => this.navigateToStats()
});
}
if (user?.permissions?.canAccessUserStats || user?.permissions?.admin) {
actions.push({
label: this.translocoService.translate('layout.topbar.readingStats'),
icon: 'pi pi-users',
command: () => this.navigateToUserStats()
});
}
this.statsMenuItems = actions;
}
get hasStatsAccess(): boolean {
return this.statsMenuItems.length > 0;
}
get shouldShowStatsMenu(): boolean {
return this.statsMenuItems.length > 1;
}
get statsTooltip(): string {
if (this.statsMenuItems.length === 0) {
return this.translocoService.translate('layout.topbar.stats');
}
if (this.statsMenuItems.length === 1) {
return this.statsMenuItems[0].label || this.translocoService.translate('layout.topbar.stats');
}
return this.translocoService.translate('layout.topbar.stats');
}
get iconClass(): string {
if (this.progressHighlight) return 'pi-spinner spin';
if (this.iconPulsating) return 'pi-wave-pulse';
if (this.completedTaskCount > 0 || this.hasPendingBookdropFiles) return 'pi-bell';
return 'pi-wave-pulse';
}
get iconColor(): string {
if (this.progressHighlight) return 'gold';
if (this.showPulse) {
switch (this.latestNotificationSeverity) {
case Severity.ERROR:
return 'crimson';
case Severity.INFO:
return 'aqua';
case Severity.WARN:
return 'orange';
default:
return 'orange';
}
}
if (this.completedTaskCount > 0 || this.hasPendingBookdropFiles)
return 'limegreen';
return 'inherit';
}
get iconPulsating(): boolean {
return !this.progressHighlight && (this.showPulse);
}
get shouldShowNotificationBadge(): boolean {
return (
(this.completedTaskCount > 0 || this.hasPendingBookdropFiles) &&
!this.progressHighlight &&
!this.showPulse
);
}
private buildLanguageActions(activeLang: string): MenuItem[] {
return AVAILABLE_LANGS.map((lang) => ({
label: LANG_LABELS[lang] || lang,
icon: lang === activeLang ? 'pi pi-check' : undefined,
command: () => this.switchLanguage(lang),
}));
}
}