diff --git a/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.html b/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.html
index 8dac6f99e..53d91b1f6 100644
--- a/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.html
+++ b/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.html
@@ -87,7 +87,7 @@
@@ -138,7 +143,7 @@
(click)="openSearch()"
>
- {{ t('search') }}
+
@@ -166,7 +171,7 @@
[attr.aria-label]="t('add')"
>
- {{ t('add') }}
+
- {{ t('uploadBook') }}
+
}
diff --git a/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.scss b/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.scss
index 8a3d1d59c..b120a9ad4 100644
--- a/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.scss
+++ b/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.scss
@@ -148,6 +148,38 @@
}
}
+.sidebar-notification-button {
+ position: relative;
+}
+
+.sidebar-notification-button-content {
+ position: relative;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ margin-left: 0;
+ overflow: visible;
+ white-space: normal;
+}
+
+.sidebar-notification-badge {
+ position: absolute;
+ top: -0.3rem;
+ right: -0.35rem;
+ min-width: 1rem;
+ height: 1rem;
+ padding: 0 0.25rem;
+ border-radius: var(--radius-pill);
+ background: var(--primary-color);
+ color: var(--primary-color-text);
+ font-size: 0.65rem;
+ font-weight: 700;
+ line-height: 1rem;
+ text-align: center;
+ pointer-events: none;
+ z-index: 1;
+}
+
.sidebar-nav {
flex: 1 1 auto;
overflow-y: auto;
@@ -219,7 +251,8 @@
flex-shrink: 0;
}
- span {
+ .sidebar-action-label,
+ .sidebar-footer-action-label {
margin-left: var(--sidebar-row-label-offset);
overflow: hidden;
text-overflow: ellipsis;
@@ -241,7 +274,7 @@
padding-left: 0;
padding-right: 0;
- span {
+ .sidebar-footer-action-label {
display: none;
}
@@ -454,7 +487,7 @@
}
}
- .sidebar-footer-action span {
+ .sidebar-footer-action .sidebar-footer-action-label {
display: inline-flex;
margin-left: 0;
font-size: var(--text-sm);
diff --git a/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.spec.ts b/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.spec.ts
index e46b72ac7..9799a313e 100644
--- a/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.spec.ts
+++ b/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.spec.ts
@@ -15,7 +15,10 @@ import { MagicShelfService } from '../../../features/magic-shelf/service/magic-s
import { SeriesDataService } from '../../../features/series-browser/service/series-data.service';
import { UserService } from '../../../features/settings/user-management/user.service';
import { CommandPaletteService } from '../../../features/command-palette/command-palette.service';
+import { BookdropFileService } from '../../../features/bookdrop/service/bookdrop-file.service';
import { AuthService } from '../../service/auth.service';
+import { MetadataBatchProgressNotification, MetadataBatchStatus } from '../../model/metadata-batch-progress.model';
+import { MetadataProgressService } from '../../service/metadata-progress.service';
import { AppVersion, VersionService } from '../../service/version.service';
import { DialogLauncherService } from '../../services/dialog-launcher.service';
import { LayoutService } from '../layout.service';
@@ -53,6 +56,9 @@ describe('AppSidebarComponent', () => {
let commandPaletteService: { open: ReturnType };
let currentUser: WritableSignal;
let versionInfo: BehaviorSubject;
+ let activeTasks$: BehaviorSubject>;
+ let progressUpdates$: BehaviorSubject;
+ let hasPendingFiles$: BehaviorSubject;
const sidebarCollapsed = signal(false);
const isDesktop = signal(true);
const layoutService = {
@@ -69,6 +75,16 @@ describe('AppSidebarComponent', () => {
commandPaletteService = { open: vi.fn() };
currentUser = signal(null);
versionInfo = new BehaviorSubject({ current: '1.2.3', latest: '1.2.3' });
+ activeTasks$ = new BehaviorSubject>({});
+ progressUpdates$ = new BehaviorSubject({
+ taskId: 'initial',
+ completed: 0,
+ total: 1,
+ message: 'idle',
+ status: MetadataBatchStatus.COMPLETED,
+ review: false,
+ });
+ hasPendingFiles$ = new BehaviorSubject(false);
TestBed.configureTestingModule({
imports: [AppSidebarComponent, getTranslocoModule()],
@@ -96,6 +112,8 @@ describe('AppSidebarComponent', () => {
{ provide: CommandPaletteService, useValue: commandPaletteService },
{ provide: BookDialogHelperService, useValue: { openShelfCreatorDialog: vi.fn() } },
{ provide: AuthService, useValue: { logout: vi.fn() } },
+ { provide: MetadataProgressService, useValue: { activeTasks$, progressUpdates$ } },
+ { provide: BookdropFileService, useValue: { hasPendingFiles$ } },
{ provide: VersionService, useValue: { getVersion: vi.fn(() => versionInfo) } },
{ provide: LayoutService, useValue: layoutService },
{ provide: UserService, useValue: { currentUser } },
@@ -229,4 +247,61 @@ describe('AppSidebarComponent', () => {
expect(container.style.getPropertyValue('--sidebar-popover-top')).toBe('212px');
expect(container.style.getPropertyValue('--sidebar-popover-left')).toBe(`${window.innerWidth - 128}px`);
});
+
+ it('aggregates metadata tasks and pending bookdrop files into the sidebar badge count', () => {
+ const sidebar = component as unknown as {
+ completedTaskCount: number;
+ shouldShowNotificationBadge: boolean;
+ };
+
+ activeTasks$.next({
+ taskA: {
+ taskId: 'taskA',
+ completed: 1,
+ total: 2,
+ message: 'Scanning',
+ status: MetadataBatchStatus.COMPLETED,
+ review: false,
+ },
+ taskB: {
+ taskId: 'taskB',
+ completed: 2,
+ total: 2,
+ message: 'Importing',
+ status: MetadataBatchStatus.ERROR,
+ review: true,
+ },
+ });
+ hasPendingFiles$.next(true);
+
+ expect(sidebar.completedTaskCount).toBe(3);
+ expect(sidebar.shouldShowNotificationBadge).toBe(true);
+ });
+
+ it('hides the badge while metadata progress is actively running', () => {
+ const sidebar = component as unknown as {
+ shouldShowNotificationBadge: boolean;
+ };
+
+ activeTasks$.next({
+ taskA: {
+ taskId: 'taskA',
+ completed: 1,
+ total: 3,
+ message: 'Updating metadata',
+ status: MetadataBatchStatus.IN_PROGRESS,
+ review: false,
+ },
+ });
+ progressUpdates$.next({
+ taskId: 'taskA',
+ completed: 1,
+ total: 3,
+ message: 'Updating metadata',
+ status: MetadataBatchStatus.IN_PROGRESS,
+ review: false,
+ });
+
+ expect(sidebar.shouldShowNotificationBadge).toBe(false);
+ });
});
diff --git a/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.ts b/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.ts
index b0e303175..69dc36671 100644
--- a/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.ts
+++ b/frontend/src/app/shared/layout/layout-sidebar/app.sidebar.component.ts
@@ -1,4 +1,4 @@
-import { Component, Renderer2, RendererStyleFlags2, computed, inject, signal } from '@angular/core';
+import { Component, DestroyRef, Renderer2, RendererStyleFlags2, computed, inject, signal } from '@angular/core';
import { Router, RouterLink } from '@angular/router';
import { AppSidebarSectionComponent } from './app.sidebar-section.component';
import { MenuTrigger } from '@angular/aria/menu';
@@ -30,7 +30,7 @@ import { AuthService } from '../../service/auth.service';
import { LayoutService } from '../layout.service';
import { TranslocoDirective, TranslocoPipe, TranslocoService } from '@jsverse/transloco';
import { Tooltip } from 'primeng/tooltip';
-import { toSignal } from '@angular/core/rxjs-interop';
+import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
import { NavItem, SidebarSection } from '../navigation/nav-item.model';
import { buildCreateActionNavItems } from '../navigation/nav-catalog';
import {
@@ -41,6 +41,9 @@ import {
buildToolsSection,
} from './sidebar-sections';
import { VersionService } from '../../service/version.service';
+import { MetadataProgressService } from '../../service/metadata-progress.service';
+import { BookdropFileService } from '../../../features/bookdrop/service/bookdrop-file.service';
+import { MetadataBatchProgressNotification, MetadataBatchStatus } from '../../model/metadata-batch-progress.model';
const DOCUMENTATION_URL = 'https://grimmory.org/docs/getting-started';
@@ -125,6 +128,9 @@ export class AppSidebarComponent {
private readonly authorService = inject(AuthorService);
private readonly t = inject(TranslocoService);
private readonly renderer = inject(Renderer2);
+ private readonly destroyRef = inject(DestroyRef);
+ private readonly metadataProgressService = inject(MetadataProgressService);
+ private readonly bookdropFileService = inject(BookdropFileService);
readonly currentUser = this.userService.currentUser;
private readonly allAuthors = this.authorService.allAuthors;
@@ -207,17 +213,43 @@ export class AppSidebarComponent {
});
protected readonly notificationsOpen = signal(false);
+ protected progressHighlight = false;
+ protected completedTaskCount = 0;
+ protected hasPendingBookdropFiles = false;
protected readonly mobileMenuPositions = BELOW_ALIGN_LEFT;
protected readonly aboveMenuPositions = ABOVE_ALIGN_LEFT;
protected readonly footerMenuPositions = computed(() =>
this.layoutService.desktopSidebarCollapsed() ? BESIDE_RIGHT_BOTTOM : ABOVE_ALIGN_LEFT,
);
+ private readonly latestTasks: Record = {};
+
+ constructor() {
+ this.subscribeToMetadataProgress();
+
+ this.metadataProgressService.activeTasks$
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe((tasks) => {
+ this.replaceLatestTasks(tasks);
+ this.updateCompletedTaskCount();
+ });
+
+ this.bookdropFileService.hasPendingFiles$
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe((hasPending) => {
+ this.hasPendingBookdropFiles = hasPending;
+ this.updateCompletedTaskCount();
+ });
+ }
openSearch(): void {
this.commandPaletteService.open();
}
+ protected get shouldShowNotificationBadge(): boolean {
+ return this.completedTaskCount > 0 && !this.progressHighlight;
+ }
+
closeMobileSidebar(): void {
this.layoutService.closeMobileSidebar();
}
@@ -333,4 +365,25 @@ export class AppSidebarComponent {
}
overlay.toggle(event);
}
+
+ private subscribeToMetadataProgress(): void {
+ this.metadataProgressService.progressUpdates$
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe((progress) => {
+ this.progressHighlight = progress.status === MetadataBatchStatus.IN_PROGRESS;
+ });
+ }
+
+ private replaceLatestTasks(tasks: Record): void {
+ for (const key of Object.keys(this.latestTasks)) {
+ delete this.latestTasks[key];
+ }
+ Object.assign(this.latestTasks, tasks);
+ }
+
+ private updateCompletedTaskCount(): void {
+ const metadataTaskCount = Object.keys(this.latestTasks).length;
+ const bookdropFileTaskCount = this.hasPendingBookdropFiles ? 1 : 0;
+ this.completedTaskCount = metadataTaskCount + bookdropFileTaskCount;
+ }
}
diff --git a/frontend/src/assets/layout/styles/layout/_sidebar.scss b/frontend/src/assets/layout/styles/layout/_sidebar.scss
index 0d292d60d..5ff04d466 100644
--- a/frontend/src/assets/layout/styles/layout/_sidebar.scss
+++ b/frontend/src/assets/layout/styles/layout/_sidebar.scss
@@ -118,7 +118,7 @@ body.layout-resizing-cursor {
.sidebar-item-chevron,
.entity-menu-button,
.sidebar-item-end-content,
- .sidebar-action-link span,
+ .sidebar-footer-action-label,
.sidebar-user-trigger .sidebar-user-meta,
.sidebar-search-shortcut {
display: none;