fix(dashboard): improve performance with OnPush change detection (#440)
* fix(dashboard): improve performance with OnPush change detection * fix(dashboard): refactor book card component for improved readability and performance * fix(tests): mock matchMedia for improved test compatibility * fix(tests): matchMedia mock for better CI compatibility and support * fix(dashboard): add clearAll method to BookBrowserScrollService and update tests * fix(dashboard): improve performance with content visibility and refactor styles * fix(dashboard): improve scroll performance with estimated total height and refactor layout * fix(tests): add mock for getCurrentUser in userService for improved test coverage * fix(dashboard): implement infinite scroll for book loading and scroll restoration * fix(tests): fix lint error * fix(tests): mock ResizeObserver and IntersectionObserver * fix(tests): mock ResizeObserver and IntersectionObserver (again) * fix(dashboard): improve accessibility and performance by updating aria attributes and optimizing animations * fix(dashboard): improve submenu accessibility and optimize virtual scroller performance * fix(dashboard): clean up imports and improve component structure * fix(dashboard): correct mobile check in author browser component * fix(dashboard): add OnDestroy lifecycle hook to BookBrowserComponent
This commit is contained in:
@@ -27,9 +27,7 @@
|
|||||||
"outputPath": "dist/grimmory",
|
"outputPath": "dist/grimmory",
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"browser": "src/main.ts",
|
"browser": "src/main.ts",
|
||||||
"polyfills": [
|
"polyfills": [],
|
||||||
"zone.js"
|
|
||||||
],
|
|
||||||
"tsConfig": "tsconfig.app.json",
|
"tsConfig": "tsconfig.app.json",
|
||||||
"inlineStyleLanguage": "scss",
|
"inlineStyleLanguage": "scss",
|
||||||
"assets": [
|
"assets": [
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^21.2.7",
|
"@angular/animations": "^21.2.7",
|
||||||
"@angular/cdk": "^21.2.5",
|
"@angular/cdk": "^21.2.6",
|
||||||
|
"@angular/cdk-experimental": "^21.2.5",
|
||||||
"@angular/common": "^21.2.7",
|
"@angular/common": "^21.2.7",
|
||||||
"@angular/compiler": "^21.2.7",
|
"@angular/compiler": "^21.2.7",
|
||||||
"@angular/core": "^21.2.7",
|
"@angular/core": "^21.2.7",
|
||||||
@@ -34,7 +35,6 @@
|
|||||||
"@angular/service-worker": "^21.2.7",
|
"@angular/service-worker": "^21.2.7",
|
||||||
"@embedpdf/pdfium": "2.14.0",
|
"@embedpdf/pdfium": "2.14.0",
|
||||||
"@embedpdf/snippet": "2.14.0",
|
"@embedpdf/snippet": "2.14.0",
|
||||||
"@iharbeck/ngx-virtual-scroller": "^20.0.0",
|
|
||||||
"@jsverse/transloco": "^8.2.1",
|
"@jsverse/transloco": "^8.2.1",
|
||||||
"@primeuix/themes": "^2.0.3",
|
"@primeuix/themes": "^2.0.3",
|
||||||
"@stomp/rx-stomp": "^2.3.0",
|
"@stomp/rx-stomp": "^2.3.0",
|
||||||
@@ -58,8 +58,7 @@
|
|||||||
"showdown": "^2.1.0",
|
"showdown": "^2.1.0",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"uuid": "^11.1.0",
|
"uuid": "^11.1.0",
|
||||||
"ws": "^8.20.0",
|
"ws": "^8.20.0"
|
||||||
"zone.js": "^0.16.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@analogjs/vite-plugin-angular": "^2.4.0",
|
"@analogjs/vite-plugin-angular": "^2.4.0",
|
||||||
|
|||||||
@@ -115,8 +115,7 @@ describe("AppComponent", () => {
|
|||||||
{ provide: LibraryLoadingService, useValue: libraryLoadingService },
|
{ provide: LibraryLoadingService, useValue: libraryLoadingService },
|
||||||
{ provide: AuthService, useValue: authService },
|
{ provide: AuthService, useValue: authService },
|
||||||
ConfirmationService,
|
ConfirmationService,
|
||||||
MessageService,
|
MessageService],
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture = TestBed.createComponent(AppComponent);
|
fixture = TestBed.createComponent(AppComponent);
|
||||||
@@ -210,12 +209,10 @@ describe("AppComponent", () => {
|
|||||||
|
|
||||||
expect(bookService.handleBookUpdate).toHaveBeenCalledWith({ id: 1 });
|
expect(bookService.handleBookUpdate).toHaveBeenCalledWith({ id: 1 });
|
||||||
expect(bookService.handleMultipleBookCoverPatches).toHaveBeenCalledWith([
|
expect(bookService.handleMultipleBookCoverPatches).toHaveBeenCalledWith([
|
||||||
{ id: 1 },
|
{ id: 1 }]);
|
||||||
]);
|
|
||||||
expect(bookService.handleRemovedBookIds).toHaveBeenCalledWith([1, 2]);
|
expect(bookService.handleRemovedBookIds).toHaveBeenCalledWith([1, 2]);
|
||||||
expect(bookService.handleMultipleBookUpdates).toHaveBeenCalledWith([
|
expect(bookService.handleMultipleBookUpdates).toHaveBeenCalledWith([
|
||||||
{ id: 3 },
|
{ id: 3 }]);
|
||||||
]);
|
|
||||||
expect(metadataProgressService.handleIncomingProgress).toHaveBeenCalledWith(
|
expect(metadataProgressService.handleIncomingProgress).toHaveBeenCalledWith(
|
||||||
{ taskId: "task-1" },
|
{ taskId: "task-1" },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function createRoute(path: string, params: Record<string, string> = {}): Activat
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('CustomReuseStrategy', () => {
|
describe('CustomReuseStrategy', () => {
|
||||||
const handle = {componentRef: {} as never} as DetachedRouteHandle;
|
const handle = {componentRef: {destroy: vi.fn()} as never} as DetachedRouteHandle;
|
||||||
|
|
||||||
let strategy: CustomReuseStrategy;
|
let strategy: CustomReuseStrategy;
|
||||||
let scrollService: BookBrowserScrollService;
|
let scrollService: BookBrowserScrollService;
|
||||||
@@ -122,4 +122,72 @@ describe('CustomReuseStrategy', () => {
|
|||||||
expect(strategy.shouldReuseRoute(differentParams, current)).toBe(false);
|
expect(strategy.shouldReuseRoute(differentParams, current)).toBe(false);
|
||||||
expect(strategy.shouldReuseRoute(differentConfig, current)).toBe(false);
|
expect(strategy.shouldReuseRoute(differentConfig, current)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('evicts the oldest route when storing more than MAX_STORED_ROUTES (3)', () => {
|
||||||
|
const route1 = createRoute('library/:libraryId/books', {libraryId: '1'});
|
||||||
|
const route2 = createRoute('library/:libraryId/books', {libraryId: '2'});
|
||||||
|
const route3 = createRoute('library/:libraryId/books', {libraryId: '3'});
|
||||||
|
const route4 = createRoute('library/:libraryId/books', {libraryId: '4'});
|
||||||
|
|
||||||
|
const handle1 = {componentRef: {id: 1, destroy: vi.fn()} as never} as DetachedRouteHandle;
|
||||||
|
const handle2 = {componentRef: {id: 2, destroy: vi.fn()} as never} as DetachedRouteHandle;
|
||||||
|
const handle3 = {componentRef: {id: 3, destroy: vi.fn()} as never} as DetachedRouteHandle;
|
||||||
|
const handle4 = {componentRef: {id: 4, destroy: vi.fn()} as never} as DetachedRouteHandle;
|
||||||
|
|
||||||
|
strategy.store(route1, handle1);
|
||||||
|
strategy.store(route2, handle2);
|
||||||
|
strategy.store(route3, handle3);
|
||||||
|
|
||||||
|
expect(strategy.shouldAttach(route1)).toBe(true);
|
||||||
|
expect(strategy.shouldAttach(route2)).toBe(true);
|
||||||
|
expect(strategy.shouldAttach(route3)).toBe(true);
|
||||||
|
|
||||||
|
strategy.store(route4, handle4);
|
||||||
|
|
||||||
|
expect(strategy.shouldAttach(route1)).toBe(false);
|
||||||
|
expect(strategy.shouldAttach(route2)).toBe(true);
|
||||||
|
expect(strategy.shouldAttach(route3)).toBe(true);
|
||||||
|
expect(strategy.shouldAttach(route4)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('clears scroll positions when evicting old routes', () => {
|
||||||
|
const clearSpy = vi.spyOn(scrollService, 'clearPosition');
|
||||||
|
|
||||||
|
const route1 = createRoute('library/:libraryId/books', {libraryId: '10'});
|
||||||
|
const route2 = createRoute('library/:libraryId/books', {libraryId: '20'});
|
||||||
|
const route3 = createRoute('library/:libraryId/books', {libraryId: '30'});
|
||||||
|
const route4 = createRoute('library/:libraryId/books', {libraryId: '40'});
|
||||||
|
|
||||||
|
scrollService.savePosition('library/:libraryId/books:10', 100);
|
||||||
|
|
||||||
|
strategy.store(route1, handle);
|
||||||
|
strategy.store(route2, handle);
|
||||||
|
strategy.store(route3, handle);
|
||||||
|
|
||||||
|
expect(clearSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
strategy.store(route4, handle);
|
||||||
|
|
||||||
|
expect(clearSpy).toHaveBeenCalledWith('library/:libraryId/books:10');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('re-storing an existing route refreshes its LRU position', () => {
|
||||||
|
const route1 = createRoute('library/:libraryId/books', {libraryId: '1'});
|
||||||
|
const route2 = createRoute('library/:libraryId/books', {libraryId: '2'});
|
||||||
|
const route3 = createRoute('library/:libraryId/books', {libraryId: '3'});
|
||||||
|
const route4 = createRoute('library/:libraryId/books', {libraryId: '4'});
|
||||||
|
|
||||||
|
strategy.store(route1, handle);
|
||||||
|
strategy.store(route2, handle);
|
||||||
|
strategy.store(route3, handle);
|
||||||
|
|
||||||
|
strategy.store(route1, handle);
|
||||||
|
|
||||||
|
strategy.store(route4, handle);
|
||||||
|
|
||||||
|
expect(strategy.shouldAttach(route1)).toBe(true);
|
||||||
|
expect(strategy.shouldAttach(route2)).toBe(false);
|
||||||
|
expect(strategy.shouldAttach(route3)).toBe(true);
|
||||||
|
expect(strategy.shouldAttach(route4)).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,26 @@
|
|||||||
import {inject, Injectable} from '@angular/core';
|
import {inject, Injectable} from '@angular/core';
|
||||||
import {ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy} from '@angular/router';
|
import {ActivatedRouteSnapshot, DetachedRouteHandle, destroyDetachedRouteHandle, RouteReuseStrategy} from '@angular/router';
|
||||||
import {BookBrowserScrollService} from '../features/book/components/book-browser/book-browser-scroll.service';
|
import {BookBrowserScrollService} from '../features/book/components/book-browser/book-browser-scroll.service';
|
||||||
import {BookSelectionService} from '../features/book/components/book-browser/book-selection.service';
|
import {BookSelectionService} from '../features/book/components/book-browser/book-selection.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of detached BookBrowser routes kept in memory.
|
||||||
|
* Each cached route retains its full component tree (book cards, images,
|
||||||
|
* event listeners, virtual-scroller instance) so an unbounded cache leads
|
||||||
|
* to severe memory growth when the user switches between libraries.
|
||||||
|
*
|
||||||
|
* 3 slots is enough for productive back-navigation while keeping memory
|
||||||
|
* usage under control.
|
||||||
|
*/
|
||||||
|
const MAX_STORED_ROUTES = 3;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class CustomReuseStrategy implements RouteReuseStrategy {
|
export class CustomReuseStrategy implements RouteReuseStrategy {
|
||||||
private storedRoutes = new Map<string, DetachedRouteHandle>();
|
private storedRoutes = new Map<string, DetachedRouteHandle>();
|
||||||
|
/** Insertion-order queue so we can evict the oldest entry (LRU). */
|
||||||
|
private insertionOrder: string[] = [];
|
||||||
private scrollService = inject(BookBrowserScrollService);
|
private scrollService = inject(BookBrowserScrollService);
|
||||||
private bookSelectionService = inject(BookSelectionService);
|
private bookSelectionService = inject(BookSelectionService);
|
||||||
|
|
||||||
@@ -40,8 +53,28 @@ export class CustomReuseStrategy implements RouteReuseStrategy {
|
|||||||
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void {
|
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void {
|
||||||
if (handle && this.isBookBrowserRoute(route)) {
|
if (handle && this.isBookBrowserRoute(route)) {
|
||||||
const key = this.getRouteKey(route);
|
const key = this.getRouteKey(route);
|
||||||
|
|
||||||
|
// If the key already exists, remove it from insertion order so it
|
||||||
|
// can be re-appended at the end (most-recently-used).
|
||||||
|
const existingIdx = this.insertionOrder.indexOf(key);
|
||||||
|
if (existingIdx !== -1) {
|
||||||
|
this.insertionOrder.splice(existingIdx, 1);
|
||||||
|
}
|
||||||
|
|
||||||
this.storedRoutes.set(key, handle);
|
this.storedRoutes.set(key, handle);
|
||||||
|
this.insertionOrder.push(key);
|
||||||
this.bookSelectionService.deselectAll();
|
this.bookSelectionService.deselectAll();
|
||||||
|
|
||||||
|
// Evict oldest routes when we exceed the budget.
|
||||||
|
while (this.insertionOrder.length > MAX_STORED_ROUTES) {
|
||||||
|
const evictKey = this.insertionOrder.shift()!;
|
||||||
|
const evictedHandle = this.storedRoutes.get(evictKey);
|
||||||
|
this.storedRoutes.delete(evictKey);
|
||||||
|
this.scrollService.clearPosition(evictKey);
|
||||||
|
if (evictedHandle) {
|
||||||
|
destroyDetachedRouteHandle(evictedHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {signal, type EnvironmentProviders, type Provider, type WritableSignal} from '@angular/core';
|
import {ApplicationRef, provideZonelessChangeDetection, signal, type EnvironmentProviders, type Provider, type WritableSignal} from '@angular/core';
|
||||||
import {provideHttpClient} from '@angular/common/http';
|
import {provideHttpClient} from '@angular/common/http';
|
||||||
import {provideHttpClientTesting} from '@angular/common/http/testing';
|
import {provideHttpClientTesting} from '@angular/common/http/testing';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
@@ -28,6 +28,7 @@ export function createQueryClientHarness(): QueryClientHarness {
|
|||||||
return {
|
return {
|
||||||
queryClient,
|
queryClient,
|
||||||
providers: [
|
providers: [
|
||||||
|
provideZonelessChangeDetection(),
|
||||||
provideHttpClient(),
|
provideHttpClient(),
|
||||||
provideHttpClientTesting(),
|
provideHttpClientTesting(),
|
||||||
provideTanStackQuery(queryClient),
|
provideTanStackQuery(queryClient),
|
||||||
@@ -38,3 +39,22 @@ export function createQueryClientHarness(): QueryClientHarness {
|
|||||||
export function flushSignalAndQueryEffects(): void {
|
export function flushSignalAndQueryEffects(): void {
|
||||||
TestBed.flushEffects();
|
TestBed.flushEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronously flushes Angular effects and query state across multiple rounds.
|
||||||
|
* Use this for tests involving async operations like HTTP requests or timers.
|
||||||
|
* For synchronous signal/effect flushing, use `flushSignalAndQueryEffects()` instead.
|
||||||
|
*
|
||||||
|
* @param rounds Number of cycles to await macrotask and microtask resolutions. Defaults to 5.
|
||||||
|
*/
|
||||||
|
export async function flushQueryAsync(rounds = 5): Promise<void> {
|
||||||
|
const appRef = TestBed.inject(ApplicationRef);
|
||||||
|
for (let i = 0; i < rounds; i++) {
|
||||||
|
TestBed.flushEffects();
|
||||||
|
appRef.tick();
|
||||||
|
await Promise.resolve();
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 0));
|
||||||
|
}
|
||||||
|
TestBed.flushEffects();
|
||||||
|
appRef.tick();
|
||||||
|
}
|
||||||
|
|||||||
+9
-10
@@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@if (!isMobile) {
|
@if (!isMobile()) {
|
||||||
<button class="display-settings-btn" (click)="displaySettingsPopover.toggle($event)">
|
<button class="display-settings-btn" (click)="displaySettingsPopover.toggle($event)">
|
||||||
<i class="pi pi-sliders-h"></i>
|
<i class="pi pi-sliders-h"></i>
|
||||||
</button>
|
</button>
|
||||||
@@ -193,21 +193,20 @@
|
|||||||
<p>{{ t('noAuthorsFound') }}</p>
|
<p>{{ t('noAuthorsFound') }}</p>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<virtual-scroller
|
<cdk-virtual-scroll-viewport autosize
|
||||||
|
[minBufferPx]="600" [maxBufferPx]="1200"
|
||||||
#scroll
|
#scroll
|
||||||
[items]="authorList"
|
|
||||||
[bufferAmount]="16"
|
|
||||||
class="virtual-scroller">
|
class="virtual-scroller">
|
||||||
<div class="author-grid"
|
<div class="author-grid"
|
||||||
#container
|
*cdkVirtualFor="let row of authorRows(); let rowIndex = index"
|
||||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
[ngStyle]="{'grid-template-columns': 'repeat(' + gridColumns() + ', 1fr)'}">
|
||||||
@for (author of scroll.viewPortItems; track author.id; let i = $index) {
|
@for (author of row; track author.id; let colIdx = $index) {
|
||||||
<div class="virtual-scroller-item"
|
<div class="virtual-scroller-item"
|
||||||
[ngStyle]="{width: cardWidth + 'px', height: cardHeight + 'px'}"
|
[ngStyle]="{width: cardWidth() + 'px', height: cardHeight() + 'px'}"
|
||||||
[style.--card-scale]="authorScaleService.scaleFactor()">
|
[style.--card-scale]="authorScaleService.scaleFactor()">
|
||||||
<app-author-card
|
<app-author-card
|
||||||
[author]="author"
|
[author]="author"
|
||||||
[index]="authorList.indexOf(author)"
|
[index]="rowIndex * gridColumns() + colIdx"
|
||||||
[cacheBuster]="thumbnailCacheBusters.get(author.id) || 0"
|
[cacheBuster]="thumbnailCacheBusters.get(author.id) || 0"
|
||||||
[canQuickMatch]="canEditMetadata"
|
[canQuickMatch]="canEditMetadata"
|
||||||
[canDelete]="canDeleteBook"
|
[canDelete]="canDeleteBook"
|
||||||
@@ -223,7 +222,7 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</virtual-scroller>
|
</cdk-virtual-scroll-viewport>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+49
-20
@@ -1,4 +1,5 @@
|
|||||||
import {Component, computed, DestroyRef, effect, HostListener, inject, OnInit, signal, ViewChild} from '@angular/core';
|
import {Component, computed, DestroyRef, effect, HostListener, inject, OnInit, signal, ViewChild} from '@angular/core';
|
||||||
|
import {computeGridColumns} from '../../../../shared/util/viewport.util';
|
||||||
import {NgStyle} from '@angular/common';
|
import {NgStyle} from '@angular/common';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
@@ -12,12 +13,14 @@ import {Button} from 'primeng/button';
|
|||||||
import {Divider} from 'primeng/divider';
|
import {Divider} from 'primeng/divider';
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {VirtualScrollerComponent, VirtualScrollerModule} from '@iharbeck/ngx-virtual-scroller';
|
import {CdkVirtualScrollViewport, CdkVirtualForOf} from '@angular/cdk/scrolling';
|
||||||
|
import {CdkAutoSizeVirtualScroll} from '@angular/cdk-experimental/scrolling';
|
||||||
import {BookBrowserScrollService} from '../../../book/components/book-browser/book-browser-scroll.service';
|
import {BookBrowserScrollService} from '../../../book/components/book-browser/book-browser-scroll.service';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {AuthorService} from '../../service/author.service';
|
import {AuthorService} from '../../service/author.service';
|
||||||
import {AuthorSummary, EnrichedAuthor, AuthorFilters, DEFAULT_AUTHOR_FILTERS} from '../../model/author.model';
|
import {AuthorSummary, EnrichedAuthor, AuthorFilters, DEFAULT_AUTHOR_FILTERS} from '../../model/author.model';
|
||||||
import {AuthorCardComponent} from '../author-card/author-card.component';
|
import {AuthorCardComponent} from '../author-card/author-card.component';
|
||||||
|
import {chunk} from '../../../../shared/util/array.util';
|
||||||
import {AuthorScalePreferenceService} from '../../service/author-scale-preference.service';
|
import {AuthorScalePreferenceService} from '../../service/author-scale-preference.service';
|
||||||
import {AuthorSelectionService, AuthorCheckboxClickEvent} from '../../service/author-selection.service';
|
import {AuthorSelectionService, AuthorCheckboxClickEvent} from '../../service/author-selection.service';
|
||||||
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
||||||
@@ -68,7 +71,9 @@ const DEFAULT_SORT_DIRECTIONS: Record<string, SortDirection> = {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
AuthorCardComponent,
|
AuthorCardComponent,
|
||||||
VirtualScrollerModule
|
CdkVirtualScrollViewport,
|
||||||
|
CdkVirtualForOf,
|
||||||
|
CdkAutoSizeVirtualScroll,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AuthorBrowserComponent implements OnInit {
|
export class AuthorBrowserComponent implements OnInit {
|
||||||
@@ -91,10 +96,27 @@ export class AuthorBrowserComponent implements OnInit {
|
|||||||
protected authorScaleService = inject(AuthorScalePreferenceService);
|
protected authorScaleService = inject(AuthorScalePreferenceService);
|
||||||
protected selectionService = inject(AuthorSelectionService);
|
protected selectionService = inject(AuthorSelectionService);
|
||||||
|
|
||||||
@ViewChild('scroll')
|
virtualScroller: CdkVirtualScrollViewport | undefined;
|
||||||
virtualScroller: VirtualScrollerComponent | undefined;
|
|
||||||
|
|
||||||
screenWidth = window.innerWidth;
|
@ViewChild('scroll')
|
||||||
|
set scrollViewport(vp: CdkVirtualScrollViewport | undefined) {
|
||||||
|
this.virtualScroller = vp;
|
||||||
|
this.viewportResizeObserver?.disconnect();
|
||||||
|
if (vp) {
|
||||||
|
const el = vp.elementRef.nativeElement as HTMLElement;
|
||||||
|
this.viewportWidth.set(el.clientWidth);
|
||||||
|
this.viewportResizeObserver = new ResizeObserver(entries => {
|
||||||
|
this.viewportWidth.set(entries[0]?.contentRect.width ?? el.clientWidth);
|
||||||
|
});
|
||||||
|
this.viewportResizeObserver.observe(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly GRID_GAP = 20;
|
||||||
|
private readonly viewportWidth = signal(0);
|
||||||
|
private viewportResizeObserver: ResizeObserver | undefined;
|
||||||
|
|
||||||
|
readonly screenWidth = signal(typeof window !== 'undefined' ? window.innerWidth : 1024);
|
||||||
thumbnailCacheBusters = new Map<number, number>();
|
thumbnailCacheBusters = new Map<number, number>();
|
||||||
private selectedAuthors = this.selectionService.selectedAuthors;
|
private selectedAuthors = this.selectionService.selectedAuthors;
|
||||||
private allAuthorsState = signal<AuthorSummary[] | null>(null);
|
private allAuthorsState = signal<AuthorSummary[] | null>(null);
|
||||||
@@ -178,30 +200,34 @@ export class AuthorBrowserComponent implements OnInit {
|
|||||||
|
|
||||||
@HostListener('window:resize')
|
@HostListener('window:resize')
|
||||||
onResize(): void {
|
onResize(): void {
|
||||||
this.screenWidth = window.innerWidth;
|
this.screenWidth.set(window.innerWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isMobile(): boolean {
|
readonly isMobile = computed(() => this.screenWidth() <= 767);
|
||||||
return this.screenWidth <= 767;
|
|
||||||
}
|
|
||||||
|
|
||||||
get cardWidth(): number {
|
readonly cardWidth = computed(() => {
|
||||||
const base = this.isMobile
|
const base = this.isMobile()
|
||||||
? AuthorBrowserComponent.MOBILE_BASE_WIDTH
|
? AuthorBrowserComponent.MOBILE_BASE_WIDTH
|
||||||
: AuthorBrowserComponent.BASE_WIDTH;
|
: AuthorBrowserComponent.BASE_WIDTH;
|
||||||
return Math.round(base * this.authorScaleService.scaleFactor());
|
return Math.round(base * this.authorScaleService.scaleFactor());
|
||||||
}
|
});
|
||||||
|
|
||||||
get cardHeight(): number {
|
readonly cardHeight = computed(() => {
|
||||||
const base = this.isMobile
|
const base = this.isMobile()
|
||||||
? AuthorBrowserComponent.MOBILE_BASE_HEIGHT
|
? AuthorBrowserComponent.MOBILE_BASE_HEIGHT
|
||||||
: AuthorBrowserComponent.BASE_HEIGHT;
|
: AuthorBrowserComponent.BASE_HEIGHT;
|
||||||
return Math.round(base * this.authorScaleService.scaleFactor());
|
return Math.round(base * this.authorScaleService.scaleFactor());
|
||||||
}
|
});
|
||||||
|
|
||||||
get gridColumnMinWidth(): string {
|
readonly gridColumnMinWidth = computed(() => `${this.cardWidth()}px`);
|
||||||
return `${this.cardWidth}px`;
|
|
||||||
}
|
readonly gridColumns = computed(() => {
|
||||||
|
return computeGridColumns(this.viewportWidth(), this.cardWidth() || 165, AuthorBrowserComponent.GRID_GAP);
|
||||||
|
});
|
||||||
|
|
||||||
|
readonly authorRows = computed(() => {
|
||||||
|
return chunk(this.filteredAuthors(), this.gridColumns());
|
||||||
|
});
|
||||||
|
|
||||||
sortOptions: SortOption[] = [];
|
sortOptions: SortOption[] = [];
|
||||||
|
|
||||||
@@ -212,6 +238,7 @@ export class AuthorBrowserComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.pageTitle.setPageTitle(this.t.translate('authorBrowser.pageTitle'));
|
this.pageTitle.setPageTitle(this.t.translate('authorBrowser.pageTitle'));
|
||||||
|
this.destroyRef.onDestroy(() => this.viewportResizeObserver?.disconnect());
|
||||||
|
|
||||||
this.sortOptions = [
|
this.sortOptions = [
|
||||||
{label: this.t.translate('authorBrowser.sort.name'), value: 'name'},
|
{label: this.t.translate('authorBrowser.sort.name'), value: 'name'},
|
||||||
@@ -236,6 +263,8 @@ export class AuthorBrowserComponent implements OnInit {
|
|||||||
this.destroyRef.onDestroy(() => this.selectionService.deselectAll());
|
this.destroyRef.onDestroy(() => this.selectionService.deselectAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onSearchChange(value: string): void {
|
onSearchChange(value: string): void {
|
||||||
this.searchTerm.set(value);
|
this.searchTerm.set(value);
|
||||||
}
|
}
|
||||||
@@ -515,9 +544,9 @@ export class AuthorBrowserComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private saveScrollPosition(): void {
|
private saveScrollPosition(): void {
|
||||||
if (this.virtualScroller?.viewPortInfo) {
|
if (this.virtualScroller) {
|
||||||
const key = this.getScrollPositionKey();
|
const key = this.getScrollPositionKey();
|
||||||
const position = this.virtualScroller.viewPortInfo.scrollStartPosition ?? 0;
|
const position = this.virtualScroller.measureScrollOffset('top') ?? 0;
|
||||||
this.scrollService.savePosition(key, position);
|
this.scrollService.savePosition(key, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -1,3 +1,8 @@
|
|||||||
|
:host {
|
||||||
|
content-visibility: auto;
|
||||||
|
contain-intrinsic-size: auto 250px 300px;
|
||||||
|
}
|
||||||
|
|
||||||
.author-card {
|
.author-card {
|
||||||
background-color: var(--card-background);
|
background-color: var(--card-background);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import {ChangeDetectorRef, Component, EventEmitter, inject, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
|
import {ChangeDetectorRef, Component, EventEmitter, inject, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
|
||||||
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {CheckboxChangeEvent, CheckboxModule} from 'primeng/checkbox';
|
import {CheckboxChangeEvent, Checkbox} from 'primeng/checkbox';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TieredMenu} from 'primeng/tieredmenu';
|
import {TieredMenu} from 'primeng/tieredmenu';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
@@ -14,7 +14,7 @@ import {AuthorService} from '../../service/author.service';
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './author-card.component.html',
|
templateUrl: './author-card.component.html',
|
||||||
styleUrls: ['./author-card.component.scss'],
|
styleUrls: ['./author-card.component.scss'],
|
||||||
imports: [TranslocoPipe, Tooltip, CheckboxModule, FormsModule, TieredMenu, Button]
|
imports: [TranslocoPipe, Tooltip, Checkbox, FormsModule, TieredMenu, Button]
|
||||||
})
|
})
|
||||||
export class AuthorCardComponent implements OnChanges {
|
export class AuthorCardComponent implements OnChanges {
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -104,14 +104,14 @@
|
|||||||
<p>{{ t('noBooksFound') }}</p>
|
<p>{{ t('noBooksFound') }}</p>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<virtual-scroller #scroll [items]="books" [bufferAmount]="16" class="books-virtual-scroller">
|
<cdk-virtual-scroll-viewport autosize [minBufferPx]="600" [maxBufferPx]="1200" class="books-virtual-scroller">
|
||||||
<div class="books-grid" #container
|
<div *cdkVirtualFor="let row of bookRows(); let rowIdx = index" class="books-grid"
|
||||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
[ngStyle]="{'grid-template-columns': 'repeat(' + gridColumns() + ', 1fr)'}">
|
||||||
@for (book of scroll.viewPortItems; track book.id; let i = $index) {
|
@for (book of row; let j = $index; track book.id) {
|
||||||
<div class="virtual-scroller-item"
|
<div class="virtual-scroller-item"
|
||||||
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
||||||
<app-book-card
|
<app-book-card
|
||||||
[index]="books.indexOf(book)"
|
[index]="rowIdx * gridColumns() + j"
|
||||||
[book]="book"
|
[book]="book"
|
||||||
[isSeriesCollapsed]="false"
|
[isSeriesCollapsed]="false"
|
||||||
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</virtual-scroller>
|
</cdk-virtual-scroll-viewport>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -161,7 +161,6 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100dvh - 22rem);
|
height: calc(100dvh - 22rem);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow-y: auto;
|
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
scrollbar-color: var(--primary-color) rgb(20 20 30 / 50%);
|
scrollbar-color: var(--primary-color) rgb(20 20 30 / 50%);
|
||||||
|
|
||||||
|
|||||||
+40
-3
@@ -1,4 +1,5 @@
|
|||||||
import {AfterViewChecked, Component, computed, ElementRef, inject, OnInit, signal, ViewChild} from '@angular/core';
|
import {AfterViewChecked, Component, computed, DestroyRef, ElementRef, inject, OnInit, signal, ViewChild} from '@angular/core';
|
||||||
|
import {computeGridColumns} from '../../../../shared/util/viewport.util';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {NgClass, NgStyle} from '@angular/common';
|
import {NgClass, NgStyle} from '@angular/common';
|
||||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||||
@@ -6,7 +7,8 @@ import {ProgressSpinner} from 'primeng/progressspinner';
|
|||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {Tag} from 'primeng/tag';
|
import {Tag} from 'primeng/tag';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {VirtualScrollerModule} from '@iharbeck/ngx-virtual-scroller';
|
import {CdkVirtualScrollViewport, CdkVirtualForOf} from '@angular/cdk/scrolling';
|
||||||
|
import {CdkAutoSizeVirtualScroll} from '@angular/cdk-experimental/scrolling';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {AuthorService} from '../../service/author.service';
|
import {AuthorService} from '../../service/author.service';
|
||||||
@@ -19,6 +21,7 @@ import {UserService} from '../../../settings/user-management/user.service';
|
|||||||
import {AuthorMatchComponent} from '../author-match/author-match.component';
|
import {AuthorMatchComponent} from '../author-match/author-match.component';
|
||||||
import {AuthorEditorComponent} from '../author-editor/author-editor.component';
|
import {AuthorEditorComponent} from '../author-editor/author-editor.component';
|
||||||
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
||||||
|
import {chunk} from '../../../../shared/util/array.util';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-author-detail',
|
selector: 'app-author-detail',
|
||||||
@@ -38,7 +41,9 @@ import {PageTitleService} from '../../../../shared/service/page-title.service';
|
|||||||
Tag,
|
Tag,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
VirtualScrollerModule,
|
CdkVirtualScrollViewport,
|
||||||
|
CdkVirtualForOf,
|
||||||
|
CdkAutoSizeVirtualScroll,
|
||||||
BookCardComponent,
|
BookCardComponent,
|
||||||
AuthorMatchComponent,
|
AuthorMatchComponent,
|
||||||
AuthorEditorComponent
|
AuthorEditorComponent
|
||||||
@@ -46,6 +51,8 @@ import {PageTitleService} from '../../../../shared/service/page-title.service';
|
|||||||
})
|
})
|
||||||
export class AuthorDetailComponent implements OnInit, AfterViewChecked {
|
export class AuthorDetailComponent implements OnInit, AfterViewChecked {
|
||||||
|
|
||||||
|
private static readonly GRID_GAP = 21;
|
||||||
|
|
||||||
private route = inject(ActivatedRoute);
|
private route = inject(ActivatedRoute);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
private authorService = inject(AuthorService);
|
private authorService = inject(AuthorService);
|
||||||
@@ -56,8 +63,27 @@ export class AuthorDetailComponent implements OnInit, AfterViewChecked {
|
|||||||
protected userService = inject(UserService);
|
protected userService = inject(UserService);
|
||||||
private pageTitle = inject(PageTitleService);
|
private pageTitle = inject(PageTitleService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
@ViewChild('descriptionContent') descriptionContentRef?: ElementRef<HTMLElement>;
|
@ViewChild('descriptionContent') descriptionContentRef?: ElementRef<HTMLElement>;
|
||||||
|
virtualScroller?: CdkVirtualScrollViewport;
|
||||||
|
|
||||||
|
@ViewChild(CdkVirtualScrollViewport)
|
||||||
|
set scrollViewport(vp: CdkVirtualScrollViewport | undefined) {
|
||||||
|
this.virtualScroller = vp;
|
||||||
|
this.viewportResizeObserver?.disconnect();
|
||||||
|
if (vp) {
|
||||||
|
const el = vp.elementRef.nativeElement as HTMLElement;
|
||||||
|
this.viewportWidth.set(el.clientWidth);
|
||||||
|
this.viewportResizeObserver = new ResizeObserver(entries => {
|
||||||
|
this.viewportWidth.set(entries[0]?.contentRect.width ?? el.clientWidth);
|
||||||
|
});
|
||||||
|
this.viewportResizeObserver.observe(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly viewportWidth = signal(0);
|
||||||
|
private viewportResizeObserver: ResizeObserver | undefined;
|
||||||
|
|
||||||
loading = true;
|
loading = true;
|
||||||
tab = 'books';
|
tab = 'books';
|
||||||
@@ -87,6 +113,14 @@ export class AuthorDetailComponent implements OnInit, AfterViewChecked {
|
|||||||
return this.coverScalePreferenceService.gridColumnMinWidth();
|
return this.coverScalePreferenceService.gridColumnMinWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly gridColumns = computed(() => {
|
||||||
|
return computeGridColumns(this.viewportWidth(), parseInt(this.gridColumnMinWidth, 10) || 180, AuthorDetailComponent.GRID_GAP);
|
||||||
|
});
|
||||||
|
|
||||||
|
readonly bookRows = computed(() => {
|
||||||
|
return chunk(this.authorBooks(), this.gridColumns());
|
||||||
|
});
|
||||||
|
|
||||||
get photoUrl(): string {
|
get photoUrl(): string {
|
||||||
const author = this.author();
|
const author = this.author();
|
||||||
if (!author) return '';
|
if (!author) return '';
|
||||||
@@ -105,8 +139,11 @@ export class AuthorDetailComponent implements OnInit, AfterViewChecked {
|
|||||||
this.tab = tabParam;
|
this.tab = tabParam;
|
||||||
}
|
}
|
||||||
this.loadAuthor(authorId);
|
this.loadAuthor(authorId);
|
||||||
|
this.destroyRef.onDestroy(() => this.viewportResizeObserver?.disconnect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ngAfterViewChecked(): void {
|
ngAfterViewChecked(): void {
|
||||||
if (!this.isExpanded && this.descriptionContentRef) {
|
if (!this.isExpanded && this.descriptionContentRef) {
|
||||||
const el = this.descriptionContentRef.nativeElement;
|
const el = this.descriptionContentRef.nativeElement;
|
||||||
|
|||||||
+11
@@ -19,4 +19,15 @@ describe('BookBrowserScrollService', () => {
|
|||||||
service.clearPosition('books');
|
service.clearPosition('books');
|
||||||
expect(service.getPosition('books')).toBeUndefined();
|
expect(service.getPosition('books')).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('clearAll removes all stored positions', () => {
|
||||||
|
const fresh = new BookBrowserScrollService();
|
||||||
|
fresh.savePosition('a', 10);
|
||||||
|
fresh.savePosition('b', 20);
|
||||||
|
|
||||||
|
fresh.clearAll();
|
||||||
|
|
||||||
|
expect(fresh.getPosition('a')).toBeUndefined();
|
||||||
|
expect(fresh.getPosition('b')).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ export class BookBrowserScrollService {
|
|||||||
this.scrollPositions.delete(key);
|
this.scrollPositions.delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll(): void {
|
||||||
|
this.scrollPositions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
createKey(path: string, params: Record<string, string>): string {
|
createKey(path: string, params: Record<string, string>): string {
|
||||||
const paramValues = Object.values(params).join('-');
|
const paramValues = Object.values(params).join('-');
|
||||||
return paramValues ? `${path}:${paramValues}` : path;
|
return paramValues ? `${path}:${paramValues}` : path;
|
||||||
|
|||||||
+25
-28
@@ -318,35 +318,32 @@
|
|||||||
></app-book-table>
|
></app-book-table>
|
||||||
}
|
}
|
||||||
@if (currentViewMode === 'grid') {
|
@if (currentViewMode === 'grid') {
|
||||||
<virtual-scroller class="virtual-scroller" #scroll
|
<div class="virtual-scroller" #scrollContainer>
|
||||||
[items]="books"
|
<div class="scroll-height-anchor" [ngStyle]="{'min-height': estimatedTotalHeight() + 'px'}">
|
||||||
[bufferAmount]="16"
|
<div class="book-grid"
|
||||||
[compareItems]="compareBookItems"
|
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
||||||
(vsEnd)="onScrollEnd()">
|
@for (book of books; track book.id; let i = $index) {
|
||||||
<div
|
<div
|
||||||
class="grid"
|
class="virtual-scroller-item"
|
||||||
#container
|
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
||||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
<app-book-card
|
||||||
@for (book of scroll.viewPortItems; let i = $index; track book.id) {
|
[index]="i"
|
||||||
<div
|
[book]="book"
|
||||||
class="virtual-scroller-item"
|
[isCheckboxEnabled]="true"
|
||||||
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
[seriesViewEnabled]="seriesViewEnabled"
|
||||||
<app-book-card
|
[onBookSelect]="onBookCardSelect"
|
||||||
[index]="bookIndexById().get(book.id) ?? i"
|
[isSeriesCollapsed]="seriesCollapseFilter.seriesCollapsed()"
|
||||||
[book]="book"
|
(checkboxClick)="onCheckboxClicked($event)"
|
||||||
[isCheckboxEnabled]="true"
|
[isSelected]="selectedBooks().has(book.id)"
|
||||||
[seriesViewEnabled]="seriesViewEnabled"
|
[useSquareCovers]="isAudiobookOnlyLibrary"
|
||||||
[onBookSelect]="onBookCardSelect"
|
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
||||||
[isSeriesCollapsed]="seriesCollapseFilter.seriesCollapsed()"
|
</app-book-card>
|
||||||
(checkboxClick)="onCheckboxClicked($event)"
|
</div>
|
||||||
[isSelected]="selectedBooks().has(book.id)"
|
}
|
||||||
[useSquareCovers]="isAudiobookOnlyLibrary"
|
</div>
|
||||||
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
<div class="scroll-sentinel" #scrollSentinel></div>
|
||||||
</app-book-card>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</virtual-scroller>
|
</div>
|
||||||
}
|
}
|
||||||
@if (userService.currentUser(); as currentUser) {
|
@if (userService.currentUser(); as currentUser) {
|
||||||
<div class="book-browser-footer" [class.footer-hidden]="selectedCount() === 0">
|
<div class="book-browser-footer" [class.footer-hidden]="selectedCount() === 0">
|
||||||
|
|||||||
@@ -440,32 +440,31 @@
|
|||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
will-change: scroll-position;
|
|
||||||
overflow-anchor: none;
|
|
||||||
|
|
||||||
@media (width <= 768px) {
|
@media (width <= 768px) {
|
||||||
height: calc(100dvh - 9rem);
|
height: calc(100dvh - 9rem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid {
|
.book-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(1px, 1fr));
|
gap: 21px;
|
||||||
column-gap: 21px;
|
|
||||||
align-items: start;
|
align-items: start;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
contain: layout style;
|
|
||||||
|
|
||||||
// Mobile: fixed 2 or 3 columns based on phone width
|
|
||||||
@media (width <= 767px) {
|
@media (width <= 767px) {
|
||||||
column-gap: 8px;
|
gap: 0.5rem 8px;
|
||||||
padding: 0 0.5rem;
|
padding: 0 0.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.scroll-sentinel {
|
||||||
|
height: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
.virtual-scroller-item {
|
.virtual-scroller-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-bottom: 21px; // Whole px to avoid parseInt truncation in ngx-virtual-scroller
|
margin-bottom: 21px;
|
||||||
contain: strict;
|
contain: strict;
|
||||||
content-visibility: auto;
|
content-visibility: auto;
|
||||||
contain-intrinsic-size: auto var(--virtual-scroller-item-height, 220px);
|
contain-intrinsic-size: auto var(--virtual-scroller-item-height, 220px);
|
||||||
|
|||||||
+48
-2
@@ -1,4 +1,4 @@
|
|||||||
import {computed, signal, WritableSignal} from '@angular/core';
|
import {computed, ElementRef, signal, WritableSignal} from '@angular/core';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {ActivatedRoute, convertToParamMap, ParamMap, Router} from '@angular/router';
|
import {ActivatedRoute, convertToParamMap, ParamMap, Router} from '@angular/router';
|
||||||
import {BehaviorSubject, Subject} from 'rxjs';
|
import {BehaviorSubject, Subject} from 'rxjs';
|
||||||
@@ -247,6 +247,7 @@ function createHarness(options?: {
|
|||||||
const _filters = signal<AppBookFilters>({});
|
const _filters = signal<AppBookFilters>({});
|
||||||
const _sort = signal<AppBookSort>({field: 'addedOn', dir: 'desc'});
|
const _sort = signal<AppBookSort>({field: 'addedOn', dir: 'desc'});
|
||||||
const _search = signal('');
|
const _search = signal('');
|
||||||
|
const _hasNextPage = signal(false);
|
||||||
|
|
||||||
const filteredSortedBooks = computed(() => {
|
const filteredSortedBooks = computed(() => {
|
||||||
let result = books();
|
let result = books();
|
||||||
@@ -266,7 +267,8 @@ function createHarness(options?: {
|
|||||||
return {
|
return {
|
||||||
books: filteredSortedBooks,
|
books: filteredSortedBooks,
|
||||||
totalElements: computed(() => filteredSortedBooks().length),
|
totalElements: computed(() => filteredSortedBooks().length),
|
||||||
hasNextPage: computed(() => false),
|
hasNextPage: _hasNextPage.asReadonly(),
|
||||||
|
setHasNextPage: (v: boolean) => _hasNextPage.set(v),
|
||||||
isLoading: isBooksLoading.asReadonly(),
|
isLoading: isBooksLoading.asReadonly(),
|
||||||
isFetchingNextPage: computed(() => false),
|
isFetchingNextPage: computed(() => false),
|
||||||
isError: computed(() => !!booksError()),
|
isError: computed(() => !!booksError()),
|
||||||
@@ -354,9 +356,20 @@ function createHarness(options?: {
|
|||||||
describe('BookBrowserComponent', () => {
|
describe('BookBrowserComponent', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
|
vi.stubGlobal('ResizeObserver', class {
|
||||||
|
observe = vi.fn();
|
||||||
|
unobserve = vi.fn();
|
||||||
|
disconnect = vi.fn();
|
||||||
|
});
|
||||||
|
vi.stubGlobal('IntersectionObserver', class {
|
||||||
|
observe = vi.fn();
|
||||||
|
unobserve = vi.fn();
|
||||||
|
disconnect = vi.fn();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
vi.unstubAllGlobals();
|
||||||
vi.runOnlyPendingTimers();
|
vi.runOnlyPendingTimers();
|
||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
TestBed.resetTestingModule();
|
TestBed.resetTestingModule();
|
||||||
@@ -423,4 +436,37 @@ describe('BookBrowserComponent', () => {
|
|||||||
expect(component.showGridLoadingPlaceholder).toBe(false);
|
expect(component.showGridLoadingPlaceholder).toBe(false);
|
||||||
expect(component.showTableLoadingPlaceholder).toBe(false);
|
expect(component.showTableLoadingPlaceholder).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('triggers next page fetch when scrolled near the bottom of rendered content', async () => {
|
||||||
|
const {component} = createHarness();
|
||||||
|
const appBooksApi = TestBed.inject(AppBooksApiService);
|
||||||
|
|
||||||
|
// Initial load
|
||||||
|
vi.runOnlyPendingTimers();
|
||||||
|
TestBed.flushEffects();
|
||||||
|
|
||||||
|
// Mock hasNextPage to be true
|
||||||
|
// @ts-expect-error test helper
|
||||||
|
appBooksApi.setHasNextPage(true);
|
||||||
|
const fetchNextPageSpy = vi.spyOn(appBooksApi, 'fetchNextPage');
|
||||||
|
|
||||||
|
// Mock scroll container
|
||||||
|
const mockElement = {
|
||||||
|
scrollTop: 2000,
|
||||||
|
clientHeight: 1000,
|
||||||
|
clientWidth: 1000,
|
||||||
|
scrollHeight: 5000,
|
||||||
|
addEventListener: vi.fn(),
|
||||||
|
removeEventListener: vi.fn(),
|
||||||
|
} as unknown as HTMLElement;
|
||||||
|
|
||||||
|
component.currentViewMode = VIEW_MODES.GRID;
|
||||||
|
component.scrollContainerRef = {nativeElement: mockElement} as ElementRef<HTMLElement>;
|
||||||
|
|
||||||
|
// Trigger initial check
|
||||||
|
vi.runOnlyPendingTimers(); // For requestAnimationFrame
|
||||||
|
TestBed.flushEffects();
|
||||||
|
|
||||||
|
expect(fetchNextPageSpy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import {AfterViewInit, ChangeDetectionStrategy, Component, HostListener, computed, effect, inject, OnDestroy, OnInit, signal, untracked, ViewChild} from '@angular/core';
|
import {AfterViewInit, ChangeDetectionStrategy, Component, DestroyRef, ElementRef, HostListener, OnDestroy, computed, effect, inject, OnInit, signal, untracked, ViewChild} from '@angular/core';
|
||||||
import {toObservable, toSignal} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed, toObservable, toSignal} from '@angular/core/rxjs-interop';
|
||||||
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
||||||
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
||||||
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
||||||
import {BookService} from '../../service/book.service';
|
import {BookService} from '../../service/book.service';
|
||||||
import {BookMetadataManageService} from '../../service/book-metadata-manage.service';
|
import {BookMetadataManageService} from '../../service/book-metadata-manage.service';
|
||||||
import {debounceTime, distinctUntilChanged, filter, map, takeUntil} from 'rxjs/operators';
|
import {debounceTime, distinctUntilChanged, filter, map, take} from 'rxjs/operators';
|
||||||
import {combineLatest, finalize, Subject} from 'rxjs';
|
import {combineLatest, finalize, Subject} from 'rxjs';
|
||||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
import {Library} from '../../model/library.model';
|
import {Library} from '../../model/library.model';
|
||||||
@@ -13,10 +13,9 @@ import {SortDirection, SortOption} from '../../model/sort.model';
|
|||||||
import {Book} from '../../model/book.model';
|
import {Book} from '../../model/book.model';
|
||||||
import {LibraryShelfMenuService} from '../../service/library-shelf-menu.service';
|
import {LibraryShelfMenuService} from '../../service/library-shelf-menu.service';
|
||||||
import {BookTableComponent} from './book-table/book-table.component';
|
import {BookTableComponent} from './book-table/book-table.component';
|
||||||
import {animate, style, transition, trigger} from '@angular/animations';
|
import {computeGridColumns} from '../../../../shared/util/viewport.util';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {NgClass, NgStyle} from '@angular/common';
|
import {NgClass, NgStyle} from '@angular/common';
|
||||||
import {VirtualScrollerComponent, VirtualScrollerModule} from '@iharbeck/ngx-virtual-scroller';
|
|
||||||
import {BookCardComponent} from './book-card/book-card.component';
|
import {BookCardComponent} from './book-card/book-card.component';
|
||||||
|
|
||||||
import {Menu} from 'primeng/menu';
|
import {Menu} from 'primeng/menu';
|
||||||
@@ -36,7 +35,7 @@ import {Divider} from 'primeng/divider';
|
|||||||
import {MultiSelect} from 'primeng/multiselect';
|
import {MultiSelect} from 'primeng/multiselect';
|
||||||
import {TableColumnPreferenceService} from './table-column-preference.service';
|
import {TableColumnPreferenceService} from './table-column-preference.service';
|
||||||
import {TieredMenu} from 'primeng/tieredmenu';
|
import {TieredMenu} from 'primeng/tieredmenu';
|
||||||
import {BadgeModule} from 'primeng/badge';
|
import {Badge} from 'primeng/badge';
|
||||||
import {BookMenuService} from '../../service/book-menu.service';
|
import {BookMenuService} from '../../service/book-menu.service';
|
||||||
import {SidebarFilterTogglePrefService} from './filters/sidebar-filter-toggle-pref.service';
|
import {SidebarFilterTogglePrefService} from './filters/sidebar-filter-toggle-pref.service';
|
||||||
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
||||||
@@ -74,23 +73,11 @@ export enum EntityType {
|
|||||||
styleUrls: ['./book-browser.component.scss'],
|
styleUrls: ['./book-browser.component.scss'],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
imports: [
|
imports: [
|
||||||
Button, VirtualScrollerModule, BookCardComponent, Menu, InputText, FormsModule,
|
Button, BookCardComponent, Menu, InputText, FormsModule,
|
||||||
BookTableComponent, BookFilterComponent, Tooltip, NgClass, NgStyle, Popover,
|
BookTableComponent, BookFilterComponent, Tooltip, NgClass, NgStyle, Popover,
|
||||||
Checkbox, Slider, Divider, MultiSelect, TieredMenu, BadgeModule, MultiSortPopoverComponent, TranslocoDirective
|
Checkbox, Slider, Divider, MultiSelect, TieredMenu, Badge, MultiSortPopoverComponent, TranslocoDirective,
|
||||||
],
|
],
|
||||||
providers: [SeriesCollapseFilter],
|
providers: [SeriesCollapseFilter],
|
||||||
animations: [
|
|
||||||
trigger('slideInOut', [
|
|
||||||
transition(':enter', [
|
|
||||||
style({transform: 'translateY(100%)'}),
|
|
||||||
animate('0.1s ease-in', style({transform: 'translateY(0)'}))
|
|
||||||
]),
|
|
||||||
transition(':leave', [
|
|
||||||
style({transform: 'translateY(0)'}),
|
|
||||||
animate('0.1s ease-out', style({transform: 'translateY(100%)'}))
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
@@ -123,6 +110,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
private localStorageService = inject(LocalStorageService);
|
private localStorageService = inject(LocalStorageService);
|
||||||
private scrollService = inject(BookBrowserScrollService);
|
private scrollService = inject(BookBrowserScrollService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
private readonly defaultSortCriteria: SortOption[] = [{
|
private readonly defaultSortCriteria: SortOption[] = [{
|
||||||
field: 'addedOn',
|
field: 'addedOn',
|
||||||
@@ -294,6 +282,41 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
readonly compareBookItems = (a: Book, b: Book): boolean => a?.id === b?.id;
|
readonly compareBookItems = (a: Book, b: Book): boolean => a?.id === b?.id;
|
||||||
|
|
||||||
|
private readonly GRID_GAP = 21;
|
||||||
|
private readonly containerWidth = signal(0);
|
||||||
|
private containerResizeObserver: ResizeObserver | undefined;
|
||||||
|
|
||||||
|
readonly gridColumns = computed(() => {
|
||||||
|
return computeGridColumns(this.containerWidth(), parseInt(this.gridColumnMinWidth, 10) || 180, this.GRID_GAP);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimated total content height based on totalElements from the first API page.
|
||||||
|
* Used as min-height so the scrollbar reflects the full collection from the start.
|
||||||
|
* Only grows, never shrinks — prevents scroll teleportation.
|
||||||
|
*/
|
||||||
|
readonly estimatedTotalHeight = computed(() => {
|
||||||
|
const total = this.appBooksApi.totalElements();
|
||||||
|
if (total === 0) return 0;
|
||||||
|
const cols = this.gridColumns();
|
||||||
|
const rows = Math.ceil(total / cols);
|
||||||
|
const rowHeight = this.currentCardSize.height + this.GRID_GAP;
|
||||||
|
return rows * rowHeight;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total height of currently loaded books in grid view.
|
||||||
|
*/
|
||||||
|
readonly renderedHeight = computed(() => {
|
||||||
|
const books = this.books();
|
||||||
|
if (!books || books.length === 0) return 0;
|
||||||
|
const cols = this.gridColumns();
|
||||||
|
const rows = Math.ceil(books.length / cols);
|
||||||
|
const rowHeight = this.currentCardSize.height + this.GRID_GAP;
|
||||||
|
return rows * rowHeight;
|
||||||
|
});
|
||||||
|
|
||||||
protected resetFilterSubject = new Subject<void>();
|
protected resetFilterSubject = new Subject<void>();
|
||||||
|
|
||||||
readonly skeletonSlots = Array.from({length: 24}, (_, index) => index);
|
readonly skeletonSlots = Array.from({length: 24}, (_, index) => index);
|
||||||
@@ -321,7 +344,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
private readonly MOBILE_COLUMNS_STORAGE_KEY = 'mobileColumnsPreference';
|
private readonly MOBILE_COLUMNS_STORAGE_KEY = 'mobileColumnsPreference';
|
||||||
|
|
||||||
private settingFiltersFromUrl = false;
|
private settingFiltersFromUrl = false;
|
||||||
private destroy$ = new Subject<void>();
|
|
||||||
protected metadataMenuItems: MenuItem[] | undefined;
|
protected metadataMenuItems: MenuItem[] | undefined;
|
||||||
protected moreActionsMenuItems: MenuItem[] | undefined;
|
protected moreActionsMenuItems: MenuItem[] | undefined;
|
||||||
protected readonly onBookCardSelect = (book: Book, selected: boolean): void => {
|
protected readonly onBookCardSelect = (book: Book, selected: boolean): void => {
|
||||||
@@ -389,12 +411,61 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers sequential page loads if the current scroll position is beyond the loaded content.
|
||||||
|
* This is critical for scroll restoration on page reload.
|
||||||
|
*/
|
||||||
|
private readonly fillScrollGapEffect = effect(() => {
|
||||||
|
const books = this.books();
|
||||||
|
if (books && books.length > 0) {
|
||||||
|
this.checkAndFetchIfNeeded();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@ViewChild(BookTableComponent)
|
@ViewChild(BookTableComponent)
|
||||||
bookTableComponent!: BookTableComponent;
|
bookTableComponent!: BookTableComponent;
|
||||||
@ViewChild(BookFilterComponent, {static: false})
|
@ViewChild(BookFilterComponent, {static: false})
|
||||||
bookFilterComponent!: BookFilterComponent;
|
bookFilterComponent!: BookFilterComponent;
|
||||||
@ViewChild('scroll')
|
|
||||||
virtualScroller: VirtualScrollerComponent | undefined;
|
private scrollContainer: HTMLElement | undefined;
|
||||||
|
private sentinelObserver: IntersectionObserver | undefined;
|
||||||
|
|
||||||
|
@ViewChild('scrollContainer')
|
||||||
|
set scrollContainerRef(ref: ElementRef<HTMLElement> | undefined) {
|
||||||
|
this.containerResizeObserver?.disconnect();
|
||||||
|
if (this.scrollContainer) {
|
||||||
|
this.scrollContainer.removeEventListener('scroll', this.onScroll);
|
||||||
|
}
|
||||||
|
this.scrollContainer = ref?.nativeElement;
|
||||||
|
if (this.scrollContainer) {
|
||||||
|
const el = this.scrollContainer;
|
||||||
|
this.containerWidth.set(el.clientWidth);
|
||||||
|
this.containerResizeObserver = new ResizeObserver(entries => {
|
||||||
|
this.containerWidth.set(entries[0]?.contentRect.width ?? el.clientWidth);
|
||||||
|
});
|
||||||
|
this.containerResizeObserver.observe(el);
|
||||||
|
el.addEventListener('scroll', this.onScroll, {passive: true});
|
||||||
|
// Initial check in case we are already scrolled down
|
||||||
|
globalThis.requestAnimationFrame(() => this.checkAndFetchIfNeeded());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewChild('scrollSentinel')
|
||||||
|
set scrollSentinelRef(ref: ElementRef<HTMLElement> | undefined) {
|
||||||
|
this.sentinelObserver?.disconnect();
|
||||||
|
const el = ref?.nativeElement;
|
||||||
|
if (el) {
|
||||||
|
this.sentinelObserver = new IntersectionObserver(
|
||||||
|
entries => {
|
||||||
|
if (entries[0]?.isIntersecting) {
|
||||||
|
this.checkAndFetchNextPage();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{root: this.scrollContainer, rootMargin: '600px'}
|
||||||
|
);
|
||||||
|
this.sentinelObserver.observe(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@HostListener('window:resize')
|
@HostListener('window:resize')
|
||||||
onResize(): void {
|
onResize(): void {
|
||||||
@@ -533,8 +604,37 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.destroy$.next();
|
if (this.scrollContainer) {
|
||||||
this.destroy$.complete();
|
this.scrollContainer.removeEventListener('scroll', this.onScroll);
|
||||||
|
}
|
||||||
|
this.containerResizeObserver?.disconnect();
|
||||||
|
this.sentinelObserver?.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private onScroll = (): void => {
|
||||||
|
this.checkAndFetchIfNeeded();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the current scroll position plus viewport exceeds the rendered height (with a buffer)
|
||||||
|
* and fetches the next page if necessary.
|
||||||
|
*/
|
||||||
|
private checkAndFetchIfNeeded(): void {
|
||||||
|
if (!this.scrollContainer || this.currentViewMode === VIEW_MODES.TABLE) return;
|
||||||
|
|
||||||
|
const {scrollTop, clientHeight} = this.scrollContainer;
|
||||||
|
const buffer = 1000; // Large buffer to facilitate scroll restoration
|
||||||
|
const renderedHeight = untracked(() => this.renderedHeight());
|
||||||
|
|
||||||
|
if (scrollTop + clientHeight >= renderedHeight - buffer) {
|
||||||
|
untracked(() => this.checkAndFetchNextPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private checkAndFetchNextPage(): void {
|
||||||
|
if (this.appBooksApi.hasNextPage() && !this.appBooksApi.isFetchingNextPage()) {
|
||||||
|
this.appBooksApi.fetchNextPage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getScrollPositionKey(): string {
|
private getScrollPositionKey(): string {
|
||||||
@@ -545,29 +645,38 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
private setupScrollPositionTracking(): void {
|
private setupScrollPositionTracking(): void {
|
||||||
this.router.events.pipe(
|
this.router.events.pipe(
|
||||||
filter(event => event instanceof NavigationStart),
|
filter(event => event instanceof NavigationStart),
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
).subscribe(() => {
|
).subscribe(() => {
|
||||||
this.saveScrollPosition();
|
this.saveScrollPosition();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private saveScrollPosition(): void {
|
private saveScrollPosition(): void {
|
||||||
if (this.virtualScroller?.viewPortInfo) {
|
if (this.scrollContainer) {
|
||||||
const key = this.getScrollPositionKey();
|
const key = this.getScrollPositionKey();
|
||||||
const position = this.virtualScroller.viewPortInfo.scrollStartPosition ?? 0;
|
this.scrollService.savePosition(key, this.scrollContainer.scrollTop);
|
||||||
this.scrollService.savePosition(key, position);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupRouteChangeHandlers(): void {
|
private setupRouteChangeHandlers(): void {
|
||||||
this.activatedRoute.paramMap.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
this.activatedRoute.paramMap.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||||
this.searchTerm.set('');
|
this.searchTerm.set('');
|
||||||
this.bookTitle = '';
|
this.bookTitle = '';
|
||||||
this.bookSelectionService.deselectAll();
|
this.bookSelectionService.deselectAll();
|
||||||
this.clearFilter();
|
this.clearFilter();
|
||||||
|
this.scrollToTop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private scrollToTop(): void {
|
||||||
|
if (this.scrollContainer) {
|
||||||
|
this.scrollContainer.scrollTop = 0;
|
||||||
|
}
|
||||||
|
if (this.bookTableComponent) {
|
||||||
|
this.bookTableComponent.scrollToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly syncMetadataMenuEffect = effect(() => {
|
private readonly syncMetadataMenuEffect = effect(() => {
|
||||||
const user = this.userService.currentUser();
|
const user = this.userService.currentUser();
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
@@ -589,7 +698,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.activatedRoute.queryParamMap,
|
this.activatedRoute.queryParamMap,
|
||||||
this.currentUser$,
|
this.currentUser$,
|
||||||
]).pipe(
|
]).pipe(
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
).subscribe(([entityInfo, queryParamMap, currentUser]) => {
|
).subscribe(([entityInfo, queryParamMap, currentUser]) => {
|
||||||
const parseResult = this.queryParamsService.parseQueryParams(
|
const parseResult = this.queryParamsService.parseQueryParams(
|
||||||
queryParamMap,
|
queryParamMap,
|
||||||
@@ -934,8 +1043,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
openShelfAssigner(): void {
|
openShelfAssigner(): void {
|
||||||
this.dynamicDialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks());
|
this.dynamicDialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks());
|
||||||
if (this.dynamicDialogRef) {
|
if (this.dynamicDialogRef) {
|
||||||
this.dynamicDialogRef.onClose.subscribe(result => {
|
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(result => {
|
||||||
if (result.assigned) {
|
if (result?.assigned) {
|
||||||
this.bookSelectionService.deselectAll();
|
this.bookSelectionService.deselectAll();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -945,7 +1054,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
lockUnlockMetadata(): void {
|
lockUnlockMetadata(): void {
|
||||||
this.dynamicDialogRef = this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks());
|
this.dynamicDialogRef = this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks());
|
||||||
if (this.dynamicDialogRef) {
|
if (this.dynamicDialogRef) {
|
||||||
this.dynamicDialogRef.onClose.subscribe(() => {
|
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.bookSelectionService.deselectAll();
|
this.bookSelectionService.deselectAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -967,7 +1076,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
bulkEditMetadata(): void {
|
bulkEditMetadata(): void {
|
||||||
this.dynamicDialogRef = this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks());
|
this.dynamicDialogRef = this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks());
|
||||||
if (this.dynamicDialogRef) {
|
if (this.dynamicDialogRef) {
|
||||||
this.dynamicDialogRef.onClose.subscribe(() => {
|
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.bookSelectionService.deselectAll();
|
this.bookSelectionService.deselectAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -976,7 +1085,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
multiBookEditMetadata(): void {
|
multiBookEditMetadata(): void {
|
||||||
this.dynamicDialogRef = this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks());
|
this.dynamicDialogRef = this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks());
|
||||||
if (this.dynamicDialogRef) {
|
if (this.dynamicDialogRef) {
|
||||||
this.dynamicDialogRef.onClose.subscribe(() => {
|
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.bookSelectionService.deselectAll();
|
this.bookSelectionService.deselectAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1096,7 +1205,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
this.dynamicDialogRef = this.dialogHelperService.openBulkBookFileAttacherDialog(sourceBooks);
|
this.dynamicDialogRef = this.dialogHelperService.openBulkBookFileAttacherDialog(sourceBooks);
|
||||||
if (this.dynamicDialogRef) {
|
if (this.dynamicDialogRef) {
|
||||||
this.dynamicDialogRef.onClose.subscribe(result => {
|
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(result => {
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
this.bookSelectionService.deselectAll();
|
this.bookSelectionService.deselectAll();
|
||||||
}
|
}
|
||||||
@@ -1129,10 +1238,4 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.mobileColumnCount = saved;
|
this.mobileColumnCount = saved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onScrollEnd(): void {
|
|
||||||
if (this.appBooksApi.hasNextPage() && !this.appBooksApi.isFetchingNextPage()) {
|
|
||||||
this.appBooksApi.fetchNextPage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+59
-64
@@ -1,126 +1,121 @@
|
|||||||
<div class="book-card"
|
<div class="book-card"
|
||||||
[class.selected]="isSelected"
|
[class.selected]="isSelected()"
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
(click)="onCardClick($event)"
|
(click)="onCardClick($event)"
|
||||||
(keydown.enter)="onCardClick($event)">
|
(keydown.enter)="onCardClick($event)">
|
||||||
|
|
||||||
<div class="cover-container" [ngClass]="{ 'center-info-btn': _isSeriesViewActive || !hasDigitalFile(), 'audiobook-cover': _isAudiobook, 'square-library-cover': useSquareCovers }">
|
<div class="cover-container" [ngClass]="{ 'center-info-btn': isSeriesViewActive() || !hasDigitalFile(), 'audiobook-cover': isAudiobook(), 'square-library-cover': useSquareCovers() }">
|
||||||
@if (coverImageUrl) {
|
@if (coverImageUrl(); as url) {
|
||||||
<img
|
<img
|
||||||
[src]="coverImageUrl"
|
[src]="url"
|
||||||
class="book-cover"
|
class="book-cover"
|
||||||
[class.square-cover]="_isAudiobook || useSquareCovers"
|
[class.square-cover]="isAudiobook() || useSquareCovers()"
|
||||||
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle })"
|
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle() })"
|
||||||
width="250"
|
width="250"
|
||||||
[height]="(_isAudiobook || useSquareCovers) ? 250 : 350"
|
[height]="(isAudiobook() || useSquareCovers()) ? 250 : 350"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
fetchpriority="low"/>
|
fetchpriority="low"/>
|
||||||
} @else {
|
} @else {
|
||||||
<app-cover-placeholder class="book-cover" [class.square-cover]="_isAudiobook || useSquareCovers" [title]="book.metadata?.title ?? ''" [author]="(book.metadata?.authors ?? []).join(', ')" />
|
<app-cover-placeholder class="book-cover" [class.square-cover]="isAudiobook() || useSquareCovers()" [title]="book().metadata?.title ?? ''" [author]="(book().metadata?.authors ?? []).join(', ')" />
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="top-left-overlay-stack">
|
<div class="top-left-overlay-stack">
|
||||||
@if ((overlayPreferenceService?.showBookTypePill() ?? true) && getDisplayFormat(); as displayFormat) {
|
@if (showBookTypePill() && displayFormat(); as fmt) {
|
||||||
<div class="book-type-pill-overlay" [ngClass]="'book-type-' + displayFormat.toLowerCase()">
|
<div class="book-type-pill-overlay" [ngClass]="'book-type-' + fmt.toLowerCase()">
|
||||||
{{ displayFormat }}
|
{{ fmt }}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (!book.seriesCount && book.metadata?.seriesNumber !== null && book.metadata?.seriesNumber !== undefined) {
|
@if (!book().seriesCount && book().metadata?.seriesNumber !== null && book().metadata?.seriesNumber !== undefined) {
|
||||||
<div class="series-number-overlay">
|
<div class="series-number-overlay">
|
||||||
#{{ book.metadata?.seriesNumber }}
|
#{{ book().metadata?.seriesNumber }}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (book.seriesCount && book.seriesCount >= 1) {
|
@if (book().seriesCount && book().seriesCount! >= 1) {
|
||||||
<div class="series-items-count-overlay">
|
<div class="series-items-count-overlay">
|
||||||
<i class="pi pi-book series-items-count-icon"></i>{{ book.seriesCount }}
|
<i class="pi pi-book series-items-count-icon"></i>{{ book().seriesCount }}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (_isSeriesViewActive) {
|
@if (isSeriesViewActive()) {
|
||||||
<p-button [rounded]="true" icon="pi pi-info" class="info-btn" (click)="openSeriesInfo()" [ariaLabel]="'book.card.alt.viewSeriesInfo' | transloco"></p-button>
|
<button type="button" class="p-button p-component p-button-rounded info-btn" (click)="openSeriesInfo()" [attr.aria-label]="'book.card.alt.viewSeriesInfo' | transloco">
|
||||||
|
<i class="pi pi-info"></i>
|
||||||
|
</button>
|
||||||
} @else {
|
} @else {
|
||||||
<p-button [rounded]="true" icon="pi pi-info" class="info-btn" (click)="openBookInfo(book)" [ariaLabel]="'book.card.alt.viewDetails' | transloco">
|
<button type="button" class="p-button p-component p-button-rounded info-btn" (click)="openBookInfo(book())" [attr.aria-label]="'book.card.alt.viewDetails' | transloco">
|
||||||
</p-button>
|
<i class="pi pi-info"></i>
|
||||||
|
</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!_isSeriesViewActive && hasDigitalFile()) {
|
@if (!isSeriesViewActive() && hasDigitalFile()) {
|
||||||
<a [routerLink]="urlHelper.getBookPrimaryReadingUrl(book)" (click)="readBook(book)"><p-button [rounded]="true" [icon]="readButtonIcon" class="read-btn" (click)="readBook(book)"
|
<a [routerLink]="readingUrl()" (click)="readBook(book())"
|
||||||
[pTooltip]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : ''"
|
class="p-button p-component p-button-rounded read-btn"
|
||||||
tooltipPosition="bottom"
|
[pTooltip]="isContinueReading() ? ('book.card.alt.continueReading' | transloco) : ''"
|
||||||
[ariaLabel]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : (_isAudiobook ? ('book.card.alt.playAudiobook' | transloco) : ('book.card.alt.readBook' | transloco))"></p-button></a>
|
tooltipPosition="bottom"
|
||||||
|
[attr.aria-label]="isContinueReading() ? ('book.card.alt.continueReading' | transloco) : (isAudiobook() ? ('book.card.alt.playAudiobook' | transloco) : ('book.card.alt.readBook' | transloco))">
|
||||||
|
<i [class]="readButtonIcon()"></i>
|
||||||
|
</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (isCheckboxEnabled) {
|
@if (isCheckboxEnabled()) {
|
||||||
<p-checkbox
|
<p-checkbox
|
||||||
[binary]="true"
|
[binary]="true"
|
||||||
class="select-checkbox"
|
class="select-checkbox"
|
||||||
(click)="captureMouseEvent($event)"
|
(click)="captureMouseEvent($event)"
|
||||||
[ngModel]="isSelected"
|
[ngModel]="isSelected()"
|
||||||
(onChange)="toggleSelection($event)">
|
(onChange)="toggleSelection($event)">
|
||||||
</p-checkbox>
|
</p-checkbox>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (hasProgress) {
|
@if (hasProgress()) {
|
||||||
<div class="cover-progress-bar-container" [pTooltip]="progressTooltip" tooltipPosition="top">
|
<div class="cover-progress-bar-container" [pTooltip]="progressTooltip()" tooltipPosition="top">
|
||||||
@if (_progressPercentage !== null) {
|
@if (progressPercentage() !== null) {
|
||||||
<p-progressBar
|
<div class="cover-progress-bar" [ngClass]="{ 'progress-complete': progressPercentage() === 100, 'progress-incomplete': progressPercentage()! < 100 }">
|
||||||
[value]="_progressPercentage"
|
<div class="progress-fill" [style.width.%]="progressPercentage()!"></div>
|
||||||
[showValue]="false"
|
</div>
|
||||||
class="cover-progress-bar"
|
|
||||||
[ngClass]="{ 'progress-complete': _progressPercentage === 100, 'progress-incomplete': _progressPercentage < 100 }">
|
|
||||||
</p-progressBar>
|
|
||||||
}
|
}
|
||||||
@if (_koProgressPercentage !== null) {
|
@if (koProgressPercentage() !== null) {
|
||||||
<p-progressBar
|
<div class="cover-progress-bar" [ngClass]="koProgressPercentage() === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko'">
|
||||||
[value]="_koProgressPercentage"
|
<div class="progress-fill" [style.width.%]="koProgressPercentage()!"></div>
|
||||||
[showValue]="false"
|
</div>
|
||||||
class="cover-progress-bar"
|
|
||||||
[ngClass]="_koProgressPercentage === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko'">
|
|
||||||
</p-progressBar>
|
|
||||||
}
|
}
|
||||||
@if (_koboProgressPercentage !== null) {
|
@if (koboProgressPercentage() !== null) {
|
||||||
<p-progressBar
|
<div class="cover-progress-bar" [ngClass]="koboProgressPercentage() === 100 ? 'progress-complete-kobo' : 'progress-incomplete-kobo'">
|
||||||
[value]="_koboProgressPercentage"
|
<div class="progress-fill" [style.width.%]="koboProgressPercentage()!"></div>
|
||||||
[showValue]="false"
|
</div>
|
||||||
class="cover-progress-bar"
|
|
||||||
[ngClass]="_koboProgressPercentage === 100 ? 'progress-complete-kobo' : 'progress-incomplete-kobo'">
|
|
||||||
</p-progressBar>
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (!bottomBarHidden) {
|
@if (!bottomBarHidden()) {
|
||||||
<div class="book-title-container">
|
<div class="book-title-container">
|
||||||
<div class="read-status-indicator"
|
<div class="read-status-indicator"
|
||||||
[ngClass]="_readStatusClass"
|
[ngClass]="readStatusClass()"
|
||||||
[pTooltip]="readStatusTooltip"
|
[pTooltip]="readStatusTooltip()"
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="bottom"
|
||||||
(click)="toggleReadStatusMenu($event, readStatusMenu)"
|
(click)="toggleReadStatusMenu($event, readStatusMenu)"
|
||||||
(keydown.enter)="toggleReadStatusMenu($event, readStatusMenu)"
|
(keydown.enter)="toggleReadStatusMenu($event, readStatusMenu)"
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
[attr.aria-label]="'book.card.alt.readStatusMenu' | transloco">
|
[attr.aria-label]="'book.card.alt.readStatusMenu' | transloco">
|
||||||
<i [class]="_readStatusIcon" style="font-size: 0.9rem"></i>
|
<i [class]="readStatusIcon()" style="font-size: 0.9rem"></i>
|
||||||
</div>
|
</div>
|
||||||
<p-tieredmenu #readStatusMenu [model]="readStatusMenuItems" [popup]="true" appendTo="body"></p-tieredmenu>
|
<p-tieredmenu #readStatusMenu [model]="readStatusMenuItems()" [popup]="true" appendTo="body"></p-tieredmenu>
|
||||||
<h4 class="book-title"
|
<h4 class="book-title"
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="bottom"
|
||||||
[pTooltip]="titleTooltip">
|
[pTooltip]="titleTooltip()">
|
||||||
{{ displayTitle }}
|
{{ displayTitle() }}
|
||||||
</h4>
|
</h4>
|
||||||
<p-tieredmenu #menu [model]="items" [popup]="true" appendTo="body" (onShow)="onMenuShow()" (onHide)="onMenuHide()"></p-tieredmenu>
|
<p-tieredmenu #menu [model]="items()" [popup]="true" appendTo="body" (onShow)="onMenuShow()" (onHide)="onMenuHide()"></p-tieredmenu>
|
||||||
<p-button
|
<button type="button"
|
||||||
class="custom-button-padding"
|
class="p-button p-component p-button-text p-button-sm custom-button-padding"
|
||||||
size="small"
|
|
||||||
[text]="true"
|
|
||||||
(click)="onMenuToggle($event, menu)"
|
(click)="onMenuToggle($event, menu)"
|
||||||
icon="pi pi-ellipsis-v"
|
[attr.aria-label]="'book.card.alt.bookMenu' | transloco">
|
||||||
[ariaLabel]="'book.card.alt.bookMenu' | transloco">
|
<i class="pi pi-ellipsis-v"></i>
|
||||||
</p-button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+14
-38
@@ -100,7 +100,6 @@
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
transition: opacity 0.15s ease, visibility 0.15s ease;
|
transition: opacity 0.15s ease, visibility 0.15s ease;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
will-change: opacity, visibility;
|
|
||||||
|
|
||||||
::ng-deep .p-button {
|
::ng-deep .p-button {
|
||||||
box-shadow:
|
box-shadow:
|
||||||
@@ -155,7 +154,6 @@
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
transition: opacity 0.15s ease, visibility 0.15s ease;
|
transition: opacity 0.15s ease, visibility 0.15s ease;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
will-change: opacity, visibility;
|
|
||||||
|
|
||||||
@media (width <= 767px) {
|
@media (width <= 767px) {
|
||||||
top: 4px;
|
top: 4px;
|
||||||
@@ -191,6 +189,20 @@
|
|||||||
height: 2.5px;
|
height: 2.5px;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
|
background: rgb(0 0 0 / 30%);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.progress-fill {
|
||||||
|
height: 100%;
|
||||||
|
transition: width 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.progress-incomplete .progress-fill { background: var(--primary-color); }
|
||||||
|
&.progress-complete .progress-fill { background: #22c55e; }
|
||||||
|
&.progress-incomplete-ko .progress-fill { background: #f97316; }
|
||||||
|
&.progress-complete-ko .progress-fill { background: #f59e0b; }
|
||||||
|
&.progress-incomplete-kobo .progress-fill { background: #a855f7; }
|
||||||
|
&.progress-complete-kobo .progress-fill { background: #8b5cf6; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.series-number-overlay {
|
.series-number-overlay {
|
||||||
@@ -396,39 +408,3 @@
|
|||||||
.status-unset {
|
.status-unset {
|
||||||
color: var(--text-color-secondary);
|
color: var(--text-color-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep .progress-incomplete .p-progressbar-value {
|
|
||||||
background-color: #3b82f6;
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .progress-complete .p-progressbar-value {
|
|
||||||
background-color: #22c55e;
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .progress-incomplete-ko .p-progressbar-value {
|
|
||||||
background-color: #fbbf24;
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .progress-complete-ko .p-progressbar-value {
|
|
||||||
background-color: #8b5cf6;
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .progress-incomplete-kobo .p-progressbar-value {
|
|
||||||
background-color: #bf0000;
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .progress-complete-kobo .p-progressbar-value {
|
|
||||||
background-color: #f65c9c;
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .cover-progress-bar {
|
|
||||||
--p-progressbar-border-radius: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .custom-button-padding .p-button {
|
|
||||||
padding-block: 0.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
::ng-deep .book-details-dialog .p-dialog-header {
|
|
||||||
padding: 1rem 1.25rem !important;
|
|
||||||
}
|
|
||||||
|
|||||||
+103
-83
@@ -1,10 +1,9 @@
|
|||||||
import {NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges} from '@angular/core';
|
import {ComponentRef, NO_ERRORS_SCHEMA, signal, WritableSignal} from '@angular/core';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
import {Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {QueryClient} from '@tanstack/angular-query-experimental';
|
import {QueryClient} from '@tanstack/angular-query-experimental';
|
||||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||||
|
|
||||||
import {TranslocoService} from '@jsverse/transloco';
|
|
||||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||||
import {TaskHelperService} from '../../../../settings/task-management/task-helper.service';
|
import {TaskHelperService} from '../../../../settings/task-management/task-helper.service';
|
||||||
import {EmailService} from '../../../../settings/email-v2/email.service';
|
import {EmailService} from '../../../../settings/email-v2/email.service';
|
||||||
@@ -18,6 +17,7 @@ import {BookFileService} from '../../../service/book-file.service';
|
|||||||
import {BookMetadataManageService} from '../../../service/book-metadata-manage.service';
|
import {BookMetadataManageService} from '../../../service/book-metadata-manage.service';
|
||||||
import {BookNavigationService} from '../../../service/book-navigation.service';
|
import {BookNavigationService} from '../../../service/book-navigation.service';
|
||||||
import {BookService} from '../../../service/book.service';
|
import {BookService} from '../../../service/book.service';
|
||||||
|
import {getTranslocoModule} from '../../../../../core/testing/transloco-testing';
|
||||||
|
|
||||||
function makeBook(overrides: Partial<Book> = {}): Book {
|
function makeBook(overrides: Partial<Book> = {}): Book {
|
||||||
return {
|
return {
|
||||||
@@ -92,6 +92,8 @@ function makeUser(metadataCenterViewMode: 'route' | 'dialog'): User {
|
|||||||
|
|
||||||
describe('BookCardComponent', () => {
|
describe('BookCardComponent', () => {
|
||||||
let component: BookCardComponent;
|
let component: BookCardComponent;
|
||||||
|
let fixture: ComponentFixture<BookCardComponent>;
|
||||||
|
let ref: ComponentRef<BookCardComponent>;
|
||||||
let bookService: {
|
let bookService: {
|
||||||
readBook: ReturnType<typeof vi.fn>;
|
readBook: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
@@ -108,7 +110,8 @@ describe('BookCardComponent', () => {
|
|||||||
refreshMetadataTask: ReturnType<typeof vi.fn>;
|
refreshMetadataTask: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
let userService: {
|
let userService: {
|
||||||
currentUser: ReturnType<typeof vi.fn>;
|
currentUser: WritableSignal<User | null>;
|
||||||
|
getCurrentUser: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
let emailService: {
|
let emailService: {
|
||||||
emailBookQuick: ReturnType<typeof vi.fn>;
|
emailBookQuick: ReturnType<typeof vi.fn>;
|
||||||
@@ -122,6 +125,7 @@ describe('BookCardComponent', () => {
|
|||||||
let urlHelper: {
|
let urlHelper: {
|
||||||
getThumbnailUrl: ReturnType<typeof vi.fn>;
|
getThumbnailUrl: ReturnType<typeof vi.fn>;
|
||||||
getAudiobookThumbnailUrl: ReturnType<typeof vi.fn>;
|
getAudiobookThumbnailUrl: ReturnType<typeof vi.fn>;
|
||||||
|
getBookPrimaryReadingUrl: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
let confirmationService: {
|
let confirmationService: {
|
||||||
confirm: ReturnType<typeof vi.fn>;
|
confirm: ReturnType<typeof vi.fn>;
|
||||||
@@ -140,15 +144,9 @@ describe('BookCardComponent', () => {
|
|||||||
let appSettingsService: {
|
let appSettingsService: {
|
||||||
appSettings: ReturnType<typeof vi.fn>;
|
appSettings: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
let translocoService: {
|
|
||||||
translate: ReturnType<typeof vi.fn>;
|
|
||||||
};
|
|
||||||
let queryClient: {
|
let queryClient: {
|
||||||
fetchQuery: ReturnType<typeof vi.fn>;
|
fetchQuery: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
let cdr: {
|
|
||||||
markForCheck: ReturnType<typeof vi.fn>;
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
bookService = {
|
bookService = {
|
||||||
@@ -166,8 +164,10 @@ describe('BookCardComponent', () => {
|
|||||||
taskHelperService = {
|
taskHelperService = {
|
||||||
refreshMetadataTask: vi.fn(),
|
refreshMetadataTask: vi.fn(),
|
||||||
};
|
};
|
||||||
|
const currentUser = signal<User | null>(null);
|
||||||
userService = {
|
userService = {
|
||||||
currentUser: vi.fn(() => null),
|
currentUser,
|
||||||
|
getCurrentUser: vi.fn(() => currentUser()),
|
||||||
};
|
};
|
||||||
emailService = {
|
emailService = {
|
||||||
emailBookQuick: vi.fn(),
|
emailBookQuick: vi.fn(),
|
||||||
@@ -181,6 +181,7 @@ describe('BookCardComponent', () => {
|
|||||||
urlHelper = {
|
urlHelper = {
|
||||||
getThumbnailUrl: vi.fn((bookId: number, coverUpdatedOn?: string) => `thumb:${bookId}:${coverUpdatedOn ?? 'none'}`),
|
getThumbnailUrl: vi.fn((bookId: number, coverUpdatedOn?: string) => `thumb:${bookId}:${coverUpdatedOn ?? 'none'}`),
|
||||||
getAudiobookThumbnailUrl: vi.fn((bookId: number, audiobookCoverUpdatedOn?: string) => `audio-thumb:${bookId}:${audiobookCoverUpdatedOn ?? 'none'}`),
|
getAudiobookThumbnailUrl: vi.fn((bookId: number, audiobookCoverUpdatedOn?: string) => `audio-thumb:${bookId}:${audiobookCoverUpdatedOn ?? 'none'}`),
|
||||||
|
getBookPrimaryReadingUrl: vi.fn((book: Book) => `/read/${book.id}`),
|
||||||
};
|
};
|
||||||
confirmationService = {
|
confirmationService = {
|
||||||
confirm: vi.fn(),
|
confirm: vi.fn(),
|
||||||
@@ -199,20 +200,15 @@ describe('BookCardComponent', () => {
|
|||||||
appSettingsService = {
|
appSettingsService = {
|
||||||
appSettings: vi.fn(() => ({diskType: 'LOCAL'})),
|
appSettings: vi.fn(() => ({diskType: 'LOCAL'})),
|
||||||
};
|
};
|
||||||
translocoService = {
|
|
||||||
translate: vi.fn((key: string, params?: Record<string, unknown>) => (params ? `${key}:${JSON.stringify(params)}` : key)),
|
|
||||||
};
|
|
||||||
queryClient = {
|
queryClient = {
|
||||||
fetchQuery: vi.fn(),
|
fetchQuery: vi.fn(),
|
||||||
};
|
};
|
||||||
cdr = {
|
|
||||||
markForCheck: vi.fn(),
|
|
||||||
};
|
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [BookCardComponent],
|
imports: [BookCardComponent, getTranslocoModule()],
|
||||||
schemas: [NO_ERRORS_SCHEMA],
|
schemas: [NO_ERRORS_SCHEMA],
|
||||||
providers: [
|
providers: [
|
||||||
|
{provide: ActivatedRoute, useValue: {}},
|
||||||
{provide: BookService, useValue: bookService},
|
{provide: BookService, useValue: bookService},
|
||||||
{provide: BookFileService, useValue: bookFileService},
|
{provide: BookFileService, useValue: bookFileService},
|
||||||
{provide: BookMetadataManageService, useValue: bookMetadataManageService},
|
{provide: BookMetadataManageService, useValue: bookMetadataManageService},
|
||||||
@@ -226,16 +222,34 @@ describe('BookCardComponent', () => {
|
|||||||
{provide: BookDialogHelperService, useValue: bookDialogHelperService},
|
{provide: BookDialogHelperService, useValue: bookDialogHelperService},
|
||||||
{provide: BookNavigationService, useValue: bookNavigationService},
|
{provide: BookNavigationService, useValue: bookNavigationService},
|
||||||
{provide: AppSettingsService, useValue: appSettingsService},
|
{provide: AppSettingsService, useValue: appSettingsService},
|
||||||
{provide: TranslocoService, useValue: translocoService},
|
|
||||||
{provide: QueryClient, useValue: queryClient},
|
{provide: QueryClient, useValue: queryClient},
|
||||||
{provide: QueryClient, useValue: queryClient},
|
|
||||||
{provide: BookCardComponent, useValue: BookCardComponent},
|
|
||||||
{provide: 'ChangeDetectorRef', useValue: cdr},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
component = TestBed.createComponent(BookCardComponent).componentInstance;
|
// Secondary mock for matchMedia to ensure it's available in CI environment
|
||||||
(component as unknown as {cdr: typeof cdr}).cdr = cdr;
|
Object.defineProperty(window, 'matchMedia', {
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
value: vi.fn().mockImplementation(query => ({
|
||||||
|
matches: false,
|
||||||
|
media: query,
|
||||||
|
onchange: null,
|
||||||
|
addListener: vi.fn(),
|
||||||
|
removeListener: vi.fn(),
|
||||||
|
addEventListener: vi.fn(),
|
||||||
|
removeEventListener: vi.fn(),
|
||||||
|
dispatchEvent: vi.fn(),
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(BookCardComponent);
|
||||||
|
ref = fixture.componentRef;
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
|
// Set required inputs before first change detection
|
||||||
|
ref.setInput('book', makeBook());
|
||||||
|
ref.setInput('index', 0);
|
||||||
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -243,8 +257,8 @@ describe('BookCardComponent', () => {
|
|||||||
TestBed.resetTestingModule();
|
TestBed.resetTestingModule();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('derives progress, audiobook, and series display state from inputs and changes', () => {
|
it('derives progress, audiobook, and series display state from inputs', () => {
|
||||||
component.book = makeBook({
|
ref.setInput('book', makeBook({
|
||||||
id: 8,
|
id: 8,
|
||||||
metadata: {
|
metadata: {
|
||||||
bookId: 8,
|
bookId: 8,
|
||||||
@@ -265,27 +279,24 @@ describe('BookCardComponent', () => {
|
|||||||
koreaderProgress: {percentage: 11},
|
koreaderProgress: {percentage: 11},
|
||||||
koboProgress: {percentage: 7},
|
koboProgress: {percentage: 7},
|
||||||
readStatus: ReadStatus.READING,
|
readStatus: ReadStatus.READING,
|
||||||
});
|
}));
|
||||||
component.seriesViewEnabled = true;
|
ref.setInput('seriesViewEnabled', true);
|
||||||
component.isSeriesCollapsed = true;
|
ref.setInput('isSeriesCollapsed', true);
|
||||||
component.forceEbookMode = false;
|
ref.setInput('forceEbookMode', false);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
component.ngOnInit();
|
expect(component.hasProgress()).toBe(true);
|
||||||
|
expect(component.displayTitle()).toBe('Series Saga');
|
||||||
|
expect(component.titleTooltip()).toContain('Series Saga');
|
||||||
|
expect(component.coverImageUrl()).toBe('audio-thumb:8:2024-04-02');
|
||||||
|
expect(component.progressTooltip()).toBe('42% (Grimmory) | 11% (KOReader) | 7% (Kobo)');
|
||||||
|
expect(component.readButtonIcon()).toBe('pi pi-forward');
|
||||||
|
|
||||||
expect(component.hasProgress).toBe(true);
|
ref.setInput('isSeriesCollapsed', false);
|
||||||
expect(component.displayTitle).toBe('Series Saga');
|
fixture.detectChanges();
|
||||||
expect(component.titleTooltip).toContain('Series Saga');
|
|
||||||
expect(component.coverImageUrl).toBe('audio-thumb:8:2024-04-02');
|
|
||||||
expect(component.progressTooltip).toBe('42% (Grimmory) | 11% (KOReader) | 7% (Kobo)');
|
|
||||||
expect(component.readButtonIcon).toBe('pi pi-forward');
|
|
||||||
|
|
||||||
component.isSeriesCollapsed = false;
|
expect(component.displayTitle()).toBe('Volume One');
|
||||||
component.ngOnChanges({
|
expect(component.titleTooltip()).toContain('Volume One');
|
||||||
isSeriesCollapsed: new SimpleChange(true, false, false),
|
|
||||||
} as SimpleChanges);
|
|
||||||
|
|
||||||
expect(component.displayTitle).toBe('Volume One');
|
|
||||||
expect(component.titleTooltip).toContain('Volume One');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses forced ebook mode for audiobook reads and falls back to the normal read flow otherwise', () => {
|
it('uses forced ebook mode for audiobook reads and falls back to the normal read flow otherwise', () => {
|
||||||
@@ -310,23 +321,26 @@ describe('BookCardComponent', () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
component.forceEbookMode = true;
|
ref.setInput('forceEbookMode', true);
|
||||||
|
fixture.detectChanges();
|
||||||
component.readBook(audiobookWithAlternativeFormat);
|
component.readBook(audiobookWithAlternativeFormat);
|
||||||
|
|
||||||
expect(bookService.readBook).toHaveBeenCalledWith(12, undefined, 'PDF');
|
expect(bookService.readBook).toHaveBeenCalledWith(12, undefined, 'PDF');
|
||||||
|
|
||||||
component.forceEbookMode = false;
|
ref.setInput('forceEbookMode', false);
|
||||||
|
fixture.detectChanges();
|
||||||
component.readBook(makeBook({id: 13}));
|
component.readBook(makeBook({id: 13}));
|
||||||
|
|
||||||
expect(bookService.readBook).toHaveBeenCalledWith(13);
|
expect(bookService.readBook).toHaveBeenCalledWith(13);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('derives display format from missing primary files, extensions, paths, and forced audiobook ebook types', () => {
|
it('derives display format from missing primary files, extensions, paths, and forced audiobook ebook types', () => {
|
||||||
component.book = makeBook({id: 20, primaryFile: undefined});
|
ref.setInput('book', makeBook({id: 20, primaryFile: undefined}));
|
||||||
component.forceEbookMode = false;
|
ref.setInput('forceEbookMode', false);
|
||||||
expect(component.getDisplayFormat()).toBe('PHY');
|
fixture.detectChanges();
|
||||||
|
expect(component.displayFormat()).toBe('PHY');
|
||||||
|
|
||||||
component.book = makeBook({
|
ref.setInput('book', makeBook({
|
||||||
id: 21,
|
id: 21,
|
||||||
primaryFile: {
|
primaryFile: {
|
||||||
id: 211,
|
id: 211,
|
||||||
@@ -335,10 +349,11 @@ describe('BookCardComponent', () => {
|
|||||||
extension: 'pdf',
|
extension: 'pdf',
|
||||||
filePath: 'books/volume-one.pdf',
|
filePath: 'books/volume-one.pdf',
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
expect(component.getDisplayFormat()).toBe('PDF');
|
fixture.detectChanges();
|
||||||
|
expect(component.displayFormat()).toBe('PDF');
|
||||||
|
|
||||||
component.book = makeBook({
|
ref.setInput('book', makeBook({
|
||||||
id: 22,
|
id: 22,
|
||||||
primaryFile: {
|
primaryFile: {
|
||||||
id: 221,
|
id: 221,
|
||||||
@@ -346,10 +361,11 @@ describe('BookCardComponent', () => {
|
|||||||
bookType: 'EPUB',
|
bookType: 'EPUB',
|
||||||
filePath: 'books/volume-one.mobi',
|
filePath: 'books/volume-one.mobi',
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
expect(component.getDisplayFormat()).toBe('MOBI');
|
fixture.detectChanges();
|
||||||
|
expect(component.displayFormat()).toBe('MOBI');
|
||||||
|
|
||||||
component.book = makeBook({
|
ref.setInput('book', makeBook({
|
||||||
id: 23,
|
id: 23,
|
||||||
primaryFile: {
|
primaryFile: {
|
||||||
id: 231,
|
id: 231,
|
||||||
@@ -358,40 +374,45 @@ describe('BookCardComponent', () => {
|
|||||||
filePath: 'books/volume-one.m4b',
|
filePath: 'books/volume-one.m4b',
|
||||||
},
|
},
|
||||||
epubProgress: {cfi: 'epub', percentage: 73},
|
epubProgress: {cfi: 'epub', percentage: 73},
|
||||||
});
|
}));
|
||||||
component.forceEbookMode = true;
|
ref.setInput('forceEbookMode', true);
|
||||||
expect(component.getDisplayFormat()).toBe('EPUB');
|
fixture.detectChanges();
|
||||||
|
expect(component.displayFormat()).toBe('EPUB');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('guards card selection and preserves shift metadata for ctrl-initiated changes only', () => {
|
it('guards card selection and emits checkbox events for ctrl-initiated changes only', () => {
|
||||||
component.book = makeBook({id: 30});
|
ref.setInput('book', makeBook({id: 30}));
|
||||||
component.index = 4;
|
ref.setInput('index', 4);
|
||||||
component.isCheckboxEnabled = false;
|
ref.setInput('isCheckboxEnabled', false);
|
||||||
component.isSelected = false;
|
ref.setInput('isSelected', false);
|
||||||
component.onBookSelect = vi.fn();
|
const selectFn = vi.fn();
|
||||||
|
ref.setInput('onBookSelect', selectFn);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
const emitSpy = vi.spyOn(component.checkboxClick, 'emit');
|
const emitted: unknown[] = [];
|
||||||
|
component.checkboxClick.subscribe(e => emitted.push(e));
|
||||||
|
|
||||||
component.toggleCardSelection(true);
|
component.toggleCardSelection(true);
|
||||||
expect(emitSpy).not.toHaveBeenCalled();
|
expect(emitted).toHaveLength(0);
|
||||||
expect(component.onBookSelect).not.toHaveBeenCalled();
|
expect(selectFn).not.toHaveBeenCalled();
|
||||||
|
|
||||||
component.isCheckboxEnabled = true;
|
ref.setInput('isCheckboxEnabled', true);
|
||||||
|
fixture.detectChanges();
|
||||||
component.captureMouseEvent(new MouseEvent('mousedown', {shiftKey: true}));
|
component.captureMouseEvent(new MouseEvent('mousedown', {shiftKey: true}));
|
||||||
|
|
||||||
component.onCardClick(new MouseEvent('click', {ctrlKey: false}));
|
component.onCardClick(new MouseEvent('click', {ctrlKey: false}));
|
||||||
expect(emitSpy).not.toHaveBeenCalled();
|
expect(emitted).toHaveLength(0);
|
||||||
|
|
||||||
component.onCardClick(new MouseEvent('click', {ctrlKey: true}));
|
component.onCardClick(new MouseEvent('click', {ctrlKey: true}));
|
||||||
|
|
||||||
expect(component.isSelected).toBe(true);
|
expect(emitted).toHaveLength(1);
|
||||||
expect(emitSpy).toHaveBeenCalledWith({
|
expect(emitted[0]).toEqual({
|
||||||
index: 4,
|
index: 4,
|
||||||
book: component.book,
|
book: component.book(),
|
||||||
selected: true,
|
selected: true,
|
||||||
shiftKey: true,
|
shiftKey: true,
|
||||||
});
|
});
|
||||||
expect(component.onBookSelect).toHaveBeenCalledWith(component.book, true);
|
expect(selectFn).toHaveBeenCalledWith(component.book(), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('routes series info and book details through the correct destination', () => {
|
it('routes series info and book details through the correct destination', () => {
|
||||||
@@ -406,16 +427,17 @@ describe('BookCardComponent', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
userService.currentUser.mockReturnValue(makeUser('route'));
|
userService.currentUser.set(makeUser('route'));
|
||||||
component.book = book;
|
ref.setInput('book', book);
|
||||||
component.isSeriesCollapsed = true;
|
ref.setInput('isSeriesCollapsed', true);
|
||||||
component.ngOnInit();
|
fixture.detectChanges();
|
||||||
|
|
||||||
component.openSeriesInfo();
|
component.openSeriesInfo();
|
||||||
expect(router.navigate).toHaveBeenCalledWith(['/series', 'The Series']);
|
expect(router.navigate).toHaveBeenCalledWith(['/series', 'The Series']);
|
||||||
|
|
||||||
bookNavigationService.availableBookIds.mockReturnValue([2, 44, 77]);
|
bookNavigationService.availableBookIds.mockReturnValue([2, 44, 77]);
|
||||||
component.isSeriesCollapsed = false;
|
ref.setInput('isSeriesCollapsed', false);
|
||||||
|
fixture.detectChanges();
|
||||||
component.openSeriesInfo();
|
component.openSeriesInfo();
|
||||||
|
|
||||||
expect(bookNavigationService.setNavigationContext).toHaveBeenCalledWith([2, 44, 77], 44);
|
expect(bookNavigationService.setNavigationContext).toHaveBeenCalledWith([2, 44, 77], 44);
|
||||||
@@ -423,9 +445,7 @@ describe('BookCardComponent', () => {
|
|||||||
queryParams: {tab: 'view'},
|
queryParams: {tab: 'view'},
|
||||||
});
|
});
|
||||||
|
|
||||||
userService.currentUser.mockReturnValue(makeUser('dialog'));
|
userService.currentUser.set(makeUser('dialog'));
|
||||||
const dialogComponent = component as unknown as {metadataCenterViewMode: 'route' | 'dialog'};
|
|
||||||
dialogComponent.metadataCenterViewMode = 'dialog';
|
|
||||||
router.navigate.mockClear();
|
router.navigate.mockClear();
|
||||||
bookNavigationService.setNavigationContext.mockClear();
|
bookNavigationService.setNavigationContext.mockClear();
|
||||||
|
|
||||||
|
|||||||
+264
-355
@@ -1,24 +1,20 @@
|
|||||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, inject, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, computed, inject, input, output, signal} from '@angular/core';
|
||||||
import {TooltipModule} from "primeng/tooltip";
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {AdditionalFile, Book, BookType, ReadStatus} from '../../../model/book.model';
|
import {AdditionalFile, Book, BookType, ReadStatus} from '../../../model/book.model';
|
||||||
import {Button} from 'primeng/button';
|
|
||||||
import {MenuModule} from 'primeng/menu';
|
|
||||||
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
||||||
import {BookService} from '../../../service/book.service';
|
import {BookService} from '../../../service/book.service';
|
||||||
import {BookFileService} from '../../../service/book-file.service';
|
import {BookFileService} from '../../../service/book-file.service';
|
||||||
import {BookMetadataManageService} from '../../../service/book-metadata-manage.service';
|
import {BookMetadataManageService} from '../../../service/book-metadata-manage.service';
|
||||||
import {CheckboxChangeEvent, CheckboxModule} from 'primeng/checkbox';
|
import {CheckboxChangeEvent, Checkbox} from 'primeng/checkbox';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {MetadataRefreshType} from '../../../../metadata/model/request/metadata-refresh-type.enum';
|
import {MetadataRefreshType} from '../../../../metadata/model/request/metadata-refresh-type.enum';
|
||||||
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
||||||
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
||||||
import {NgClass} from '@angular/common';
|
import {NgClass} from '@angular/common';
|
||||||
import {User, UserService} from '../../../../settings/user-management/user.service';
|
import {UserService} from '../../../../settings/user-management/user.service';
|
||||||
import {EmailService} from '../../../../settings/email-v2/email.service';
|
import {EmailService} from '../../../../settings/email-v2/email.service';
|
||||||
import {TieredMenu} from 'primeng/tieredmenu';
|
import {TieredMenu} from 'primeng/tieredmenu';
|
||||||
import {Router} from '@angular/router';
|
import {Router, RouterLink} from '@angular/router';
|
||||||
import {RouterLink} from '@angular/router';
|
|
||||||
import {ProgressBar} from 'primeng/progressbar';
|
|
||||||
import {readStatusLabels} from '../book-filter/book-filter.config';
|
import {readStatusLabels} from '../book-filter/book-filter.config';
|
||||||
import {ResetProgressTypes} from '../../../../../shared/constants/reset-progress-type';
|
import {ResetProgressTypes} from '../../../../../shared/constants/reset-progress-type';
|
||||||
import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
||||||
@@ -34,32 +30,37 @@ import {QueryClient} from '@tanstack/angular-query-experimental';
|
|||||||
selector: 'app-book-card',
|
selector: 'app-book-card',
|
||||||
templateUrl: './book-card.component.html',
|
templateUrl: './book-card.component.html',
|
||||||
styleUrls: ['./book-card.component.scss'],
|
styleUrls: ['./book-card.component.scss'],
|
||||||
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgClass, TieredMenu, ProgressBar, TooltipModule, RouterLink, TranslocoPipe, CoverPlaceholderComponent],
|
imports: [Checkbox, FormsModule, NgClass, TieredMenu, Tooltip, RouterLink, TranslocoPipe, CoverPlaceholderComponent],
|
||||||
standalone: true,
|
standalone: true,
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
export class BookCardComponent {
|
||||||
|
|
||||||
@Output() checkboxClick = new EventEmitter<{ index: number; book: Book; selected: boolean; shiftKey: boolean }>();
|
// --- Inputs ---
|
||||||
@Output() menuToggled = new EventEmitter<boolean>();
|
readonly book = input.required<Book>();
|
||||||
|
readonly index = input.required<number>();
|
||||||
|
readonly isCheckboxEnabled = input(false);
|
||||||
|
readonly onBookSelect = input<((book: Book, selected: boolean) => void) | undefined>();
|
||||||
|
readonly isSelected = input(false);
|
||||||
|
readonly bottomBarHidden = input(false);
|
||||||
|
readonly seriesViewEnabled = input(false);
|
||||||
|
readonly isSeriesCollapsed = input(false);
|
||||||
|
readonly overlayPreferenceService = input<BookCardOverlayPreferenceService | undefined>();
|
||||||
|
private readonly overlayService = inject(BookCardOverlayPreferenceService);
|
||||||
|
readonly showBookTypePill = computed(() => (this.overlayPreferenceService() ?? this.overlayService).showBookTypePill());
|
||||||
|
readonly forceEbookMode = input(false);
|
||||||
|
readonly useSquareCovers = input(false);
|
||||||
|
|
||||||
@Input() index!: number;
|
readonly checkboxClick = output<{ index: number; book: Book; selected: boolean; shiftKey: boolean }>();
|
||||||
@Input() book!: Book;
|
readonly menuToggled = output<boolean>();
|
||||||
@Input() isCheckboxEnabled: boolean = false;
|
|
||||||
@Input() onBookSelect?: (book: Book, selected: boolean) => void;
|
|
||||||
@Input() isSelected: boolean = false;
|
|
||||||
@Input() bottomBarHidden: boolean = false;
|
|
||||||
@Input() seriesViewEnabled: boolean = false;
|
|
||||||
@Input() isSeriesCollapsed: boolean = false;
|
|
||||||
@Input() overlayPreferenceService?: BookCardOverlayPreferenceService;
|
|
||||||
@Input() forceEbookMode: boolean = false;
|
|
||||||
@Input() useSquareCovers: boolean = false;
|
|
||||||
|
|
||||||
@ViewChild('checkboxElem') checkboxElem!: ElementRef<HTMLInputElement>;
|
readonly items = signal<MenuItem[] | undefined>(undefined);
|
||||||
items: MenuItem[] | undefined;
|
readonly readStatusMenuItems = signal<MenuItem[]>([]);
|
||||||
readStatusMenuItems: MenuItem[] = [];
|
readonly isSubMenuLoading = signal(false);
|
||||||
isSubMenuLoading = false;
|
private readonly additionalFilesLoaded = signal(false);
|
||||||
private additionalFilesLoaded = false;
|
/** Tracks the book id for which the menu was last built, to auto-rebuild on virtual-scroller reuse. */
|
||||||
|
private menuBookId: number | undefined;
|
||||||
|
private menuInitialized = false;
|
||||||
|
|
||||||
private bookService = inject(BookService);
|
private bookService = inject(BookService);
|
||||||
private bookFileService = inject(BookFileService);
|
private bookFileService = inject(BookFileService);
|
||||||
@@ -69,165 +70,113 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
private emailService = inject(EmailService);
|
private emailService = inject(EmailService);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
protected urlHelper = inject(UrlHelperService);
|
private urlHelper = inject(UrlHelperService);
|
||||||
private confirmationService = inject(ConfirmationService);
|
private confirmationService = inject(ConfirmationService);
|
||||||
private bookDialogHelperService = inject(BookDialogHelperService);
|
private bookDialogHelperService = inject(BookDialogHelperService);
|
||||||
private bookNavigationService = inject(BookNavigationService);
|
private bookNavigationService = inject(BookNavigationService);
|
||||||
private cdr = inject(ChangeDetectorRef);
|
|
||||||
private appSettingsService = inject(AppSettingsService);
|
private appSettingsService = inject(AppSettingsService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
private queryClient = inject(QueryClient);
|
private queryClient = inject(QueryClient);
|
||||||
|
|
||||||
protected _progressPercentage: number | null = null;
|
|
||||||
protected _koProgressPercentage: number | null = null;
|
|
||||||
protected _koboProgressPercentage: number | null = null;
|
|
||||||
protected _displayTitle: string | undefined = undefined;
|
|
||||||
protected _isSeriesViewActive: boolean = false;
|
|
||||||
protected _coverImageUrl: string | null = null;
|
|
||||||
protected _readStatusIcon: string = '';
|
|
||||||
protected _readStatusClass: string = '';
|
|
||||||
protected _readStatusTooltip: string = '';
|
|
||||||
protected _shouldShowStatusIcon: boolean = false;
|
|
||||||
protected _seriesCountTooltip: string = '';
|
|
||||||
protected _titleTooltip: string = '';
|
|
||||||
protected _hasProgress: boolean = false;
|
|
||||||
protected _isAudiobook: boolean = false;
|
|
||||||
protected _progressTooltip: string = '';
|
|
||||||
protected _isContinueReading: boolean = false;
|
|
||||||
protected _readButtonIcon: string = 'pi pi-book';
|
|
||||||
|
|
||||||
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
|
||||||
protected readStatusHelper = inject(ReadStatusHelper);
|
protected readStatusHelper = inject(ReadStatusHelper);
|
||||||
private user: User | null = null;
|
|
||||||
private diskType: string = 'LOCAL';
|
|
||||||
private menuInitialized = false;
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
private readonly currentUser = computed(() => this.userService.currentUser());
|
||||||
this.computeAllMemoizedValues();
|
private readonly metadataCenterViewMode = computed(() => this.currentUser()?.userSettings?.metadataCenterViewMode ?? 'route' as 'route' | 'dialog');
|
||||||
const currentUser = this.userService.currentUser();
|
private readonly diskType = computed(() => this.appSettingsService.appSettings()?.diskType ?? 'LOCAL');
|
||||||
if (currentUser) {
|
|
||||||
this.user = currentUser;
|
|
||||||
this.metadataCenterViewMode = currentUser.userSettings?.metadataCenterViewMode ?? 'route';
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings = this.appSettingsService.appSettings();
|
|
||||||
if (settings) {
|
|
||||||
this.diskType = settings.diskType ?? 'LOCAL';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
readonly progressPercentage = computed(() => {
|
||||||
this._coverImageUrl = null;
|
const b = this.book();
|
||||||
}
|
return b.epubProgress?.percentage ?? b.pdfProgress?.percentage ?? b.cbxProgress?.percentage ?? null;
|
||||||
|
});
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
readonly koProgressPercentage = computed(() => this.book().koreaderProgress?.percentage ?? null);
|
||||||
if (changes['book'] || changes['forceEbookMode'] || changes['useSquareCovers']) {
|
readonly koboProgressPercentage = computed(() => this.book().koboProgress?.percentage ?? null);
|
||||||
this.computeAllMemoizedValues();
|
|
||||||
if (changes['book'] && !changes['book'].firstChange && this.menuInitialized) {
|
|
||||||
this.additionalFilesLoaded = false;
|
|
||||||
this.initMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changes['seriesViewEnabled'] || changes['isSeriesCollapsed']) {
|
readonly hasProgress = computed(() =>
|
||||||
this._isSeriesViewActive = this.seriesViewEnabled && !!this.book.seriesCount && this.book.seriesCount >= 1;
|
this.progressPercentage() !== null || this.koProgressPercentage() !== null || this.koboProgressPercentage() !== null
|
||||||
this._displayTitle = (this.isSeriesCollapsed && this.book.metadata?.seriesName) ? this.book.metadata?.seriesName : this.book.metadata?.title;
|
);
|
||||||
this._titleTooltip = this.t.translate('book.card.alt.titleTooltip', { title: this._displayTitle });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private computeAllMemoizedValues(): void {
|
readonly isSeriesViewActive = computed(() =>
|
||||||
this._progressPercentage = this.book.epubProgress?.percentage
|
this.seriesViewEnabled() && !!this.book().seriesCount && this.book().seriesCount! >= 1
|
||||||
?? this.book.pdfProgress?.percentage
|
);
|
||||||
?? this.book.cbxProgress?.percentage
|
|
||||||
?? null;
|
|
||||||
|
|
||||||
this._koProgressPercentage = this.book.koreaderProgress?.percentage ?? null;
|
readonly displayTitle = computed(() =>
|
||||||
this._koboProgressPercentage = this.book.koboProgress?.percentage ?? null;
|
(this.isSeriesCollapsed() && this.book().metadata?.seriesName)
|
||||||
|
? this.book().metadata?.seriesName
|
||||||
|
: this.book().metadata?.title
|
||||||
|
);
|
||||||
|
|
||||||
this._hasProgress = this._progressPercentage !== null || this._koProgressPercentage !== null || this._koboProgressPercentage !== null;
|
readonly isAudiobook = computed(() =>
|
||||||
|
this.book().primaryFile?.bookType === 'AUDIOBOOK' && !this.forceEbookMode()
|
||||||
|
);
|
||||||
|
|
||||||
this._isSeriesViewActive = this.seriesViewEnabled && !!this.book.seriesCount && this.book.seriesCount >= 1;
|
readonly coverImageUrl = computed(() =>
|
||||||
this._displayTitle = (this.isSeriesCollapsed && this.book.metadata?.seriesName)
|
this.isAudiobook()
|
||||||
? this.book.metadata?.seriesName
|
? this.urlHelper.getAudiobookThumbnailUrl(this.book().id, this.book().metadata?.audiobookCoverUpdatedOn)
|
||||||
: this.book.metadata?.title;
|
: this.urlHelper.getThumbnailUrl(this.book().id, this.book().metadata?.coverUpdatedOn)
|
||||||
this._isAudiobook = this.book.primaryFile?.bookType === 'AUDIOBOOK' && !this.forceEbookMode;
|
);
|
||||||
this._coverImageUrl = this._isAudiobook
|
|
||||||
? this.urlHelper.getAudiobookThumbnailUrl(this.book.id, this.book.metadata?.audiobookCoverUpdatedOn)
|
|
||||||
: this.urlHelper.getThumbnailUrl(this.book.id, this.book.metadata?.coverUpdatedOn);
|
|
||||||
|
|
||||||
this._readStatusIcon = this.readStatusHelper.getReadStatusIcon(this.book.readStatus);
|
readonly readStatusIcon = computed(() => this.readStatusHelper.getReadStatusIcon(this.book().readStatus));
|
||||||
this._readStatusClass = this.readStatusHelper.getReadStatusClass(this.book.readStatus);
|
readonly readStatusClass = computed(() => this.readStatusHelper.getReadStatusClass(this.book().readStatus));
|
||||||
this._readStatusTooltip = this.readStatusHelper.getReadStatusTooltip(this.book.readStatus);
|
readonly readStatusTooltip = computed(() => this.readStatusHelper.getReadStatusTooltip(this.book().readStatus));
|
||||||
this._shouldShowStatusIcon = this.readStatusHelper.shouldShowStatusIcon(this.book.readStatus);
|
|
||||||
|
|
||||||
this._seriesCountTooltip = this.t.translate('book.card.alt.seriesCollapsed', { count: this.book.seriesCount });
|
readonly seriesCountTooltip = computed(() =>
|
||||||
this._titleTooltip = this.t.translate('book.card.alt.titleTooltip', { title: this._displayTitle });
|
this.t.translate('book.card.alt.seriesCollapsed', {count: this.book().seriesCount})
|
||||||
|
);
|
||||||
|
|
||||||
const progressParts: string[] = [];
|
readonly titleTooltip = computed(() =>
|
||||||
if (this._progressPercentage !== null) {
|
this.t.translate('book.card.alt.titleTooltip', {title: this.displayTitle()})
|
||||||
progressParts.push(`${this._progressPercentage}% (Grimmory)`);
|
);
|
||||||
}
|
|
||||||
if (this._koProgressPercentage !== null) {
|
|
||||||
progressParts.push(`${this._koProgressPercentage}% (KOReader)`);
|
|
||||||
}
|
|
||||||
if (this._koboProgressPercentage !== null) {
|
|
||||||
progressParts.push(`${this._koboProgressPercentage}% (Kobo)`);
|
|
||||||
}
|
|
||||||
this._progressTooltip = progressParts.join(' | ');
|
|
||||||
|
|
||||||
const maxProgress = Math.max(
|
readonly progressTooltip = computed(() => {
|
||||||
this._progressPercentage ?? 0,
|
const parts: string[] = [];
|
||||||
this._koProgressPercentage ?? 0,
|
const p = this.progressPercentage();
|
||||||
this._koboProgressPercentage ?? 0
|
const ko = this.koProgressPercentage();
|
||||||
|
const kobo = this.koboProgressPercentage();
|
||||||
|
if (p !== null) parts.push(`${p}% (Grimmory)`);
|
||||||
|
if (ko !== null) parts.push(`${ko}% (KOReader)`);
|
||||||
|
if (kobo !== null) parts.push(`${kobo}% (Kobo)`);
|
||||||
|
return parts.join(' | ');
|
||||||
|
});
|
||||||
|
|
||||||
|
readonly isContinueReading = computed(() => {
|
||||||
|
const max = Math.max(
|
||||||
|
this.progressPercentage() ?? 0,
|
||||||
|
this.koProgressPercentage() ?? 0,
|
||||||
|
this.koboProgressPercentage() ?? 0
|
||||||
);
|
);
|
||||||
this._isContinueReading = maxProgress > 0 && maxProgress < 100;
|
return max > 0 && max < 100;
|
||||||
|
});
|
||||||
|
|
||||||
if (this._isAudiobook) {
|
readonly readButtonIcon = computed(() => {
|
||||||
this._readButtonIcon = this._isContinueReading ? 'pi pi-forward' : 'pi pi-play';
|
if (this.isAudiobook()) {
|
||||||
} else {
|
return this.isContinueReading() ? 'pi pi-forward' : 'pi pi-play';
|
||||||
this._readButtonIcon = this._isContinueReading ? 'pi pi-forward' : 'pi pi-book';
|
|
||||||
}
|
}
|
||||||
}
|
return this.isContinueReading() ? 'pi pi-forward' : 'pi pi-book';
|
||||||
|
});
|
||||||
|
|
||||||
get hasProgress(): boolean {
|
readonly displayFormat = computed<string | null>(() => {
|
||||||
return this._hasProgress;
|
const b = this.book();
|
||||||
}
|
if (!b.primaryFile) return 'PHY';
|
||||||
|
if (this.forceEbookMode() && b.primaryFile.bookType === 'AUDIOBOOK') {
|
||||||
|
const ebookType = this.getEbookType(b);
|
||||||
|
if (ebookType) return ebookType;
|
||||||
|
}
|
||||||
|
const ext = b.primaryFile.extension;
|
||||||
|
if (ext) return ext.toUpperCase();
|
||||||
|
return this.getFileExtension(b.primaryFile.filePath);
|
||||||
|
});
|
||||||
|
|
||||||
get seriesCountTooltip(): string {
|
readonly hasDigitalFile = computed(() => !!this.book().primaryFile);
|
||||||
return this._seriesCountTooltip;
|
|
||||||
}
|
|
||||||
|
|
||||||
get titleTooltip(): string {
|
readonly readingUrl = computed(() => this.urlHelper.getBookPrimaryReadingUrl(this.book()));
|
||||||
return this._titleTooltip;
|
|
||||||
}
|
|
||||||
|
|
||||||
get readStatusTooltip(): string {
|
|
||||||
return this._readStatusTooltip;
|
|
||||||
}
|
|
||||||
|
|
||||||
get progressTooltip(): string {
|
|
||||||
return this._progressTooltip;
|
|
||||||
}
|
|
||||||
|
|
||||||
get readButtonIcon(): string {
|
|
||||||
return this._readButtonIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
get displayTitle(): string | undefined {
|
|
||||||
return this._displayTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
get coverImageUrl(): string | null {
|
|
||||||
return this._coverImageUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
private buildReadStatusMenuItems(): void {
|
private buildReadStatusMenuItems(): void {
|
||||||
this.readStatusMenuItems = Object.entries(readStatusLabels).map(([status, label]) => ({
|
this.readStatusMenuItems.set(Object.entries(readStatusLabels).map(([status, label]) => ({
|
||||||
label,
|
label,
|
||||||
command: () => {
|
command: () => {
|
||||||
this.bookService.updateBookReadStatus(this.book.id, status as ReadStatus).subscribe({
|
this.bookService.updateBookReadStatus(this.book().id, status as ReadStatus).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -246,20 +195,19 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleReadStatusMenu(event: Event, menu: TieredMenu): void {
|
toggleReadStatusMenu(event: Event, menu: TieredMenu): void {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (this.readStatusMenuItems.length === 0) {
|
if (this.readStatusMenuItems().length === 0) {
|
||||||
this.buildReadStatusMenuItems();
|
this.buildReadStatusMenuItems();
|
||||||
}
|
}
|
||||||
menu.toggle(event);
|
menu.toggle(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
readBook(book: Book): void {
|
readBook(book: Book): void {
|
||||||
if (this.forceEbookMode && book.primaryFile?.bookType === 'AUDIOBOOK') {
|
if (this.forceEbookMode() && book.primaryFile?.bookType === 'AUDIOBOOK') {
|
||||||
const ebookType = this.getEbookType(book);
|
const ebookType = this.getEbookType(book);
|
||||||
if (ebookType) {
|
if (ebookType) {
|
||||||
this.bookService.readBook(book.id, undefined, ebookType);
|
this.bookService.readBook(book.id, undefined, ebookType);
|
||||||
@@ -288,52 +236,47 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMenuToggle(event: Event, menu: TieredMenu): void {
|
onMenuToggle(event: Event, menu: TieredMenu): void {
|
||||||
if (!this.menuInitialized) {
|
const currentBookId = this.book().id;
|
||||||
|
|
||||||
|
if (!this.menuInitialized || this.menuBookId !== currentBookId) {
|
||||||
this.menuInitialized = true;
|
this.menuInitialized = true;
|
||||||
|
this.menuBookId = currentBookId;
|
||||||
|
this.additionalFilesLoaded.set(false);
|
||||||
this.initMenu();
|
this.initMenu();
|
||||||
this.cdr.markForCheck();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.toggle(event);
|
menu.toggle(event);
|
||||||
|
|
||||||
if (!this.additionalFilesLoaded && !this.isSubMenuLoading && this.needsAdditionalFilesData()) {
|
if (!this.additionalFilesLoaded() && !this.isSubMenuLoading() && this.needsAdditionalFilesData()) {
|
||||||
this.isSubMenuLoading = true;
|
this.isSubMenuLoading.set(true);
|
||||||
this.cdr.markForCheck();
|
const requestedBookId = currentBookId;
|
||||||
const requestedBookId = this.book.id;
|
|
||||||
void this.queryClient.fetchQuery(this.bookService.bookDetailQueryOptions(requestedBookId, true))
|
void this.queryClient.fetchQuery(this.bookService.bookDetailQueryOptions(requestedBookId, true))
|
||||||
.then((book) => {
|
.then((fetchedBook) => {
|
||||||
if (this.book.id !== requestedBookId) {
|
if (this.book().id !== requestedBookId) return;
|
||||||
return;
|
this.additionalFilesLoaded.set(true);
|
||||||
}
|
this.initMenu(fetchedBook);
|
||||||
this.book = book;
|
|
||||||
this.additionalFilesLoaded = true;
|
|
||||||
this.isSubMenuLoading = false;
|
|
||||||
this.initMenu();
|
|
||||||
this.cdr.markForCheck();
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.finally(() => {
|
||||||
if (this.book.id !== requestedBookId) {
|
if (this.book().id === requestedBookId) {
|
||||||
return;
|
this.isSubMenuLoading.set(false);
|
||||||
}
|
}
|
||||||
this.isSubMenuLoading = false;
|
|
||||||
this.cdr.markForCheck();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private needsAdditionalFilesData(): boolean {
|
private needsAdditionalFilesData(): boolean {
|
||||||
if (this.additionalFilesLoaded) {
|
if (this.additionalFilesLoaded()) return false;
|
||||||
return false;
|
const b = this.book();
|
||||||
}
|
const hasNoAlternativeFormats = !b.alternativeFormats || b.alternativeFormats.length === 0;
|
||||||
const hasNoAlternativeFormats = !this.book.alternativeFormats || this.book.alternativeFormats.length === 0;
|
const hasNoSupplementaryFiles = !b.supplementaryFiles || b.supplementaryFiles.length === 0;
|
||||||
const hasNoSupplementaryFiles = !this.book.supplementaryFiles || this.book.supplementaryFiles.length === 0;
|
const canDownload = !!this.currentUser()?.permissions.canDownload;
|
||||||
const canDownload = !!this.user?.permissions.canDownload;
|
const canDeleteBook = !!this.currentUser()?.permissions.canDeleteBook;
|
||||||
const canDeleteBook = !!this.user?.permissions.canDeleteBook;
|
|
||||||
return (canDownload || canDeleteBook) && hasNoAlternativeFormats && hasNoSupplementaryFiles;
|
return (canDownload || canDeleteBook) && hasNoAlternativeFormats && hasNoSupplementaryFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private initMenu() {
|
private initMenu(bookOverride?: Book) {
|
||||||
this.items = [
|
const b = bookOverride ?? this.book();
|
||||||
|
this.items.set([
|
||||||
{
|
{
|
||||||
label: this.t.translate('book.card.menu.assignShelf'),
|
label: this.t.translate('book.card.menu.assignShelf'),
|
||||||
icon: 'pi pi-folder',
|
icon: 'pi pi-folder',
|
||||||
@@ -344,64 +287,60 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
icon: 'pi pi-info-circle',
|
icon: 'pi pi-info-circle',
|
||||||
command: () => {
|
command: () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.openBookInfo(this.book);
|
this.openBookInfo(this.book());
|
||||||
}, 150);
|
}, 150);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...this.getPermissionBasedMenuItems(),
|
...this.getPermissionBasedMenuItems(b),
|
||||||
...this.moreMenuItems(),
|
...this.moreMenuItems(),
|
||||||
];
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPermissionBasedMenuItems(): MenuItem[] {
|
private getPermissionBasedMenuItems(b: Book): MenuItem[] {
|
||||||
const items: MenuItem[] = [];
|
const items: MenuItem[] = [];
|
||||||
|
|
||||||
if (this.user?.permissions.canDownload) {
|
if (this.currentUser()?.permissions.canDownload) {
|
||||||
const hasAdditionalFiles = (this.book.alternativeFormats && this.book.alternativeFormats.length > 0) ||
|
const hasAdditional = (b.alternativeFormats && b.alternativeFormats.length > 0) ||
|
||||||
(this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0);
|
(b.supplementaryFiles && b.supplementaryFiles.length > 0);
|
||||||
|
|
||||||
if (hasAdditionalFiles) {
|
if (hasAdditional) {
|
||||||
const downloadItems = this.getDownloadMenuItems();
|
|
||||||
items.push({
|
items.push({
|
||||||
label: this.t.translate('book.card.menu.download'),
|
label: this.t.translate('book.card.menu.download'),
|
||||||
icon: 'pi pi-download',
|
icon: 'pi pi-download',
|
||||||
items: downloadItems
|
items: this.getDownloadMenuItems(b)
|
||||||
});
|
});
|
||||||
} else if (this.additionalFilesLoaded) {
|
} else if (this.additionalFilesLoaded()) {
|
||||||
items.push({
|
items.push({
|
||||||
label: this.t.translate('book.card.menu.download'),
|
label: this.t.translate('book.card.menu.download'),
|
||||||
icon: 'pi pi-download',
|
icon: 'pi pi-download',
|
||||||
command: () => {
|
command: () => this.bookFileService.downloadFile(this.book())
|
||||||
this.bookFileService.downloadFile(this.book);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
items.push({
|
items.push({
|
||||||
label: this.t.translate('book.card.menu.download'),
|
label: this.t.translate('book.card.menu.download'),
|
||||||
icon: this.isSubMenuLoading ? 'pi pi-spin pi-spinner' : 'pi pi-download',
|
icon: this.isSubMenuLoading() ? 'pi pi-spin pi-spinner' : 'pi pi-download',
|
||||||
items: [{label: this.t.translate('book.card.menu.loading'), disabled: true}]
|
items: [{label: this.t.translate('book.card.menu.loading'), disabled: true}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.user?.permissions.canDeleteBook) {
|
if (this.currentUser()?.permissions.canDeleteBook) {
|
||||||
const hasAdditionalFiles = (this.book.alternativeFormats && this.book.alternativeFormats.length > 0) ||
|
const hasAdditional = (b.alternativeFormats && b.alternativeFormats.length > 0) ||
|
||||||
(this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0);
|
(b.supplementaryFiles && b.supplementaryFiles.length > 0);
|
||||||
|
|
||||||
if (hasAdditionalFiles) {
|
if (hasAdditional) {
|
||||||
const deleteItems = this.getDeleteMenuItems();
|
|
||||||
items.push({
|
items.push({
|
||||||
label: this.t.translate('book.card.menu.delete'),
|
label: this.t.translate('book.card.menu.delete'),
|
||||||
icon: 'pi pi-trash',
|
icon: 'pi pi-trash',
|
||||||
items: deleteItems
|
items: this.getDeleteMenuItems(b)
|
||||||
});
|
});
|
||||||
} else if (this.additionalFilesLoaded) {
|
} else if (this.additionalFilesLoaded()) {
|
||||||
items.push({
|
items.push({
|
||||||
label: this.t.translate('book.card.menu.delete'),
|
label: this.t.translate('book.card.menu.delete'),
|
||||||
icon: 'pi pi-trash',
|
icon: 'pi pi-trash',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.confirmationService.confirm({
|
this.confirmationService.confirm({
|
||||||
message: this.t.translate('book.card.confirm.deleteBookMessage', {title: this.book.metadata?.title}),
|
message: this.t.translate('book.card.confirm.deleteBookMessage', {title: this.book().metadata?.title}),
|
||||||
header: this.t.translate('book.card.confirm.deleteBookHeader'),
|
header: this.t.translate('book.card.confirm.deleteBookHeader'),
|
||||||
icon: 'pi pi-exclamation-triangle',
|
icon: 'pi pi-exclamation-triangle',
|
||||||
acceptIcon: 'pi pi-trash',
|
acceptIcon: 'pi pi-trash',
|
||||||
@@ -411,7 +350,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
acceptButtonStyleClass: 'p-button-danger',
|
acceptButtonStyleClass: 'p-button-danger',
|
||||||
rejectButtonStyleClass: 'p-button-outlined',
|
rejectButtonStyleClass: 'p-button-outlined',
|
||||||
accept: () => {
|
accept: () => {
|
||||||
this.bookService.deleteBooks(new Set([this.book.id])).subscribe();
|
this.bookService.deleteBooks(new Set([this.book().id])).subscribe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -419,69 +358,67 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
} else {
|
} else {
|
||||||
items.push({
|
items.push({
|
||||||
label: this.t.translate('book.card.menu.delete'),
|
label: this.t.translate('book.card.menu.delete'),
|
||||||
icon: this.isSubMenuLoading ? 'pi pi-spin pi-spinner' : 'pi pi-trash',
|
icon: this.isSubMenuLoading() ? 'pi pi-spin pi-spinner' : 'pi pi-trash',
|
||||||
items: [{label: this.t.translate('book.card.menu.loading'), disabled: true}]
|
items: [{label: this.t.translate('book.card.menu.loading'), disabled: true}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.user?.permissions.canEmailBook) {
|
if (this.currentUser()?.permissions.canEmailBook) {
|
||||||
items.push(
|
items.push({
|
||||||
{
|
label: this.t.translate('book.card.menu.emailBook'),
|
||||||
label: this.t.translate('book.card.menu.emailBook'),
|
icon: 'pi pi-envelope',
|
||||||
|
items: [{
|
||||||
|
label: this.t.translate('book.card.menu.quickSend'),
|
||||||
icon: 'pi pi-envelope',
|
icon: 'pi pi-envelope',
|
||||||
items: [{
|
command: () => {
|
||||||
label: this.t.translate('book.card.menu.quickSend'),
|
const doSend = () => {
|
||||||
icon: 'pi pi-envelope',
|
this.emailService.emailBookQuick(this.book().id).subscribe({
|
||||||
command: () => {
|
next: () => {
|
||||||
const doSend = () => {
|
this.messageService.add({
|
||||||
this.emailService.emailBookQuick(this.book.id).subscribe({
|
severity: 'info',
|
||||||
next: () => {
|
summary: this.t.translate('common.success'),
|
||||||
this.messageService.add({
|
detail: this.t.translate('book.card.toast.quickSendSuccessDetail'),
|
||||||
severity: 'info',
|
});
|
||||||
summary: this.t.translate('common.success'),
|
},
|
||||||
detail: this.t.translate('book.card.toast.quickSendSuccessDetail'),
|
error: (err: {error?: {message?: string}}) => {
|
||||||
});
|
const errorMessage = err?.error?.message || this.t.translate('book.card.toast.quickSendErrorDetail');
|
||||||
},
|
this.messageService.add({
|
||||||
error: (err) => {
|
severity: 'error',
|
||||||
const errorMessage = err?.error?.message || this.t.translate('book.card.toast.quickSendErrorDetail');
|
summary: this.t.translate('common.error'),
|
||||||
this.messageService.add({
|
detail: errorMessage,
|
||||||
severity: 'error',
|
});
|
||||||
summary: this.t.translate('common.error'),
|
},
|
||||||
detail: errorMessage,
|
});
|
||||||
});
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.book.primaryFile?.fileSizeKb && this.book.primaryFile.fileSizeKb > 25 * 1024) {
|
const currentBook = this.book();
|
||||||
this.confirmationService.confirm({
|
if (currentBook.primaryFile?.fileSizeKb && currentBook.primaryFile.fileSizeKb > 25 * 1024) {
|
||||||
message: this.t.translate('book.card.confirm.largeFileMessage'),
|
this.confirmationService.confirm({
|
||||||
header: this.t.translate('book.card.confirm.largeFileHeader'),
|
message: this.t.translate('book.card.confirm.largeFileMessage'),
|
||||||
icon: 'pi pi-exclamation-triangle',
|
header: this.t.translate('book.card.confirm.largeFileHeader'),
|
||||||
acceptLabel: this.t.translate('book.card.confirm.sendAnyway'),
|
icon: 'pi pi-exclamation-triangle',
|
||||||
rejectLabel: this.t.translate('common.cancel'),
|
acceptLabel: this.t.translate('book.card.confirm.sendAnyway'),
|
||||||
acceptButtonProps: { severity: 'warn' },
|
rejectLabel: this.t.translate('common.cancel'),
|
||||||
rejectButtonProps: { severity: 'secondary' },
|
acceptButtonProps: {severity: 'warn'},
|
||||||
accept: doSend,
|
rejectButtonProps: {severity: 'secondary'},
|
||||||
});
|
accept: doSend,
|
||||||
} else {
|
});
|
||||||
doSend();
|
} else {
|
||||||
}
|
doSend();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
},
|
||||||
label: this.t.translate('book.card.menu.customSend'),
|
{
|
||||||
icon: 'pi pi-envelope',
|
label: this.t.translate('book.card.menu.customSend'),
|
||||||
command: () => {
|
icon: 'pi pi-envelope',
|
||||||
this.bookDialogHelperService.openCustomSendDialog(this.book);
|
command: () => this.bookDialogHelperService.openCustomSendDialog(this.book())
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.user?.permissions.canEditMetadata) {
|
if (this.currentUser()?.permissions.canEditMetadata) {
|
||||||
items.push({
|
items.push({
|
||||||
label: this.t.translate('book.card.menu.metadata'),
|
label: this.t.translate('book.card.menu.metadata'),
|
||||||
icon: 'pi pi-database',
|
icon: 'pi pi-database',
|
||||||
@@ -491,9 +428,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
icon: 'pi pi-sparkles',
|
icon: 'pi pi-sparkles',
|
||||||
command: () => {
|
command: () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.router.navigate(['/book', this.book.id], {
|
this.router.navigate(['/book', this.book().id], {queryParams: {tab: 'match'}});
|
||||||
queryParams: {tab: 'match'}
|
|
||||||
})
|
|
||||||
}, 150);
|
}, 150);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -503,28 +438,26 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
command: () => {
|
command: () => {
|
||||||
this.taskHelperService.refreshMetadataTask({
|
this.taskHelperService.refreshMetadataTask({
|
||||||
refreshType: MetadataRefreshType.BOOKS,
|
refreshType: MetadataRefreshType.BOOKS,
|
||||||
bookIds: [this.book.id],
|
bookIds: [this.book().id],
|
||||||
}).subscribe();
|
}).subscribe();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: this.t.translate('book.card.menu.customFetch'),
|
label: this.t.translate('book.card.menu.customFetch'),
|
||||||
icon: 'pi pi-sync',
|
icon: 'pi pi-sync',
|
||||||
command: () => {
|
command: () => this.bookDialogHelperService.openMetadataRefreshDialog(new Set([this.book().id])),
|
||||||
this.bookDialogHelperService.openMetadataRefreshDialog(new Set([this.book!.id]))
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: this.t.translate('book.card.menu.regenerateCover'),
|
label: this.t.translate('book.card.menu.regenerateCover'),
|
||||||
icon: 'pi pi-image',
|
icon: 'pi pi-image',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.bookMetadataManageService.regenerateCover(this.book.id).subscribe({
|
this.bookMetadataManageService.regenerateCover(this.book().id).subscribe({
|
||||||
next: () => this.messageService.add({
|
next: () => this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
summary: this.t.translate('common.success'),
|
summary: this.t.translate('common.success'),
|
||||||
detail: this.t.translate('book.card.toast.coverRegenSuccessDetail')
|
detail: this.t.translate('book.card.toast.coverRegenSuccessDetail')
|
||||||
}),
|
}),
|
||||||
error: (err) => this.messageService.add({
|
error: (err: {error?: {message?: string}}) => this.messageService.add({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
summary: this.t.translate('common.error'),
|
summary: this.t.translate('common.error'),
|
||||||
detail: err?.error?.message || this.t.translate('book.card.toast.coverRegenFailedDetail')
|
detail: err?.error?.message || this.t.translate('book.card.toast.coverRegenFailedDetail')
|
||||||
@@ -536,13 +469,13 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
label: this.t.translate('book.card.menu.generateCustomCover'),
|
label: this.t.translate('book.card.menu.generateCustomCover'),
|
||||||
icon: 'pi pi-palette',
|
icon: 'pi pi-palette',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.bookMetadataManageService.generateCustomCover(this.book.id).subscribe({
|
this.bookMetadataManageService.generateCustomCover(this.book().id).subscribe({
|
||||||
next: () => this.messageService.add({
|
next: () => this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
summary: this.t.translate('common.success'),
|
summary: this.t.translate('common.success'),
|
||||||
detail: this.t.translate('book.card.toast.customCoverSuccessDetail')
|
detail: this.t.translate('book.card.toast.customCoverSuccessDetail')
|
||||||
}),
|
}),
|
||||||
error: (err) => this.messageService.add({
|
error: (err: {error?: {message?: string}}) => this.messageService.add({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
summary: this.t.translate('common.error'),
|
summary: this.t.translate('common.error'),
|
||||||
detail: err?.error?.message || this.t.translate('book.card.toast.customCoverFailedDetail')
|
detail: err?.error?.message || this.t.translate('book.card.toast.customCoverFailedDetail')
|
||||||
@@ -561,13 +494,11 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
const items: MenuItem[] = [];
|
const items: MenuItem[] = [];
|
||||||
const moreActions: MenuItem[] = [];
|
const moreActions: MenuItem[] = [];
|
||||||
|
|
||||||
if (this.user?.permissions.canMoveOrganizeFiles && this.diskType === 'LOCAL') {
|
if (this.currentUser()?.permissions.canMoveOrganizeFiles && this.diskType() === 'LOCAL') {
|
||||||
moreActions.push({
|
moreActions.push({
|
||||||
label: this.t.translate('book.card.menu.organizeFile'),
|
label: this.t.translate('book.card.menu.organizeFile'),
|
||||||
icon: 'pi pi-arrows-h',
|
icon: 'pi pi-arrows-h',
|
||||||
command: () => {
|
command: () => this.bookDialogHelperService.openFileMoverDialog(new Set([this.book().id]))
|
||||||
this.bookDialogHelperService.openFileMoverDialog(new Set([this.book.id]));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,7 +509,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
items: Object.entries(readStatusLabels).map(([status, label]) => ({
|
items: Object.entries(readStatusLabels).map(([status, label]) => ({
|
||||||
label,
|
label,
|
||||||
command: () => {
|
command: () => {
|
||||||
this.bookService.updateBookReadStatus(this.book.id, status as ReadStatus).subscribe({
|
this.bookService.updateBookReadStatus(this.book().id, status as ReadStatus).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -603,7 +534,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
label: this.t.translate('book.card.menu.resetGrimmoryProgress'),
|
label: this.t.translate('book.card.menu.resetGrimmoryProgress'),
|
||||||
icon: 'pi pi-undo',
|
icon: 'pi pi-undo',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.bookService.resetProgress(this.book.id, ResetProgressTypes.GRIMMORY).subscribe({
|
this.bookService.resetProgress(this.book().id, ResetProgressTypes.GRIMMORY).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -627,7 +558,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
label: this.t.translate('book.card.menu.resetKOReaderProgress'),
|
label: this.t.translate('book.card.menu.resetKOReaderProgress'),
|
||||||
icon: 'pi pi-undo',
|
icon: 'pi pi-undo',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.bookService.resetProgress(this.book.id, ResetProgressTypes.KOREADER).subscribe({
|
this.bookService.resetProgress(this.book().id, ResetProgressTypes.KOREADER).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -659,15 +590,16 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private openShelfDialog(): void {
|
private openShelfDialog(): void {
|
||||||
this.bookDialogHelperService.openShelfAssignerDialog(this.book, null);
|
this.bookDialogHelperService.openShelfAssignerDialog(this.book(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
openSeriesInfo(): void {
|
openSeriesInfo(): void {
|
||||||
const seriesName = this.book?.metadata?.seriesName;
|
const b = this.book();
|
||||||
if (this.isSeriesCollapsed && seriesName) {
|
const seriesName = b.metadata?.seriesName;
|
||||||
|
if (this.isSeriesCollapsed() && seriesName) {
|
||||||
this.router.navigate(['/series', seriesName]);
|
this.router.navigate(['/series', seriesName]);
|
||||||
} else {
|
} else {
|
||||||
this.openBookInfo(this.book);
|
this.openBookInfo(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,7 +609,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
this.bookNavigationService.setNavigationContext(allBookIds, book.id);
|
this.bookNavigationService.setNavigationContext(allBookIds, book.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.metadataCenterViewMode === 'route') {
|
if (this.metadataCenterViewMode() === 'route') {
|
||||||
this.router.navigate(['/book', book.id], {
|
this.router.navigate(['/book', book.id], {
|
||||||
queryParams: {tab: 'view'}
|
queryParams: {tab: 'view'}
|
||||||
});
|
});
|
||||||
@@ -686,52 +618,50 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDownloadMenuItems(): MenuItem[] {
|
private getDownloadMenuItems(b: Book): MenuItem[] {
|
||||||
const items: MenuItem[] = [];
|
const items: MenuItem[] = [];
|
||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
label: `${this.book.fileName || 'Book File'}`,
|
label: `${b.fileName || 'Book File'}`,
|
||||||
icon: 'pi pi-file',
|
icon: 'pi pi-file',
|
||||||
command: () => {
|
command: () => this.bookFileService.downloadFile(this.book())
|
||||||
this.bookFileService.downloadFile(this.book);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.hasAdditionalFiles()) {
|
if (this.hasAdditionalFilesForBook(b)) {
|
||||||
items.push({separator: true});
|
items.push({separator: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.book.alternativeFormats && this.book.alternativeFormats.length > 0) {
|
if (b.alternativeFormats && b.alternativeFormats.length > 0) {
|
||||||
this.book.alternativeFormats.forEach(format => {
|
for (const format of b.alternativeFormats) {
|
||||||
const extension = this.getFileExtension(format.filePath);
|
const extension = this.getFileExtension(format.filePath);
|
||||||
items.push({
|
items.push({
|
||||||
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
|
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
|
||||||
icon: this.getFileIcon(extension),
|
icon: this.getFileIcon(extension),
|
||||||
command: () => this.downloadAdditionalFile(this.book, format.id)
|
command: () => this.downloadAdditionalFile(this.book(), format.id)
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.book.alternativeFormats && this.book.alternativeFormats.length > 0 &&
|
if (b.alternativeFormats && b.alternativeFormats.length > 0 &&
|
||||||
this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0) {
|
b.supplementaryFiles && b.supplementaryFiles.length > 0) {
|
||||||
items.push({separator: true});
|
items.push({separator: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0) {
|
if (b.supplementaryFiles && b.supplementaryFiles.length > 0) {
|
||||||
this.book.supplementaryFiles.forEach(file => {
|
for (const file of b.supplementaryFiles) {
|
||||||
const extension = this.getFileExtension(file.filePath);
|
const extension = this.getFileExtension(file.filePath);
|
||||||
items.push({
|
items.push({
|
||||||
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
|
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
|
||||||
icon: this.getFileIcon(extension),
|
icon: this.getFileIcon(extension),
|
||||||
command: () => this.downloadAdditionalFile(this.book, file.id)
|
command: () => this.downloadAdditionalFile(this.book(), file.id)
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDeleteMenuItems(): MenuItem[] {
|
private getDeleteMenuItems(b: Book): MenuItem[] {
|
||||||
const items: MenuItem[] = [];
|
const items: MenuItem[] = [];
|
||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
@@ -739,7 +669,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
icon: 'pi pi-book',
|
icon: 'pi pi-book',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.confirmationService.confirm({
|
this.confirmationService.confirm({
|
||||||
message: this.t.translate('book.card.confirm.deleteBookMessage', {title: this.book.metadata?.title}),
|
message: this.t.translate('book.card.confirm.deleteBookMessage', {title: this.book().metadata?.title}),
|
||||||
header: this.t.translate('book.card.confirm.deleteBookHeader'),
|
header: this.t.translate('book.card.confirm.deleteBookHeader'),
|
||||||
icon: 'pi pi-exclamation-triangle',
|
icon: 'pi pi-exclamation-triangle',
|
||||||
acceptIcon: 'pi pi-trash',
|
acceptIcon: 'pi pi-trash',
|
||||||
@@ -749,49 +679,49 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
acceptButtonStyleClass: 'p-button-danger',
|
acceptButtonStyleClass: 'p-button-danger',
|
||||||
rejectButtonStyleClass: 'p-button-outlined',
|
rejectButtonStyleClass: 'p-button-outlined',
|
||||||
accept: () => {
|
accept: () => {
|
||||||
this.bookService.deleteBooks(new Set([this.book.id])).subscribe();
|
this.bookService.deleteBooks(new Set([this.book().id])).subscribe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.hasAdditionalFiles()) {
|
if (this.hasAdditionalFilesForBook(b)) {
|
||||||
items.push({separator: true});
|
items.push({separator: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.book.alternativeFormats && this.book.alternativeFormats.length > 0) {
|
if (b.alternativeFormats && b.alternativeFormats.length > 0) {
|
||||||
this.book.alternativeFormats.forEach(format => {
|
for (const format of b.alternativeFormats) {
|
||||||
const extension = this.getFileExtension(format.filePath);
|
const extension = this.getFileExtension(format.filePath);
|
||||||
items.push({
|
items.push({
|
||||||
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
|
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
|
||||||
icon: this.getFileIcon(extension),
|
icon: this.getFileIcon(extension),
|
||||||
command: () => this.deleteAdditionalFile(this.book.id, format.id, format.fileName || 'file')
|
command: () => this.deleteAdditionalFile(this.book().id, format.id, format.fileName || 'file')
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.book.alternativeFormats && this.book.alternativeFormats.length > 0 &&
|
if (b.alternativeFormats && b.alternativeFormats.length > 0 &&
|
||||||
this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0) {
|
b.supplementaryFiles && b.supplementaryFiles.length > 0) {
|
||||||
items.push({separator: true});
|
items.push({separator: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0) {
|
if (b.supplementaryFiles && b.supplementaryFiles.length > 0) {
|
||||||
this.book.supplementaryFiles.forEach(file => {
|
for (const file of b.supplementaryFiles) {
|
||||||
const extension = this.getFileExtension(file.filePath);
|
const extension = this.getFileExtension(file.filePath);
|
||||||
items.push({
|
items.push({
|
||||||
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
|
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
|
||||||
icon: this.getFileIcon(extension),
|
icon: this.getFileIcon(extension),
|
||||||
command: () => this.deleteAdditionalFile(this.book.id, file.id, file.fileName || 'file')
|
command: () => this.deleteAdditionalFile(this.book().id, file.id, file.fileName || 'file')
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private hasAdditionalFiles(): boolean {
|
private hasAdditionalFilesForBook(b: Book): boolean {
|
||||||
return !!(this.book.alternativeFormats && this.book.alternativeFormats.length > 0) ||
|
return !!(b.alternativeFormats && b.alternativeFormats.length > 0) ||
|
||||||
!!(this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0);
|
!!(b.supplementaryFiles && b.supplementaryFiles.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private downloadAdditionalFile(book: Book, fileId: number): void {
|
private downloadAdditionalFile(book: Book, fileId: number): void {
|
||||||
@@ -815,7 +745,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
detail: this.t.translate('book.card.toast.deleteFileSuccessDetail', {fileName})
|
detail: this.t.translate('book.card.toast.deleteFileSuccessDetail', {fileName})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error: {message?: string}) => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
summary: this.t.translate('common.error'),
|
summary: this.t.translate('common.error'),
|
||||||
@@ -827,34 +757,13 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileExtension(filePath?: string): string | null {
|
private getFileExtension(filePath?: string): string | null {
|
||||||
if (!filePath) return null;
|
if (!filePath) return null;
|
||||||
const parts = filePath.split('.');
|
const parts = filePath.split('.');
|
||||||
if (parts.length < 2) return null;
|
if (parts.length < 2) return null;
|
||||||
return parts.pop()?.toUpperCase() || null;
|
return parts.pop()?.toUpperCase() || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDisplayFormat(): string | null {
|
|
||||||
if (!this.book?.primaryFile) {
|
|
||||||
return 'PHY';
|
|
||||||
}
|
|
||||||
if (this.forceEbookMode && this.book.primaryFile?.bookType === 'AUDIOBOOK') {
|
|
||||||
const ebookType = this.getEbookType(this.book);
|
|
||||||
if (ebookType) {
|
|
||||||
return ebookType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const ext = this.book?.primaryFile?.extension;
|
|
||||||
if (ext) {
|
|
||||||
return ext.toUpperCase();
|
|
||||||
}
|
|
||||||
return this.getFileExtension(this.book?.primaryFile?.filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
hasDigitalFile(): boolean {
|
|
||||||
return !!this.book?.primaryFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getFileIcon(fileType: string | null): string {
|
private getFileIcon(fileType: string | null): string {
|
||||||
if (!fileType) return 'pi pi-file';
|
if (!fileType) return 'pi pi-file';
|
||||||
switch (fileType.toLowerCase()) {
|
switch (fileType.toLowerCase()) {
|
||||||
@@ -896,26 +805,26 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggleCardSelection(!this.isSelected)
|
this.toggleCardSelection(!this.isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleCardSelection(selected: boolean): void {
|
toggleCardSelection(selected: boolean): void {
|
||||||
if (!this.isCheckboxEnabled) {
|
if (!this.isCheckboxEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isSelected = selected;
|
|
||||||
const shiftKey = this.lastMouseEvent?.shiftKey ?? false;
|
const shiftKey = this.lastMouseEvent?.shiftKey ?? false;
|
||||||
|
|
||||||
this.checkboxClick.emit({
|
this.checkboxClick.emit({
|
||||||
index: this.index,
|
index: this.index(),
|
||||||
book: this.book,
|
book: this.book(),
|
||||||
selected: selected,
|
selected,
|
||||||
shiftKey: shiftKey,
|
shiftKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.onBookSelect) {
|
const selectFn = this.onBookSelect();
|
||||||
this.onBookSelect(this.book, selected);
|
if (selectFn) {
|
||||||
|
selectFn(this.book(), selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastMouseEvent = null;
|
this.lastMouseEvent = null;
|
||||||
|
|||||||
+19
-12
@@ -1,9 +1,9 @@
|
|||||||
import {Component, EventEmitter, inject, Input, OnChanges, OnDestroy, OnInit, Output} from '@angular/core';
|
import {Component, ElementRef, EventEmitter, inject, Input, OnChanges, OnDestroy, OnInit, Output} from '@angular/core';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import {DatePipe, NgClass} from '@angular/common';
|
import {DatePipe, NgClass} from '@angular/common';
|
||||||
import {Rating} from 'primeng/rating';
|
import {Rating} from 'primeng/rating';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TooltipModule} from "primeng/tooltip";
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {Book, BookMetadata, ReadStatus} from '../../../model/book.model';
|
import {Book, BookMetadata, ReadStatus} from '../../../model/book.model';
|
||||||
import {SortOption} from '../../../model/sort.model';
|
import {SortOption} from '../../../model/sort.model';
|
||||||
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
||||||
@@ -13,7 +13,6 @@ import {BookService} from '../../../service/book.service';
|
|||||||
import {BookMetadataManageService} from '../../../service/book-metadata-manage.service';
|
import {BookMetadataManageService} from '../../../service/book-metadata-manage.service';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {RouterLink} from '@angular/router';
|
import {RouterLink} from '@angular/router';
|
||||||
import {Subject} from 'rxjs';
|
|
||||||
import {UserService} from '../../../../settings/user-management/user.service';
|
import {UserService} from '../../../../settings/user-management/user.service';
|
||||||
import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
@@ -27,7 +26,7 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
Rating,
|
Rating,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
Button,
|
Button,
|
||||||
TooltipModule,
|
Tooltip,
|
||||||
NgClass,
|
NgClass,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
@@ -54,9 +53,10 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
private datePipe = inject(DatePipe);
|
private datePipe = inject(DatePipe);
|
||||||
private readStatusHelper = inject(ReadStatusHelper);
|
private readStatusHelper = inject(ReadStatusHelper);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
private elementRef = inject(ElementRef);
|
||||||
|
|
||||||
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
||||||
private destroy$ = new Subject<void>();
|
private resizeListener = this.setScrollHeight.bind(this);
|
||||||
|
|
||||||
readonly allColumns: { field: string; header: string }[] = [
|
readonly allColumns: { field: string; header: string }[] = [
|
||||||
{field: 'readStatus', header: this.t.translate('book.columnPref.columns.readStatus')},
|
{field: 'readStatus', header: this.t.translate('book.columnPref.columns.readStatus')},
|
||||||
@@ -94,7 +94,7 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
this.selectedBookIds = this.preselectedBookIds;
|
this.selectedBookIds = this.preselectedBookIds;
|
||||||
this.selectedBooks = this.bookService.getBooksByIds([...this.selectedBookIds]);
|
this.selectedBooks = this.bookService.getBooksByIds([...this.selectedBookIds]);
|
||||||
this.setScrollHeight();
|
this.setScrollHeight();
|
||||||
window.addEventListener('resize', this.setScrollHeight.bind(this));
|
window.addEventListener('resize', this.resizeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
setScrollHeight() {
|
setScrollHeight() {
|
||||||
@@ -105,12 +105,21 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
const wrapperElements: HTMLCollection = document.getElementsByClassName('p-virtualscroller');
|
const wrapperElements = this.elementRef.nativeElement.querySelectorAll('.p-virtualscroller');
|
||||||
Array.prototype.forEach.call(wrapperElements, function (wrapperElement) {
|
wrapperElements.forEach((wrapperElement: Element) => {
|
||||||
wrapperElement.style["height"] = 'calc(100dvh - 160px)';
|
if (wrapperElement instanceof HTMLElement) {
|
||||||
|
wrapperElement.style.height = 'calc(100dvh - 160px)';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToTop(): void {
|
||||||
|
const tableElement = this.elementRef.nativeElement.querySelector('.p-datatable-wrapper');
|
||||||
|
if (tableElement instanceof HTMLElement) {
|
||||||
|
tableElement.scrollTop = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
selectAllBooks(): void {
|
selectAllBooks(): void {
|
||||||
this.selectedBookIds = new Set(this.books.map(book => book.id));
|
this.selectedBookIds = new Set(this.books.map(book => book.id));
|
||||||
this.selectedBooks = [...this.books];
|
this.selectedBooks = [...this.books];
|
||||||
@@ -343,8 +352,6 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.destroy$.next();
|
window.removeEventListener('resize', this.resizeListener);
|
||||||
this.destroy$.complete();
|
|
||||||
window.removeEventListener('resize', this.setScrollHeight.bind(this));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-3
@@ -1,3 +1,4 @@
|
|||||||
|
import {signal} from '@angular/core';
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||||
@@ -16,7 +17,10 @@ describe('BookCardLiteComponent', () => {
|
|||||||
getThumbnailUrl: ReturnType<typeof vi.fn>;
|
getThumbnailUrl: ReturnType<typeof vi.fn>;
|
||||||
getAudiobookThumbnailUrl: ReturnType<typeof vi.fn>;
|
getAudiobookThumbnailUrl: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
let userService: {currentUser: ReturnType<typeof vi.fn>};
|
let userService: {
|
||||||
|
currentUser: ReturnType<typeof signal<unknown>>;
|
||||||
|
getCurrentUser: ReturnType<typeof vi.fn>;
|
||||||
|
};
|
||||||
let hostService: {requestBookSwitch: ReturnType<typeof vi.fn>};
|
let hostService: {requestBookSwitch: ReturnType<typeof vi.fn>};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -25,8 +29,10 @@ describe('BookCardLiteComponent', () => {
|
|||||||
getThumbnailUrl: vi.fn(() => '/covers/1'),
|
getThumbnailUrl: vi.fn(() => '/covers/1'),
|
||||||
getAudiobookThumbnailUrl: vi.fn(() => '/covers/audio/1'),
|
getAudiobookThumbnailUrl: vi.fn(() => '/covers/audio/1'),
|
||||||
};
|
};
|
||||||
|
const currentUser = signal<unknown>({userSettings: {metadataCenterViewMode: 'route'}});
|
||||||
userService = {
|
userService = {
|
||||||
currentUser: vi.fn(() => ({userSettings: {metadataCenterViewMode: 'route'}})),
|
currentUser,
|
||||||
|
getCurrentUser: vi.fn(() => currentUser()),
|
||||||
};
|
};
|
||||||
hostService = {
|
hostService = {
|
||||||
requestBookSwitch: vi.fn(),
|
requestBookSwitch: vi.fn(),
|
||||||
@@ -84,7 +90,7 @@ describe('BookCardLiteComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('delegates to the metadata host when the user prefers dialog mode', () => {
|
it('delegates to the metadata host when the user prefers dialog mode', () => {
|
||||||
userService.currentUser.mockReturnValue({userSettings: {metadataCenterViewMode: 'dialog'}});
|
userService.currentUser.set({userSettings: {metadataCenterViewMode: 'dialog'}});
|
||||||
const book = buildBook();
|
const book = buildBook();
|
||||||
|
|
||||||
component.openBookInfo(book);
|
component.openBookInfo(book);
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ import {UserService} from '../../../settings/user-management/user.service';
|
|||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {NgClass} from '@angular/common';
|
import {NgClass} from '@angular/common';
|
||||||
import {BookMetadataHostService} from '../../../../shared/service/book-metadata-host.service';
|
import {BookMetadataHostService} from '../../../../shared/service/book-metadata-host.service';
|
||||||
import {TooltipModule} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-book-card-lite-component',
|
selector: 'app-book-card-lite-component',
|
||||||
@@ -15,7 +15,7 @@ import {TooltipModule} from 'primeng/tooltip';
|
|||||||
imports: [
|
imports: [
|
||||||
Button,
|
Button,
|
||||||
NgClass,
|
NgClass,
|
||||||
TooltipModule,
|
Tooltip,
|
||||||
CoverPlaceholderComponent
|
CoverPlaceholderComponent
|
||||||
],
|
],
|
||||||
templateUrl: './book-card-lite-component.html',
|
templateUrl: './book-card-lite-component.html',
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
@@ -17,7 +16,6 @@ import {BookNote, BookNoteService, CreateBookNoteRequest} from '../../../../shar
|
|||||||
selector: 'app-book-notes-component',
|
selector: 'app-book-notes-component',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
Button,
|
Button,
|
||||||
Dialog,
|
Dialog,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {toObservable, toSignal} from '@angular/core/rxjs-interop';
|
|||||||
import {debounceTime, distinctUntilChanged} from 'rxjs/operators';
|
import {debounceTime, distinctUntilChanged} from 'rxjs/operators';
|
||||||
import {Book} from '../../model/book.model';
|
import {Book} from '../../model/book.model';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {InputTextModule} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {BookService} from '../../service/book.service';
|
import {BookService} from '../../service/book.service';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {SlicePipe} from '@angular/common';
|
import {SlicePipe} from '@angular/common';
|
||||||
@@ -22,7 +22,7 @@ import {Popover} from 'primeng/popover';
|
|||||||
templateUrl: './book-searcher.component.html',
|
templateUrl: './book-searcher.component.html',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
InputTextModule,
|
InputText,
|
||||||
Button,
|
Button,
|
||||||
SlicePipe,
|
SlicePipe,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
|
|||||||
@@ -398,7 +398,7 @@
|
|||||||
</p-tabs>
|
</p-tabs>
|
||||||
@if (selectedBooks.size > 0) {
|
@if (selectedBooks.size > 0) {
|
||||||
@if (currentUser(); as user) {
|
@if (currentUser(); as user) {
|
||||||
<div class="book-browser-footer" [@slideInOut]>
|
<div class="book-browser-footer" [animate.enter]="'slide-in-up'" [animate.leave]="'slide-out-down'">
|
||||||
<div class="footer-content">
|
<div class="footer-content">
|
||||||
<div class="footer-left">
|
<div class="footer-left">
|
||||||
<div class="selected-count-badge">
|
<div class="selected-count-badge">
|
||||||
|
|||||||
@@ -808,6 +808,24 @@
|
|||||||
|
|
||||||
// ── Footer ──
|
// ── Footer ──
|
||||||
|
|
||||||
|
@keyframes slide-in-up {
|
||||||
|
from { transform: translateY(100%); }
|
||||||
|
to { transform: translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slide-out-down {
|
||||||
|
from { transform: translateY(0); }
|
||||||
|
to { transform: translateY(100%); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-in-up {
|
||||||
|
animation: slide-in-up 0.1s ease-in forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-out-down {
|
||||||
|
animation: slide-out-down 0.1s ease-out forwards;
|
||||||
|
}
|
||||||
|
|
||||||
.book-browser-footer {
|
.book-browser-footer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ import {Button} from "primeng/button";
|
|||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {toSignal} from '@angular/core/rxjs-interop';
|
import {toSignal} from '@angular/core/rxjs-interop';
|
||||||
import {DecimalPipe, KeyValuePipe, NgClass, NgStyle} from "@angular/common";
|
import {DecimalPipe, KeyValuePipe, NgClass, NgStyle} from "@angular/common";
|
||||||
import {finalize, map} from "rxjs/operators";
|
import {finalize, map, take} from "rxjs/operators";
|
||||||
import {Book, BookType, computeSeriesReadStatus, ReadStatus} from "../../model/book.model";
|
import {Book, BookType, computeSeriesReadStatus, ReadStatus} from "../../model/book.model";
|
||||||
import {BookService} from "../../service/book.service";
|
import {BookService} from "../../service/book.service";
|
||||||
import {BookMetadataManageService} from "../../service/book-metadata-manage.service";
|
import {BookMetadataManageService} from "../../service/book-metadata-manage.service";
|
||||||
import {BookCardComponent} from "../book-browser/book-card/book-card.component";
|
import {BookCardComponent} from "../book-browser/book-card/book-card.component";
|
||||||
import {CoverScalePreferenceService} from "../book-browser/cover-scale-preference.service";
|
import {CoverScalePreferenceService} from "../book-browser/cover-scale-preference.service";
|
||||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from "primeng/tabs";
|
import {Tab, TabList, TabPanel, TabPanels, Tabs} from "primeng/tabs";
|
||||||
import {VirtualScrollerModule} from "@iharbeck/ngx-virtual-scroller";
|
|
||||||
import {ProgressSpinner} from "primeng/progressspinner";
|
import {ProgressSpinner} from "primeng/progressspinner";
|
||||||
import {ProgressBar} from "primeng/progressbar";
|
import {ProgressBar} from "primeng/progressbar";
|
||||||
import {DynamicDialogRef} from "primeng/dynamicdialog";
|
import {DynamicDialogRef} from "primeng/dynamicdialog";
|
||||||
@@ -27,7 +26,6 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
import {Tooltip} from "primeng/tooltip";
|
import {Tooltip} from "primeng/tooltip";
|
||||||
import {Divider} from "primeng/divider";
|
import {Divider} from "primeng/divider";
|
||||||
import {TagComponent} from "../../../../shared/components/tag/tag.component";
|
import {TagComponent} from "../../../../shared/components/tag/tag.component";
|
||||||
import {animate, style, transition, trigger} from "@angular/animations";
|
|
||||||
import {AfterViewChecked, Component, computed, effect, ElementRef, inject, ViewChild} from '@angular/core';
|
import {AfterViewChecked, Component, computed, effect, ElementRef, inject, ViewChild} from '@angular/core';
|
||||||
import {BookCardOverlayPreferenceService} from '../book-browser/book-card-overlay-preference.service';
|
import {BookCardOverlayPreferenceService} from '../book-browser/book-card-overlay-preference.service';
|
||||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||||
@@ -84,26 +82,13 @@ interface SeriesStats {
|
|||||||
Tab,
|
Tab,
|
||||||
TabPanels,
|
TabPanels,
|
||||||
TabPanel,
|
TabPanel,
|
||||||
VirtualScrollerModule,
|
|
||||||
TieredMenu,
|
TieredMenu,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Divider,
|
Divider,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TagComponent,
|
TagComponent,
|
||||||
CoverPlaceholderComponent
|
CoverPlaceholderComponent,
|
||||||
],
|
],
|
||||||
animations: [
|
|
||||||
trigger('slideInOut', [
|
|
||||||
transition(':enter', [
|
|
||||||
style({transform: 'translateY(100%)'}),
|
|
||||||
animate('0.1s ease-in', style({transform: 'translateY(0)'}))
|
|
||||||
]),
|
|
||||||
transition(':leave', [
|
|
||||||
style({transform: 'translateY(0)'}),
|
|
||||||
animate('0.1s ease-out', style({transform: 'translateY(100%)'}))
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class SeriesPageComponent implements AfterViewChecked {
|
export class SeriesPageComponent implements AfterViewChecked {
|
||||||
|
|
||||||
@@ -606,7 +591,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
openShelfAssigner(): void {
|
openShelfAssigner(): void {
|
||||||
this.dialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks);
|
this.dialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks);
|
||||||
if (this.dialogRef) {
|
if (this.dialogRef) {
|
||||||
this.dialogRef.onClose.subscribe(result => {
|
this.dialogRef.onClose.pipe(take(1)).subscribe(result => {
|
||||||
if (result.assigned) {
|
if (result.assigned) {
|
||||||
this.selectedBooks.clear();
|
this.selectedBooks.clear();
|
||||||
}
|
}
|
||||||
@@ -617,7 +602,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
lockUnlockMetadata(): void {
|
lockUnlockMetadata(): void {
|
||||||
this.dialogRef = this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks);
|
this.dialogRef = this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks);
|
||||||
if (this.dialogRef) {
|
if (this.dialogRef) {
|
||||||
this.dialogRef.onClose.subscribe(() => {
|
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.deselectAllBooks();
|
this.deselectAllBooks();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -638,7 +623,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
bulkEditMetadata(): void {
|
bulkEditMetadata(): void {
|
||||||
this.dialogRef = this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks);
|
this.dialogRef = this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks);
|
||||||
if (this.dialogRef) {
|
if (this.dialogRef) {
|
||||||
this.dialogRef.onClose.subscribe(() => {
|
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.deselectAllBooks();
|
this.deselectAllBooks();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -647,7 +632,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
multiBookEditMetadata(): void {
|
multiBookEditMetadata(): void {
|
||||||
this.dialogRef = this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks);
|
this.dialogRef = this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks);
|
||||||
if (this.dialogRef) {
|
if (this.dialogRef) {
|
||||||
this.dialogRef.onClose.subscribe(() => {
|
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.deselectAllBooks();
|
this.deselectAllBooks();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {InputText} from 'primeng/inputtext';
|
|||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
||||||
import {UserService} from '../../../settings/user-management/user.service';
|
import {UserService} from '../../../settings/user-management/user.service';
|
||||||
import {CheckboxModule} from 'primeng/checkbox';
|
import {Checkbox} from 'primeng/checkbox';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -23,7 +23,7 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
InputText,
|
InputText,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
IconDisplayComponent,
|
IconDisplayComponent,
|
||||||
CheckboxModule,
|
Checkbox,
|
||||||
TranslocoDirective
|
TranslocoDirective
|
||||||
],
|
],
|
||||||
styleUrl: './shelf-creator.component.scss',
|
styleUrl: './shelf-creator.component.scss',
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@ import {Shelf} from '../../model/shelf.model';
|
|||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {IconPickerService, IconSelection} from '../../../../shared/service/icon-picker.service';
|
import {IconPickerService, IconSelection} from '../../../../shared/service/icon-picker.service';
|
||||||
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
||||||
import {CheckboxModule} from 'primeng/checkbox';
|
import {Checkbox} from 'primeng/checkbox';
|
||||||
import {UserService} from '../../../settings/user-management/user.service';
|
import {UserService} from '../../../settings/user-management/user.service';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
IconDisplayComponent,
|
IconDisplayComponent,
|
||||||
CheckboxModule,
|
Checkbox,
|
||||||
TranslocoDirective
|
TranslocoDirective
|
||||||
],
|
],
|
||||||
templateUrl: './shelf-edit-dialog.component.html',
|
templateUrl: './shelf-edit-dialog.component.html',
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export class AppBooksApiService {
|
|||||||
getNextPageParam: (lastPage: AppPageResponse<AppBookSummary>) =>
|
getNextPageParam: (lastPage: AppPageResponse<AppBookSummary>) =>
|
||||||
lastPage.hasNext ? lastPage.page + 1 : undefined,
|
lastPage.hasNext ? lastPage.page + 1 : undefined,
|
||||||
enabled: !!this.token(),
|
enabled: !!this.token(),
|
||||||
staleTime: 30_000,
|
staleTime: 5 * 60_000,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
readonly filterOptionsQuery = injectQuery(() => ({
|
readonly filterOptionsQuery = injectQuery(() => ({
|
||||||
@@ -54,7 +54,7 @@ export class AppBooksApiService {
|
|||||||
return lastValueFrom(this.http.get<AppFilterOptions>(this.filterOptionsUrl, {params}));
|
return lastValueFrom(this.http.get<AppFilterOptions>(this.filterOptionsUrl, {params}));
|
||||||
},
|
},
|
||||||
enabled: !!this.token(),
|
enabled: !!this.token(),
|
||||||
staleTime: 60_000,
|
staleTime: 10 * 60_000,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/** Accumulated books from all loaded pages, mapped to the Book interface. */
|
/** Accumulated books from all loaded pages, mapped to the Book interface. */
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {TranslocoService} from '@jsverse/transloco';
|
|||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||||
|
|
||||||
import {createAuthServiceStub, createQueryClientHarness, flushSignalAndQueryEffects} from '../../../core/testing/query-testing';
|
import {createAuthServiceStub, createQueryClientHarness, flushSignalAndQueryEffects, flushQueryAsync} from '../../../core/testing/query-testing';
|
||||||
import type {Book, BookMetadata} from '../model/book.model';
|
import type {Book, BookMetadata} from '../model/book.model';
|
||||||
import type {Shelf} from '../model/shelf.model';
|
import type {Shelf} from '../model/shelf.model';
|
||||||
import {AuthService} from '../../../shared/service/auth.service';
|
import {AuthService} from '../../../shared/service/auth.service';
|
||||||
@@ -46,12 +46,7 @@ function buildBook(id: number, overrides: BuildBookOverrides = {}): Book {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function flushBooksQuery(): Promise<void> {
|
async function flushBooksQuery(): Promise<void> {
|
||||||
await Promise.resolve();
|
await flushQueryAsync();
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 0));
|
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
await Promise.resolve();
|
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('BookService', () => {
|
describe('BookService', () => {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export class BookService {
|
|||||||
return queryOptions({
|
return queryOptions({
|
||||||
queryKey: BOOKS_QUERY_KEY,
|
queryKey: BOOKS_QUERY_KEY,
|
||||||
queryFn: () => lastValueFrom(this.http.get<Book[]>(this.url, {params: {stripForListView: false}})),
|
queryFn: () => lastValueFrom(this.http.get<Book[]>(this.url, {params: {stripForListView: false}})),
|
||||||
staleTime: 30_000,
|
staleTime: 5 * 60_000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-8
@@ -1,6 +1,6 @@
|
|||||||
import {Component, DestroyRef, inject, OnInit, QueryList, ViewChildren} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit, QueryList, ViewChildren} from '@angular/core';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {startWith, tap} from 'rxjs/operators';
|
import {startWith, take, tap} from 'rxjs/operators';
|
||||||
import {PageTitleService} from "../../../../shared/service/page-title.service";
|
import {PageTitleService} from "../../../../shared/service/page-title.service";
|
||||||
|
|
||||||
import {BookdropFile, BookdropFinalizePayload, BookdropFinalizeResult, BookdropService, FileExtractionResult, BulkEditRequest as BackendBulkEditRequest, BulkEditResult as BackendBulkEditResult} from '../../service/bookdrop.service';
|
import {BookdropFile, BookdropFinalizePayload, BookdropFinalizeResult, BookdropService, FileExtractionResult, BulkEditRequest as BackendBulkEditRequest, BulkEditResult as BackendBulkEditResult} from '../../service/bookdrop.service';
|
||||||
@@ -14,9 +14,9 @@ import {Select} from 'primeng/select';
|
|||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {Divider} from 'primeng/divider';
|
import {Divider} from 'primeng/divider';
|
||||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||||
import {Subscription} from 'rxjs';
|
|
||||||
import {InputGroup} from 'primeng/inputgroup';
|
import {InputGroup} from 'primeng/inputgroup';
|
||||||
import {InputGroupAddonModule} from 'primeng/inputgroupaddon';
|
import {InputGroupAddon} from 'primeng/inputgroupaddon';
|
||||||
|
|
||||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||||
import {BookMetadata} from '../../../book/model/book.model';
|
import {BookMetadata} from '../../../book/model/book.model';
|
||||||
@@ -60,7 +60,7 @@ export interface BookdropFileUI {
|
|||||||
NgClass,
|
NgClass,
|
||||||
Paginator,
|
Paginator,
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputGroupAddonModule,
|
InputGroupAddon,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@@ -79,8 +79,6 @@ export class BookdropFileReviewComponent implements OnInit {
|
|||||||
|
|
||||||
@ViewChildren('metadataPicker') metadataPickers!: QueryList<BookdropFileMetadataPickerComponent>;
|
@ViewChildren('metadataPicker') metadataPickers!: QueryList<BookdropFileMetadataPickerComponent>;
|
||||||
|
|
||||||
private routerSub!: Subscription;
|
|
||||||
|
|
||||||
uploadPattern = '';
|
uploadPattern = '';
|
||||||
_defaultLibraryId: string | null = null;
|
_defaultLibraryId: string | null = null;
|
||||||
|
|
||||||
@@ -673,7 +671,7 @@ export class BookdropFileReviewComponent implements OnInit {
|
|||||||
data: {fileCount: totalCount},
|
data: {fileCount: totalCount},
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogRef?.onClose.subscribe((result: BulkEditResult | null) => {
|
dialogRef?.onClose.pipe(take(1)).subscribe((result: BulkEditResult | null) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.applyBulkMetadataViaBackend(result);
|
this.applyBulkMetadataViaBackend(result);
|
||||||
}
|
}
|
||||||
@@ -712,7 +710,7 @@ export class BookdropFileReviewComponent implements OnInit {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogRef?.onClose.subscribe((result: { results: FileExtractionResult[] } | null) => {
|
dialogRef?.onClose.pipe(take(1)).subscribe((result: { results: FileExtractionResult[] } | null) => {
|
||||||
if (result?.results) {
|
if (result?.results) {
|
||||||
this.applyExtractedMetadata(result.results);
|
this.applyExtractedMetadata(result.results);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-13
@@ -16,22 +16,17 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (books) {
|
@if (books && books.length > 0) {
|
||||||
<div class="dashboard-scroller-infinite"
|
<div class="dashboard-scroller-strip">
|
||||||
infiniteScroll
|
@for (book of books; track book.id; let i = $index) {
|
||||||
[infiniteScrollDistance]="2"
|
<div class="dashboard-scroller-card" [ngClass]="{'square-card': useSquareCovers}">
|
||||||
[infiniteScrollThrottle]="50"
|
|
||||||
#scrollContainer
|
|
||||||
[horizontal]="true">
|
|
||||||
@for (book of books; track book.id) {
|
|
||||||
<div class="dashboard-scroller-card" [ngClass]="{'menu-open': openMenuBookId === book.id, 'square-card': useSquareCovers}">
|
|
||||||
<app-book-card
|
<app-book-card
|
||||||
[book]="book"
|
[book]="book"
|
||||||
[isCheckboxEnabled]="false"
|
[index]="i"
|
||||||
[forceEbookMode]="forceEbookMode"
|
[forceEbookMode]="forceEbookMode"
|
||||||
(menuToggled)="handleMenuToggle(book.id, $event)"
|
[useSquareCovers]="useSquareCovers"
|
||||||
[overlayPreferenceService]="bookCardOverlayPreferenceService"
|
[overlayPreferenceService]="overlayPreferenceService">
|
||||||
></app-book-card>
|
</app-book-card>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+9
-32
@@ -4,7 +4,7 @@
|
|||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
backdrop-filter: blur(20px);
|
background: rgb(30 30 45 / 40%);
|
||||||
border: color-mix(in srgb, var(--p-surface-500), transparent 50%) 1px solid;
|
border: color-mix(in srgb, var(--p-surface-500), transparent 50%) 1px solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,60 +70,37 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard-scroller-infinite {
|
.dashboard-scroller-strip {
|
||||||
display: flex;
|
display: flex;
|
||||||
overflow: auto hidden;
|
overflow: auto hidden;
|
||||||
scroll-snap-type: x mandatory;
|
scroll-snap-type: x mandatory;
|
||||||
padding: 1rem 0.5rem;
|
padding: 1rem 0.5rem;
|
||||||
gap: 2rem;
|
gap: 2rem;
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
scrollbar-color: var(--primary-color) rgb(20 20 30 / 50%);
|
scrollbar-width: none;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard-scroller-card {
|
.dashboard-scroller-card {
|
||||||
height: 200px;
|
|
||||||
width: 116px;
|
width: 116px;
|
||||||
flex: 0 0 124px;
|
flex: 0 0 124px;
|
||||||
scroll-snap-align: start;
|
scroll-snap-align: start;
|
||||||
transition: transform 0.25s ease;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
transition: transform 0.15s ease;
|
||||||
|
|
||||||
&.square-card {
|
&.square-card {
|
||||||
width: 160px;
|
width: 160px;
|
||||||
height: auto;
|
|
||||||
flex-basis: 160px;
|
flex-basis: 160px;
|
||||||
|
|
||||||
::ng-deep .cover-container.audiobook-cover {
|
|
||||||
aspect-ratio: 1/1 !important;
|
|
||||||
flex: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover, &.menu-open {
|
&:hover {
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audiobook covers should fill the container height
|
|
||||||
::ng-deep {
|
|
||||||
app-book-card {
|
|
||||||
display: block;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.book-card {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cover-container.audiobook-cover {
|
|
||||||
aspect-ratio: unset;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.magic-shelf-icon {
|
.magic-shelf-icon {
|
||||||
|
|||||||
+4
-17
@@ -1,12 +1,9 @@
|
|||||||
import {ChangeDetectionStrategy, Component, ElementRef, Input, ViewChild, inject} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
||||||
import {BookCardComponent} from '../../../book/components/book-browser/book-card/book-card.component';
|
|
||||||
import {InfiniteScrollDirective} from 'ngx-infinite-scroll';
|
|
||||||
import {NgClass} from '@angular/common';
|
import {NgClass} from '@angular/common';
|
||||||
|
|
||||||
import {ProgressSpinnerModule} from 'primeng/progressspinner';
|
|
||||||
import {Book} from '../../../book/model/book.model';
|
import {Book} from '../../../book/model/book.model';
|
||||||
import {ScrollerType} from '../../models/dashboard-config.model';
|
import {ScrollerType} from '../../models/dashboard-config.model';
|
||||||
import { BookCardOverlayPreferenceService } from '../../../book/components/book-browser/book-card-overlay-preference.service';
|
import {BookCardComponent} from '../../../book/components/book-browser/book-card/book-card.component';
|
||||||
|
import {BookCardOverlayPreferenceService} from '../../../book/components/book-browser/book-card-overlay-preference.service';
|
||||||
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -15,9 +12,7 @@ import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
|
|||||||
templateUrl: './dashboard-scroller.component.html',
|
templateUrl: './dashboard-scroller.component.html',
|
||||||
styleUrls: ['./dashboard-scroller.component.scss'],
|
styleUrls: ['./dashboard-scroller.component.scss'],
|
||||||
imports: [
|
imports: [
|
||||||
InfiniteScrollDirective,
|
|
||||||
BookCardComponent,
|
BookCardComponent,
|
||||||
ProgressSpinnerModule,
|
|
||||||
NgClass,
|
NgClass,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TranslocoPipe
|
TranslocoPipe
|
||||||
@@ -31,17 +26,9 @@ export class DashboardScrollerComponent {
|
|||||||
@Input() books!: Book[] | null;
|
@Input() books!: Book[] | null;
|
||||||
@Input() isMagicShelf: boolean = false;
|
@Input() isMagicShelf: boolean = false;
|
||||||
@Input() useSquareCovers: boolean = false;
|
@Input() useSquareCovers: boolean = false;
|
||||||
|
@Input() overlayPreferenceService!: BookCardOverlayPreferenceService;
|
||||||
@ViewChild('scrollContainer') scrollContainer!: ElementRef;
|
|
||||||
openMenuBookId: number | null = null;
|
|
||||||
|
|
||||||
public bookCardOverlayPreferenceService = inject(BookCardOverlayPreferenceService);
|
|
||||||
|
|
||||||
get forceEbookMode(): boolean {
|
get forceEbookMode(): boolean {
|
||||||
return this.bookListType === ScrollerType.LAST_READ;
|
return this.bookListType === ScrollerType.LAST_READ;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMenuToggle(bookId: number, isOpen: boolean) {
|
|
||||||
this.openMenuBookId = isOpen ? bookId : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-12
@@ -1,13 +1,11 @@
|
|||||||
import {Component, computed, effect, inject} from '@angular/core';
|
import {Component, computed, effect, inject} from '@angular/core';
|
||||||
import {toSignal} from '@angular/core/rxjs-interop';
|
import {toSignal} from '@angular/core/rxjs-interop';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
import {ButtonModule} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {CheckboxModule} from 'primeng/checkbox';
|
import {Checkbox} from 'primeng/checkbox';
|
||||||
import {InputTextModule} from 'primeng/inputtext';
|
import {Select} from 'primeng/select';
|
||||||
import {SelectModule} from 'primeng/select';
|
import {InputNumber} from 'primeng/inputnumber';
|
||||||
import {InputNumberModule} from 'primeng/inputnumber';
|
|
||||||
import {DashboardConfig, ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
|
import {DashboardConfig, ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
|
||||||
import {DashboardConfigService} from '../../services/dashboard-config.service';
|
import {DashboardConfigService} from '../../services/dashboard-config.service';
|
||||||
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
||||||
@@ -22,13 +20,11 @@ export const MAX_ITEMS = 20;
|
|||||||
selector: 'app-dashboard-settings',
|
selector: 'app-dashboard-settings',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
ButtonModule,
|
Button,
|
||||||
CheckboxModule,
|
Checkbox,
|
||||||
InputTextModule,
|
Select,
|
||||||
SelectModule,
|
InputNumber,
|
||||||
InputNumberModule,
|
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TranslocoPipe
|
TranslocoPipe
|
||||||
],
|
],
|
||||||
|
|||||||
+17
-3
@@ -51,15 +51,29 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (dashboardConfig(); as config) {
|
@if (dashboardConfig(); as config) {
|
||||||
@for (scroller of config.scrollers; track scroller.id) {
|
@for (scroller of enabledScrollers(); track scroller.id; let idx = $index) {
|
||||||
@if (scroller.enabled) {
|
@if (idx < 2) {
|
||||||
<app-dashboard-scroller
|
<app-dashboard-scroller
|
||||||
[bookListType]="scroller.type"
|
[bookListType]="scroller.type"
|
||||||
[title]="scroller.title"
|
[title]="scroller.title"
|
||||||
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
|
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
|
||||||
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
|
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
|
||||||
[books]="getBooksForScroller(scroller)">
|
[books]="getBooksForScroller(scroller)"
|
||||||
|
[overlayPreferenceService]="overlayPreferenceService">
|
||||||
</app-dashboard-scroller>
|
</app-dashboard-scroller>
|
||||||
|
} @else {
|
||||||
|
@defer (on viewport) {
|
||||||
|
<app-dashboard-scroller
|
||||||
|
[bookListType]="scroller.type"
|
||||||
|
[title]="scroller.title"
|
||||||
|
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
|
||||||
|
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
|
||||||
|
[books]="getBooksForScroller(scroller)"
|
||||||
|
[overlayPreferenceService]="overlayPreferenceService">
|
||||||
|
</app-dashboard-scroller>
|
||||||
|
} @placeholder {
|
||||||
|
<div class="scroller-placeholder"></div>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-11
@@ -3,14 +3,6 @@
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&::before {
|
|
||||||
content: '';
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
width: 12px;
|
width: 12px;
|
||||||
}
|
}
|
||||||
@@ -78,7 +70,6 @@
|
|||||||
background: var(--p-surface-900);
|
background: var(--p-surface-900);
|
||||||
border-radius: 24px;
|
border-radius: 24px;
|
||||||
border: 1px solid var(--p-content-border-color);
|
border: 1px solid var(--p-content-border-color);
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
@@ -89,7 +80,6 @@
|
|||||||
|
|
||||||
::ng-deep .p-dialog-mask {
|
::ng-deep .p-dialog-mask {
|
||||||
background-color: rgb(0 0 0 / 50%);
|
background-color: rgb(0 0 0 / 50%);
|
||||||
backdrop-filter: blur(3px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard-settings-button {
|
.dashboard-settings-button {
|
||||||
@@ -100,7 +90,6 @@
|
|||||||
|
|
||||||
::ng-deep .p-button {
|
::ng-deep .p-button {
|
||||||
box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
|
box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
background: rgb(var(--p-surface-900-rgb), 80%);
|
background: rgb(var(--p-surface-900-rgb), 80%);
|
||||||
border: 1px solid var(--p-content-border-color);
|
border: 1px solid var(--p-content-border-color);
|
||||||
|
|
||||||
@@ -123,3 +112,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.scroller-placeholder {
|
||||||
|
height: 260px;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|||||||
+13
-5
@@ -1,11 +1,11 @@
|
|||||||
import {Component, computed, inject, OnInit} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, computed, inject, OnInit} from '@angular/core';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {DashboardScrollerComponent} from '../dashboard-scroller/dashboard-scroller.component';
|
import {DashboardScrollerComponent} from '../dashboard-scroller/dashboard-scroller.component';
|
||||||
import {BookService} from '../../../book/service/book.service';
|
import {BookService} from '../../../book/service/book.service';
|
||||||
import {Book, ReadStatus} from '../../../book/model/book.model';
|
import {Book, ReadStatus} from '../../../book/model/book.model';
|
||||||
import {UserService} from '../../../settings/user-management/user.service';
|
import {UserService} from '../../../settings/user-management/user.service';
|
||||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||||
import {TooltipModule} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {DashboardConfigService} from '../../services/dashboard-config.service';
|
import {DashboardConfigService} from '../../services/dashboard-config.service';
|
||||||
import {ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
|
import {ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
|
||||||
@@ -17,18 +17,20 @@ import {SortService} from '../../../book/service/sort.service';
|
|||||||
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
||||||
import {SortDirection, SortOption} from '../../../book/model/sort.model';
|
import {SortDirection, SortOption} from '../../../book/model/sort.model';
|
||||||
import {LibraryService} from '../../../book/service/library.service';
|
import {LibraryService} from '../../../book/service/library.service';
|
||||||
|
import {BookCardOverlayPreferenceService} from '../../../book/components/book-browser/book-card-overlay-preference.service';
|
||||||
|
|
||||||
const DEFAULT_MAX_ITEMS = 20;
|
const DEFAULT_MAX_ITEMS = 20;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-main-dashboard',
|
selector: 'app-main-dashboard',
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
templateUrl: './main-dashboard.component.html',
|
templateUrl: './main-dashboard.component.html',
|
||||||
styleUrls: ['./main-dashboard.component.scss'],
|
styleUrls: ['./main-dashboard.component.scss'],
|
||||||
imports: [
|
imports: [
|
||||||
Button,
|
Button,
|
||||||
DashboardScrollerComponent,
|
DashboardScrollerComponent,
|
||||||
ProgressSpinner,
|
ProgressSpinner,
|
||||||
TooltipModule,
|
Tooltip,
|
||||||
TranslocoDirective
|
TranslocoDirective
|
||||||
],
|
],
|
||||||
standalone: true
|
standalone: true
|
||||||
@@ -45,13 +47,19 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
private sortService = inject(SortService);
|
private sortService = inject(SortService);
|
||||||
private pageTitle = inject(PageTitleService);
|
private pageTitle = inject(PageTitleService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
protected overlayPreferenceService = inject(BookCardOverlayPreferenceService);
|
||||||
|
|
||||||
readonly dashboardConfig = this.dashboardConfigService.config;
|
readonly dashboardConfig = this.dashboardConfigService.config;
|
||||||
readonly isBooksLoading = this.bookService.isBooksLoading;
|
readonly isBooksLoading = this.bookService.isBooksLoading;
|
||||||
readonly isLibrariesEmpty = computed(() =>
|
readonly isLibrariesEmpty = computed(() =>
|
||||||
!this.libraryService.isLibrariesLoading() && this.libraryService.libraries().length === 0
|
!this.libraryService.isLibrariesLoading() && this.libraryService.libraries().length === 0
|
||||||
);
|
);
|
||||||
readonly scrollerBooks = computed(() => {
|
|
||||||
|
readonly enabledScrollers = computed(() => {
|
||||||
|
return this.dashboardConfig().scrollers.filter(s => s.enabled);
|
||||||
|
});
|
||||||
|
|
||||||
|
private readonly scrollerBooksMap = computed(() => {
|
||||||
const config = this.dashboardConfig();
|
const config = this.dashboardConfig();
|
||||||
const books = this.bookService.books();
|
const books = this.bookService.books();
|
||||||
const scrollerMap = new Map<string, Book[]>();
|
const scrollerMap = new Map<string, Book[]>();
|
||||||
@@ -70,7 +78,7 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getBooksForScroller(config: ScrollerConfig): Book[] {
|
getBooksForScroller(config: ScrollerConfig): Book[] {
|
||||||
return this.scrollerBooks().get(config.id) ?? [];
|
return this.scrollerBooksMap().get(config.id) ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private getBooksForConfig(config: ScrollerConfig, books: Book[], magicShelves: {id?: number | null; filterJson: string}[]): Book[] {
|
private getBooksForConfig(config: ScrollerConfig, books: Book[], magicShelves: {id?: number | null; filterJson: string}[]): Book[] {
|
||||||
|
|||||||
+1
-2
@@ -1,11 +1,10 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
import {TranslocoDirective} from '@jsverse/transloco';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-library-loading',
|
selector: 'app-library-loading',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TranslocoDirective],
|
imports: [TranslocoDirective],
|
||||||
templateUrl: './library-loading.component.html',
|
templateUrl: './library-loading.component.html',
|
||||||
styleUrl: './library-loading.component.scss'
|
styleUrl: './library-loading.component.scss'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ import {MultiSelect} from 'primeng/multiselect';
|
|||||||
import {AutoComplete} from 'primeng/autocomplete';
|
import {AutoComplete} from 'primeng/autocomplete';
|
||||||
import {EMPTY_CHECK_OPERATORS, MULTI_VALUE_OPERATORS, RELATIVE_DATE_OPERATORS, parseValue, removeNulls, serializeDateRules} from '../service/magic-shelf-utils';
|
import {EMPTY_CHECK_OPERATORS, MULTI_VALUE_OPERATORS, RELATIVE_DATE_OPERATORS, parseValue, removeNulls, serializeDateRules} from '../service/magic-shelf-utils';
|
||||||
import {IconPickerService, IconSelection} from '../../../shared/service/icon-picker.service';
|
import {IconPickerService, IconSelection} from '../../../shared/service/icon-picker.service';
|
||||||
import {CheckboxChangeEvent, CheckboxModule} from "primeng/checkbox";
|
import {CheckboxChangeEvent, Checkbox} from "primeng/checkbox";
|
||||||
import {UserService} from "../../settings/user-management/user.service";
|
import {UserService} from "../../settings/user-management/user.service";
|
||||||
import {IconDisplayComponent} from '../../../shared/components/icon-display/icon-display.component';
|
import {IconDisplayComponent} from '../../../shared/components/icon-display/icon-display.component';
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {BookService} from '../../book/service/book.service';
|
import {BookService} from '../../book/service/book.service';
|
||||||
import {ShelfService} from '../../book/service/shelf.service';
|
import {ShelfService} from '../../book/service/shelf.service';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {TextareaModule} from 'primeng/textarea';
|
import {Textarea} from 'primeng/textarea';
|
||||||
|
|
||||||
export type RuleOperator =
|
export type RuleOperator =
|
||||||
| 'equals'
|
| 'equals'
|
||||||
@@ -238,11 +238,11 @@ const READ_STATUS_KEYS: Record<string, string> = {
|
|||||||
InputNumber,
|
InputNumber,
|
||||||
MultiSelect,
|
MultiSelect,
|
||||||
AutoComplete,
|
AutoComplete,
|
||||||
CheckboxModule,
|
Checkbox,
|
||||||
IconDisplayComponent,
|
IconDisplayComponent,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TextareaModule
|
Textarea
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class MagicShelfComponent implements OnInit {
|
export class MagicShelfComponent implements OnInit {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {HttpTestingController} from '@angular/common/http/testing';
|
|||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||||
|
|
||||||
import {createAuthServiceStub, createQueryClientHarness, flushSignalAndQueryEffects} from '../../../core/testing/query-testing';
|
import {createAuthServiceStub, createQueryClientHarness, flushSignalAndQueryEffects, flushQueryAsync} from '../../../core/testing/query-testing';
|
||||||
import type {Book} from '../../book/model/book.model';
|
import type {Book} from '../../book/model/book.model';
|
||||||
import {AuthService} from '../../../shared/service/auth.service';
|
import {AuthService} from '../../../shared/service/auth.service';
|
||||||
import type {GroupRule} from '../component/magic-shelf-component';
|
import type {GroupRule} from '../component/magic-shelf-component';
|
||||||
@@ -46,12 +46,7 @@ function buildBook(id: number, overrides: Partial<Book> = {}): Book {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function flushShelvesQuery(): Promise<void> {
|
async function flushShelvesQuery(): Promise<void> {
|
||||||
await Promise.resolve();
|
await flushQueryAsync();
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 0));
|
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
await Promise.resolve();
|
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('MagicShelfService', () => {
|
describe('MagicShelfService', () => {
|
||||||
|
|||||||
+4
-3
@@ -1,13 +1,14 @@
|
|||||||
import {Component, inject, Input, OnInit, OnChanges, SimpleChanges} from '@angular/core';
|
import {Component, inject, Input, OnInit, OnChanges, SimpleChanges} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
|
import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import {ProgressSpinnerModule} from 'primeng/progressspinner';
|
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
import {NgClass} from '@angular/common';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-book-reading-sessions',
|
selector: 'app-book-reading-sessions',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TableModule, ProgressSpinnerModule, TranslocoDirective],
|
imports: [
|
||||||
|
NgClass,TableModule, ProgressSpinner, TranslocoDirective],
|
||||||
templateUrl: './book-reading-sessions.component.html',
|
templateUrl: './book-reading-sessions.component.html',
|
||||||
styleUrls: ['./book-reading-sessions.component.scss']
|
styleUrls: ['./book-reading-sessions.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+8
-12
@@ -1,12 +1,10 @@
|
|||||||
import {Component, effect, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, effect, inject, OnDestroy, OnInit} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import {ButtonModule} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {CheckboxModule} from 'primeng/checkbox';
|
import {Checkbox} from 'primeng/checkbox';
|
||||||
import {InputTextModule} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {DialogModule} from 'primeng/dialog';
|
import {Dialog} from 'primeng/dialog';
|
||||||
import {ConfirmDialogModule} from 'primeng/confirmdialog';
|
|
||||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||||
import {PageTitleService} from "../../../../shared/service/page-title.service";
|
import {PageTitleService} from "../../../../shared/service/page-title.service";
|
||||||
import {BookService} from '../../../book/service/book.service';
|
import {BookService} from '../../../book/service/book.service';
|
||||||
@@ -43,15 +41,13 @@ interface TabConfig {
|
|||||||
selector: 'app-metadata-manager',
|
selector: 'app-metadata-manager',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
Tabs,
|
Tabs,
|
||||||
TableModule,
|
TableModule,
|
||||||
ButtonModule,
|
Button,
|
||||||
CheckboxModule,
|
Checkbox,
|
||||||
InputTextModule,
|
InputText,
|
||||||
DialogModule,
|
Dialog,
|
||||||
ConfirmDialogModule,
|
|
||||||
TabList,
|
TabList,
|
||||||
Tab,
|
Tab,
|
||||||
TabPanels,
|
TabPanels,
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import {Component, effect, inject, Input} from '@angular/core';
|
import {Component, effect, inject, Input} from '@angular/core';
|
||||||
import {ToggleSwitchModule} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||||
import {AppSettingKey, MetadataProviderSpecificFields} from '../../../../shared/model/app-settings.model';
|
import {AppSettingKey, MetadataProviderSpecificFields} from '../../../../shared/model/app-settings.model';
|
||||||
@@ -8,7 +8,7 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-provider-field-selector',
|
selector: 'app-metadata-provider-field-selector',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [ToggleSwitchModule, FormsModule, TranslocoDirective],
|
imports: [ToggleSwitch, FormsModule, TranslocoDirective],
|
||||||
templateUrl: './metadata-provider-field-selector.component.html',
|
templateUrl: './metadata-provider-field-selector.component.html',
|
||||||
styleUrl: './metadata-provider-field-selector.component.scss'
|
styleUrl: './metadata-provider-field-selector.component.scss'
|
||||||
})
|
})
|
||||||
|
|||||||
+3
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, effect, inject, OnInit, signal, ViewChild} from '@angular/core';
|
import {Component, computed, effect, inject, OnInit, signal, ViewChild} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
import {FetchedProposal, MetadataTaskService} from '../../../book/service/metadata-task';
|
import {FetchedProposal, MetadataTaskService} from '../../../book/service/metadata-task';
|
||||||
import {BookService} from '../../../book/service/book.service';
|
import {BookService} from '../../../book/service/book.service';
|
||||||
@@ -11,13 +10,15 @@ import {ProgressBar} from 'primeng/progressbar';
|
|||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {MetadataProgressService} from '../../../../shared/service/metadata-progress.service';
|
import {MetadataProgressService} from '../../../../shared/service/metadata-progress.service';
|
||||||
import {MetadataPickerComponent} from '../book-metadata-center/metadata-picker/metadata-picker.component';
|
import {MetadataPickerComponent} from '../book-metadata-center/metadata-picker/metadata-picker.component';
|
||||||
|
import {DecimalPipe} from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-review-dialog-component',
|
selector: 'app-metadata-review-dialog-component',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './metadata-review-dialog-component.html',
|
templateUrl: './metadata-review-dialog-component.html',
|
||||||
styleUrls: ['./metadata-review-dialog-component.scss'],
|
styleUrls: ['./metadata-review-dialog-component.scss'],
|
||||||
imports: [CommonModule, MetadataPickerComponent, ProgressSpinner, Button, Divider, ProgressBar, Tooltip],
|
imports: [
|
||||||
|
DecimalPipe,MetadataPickerComponent, ProgressSpinner, Button, Divider, ProgressBar, Tooltip],
|
||||||
})
|
})
|
||||||
export class MetadataReviewDialogComponent implements OnInit {
|
export class MetadataReviewDialogComponent implements OnInit {
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {of, Subject} from 'rxjs';
|
import {of, Subject} from 'rxjs';
|
||||||
import {debounceTime, switchMap, takeUntil} from 'rxjs/operators';
|
import {debounceTime, switchMap} from 'rxjs/operators';
|
||||||
import {InputTextModule} from 'primeng/inputtext';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {Select} from 'primeng/select';
|
import {Select} from 'primeng/select';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {TooltipModule} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {Paginator} from 'primeng/paginator';
|
import {Paginator} from 'primeng/paginator';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {NotebookService} from '../../service/notebook.service';
|
import {NotebookService} from '../../service/notebook.service';
|
||||||
@@ -14,6 +14,7 @@ import {NotebookEntry, NotebookPage} from '../../model/notebook.model';
|
|||||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||||
import {CoverPlaceholderComponent} from '../../../../shared/components/cover-generator/cover-generator.component';
|
import {CoverPlaceholderComponent} from '../../../../shared/components/cover-generator/cover-generator.component';
|
||||||
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
||||||
|
import {DatePipe} from '@angular/common';
|
||||||
|
|
||||||
interface BookGroup {
|
interface BookGroup {
|
||||||
bookId: number;
|
bookId: number;
|
||||||
@@ -36,12 +37,12 @@ const EMPTY_PAGE: NotebookPage = {
|
|||||||
selector: 'app-notebook',
|
selector: 'app-notebook',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
DatePipe,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
InputTextModule,
|
InputText,
|
||||||
Select,
|
Select,
|
||||||
Button,
|
Button,
|
||||||
TooltipModule,
|
Tooltip,
|
||||||
Paginator,
|
Paginator,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
CoverPlaceholderComponent,
|
CoverPlaceholderComponent,
|
||||||
@@ -49,8 +50,8 @@ const EMPTY_PAGE: NotebookPage = {
|
|||||||
templateUrl: './notebook.component.html',
|
templateUrl: './notebook.component.html',
|
||||||
styleUrls: ['./notebook.component.scss'],
|
styleUrls: ['./notebook.component.scss'],
|
||||||
})
|
})
|
||||||
export class NotebookComponent implements OnInit, OnDestroy {
|
export class NotebookComponent implements OnInit {
|
||||||
private readonly destroy$ = new Subject<void>();
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
private readonly searchSubject = new Subject<void>();
|
private readonly searchSubject = new Subject<void>();
|
||||||
private readonly loadTrigger$ = new Subject<void>();
|
private readonly loadTrigger$ = new Subject<void>();
|
||||||
private readonly bookFilterSubject = new Subject<string>();
|
private readonly bookFilterSubject = new Subject<string>();
|
||||||
@@ -93,7 +94,7 @@ export class NotebookComponent implements OnInit, OnDestroy {
|
|||||||
this.page, this.pageSize, types, this.selectedBookId, this.searchQuery, this.sortDirection
|
this.page, this.pageSize, types, this.selectedBookId, this.searchQuery, this.sortDirection
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
).subscribe(result => {
|
).subscribe(result => {
|
||||||
this.totalEntries = result.page.totalElements;
|
this.totalEntries = result.page.totalElements;
|
||||||
this.groupEntries(result.content);
|
this.groupEntries(result.content);
|
||||||
@@ -102,7 +103,7 @@ export class NotebookComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.searchSubject.pipe(
|
this.searchSubject.pipe(
|
||||||
debounceTime(300),
|
debounceTime(300),
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
).subscribe(() => {
|
).subscribe(() => {
|
||||||
this.page = 0;
|
this.page = 0;
|
||||||
this.first = 0;
|
this.first = 0;
|
||||||
@@ -112,7 +113,7 @@ export class NotebookComponent implements OnInit, OnDestroy {
|
|||||||
this.bookFilterSubject.pipe(
|
this.bookFilterSubject.pipe(
|
||||||
debounceTime(300),
|
debounceTime(300),
|
||||||
switchMap(filter => this.notebookService.getBooksWithAnnotations(filter || undefined)),
|
switchMap(filter => this.notebookService.getBooksWithAnnotations(filter || undefined)),
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
).subscribe(books => {
|
).subscribe(books => {
|
||||||
this.updateBookOptions(books.map(b => ({label: b.bookTitle, value: b.bookId})));
|
this.updateBookOptions(books.map(b => ({label: b.bookTitle, value: b.bookId})));
|
||||||
});
|
});
|
||||||
@@ -121,11 +122,6 @@ export class NotebookComponent implements OnInit, OnDestroy {
|
|||||||
this.loadTrigger$.next();
|
this.loadTrigger$.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
onSearchChange(): void {
|
onSearchChange(): void {
|
||||||
this.searchSubject.next();
|
this.searchSubject.next();
|
||||||
}
|
}
|
||||||
@@ -161,7 +157,7 @@ export class NotebookComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private loadBooks(): void {
|
private loadBooks(): void {
|
||||||
this.notebookService.getBooksWithAnnotations()
|
this.notebookService.getBooksWithAnnotations()
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
.subscribe(books => {
|
.subscribe(books => {
|
||||||
this.bookOptions = books.map(b => ({label: b.bookTitle, value: b.bookId}));
|
this.bookOptions = books.map(b => ({label: b.bookTitle, value: b.bookId}));
|
||||||
});
|
});
|
||||||
@@ -240,7 +236,7 @@ export class NotebookComponent implements OnInit, OnDestroy {
|
|||||||
this.exporting = true;
|
this.exporting = true;
|
||||||
this.notebookService.getExportEntries(
|
this.notebookService.getExportEntries(
|
||||||
types, this.selectedBookId, this.searchQuery, this.sortDirection
|
types, this.selectedBookId, this.searchQuery, this.sortDirection
|
||||||
).pipe(takeUntil(this.destroy$)).subscribe(entries => {
|
).pipe(takeUntilDestroyed(this.destroyRef)).subscribe(entries => {
|
||||||
this.generateMarkdownDownload(entries);
|
this.generateMarkdownDownload(entries);
|
||||||
this.exporting = false;
|
this.exporting = false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Component, ElementRef, inject, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
import {Component, ElementRef, inject, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||||
import {CommonModule, Location} from '@angular/common';
|
import {Location} from '@angular/common';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {from, Observable, of, Subject} from 'rxjs';
|
import {from, Observable, of, Subject} from 'rxjs';
|
||||||
@@ -28,7 +28,6 @@ import {API_CONFIG} from '../../../core/config/api-config';
|
|||||||
selector: 'app-audiobook-player',
|
selector: 'app-audiobook-player',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
Button,
|
Button,
|
||||||
Slider,
|
Slider,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Component, effect, ElementRef, HostListener, inject, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
import { Component, effect, ElementRef, HostListener, inject, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { forkJoin, from, Subject } from 'rxjs';
|
import { forkJoin, from, Subject } from 'rxjs';
|
||||||
import { debounceTime, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
import { debounceTime, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
||||||
import { PageTitleService } from "../../../shared/service/page-title.service";
|
import { PageTitleService } from "../../../shared/service/page-title.service";
|
||||||
@@ -45,7 +44,6 @@ import {
|
|||||||
selector: 'app-cbx-reader',
|
selector: 'app-cbx-reader',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
|
||||||
ProgressSpinner,
|
ProgressSpinner,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
TranslocoPipe,
|
TranslocoPipe,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, EventEmitter, inject, Input, Output, OnChanges, SimpleChanges} from '@angular/core';
|
import {Component, EventEmitter, inject, Input, Output, OnChanges, SimpleChanges} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
||||||
import {ReaderIconComponent} from '../../ebook-reader/shared/icon.component';
|
import {ReaderIconComponent} from '../../ebook-reader/shared/icon.component';
|
||||||
@@ -19,7 +18,7 @@ export interface CbxNoteDialogResult {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cbx-note-dialog',
|
selector: 'app-cbx-note-dialog',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, FormsModule, TranslocoPipe, ReaderIconComponent],
|
imports: [FormsModule, TranslocoPipe, ReaderIconComponent],
|
||||||
templateUrl: './cbx-note-dialog.component.html',
|
templateUrl: './cbx-note-dialog.component.html',
|
||||||
styleUrls: ['./cbx-note-dialog.component.scss']
|
styleUrls: ['./cbx-note-dialog.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, EventEmitter, inject, Output} from '@angular/core';
|
import {Component, EventEmitter, inject, Output} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
||||||
import {ReaderIconComponent} from '../../ebook-reader/shared/icon.component';
|
import {ReaderIconComponent} from '../../ebook-reader/shared/icon.component';
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ interface ShortcutGroup {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cbx-shortcuts-help',
|
selector: 'app-cbx-shortcuts-help',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TranslocoPipe, ReaderIconComponent],
|
imports: [TranslocoPipe, ReaderIconComponent],
|
||||||
templateUrl: './cbx-shortcuts-help.component.html',
|
templateUrl: './cbx-shortcuts-help.component.html',
|
||||||
styleUrls: ['./cbx-shortcuts-help.component.scss']
|
styleUrls: ['./cbx-shortcuts-help.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, inject} from '@angular/core';
|
import {Component, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
||||||
import {Book} from '../../../../book/model/book.model';
|
import {Book} from '../../../../book/model/book.model';
|
||||||
@@ -9,7 +8,7 @@ import {CbxFooterService} from './cbx-footer.service';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cbx-footer',
|
selector: 'app-cbx-footer',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, FormsModule, TranslocoPipe, ReaderIconComponent],
|
imports: [FormsModule, TranslocoPipe, ReaderIconComponent],
|
||||||
templateUrl: './cbx-footer.component.html',
|
templateUrl: './cbx-footer.component.html',
|
||||||
styleUrls: ['./cbx-footer.component.scss']
|
styleUrls: ['./cbx-footer.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ import {Component, inject, Input} from '@angular/core';
|
|||||||
import {TranslocoPipe} from '@jsverse/transloco';
|
import {TranslocoPipe} from '@jsverse/transloco';
|
||||||
import {CbxHeaderService} from './cbx-header.service';
|
import {CbxHeaderService} from './cbx-header.service';
|
||||||
import {ReaderIconComponent} from '../../../ebook-reader';
|
import {ReaderIconComponent} from '../../../ebook-reader';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cbx-header',
|
selector: 'app-cbx-header',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TranslocoPipe, ReaderIconComponent],
|
imports: [TranslocoPipe, ReaderIconComponent],
|
||||||
templateUrl: './cbx-header.component.html',
|
templateUrl: './cbx-header.component.html',
|
||||||
styleUrls: ['./cbx-header.component.scss']
|
styleUrls: ['./cbx-header.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import { Component, inject } from '@angular/core';
|
import { Component, inject } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { TranslocoService, TranslocoPipe } from '@jsverse/transloco';
|
import { TranslocoService, TranslocoPipe } from '@jsverse/transloco';
|
||||||
import {
|
import {
|
||||||
CbxFitMode,
|
CbxFitMode,
|
||||||
@@ -18,7 +17,7 @@ import { CbxQuickSettingsService } from './cbx-quick-settings.service';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cbx-quick-settings',
|
selector: 'app-cbx-quick-settings',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TranslocoPipe, ReaderIconComponent],
|
imports: [TranslocoPipe, ReaderIconComponent],
|
||||||
templateUrl: './cbx-quick-settings.component.html',
|
templateUrl: './cbx-quick-settings.component.html',
|
||||||
styleUrls: ['./cbx-quick-settings.component.scss']
|
styleUrls: ['./cbx-quick-settings.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
||||||
import {CommonModule, DatePipe} from '@angular/common';
|
import {DatePipe} from '@angular/common';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TranslocoPipe} from '@jsverse/transloco';
|
import {TranslocoPipe} from '@jsverse/transloco';
|
||||||
import {CbxSidebarService, CbxSidebarTab} from './cbx-sidebar.service';
|
import {CbxSidebarService, CbxSidebarTab} from './cbx-sidebar.service';
|
||||||
@@ -12,7 +12,7 @@ import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './cbx-sidebar.component.html',
|
templateUrl: './cbx-sidebar.component.html',
|
||||||
styleUrls: ['./cbx-sidebar.component.scss'],
|
styleUrls: ['./cbx-sidebar.component.scss'],
|
||||||
imports: [CommonModule, FormsModule, TranslocoPipe, ReaderIconComponent, DatePipe, CoverPlaceholderComponent]
|
imports: [FormsModule, TranslocoPipe, ReaderIconComponent, DatePipe, CoverPlaceholderComponent]
|
||||||
})
|
})
|
||||||
export class CbxSidebarComponent {
|
export class CbxSidebarComponent {
|
||||||
private readonly sidebarService = inject(CbxSidebarService);
|
private readonly sidebarService = inject(CbxSidebarService);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, Input, OnChanges, OnDestroy, SimpleChanges, ViewChild, ElementRef, AfterViewInit} from '@angular/core';
|
import {Component, Input, OnChanges, OnDestroy, SimpleChanges, ViewChild, ElementRef, AfterViewInit} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {CbxPageSplitOption} from '../../../settings/user-management/user.service';
|
import {CbxPageSplitOption} from '../../../settings/user-management/user.service';
|
||||||
|
|
||||||
export type CanvasSplitState = 'NO_SPLIT' | 'LEFT_PART' | 'RIGHT_PART';
|
export type CanvasSplitState = 'NO_SPLIT' | 'LEFT_PART' | 'RIGHT_PART';
|
||||||
@@ -14,7 +13,7 @@ export type CanvasSplitState = 'NO_SPLIT' | 'LEFT_PART' | 'RIGHT_PART';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-canvas-renderer',
|
selector: 'app-canvas-renderer',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule],
|
imports: [],
|
||||||
template: `
|
template: `
|
||||||
<canvas
|
<canvas
|
||||||
#canvas
|
#canvas
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, EventEmitter, inject, Input, Output} from '@angular/core';
|
import {Component, EventEmitter, inject, Input, Output} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {Book} from '../../../book/model/book.model';
|
import {Book} from '../../../book/model/book.model';
|
||||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||||
@@ -8,7 +7,7 @@ import {CoverPlaceholderComponent} from '../../../../shared/components/cover-gen
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-reader-book-metadata-dialog',
|
selector: 'app-reader-book-metadata-dialog',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TranslocoDirective, CoverPlaceholderComponent],
|
imports: [TranslocoDirective, CoverPlaceholderComponent],
|
||||||
templateUrl: './metadata-dialog.component.html',
|
templateUrl: './metadata-dialog.component.html',
|
||||||
styleUrls: ['./metadata-dialog.component.scss']
|
styleUrls: ['./metadata-dialog.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, EventEmitter, Input, Output, OnChanges, SimpleChanges} from '@angular/core';
|
import {Component, EventEmitter, Input, Output, OnChanges, SimpleChanges} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
|
||||||
import {ReaderIconComponent} from '../shared/icon.component';
|
import {ReaderIconComponent} from '../shared/icon.component';
|
||||||
@@ -21,7 +20,7 @@ export interface NoteDialogResult {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-reader-note-dialog',
|
selector: 'app-reader-note-dialog',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, FormsModule, TranslocoDirective, TranslocoPipe, ReaderIconComponent],
|
imports: [FormsModule, TranslocoDirective, TranslocoPipe, ReaderIconComponent],
|
||||||
templateUrl: './note-dialog.component.html',
|
templateUrl: './note-dialog.component.html',
|
||||||
styleUrls: ['./note-dialog.component.scss']
|
styleUrls: ['./note-dialog.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, EventEmitter, inject, Output} from '@angular/core';
|
import {Component, EventEmitter, inject, Output} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||||
import {ReaderIconComponent} from '../shared/icon.component';
|
import {ReaderIconComponent} from '../shared/icon.component';
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ interface ShortcutGroup {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-ebook-shortcuts-help',
|
selector: 'app-ebook-shortcuts-help',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TranslocoPipe, ReaderIconComponent],
|
imports: [TranslocoPipe, ReaderIconComponent],
|
||||||
templateUrl: './shortcuts-help.component.html',
|
templateUrl: './shortcuts-help.component.html',
|
||||||
styleUrls: ['./shortcuts-help.component.scss']
|
styleUrls: ['./shortcuts-help.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, effect, HostListener, inject, OnInit, signal} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, effect, HostListener, inject, OnInit, signal} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {from, Observable, of, Subject, throwError} from 'rxjs';
|
import {from, Observable, of, Subject, throwError} from 'rxjs';
|
||||||
import {catchError, map, switchMap, takeUntil, tap} from 'rxjs/operators';
|
import {catchError, map, switchMap, takeUntil, tap} from 'rxjs/operators';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
@@ -39,7 +38,6 @@ import {WakeLockService} from '../../../shared/service/wake-lock.service';
|
|||||||
selector: 'app-ebook-reader',
|
selector: 'app-ebook-reader',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
|
||||||
ReaderHeaderComponent,
|
ReaderHeaderComponent,
|
||||||
ReaderSettingsDialogComponent,
|
ReaderSettingsDialogComponent,
|
||||||
ReaderQuickSettingsComponent,
|
ReaderQuickSettingsComponent,
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Subject} from 'rxjs';
|
import {Subject} from 'rxjs';
|
||||||
import {takeUntil, debounceTime, distinctUntilChanged, filter} from 'rxjs/operators';
|
import {debounceTime, distinctUntilChanged, filter} from 'rxjs/operators';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
import {TranslocoDirective} from '@jsverse/transloco';
|
||||||
import {ReaderLeftSidebarService, LeftSidebarTab} from './panel.service';
|
import {ReaderLeftSidebarService, LeftSidebarTab} from './panel.service';
|
||||||
import {BookNoteV2} from '../../../../../shared/service/book-note-v2.service';
|
import {BookNoteV2} from '../../../../../shared/service/book-note-v2.service';
|
||||||
import {ReaderIconComponent} from '../../shared/icon.component';
|
import {ReaderIconComponent} from '../../shared/icon.component';
|
||||||
|
import {DatePipe, DecimalPipe} from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-reader-left-sidebar',
|
selector: 'app-reader-left-sidebar',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './panel.component.html',
|
templateUrl: './panel.component.html',
|
||||||
styleUrls: ['./panel.component.scss'],
|
styleUrls: ['./panel.component.scss'],
|
||||||
imports: [CommonModule, FormsModule, TranslocoDirective, ReaderIconComponent]
|
imports: [
|
||||||
|
DecimalPipe,
|
||||||
|
DatePipe,FormsModule, TranslocoDirective, ReaderIconComponent]
|
||||||
})
|
})
|
||||||
export class ReaderLeftSidebarComponent {
|
export class ReaderLeftSidebarComponent {
|
||||||
private readonly leftSidebarService = inject(ReaderLeftSidebarService);
|
private readonly leftSidebarService = inject(ReaderLeftSidebarService);
|
||||||
private readonly destroyRef = inject(DestroyRef);
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
private readonly destroy$ = new Subject<void>();
|
|
||||||
private closeAnimationTimeout: ReturnType<typeof setTimeout> | null = null;
|
private closeAnimationTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
|
||||||
readonly activeTab = this.leftSidebarService.activeTab;
|
readonly activeTab = this.leftSidebarService.activeTab;
|
||||||
@@ -58,14 +60,12 @@ export class ReaderLeftSidebarComponent {
|
|||||||
debounceTime(500),
|
debounceTime(500),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
filter(query => query.length >= 3 || query.length === 0),
|
filter(query => query.length >= 3 || query.length === 0),
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
)
|
)
|
||||||
.subscribe(query => this.leftSidebarService.search(query));
|
.subscribe(query => this.leftSidebarService.search(query));
|
||||||
|
|
||||||
this.destroyRef.onDestroy(() => {
|
this.destroyRef.onDestroy(() => {
|
||||||
this.clearCloseAnimation();
|
this.clearCloseAnimation();
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
import {TranslocoDirective} from '@jsverse/transloco';
|
||||||
import {TocItem} from 'epubjs';
|
import {TocItem} from 'epubjs';
|
||||||
import {ReaderSidebarService, SidebarTab} from './sidebar.service';
|
import {ReaderSidebarService, SidebarTab} from './sidebar.service';
|
||||||
import {ReaderIconComponent} from '../../shared/icon.component';
|
import {ReaderIconComponent} from '../../shared/icon.component';
|
||||||
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
||||||
|
import {DatePipe, NgTemplateOutlet} from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-reader-sidebar',
|
selector: 'app-reader-sidebar',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './sidebar.component.html',
|
templateUrl: './sidebar.component.html',
|
||||||
styleUrls: ['./sidebar.component.scss'],
|
styleUrls: ['./sidebar.component.scss'],
|
||||||
imports: [CommonModule, FormsModule, TranslocoDirective, ReaderIconComponent, CoverPlaceholderComponent]
|
imports: [
|
||||||
|
DatePipe, NgTemplateOutlet, FormsModule, TranslocoDirective, ReaderIconComponent, CoverPlaceholderComponent]
|
||||||
})
|
})
|
||||||
export class ReaderSidebarComponent {
|
export class ReaderSidebarComponent {
|
||||||
private readonly sidebarService = inject(ReaderSidebarService);
|
private readonly sidebarService = inject(ReaderSidebarService);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
export type ReaderIconName =
|
export type ReaderIconName =
|
||||||
| 'menu'
|
| 'menu'
|
||||||
@@ -211,7 +210,7 @@ const ICONS: Record<ReaderIconName, IconPath[]> = {
|
|||||||
selector: 'app-reader-icon',
|
selector: 'app-reader-icon',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
imports: [CommonModule],
|
imports: [],
|
||||||
template: `
|
template: `
|
||||||
<svg
|
<svg
|
||||||
[attr.width]="size"
|
[attr.width]="size"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
import {TranslocoDirective} from '@jsverse/transloco';
|
||||||
import {ReaderIconComponent} from './icon.component';
|
import {ReaderIconComponent} from './icon.component';
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ export interface TextSelectionAction {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-text-selection-popup',
|
selector: 'app-text-selection-popup',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TranslocoDirective, ReaderIconComponent],
|
imports: [TranslocoDirective, ReaderIconComponent],
|
||||||
templateUrl: './selection-popup.component.html',
|
templateUrl: './selection-popup.component.html',
|
||||||
styleUrls: ['./selection-popup.component.scss']
|
styleUrls: ['./selection-popup.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+5
-9
@@ -77,14 +77,10 @@
|
|||||||
<p>{{ t('noSeriesFound') }}</p>
|
<p>{{ t('noSeriesFound') }}</p>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<virtual-scroller
|
<cdk-virtual-scroll-viewport autosize [minBufferPx]="600" [maxBufferPx]="1200" class="virtual-scroller">
|
||||||
#scroll
|
<div *cdkVirtualFor="let row of seriesRows(); let rowIdx = index" class="series-grid"
|
||||||
[items]="seriesList"
|
[ngStyle]="{'grid-template-columns': 'repeat(' + gridColumns() + ', 1fr)'}">
|
||||||
class="virtual-scroller">
|
@for (series of row; track series.seriesName) {
|
||||||
<div class="series-grid"
|
|
||||||
#container
|
|
||||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
|
||||||
@for (series of scroll.viewPortItems; track series.seriesName) {
|
|
||||||
<div class="virtual-scroller-item"
|
<div class="virtual-scroller-item"
|
||||||
[ngStyle]="{width: cardWidth + 'px', height: cardHeight + 'px'}"
|
[ngStyle]="{width: cardWidth + 'px', height: cardHeight + 'px'}"
|
||||||
[style.--card-scale]="seriesScaleService.scaleFactor()">
|
[style.--card-scale]="seriesScaleService.scaleFactor()">
|
||||||
@@ -95,7 +91,7 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</virtual-scroller>
|
</cdk-virtual-scroll-viewport>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -108,7 +108,6 @@
|
|||||||
height: calc(100dvh - 12.5rem);
|
height: calc(100dvh - 12.5rem);
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow-y: auto;
|
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
scrollbar-color: var(--primary-color) rgb(20 20 30 / 50%);
|
scrollbar-color: var(--primary-color) rgb(20 20 30 / 50%);
|
||||||
|
|
||||||
|
|||||||
+40
-3
@@ -1,4 +1,5 @@
|
|||||||
import {Component, HostListener, computed, inject, OnInit, signal} from '@angular/core';
|
import {Component, DestroyRef, HostListener, computed, inject, OnInit, signal, ViewChild} from '@angular/core';
|
||||||
|
import {computeGridColumns} from '../../../../shared/util/viewport.util';
|
||||||
import {NgStyle} from '@angular/common';
|
import {NgStyle} from '@angular/common';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||||
@@ -7,10 +8,12 @@ import {Select} from 'primeng/select';
|
|||||||
import {Slider} from 'primeng/slider';
|
import {Slider} from 'primeng/slider';
|
||||||
import {Popover} from 'primeng/popover';
|
import {Popover} from 'primeng/popover';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {VirtualScrollerModule} from '@iharbeck/ngx-virtual-scroller';
|
import {CdkVirtualScrollViewport, CdkVirtualForOf} from '@angular/cdk/scrolling';
|
||||||
|
import {CdkAutoSizeVirtualScroll} from '@angular/cdk-experimental/scrolling';
|
||||||
import {SeriesDataService} from '../../service/series-data.service';
|
import {SeriesDataService} from '../../service/series-data.service';
|
||||||
import {SeriesSummary} from '../../model/series.model';
|
import {SeriesSummary} from '../../model/series.model';
|
||||||
import {SeriesCardComponent} from '../series-card/series-card.component';
|
import {SeriesCardComponent} from '../series-card/series-card.component';
|
||||||
|
import {chunk} from '../../../../shared/util/array.util';
|
||||||
import {BookService} from '../../../book/service/book.service';
|
import {BookService} from '../../../book/service/book.service';
|
||||||
import {ReadStatus} from '../../../book/model/book.model';
|
import {ReadStatus} from '../../../book/model/book.model';
|
||||||
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
import {PageTitleService} from '../../../../shared/service/page-title.service';
|
||||||
@@ -42,7 +45,9 @@ interface SortOption {
|
|||||||
Popover,
|
Popover,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
SeriesCardComponent,
|
SeriesCardComponent,
|
||||||
VirtualScrollerModule
|
CdkVirtualScrollViewport,
|
||||||
|
CdkVirtualForOf,
|
||||||
|
CdkAutoSizeVirtualScroll,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class SeriesBrowserComponent implements OnInit {
|
export class SeriesBrowserComponent implements OnInit {
|
||||||
@@ -51,14 +56,35 @@ export class SeriesBrowserComponent implements OnInit {
|
|||||||
private static readonly BASE_HEIGHT = 285;
|
private static readonly BASE_HEIGHT = 285;
|
||||||
private static readonly MOBILE_BASE_WIDTH = 180;
|
private static readonly MOBILE_BASE_WIDTH = 180;
|
||||||
private static readonly MOBILE_BASE_HEIGHT = 250;
|
private static readonly MOBILE_BASE_HEIGHT = 250;
|
||||||
|
private static readonly GRID_GAP = 20;
|
||||||
|
|
||||||
private seriesDataService = inject(SeriesDataService);
|
private seriesDataService = inject(SeriesDataService);
|
||||||
private bookService = inject(BookService);
|
private bookService = inject(BookService);
|
||||||
private pageTitle = inject(PageTitleService);
|
private pageTitle = inject(PageTitleService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
protected seriesScaleService = inject(SeriesScalePreferenceService);
|
protected seriesScaleService = inject(SeriesScalePreferenceService);
|
||||||
|
|
||||||
|
virtualScroller: CdkVirtualScrollViewport | undefined;
|
||||||
|
|
||||||
|
@ViewChild(CdkVirtualScrollViewport)
|
||||||
|
set scrollViewport(vp: CdkVirtualScrollViewport | undefined) {
|
||||||
|
this.virtualScroller = vp;
|
||||||
|
this.viewportResizeObserver?.disconnect();
|
||||||
|
if (vp) {
|
||||||
|
const el = vp.elementRef.nativeElement as HTMLElement;
|
||||||
|
this.viewportWidth.set(el.clientWidth);
|
||||||
|
this.viewportResizeObserver = new ResizeObserver(entries => {
|
||||||
|
this.viewportWidth.set(entries[0]?.contentRect.width ?? el.clientWidth);
|
||||||
|
});
|
||||||
|
this.viewportResizeObserver.observe(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly viewportWidth = signal(0);
|
||||||
|
private viewportResizeObserver: ResizeObserver | undefined;
|
||||||
|
|
||||||
readonly isBooksLoading = this.bookService.isBooksLoading;
|
readonly isBooksLoading = this.bookService.isBooksLoading;
|
||||||
private readonly searchTerm = signal('');
|
private readonly searchTerm = signal('');
|
||||||
private readonly statusFilter = signal('all');
|
private readonly statusFilter = signal('all');
|
||||||
@@ -109,6 +135,14 @@ export class SeriesBrowserComponent implements OnInit {
|
|||||||
return `${this.cardWidth}px`;
|
return `${this.cardWidth}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly gridColumns = computed(() => {
|
||||||
|
return computeGridColumns(this.viewportWidth(), this.cardWidth || 230, SeriesBrowserComponent.GRID_GAP);
|
||||||
|
});
|
||||||
|
|
||||||
|
readonly seriesRows = computed(() => {
|
||||||
|
return chunk(this.filteredSeries(), this.gridColumns());
|
||||||
|
});
|
||||||
|
|
||||||
get searchValue(): string {
|
get searchValue(): string {
|
||||||
return this.searchTerm();
|
return this.searchTerm();
|
||||||
}
|
}
|
||||||
@@ -123,6 +157,7 @@ export class SeriesBrowserComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.pageTitle.setPageTitle(this.t.translate('seriesBrowser.pageTitle'));
|
this.pageTitle.setPageTitle(this.t.translate('seriesBrowser.pageTitle'));
|
||||||
|
this.destroyRef.onDestroy(() => this.viewportResizeObserver?.disconnect());
|
||||||
|
|
||||||
this.filterOptions = [
|
this.filterOptions = [
|
||||||
{label: this.t.translate('seriesBrowser.filters.all'), value: 'all'},
|
{label: this.t.translate('seriesBrowser.filters.all'), value: 'all'},
|
||||||
@@ -142,6 +177,8 @@ export class SeriesBrowserComponent implements OnInit {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onSearchChange(value: string): void {
|
onSearchChange(value: string): void {
|
||||||
this.searchTerm.set(value);
|
this.searchTerm.set(value);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -1,3 +1,8 @@
|
|||||||
|
:host {
|
||||||
|
content-visibility: auto;
|
||||||
|
contain-intrinsic-size: auto 230px 285px;
|
||||||
|
}
|
||||||
|
|
||||||
.series-card {
|
.series-card {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Component, inject, OnInit, OnDestroy} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {TableLazyLoadEvent, TableModule} from 'primeng/table';
|
import {TableLazyLoadEvent, TableModule} from 'primeng/table';
|
||||||
import {Select} from 'primeng/select';
|
import {Select} from 'primeng/select';
|
||||||
@@ -9,6 +9,7 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
|||||||
import {Subscription, interval} from 'rxjs';
|
import {Subscription, interval} from 'rxjs';
|
||||||
import {AuditLog, AuditLogService} from './audit-log.service';
|
import {AuditLog, AuditLogService} from './audit-log.service';
|
||||||
import {TagColor, TagComponent} from '../../../shared/components/tag/tag.component';
|
import {TagColor, TagComponent} from '../../../shared/components/tag/tag.component';
|
||||||
|
import {DatePipe} from '@angular/common';
|
||||||
|
|
||||||
const ACTION_COLOR_GROUPS: [TagColor, string[]][] = [
|
const ACTION_COLOR_GROUPS: [TagColor, string[]][] = [
|
||||||
['red', ['USER_DELETED', 'LIBRARY_DELETED', 'BOOK_DELETED', 'SHELF_DELETED', 'MAGIC_SHELF_DELETED', 'EMAIL_PROVIDER_DELETED', 'OPDS_USER_DELETED', 'AUTHOR_DELETED']],
|
['red', ['USER_DELETED', 'LIBRARY_DELETED', 'BOOK_DELETED', 'SHELF_DELETED', 'MAGIC_SHELF_DELETED', 'EMAIL_PROVIDER_DELETED', 'OPDS_USER_DELETED', 'AUTHOR_DELETED']],
|
||||||
@@ -40,11 +41,12 @@ interface UsernameOption {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-audit-logs',
|
selector: 'app-audit-logs',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, TableModule, Select, DatePicker, FormsModule, TranslocoDirective, TagComponent],
|
imports: [
|
||||||
|
DatePipe,TableModule, Select, DatePicker, FormsModule, TranslocoDirective, TagComponent],
|
||||||
templateUrl: './audit-logs.component.html',
|
templateUrl: './audit-logs.component.html',
|
||||||
styleUrl: './audit-logs.component.scss'
|
styleUrl: './audit-logs.component.scss'
|
||||||
})
|
})
|
||||||
export class AuditLogsComponent implements OnInit, OnDestroy {
|
export class AuditLogsComponent implements OnInit {
|
||||||
private readonly auditLogService = inject(AuditLogService);
|
private readonly auditLogService = inject(AuditLogService);
|
||||||
private readonly route = inject(ActivatedRoute);
|
private readonly route = inject(ActivatedRoute);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
@@ -59,6 +61,7 @@ export class AuditLogsComponent implements OnInit, OnDestroy {
|
|||||||
expandedRows = new Set<number>();
|
expandedRows = new Set<number>();
|
||||||
autoRefresh = false;
|
autoRefresh = false;
|
||||||
private autoRefreshSub?: Subscription;
|
private autoRefreshSub?: Subscription;
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
usernameOptions: UsernameOption[] = [{label: 'All Users', value: ''}];
|
usernameOptions: UsernameOption[] = [{label: 'All Users', value: ''}];
|
||||||
|
|
||||||
@@ -111,10 +114,6 @@ export class AuditLogsComponent implements OnInit, OnDestroy {
|
|||||||
this.loadLogs();
|
this.loadLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.autoRefreshSub?.unsubscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
loadUsernames(): void {
|
loadUsernames(): void {
|
||||||
this.auditLogService.getDistinctUsernames().subscribe({
|
this.auditLogService.getDistinctUsernames().subscribe({
|
||||||
next: (usernames) => {
|
next: (usernames) => {
|
||||||
@@ -168,7 +167,9 @@ export class AuditLogsComponent implements OnInit, OnDestroy {
|
|||||||
toggleAutoRefresh(): void {
|
toggleAutoRefresh(): void {
|
||||||
this.autoRefresh = !this.autoRefresh;
|
this.autoRefresh = !this.autoRefresh;
|
||||||
if (this.autoRefresh) {
|
if (this.autoRefresh) {
|
||||||
this.autoRefreshSub = interval(10000).subscribe(() => this.loadLogs(false));
|
this.autoRefreshSub = interval(10000)
|
||||||
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
|
.subscribe(() => this.loadLogs(false));
|
||||||
} else {
|
} else {
|
||||||
this.autoRefreshSub?.unsubscribe();
|
this.autoRefreshSub?.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
import {take} from 'rxjs/operators';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {CustomFontService} from '../../../shared/service/custom-font.service';
|
import {CustomFontService} from '../../../shared/service/custom-font.service';
|
||||||
@@ -12,11 +13,13 @@ import {FontUploadDialogComponent} from './font-upload-dialog/font-upload-dialog
|
|||||||
import {Skeleton} from 'primeng/skeleton';
|
import {Skeleton} from 'primeng/skeleton';
|
||||||
import {DialogSize, DialogStyle} from '../../../shared/services/dialog-launcher.service';
|
import {DialogSize, DialogStyle} from '../../../shared/services/dialog-launcher.service';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
import {DatePipe} from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-custom-fonts',
|
selector: 'app-custom-fonts',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, Button, ConfirmDialog, Tooltip, Skeleton, TranslocoDirective],
|
imports: [
|
||||||
|
DatePipe,Button, ConfirmDialog, Tooltip, Skeleton, TranslocoDirective],
|
||||||
templateUrl: './custom-fonts.component.html',
|
templateUrl: './custom-fonts.component.html',
|
||||||
styleUrls: ['./custom-fonts.component.scss'],
|
styleUrls: ['./custom-fonts.component.scss'],
|
||||||
providers: [ConfirmationService, DialogService]
|
providers: [ConfirmationService, DialogService]
|
||||||
@@ -34,6 +37,7 @@ export class CustomFontsComponent implements OnInit {
|
|||||||
private confirmationService = inject(ConfirmationService);
|
private confirmationService = inject(ConfirmationService);
|
||||||
private dialogService = inject(DialogService);
|
private dialogService = inject(DialogService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.loadFonts();
|
this.loadFonts();
|
||||||
@@ -82,7 +86,7 @@ export class CustomFontsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.uploadDialogRef) {
|
if (this.uploadDialogRef) {
|
||||||
this.uploadDialogRef.onClose.subscribe((font: CustomFont | null) => {
|
this.uploadDialogRef.onClose.pipe(take(1), takeUntilDestroyed(this.destroyRef)).subscribe((font: CustomFont | null) => {
|
||||||
if (font) {
|
if (font) {
|
||||||
this.customFonts.push(font);
|
this.customFonts.push(font);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, ViewChild, ElementRef, OnDestroy, inject} from '@angular/core';
|
import {Component, ViewChild, ElementRef, OnDestroy, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {CustomFontService} from '../../../../shared/service/custom-font.service';
|
import {CustomFontService} from '../../../../shared/service/custom-font.service';
|
||||||
@@ -12,7 +11,7 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-font-upload-dialog',
|
selector: 'app-font-upload-dialog',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, Button, InputText, FormsModule, TranslocoDirective, TranslocoPipe],
|
imports: [Button, InputText, FormsModule, TranslocoDirective, TranslocoPipe],
|
||||||
templateUrl: './font-upload-dialog.component.html',
|
templateUrl: './font-upload-dialog.component.html',
|
||||||
styleUrls: ['./font-upload-dialog.component.scss']
|
styleUrls: ['./font-upload-dialog.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ import {FormsModule} from '@angular/forms';
|
|||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {ToastModule} from 'primeng/toast';
|
import {Toast} from 'primeng/toast';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
|
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
|
||||||
import {UserService} from '../../../user-management/user.service';
|
import {UserService} from '../../../user-management/user.service';
|
||||||
@@ -18,7 +18,7 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
InputText,
|
InputText,
|
||||||
ToggleSwitch,
|
ToggleSwitch,
|
||||||
Button,
|
Button,
|
||||||
ToastModule,
|
Toast,
|
||||||
ExternalDocLinkComponent,
|
ExternalDocLinkComponent,
|
||||||
TranslocoDirective
|
TranslocoDirective
|
||||||
],
|
],
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ import {SettingsHelperService} from '../../../../../shared/service/settings-help
|
|||||||
import {AppSettingKey, KoboSettings} from '../../../../../shared/model/app-settings.model';
|
import {AppSettingKey, KoboSettings} from '../../../../../shared/model/app-settings.model';
|
||||||
import {ShelfService} from '../../../../book/service/shelf.service';
|
import {ShelfService} from '../../../../book/service/shelf.service';
|
||||||
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
|
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
|
||||||
import {ToastModule} from 'primeng/toast';
|
import {Toast} from 'primeng/toast';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -24,7 +24,7 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './kobo-sync-settings-component.html',
|
templateUrl: './kobo-sync-settings-component.html',
|
||||||
styleUrl: './kobo-sync-settings-component.scss',
|
styleUrl: './kobo-sync-settings-component.scss',
|
||||||
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent, ToastModule, TranslocoDirective],
|
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent, Toast, TranslocoDirective],
|
||||||
providers: [MessageService, ConfirmationService]
|
providers: [MessageService, ConfirmationService]
|
||||||
})
|
})
|
||||||
export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ import {FormsModule} from '@angular/forms';
|
|||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {ToastModule} from 'primeng/toast';
|
import {Toast} from 'primeng/toast';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {KoreaderService} from './koreader.service';
|
import {KoreaderService} from './koreader.service';
|
||||||
import {UserService} from '../../../user-management/user.service';
|
import {UserService} from '../../../user-management/user.service';
|
||||||
@@ -19,7 +19,7 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
|||||||
InputText,
|
InputText,
|
||||||
ToggleSwitch,
|
ToggleSwitch,
|
||||||
Button,
|
Button,
|
||||||
ToastModule,
|
Toast,
|
||||||
ExternalDocLinkComponent,
|
ExternalDocLinkComponent,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TranslocoPipe
|
TranslocoPipe
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@ import {MessageService} from 'primeng/api';
|
|||||||
import {AppSettingKey} from '../../../../shared/model/app-settings.model';
|
import {AppSettingKey} from '../../../../shared/model/app-settings.model';
|
||||||
import {Select} from 'primeng/select';
|
import {Select} from 'primeng/select';
|
||||||
import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component';
|
import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component';
|
||||||
import { ToggleSwitchModule } from 'primeng/toggleswitch';
|
import { ToggleSwitch } from 'primeng/toggleswitch';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -21,7 +21,7 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
Select,
|
Select,
|
||||||
ExternalDocLinkComponent,
|
ExternalDocLinkComponent,
|
||||||
ToggleSwitchModule,
|
ToggleSwitch,
|
||||||
TranslocoDirective
|
TranslocoDirective
|
||||||
],
|
],
|
||||||
templateUrl: './metadata-provider-settings.component.html',
|
templateUrl: './metadata-provider-settings.component.html',
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
import {Component, effect, inject} from '@angular/core';
|
import {Component, effect, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {AccordionModule} from 'primeng/accordion';
|
import {Accordion, AccordionPanel, AccordionHeader, AccordionContent} from 'primeng/accordion';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
@@ -19,7 +18,7 @@ import {SidecarService} from '../../metadata/service/sidecar.service';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-library-metadata-settings-component',
|
selector: 'app-library-metadata-settings-component',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, FormsModule, MetadataAdvancedFetchOptionsComponent, AccordionModule, ExternalDocLinkComponent, Button, Tooltip, TranslocoDirective],
|
imports: [FormsModule, MetadataAdvancedFetchOptionsComponent, Accordion, AccordionPanel, AccordionHeader, AccordionContent, ExternalDocLinkComponent, Button, Tooltip, TranslocoDirective],
|
||||||
templateUrl: './library-metadata-settings.component.html',
|
templateUrl: './library-metadata-settings.component.html',
|
||||||
styleUrls: ['./library-metadata-settings.component.scss']
|
styleUrls: ['./library-metadata-settings.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+2
-2
@@ -4,14 +4,14 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
|||||||
import {clampStripMaxWidthPercent} from '../../../readers/cbx-reader/core/cbx-reader-storage';
|
import {clampStripMaxWidthPercent} from '../../../readers/cbx-reader/core/cbx-reader-storage';
|
||||||
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, UserSettings} from '../../user-management/user.service';
|
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, UserSettings} from '../../user-management/user.service';
|
||||||
import {ReaderPreferencesService} from '../reader-preferences.service';
|
import {ReaderPreferencesService} from '../reader-preferences.service';
|
||||||
import {TooltipModule} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cbx-reader-preferences-component',
|
selector: 'app-cbx-reader-preferences-component',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TooltipModule
|
Tooltip
|
||||||
],
|
],
|
||||||
templateUrl: './cbx-reader-preferences-component.html',
|
templateUrl: './cbx-reader-preferences-component.html',
|
||||||
styleUrl: './cbx-reader-preferences-component.scss'
|
styleUrl: './cbx-reader-preferences-component.scss'
|
||||||
|
|||||||
+2
-2
@@ -3,14 +3,14 @@ import {FormsModule} from '@angular/forms';
|
|||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
import {TranslocoDirective} from '@jsverse/transloco';
|
||||||
import {ReaderPreferencesService} from '../reader-preferences.service';
|
import {ReaderPreferencesService} from '../reader-preferences.service';
|
||||||
import {PageSpread, UserSettings} from '../../user-management/user.service';
|
import {PageSpread, UserSettings} from '../../user-management/user.service';
|
||||||
import {TooltipModule} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-pdf-reader-preferences-component',
|
selector: 'app-pdf-reader-preferences-component',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TooltipModule
|
Tooltip
|
||||||
],
|
],
|
||||||
templateUrl: './pdf-reader-preferences-component.html',
|
templateUrl: './pdf-reader-preferences-component.html',
|
||||||
styleUrl: './pdf-reader-preferences-component.scss'
|
styleUrl: './pdf-reader-preferences-component.scss'
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import {Component, effect, inject} from '@angular/core';
|
import {Component, effect, inject} from '@angular/core';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
|
|
||||||
import {TooltipModule} from 'primeng/tooltip';
|
|
||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
import {TranslocoDirective} from '@jsverse/transloco';
|
||||||
import {UserService, UserSettings} from '../user-management/user.service';
|
import {UserService, UserSettings} from '../user-management/user.service';
|
||||||
import {EpubReaderPreferencesComponent} from './epub-reader-preferences/epub-reader-preferences-component';
|
import {EpubReaderPreferencesComponent} from './epub-reader-preferences/epub-reader-preferences-component';
|
||||||
@@ -16,7 +16,7 @@ import {LocalSettingsComponent} from "./local-settings/local-settings.component"
|
|||||||
templateUrl: './reader-preferences.component.html',
|
templateUrl: './reader-preferences.component.html',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
styleUrls: ['./reader-preferences.component.scss'],
|
styleUrls: ['./reader-preferences.component.scss'],
|
||||||
imports: [FormsModule, TooltipModule, TranslocoDirective, EpubReaderPreferencesComponent, PdfReaderPreferencesComponent, CbxReaderPreferencesComponent, CustomFontsComponent, SettingsApplicationModeComponent, LocalSettingsComponent]
|
imports: [FormsModule, TranslocoDirective, EpubReaderPreferencesComponent, PdfReaderPreferencesComponent, CbxReaderPreferencesComponent, CustomFontsComponent, SettingsApplicationModeComponent, LocalSettingsComponent]
|
||||||
})
|
})
|
||||||
export class ReaderPreferences {
|
export class ReaderPreferences {
|
||||||
private readonly userService = inject(UserService);
|
private readonly userService = inject(UserService);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {ProgressBar} from 'primeng/progressbar';
|
import {ProgressBar} from 'primeng/progressbar';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
@@ -19,17 +18,19 @@ import {
|
|||||||
TaskType
|
TaskType
|
||||||
} from './task.service';
|
} from './task.service';
|
||||||
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
|
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
|
||||||
import {finalize, forkJoin, Subscription} from 'rxjs';
|
import {finalize, forkJoin} from 'rxjs';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||||
|
import {NgClass} from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-task-management',
|
selector: 'app-task-management',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
NgClass,
|
||||||
Button,
|
Button,
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
Select,
|
Select,
|
||||||
@@ -43,18 +44,18 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
|||||||
templateUrl: './task-management.component.html',
|
templateUrl: './task-management.component.html',
|
||||||
styleUrl: './task-management.component.scss'
|
styleUrl: './task-management.component.scss'
|
||||||
})
|
})
|
||||||
export class TaskManagementComponent implements OnInit, OnDestroy {
|
export class TaskManagementComponent implements OnInit {
|
||||||
// Services
|
// Services
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private taskService = inject(TaskService);
|
private taskService = inject(TaskService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
// State
|
// State
|
||||||
taskInfos: TaskInfo[] = [];
|
taskInfos: TaskInfo[] = [];
|
||||||
taskHistories = new Map<string, TaskHistory>();
|
taskHistories = new Map<string, TaskHistory>();
|
||||||
loading = false;
|
loading = false;
|
||||||
executingTasks = new Set<string>();
|
executingTasks = new Set<string>();
|
||||||
private subscription?: Subscription;
|
|
||||||
|
|
||||||
// Metadata Replace Options
|
// Metadata Replace Options
|
||||||
metadataReplaceOptions = [
|
metadataReplaceOptions = [
|
||||||
@@ -92,10 +93,6 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
|
|||||||
this.subscribeToTaskProgress();
|
this.subscribeToTaskProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.subscription?.unsubscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Data Loading & Real-time Updates
|
// Data Loading & Real-time Updates
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -124,11 +121,13 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private subscribeToTaskProgress(): void {
|
private subscribeToTaskProgress(): void {
|
||||||
this.subscription = this.taskService.taskProgress$.subscribe(progress => {
|
this.taskService.taskProgress$
|
||||||
if (progress) {
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
this.updateTaskWithProgress(progress);
|
.subscribe(progress => {
|
||||||
}
|
if (progress) {
|
||||||
});
|
this.updateTaskWithProgress(progress);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateTaskWithProgress(progress: TaskProgressPayload): void {
|
private updateTaskWithProgress(progress: TaskProgressPayload): void {
|
||||||
|
|||||||
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, EventEmitter, inject, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
|
import {Component, computed, EventEmitter, inject, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {Select} from 'primeng/select';
|
import {Select} from 'primeng/select';
|
||||||
@@ -20,7 +19,6 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
|||||||
selector: 'app-content-restrictions-editor',
|
selector: 'app-content-restrictions-editor',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
Button,
|
Button,
|
||||||
Select,
|
Select,
|
||||||
|
|||||||
+8
-4
@@ -1,8 +1,9 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
|
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||||
import {Checkbox} from 'primeng/checkbox';
|
import {Checkbox} from 'primeng/checkbox';
|
||||||
import {MultiSelectModule} from 'primeng/multiselect';
|
import {MultiSelect} from 'primeng/multiselect';
|
||||||
import {Library} from '../../../book/model/library.model';
|
import {Library} from '../../../book/model/library.model';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {LibraryService} from '../../../book/service/library.service';
|
import {LibraryService} from '../../../book/service/library.service';
|
||||||
@@ -21,7 +22,7 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
MultiSelectModule,
|
MultiSelect,
|
||||||
Button,
|
Button,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
TranslocoPipe
|
TranslocoPipe
|
||||||
@@ -38,6 +39,7 @@ export class CreateUserDialogComponent implements OnInit {
|
|||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private ref = inject(DynamicDialogRef);
|
private ref = inject(DynamicDialogRef);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
get libraries(): Library[] {
|
get libraries(): Library[] {
|
||||||
return this.libraryService.libraries();
|
return this.libraryService.libraries();
|
||||||
@@ -81,7 +83,9 @@ export class CreateUserDialogComponent implements OnInit {
|
|||||||
permissionBulkResetBookReadStatus: [false],
|
permissionBulkResetBookReadStatus: [false],
|
||||||
}, {validators: [passwordMatchValidator('password', 'confirmPassword')]});
|
}, {validators: [passwordMatchValidator('password', 'confirmPassword')]});
|
||||||
|
|
||||||
this.userForm.get('permissionAdmin')?.valueChanges.subscribe((isAdmin: boolean) => {
|
this.userForm.get('permissionAdmin')?.valueChanges
|
||||||
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
|
.subscribe((isAdmin: boolean) => {
|
||||||
const controls = this.userForm.controls;
|
const controls = this.userForm.controls;
|
||||||
Object.keys(controls).forEach(key => {
|
Object.keys(controls).forEach(key => {
|
||||||
if (key !== 'permissionAdmin' && key.startsWith('permission')) {
|
if (key !== 'permissionAdmin' && key.startsWith('permission')) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {TestBed} from '@angular/core/testing';
|
|||||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||||
|
|
||||||
import {AuthService} from '../../../shared/service/auth.service';
|
import {AuthService} from '../../../shared/service/auth.service';
|
||||||
import {createAuthServiceStub, createQueryClientHarness, flushSignalAndQueryEffects} from '../../../core/testing/query-testing';
|
import {createAuthServiceStub, createQueryClientHarness, flushSignalAndQueryEffects, flushQueryAsync} from '../../../core/testing/query-testing';
|
||||||
import {CURRENT_USER_QUERY_KEY} from './user-query-keys';
|
import {CURRENT_USER_QUERY_KEY} from './user-query-keys';
|
||||||
import {type User, type UserSettings, UserService} from './user.service';
|
import {type User, type UserSettings, UserService} from './user.service';
|
||||||
|
|
||||||
@@ -117,12 +117,7 @@ function buildUser(overrides: BuildUserOverrides = {}): User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function flushCurrentUserQuery(): Promise<void> {
|
async function flushCurrentUserQuery(): Promise<void> {
|
||||||
await Promise.resolve();
|
await flushQueryAsync();
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 0));
|
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
await Promise.resolve();
|
|
||||||
flushSignalAndQueryEffects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('UserService', () => {
|
describe('UserService', () => {
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,7 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import {ToastModule} from 'primeng/toast';
|
|
||||||
import {ViewPreferencesComponent} from './view-preferences/view-preferences.component';
|
import {ViewPreferencesComponent} from './view-preferences/view-preferences.component';
|
||||||
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/sidebar-sorting-preferences.component';
|
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/sidebar-sorting-preferences.component';
|
||||||
import {MetaCenterViewModeComponent} from './meta-center-view-mode/meta-center-view-mode-component';
|
import {MetaCenterViewModeComponent} from './meta-center-view-mode/meta-center-view-mode-component';
|
||||||
@@ -17,7 +17,6 @@ import {LocalStorageService} from '../../../shared/service/local-storage.service
|
|||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
TableModule,
|
TableModule,
|
||||||
ToastModule,
|
|
||||||
ViewPreferencesComponent,
|
ViewPreferencesComponent,
|
||||||
SidebarSortingPreferencesComponent,
|
SidebarSortingPreferencesComponent,
|
||||||
MetaCenterViewModeComponent,
|
MetaCenterViewModeComponent,
|
||||||
|
|||||||
+1
-2
@@ -10,7 +10,7 @@ import {ShelfService} from '../../../book/service/shelf.service';
|
|||||||
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
||||||
import {Subject} from 'rxjs';
|
import {Subject} from 'rxjs';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {ToastModule} from 'primeng/toast';
|
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {takeUntil} from 'rxjs/operators';
|
import {takeUntil} from 'rxjs/operators';
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
@@ -28,7 +28,6 @@ import {CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray} from
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
Button,
|
Button,
|
||||||
TableModule,
|
TableModule,
|
||||||
ToastModule,
|
|
||||||
Tooltip,
|
Tooltip,
|
||||||
ToggleSwitch,
|
ToggleSwitch,
|
||||||
TranslocoDirective,
|
TranslocoDirective,
|
||||||
|
|||||||
+22
-10
@@ -1,5 +1,4 @@
|
|||||||
import {Component, effect, inject, OnDestroy} from '@angular/core';
|
import {Component, DestroyRef, effect, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {BehaviorSubject, Observable} from 'rxjs';
|
import {BehaviorSubject, Observable} from 'rxjs';
|
||||||
import {Chart, ChartConfiguration, ChartData, TooltipModel} from 'chart.js';
|
import {Chart, ChartConfiguration, ChartData, TooltipModel} from 'chart.js';
|
||||||
@@ -7,6 +6,7 @@ import {LibraryFilterService} from '../../service/library-filter.service';
|
|||||||
import {BookService} from '../../../../../book/service/book.service';
|
import {BookService} from '../../../../../book/service/book.service';
|
||||||
import {Book, ReadStatus} from '../../../../../book/model/book.model';
|
import {Book, ReadStatus} from '../../../../../book/model/book.model';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
import {AsyncPipe} from '@angular/common';
|
||||||
|
|
||||||
interface AuthorStats {
|
interface AuthorStats {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -40,14 +40,16 @@ const COMPLETION_COLORS = {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-author-universe-chart',
|
selector: 'app-author-universe-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, BaseChartDirective, TranslocoDirective],
|
imports: [
|
||||||
|
AsyncPipe, BaseChartDirective, TranslocoDirective],
|
||||||
templateUrl: './author-universe-chart.component.html',
|
templateUrl: './author-universe-chart.component.html',
|
||||||
styleUrls: ['./author-universe-chart.component.scss']
|
styleUrls: ['./author-universe-chart.component.scss']
|
||||||
})
|
})
|
||||||
export class AuthorUniverseChartComponent implements OnDestroy {
|
export class AuthorUniverseChartComponent {
|
||||||
private readonly bookService = inject(BookService);
|
private readonly bookService = inject(BookService);
|
||||||
private readonly libraryFilterService = inject(LibraryFilterService);
|
private readonly libraryFilterService = inject(LibraryFilterService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
private readonly syncChartEffect = effect(() => {
|
private readonly syncChartEffect = effect(() => {
|
||||||
if (this.bookService.isBooksLoading()) {
|
if (this.bookService.isBooksLoading()) {
|
||||||
return;
|
return;
|
||||||
@@ -71,10 +73,9 @@ export class AuthorUniverseChartComponent implements OnDestroy {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.initChartOptions();
|
this.initChartOptions();
|
||||||
}
|
this.destroyRef.onDestroy(() => {
|
||||||
|
document.getElementById('author-chart-tooltip')?.remove();
|
||||||
ngOnDestroy(): void {
|
});
|
||||||
document.getElementById('author-chart-tooltip')?.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private initChartOptions(): void {
|
private initChartOptions(): void {
|
||||||
@@ -485,6 +486,15 @@ export class AuthorUniverseChartComponent implements OnDestroy {
|
|||||||
return insights;
|
return insights;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private escapeHtml(value: string): string {
|
||||||
|
return value
|
||||||
|
.replaceAll('&', '&')
|
||||||
|
.replaceAll('<', '<')
|
||||||
|
.replaceAll('>', '>')
|
||||||
|
.replaceAll('"', '"')
|
||||||
|
.replaceAll("'", ''');
|
||||||
|
}
|
||||||
|
|
||||||
private handleExternalTooltip(context: { chart: Chart; tooltip: TooltipModel<'bubble'> }): void {
|
private handleExternalTooltip(context: { chart: Chart; tooltip: TooltipModel<'bubble'> }): void {
|
||||||
const {chart, tooltip} = context;
|
const {chart, tooltip} = context;
|
||||||
let tooltipEl = document.getElementById('author-chart-tooltip');
|
let tooltipEl = document.getElementById('author-chart-tooltip');
|
||||||
@@ -529,8 +539,9 @@ export class AuthorUniverseChartComponent implements OnDestroy {
|
|||||||
? `${stats.avgRating.toFixed(2)} \u2605`
|
? `${stats.avgRating.toFixed(2)} \u2605`
|
||||||
: this.t.translate('statsLibrary.authorUniverse.tooltipNoRatings');
|
: this.t.translate('statsLibrary.authorUniverse.tooltipNoRatings');
|
||||||
|
|
||||||
|
const safeGenres = this.escapeHtml(stats.categories.slice(0, 3).join(', '));
|
||||||
const categoriesHtml = stats.categories.length > 0
|
const categoriesHtml = stats.categories.length > 0
|
||||||
? `<div style="color:rgba(255,255,255,0.9);font-size:12px;line-height:1.6">${this.t.translate('statsLibrary.authorUniverse.tooltipGenres', {genres: stats.categories.slice(0, 3).join(', ')})}</div>`
|
? `<div style="color:rgba(255,255,255,0.9);font-size:12px;line-height:1.6">${this.t.translate('statsLibrary.authorUniverse.tooltipGenres', {genres: safeGenres})}</div>`
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
const booksLine = this.t.translate('statsLibrary.authorUniverse.tooltipBooks', {count: stats.bookCount});
|
const booksLine = this.t.translate('statsLibrary.authorUniverse.tooltipBooks', {count: stats.bookCount});
|
||||||
@@ -538,8 +549,9 @@ export class AuthorUniverseChartComponent implements OnDestroy {
|
|||||||
const ratingLine = this.t.translate('statsLibrary.authorUniverse.tooltipAvgRating', {rating: ratingText});
|
const ratingLine = this.t.translate('statsLibrary.authorUniverse.tooltipAvgRating', {rating: ratingText});
|
||||||
const readLine = this.t.translate('statsLibrary.authorUniverse.tooltipRead', {read: stats.readCount, total: stats.bookCount, percent: Math.round(stats.completionRate)});
|
const readLine = this.t.translate('statsLibrary.authorUniverse.tooltipRead', {read: stats.readCount, total: stats.bookCount, percent: Math.round(stats.completionRate)});
|
||||||
|
|
||||||
|
const safeName = this.escapeHtml(stats.name);
|
||||||
tooltipEl.innerHTML = `
|
tooltipEl.innerHTML = `
|
||||||
<div style="color:#fff;font-size:14px;font-weight:700;margin-bottom:6px">${stats.name}</div>
|
<div style="color:#fff;font-size:14px;font-weight:700;margin-bottom:6px">${safeName}</div>
|
||||||
<div style="color:rgba(255,255,255,0.9);font-size:12px;line-height:1.6">${booksLine}</div>
|
<div style="color:rgba(255,255,255,0.9);font-size:12px;line-height:1.6">${booksLine}</div>
|
||||||
<div style="color:rgba(255,255,255,0.9);font-size:12px;line-height:1.6">${pagesLine}</div>
|
<div style="color:rgba(255,255,255,0.9);font-size:12px;line-height:1.6">${pagesLine}</div>
|
||||||
<div style="color:rgba(255,255,255,0.9);font-size:12px;line-height:1.6">${ratingLine}</div>
|
<div style="color:rgba(255,255,255,0.9);font-size:12px;line-height:1.6">${ratingLine}</div>
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, inject} from '@angular/core';
|
import {Component, computed, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||||
import {LibraryFilterService} from '../../service/library-filter.service';
|
import {LibraryFilterService} from '../../service/library-filter.service';
|
||||||
@@ -27,7 +26,7 @@ const FORMAT_COLORS: Record<string, string> = {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-book-formats-chart',
|
selector: 'app-book-formats-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, BaseChartDirective, TranslocoDirective],
|
imports: [BaseChartDirective, TranslocoDirective],
|
||||||
templateUrl: './book-formats-chart.component.html',
|
templateUrl: './book-formats-chart.component.html',
|
||||||
styleUrls: ['./book-formats-chart.component.scss']
|
styleUrls: ['./book-formats-chart.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, inject} from '@angular/core';
|
import {Component, computed, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||||
import {LibraryFilterService} from '../../service/library-filter.service';
|
import {LibraryFilterService} from '../../service/library-filter.service';
|
||||||
@@ -129,7 +128,7 @@ const LANGUAGE_NAMES: Record<string, string> = {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-language-chart',
|
selector: 'app-language-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, BaseChartDirective, TranslocoDirective],
|
imports: [BaseChartDirective, TranslocoDirective],
|
||||||
templateUrl: './language-chart.component.html',
|
templateUrl: './language-chart.component.html',
|
||||||
styleUrls: ['./language-chart.component.scss']
|
styleUrls: ['./language-chart.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, inject} from '@angular/core';
|
import {Component, computed, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||||
import {LibraryFilterService} from '../../service/library-filter.service';
|
import {LibraryFilterService} from '../../service/library-filter.service';
|
||||||
@@ -28,7 +27,7 @@ const SCORE_RANGE_DEFS: { key: ScoreRangeKey; min: number; max: number; color: s
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-score-chart',
|
selector: 'app-metadata-score-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, BaseChartDirective, TranslocoDirective],
|
imports: [BaseChartDirective, TranslocoDirective],
|
||||||
templateUrl: './metadata-score-chart.component.html',
|
templateUrl: './metadata-score-chart.component.html',
|
||||||
styleUrls: ['./metadata-score-chart.component.scss']
|
styleUrls: ['./metadata-score-chart.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, inject} from '@angular/core';
|
import {Component, computed, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||||
import {LibraryFilterService} from '../../service/library-filter.service';
|
import {LibraryFilterService} from '../../service/library-filter.service';
|
||||||
@@ -35,7 +34,7 @@ const PAGE_RANGES: PageRange[] = [
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-count-chart',
|
selector: 'app-page-count-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, BaseChartDirective, TranslocoDirective],
|
imports: [BaseChartDirective, TranslocoDirective],
|
||||||
templateUrl: './page-count-chart.component.html',
|
templateUrl: './page-count-chart.component.html',
|
||||||
styleUrls: ['./page-count-chart.component.scss']
|
styleUrls: ['./page-count-chart.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, inject} from '@angular/core';
|
import {Component, computed, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||||
import {LibraryFilterService} from '../../service/library-filter.service';
|
import {LibraryFilterService} from '../../service/library-filter.service';
|
||||||
@@ -52,7 +51,7 @@ const DECADE_COLORS: Record<string, string> = {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-publication-timeline-chart',
|
selector: 'app-publication-timeline-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, BaseChartDirective, TranslocoDirective],
|
imports: [BaseChartDirective, TranslocoDirective],
|
||||||
templateUrl: './publication-timeline-chart.component.html',
|
templateUrl: './publication-timeline-chart.component.html',
|
||||||
styleUrls: ['./publication-timeline-chart.component.scss']
|
styleUrls: ['./publication-timeline-chart.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, inject} from '@angular/core';
|
import {Component, computed, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||||
import {LibraryFilterService} from '../../service/library-filter.service';
|
import {LibraryFilterService} from '../../service/library-filter.service';
|
||||||
@@ -30,7 +29,7 @@ type TrendChartData = ChartData<'line', number[], string>;
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-publication-trend-chart',
|
selector: 'app-publication-trend-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, BaseChartDirective, TranslocoDirective],
|
imports: [BaseChartDirective, TranslocoDirective],
|
||||||
templateUrl: './publication-trend-chart.component.html',
|
templateUrl: './publication-trend-chart.component.html',
|
||||||
styleUrls: ['./publication-trend-chart.component.scss']
|
styleUrls: ['./publication-trend-chart.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, inject} from '@angular/core';
|
import {Component, computed, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||||
import {LibraryFilterService} from '../../service/library-filter.service';
|
import {LibraryFilterService} from '../../service/library-filter.service';
|
||||||
@@ -36,7 +35,7 @@ type JourneyChartData = ChartData<'line', number[], string>;
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-reading-journey-chart',
|
selector: 'app-reading-journey-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, BaseChartDirective, TranslocoDirective],
|
imports: [BaseChartDirective, TranslocoDirective],
|
||||||
templateUrl: './reading-journey-chart.component.html',
|
templateUrl: './reading-journey-chart.component.html',
|
||||||
styleUrls: ['./reading-journey-chart.component.scss']
|
styleUrls: ['./reading-journey-chart.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
+4
-2
@@ -1,5 +1,4 @@
|
|||||||
import {Component, effect, inject, Input, OnInit} from '@angular/core';
|
import {Component, effect, inject, Input, OnInit} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {BaseChartDirective} from 'ng2-charts';
|
import {BaseChartDirective} from 'ng2-charts';
|
||||||
import {ChartConfiguration, ChartData, TooltipItem} from 'chart.js';
|
import {ChartConfiguration, ChartData, TooltipItem} from 'chart.js';
|
||||||
@@ -9,6 +8,7 @@ import {LibraryFilterService} from '../../service/library-filter.service';
|
|||||||
import {BookService} from '../../../../../book/service/book.service';
|
import {BookService} from '../../../../../book/service/book.service';
|
||||||
import {Book, ReadStatus} from '../../../../../book/model/book.model';
|
import {Book, ReadStatus} from '../../../../../book/model/book.model';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
import {NgClass, AsyncPipe} from '@angular/common';
|
||||||
|
|
||||||
interface ItemStats {
|
interface ItemStats {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -74,7 +74,9 @@ const READ_STATUS_ORDER: ReadStatus[] = [
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-top-items-chart',
|
selector: 'app-top-items-chart',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, FormsModule, BaseChartDirective, Select, TranslocoDirective],
|
imports: [
|
||||||
|
AsyncPipe,
|
||||||
|
NgClass,FormsModule, BaseChartDirective, Select, TranslocoDirective],
|
||||||
templateUrl: './top-items-chart.component.html',
|
templateUrl: './top-items-chart.component.html',
|
||||||
styleUrls: ['./top-items-chart.component.scss']
|
styleUrls: ['./top-items-chart.component.scss']
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, computed, inject} from '@angular/core';
|
import {Component, computed, inject} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {CdkDragDrop, DragDropModule, moveItemInArray} from '@angular/cdk/drag-drop';
|
import {CdkDragDrop, DragDropModule, moveItemInArray} from '@angular/cdk/drag-drop';
|
||||||
import {Select} from 'primeng/select';
|
import {Select} from 'primeng/select';
|
||||||
@@ -30,7 +29,6 @@ interface ChartConfig {
|
|||||||
selector: 'app-library-stats',
|
selector: 'app-library-stats',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
Select,
|
Select,
|
||||||
DragDropModule,
|
DragDropModule,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user