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:
@@ -32,6 +32,11 @@ describe('app routes', () => {
|
||||
expect(children.find(route => route.path === 'all-books')?.canActivate).toEqual([AuthGuard]);
|
||||
expect(children.find(route => route.path === 'magic-shelf/:magicShelfId/books')?.canActivate).toEqual([AuthGuard]);
|
||||
expect(children.find(route => route.path === 'notebook')?.canActivate).toEqual([AuthGuard]);
|
||||
expect(typeof children.find(route => route.path === 'all-books')?.loadComponent).toBe('function');
|
||||
expect(typeof children.find(route => route.path === 'library/:libraryId/books')?.loadComponent).toBe('function');
|
||||
expect(typeof children.find(route => route.path === 'shelf/:shelfId/books')?.loadComponent).toBe('function');
|
||||
expect(typeof children.find(route => route.path === 'unshelved-books')?.loadComponent).toBe('function');
|
||||
expect(typeof children.find(route => route.path === 'magic-shelf/:magicShelfId/books')?.loadComponent).toBe('function');
|
||||
});
|
||||
|
||||
it('defines guarded lazy routes for metadata, stats, and bookdrop', () => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {Routes} from '@angular/router';
|
||||
import {BookBrowserComponent} from './features/book/components/book-browser/book-browser.component';
|
||||
import {AppLayoutComponent} from './shared/layout/component/layout-main/app.layout.component';
|
||||
import {AppLayoutComponent} from './shared/layout/layout-main/app.layout.component';
|
||||
import {LoginComponent} from './shared/components/login/login.component';
|
||||
import {AuthGuard} from './core/security/auth.guard';
|
||||
import {ChangePasswordComponent} from './shared/components/change-password/change-password.component';
|
||||
@@ -16,6 +15,9 @@ import {LibraryStatsGuard} from './core/security/guards/library-stats.guard';
|
||||
import {UserStatsGuard} from './core/security/guards/user-stats.guard';
|
||||
import {EditMetadataGuard} from './core/security/guards/edit-metdata.guard';
|
||||
|
||||
const loadBookBrowserComponent = () =>
|
||||
import('./features/book/components/book-browser/book-browser.component').then(m => m.BookBrowserComponent);
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
@@ -34,16 +36,16 @@ export const routes: Routes = [
|
||||
component: AppLayoutComponent,
|
||||
children: [
|
||||
{path: 'dashboard', component: MainDashboardComponent, canActivate: [AuthGuard]},
|
||||
{path: 'all-books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'all-books', loadComponent: loadBookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'settings', loadComponent: () => import('./features/settings/settings.component').then(m => m.SettingsComponent), canActivate: [AuthGuard]},
|
||||
{path: 'library/:libraryId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'shelf/:shelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'unshelved-books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'library/:libraryId/books', loadComponent: loadBookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'shelf/:shelfId/books', loadComponent: loadBookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'unshelved-books', loadComponent: loadBookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'series', loadComponent: () => import('./features/series-browser/components/series-browser/series-browser.component').then(m => m.SeriesBrowserComponent), canActivate: [AuthGuard]},
|
||||
{path: 'series/:seriesName', loadComponent: () => import('./features/book/components/series-page/series-page.component').then(m => m.SeriesPageComponent), canActivate: [AuthGuard]},
|
||||
{path: 'authors', loadComponent: () => import('./features/author-browser/components/author-browser/author-browser.component').then(m => m.AuthorBrowserComponent), canActivate: [AuthGuard]},
|
||||
{path: 'author/:authorId', loadComponent: () => import('./features/author-browser/components/author-detail/author-detail.component').then(m => m.AuthorDetailComponent), canActivate: [AuthGuard]},
|
||||
{path: 'magic-shelf/:magicShelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'magic-shelf/:magicShelfId/books', loadComponent: loadBookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'book/:bookId', loadComponent: () => import('./features/metadata/component/book-metadata-center/book-metadata-center.component').then(m => m.BookMetadataCenterComponent), canActivate: [AuthGuard]},
|
||||
{path: 'bookdrop', loadComponent: () => import('./features/bookdrop/component/bookdrop-file-review/bookdrop-file-review.component').then(m => m.BookdropFileReviewComponent), canActivate: [BookdropGuard]},
|
||||
{path: 'metadata-manager', loadComponent: () => import('./features/metadata/component/metadata-manager/metadata-manager.component').then(m => m.MetadataManagerComponent), canActivate: [EditMetadataGuard]},
|
||||
|
||||
@@ -33,7 +33,7 @@ export class LoadingService {
|
||||
if (content) {
|
||||
content.style.cssText = `
|
||||
text-align: center;
|
||||
background: var(--surface-card);
|
||||
background: var(--card-background);
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
|
||||
@@ -172,11 +172,13 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
return [];
|
||||
}
|
||||
|
||||
return this.entityService.isLibrary(entity)
|
||||
const actions = this.entityService.isLibrary(entity)
|
||||
? this.libraryShelfMenuService.initializeLibraryMenuItems(entity)
|
||||
: this.entityService.isMagicShelf(entity)
|
||||
? this.libraryShelfMenuService.initializeMagicShelfMenuItems(entity)
|
||||
: this.libraryShelfMenuService.initializeShelfMenuItems(entity);
|
||||
|
||||
return actions;
|
||||
});
|
||||
readonly books = computed(() => {
|
||||
const {entityId, entityType} = this.entityInfo();
|
||||
@@ -999,4 +1001,5 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.mobileColumnCount = saved;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -33,12 +33,12 @@
|
||||
|
||||
.cover-container.audiobook-cover {
|
||||
aspect-ratio: 5/7;
|
||||
background-color: var(--surface-ground);
|
||||
background-color: var(--ground-background);
|
||||
}
|
||||
|
||||
.cover-container.square-library-cover {
|
||||
aspect-ratio: 1/1;
|
||||
background-color: var(--surface-ground);
|
||||
background-color: var(--ground-background);
|
||||
}
|
||||
|
||||
.book-cover {
|
||||
|
||||
@@ -115,12 +115,12 @@
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--surface-border);
|
||||
background: var(--border-color);
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
@@ -293,7 +293,7 @@
|
||||
|
||||
.review-title-section {
|
||||
flex-shrink: 0;
|
||||
border-bottom: 1px solid var(--surface-border);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
padding: 8px 16px 4px;
|
||||
}
|
||||
|
||||
@@ -363,12 +363,12 @@
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--surface-border);
|
||||
background: var(--border-color);
|
||||
border-radius: 2px;
|
||||
|
||||
&:hover {
|
||||
|
||||
+2
-2
@@ -139,7 +139,7 @@
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
|
||||
background-color: var(--surface-ground);
|
||||
background-color: var(--ground-background);
|
||||
aspect-ratio: 2/3;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@
|
||||
.search-book-year {
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-secondary-color);
|
||||
background-color: var(--surface-ground);
|
||||
background-color: var(--ground-background);
|
||||
padding: 0.125rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
border-radius: 0.75rem 0.75rem 0 0;
|
||||
font-weight: 600;
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
||||
import {Router} from '@angular/router';
|
||||
import {LibraryService} from './library.service';
|
||||
import {ShelfService} from './shelf.service';
|
||||
import {Library} from '../model/library.model';
|
||||
import {Shelf} from '../model/shelf.model';
|
||||
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {MagicShelf, MagicShelfService} from '../../magic-shelf/service/magic-shelf.service';
|
||||
import {TaskHelperService} from '../../settings/task-management/task-helper.service';
|
||||
import {UserService} from "../../settings/user-management/user.service";
|
||||
import {LoadingService} from '../../../core/services/loading.service';
|
||||
import {finalize} from 'rxjs';
|
||||
import {DialogLauncherService} from '../../../shared/services/dialog-launcher.service';
|
||||
import {BookDialogHelperService} from '../components/book-browser/book-dialog-helper.service';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { ConfirmationService, MessageService } from 'primeng/api';
|
||||
import { Router } from '@angular/router';
|
||||
import { LibraryService } from './library.service';
|
||||
import { ShelfService } from './shelf.service';
|
||||
import { Library } from '../model/library.model';
|
||||
import { Shelf } from '../model/shelf.model';
|
||||
import { MetadataRefreshType } from '../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import { MagicShelf, MagicShelfService } from '../../magic-shelf/service/magic-shelf.service';
|
||||
import { TaskHelperService } from '../../settings/task-management/task-helper.service';
|
||||
import { UserService } from '../../settings/user-management/user.service';
|
||||
import { LoadingService } from '../../../core/services/loading.service';
|
||||
import { finalize } from 'rxjs';
|
||||
import { DialogLauncherService } from '../../../shared/services/dialog-launcher.service';
|
||||
import { BookDialogHelperService } from '../components/book-browser/book-dialog-helper.service';
|
||||
import { TranslocoService } from '@jsverse/transloco';
|
||||
import type { MenuItem } from 'primeng/api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -33,7 +34,7 @@ export class LibraryShelfMenuService {
|
||||
private bookDialogHelperService = inject(BookDialogHelperService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
initializeLibraryMenuItems(entity: Library | Shelf | MagicShelf | null): MenuItem[] {
|
||||
initializeLibraryMenuItems(entity: Library | null): MenuItem[] {
|
||||
return [
|
||||
{
|
||||
label: this.t.translate('book.shelfMenuService.library.optionsLabel'),
|
||||
@@ -85,9 +86,12 @@ export class LibraryShelfMenuService {
|
||||
severity: 'success',
|
||||
},
|
||||
accept: () => {
|
||||
const entityId = entity?.id;
|
||||
if (entityId == null) return;
|
||||
this.libraryService.refreshLibrary(entityId).subscribe({
|
||||
const libraryId = entity?.id;
|
||||
if (libraryId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.libraryService.refreshLibrary(libraryId).subscribe({
|
||||
complete: () => {
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.libraryRefreshSuccessDetail')});
|
||||
},
|
||||
@@ -149,13 +153,14 @@ export class LibraryShelfMenuService {
|
||||
},
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(this.t.translate('book.shelfMenuService.loading.deletingLibrary', {name: entity?.name}));
|
||||
const entityId = entity?.id;
|
||||
if (entityId == null) {
|
||||
const libraryId = entity?.id;
|
||||
|
||||
if (libraryId == null) {
|
||||
this.loadingService.hide(loader);
|
||||
return;
|
||||
}
|
||||
|
||||
this.libraryService.deleteLibrary(entityId)
|
||||
this.libraryService.deleteLibrary(libraryId)
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
.subscribe({
|
||||
complete: () => {
|
||||
@@ -219,9 +224,12 @@ export class LibraryShelfMenuService {
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
const entityId = entity?.id;
|
||||
if (entityId == null) return;
|
||||
this.shelfService.deleteShelf(entityId).subscribe({
|
||||
const shelfId = entity?.id;
|
||||
if (shelfId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.shelfService.deleteShelf(shelfId).subscribe({
|
||||
complete: () => {
|
||||
this.router.navigate(['/']);
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.shelfDeletedDetail')});
|
||||
@@ -293,9 +301,12 @@ export class LibraryShelfMenuService {
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
const entityId = entity?.id;
|
||||
if (entityId == null) return;
|
||||
this.magicShelfService.deleteShelf(entityId).subscribe({
|
||||
const shelfId = entity?.id;
|
||||
if (shelfId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.magicShelfService.deleteShelf(shelfId).subscribe({
|
||||
complete: () => {
|
||||
this.router.navigate(['/']);
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.magicShelfDeletedDetail')});
|
||||
|
||||
+2
-47
@@ -88,7 +88,7 @@
|
||||
width: 116px;
|
||||
flex: 0 0 124px;
|
||||
scroll-snap-align: start;
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition: transform 0.25s ease;
|
||||
position: relative;
|
||||
|
||||
&.square-card {
|
||||
@@ -103,52 +103,7 @@
|
||||
}
|
||||
|
||||
&:hover, &.menu-open {
|
||||
transform: translateY(-4px) scale(1.04);
|
||||
filter: drop-shadow(0 25px 50px rgb(0 0 0 / 40%));
|
||||
|
||||
&::after {
|
||||
opacity: 1;
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
&::before {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -2px;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
color-mix(in srgb, var(--p-primary-400), transparent 70%),
|
||||
color-mix(in srgb, var(--p-primary-800), transparent 70%)
|
||||
);
|
||||
border-radius: 12px;
|
||||
z-index: -1;
|
||||
opacity: 0;
|
||||
transition: opacity 0.4s ease;
|
||||
filter: blur(8px);
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -8px;
|
||||
left: 10%;
|
||||
right: 10%;
|
||||
height: 5px;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
var(--p-primary-500),
|
||||
transparent
|
||||
);
|
||||
border-radius: 50%;
|
||||
opacity: 0;
|
||||
transition: all 0.4s ease;
|
||||
filter: blur(6px);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
// Audiobook covers should fill the container height
|
||||
|
||||
+1
-1
@@ -409,7 +409,7 @@ label {
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
min-height: 2.5rem;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-radius: 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
|
||||
+2
-2
@@ -181,7 +181,7 @@
|
||||
text-transform: none;
|
||||
letter-spacing: normal;
|
||||
color: var(--text-secondary-color);
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
padding: 0.125rem 0.5rem;
|
||||
@@ -293,7 +293,7 @@
|
||||
justify-content: center;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border: 1px dashed var(--border-color);
|
||||
border-radius: 6px;
|
||||
color: var(--text-secondary-color);
|
||||
|
||||
+1
-1
@@ -635,7 +635,7 @@
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.625rem 0.875rem;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
border-radius: 0.75rem 0.75rem 0 0;
|
||||
font-weight: 600;
|
||||
|
||||
+3
-3
@@ -88,7 +88,7 @@
|
||||
justify-content: center;
|
||||
padding: 3rem 2rem;
|
||||
text-align: center;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border: 1px dashed var(--border-color);
|
||||
border-radius: 0.75rem;
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
}
|
||||
|
||||
.json-viewer {
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 0.5rem;
|
||||
overflow: hidden;
|
||||
@@ -189,7 +189,7 @@
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
|
||||
+6
-6
@@ -37,8 +37,8 @@
|
||||
// Search Section
|
||||
.search-section {
|
||||
flex-shrink: 0;
|
||||
background: var(--surface-ground);
|
||||
border: 1px solid var(--surface-border);
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
@@ -123,8 +123,8 @@
|
||||
justify-content: center;
|
||||
padding: 3rem;
|
||||
text-align: center;
|
||||
background: var(--surface-ground);
|
||||
border: 1px dashed var(--surface-border);
|
||||
background: var(--ground-background);
|
||||
border: 1px dashed var(--border-color);
|
||||
border-radius: 12px;
|
||||
|
||||
h3 {
|
||||
@@ -181,7 +181,7 @@
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 1rem;
|
||||
padding-bottom: 0.75rem;
|
||||
border-bottom: 1px solid var(--surface-border);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
|
||||
.results-count {
|
||||
display: flex;
|
||||
@@ -224,7 +224,7 @@
|
||||
height: 220px;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border: 2px solid transparent;
|
||||
|
||||
&:hover {
|
||||
|
||||
+3
-3
@@ -257,7 +257,7 @@
|
||||
border: 1px solid rgb(128 128 128 / 20%);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
@@ -349,7 +349,7 @@
|
||||
|
||||
.delete-info {
|
||||
padding: 1rem;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgb(128 128 128 / 20%);
|
||||
|
||||
@@ -394,7 +394,7 @@
|
||||
|
||||
.current-value {
|
||||
padding: 1rem;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border: 1px solid rgb(128 128 128 / 20%);
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1.5rem;
|
||||
|
||||
+3
-3
@@ -70,17 +70,17 @@
|
||||
.sidecar-section-header {
|
||||
margin-top: 1.5rem;
|
||||
padding-top: 1.5rem;
|
||||
border-top: 1px solid var(--surface-border);
|
||||
border-top: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.nested-setting {
|
||||
margin-left: 1.5rem;
|
||||
padding-left: 1rem;
|
||||
border-left: 2px solid var(--surface-border);
|
||||
border-left: 2px solid var(--border-color);
|
||||
}
|
||||
|
||||
code {
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
padding: 0.125rem 0.375rem;
|
||||
border-radius: 4px;
|
||||
font-family: monospace;
|
||||
|
||||
+4
-4
@@ -5,10 +5,10 @@
|
||||
}
|
||||
|
||||
.add-restriction-form {
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--surface-border);
|
||||
border: 1px solid var(--border-color);
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
@@ -76,10 +76,10 @@
|
||||
}
|
||||
|
||||
.restrictions-group {
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--surface-border);
|
||||
border: 1px solid var(--border-color);
|
||||
|
||||
.group-title {
|
||||
display: flex;
|
||||
|
||||
+3
-3
@@ -103,7 +103,7 @@
|
||||
}
|
||||
|
||||
.config-modal {
|
||||
background: var(--surface-card, rgb(30 30 30 / 95%));
|
||||
background: var(--card-background, rgb(30 30 30 / 95%));
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 20px 40px rgb(0 0 0 / 40%);
|
||||
border: 1px solid rgb(255 255 255 / 15%);
|
||||
@@ -120,7 +120,7 @@
|
||||
align-items: center;
|
||||
padding: 20px 25px;
|
||||
border-bottom: 1px solid rgb(255 255 255 / 10%);
|
||||
background: var(--surface-ground, rgb(40 40 40 / 80%));
|
||||
background: var(--ground-background, rgb(40 40 40 / 80%));
|
||||
|
||||
h3 {
|
||||
color: var(--text-color, #fff);
|
||||
@@ -167,7 +167,7 @@
|
||||
gap: 12px;
|
||||
padding: 20px 25px;
|
||||
border-bottom: 1px solid rgb(255 255 255 / 10%);
|
||||
background: var(--surface-ground, rgb(35 35 35 / 60%));
|
||||
background: var(--ground-background, rgb(35 35 35 / 60%));
|
||||
|
||||
.config-action-btn {
|
||||
background: rgb(255 255 255 / 10%);
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import {describe, expect, expectTypeOf, it} from 'vitest';
|
||||
|
||||
import {MenuChangeEvent} from './menuchangeevent';
|
||||
|
||||
describe('menuchangeevent', () => {
|
||||
it('supports route-backed menu change events', () => {
|
||||
const event: MenuChangeEvent = {
|
||||
key: 'settings',
|
||||
routeEvent: true
|
||||
};
|
||||
|
||||
expect(event.key).toBe('settings');
|
||||
expect(event.routeEvent).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps routeEvent optional', () => {
|
||||
expectTypeOf<MenuChangeEvent['routeEvent']>().toEqualTypeOf<boolean | undefined>();
|
||||
});
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
export interface MenuChangeEvent {
|
||||
key: string;
|
||||
routeEvent?: boolean;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<div class="layout-wrapper" [ngClass]="containerClass">
|
||||
<app-topbar></app-topbar>
|
||||
<div class="layout-sidebar">
|
||||
<app-sidebar></app-sidebar>
|
||||
</div>
|
||||
<div class="layout-main-container">
|
||||
<div class="layout-main">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-mask"></div>
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
/* Intentionally empty: layout shell styles are defined in child surfaces. */
|
||||
@@ -1,16 +0,0 @@
|
||||
import {describe, it} from 'vitest';
|
||||
|
||||
// NOTE(frontend-seam): Honest layout coverage needs a host harness for router events, renderer
|
||||
// listeners, overlay subscriptions, body-scroll mutation, and view-child/sidebar interactions.
|
||||
// In its current shape the component is mostly runtime orchestration around global DOM listeners.
|
||||
describe.skip('AppLayoutComponent', () => {
|
||||
it('needs a router-overlay seam to verify menu hiding on navigation and overlay clicks', () => {
|
||||
// TODO(seam): Cover outside-click detection and overlay subscription behavior after router
|
||||
// events and renderer listeners are exposed behind a testable boundary.
|
||||
});
|
||||
|
||||
it('needs a document-style seam to verify sidebar width initialization and body scroll toggling', () => {
|
||||
// TODO(seam): Cover local-storage width hydration and blocked-scroll lifecycle once global
|
||||
// document mutations can be asserted without brittle DOM listener wiring.
|
||||
});
|
||||
});
|
||||
@@ -1,129 +0,0 @@
|
||||
import {Component, inject, OnDestroy, OnInit, Renderer2, ViewChild} from '@angular/core';
|
||||
import {NavigationEnd, Router, RouterOutlet} from '@angular/router';
|
||||
import {filter, Subscription} from 'rxjs';
|
||||
import {LayoutService} from "./service/app.layout.service";
|
||||
import {AppSidebarComponent} from "../layout-sidebar/app.sidebar.component";
|
||||
import {AppTopBarComponent} from '../layout-topbar/app.topbar.component';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {ToastModule} from 'primeng/toast';
|
||||
import {LocalStorageService} from '../../../service/local-storage.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
imports: [
|
||||
RouterOutlet,
|
||||
AppSidebarComponent,
|
||||
AppTopBarComponent,
|
||||
NgClass,
|
||||
ToastModule
|
||||
],
|
||||
templateUrl: './app.layout.component.html'
|
||||
})
|
||||
export class AppLayoutComponent implements OnInit, OnDestroy {
|
||||
public layoutService = inject(LayoutService);
|
||||
public renderer = inject(Renderer2);
|
||||
public router = inject(Router);
|
||||
private localStorageService = inject(LocalStorageService);
|
||||
|
||||
overlayMenuOpenSubscription!: Subscription;
|
||||
|
||||
menuOutsideClickListener: (() => void) | null = null;
|
||||
|
||||
profileMenuOutsideClickListener: (() => void) | null = null;
|
||||
|
||||
@ViewChild(AppSidebarComponent) appSidebar!: AppSidebarComponent;
|
||||
|
||||
@ViewChild(AppTopBarComponent) appTopbar!: AppTopBarComponent;
|
||||
|
||||
constructor() {
|
||||
this.overlayMenuOpenSubscription = this.layoutService.overlayOpen$.subscribe(() => {
|
||||
if (!this.menuOutsideClickListener) {
|
||||
this.menuOutsideClickListener = this.renderer.listen('document', 'click', (event) => {
|
||||
if (this.isOutsideClicked(event)) {
|
||||
this.hideMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.layoutService.state.staticMenuMobileActive) {
|
||||
this.blockBodyScroll();
|
||||
}
|
||||
});
|
||||
|
||||
this.router.events.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe(() => {
|
||||
this.hideMenu();
|
||||
this.hideProfileMenu();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const width = this.localStorageService.get<number>('sidebarWidth') ?? 225;
|
||||
document.documentElement.style.setProperty('--sidebar-width', width + 'px');
|
||||
}
|
||||
|
||||
isOutsideClicked(event: MouseEvent): boolean {
|
||||
const sidebarEl = document.querySelector('.layout-sidebar');
|
||||
const topbarEl = document.querySelector('.layout-menu-button');
|
||||
const eventTarget = event.target as Node;
|
||||
const clickedInsideSidebar = sidebarEl?.isSameNode(eventTarget) || sidebarEl?.contains(eventTarget);
|
||||
const clickedInsideTopbar = topbarEl?.isSameNode(eventTarget) || topbarEl?.contains(eventTarget);
|
||||
return !(clickedInsideSidebar || clickedInsideTopbar);
|
||||
}
|
||||
|
||||
hideMenu() {
|
||||
this.layoutService.state.overlayMenuActive = false;
|
||||
this.layoutService.state.staticMenuMobileActive = false;
|
||||
this.layoutService.state.menuHoverActive = false;
|
||||
if (this.menuOutsideClickListener) {
|
||||
this.menuOutsideClickListener();
|
||||
this.menuOutsideClickListener = null;
|
||||
}
|
||||
this.unblockBodyScroll();
|
||||
}
|
||||
|
||||
hideProfileMenu() {
|
||||
this.layoutService.state.profileSidebarVisible = false;
|
||||
if (this.profileMenuOutsideClickListener) {
|
||||
this.profileMenuOutsideClickListener();
|
||||
this.profileMenuOutsideClickListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
blockBodyScroll(): void {
|
||||
if (document.body.classList) {
|
||||
document.body.classList.add('blocked-scroll');
|
||||
} else {
|
||||
document.body.className += ' blocked-scroll';
|
||||
}
|
||||
}
|
||||
|
||||
unblockBodyScroll(): void {
|
||||
if (document.body.classList) {
|
||||
document.body.classList.remove('blocked-scroll');
|
||||
} else {
|
||||
document.body.className = document.body.className.replace(new RegExp('(^|\\b)' +
|
||||
'blocked-scroll'.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
||||
}
|
||||
}
|
||||
|
||||
get containerClass() {
|
||||
return {
|
||||
'layout-overlay': this.layoutService.config().menuMode === 'overlay',
|
||||
'layout-static': this.layoutService.config().menuMode === 'static',
|
||||
'layout-static-inactive': this.layoutService.state.staticMenuDesktopInactive && this.layoutService.config().menuMode === 'static',
|
||||
'layout-overlay-active': this.layoutService.state.overlayMenuActive,
|
||||
'layout-mobile-active': this.layoutService.state.staticMenuMobileActive
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.overlayMenuOpenSubscription) {
|
||||
this.overlayMenuOpenSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
if (this.menuOutsideClickListener) {
|
||||
this.menuOutsideClickListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
|
||||
import {LayoutService} from './app.layout.service';
|
||||
|
||||
describe('LayoutService', () => {
|
||||
let service: LayoutService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [LayoutService],
|
||||
});
|
||||
|
||||
service = TestBed.inject(LayoutService);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('detects when the configured theme style changes', () => {
|
||||
expect(service.updateStyle(service.config())).toBe(false);
|
||||
|
||||
service.config.set({
|
||||
...service.config(),
|
||||
theme: 'lara-dark-indigo',
|
||||
});
|
||||
|
||||
expect(service.updateStyle(service.config())).toBe(true);
|
||||
});
|
||||
|
||||
it('toggles the overlay menu and emits overlay-open notifications on desktop', () => {
|
||||
let overlayOpenCount = 0;
|
||||
service.config.set({
|
||||
...service.config(),
|
||||
menuMode: 'overlay',
|
||||
});
|
||||
service.overlayOpen$.subscribe(() => {
|
||||
overlayOpenCount += 1;
|
||||
});
|
||||
|
||||
Object.defineProperty(window, 'innerWidth', {configurable: true, value: 1280});
|
||||
service.onMenuToggle();
|
||||
|
||||
expect(service.state.overlayMenuActive).toBe(true);
|
||||
expect(service.state.staticMenuDesktopInactive).toBe(true);
|
||||
expect(overlayOpenCount).toBe(1);
|
||||
});
|
||||
|
||||
it('toggles the mobile static menu and emits overlay-open notifications on small screens', () => {
|
||||
let overlayOpenCount = 0;
|
||||
service.overlayOpen$.subscribe(() => {
|
||||
overlayOpenCount += 1;
|
||||
});
|
||||
|
||||
Object.defineProperty(window, 'innerWidth', {configurable: true, value: 768});
|
||||
service.onMenuToggle();
|
||||
|
||||
expect(service.state.staticMenuMobileActive).toBe(true);
|
||||
expect(overlayOpenCount).toBe(1);
|
||||
});
|
||||
|
||||
it('derives the replacement theme href from the current config', () => {
|
||||
const replaceThemeLinkSpy = vi.spyOn(service, 'replaceThemeLink').mockImplementation(() => undefined);
|
||||
const themeLink = document.createElement('link');
|
||||
themeLink.id = 'theme-css';
|
||||
themeLink.setAttribute('href', '/themes/lara-light-indigo/theme-light/theme.css');
|
||||
document.body.appendChild(themeLink);
|
||||
|
||||
service._config = {
|
||||
...service._config,
|
||||
theme: 'lara-light-indigo',
|
||||
colorScheme: 'light',
|
||||
};
|
||||
service.config.set({
|
||||
...service.config(),
|
||||
theme: 'lara-dark-indigo',
|
||||
colorScheme: 'dark',
|
||||
});
|
||||
|
||||
service.changeTheme();
|
||||
|
||||
expect(replaceThemeLinkSpy).toHaveBeenCalledWith('/themes/lara-dark-indigo/theme-dark/theme.css');
|
||||
themeLink.remove();
|
||||
});
|
||||
|
||||
it('updates the document root font size when the scale changes', () => {
|
||||
service.changeScale(18);
|
||||
|
||||
expect(document.documentElement.style.fontSize).toBe('18px');
|
||||
});
|
||||
});
|
||||
@@ -1,138 +0,0 @@
|
||||
import {Injectable, effect, signal} from '@angular/core';
|
||||
import {Subject} from 'rxjs';
|
||||
|
||||
export interface AppConfig {
|
||||
inputStyle: string;
|
||||
colorScheme: string;
|
||||
theme: string;
|
||||
ripple: boolean;
|
||||
menuMode: string;
|
||||
scale: number;
|
||||
}
|
||||
|
||||
interface LayoutState {
|
||||
staticMenuDesktopInactive: boolean;
|
||||
overlayMenuActive: boolean;
|
||||
profileSidebarVisible: boolean;
|
||||
configSidebarVisible: boolean;
|
||||
staticMenuMobileActive: boolean;
|
||||
menuHoverActive: boolean;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LayoutService {
|
||||
_config: AppConfig = {
|
||||
ripple: false,
|
||||
inputStyle: 'outlined',
|
||||
menuMode: 'static',
|
||||
colorScheme: 'light',
|
||||
theme: 'lara-light-indigo',
|
||||
scale: 14,
|
||||
};
|
||||
|
||||
config = signal<AppConfig>(this._config);
|
||||
|
||||
state: LayoutState = {
|
||||
staticMenuDesktopInactive: false,
|
||||
overlayMenuActive: false,
|
||||
profileSidebarVisible: false,
|
||||
configSidebarVisible: false,
|
||||
staticMenuMobileActive: false,
|
||||
menuHoverActive: false,
|
||||
};
|
||||
|
||||
private configUpdate = new Subject<AppConfig>();
|
||||
private overlayOpen = new Subject<unknown>();
|
||||
overlayOpen$ = this.overlayOpen.asObservable();
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const config = this.config();
|
||||
if (this.updateStyle(config)) {
|
||||
this.changeTheme();
|
||||
}
|
||||
this.changeScale(config.scale);
|
||||
this.onConfigUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
updateStyle(config: AppConfig) {
|
||||
return (
|
||||
config.theme !== this._config.theme ||
|
||||
config.colorScheme !== this._config.colorScheme
|
||||
);
|
||||
}
|
||||
|
||||
onMenuToggle() {
|
||||
if (this.isOverlay()) {
|
||||
this.state.overlayMenuActive = !this.state.overlayMenuActive;
|
||||
if (this.state.overlayMenuActive) {
|
||||
this.overlayOpen.next(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isDesktop()) {
|
||||
this.state.staticMenuDesktopInactive = !this.state.staticMenuDesktopInactive;
|
||||
} else {
|
||||
this.state.staticMenuMobileActive = !this.state.staticMenuMobileActive;
|
||||
if (this.state.staticMenuMobileActive) {
|
||||
this.overlayOpen.next(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isOverlay() {
|
||||
return this.config().menuMode === 'overlay';
|
||||
}
|
||||
|
||||
isDesktop() {
|
||||
return window.innerWidth > 991;
|
||||
}
|
||||
|
||||
onConfigUpdate() {
|
||||
this._config = {...this.config()};
|
||||
this.configUpdate.next(this.config());
|
||||
}
|
||||
|
||||
changeTheme() {
|
||||
const config = this.config();
|
||||
const themeLink = document.getElementById('theme-css') as HTMLLinkElement;
|
||||
const themeLinkHref = themeLink.getAttribute('href')!;
|
||||
const newHref = themeLinkHref
|
||||
.split('/')
|
||||
.map((el) =>
|
||||
el == this._config.theme
|
||||
? config.theme
|
||||
: el == `theme-${this._config.colorScheme}`
|
||||
? `theme-${config.colorScheme}`
|
||||
: el
|
||||
)
|
||||
.join('/');
|
||||
|
||||
this.replaceThemeLink(newHref);
|
||||
}
|
||||
|
||||
replaceThemeLink(href: string) {
|
||||
const id = 'theme-css';
|
||||
const themeLink = document.getElementById(id) as HTMLLinkElement;
|
||||
const cloneLinkElement = themeLink.cloneNode(true) as HTMLLinkElement;
|
||||
|
||||
cloneLinkElement.setAttribute('href', href);
|
||||
cloneLinkElement.setAttribute('id', id + '-clone');
|
||||
|
||||
themeLink.parentNode!.insertBefore(
|
||||
cloneLinkElement,
|
||||
themeLink.nextSibling
|
||||
);
|
||||
cloneLinkElement.addEventListener('load', () => {
|
||||
themeLink.remove();
|
||||
cloneLinkElement.setAttribute('id', id);
|
||||
});
|
||||
}
|
||||
|
||||
changeScale(value: number) {
|
||||
document.documentElement.style.fontSize = `${value}px`;
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<ng-container>
|
||||
@if (root) {
|
||||
@if (item.hasDropDown) {
|
||||
<div class="layout-menuitem-root-text root-item-with-dropdown">
|
||||
<div class="root-item-label-container">
|
||||
<div>{{ item.label }}</div>
|
||||
@if (item.hasCreate) {
|
||||
<i
|
||||
class="pi pi-plus plus-icon"
|
||||
(click)="openDialog(item)"
|
||||
(keydown.enter)="openDialog(item)"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
></i>
|
||||
}
|
||||
</div>
|
||||
<i
|
||||
(click)="toggleExpand(key)"
|
||||
(keydown.enter)="toggleExpand(key)"
|
||||
[ngClass]="{
|
||||
'pi': true,
|
||||
'pi-angle-up': isExpanded(key),
|
||||
'pi-angle-down': !isExpanded(key)
|
||||
}"
|
||||
class="expand-icon"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
></i>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="layout-menuitem-root-text root-item">
|
||||
<div>{{ item.label }}</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<div>
|
||||
<div
|
||||
class="menu-item-container"
|
||||
[class.active-route-container]="isRouteActive"
|
||||
(click)="triggerLink()"
|
||||
(keydown.enter)="triggerLink()"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
@if ((item.routerLink && !item.items)) {
|
||||
<a
|
||||
#link
|
||||
(click)="itemClick($event)"
|
||||
[ngClass]="item.class"
|
||||
class="menu-item-link"
|
||||
[class.active-route]="isRouteActive"
|
||||
[routerLink]="item.routerLink"
|
||||
[fragment]="item.fragment"
|
||||
[queryParamsHandling]="item.queryParamsHandling"
|
||||
[preserveFragment]="item.preserveFragment"
|
||||
[skipLocationChange]="item.skipLocationChange"
|
||||
[replaceUrl]="item.replaceUrl"
|
||||
[state]="item.state"
|
||||
[queryParams]="item.queryParams"
|
||||
[attr.target]="item.target"
|
||||
tabindex="0"
|
||||
pRipple
|
||||
>
|
||||
@if (item.unhealthy) {
|
||||
<span
|
||||
class="library-health-dot"
|
||||
[pTooltip]="'common.libraryPathInaccessible' | transloco"
|
||||
tooltipPosition="right"
|
||||
></span>
|
||||
}
|
||||
<app-icon-display
|
||||
[icon]="getIconSelection()"
|
||||
iconClass="layout-menuitem-icon"
|
||||
size="18px"
|
||||
[displayEmpty]="true"
|
||||
></app-icon-display>
|
||||
<span class="layout-menuitem-text menu-item-text">
|
||||
{{ item.label }}
|
||||
</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
<span class="menu-item-end-content">
|
||||
@if (item.type === 'Library' || item.type === 'Shelf' || item.type === 'magicShelfItem') {
|
||||
@if ((item.type !== 'Library' || (admin || canManipulateLibrary)) && item.label !== 'Unshelved' && item.label !== 'Kobo') {
|
||||
<p-button
|
||||
(click)="entitymenu.toggle($event); $event.stopPropagation()"
|
||||
(mouseover)="hovered = true"
|
||||
(focus)="hovered = true"
|
||||
(mouseleave)="hovered = false"
|
||||
(blur)="hovered = false"
|
||||
(keydown.enter)="entitymenu.toggle($event); $event.stopPropagation()"
|
||||
[text]="true"
|
||||
[outlined]="false"
|
||||
[rounded]="true"
|
||||
[label]="hovered ? '' : item.bookCount?.toString() || ''"
|
||||
[icon]="hovered ? 'pi pi-ellipsis-v' : ''"
|
||||
class="entity-menu-button"
|
||||
tabindex="0"
|
||||
></p-button>
|
||||
}
|
||||
<p-menu #entitymenu [model]="item.menu" [popup]="true" appendTo="body"></p-menu>
|
||||
}
|
||||
|
||||
@if (item.type === 'Library' && (!admin && !canManipulateLibrary) || item.type === 'All Books' || item.type === 'Series' || item.type === 'Authors' || item.label === 'Unshelved' || item.label === 'Kobo') {
|
||||
<p class="book-count">
|
||||
{{ formatCount(item.bookCount) }}
|
||||
</p>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div [@children]="isExpanded(key) ? 'expanded' : 'collapsed'" class="submenu-container">
|
||||
@if (item.items) {
|
||||
<ul>
|
||||
@for (child of item.items; track child.routerLink?.[0] ?? child.label; let i = $index) {
|
||||
<app-menuitem [item]="child" [index]="i" [parentKey]="key" [class]="child.badgeClass"></app-menuitem>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
@@ -1,16 +0,0 @@
|
||||
import {describe, it} from 'vitest';
|
||||
|
||||
// NOTE(frontend-seam): This menu item coordinates router state, menu-service broadcasts, user
|
||||
// permission effects, dialog launchers, nested expansion state, and link/view-child behavior.
|
||||
// Useful coverage needs a purpose-built menu host seam, not a brittle isolated mock tangle.
|
||||
describe.skip('AppMenuitemComponent', () => {
|
||||
it('needs a menu-service and router seam to verify active-state propagation and route activation', () => {
|
||||
// TODO(seam): Cover route-driven activation, menu broadcasts, and nested expansion after the
|
||||
// component can be exercised inside a stable menu host harness.
|
||||
});
|
||||
|
||||
it('needs a dialog/link seam to verify openDialog, triggerLink, and icon/count formatting behavior', () => {
|
||||
// TODO(seam): Cover command, dialog, and link behavior once those side effects are surfaced
|
||||
// behind a narrower, test-friendly contract.
|
||||
});
|
||||
});
|
||||
@@ -1,227 +0,0 @@
|
||||
import {Component, effect, ElementRef, HostBinding, inject, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||
import {NavigationEnd, Router, RouterLink} from '@angular/router';
|
||||
import {animate, state, style, transition, trigger} from '@angular/animations';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {MenuService} from './service/app.menu.service';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {Ripple} from 'primeng/ripple';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Menu} from 'primeng/menu';
|
||||
import {UserService} from '../../../../features/settings/user-management/user.service';
|
||||
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
||||
import {BookDialogHelperService} from '../../../../features/book/components/book-browser/book-dialog-helper.service';
|
||||
import {IconDisplayComponent} from '../../../components/icon-display/icon-display.component';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {IconSelection} from '../../../service/icon-picker.service';
|
||||
import {TranslocoPipe} from '@jsverse/transloco';
|
||||
import {MenuItem, MenuItemCommandEvent} from 'primeng/api';
|
||||
|
||||
type AppMenuItem = Omit<MenuItem, 'items'> & {
|
||||
items?: AppMenuItem[];
|
||||
label?: string;
|
||||
routerLink?: string[];
|
||||
queryParams?: MenuItem['queryParams'];
|
||||
queryParamsHandling?: MenuItem['queryParamsHandling'];
|
||||
fragment?: string;
|
||||
preserveFragment?: boolean;
|
||||
skipLocationChange?: boolean;
|
||||
replaceUrl?: boolean;
|
||||
state?: MenuItem['state'];
|
||||
target?: string;
|
||||
type?: 'library' | 'magicShelf' | 'shelf' | string;
|
||||
iconType?: IconSelection['type'];
|
||||
icon?: string;
|
||||
disabled?: boolean;
|
||||
command?: (event: MenuItemCommandEvent) => void;
|
||||
class?: string;
|
||||
menu?: MenuItem[];
|
||||
badgeClass?: string;
|
||||
unhealthy?: boolean;
|
||||
bookCount?: number;
|
||||
hasDropDown?: boolean;
|
||||
hasCreate?: boolean;
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-menuitem',
|
||||
templateUrl: './app.menuitem.component.html',
|
||||
styleUrls: ['./app.menuitem.component.scss'],
|
||||
imports: [
|
||||
RouterLink,
|
||||
NgClass,
|
||||
Ripple,
|
||||
Button,
|
||||
Menu,
|
||||
IconDisplayComponent,
|
||||
Tooltip,
|
||||
TranslocoPipe
|
||||
],
|
||||
animations: [
|
||||
trigger('children', [
|
||||
state('collapsed', style({
|
||||
height: '0'
|
||||
})),
|
||||
state('expanded', style({
|
||||
height: '*'
|
||||
})),
|
||||
transition('collapsed <=> expanded', animate('400ms cubic-bezier(0.86, 0, 0.07, 1)'))
|
||||
])
|
||||
]
|
||||
})
|
||||
export class AppMenuitemComponent implements OnInit, OnDestroy {
|
||||
@Input() item!: AppMenuItem;
|
||||
@Input() index!: number;
|
||||
@Input() @HostBinding('class.layout-root-menuitem') root!: boolean;
|
||||
@Input() parentKey!: string;
|
||||
@Input() menuKey!: string;
|
||||
@ViewChild('linkRef') linkRef!: ElementRef<HTMLAnchorElement>;
|
||||
|
||||
hovered = false;
|
||||
active = false;
|
||||
key: string = "";
|
||||
canManipulateLibrary: boolean = false;
|
||||
admin: boolean = false;
|
||||
expandedItems = new Set<string>();
|
||||
|
||||
get isRouteActive(): boolean {
|
||||
if (!this.item?.routerLink?.[0]) return false;
|
||||
return this.router.url.split('?')[0] === this.item.routerLink[0];
|
||||
}
|
||||
|
||||
private userService = inject(UserService);
|
||||
public router = inject(Router);
|
||||
private menuService = inject(MenuService);
|
||||
private dialogLauncher = inject(DialogLauncherService);
|
||||
private bookDialogHelperService = inject(BookDialogHelperService);
|
||||
menuSourceSubscription: Subscription;
|
||||
menuResetSubscription: Subscription;
|
||||
private routerSubscription: Subscription;
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const user = this.userService.currentUser();
|
||||
if (user) {
|
||||
this.canManipulateLibrary = user.permissions.canManageLibrary;
|
||||
this.admin = user.permissions.admin;
|
||||
}
|
||||
});
|
||||
|
||||
this.menuSourceSubscription = this.menuService.menuSource$.subscribe(value => {
|
||||
Promise.resolve(null).then(() => {
|
||||
if (value.routeEvent) {
|
||||
this.active = (value.key === this.key || value.key.startsWith(this.key + '-')) ? true : false;
|
||||
} else {
|
||||
if (value.key !== this.key && !value.key.startsWith(this.key + '-')) {
|
||||
this.active = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.menuResetSubscription = this.menuService.resetSource$.subscribe(() => {
|
||||
this.active = false;
|
||||
});
|
||||
|
||||
this.routerSubscription = this.router.events.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe(() => {
|
||||
if (this.item.routerLink) {
|
||||
this.updateActiveStateFromRoute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
const rootKey = this.menuKey ? this.menuKey + '-' : '';
|
||||
this.key = this.parentKey ? this.parentKey + '-' + this.index : rootKey + String(this.index);
|
||||
this.expandedItems.add(this.key);
|
||||
if (this.item.routerLink) {
|
||||
this.updateActiveStateFromRoute();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.menuSourceSubscription?.unsubscribe();
|
||||
this.menuResetSubscription?.unsubscribe();
|
||||
this.routerSubscription?.unsubscribe();
|
||||
}
|
||||
|
||||
toggleExpand(key: string) {
|
||||
if (this.expandedItems.has(key)) {
|
||||
this.expandedItems.delete(key);
|
||||
} else {
|
||||
this.expandedItems.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
isExpanded(key: string): boolean {
|
||||
return this.expandedItems.has(key);
|
||||
}
|
||||
|
||||
updateActiveStateFromRoute() {
|
||||
const firstRoute = this.item.routerLink?.[0];
|
||||
if (!firstRoute) {
|
||||
return;
|
||||
}
|
||||
|
||||
const activeRoute = this.router.isActive(firstRoute, {
|
||||
paths: 'exact',
|
||||
queryParams: 'ignored',
|
||||
matrixParams: 'ignored',
|
||||
fragment: 'ignored'
|
||||
});
|
||||
if (activeRoute) {
|
||||
this.menuService.onMenuStateChange({key: this.key, routeEvent: true});
|
||||
}
|
||||
}
|
||||
|
||||
itemClick(event: Event) {
|
||||
if (this.item.disabled) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (this.item.command) {
|
||||
this.item.command({originalEvent: event, item: this.item});
|
||||
}
|
||||
if (this.item.items) {
|
||||
this.active = !this.active;
|
||||
} else {
|
||||
this.active = true;
|
||||
}
|
||||
this.menuService.onMenuStateChange({key: this.key});
|
||||
}
|
||||
|
||||
openDialog(item: AppMenuItem) {
|
||||
if (item.type === 'library' && this.canManipulateLibrary) {
|
||||
this.dialogLauncher.openLibraryCreateDialog();
|
||||
}
|
||||
if (item.type === 'magicShelf') {
|
||||
this.dialogLauncher.openMagicShelfCreateDialog();
|
||||
}
|
||||
if (item.type === 'shelf') {
|
||||
this.bookDialogHelperService.openShelfCreatorDialog();
|
||||
}
|
||||
}
|
||||
|
||||
triggerLink() {
|
||||
if (this.item.routerLink && !this.item.items && this.linkRef) {
|
||||
this.linkRef.nativeElement.click();
|
||||
}
|
||||
}
|
||||
|
||||
formatCount(count: number | null | undefined): string {
|
||||
if (count == null) return '0';
|
||||
if (count >= 1000) return Math.floor(count / 1000) + 'K';
|
||||
return count.toString();
|
||||
}
|
||||
|
||||
getIconSelection(): IconSelection | null {
|
||||
if (!this.item.icon) return null;
|
||||
|
||||
return {
|
||||
type: this.item.iconType || 'PRIME_NG',
|
||||
value: this.item.icon
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
import {MenuService} from './app.menu.service';
|
||||
|
||||
describe('MenuService', () => {
|
||||
it('broadcasts menu state changes and reset events', () => {
|
||||
const service = new MenuService();
|
||||
const menuEvents: unknown[] = [];
|
||||
const resets: unknown[] = [];
|
||||
|
||||
const menuSubscription = service.menuSource$.subscribe(event => menuEvents.push(event));
|
||||
const resetSubscription = service.resetSource$.subscribe(event => resets.push(event));
|
||||
|
||||
service.onMenuStateChange({key: 'settings'});
|
||||
service.reset();
|
||||
|
||||
expect(menuEvents).toEqual([{key: 'settings'}]);
|
||||
expect(resets).toEqual([true]);
|
||||
|
||||
menuSubscription.unsubscribe();
|
||||
resetSubscription.unsubscribe();
|
||||
});
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { MenuChangeEvent } from '../../../api/menuchangeevent';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MenuService {
|
||||
|
||||
private menuSource = new Subject<MenuChangeEvent>();
|
||||
private resetSource = new Subject();
|
||||
|
||||
menuSource$ = this.menuSource.asObservable();
|
||||
resetSource$ = this.resetSource.asObservable();
|
||||
|
||||
onMenuStateChange(event: MenuChangeEvent) {
|
||||
this.menuSource.next(event);
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.resetSource.next(true);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<app-menu></app-menu>
|
||||
@@ -1 +0,0 @@
|
||||
/* Intentionally empty: sidebar presentation is composed from nested components. */
|
||||
@@ -1,11 +0,0 @@
|
||||
import {describe, it} from 'vitest';
|
||||
|
||||
// NOTE(frontend-seam): This component is effectively a thin runtime bridge to layout state plus
|
||||
// a nested menu tree. A worthwhile spec should be written together with a host/layout seam rather
|
||||
// than as an empty shell assertion.
|
||||
describe.skip('AppSidebarComponent', () => {
|
||||
it('needs a layout host seam to verify sidebar/menu integration without shallow shell noise', () => {
|
||||
// TODO(seam): Cover layout state and nested menu rendering once the sidebar is exercised
|
||||
// through the same host harness that will be needed for layout/menu behavior.
|
||||
});
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
import {Component, ElementRef, inject} from '@angular/core';
|
||||
import { LayoutService } from "../layout-main/service/app.layout.service";
|
||||
import {AppMenuComponent} from '../layout-menu/app.menu.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar',
|
||||
imports: [
|
||||
AppMenuComponent
|
||||
],
|
||||
templateUrl: './app.sidebar.component.html'
|
||||
})
|
||||
export class AppSidebarComponent {
|
||||
public layoutService = inject(LayoutService);
|
||||
public el = inject(ElementRef);
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
<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>
|
||||
|
||||
<p-button class="layout-menu-button" #menubutton icon="pi pi-bars" [rounded]="true" [outlined]="true"
|
||||
(click)="toggleMenu()" [ngClass]="{ 'rotate-right': !isMenuVisible, 'rotate-left': isMenuVisible }">
|
||||
</p-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>
|
||||
<a class="topbar-item" role="button" tabindex="0" (click)="navigateToBookdrop()"
|
||||
(keydown.enter)="navigateToBookdrop()" [pTooltip]="t('bookdrop')" tooltipPosition="bottom">
|
||||
<i class="pi pi-inbox topbar-icon"></i>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@if (currentUser.permissions?.canManageLibrary || currentUser.permissions?.admin) {
|
||||
<li>
|
||||
<a class="topbar-item" role="button" tabindex="0" (click)="openLibraryCreatorDialog()"
|
||||
(keydown.enter)="openLibraryCreatorDialog()" [pTooltip]="t('createNewLibrary')" tooltipPosition="bottom">
|
||||
<i class="pi pi-plus-circle topbar-icon"></i>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@if (currentUser.permissions?.canUpload || currentUser.permissions?.admin) {
|
||||
<li>
|
||||
<a class="topbar-item" role="button" tabindex="0" (click)="openFileUploadDialog()"
|
||||
(keydown.enter)="openFileUploadDialog()" [pTooltip]="t('uploadBook')" tooltipPosition="bottom">
|
||||
<i class="pi pi-upload topbar-icon"></i>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
@if (hasStatsAccess) {
|
||||
<li>
|
||||
<button class="topbar-item"
|
||||
(click)="shouldShowStatsMenu ? statsMenu?.toggle($event) : handleStatsButtonClick($event)"
|
||||
[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>
|
||||
<a class="topbar-item" role="button" tabindex="0" (click)="navigateToMetadataManager()"
|
||||
(keydown.enter)="navigateToMetadataManager()" [pTooltip]="t('metadataManager')" tooltipPosition="bottom">
|
||||
<i class="pi pi-sparkles topbar-icon"></i>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
<li>
|
||||
<a class="topbar-item" role="button" tabindex="0" (click)="navigateToSettings()"
|
||||
(keydown.enter)="navigateToSettings()" [pTooltip]="t('settings')" tooltipPosition="bottom">
|
||||
<i class="pi pi-cog topbar-icon"></i>
|
||||
</a>
|
||||
</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 class="topbar-item" (click)="openUserProfileDialog()" [pTooltip]="t('profile')"
|
||||
tooltipPosition="bottom">
|
||||
<i class="pi pi-user topbar-icon"></i>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
|
||||
<li>
|
||||
<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">
|
||||
<p-button icon="pi pi-ellipsis-v" outlined (click)="mobileMenu.toggle($event)" />
|
||||
<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 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,14 @@
|
||||
<ng-container *transloco="let t; prefix: 'layout'">
|
||||
<div class="layout-wrapper" [ngClass]="containerClass()">
|
||||
<app-topbar></app-topbar>
|
||||
<div class="layout-sidebar">
|
||||
<app-menu></app-menu>
|
||||
</div>
|
||||
<div class="layout-main-container">
|
||||
<div class="layout-main">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="layout-mask" [attr.aria-label]="t('closeNavigation')" (click)="closeMobileSidebar()"></button>
|
||||
</div>
|
||||
</ng-container>
|
||||
@@ -0,0 +1,113 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideRouter, Router } from '@angular/router';
|
||||
import { TranslocoTestingModule } from '@jsverse/transloco';
|
||||
import { AppLayoutComponent } from './app.layout.component';
|
||||
import { AppMenuComponent } from '../layout-menu/app.menu.component';
|
||||
import { AppTopBarComponent } from '../layout-topbar/app.topbar.component';
|
||||
import { LocalStorageService } from '../../service/local-storage.service';
|
||||
import { LayoutService } from '../layout.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-menu',
|
||||
standalone: true,
|
||||
template: '',
|
||||
})
|
||||
class StubMenuComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'app-topbar',
|
||||
standalone: true,
|
||||
template: '',
|
||||
})
|
||||
class StubTopBarComponent {}
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
template: '',
|
||||
})
|
||||
class DummyRouteComponent {}
|
||||
|
||||
describe('AppLayoutComponent', () => {
|
||||
let fixture: ComponentFixture<AppLayoutComponent>;
|
||||
let router: Router;
|
||||
let layoutService: LayoutService;
|
||||
|
||||
const localStorageService = {
|
||||
get: vi.fn(() => 225),
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
AppLayoutComponent,
|
||||
TranslocoTestingModule.forRoot({ langs: {} }),
|
||||
],
|
||||
providers: [
|
||||
provideRouter([
|
||||
{ path: '', component: DummyRouteComponent },
|
||||
{ path: 'next', component: DummyRouteComponent },
|
||||
]),
|
||||
{ provide: LocalStorageService, useValue: localStorageService },
|
||||
],
|
||||
});
|
||||
|
||||
TestBed.overrideComponent(AppLayoutComponent, {
|
||||
remove: {
|
||||
imports: [AppMenuComponent, AppTopBarComponent],
|
||||
},
|
||||
add: {
|
||||
imports: [StubMenuComponent, StubTopBarComponent],
|
||||
},
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(AppLayoutComponent);
|
||||
router = TestBed.inject(Router);
|
||||
layoutService = TestBed.inject(LayoutService);
|
||||
|
||||
fixture.detectChanges();
|
||||
await router.navigateByUrl('/');
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.classList.remove('blocked-scroll');
|
||||
fixture?.destroy();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('closes the mobile sidebar when the mask is clicked', () => {
|
||||
layoutService.mobileSidebarOpen.set(true);
|
||||
fixture.detectChanges();
|
||||
|
||||
const mask = fixture.nativeElement.querySelector('.layout-mask') as HTMLDivElement;
|
||||
mask.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(layoutService.mobileSidebarOpen()).toBe(false);
|
||||
});
|
||||
|
||||
it('toggles the body scroll lock with mobile sidebar state', () => {
|
||||
layoutService.mobileSidebarOpen.set(true);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(document.body.classList.contains('blocked-scroll')).toBe(true);
|
||||
|
||||
layoutService.mobileSidebarOpen.set(false);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(document.body.classList.contains('blocked-scroll')).toBe(false);
|
||||
});
|
||||
|
||||
it('closes the mobile sidebar on navigation', async () => {
|
||||
layoutService.mobileSidebarOpen.set(true);
|
||||
fixture.detectChanges();
|
||||
|
||||
await router.navigateByUrl('/next');
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(layoutService.mobileSidebarOpen()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import { DOCUMENT, NgClass } from '@angular/common';
|
||||
import { computed, Component, DestroyRef, effect, inject, OnInit } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { NavigationEnd, Router, RouterOutlet } from '@angular/router';
|
||||
import { filter } from 'rxjs';
|
||||
import { LayoutService } from '../layout.service';
|
||||
import { AppMenuComponent } from '../layout-menu/app.menu.component';
|
||||
import { AppTopBarComponent } from '../layout-topbar/app.topbar.component';
|
||||
import { TranslocoDirective } from '@jsverse/transloco';
|
||||
import { LocalStorageService } from '../../service/local-storage.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
imports: [
|
||||
RouterOutlet,
|
||||
AppMenuComponent,
|
||||
AppTopBarComponent,
|
||||
NgClass,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './app.layout.component.html'
|
||||
})
|
||||
export class AppLayoutComponent implements OnInit {
|
||||
readonly layoutService = inject(LayoutService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly localStorageService = inject(LocalStorageService);
|
||||
private readonly document = inject(DOCUMENT);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
readonly containerClass = computed(() => ({
|
||||
'layout-static': true,
|
||||
'layout-static-inactive': !this.layoutService.sidebarOpen(),
|
||||
'layout-mobile-active': this.layoutService.mobileSidebarOpen()
|
||||
}));
|
||||
|
||||
constructor() {
|
||||
effect((onCleanup) => {
|
||||
const body = this.document.body;
|
||||
body.classList.toggle('blocked-scroll', this.layoutService.mobileSidebarOpen());
|
||||
onCleanup(() => {
|
||||
body.classList.remove('blocked-scroll');
|
||||
});
|
||||
});
|
||||
|
||||
this.router.events
|
||||
.pipe(
|
||||
filter((event): event is NavigationEnd => event instanceof NavigationEnd),
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.layoutService.closeMobileSidebar();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const width = this.localStorageService.get<number>('sidebarWidth') ?? 225;
|
||||
this.document.documentElement.style.setProperty('--sidebar-width', `${width}px`);
|
||||
}
|
||||
|
||||
closeMobileSidebar(): void {
|
||||
this.layoutService.closeMobileSidebar();
|
||||
}
|
||||
}
|
||||
+18
-27
@@ -5,17 +5,16 @@
|
||||
<ul class="layout-menu">
|
||||
@if (homeMenu(); as homeMenu) {
|
||||
@for (item of homeMenu; track item.label; let i = $index) {
|
||||
@if (!item.separator) {
|
||||
<app-menuitem [item]="item" [index]="i" [root]="true" menuKey="home"></app-menuitem>
|
||||
}
|
||||
<li app-menuitem [item]="item" [index]="i" [root]="true" menuKey="home"></li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
<i class="pi pi-objects-column sidebar-width-btn"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
(click)="widthPanel.toggle($event)"
|
||||
(keydown.enter)="widthPanel.toggle($event)"></i>
|
||||
<button
|
||||
type="button"
|
||||
class="sidebar-width-btn pi pi-objects-column"
|
||||
[attr.aria-label]="t('adjustSidebarWidth')"
|
||||
(click)="widthPanel.toggle($event)"
|
||||
></button>
|
||||
<p-popover #widthPanel appendTo="body">
|
||||
<div class="sidebar-width-popover">
|
||||
<span class="sidebar-width-popover-label">{{ sidebarWidth }}px</span>
|
||||
@@ -34,9 +33,7 @@
|
||||
<ul class="layout-menu">
|
||||
@if (libraryMenu(); as libraryMenu) {
|
||||
@for (item of libraryMenu; track item.label; let i = $index) {
|
||||
@if (!item.separator) {
|
||||
<app-menuitem [item]="item" [index]="i" [root]="true" menuKey="library"></app-menuitem>
|
||||
}
|
||||
<li app-menuitem [item]="item" [index]="i" [root]="true" menuKey="library"></li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
@@ -44,25 +41,21 @@
|
||||
<ul class="layout-menu">
|
||||
@if (shelfMenu(); as shelfMenu) {
|
||||
@for (item of shelfMenu; track item.label; let i = $index) {
|
||||
@if (!item.separator) {
|
||||
<app-menuitem [item]="item" [index]="i" [root]="true" menuKey="shelf"></app-menuitem>
|
||||
}
|
||||
<li app-menuitem [item]="item" [index]="i" [root]="true" menuKey="shelf"></li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
|
||||
<ul class="layout-menu">
|
||||
@if (magicShelfMenu(); as shelfMenu) {
|
||||
@for (item of shelfMenu; track item.label; let i = $index) {
|
||||
@if (!item.separator) {
|
||||
<app-menuitem [item]="item" [index]="i" [root]="true" menuKey="magicShelf"></app-menuitem>
|
||||
}
|
||||
@if (magicShelfMenu(); as magicShelfMenu) {
|
||||
@for (item of magicShelfMenu; track item.label; let i = $index) {
|
||||
<li app-menuitem [item]="item" [index]="i" [root]="true" menuKey="magicShelf"></li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@if (versionInfo) {
|
||||
@if (versionInfo(); as versionInfo) {
|
||||
<div class="version-info" style="margin-top: auto;">
|
||||
<div class="version-text">
|
||||
@if (isSemanticVersion(versionInfo.current)) {
|
||||
@@ -80,15 +73,13 @@
|
||||
</div>
|
||||
@if (isSemanticVersion(versionInfo.current) && versionInfo.latest && versionInfo.latest !== versionInfo.current) {
|
||||
<div>
|
||||
<a
|
||||
(click)="openChangelogDialog()"
|
||||
<button
|
||||
type="button"
|
||||
class="update-link"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
(keydown.enter)="openChangelogDialog()"
|
||||
>
|
||||
(click)="openChangelogDialog()"
|
||||
>
|
||||
{{ t('update') }}
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
+18
-7
@@ -11,13 +11,19 @@
|
||||
position: absolute;
|
||||
top: 0.125rem;
|
||||
right: 0.5rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
font-size: 0.8rem;
|
||||
color: var(--p-surface-500);
|
||||
color: var(--surface-500);
|
||||
cursor: pointer;
|
||||
transition: color 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
color: var(--p-primary-color);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +37,7 @@
|
||||
|
||||
.sidebar-width-popover-label {
|
||||
font-size: 0.8rem;
|
||||
color: var(--p-text-muted-color);
|
||||
color: var(--text-muted-color);
|
||||
white-space: nowrap;
|
||||
min-width: 38px;
|
||||
text-align: right;
|
||||
@@ -50,7 +56,7 @@
|
||||
}
|
||||
|
||||
.version-text {
|
||||
color: #e5e7eb;
|
||||
color: var(--text-color-secondary);
|
||||
}
|
||||
|
||||
.version-link {
|
||||
@@ -58,7 +64,7 @@
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
color: #f3f4f6;
|
||||
color: var(--high-contrast-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,12 +73,17 @@
|
||||
}
|
||||
|
||||
.update-link {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
color: #fb923c;
|
||||
color: var(--primary-text-color);
|
||||
font-family: inherit;
|
||||
font-size: 0.75rem;
|
||||
line-height: inherit;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
color: #fdba74;
|
||||
color: var(--primary-hover-color);
|
||||
}
|
||||
}
|
||||
+89
-74
@@ -1,54 +1,71 @@
|
||||
import {Component, computed, effect, inject, OnInit, signal} from '@angular/core';
|
||||
import {toSignal} from '@angular/core/rxjs-interop';
|
||||
import {AppMenuitemComponent} from './app.menuitem.component';
|
||||
import {MenuModule} from 'primeng/menu';
|
||||
import {LibraryService} from '../../../../features/book/service/library.service';
|
||||
import {LibraryHealthService} from '../../../../features/book/service/library-health.service';
|
||||
import {ShelfService} from '../../../../features/book/service/shelf.service';
|
||||
import {BookService} from '../../../../features/book/service/book.service';
|
||||
import {LibraryShelfMenuService} from '../../../../features/book/service/library-shelf-menu.service';
|
||||
import {AppVersion, VersionService} from '../../../service/version.service';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {UserService} from '../../../../features/settings/user-management/user.service';
|
||||
import {MagicShelfService} from '../../../../features/magic-shelf/service/magic-shelf.service';
|
||||
import {SeriesDataService} from '../../../../features/series-browser/service/series-data.service';
|
||||
import {AuthorService} from '../../../../features/author-browser/service/author.service';
|
||||
import {MenuItem} from 'primeng/api';
|
||||
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {Slider} from 'primeng/slider';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Popover} from 'primeng/popover';
|
||||
import {LocalStorageService} from '../../../service/local-storage.service';
|
||||
import { Component, computed, effect, inject, signal } from '@angular/core';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { AppMenuitemComponent } from './app.menuitem.component';
|
||||
import { LibraryService } from '../../../features/book/service/library.service';
|
||||
import { LibraryHealthService } from '../../../features/book/service/library-health.service';
|
||||
import { ShelfService } from '../../../features/book/service/shelf.service';
|
||||
import { BookService } from '../../../features/book/service/book.service';
|
||||
import { LibraryShelfMenuService } from '../../../features/book/service/library-shelf-menu.service';
|
||||
import { VersionService } from '../../service/version.service';
|
||||
import { UserService } from '../../../features/settings/user-management/user.service';
|
||||
import { MagicShelfService } from '../../../features/magic-shelf/service/magic-shelf.service';
|
||||
import { SeriesDataService } from '../../../features/series-browser/service/series-data.service';
|
||||
import { AuthorService } from '../../../features/author-browser/service/author.service';
|
||||
import { DialogLauncherService } from '../../services/dialog-launcher.service';
|
||||
import { TranslocoDirective, TranslocoService } from '@jsverse/transloco';
|
||||
import { Slider } from 'primeng/slider';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { Popover } from 'primeng/popover';
|
||||
import { LocalStorageService } from '../../service/local-storage.service';
|
||||
import type { MenuItem } from 'primeng/api';
|
||||
|
||||
export type NavIconType = 'PRIME_NG' | 'CUSTOM_SVG';
|
||||
|
||||
export type NavItemType =
|
||||
| 'library' | 'shelf' | 'magicShelf'
|
||||
| 'allBooks' | 'series' | 'authors';
|
||||
|
||||
export interface NavItem {
|
||||
label: string;
|
||||
icon?: string;
|
||||
iconType?: NavIconType;
|
||||
routerLink?: string[];
|
||||
type?: NavItemType;
|
||||
group?: boolean;
|
||||
bookCount?: number;
|
||||
unhealthy?: boolean;
|
||||
items?: NavItem[];
|
||||
hasDropDown?: boolean;
|
||||
hasCreate?: boolean;
|
||||
contextMenuItems?: MenuItem[];
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-menu',
|
||||
standalone: true,
|
||||
imports: [AppMenuitemComponent, MenuModule, TranslocoDirective, Slider, FormsModule, Popover],
|
||||
imports: [AppMenuitemComponent, TranslocoDirective, Slider, FormsModule, Popover],
|
||||
templateUrl: './app.menu.component.html',
|
||||
styleUrl: './app.menu.component.scss',
|
||||
})
|
||||
export class AppMenuComponent implements OnInit {
|
||||
versionInfo: AppVersion | null = null;
|
||||
dynamicDialogRef: DynamicDialogRef | undefined | null;
|
||||
export class AppMenuComponent {
|
||||
private readonly libraryService = inject(LibraryService);
|
||||
private readonly libraryHealthService = inject(LibraryHealthService);
|
||||
private readonly shelfService = inject(ShelfService);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly versionService = inject(VersionService);
|
||||
private readonly libraryShelfMenuService = inject(LibraryShelfMenuService);
|
||||
private readonly dialogLauncherService = inject(DialogLauncherService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly magicShelfService = inject(MagicShelfService);
|
||||
private readonly seriesDataService = inject(SeriesDataService);
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly localStorageService = inject(LocalStorageService);
|
||||
|
||||
private libraryService = inject(LibraryService);
|
||||
private libraryHealthService = inject(LibraryHealthService);
|
||||
private shelfService = inject(ShelfService);
|
||||
private bookService = inject(BookService);
|
||||
private versionService = inject(VersionService);
|
||||
private libraryShelfMenuService = inject(LibraryShelfMenuService);
|
||||
private dialogLauncherService = inject(DialogLauncherService);
|
||||
private userService = inject(UserService);
|
||||
private magicShelfService = inject(MagicShelfService);
|
||||
private seriesDataService = inject(SeriesDataService);
|
||||
private authorService = inject(AuthorService);
|
||||
private t = inject(TranslocoService);
|
||||
private localStorageService = inject(LocalStorageService);
|
||||
|
||||
private activeLang = toSignal(this.t.langChanges$, {initialValue: this.t.getActiveLang()});
|
||||
private readonly activeLang = toSignal(this.t.langChanges$, {initialValue: this.t.getActiveLang()});
|
||||
private readonly currentUser = this.userService.currentUser;
|
||||
private allAuthors = this.authorService.allAuthors;
|
||||
private readonly allAuthors = this.authorService.allAuthors;
|
||||
|
||||
readonly versionInfo = toSignal(this.versionService.getVersion(), { initialValue: null });
|
||||
|
||||
librarySortField = signal<'name' | 'id'>('name');
|
||||
librarySortOrder = signal<'asc' | 'desc'>('desc');
|
||||
@@ -56,7 +73,7 @@ export class AppMenuComponent implements OnInit {
|
||||
shelfSortOrder = signal<'asc' | 'desc'>('asc');
|
||||
magicShelfSortField = signal<'name' | 'id'>('name');
|
||||
magicShelfSortOrder = signal<'asc' | 'desc'>('asc');
|
||||
sidebarWidth = 225;
|
||||
sidebarWidth = this.localStorageService.get<number>('sidebarWidth') ?? 225;
|
||||
|
||||
private readonly libraryBookCounts = computed(() => {
|
||||
const counts = new Map<number, number>();
|
||||
@@ -109,7 +126,7 @@ export class AppMenuComponent implements OnInit {
|
||||
return counts;
|
||||
});
|
||||
|
||||
readonly homeMenu = computed<MenuItem[]>(() => {
|
||||
readonly homeMenu = computed<NavItem[]>(() => {
|
||||
this.activeLang();
|
||||
|
||||
return [
|
||||
@@ -123,21 +140,21 @@ export class AppMenuComponent implements OnInit {
|
||||
},
|
||||
{
|
||||
label: this.t.translate('layout.menu.allBooks'),
|
||||
type: 'All Books',
|
||||
type: 'allBooks',
|
||||
icon: 'pi pi-fw pi-book',
|
||||
routerLink: ['/all-books'],
|
||||
bookCount: this.bookService.books().length,
|
||||
},
|
||||
{
|
||||
label: this.t.translate('layout.menu.series'),
|
||||
type: 'Series',
|
||||
type: 'series',
|
||||
icon: 'pi pi-fw pi-objects-column',
|
||||
routerLink: ['/series'],
|
||||
bookCount: this.seriesDataService.allSeries().length,
|
||||
},
|
||||
{
|
||||
label: this.t.translate('layout.menu.authors'),
|
||||
type: 'Authors',
|
||||
type: 'authors',
|
||||
icon: 'pi pi-fw pi-users',
|
||||
routerLink: ['/authors'],
|
||||
bookCount: this.allAuthors()?.length ?? 0,
|
||||
@@ -152,7 +169,7 @@ export class AppMenuComponent implements OnInit {
|
||||
];
|
||||
});
|
||||
|
||||
readonly libraryMenu = computed<MenuItem[]>(() => {
|
||||
readonly libraryMenu = computed<NavItem[]>(() => {
|
||||
this.activeLang();
|
||||
const libCounts = this.libraryBookCounts();
|
||||
|
||||
@@ -166,14 +183,15 @@ export class AppMenuComponent implements OnInit {
|
||||
{
|
||||
label: this.t.translate('layout.menu.libraries'),
|
||||
type: 'library',
|
||||
group: true,
|
||||
hasDropDown: true,
|
||||
hasCreate: true,
|
||||
items: sortedLibraries.map((library) => ({
|
||||
menu: this.libraryShelfMenuService.initializeLibraryMenuItems(library),
|
||||
contextMenuItems: this.libraryShelfMenuService.initializeLibraryMenuItems(library),
|
||||
label: library.name,
|
||||
type: 'Library',
|
||||
type: 'library',
|
||||
icon: library.icon || undefined,
|
||||
iconType: (library.iconType || undefined) as 'PRIME_NG' | 'CUSTOM_SVG' | undefined,
|
||||
iconType: this.toNavIconType(library.iconType),
|
||||
routerLink: [`/library/${library.id}/books`],
|
||||
bookCount: libCounts.get(library.id ?? 0) ?? 0,
|
||||
unhealthy: this.libraryHealthService.isUnhealthy(library.id ?? 0),
|
||||
@@ -182,7 +200,7 @@ export class AppMenuComponent implements OnInit {
|
||||
];
|
||||
});
|
||||
|
||||
readonly magicShelfMenu = computed<MenuItem[]>(() => {
|
||||
readonly magicShelfMenu = computed<NavItem[]>(() => {
|
||||
this.activeLang();
|
||||
|
||||
const sortedShelves = this.sortArray(
|
||||
@@ -195,14 +213,15 @@ export class AppMenuComponent implements OnInit {
|
||||
{
|
||||
label: this.t.translate('layout.menu.magicShelves'),
|
||||
type: 'magicShelf',
|
||||
group: true,
|
||||
hasDropDown: true,
|
||||
hasCreate: true,
|
||||
items: sortedShelves.map((shelf) => ({
|
||||
label: shelf.name,
|
||||
type: 'magicShelfItem',
|
||||
type: 'magicShelf',
|
||||
icon: shelf.icon || undefined,
|
||||
iconType: (shelf.iconType || undefined) as 'PRIME_NG' | 'CUSTOM_SVG' | undefined,
|
||||
menu: this.libraryShelfMenuService.initializeMagicShelfMenuItems(shelf),
|
||||
iconType: this.toNavIconType(shelf.iconType),
|
||||
contextMenuItems: this.libraryShelfMenuService.initializeMagicShelfMenuItems(shelf),
|
||||
routerLink: [`/magic-shelf/${shelf.id}/books`],
|
||||
bookCount: this.magicShelfBookCounts().get(shelf.id ?? 0) ?? 0,
|
||||
})),
|
||||
@@ -210,7 +229,7 @@ export class AppMenuComponent implements OnInit {
|
||||
];
|
||||
});
|
||||
|
||||
readonly shelfMenu = computed<MenuItem[]>(() => {
|
||||
readonly shelfMenu = computed<NavItem[]>(() => {
|
||||
this.activeLang();
|
||||
const shelfCounts = this.shelfBookCounts();
|
||||
|
||||
@@ -228,20 +247,20 @@ export class AppMenuComponent implements OnInit {
|
||||
}
|
||||
|
||||
const shelfItems = shelves.map((shelf) => ({
|
||||
menu: this.libraryShelfMenuService.initializeShelfMenuItems(shelf),
|
||||
contextMenuItems: this.libraryShelfMenuService.initializeShelfMenuItems(shelf),
|
||||
label: shelf.name,
|
||||
type: 'Shelf',
|
||||
type: 'shelf' as const,
|
||||
icon: shelf.icon || undefined,
|
||||
iconType: (shelf.iconType || undefined) as 'PRIME_NG' | 'CUSTOM_SVG' | undefined,
|
||||
iconType: this.toNavIconType(shelf.iconType),
|
||||
routerLink: [`/shelf/${shelf.id}/books`],
|
||||
bookCount: shelfCounts.get(shelf.id ?? 0) ?? 0,
|
||||
}));
|
||||
|
||||
const items: MenuItem[] = [{
|
||||
const items: NavItem[] = [{
|
||||
label: this.t.translate('layout.menu.unshelved'),
|
||||
type: 'Shelf',
|
||||
type: 'shelf',
|
||||
icon: 'pi pi-inbox',
|
||||
iconType: 'PRIME_NG' as 'PRIME_NG' | 'CUSTOM_SVG',
|
||||
iconType: 'PRIME_NG',
|
||||
routerLink: ['/unshelved-books'],
|
||||
bookCount: shelfCounts.get(-1) ?? 0,
|
||||
}];
|
||||
@@ -249,9 +268,9 @@ export class AppMenuComponent implements OnInit {
|
||||
if (koboShelf) {
|
||||
items.push({
|
||||
label: koboShelf.name,
|
||||
type: 'Shelf',
|
||||
type: 'shelf',
|
||||
icon: koboShelf.icon || undefined,
|
||||
iconType: (koboShelf.iconType || undefined) as 'PRIME_NG' | 'CUSTOM_SVG' | undefined,
|
||||
iconType: this.toNavIconType(koboShelf.iconType),
|
||||
routerLink: [`/shelf/${koboShelf.id}/books`],
|
||||
bookCount: shelfCounts.get(koboShelf.id ?? 0) ?? 0,
|
||||
});
|
||||
@@ -262,6 +281,7 @@ export class AppMenuComponent implements OnInit {
|
||||
return [
|
||||
{
|
||||
type: 'shelf',
|
||||
group: true,
|
||||
label: this.t.translate('layout.menu.shelves'),
|
||||
hasDropDown: true,
|
||||
hasCreate: true,
|
||||
@@ -290,15 +310,6 @@ export class AppMenuComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
this.sidebarWidth = this.localStorageService.get<number>('sidebarWidth') ?? 225;
|
||||
|
||||
this.versionService.getVersion().subscribe((data) => {
|
||||
this.versionInfo = data;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
onSidebarWidthChange(): void {
|
||||
document.documentElement.style.setProperty('--sidebar-width', this.sidebarWidth + 'px');
|
||||
}
|
||||
@@ -346,4 +357,8 @@ export class AppMenuComponent implements OnInit {
|
||||
private validateSortOrder(order: string): 'asc' | 'desc' {
|
||||
return order === 'desc' ? 'desc' : 'asc';
|
||||
}
|
||||
|
||||
private toNavIconType(iconType: string | null | undefined): NavIconType | undefined {
|
||||
return iconType === 'PRIME_NG' || iconType === 'CUSTOM_SVG' ? iconType : undefined;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
import { Subject } from 'rxjs';
|
||||
import { MenuService } from './app.menu.service';
|
||||
|
||||
describe('MenuService', () => {
|
||||
it('exposes the current path from the router URL', () => {
|
||||
const routerEvents = new Subject<unknown>();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
MenuService,
|
||||
{
|
||||
provide: Router,
|
||||
useValue: {
|
||||
url: '/dashboard?tab=recent',
|
||||
events: routerEvents.asObservable(),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const service = TestBed.inject(MenuService);
|
||||
expect(service.currentPath()).toBe('/dashboard');
|
||||
});
|
||||
|
||||
it('updates currentPath on NavigationEnd', () => {
|
||||
const routerEvents = new Subject<unknown>();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
MenuService,
|
||||
{
|
||||
provide: Router,
|
||||
useValue: {
|
||||
url: '/',
|
||||
events: routerEvents.asObservable(),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const service = TestBed.inject(MenuService);
|
||||
routerEvents.next(new NavigationEnd(1, '/library/1/books', '/library/1/books'));
|
||||
|
||||
expect(service.currentPath()).toBe('/library/1/books');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { inject, Injectable, signal } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { filter } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MenuService {
|
||||
private readonly router = inject(Router);
|
||||
|
||||
/** Current URL path (without query string), updated once per navigation. */
|
||||
readonly currentPath = signal(this.router.url.split('?')[0]);
|
||||
|
||||
constructor() {
|
||||
this.router.events
|
||||
.pipe(
|
||||
filter((event): event is NavigationEnd => event instanceof NavigationEnd),
|
||||
takeUntilDestroyed()
|
||||
)
|
||||
.subscribe((event) => {
|
||||
this.currentPath.set(event.urlAfterRedirects.split('?')[0]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<ng-container>
|
||||
@if (root) {
|
||||
@if (item.hasDropDown) {
|
||||
<div class="layout-menuitem-root-text root-item-with-dropdown">
|
||||
<div class="root-item-label-container">
|
||||
<div>{{ item.label }}</div>
|
||||
@if (item.hasCreate) {
|
||||
<button
|
||||
type="button"
|
||||
class="plus-icon-button"
|
||||
[attr.aria-label]="item.label"
|
||||
(click)="openDialog(item)"
|
||||
>
|
||||
<i class="pi pi-plus plus-icon" aria-hidden="true"></i>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="expand-icon-button"
|
||||
[attr.aria-label]="item.label"
|
||||
[attr.aria-expanded]="expanded"
|
||||
(click)="toggleExpand()"
|
||||
>
|
||||
<i
|
||||
[ngClass]="{
|
||||
'pi': true,
|
||||
'pi-angle-up': expanded,
|
||||
'pi-angle-down': !expanded
|
||||
}"
|
||||
class="expand-icon"
|
||||
aria-hidden="true"
|
||||
></i>
|
||||
</button>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="layout-menuitem-root-text root-item">
|
||||
<div>{{ item.label }}</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<div>
|
||||
<div
|
||||
class="menu-item-container"
|
||||
[class.active-route-container]="isRouteActive()"
|
||||
[class.menu-open]="menuOpen"
|
||||
>
|
||||
@if (item.routerLink && !item.items) {
|
||||
<a
|
||||
class="menu-item-link"
|
||||
[class.active-route]="isRouteActive()"
|
||||
[routerLink]="item.routerLink"
|
||||
tabindex="0"
|
||||
>
|
||||
@if (item.unhealthy) {
|
||||
<span
|
||||
class="library-health-dot"
|
||||
[pTooltip]="'common.libraryPathInaccessible' | transloco"
|
||||
tooltipPosition="right"
|
||||
></span>
|
||||
}
|
||||
<app-icon-display
|
||||
[icon]="getIconSelection()"
|
||||
iconClass="layout-menuitem-icon"
|
||||
size="18px"
|
||||
[displayEmpty]="true"
|
||||
></app-icon-display>
|
||||
<span class="layout-menuitem-text menu-item-text">
|
||||
{{ item.label }}
|
||||
</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
<span class="menu-item-end-content">
|
||||
@if (shouldShowContextMenuButton()) {
|
||||
<button
|
||||
type="button"
|
||||
class="entity-menu-button"
|
||||
[attr.aria-label]="item.label"
|
||||
(click)="entitymenu.toggle($event); menuOpen = !menuOpen; $event.stopPropagation()"
|
||||
>
|
||||
<span class="entity-menu-button-content">
|
||||
<i class="pi pi-ellipsis-v entity-menu-icon" aria-hidden="true"></i>
|
||||
<span class="entity-menu-count">{{ item.bookCount?.toString() || '' }}</span>
|
||||
</span>
|
||||
</button>
|
||||
<p-menu #entitymenu [model]="item.contextMenuItems" [popup]="true" appendTo="body" (onHide)="menuOpen = false"></p-menu>
|
||||
} @else if (item.bookCount !== undefined) {
|
||||
<p class="book-count">
|
||||
{{ formatCount(item.bookCount) }}
|
||||
</p>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div [@children]="expanded ? 'expanded' : 'collapsed'" class="submenu-container">
|
||||
@if (item.items) {
|
||||
<ul>
|
||||
@for (child of item.items; track child.routerLink?.join('/') ?? child.label; let i = $index) {
|
||||
<li app-menuitem [item]="child" [index]="i" [parentKey]="key"></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+73
-10
@@ -1,11 +1,22 @@
|
||||
.plus-icon-button,
|
||||
.expand-icon-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.plus-icon {
|
||||
color: var(--p-primary-color);
|
||||
color: var(--primary-color);
|
||||
transition: color 0.2s ease;
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: var(--p-green-400);
|
||||
color: var(--primary-hover-color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,14 +37,17 @@
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
color: var(--p-surface-500);
|
||||
padding-right: 0.75rem;
|
||||
color: var(--surface-500);
|
||||
|
||||
&:hover {
|
||||
color: var(--p-surface-200);
|
||||
color: var(--surface-200);
|
||||
}
|
||||
}
|
||||
|
||||
.expand-icon-button {
|
||||
padding-right: 0.75rem;
|
||||
}
|
||||
|
||||
.root-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -49,14 +63,12 @@
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--p-surface-800);
|
||||
border-radius: 8px;
|
||||
background-color: var(--surface-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.menu-item-container.active-route-container {
|
||||
background-color: color-mix(in srgb, var(--p-primary-300), transparent 93%);
|
||||
border-radius: 8px;
|
||||
background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
}
|
||||
|
||||
.menu-item-link {
|
||||
@@ -64,6 +76,13 @@
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
background-color: transparent;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,16 +97,60 @@
|
||||
|
||||
.menu-item-end-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.entity-menu-button {
|
||||
height: 30px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 2rem;
|
||||
height: 30px;
|
||||
padding: 0 0.55rem;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: var(--primary-color);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.entity-menu-button:hover {
|
||||
background-color: transparent;
|
||||
color: var(--primary-hover-color);
|
||||
}
|
||||
|
||||
.entity-menu-button-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.entity-menu-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.menu-item-container:hover .entity-menu-icon,
|
||||
.menu-item-container.menu-open .entity-menu-icon {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.menu-item-container:hover .entity-menu-count,
|
||||
.menu-item-container.menu-open .entity-menu-count {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.book-count {
|
||||
color: var(--primary-color);
|
||||
padding-right: 0.75rem;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.menu-item-container:hover .book-count,
|
||||
.menu-item-container:hover .entity-menu-button {
|
||||
color: var(--primary-hover-color);
|
||||
}
|
||||
|
||||
.submenu-container {
|
||||
@@ -0,0 +1,132 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { signal } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppMenuitemComponent } from './app.menuitem.component';
|
||||
import { MenuService } from './app.menu.service';
|
||||
import { DialogLauncherService } from '../../services/dialog-launcher.service';
|
||||
import { BookDialogHelperService } from '../../../features/book/components/book-browser/book-dialog-helper.service';
|
||||
import { UserService } from '../../../features/settings/user-management/user.service';
|
||||
|
||||
describe('AppMenuitemComponent', () => {
|
||||
let fixture: ComponentFixture<AppMenuitemComponent>;
|
||||
let component: AppMenuitemComponent;
|
||||
|
||||
const menuService = {
|
||||
currentPath: signal('/'),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [AppMenuitemComponent],
|
||||
providers: [
|
||||
{ provide: MenuService, useValue: menuService },
|
||||
{
|
||||
provide: DialogLauncherService,
|
||||
useValue: {
|
||||
openLibraryCreateDialog: vi.fn(),
|
||||
openMagicShelfCreateDialog: vi.fn(),
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: BookDialogHelperService,
|
||||
useValue: {
|
||||
openShelfCreatorDialog: vi.fn(),
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: UserService,
|
||||
useValue: {
|
||||
currentUser: signal({
|
||||
permissions: {
|
||||
canManageLibrary: true,
|
||||
admin: true,
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
TestBed.overrideComponent(AppMenuitemComponent, {
|
||||
set: {
|
||||
template: '',
|
||||
},
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(AppMenuitemComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.index = 0;
|
||||
});
|
||||
|
||||
it('passes context menu items through to the template', () => {
|
||||
const editCommand = vi.fn();
|
||||
const nestedCommand = vi.fn();
|
||||
|
||||
component.item = {
|
||||
label: 'Shelf A',
|
||||
type: 'shelf',
|
||||
contextMenuItems: [
|
||||
{ label: 'Edit', command: editCommand },
|
||||
{
|
||||
label: 'More',
|
||||
items: [{ label: 'Delete', command: nestedCommand }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
const items = component.item.contextMenuItems!;
|
||||
expect(items[0].label).toBe('Edit');
|
||||
items[0].command?.({} as never);
|
||||
expect(editCommand).toHaveBeenCalled();
|
||||
|
||||
expect(items[1].items?.[0].label).toBe('Delete');
|
||||
items[1].items?.[0].command?.({} as never);
|
||||
expect(nestedCommand).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('hides the context menu button for items without context menu actions', () => {
|
||||
component.item = {
|
||||
label: 'Unshelved',
|
||||
type: 'shelf',
|
||||
};
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.shouldShowContextMenuButton()).toBe(false);
|
||||
});
|
||||
|
||||
it('exposes admin and canManipulateLibrary as computed signals from UserService', () => {
|
||||
component.item = { label: 'Test' };
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.admin()).toBe(true);
|
||||
expect(component.canManipulateLibrary()).toBe(true);
|
||||
});
|
||||
|
||||
it('reports route as active when currentPath matches item routerLink', () => {
|
||||
component.item = {
|
||||
label: 'Dashboard',
|
||||
routerLink: ['/dashboard'],
|
||||
};
|
||||
|
||||
menuService.currentPath.set('/dashboard');
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.isRouteActive()).toBe(true);
|
||||
});
|
||||
|
||||
it('reports route as inactive when currentPath does not match', () => {
|
||||
component.item = {
|
||||
label: 'Dashboard',
|
||||
routerLink: ['/dashboard'],
|
||||
};
|
||||
|
||||
menuService.currentPath.set('/library/1/books');
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.isRouteActive()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,117 @@
|
||||
import { ChangeDetectionStrategy, Component, computed, HostBinding, inject, Input, OnInit } from '@angular/core';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { animate, state, style, transition, trigger } from '@angular/animations';
|
||||
import { MenuService } from './app.menu.service';
|
||||
import { NgClass } from '@angular/common';
|
||||
import { Menu } from 'primeng/menu';
|
||||
import { UserService } from '../../../features/settings/user-management/user.service';
|
||||
import { DialogLauncherService } from '../../services/dialog-launcher.service';
|
||||
import { BookDialogHelperService } from '../../../features/book/components/book-browser/book-dialog-helper.service';
|
||||
import { IconDisplayComponent } from '../../components/icon-display/icon-display.component';
|
||||
import { Tooltip } from 'primeng/tooltip';
|
||||
import { IconSelection } from '../../service/icon-picker.service';
|
||||
import { TranslocoPipe } from '@jsverse/transloco';
|
||||
import { NavItem } from './app.menu.component';
|
||||
|
||||
@Component({
|
||||
// Keep this attribute selector so recursive menu items remain valid <li> children.
|
||||
// eslint-disable-next-line @angular-eslint/component-selector
|
||||
selector: '[app-menuitem]',
|
||||
templateUrl: './app.menuitem.component.html',
|
||||
styleUrls: ['./app.menuitem.component.scss'],
|
||||
imports: [
|
||||
RouterLink,
|
||||
NgClass,
|
||||
Menu,
|
||||
IconDisplayComponent,
|
||||
Tooltip,
|
||||
TranslocoPipe
|
||||
],
|
||||
animations: [
|
||||
trigger('children', [
|
||||
state('collapsed', style({
|
||||
height: '0'
|
||||
})),
|
||||
state('expanded', style({
|
||||
height: '*'
|
||||
})),
|
||||
transition('collapsed <=> expanded', animate('400ms cubic-bezier(0.86, 0, 0.07, 1)'))
|
||||
])
|
||||
],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class AppMenuitemComponent implements OnInit {
|
||||
@Input() item!: NavItem;
|
||||
@Input() index!: number;
|
||||
@Input() @HostBinding('class.layout-root-menuitem') root!: boolean;
|
||||
@Input() parentKey!: string;
|
||||
@Input() menuKey!: string;
|
||||
|
||||
menuOpen = false;
|
||||
key: string = '';
|
||||
expanded = true;
|
||||
|
||||
private readonly menuService = inject(MenuService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly dialogLauncher = inject(DialogLauncherService);
|
||||
private readonly bookDialogHelperService = inject(BookDialogHelperService);
|
||||
|
||||
readonly isRouteActive = computed(() => {
|
||||
const route = this.item?.routerLink?.[0];
|
||||
if (!route) return false;
|
||||
return this.menuService.currentPath() === route;
|
||||
});
|
||||
|
||||
readonly canManipulateLibrary = computed(() =>
|
||||
this.userService.currentUser()?.permissions.canManageLibrary ?? false
|
||||
);
|
||||
|
||||
readonly admin = computed(() =>
|
||||
this.userService.currentUser()?.permissions.admin ?? false
|
||||
);
|
||||
|
||||
ngOnInit() {
|
||||
const rootKey = this.menuKey ? this.menuKey + '-' : '';
|
||||
this.key = this.parentKey ? this.parentKey + '-' + this.index : rootKey + String(this.index);
|
||||
}
|
||||
|
||||
toggleExpand() {
|
||||
this.expanded = !this.expanded;
|
||||
}
|
||||
|
||||
openDialog(item: NavItem) {
|
||||
if (item.type === 'library' && this.canManipulateLibrary()) {
|
||||
this.dialogLauncher.openLibraryCreateDialog();
|
||||
}
|
||||
if (item.type === 'magicShelf') {
|
||||
this.dialogLauncher.openMagicShelfCreateDialog();
|
||||
}
|
||||
if (item.type === 'shelf') {
|
||||
this.bookDialogHelperService.openShelfCreatorDialog();
|
||||
}
|
||||
}
|
||||
|
||||
formatCount(count: number | null | undefined): string {
|
||||
if (count == null) return '0';
|
||||
if (count >= 1000) return Math.floor(count / 1000) + 'K';
|
||||
return count.toString();
|
||||
}
|
||||
|
||||
getIconSelection(): IconSelection | null {
|
||||
if (!this.item.icon) return null;
|
||||
|
||||
return {
|
||||
type: this.item.iconType || 'PRIME_NG',
|
||||
value: this.item.icon
|
||||
};
|
||||
}
|
||||
|
||||
hasContextMenu(): boolean {
|
||||
return (this.item.contextMenuItems?.length ?? 0) > 0;
|
||||
}
|
||||
|
||||
shouldShowContextMenuButton(): boolean {
|
||||
return this.hasContextMenu()
|
||||
&& (this.item.type !== 'library' || (this.admin() || this.canManipulateLibrary()));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
@use '../../../../../shared/styles/panel-shared' as panel;
|
||||
@use '../../../../shared/styles/panel-shared' as panel;
|
||||
|
||||
.changelog-container {
|
||||
display: flex;
|
||||
@@ -101,7 +101,7 @@
|
||||
|
||||
code {
|
||||
font-size: 0.875em;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
padding: 0.125rem 0.375rem;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
@@ -110,7 +110,7 @@
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
padding: 1rem;
|
||||
background: var(--surface-ground);
|
||||
background: var(--ground-background);
|
||||
border-radius: 0.5rem;
|
||||
overflow-x: auto;
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ import {of, throwError} from 'rxjs';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
|
||||
import {getTranslocoModule} from '../../../../../core/testing/transloco-testing';
|
||||
import {VersionService} from '../../../../service/version.service';
|
||||
import {getTranslocoModule} from '../../../../core/testing/transloco-testing';
|
||||
import {VersionService} from '../../../service/version.service';
|
||||
import {VersionChangelogDialogComponent} from './version-changelog-dialog.component';
|
||||
|
||||
describe('VersionChangelogDialogComponent', () => {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { ReleaseNote, VersionService } from '../../../../service/version.service';
|
||||
import { ReleaseNote, VersionService } from '../../../service/version.service';
|
||||
|
||||
import showdown from 'showdown';
|
||||
import DOMPurify from 'dompurify';
|
||||
@@ -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>
|
||||
+2
-2
@@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
.topbar-icon {
|
||||
color: var(--p-surface-100);
|
||||
color: var(--surface-100);
|
||||
}
|
||||
|
||||
.topbar-item-relative {
|
||||
@@ -164,7 +164,7 @@
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
background: var(--p-surface-700);
|
||||
background: var(--surface-700);
|
||||
}
|
||||
}
|
||||
|
||||
+55
-66
@@ -1,46 +1,42 @@
|
||||
import {Component, effect, ElementRef, inject, OnDestroy, ViewChild} from '@angular/core';
|
||||
import {MenuItem} from 'primeng/api';
|
||||
import {LayoutService} from '../layout-main/service/app.layout.service';
|
||||
import {Router, RouterLink} from '@angular/router';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
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 {Button} from 'primeng/button';
|
||||
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 { 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'],
|
||||
standalone: true,
|
||||
imports: [
|
||||
RouterLink,
|
||||
TooltipModule,
|
||||
FormsModule,
|
||||
InputTextModule,
|
||||
BookSearcherComponent,
|
||||
Button,
|
||||
ThemeConfiguratorComponent,
|
||||
StyleClass,
|
||||
NgClass,
|
||||
@@ -53,24 +49,18 @@ import {LANG_STORAGE_KEY} from '../../../../core/config/language-initializer';
|
||||
],
|
||||
})
|
||||
export class AppTopBarComponent implements OnDestroy {
|
||||
public layoutService = inject(LayoutService);
|
||||
public readonly layoutService = inject(LayoutService);
|
||||
protected readonly userService = inject(UserService);
|
||||
protected readonly user = this.userService.currentUser;
|
||||
private notificationService = inject(NotificationEventService);
|
||||
private router = inject(Router);
|
||||
private authService = inject(AuthService);
|
||||
private metadataProgressService = inject(MetadataProgressService);
|
||||
private bookdropFileService = inject(BookdropFileService);
|
||||
private dialogLauncher = inject(DialogLauncherService);
|
||||
private translocoService = inject(TranslocoService);
|
||||
items!: MenuItem[];
|
||||
ref?: DynamicDialogRef;
|
||||
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('menubutton') menuButton!: ElementRef;
|
||||
@ViewChild('topbarmenubutton') topbarMenuButton!: ElementRef;
|
||||
@ViewChild('topbarmenu') menu!: ElementRef;
|
||||
@ViewChild('statsMenu') statsMenu: Menu | undefined;
|
||||
@ViewChild('statsMenu') statsMenu?: Menu;
|
||||
|
||||
isMenuVisible = true;
|
||||
progressHighlight = false;
|
||||
@@ -87,16 +77,11 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
private latestHasPendingFiles = false;
|
||||
private latestNotificationSeverity?: Severity;
|
||||
|
||||
activeLang = '';
|
||||
activeLang = this.translocoService.getActiveLang();
|
||||
langMenuItems: MenuItem[] = [];
|
||||
|
||||
constructor() {
|
||||
this.activeLang = this.translocoService.getActiveLang();
|
||||
this.langMenuItems = AVAILABLE_LANGS.map(lang => ({
|
||||
label: LANG_LABELS[lang] || lang,
|
||||
icon: lang === this.activeLang ? 'pi pi-check' : undefined,
|
||||
command: () => this.switchLanguage(lang),
|
||||
}));
|
||||
this.langMenuItems = this.buildLanguageActions(this.activeLang);
|
||||
|
||||
this.subscribeToMetadataProgress();
|
||||
this.subscribeToNotifications();
|
||||
@@ -132,7 +117,6 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.ref) this.ref.close();
|
||||
clearTimeout(this.eventTimer);
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
@@ -181,11 +165,7 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
this.translocoService.setActiveLang(lang);
|
||||
localStorage.setItem(LANG_STORAGE_KEY, lang);
|
||||
this.activeLang = lang;
|
||||
this.langMenuItems = AVAILABLE_LANGS.map(l => ({
|
||||
label: LANG_LABELS[l] || l,
|
||||
icon: l === lang ? 'pi pi-check' : undefined,
|
||||
command: () => this.switchLanguage(l),
|
||||
}));
|
||||
this.langMenuItems = this.buildLanguageActions(lang);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -193,13 +173,13 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
this.authService.logout();
|
||||
}
|
||||
|
||||
handleStatsButtonClick(event: Event) {
|
||||
handleStatsButtonClick() {
|
||||
if (this.statsMenuItems.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.statsMenuItems.length === 1) {
|
||||
this.statsMenuItems[0].command?.({originalEvent: event, item: this.statsMenuItems[0]});
|
||||
this.statsMenuItems[0].command?.({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,11 +226,10 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
|
||||
private initializeStatsMenu() {
|
||||
const user = this.user();
|
||||
|
||||
this.statsMenuItems = [];
|
||||
const actions: MenuItem[] = [];
|
||||
|
||||
if (user?.permissions?.canAccessLibraryStats || user?.permissions?.admin) {
|
||||
this.statsMenuItems.push({
|
||||
actions.push({
|
||||
label: this.translocoService.translate('layout.topbar.libraryStats'),
|
||||
icon: 'pi pi-chart-line',
|
||||
command: () => this.navigateToStats()
|
||||
@@ -258,12 +237,14 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
if (user?.permissions?.canAccessUserStats || user?.permissions?.admin) {
|
||||
this.statsMenuItems.push({
|
||||
actions.push({
|
||||
label: this.translocoService.translate('layout.topbar.readingStats'),
|
||||
icon: 'pi pi-users',
|
||||
command: () => this.navigateToUserStats()
|
||||
});
|
||||
}
|
||||
|
||||
this.statsMenuItems = actions;
|
||||
}
|
||||
|
||||
get hasStatsAccess(): boolean {
|
||||
@@ -321,4 +302,12 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
!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),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { LayoutService } from './layout.service';
|
||||
|
||||
describe('LayoutService', () => {
|
||||
let service: LayoutService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [LayoutService],
|
||||
});
|
||||
|
||||
service = TestBed.inject(LayoutService);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('toggles sidebarOpen on desktop', () => {
|
||||
vi.spyOn(service, 'isDesktop').mockReturnValue(true);
|
||||
|
||||
expect(service.sidebarOpen()).toBe(true);
|
||||
service.onMenuToggle();
|
||||
expect(service.sidebarOpen()).toBe(false);
|
||||
service.onMenuToggle();
|
||||
expect(service.sidebarOpen()).toBe(true);
|
||||
});
|
||||
|
||||
it('toggles mobileSidebarOpen on mobile', () => {
|
||||
vi.spyOn(service, 'isDesktop').mockReturnValue(false);
|
||||
|
||||
expect(service.mobileSidebarOpen()).toBe(false);
|
||||
service.onMenuToggle();
|
||||
expect(service.mobileSidebarOpen()).toBe(true);
|
||||
service.onMenuToggle();
|
||||
expect(service.mobileSidebarOpen()).toBe(false);
|
||||
});
|
||||
|
||||
it('closeMobileSidebar resets mobileSidebarOpen to false', () => {
|
||||
service.mobileSidebarOpen.set(true);
|
||||
service.closeMobileSidebar();
|
||||
expect(service.mobileSidebarOpen()).toBe(false);
|
||||
});
|
||||
|
||||
it('updates the document root font size when the scale changes', () => {
|
||||
service.scale.set(18);
|
||||
TestBed.flushEffects();
|
||||
|
||||
expect(document.documentElement.style.fontSize).toBe('18px');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { effect, inject, Injectable, signal } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LayoutService {
|
||||
private readonly document = inject(DOCUMENT);
|
||||
|
||||
readonly scale = signal(14);
|
||||
readonly sidebarOpen = signal(true);
|
||||
readonly mobileSidebarOpen = signal(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
this.changeScale(this.scale());
|
||||
});
|
||||
}
|
||||
|
||||
onMenuToggle(): void {
|
||||
if (this.isDesktop()) {
|
||||
this.sidebarOpen.update((value) => !value);
|
||||
} else {
|
||||
this.mobileSidebarOpen.update((value) => !value);
|
||||
}
|
||||
}
|
||||
|
||||
closeMobileSidebar(): void {
|
||||
this.mobileSidebarOpen.set(false);
|
||||
}
|
||||
|
||||
isDesktop(): boolean {
|
||||
return (this.document.defaultView?.innerWidth ?? 992) > 991;
|
||||
}
|
||||
|
||||
private changeScale(value: number): void {
|
||||
this.document.documentElement.style.fontSize = `${value}px`;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable, map, tap} from 'rxjs';
|
||||
import {API_CONFIG} from '../../../../core/config/api-config';
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class BackgroundUploadService {
|
||||
+1
-1
@@ -7,7 +7,7 @@ import {ToggleSwitchModule} from 'primeng/toggleswitch';
|
||||
|
||||
import Aura from '../theme-palette-extend';
|
||||
|
||||
import {AppConfigService} from '../../../service/app-config.service';
|
||||
import {AppConfigService} from '../../service/app-config.service';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {FaviconService} from './favicon-service';
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
import {getTranslocoModule} from '../../../../../core/testing/transloco-testing';
|
||||
import {getTranslocoModule} from '../../../../core/testing/transloco-testing';
|
||||
import {BackgroundUploadService} from '../background-upload.service';
|
||||
import {UploadDialogComponent} from './upload-dialog.component';
|
||||
|
||||
@@ -1,14 +1,78 @@
|
||||
import {describe, it} from 'vitest';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService } from './app-config.service';
|
||||
|
||||
// NOTE(frontend-seam): Real coverage here needs a theme-runtime seam around Prime theme tokens,
|
||||
// localStorage hydration, DOM mutation, and browser-only effects so app state initialization can be
|
||||
// asserted without changing runtime code.
|
||||
describe.skip('AppConfigService', () => {
|
||||
it('needs a browser storage and theme-token seam to validate state hydration and persistence effects', () => {
|
||||
// Intentionally skipped until storage and theme runtime hooks are controllable in tests.
|
||||
function createLocalStorageMock() {
|
||||
const store = new Map<string, string>();
|
||||
|
||||
return {
|
||||
getItem: (key: string) => store.get(key) ?? null,
|
||||
setItem: (key: string, value: string) => {
|
||||
store.set(key, value);
|
||||
},
|
||||
removeItem: (key: string) => {
|
||||
store.delete(key);
|
||||
},
|
||||
clear: () => {
|
||||
store.clear();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe('AppConfigService', () => {
|
||||
let service: AppConfigService;
|
||||
let localStorageMock: ReturnType<typeof createLocalStorageMock>;
|
||||
const rootStyle = document.documentElement.style;
|
||||
|
||||
beforeEach(() => {
|
||||
localStorageMock = createLocalStorageMock();
|
||||
vi.stubGlobal('localStorage', localStorageMock);
|
||||
rootStyle.cssText = '';
|
||||
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AppConfigService],
|
||||
});
|
||||
|
||||
service = TestBed.inject(AppConfigService);
|
||||
});
|
||||
|
||||
it('needs a document mutation seam to validate theme updates without coupling the spec to runtime DOM side effects', () => {
|
||||
// Intentionally skipped until DOM-side theme application can be driven deterministically.
|
||||
afterEach(() => {
|
||||
localStorageMock.clear();
|
||||
rootStyle.cssText = '';
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it('applies the default app-owned tokens on init', () => {
|
||||
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#4ade80');
|
||||
expect(rootStyle.getPropertyValue('--ground-background')).toBe('#0d1012');
|
||||
expect(rootStyle.getPropertyValue('--content-border-color')).toBe('#464f56');
|
||||
});
|
||||
|
||||
it('updates app-owned tokens for custom palettes', () => {
|
||||
service.appState.set({
|
||||
preset: 'Aura',
|
||||
primary: 'coralSunset',
|
||||
surface: 'midnight-blue',
|
||||
});
|
||||
service.onPresetChange();
|
||||
|
||||
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#f59673');
|
||||
expect(rootStyle.getPropertyValue('--primary-color-rgb')).toBe('239, 117, 80');
|
||||
expect(rootStyle.getPropertyValue('--ground-background')).toBe('#121518');
|
||||
expect(rootStyle.getPropertyValue('--card-background')).toBe('#1f252c');
|
||||
});
|
||||
|
||||
it('maps noir to the selected surface palette', () => {
|
||||
service.appState.set({
|
||||
preset: 'Aura',
|
||||
primary: 'noir',
|
||||
surface: 'charcoal',
|
||||
});
|
||||
service.onPresetChange();
|
||||
|
||||
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#f0f0f0');
|
||||
expect(rootStyle.getPropertyValue('--primary-contrast-color')).toBe('#141414');
|
||||
expect(rootStyle.getPropertyValue('--primary-hover-color')).toBe('#d1d1d1');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
||||
import { effect, inject, Injectable, PLATFORM_ID, signal } from '@angular/core';
|
||||
import { $t } from '@primeuix/themes';
|
||||
import Aura from '@primeuix/themes/aura';
|
||||
import Aura from '../layout/theme-palette-extend';
|
||||
import { AppState } from '../model/app-state.model';
|
||||
|
||||
type ColorPalette = Record<string, string>;
|
||||
@@ -428,8 +428,72 @@ export class AppConfigService {
|
||||
}
|
||||
|
||||
onPresetChange(): void {
|
||||
if (!isPlatformBrowser(this.platformId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const surfacePalette = this.getSurfacePalette(this.appState().surface ?? 'neutral');
|
||||
const preset = this.getPresetExt();
|
||||
$t().preset(Aura).preset(preset).surfacePalette(surfacePalette).use({ useDefaultOptions: true });
|
||||
this.applyDesignTokens();
|
||||
}
|
||||
|
||||
private applyDesignTokens(): void {
|
||||
const style = this.document.documentElement.style;
|
||||
const primaryName = this.appState().primary ?? 'green';
|
||||
const surfaceName = this.appState().surface ?? 'ash';
|
||||
const surface = this.getSurfacePalette(surfaceName);
|
||||
const primary = ((Aura.primitive ?? {}) as Record<string, ColorPalette>)[primaryName] ?? {};
|
||||
const isNoir = primaryName === 'noir';
|
||||
|
||||
const primary400 = isNoir ? surface['50'] : primary['400'];
|
||||
const primary500 = isNoir ? surface['50'] : (primary['500'] ?? primary['400']);
|
||||
|
||||
style.setProperty('--primary-color', primary400 ?? '#4ade80');
|
||||
style.setProperty('--primary-color-rgb', this.toRgbChannels(primary500));
|
||||
style.setProperty('--primary-contrast-color', isNoir ? (surface['950'] ?? '#0d1012') : (surface['900'] ?? '#1a1e21'));
|
||||
style.setProperty('--primary-hover-color', isNoir ? (surface['200'] ?? '#d3d8de') : (primary['300'] ?? primary400 ?? '#86efac'));
|
||||
style.setProperty('--primary-text-color', primary400 ?? '#4ade80');
|
||||
style.setProperty('--primary-text-color-dark', isNoir ? (surface['950'] ?? '#0d1012') : (primary['900'] ?? '#14532d'));
|
||||
|
||||
style.setProperty('--ground-background', surface['950'] ?? '#0d1012');
|
||||
style.setProperty('--overlay-background', surface['900'] ?? '#1a1e21');
|
||||
style.setProperty('--card-background', surface['900'] ?? '#1a1e21');
|
||||
style.setProperty('--content-background', surface['900'] ?? '#1a1e21');
|
||||
style.setProperty('--code-background', surface['900'] ?? '#1a1e21');
|
||||
|
||||
style.setProperty('--border-color', surface['700'] ?? '#464f56');
|
||||
style.setProperty('--content-border-color', surface['700'] ?? '#464f56');
|
||||
style.setProperty('--text-color', surface['0'] ?? '#ffffff');
|
||||
style.setProperty('--text-color-secondary', surface['300'] ?? '#b4bcc7');
|
||||
style.setProperty('--text-secondary-color', surface['400'] ?? '#919ca9');
|
||||
style.setProperty('--text-muted-color', surface['400'] ?? '#919ca9');
|
||||
style.setProperty('--high-contrast-text-color', surface['0'] ?? '#ffffff');
|
||||
|
||||
Object.entries(surface).forEach(([stop, value]) => {
|
||||
style.setProperty(`--surface-${stop}`, value);
|
||||
});
|
||||
}
|
||||
|
||||
private toRgbChannels(color: string | undefined): string {
|
||||
if (!color) {
|
||||
return '74, 222, 128';
|
||||
}
|
||||
|
||||
const normalized = color.startsWith('#') ? color.slice(1) : color;
|
||||
const hex = normalized.length === 3
|
||||
? normalized.split('').map((char) => char + char).join('')
|
||||
: normalized;
|
||||
|
||||
if (hex.length !== 6) {
|
||||
return '74, 222, 128';
|
||||
}
|
||||
|
||||
const value = Number.parseInt(hex, 16);
|
||||
if (Number.isNaN(value)) {
|
||||
return '74, 222, 128';
|
||||
}
|
||||
|
||||
return `${(value >> 16) & 255}, ${(value >> 8) & 255}, ${value & 255}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {BookUploaderComponent} from '../components/book-uploader/book-uploader.c
|
||||
import {UserProfileDialogComponent} from '../../features/settings/user-profile-dialog/user-profile-dialog.component';
|
||||
import {MagicShelfComponent} from '../../features/magic-shelf/component/magic-shelf-component';
|
||||
import {DashboardSettingsComponent} from '../../features/dashboard/components/dashboard-settings/dashboard-settings.component';
|
||||
import {VersionChangelogDialogComponent} from '../layout/component/layout-menu/version-changelog-dialog/version-changelog-dialog.component';
|
||||
import {VersionChangelogDialogComponent} from '../layout/layout-menu/version-changelog-dialog/version-changelog-dialog.component';
|
||||
import {CreateUserDialogComponent} from '../../features/settings/user-management/create-user-dialog/create-user-dialog.component';
|
||||
import {CreateEmailRecipientDialogComponent} from '../../features/settings/email-v2/create-email-recipient-dialog/create-email-recipient-dialog.component';
|
||||
import {CreateEmailProviderDialogComponent} from '../../features/settings/email-v2/create-email-provider-dialog/create-email-provider-dialog.component';
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
@@ -18,9 +18,6 @@ body {
|
||||
min-height: 100%;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
--glow-image: url("../../../images/topbar.png"), radial-gradient(50% 50% at center -25px, var(--p-primary-color) 0%, #000 100%);
|
||||
--glow-blend: hard-light, color-dodge;
|
||||
}
|
||||
|
||||
a {
|
||||
@@ -32,11 +29,6 @@ a {
|
||||
min-height: 100dvh;
|
||||
scroll-behavior: smooth;
|
||||
background-color: var(--ground-background);
|
||||
background-blend-mode: var(--glow-blend);
|
||||
background-image: var(--glow-image);
|
||||
background-position: top;
|
||||
background-repeat: no-repeat;
|
||||
background-size: auto 20rem;
|
||||
}
|
||||
|
||||
p {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
left: 1.1rem;
|
||||
transition: transform variables.$transition-duration, left variables.$transition-duration;
|
||||
background-color: var(--card-background);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border: 1px solid var(--content-border-color);
|
||||
border-radius: variables.$border-radius;
|
||||
padding: 0.5rem 0.8rem 0.5rem 1.35rem;
|
||||
box-shadow: 0 3px 5px rgb(0 0 0 / 2%), 0 0 2px rgb(0 0 0 / 5%), 0 1px 4px rgb(0 0 0 / 8%);
|
||||
@@ -35,7 +35,7 @@
|
||||
font-size: .857rem;
|
||||
text-transform: uppercase;
|
||||
font-weight: 700;
|
||||
color: var(--surface-900);
|
||||
color: var(--text-secondary-color);
|
||||
margin: .75rem 0;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
background-color: var(--surface-hover);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
&:focus-visible {
|
||||
@include mixins.focused-inset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
@mixin focus-visible() {
|
||||
&:focus-visible {
|
||||
outline: 1px solid var(--primary-color);
|
||||
outline-offset: var(--p-focus-ring-offset);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin focused() {
|
||||
outline: 0 none;
|
||||
outline-offset: 0;
|
||||
transition: box-shadow .2s;
|
||||
box-shadow: var(--focus-ring);
|
||||
}
|
||||
|
||||
@mixin focused-inset() {
|
||||
outline: 0 none;
|
||||
outline-offset: 0;
|
||||
@@ -19,4 +5,3 @@
|
||||
box-shadow: inset var(--focus-ring);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,28 +11,6 @@
|
||||
|
||||
@media (width >= 992px) {
|
||||
.layout-wrapper {
|
||||
&.layout-overlay {
|
||||
.layout-main-container {
|
||||
margin-left: 0;
|
||||
padding: 5rem 1.1rem 1.1rem 3.6rem;
|
||||
}
|
||||
|
||||
.layout-sidebar {
|
||||
transform: translateX(-100%);
|
||||
left: 0;
|
||||
top: 0;
|
||||
height: 100dvh;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
&.layout-overlay-active {
|
||||
.layout-sidebar {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.layout-static {
|
||||
.layout-main-container {
|
||||
padding-left: calc(var(--sidebar-width, 225px) + 30px);
|
||||
@@ -85,6 +63,9 @@
|
||||
z-index: 998;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
appearance: none;
|
||||
background-color: rgb(0 0 0 / 60%);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
@use "mixins";
|
||||
@use "variables";
|
||||
|
||||
.layout-topbar {
|
||||
@@ -11,7 +10,7 @@
|
||||
padding: 0 1rem;
|
||||
background-color: color-mix(in srgb, var(--card-background) 25%, transparent);
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--p-content-border-color);
|
||||
border-bottom: 1px solid var(--content-border-color);
|
||||
transition: left variables.$transition-duration;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -63,8 +62,6 @@
|
||||
background-color: var(--card-background);
|
||||
cursor: pointer;
|
||||
|
||||
// @include focus-visible();
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
@@ -149,6 +146,43 @@
|
||||
|
||||
}
|
||||
|
||||
.layout-menu-button,
|
||||
.mobile-menu-trigger {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
padding: 0;
|
||||
border: 1px solid var(--border-color);
|
||||
background-color: var(--card-background);
|
||||
cursor: pointer;
|
||||
outline-color: transparent;
|
||||
transition: outline-color .2s, border-color .2s, transform .3s ease-in-out;
|
||||
|
||||
i {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.layout-menu-button {
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.mobile-menu-trigger {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.rotate-left {
|
||||
transform: rotate(0deg);
|
||||
transition: transform 0.3s ease-in-out;
|
||||
|
||||
@@ -5,7 +5,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||
font-family: inherit;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
color: var(--surface-900);
|
||||
color: var(--high-contrast-text-color);
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
@@ -50,7 +50,7 @@ blockquote {
|
||||
}
|
||||
|
||||
hr {
|
||||
border-top: solid var(--surface-border);
|
||||
border-top: solid var(--border-color);
|
||||
border-width: 1px 0 0;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* General */
|
||||
$scale: 14px; /* main font size */
|
||||
$border-radius: 12px; /* border radius of layout element e.g. card, sidebar */
|
||||
$transition-duration: .2s; /* transition duration of layout elements e.g. sidebar, overlay menus */
|
||||
$transition-duration: .2s; /* transition duration of layout elements e.g. sidebar */
|
||||
|
||||
@@ -6,4 +6,3 @@
|
||||
@use "_content";
|
||||
@use "_responsive";
|
||||
@use "_typography";
|
||||
@use "variables/main/dark";
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
@import './main/_dark';
|
||||
@@ -1,28 +0,0 @@
|
||||
:root[class~="p-dark"] {
|
||||
/* Primary */
|
||||
--primary-color: var(--p-primary-color);
|
||||
--primary-contrast-color: var(--p-primary-contrast-color);
|
||||
--primary-hover-color: var(--p-primary-hover-color);
|
||||
--primary-text-color: var(--p-primary-400);
|
||||
--primary-text-color-dark: var(--p-primary-900);
|
||||
|
||||
/* Content & Text */
|
||||
--text-color: var(--p-surface-0);
|
||||
--text-color-secondary: var(--p-surface-300);
|
||||
--text-secondary-color: var(--p-surface-400);
|
||||
--high-contrast-text-color: var(--p-surface-0);
|
||||
--p-text-muted-color: var(--p-surface-400);
|
||||
--p-content-background: var(--p-surface-900);
|
||||
--p-content-border-color: var(--p-surface-700);
|
||||
|
||||
/* Surfaces & Borders */
|
||||
--ground-background: var(--p-surface-950);
|
||||
--overlay-background: var(--p-surface-900);
|
||||
--card-background: var(--p-surface-900);
|
||||
--card-border: 1px solid transparent;
|
||||
--border-color: var(--p-surface-700);
|
||||
|
||||
/* Code, Mark & Selection */
|
||||
--code-background: var(--p-surface-900);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
:root {
|
||||
/* Primary */
|
||||
--primary-color: #4ade80;
|
||||
--primary-color-rgb: 74, 222, 128;
|
||||
--primary-contrast-color: #1a1e21;
|
||||
--primary-hover-color: #86efac;
|
||||
--primary-text-color: #4ade80;
|
||||
--primary-text-color-dark: #14532d;
|
||||
|
||||
/* Text */
|
||||
--text-color: #ffffff;
|
||||
--text-color-secondary: #b4bcc7;
|
||||
--text-secondary-color: #919ca9;
|
||||
--text-muted-color: #919ca9;
|
||||
--high-contrast-text-color: #ffffff;
|
||||
|
||||
/* Surfaces */
|
||||
--ground-background: #0d1012;
|
||||
--overlay-background: #1a1e21;
|
||||
--card-background: #1a1e21;
|
||||
--content-background: #1a1e21;
|
||||
--code-background: #1a1e21;
|
||||
|
||||
/* Borders */
|
||||
--border-color: #464f56;
|
||||
--content-border-color: #464f56;
|
||||
--card-border: 1px solid transparent;
|
||||
|
||||
/* Surface scale */
|
||||
--surface-0: #ffffff;
|
||||
--surface-50: #f4f6f8;
|
||||
--surface-100: #e6e9ed;
|
||||
--surface-200: #d3d8de;
|
||||
--surface-300: #b4bcc7;
|
||||
--surface-400: #919ca9;
|
||||
--surface-500: #71808a;
|
||||
--surface-600: #5a666f;
|
||||
--surface-700: #464f56;
|
||||
--surface-800: #34393e;
|
||||
--surface-900: #1a1e21;
|
||||
--surface-950: #0d1012;
|
||||
|
||||
/* Interaction */
|
||||
--surface-hover: color-mix(in srgb, var(--surface-400) 12%, transparent);
|
||||
--surface-border: var(--surface-700);
|
||||
|
||||
/* Focus */
|
||||
--focus-ring-offset: 2px;
|
||||
--focus-ring: 0 0 0 0.2rem color-mix(in srgb, var(--primary-color) 40%, transparent);
|
||||
|
||||
/* Typography */
|
||||
--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "",
|
||||
"createNewLibrary": "",
|
||||
"uploadBook": "",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": ""
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "",
|
||||
"dashboard": "",
|
||||
"allBooks": "",
|
||||
@@ -30,6 +32,7 @@
|
||||
"notebook": "",
|
||||
"update": ""
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "",
|
||||
"description": "",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "Bookdrop",
|
||||
"createNewLibrary": "Neue Bibliothek erstellen",
|
||||
"uploadBook": "Buch hochladen",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": "Lesestatistiken"
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "Startseite",
|
||||
"dashboard": "Dashboard",
|
||||
"allBooks": "Alle Bücher",
|
||||
@@ -30,6 +32,7 @@
|
||||
"update": "(Aktualisierung)",
|
||||
"authors": "Autoren"
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "Neuigkeiten",
|
||||
"description": "Neueste Updates und Verbesserungen",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "Bookdrop",
|
||||
"createNewLibrary": "Create New Library",
|
||||
"uploadBook": "Upload Book",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": "Reading Stats"
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "Home",
|
||||
"dashboard": "Dashboard",
|
||||
"allBooks": "All Books",
|
||||
@@ -30,6 +32,7 @@
|
||||
"notebook": "Notebook",
|
||||
"update": "(Update)"
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "What's New",
|
||||
"description": "Latest updates and improvements",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "Buzón de libros",
|
||||
"createNewLibrary": "Crear nueva biblioteca",
|
||||
"uploadBook": "Subir libro",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": "Estadísticas de lectura"
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "Inicio",
|
||||
"dashboard": "Panel",
|
||||
"allBooks": "Todos los libros",
|
||||
@@ -30,6 +32,7 @@
|
||||
"notebook": "Cuaderno",
|
||||
"update": "(Actualizar)"
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "Novedades",
|
||||
"description": "Últimas actualizaciones y mejoras",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "Bookdrop",
|
||||
"createNewLibrary": "Créer une nouvelle bibliothèque",
|
||||
"uploadBook": "Téléverser un livre",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": "Statistiques de lecture"
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "Accueil",
|
||||
"dashboard": "Tableau de bord",
|
||||
"allBooks": "Tous les livres",
|
||||
@@ -30,6 +32,7 @@
|
||||
"update": "(Mise à jour)",
|
||||
"authors": "Auteurs"
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "Nouveautés",
|
||||
"description": "Dernières mises à jour et améliorations",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "Bookdrop",
|
||||
"createNewLibrary": "Kreiraj novu knjižnicu",
|
||||
"uploadBook": "Učitaj knjigu",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": "Statistika čitanja"
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "Početna",
|
||||
"dashboard": "Nadzorna ploča",
|
||||
"allBooks": "Sve knjige",
|
||||
@@ -30,6 +32,7 @@
|
||||
"update": "(Ažuriraj)",
|
||||
"authors": "Autori"
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "Što je novo",
|
||||
"description": "Najnovija ažuriranja i poboljšanja",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "Gyűjtőláda",
|
||||
"createNewLibrary": "Új Könyvtár Létrehozása",
|
||||
"uploadBook": "Könyv Feltöltése",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": "Olvasási Statisztikák"
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "Áttekintés",
|
||||
"dashboard": "Kezdőlap",
|
||||
"allBooks": "Minden Könyv",
|
||||
@@ -30,6 +32,7 @@
|
||||
"notebook": "Jegyzetfüzet",
|
||||
"update": "(Frissítés)"
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "Újdonságok",
|
||||
"description": "Legújabb frissítések és fejlesztések",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "",
|
||||
"createNewLibrary": "Buat Perpustakaan Baru",
|
||||
"uploadBook": "Unggah Buku",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": ""
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "",
|
||||
"dashboard": "",
|
||||
"allBooks": "",
|
||||
@@ -30,6 +32,7 @@
|
||||
"notebook": "",
|
||||
"update": ""
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "",
|
||||
"description": "",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "Bookdrop",
|
||||
"createNewLibrary": "Crea nuova libreria",
|
||||
"uploadBook": "Carica libro",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": "Statistiche di lettura"
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "Home",
|
||||
"dashboard": "Pannello di controllo",
|
||||
"allBooks": "Tutti i libri",
|
||||
@@ -30,6 +32,7 @@
|
||||
"update": "(Aggiornamento)",
|
||||
"authors": ""
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "Novità",
|
||||
"description": "Ultimi aggiornamenti e miglioramenti",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "ブックドロップ",
|
||||
"createNewLibrary": "新規ライブラリ作成",
|
||||
"uploadBook": "本をアップロード",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": "読書統計"
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "ホーム",
|
||||
"dashboard": "ダッシュボード",
|
||||
"allBooks": "すべての本",
|
||||
@@ -30,6 +32,7 @@
|
||||
"update": "(アップデート)",
|
||||
"authors": ""
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "新着情報",
|
||||
"description": "最新のアップデートと改善",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"topbar": {
|
||||
"toggleNavigation": "Toggle navigation",
|
||||
"bookdrop": "Bookdrop",
|
||||
"createNewLibrary": "Nieuwe bibliotheek aanmaken",
|
||||
"uploadBook": "",
|
||||
@@ -18,6 +19,7 @@
|
||||
"readingStats": ""
|
||||
},
|
||||
"menu": {
|
||||
"adjustSidebarWidth": "Adjust sidebar width",
|
||||
"home": "",
|
||||
"dashboard": "",
|
||||
"allBooks": "",
|
||||
@@ -30,6 +32,7 @@
|
||||
"notebook": "",
|
||||
"update": ""
|
||||
},
|
||||
"closeNavigation": "Close navigation",
|
||||
"changelog": {
|
||||
"title": "",
|
||||
"description": "",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user