perf(frontend): optimize initial bundle size with lazy-loaded dialogs and localized chart providers (#1110)
This commit is contained in:
@@ -895,8 +895,8 @@ export class BookBrowserComponent implements AfterViewInit {
|
||||
});
|
||||
}
|
||||
|
||||
openShelfAssigner(): void {
|
||||
this.dynamicDialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks());
|
||||
async openShelfAssigner() {
|
||||
this.dynamicDialogRef = await this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks());
|
||||
if (this.dynamicDialogRef) {
|
||||
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(result => {
|
||||
if (result?.assigned) {
|
||||
@@ -906,8 +906,8 @@ export class BookBrowserComponent implements AfterViewInit {
|
||||
}
|
||||
}
|
||||
|
||||
lockUnlockMetadata(): void {
|
||||
this.dynamicDialogRef = this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks());
|
||||
async lockUnlockMetadata() {
|
||||
this.dynamicDialogRef = await this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks());
|
||||
if (this.dynamicDialogRef) {
|
||||
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||
this.bookSelectionService.deselectAll();
|
||||
@@ -924,12 +924,12 @@ export class BookBrowserComponent implements AfterViewInit {
|
||||
}).subscribe();
|
||||
}
|
||||
|
||||
fetchMetadata(): void {
|
||||
this.dialogHelperService.openMetadataRefreshDialog(this.selectedBooks());
|
||||
async fetchMetadata() {
|
||||
await this.dialogHelperService.openMetadataRefreshDialog(this.selectedBooks());
|
||||
}
|
||||
|
||||
bulkEditMetadata(): void {
|
||||
this.dynamicDialogRef = this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks());
|
||||
async bulkEditMetadata() {
|
||||
this.dynamicDialogRef = await this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks());
|
||||
if (this.dynamicDialogRef) {
|
||||
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||
this.bookSelectionService.deselectAll();
|
||||
@@ -937,8 +937,8 @@ export class BookBrowserComponent implements AfterViewInit {
|
||||
}
|
||||
}
|
||||
|
||||
multiBookEditMetadata(): void {
|
||||
this.dynamicDialogRef = this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks());
|
||||
async multiBookEditMetadata() {
|
||||
this.dynamicDialogRef = await this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks());
|
||||
if (this.dynamicDialogRef) {
|
||||
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||
this.bookSelectionService.deselectAll();
|
||||
@@ -1028,11 +1028,11 @@ export class BookBrowserComponent implements AfterViewInit {
|
||||
});
|
||||
}
|
||||
|
||||
moveFiles(): void {
|
||||
this.dialogHelperService.openFileMoverDialog(this.selectedBooks());
|
||||
async moveFiles() {
|
||||
await this.dialogHelperService.openFileMoverDialog(this.selectedBooks());
|
||||
}
|
||||
|
||||
attachFilesToBook(): void {
|
||||
async attachFilesToBook() {
|
||||
const selectedBookIds = Array.from(this.selectedBooks());
|
||||
const sourceBooks = this.books().filter(book =>
|
||||
selectedBookIds.includes(book.id)
|
||||
@@ -1058,7 +1058,7 @@ export class BookBrowserComponent implements AfterViewInit {
|
||||
return;
|
||||
}
|
||||
|
||||
this.dynamicDialogRef = this.dialogHelperService.openBulkBookFileAttacherDialog(sourceBooks);
|
||||
this.dynamicDialogRef = await this.dialogHelperService.openBulkBookFileAttacherDialog(sourceBooks);
|
||||
if (this.dynamicDialogRef) {
|
||||
this.dynamicDialogRef.onClose.pipe(take(1)).subscribe(result => {
|
||||
if (result?.success) {
|
||||
|
||||
+5
-5
@@ -187,11 +187,11 @@ describe('BookCardComponent', () => {
|
||||
confirm: vi.fn(),
|
||||
};
|
||||
bookDialogHelperService = {
|
||||
openShelfAssignerDialog: vi.fn(),
|
||||
openBookDetailsDialog: vi.fn(),
|
||||
openCustomSendDialog: vi.fn(),
|
||||
openMetadataRefreshDialog: vi.fn(),
|
||||
openFileMoverDialog: vi.fn(),
|
||||
openShelfAssignerDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openBookDetailsDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openCustomSendDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openMetadataRefreshDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openFileMoverDialog: vi.fn(() => Promise.resolve(null)),
|
||||
};
|
||||
bookNavigationService = {
|
||||
availableBookIds: vi.fn(() => []),
|
||||
|
||||
+6
-6
@@ -419,7 +419,7 @@ export class BookCardComponent {
|
||||
{
|
||||
label: this.t.translate('book.card.menu.customSend'),
|
||||
icon: 'pi pi-envelope',
|
||||
command: () => this.bookDialogHelperService.openCustomSendDialog(this.book())
|
||||
command: () => void this.bookDialogHelperService.openCustomSendDialog(this.book()).catch(() => undefined)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -452,7 +452,7 @@ export class BookCardComponent {
|
||||
{
|
||||
label: this.t.translate('book.card.menu.customFetch'),
|
||||
icon: 'pi pi-sync',
|
||||
command: () => this.bookDialogHelperService.openMetadataRefreshDialog(new Set([this.book().id])),
|
||||
command: () => void this.bookDialogHelperService.openMetadataRefreshDialog(new Set([this.book().id])).catch(() => undefined),
|
||||
},
|
||||
{
|
||||
label: this.t.translate('book.card.menu.regenerateCover'),
|
||||
@@ -505,7 +505,7 @@ export class BookCardComponent {
|
||||
moreActions.push({
|
||||
label: this.t.translate('book.card.menu.organizeFile'),
|
||||
icon: 'pi pi-arrows-h',
|
||||
command: () => this.bookDialogHelperService.openFileMoverDialog(new Set([this.book().id]))
|
||||
command: () => void this.bookDialogHelperService.openFileMoverDialog(new Set([this.book().id])).catch(() => undefined)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ export class BookCardComponent {
|
||||
}
|
||||
|
||||
private openShelfDialog(): void {
|
||||
this.bookDialogHelperService.openShelfAssignerDialog(this.book(), null);
|
||||
void this.bookDialogHelperService.openShelfAssignerDialog(this.book(), null).catch(() => undefined);
|
||||
}
|
||||
|
||||
openSeriesInfo(): void {
|
||||
@@ -610,7 +610,7 @@ export class BookCardComponent {
|
||||
}
|
||||
}
|
||||
|
||||
openBookInfo(book: Book): void {
|
||||
async openBookInfo(book: Book) {
|
||||
const allBookIds = this.bookNavigationService.availableBookIds();
|
||||
if (allBookIds.length > 0) {
|
||||
this.bookNavigationService.setNavigationContext(allBookIds, book.id);
|
||||
@@ -621,7 +621,7 @@ export class BookCardComponent {
|
||||
queryParams: {tab: 'view'}
|
||||
});
|
||||
} else {
|
||||
this.bookDialogHelperService.openBookDetailsDialog(book.id);
|
||||
await this.bookDialogHelperService.openBookDetailsDialog(book.id).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-8
@@ -6,11 +6,15 @@ import {BookDialogHelperService} from './book-dialog-helper.service';
|
||||
|
||||
describe('BookDialogHelperService', () => {
|
||||
let service: BookDialogHelperService;
|
||||
let dialogLauncherService: {openDialog: ReturnType<typeof vi.fn>};
|
||||
let dialogLauncherService: {
|
||||
openDialog: ReturnType<typeof vi.fn>,
|
||||
launchLazyDialog: ReturnType<typeof vi.fn>
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
dialogLauncherService = {
|
||||
openDialog: vi.fn(() => ({id: 'dialog-ref'})),
|
||||
openDialog: vi.fn().mockResolvedValue({id: 'dialog-ref'}),
|
||||
launchLazyDialog: vi.fn((fn) => fn()),
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
@@ -27,8 +31,8 @@ describe('BookDialogHelperService', () => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
it('opens the book details dialog with the expected payload', () => {
|
||||
const dialogRef = service.openBookDetailsDialog(42);
|
||||
it('opens the book details dialog with the expected payload', async () => {
|
||||
const dialogRef = await service.openBookDetailsDialog(42);
|
||||
|
||||
expect(dialogLauncherService.openDialog).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
@@ -40,17 +44,17 @@ describe('BookDialogHelperService', () => {
|
||||
expect(dialogRef).toEqual({id: 'dialog-ref'});
|
||||
});
|
||||
|
||||
it('returns null instead of opening the shelf assigner when no inputs are provided', () => {
|
||||
const dialogRef = service.openShelfAssignerDialog(null, null);
|
||||
it('returns null instead of opening the shelf assigner when no inputs are provided', async () => {
|
||||
const dialogRef = await service.openShelfAssignerDialog(null, null);
|
||||
|
||||
expect(dialogRef).toBeNull();
|
||||
expect(dialogLauncherService.openDialog).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('opens the bulk file attacher with the provided source books', () => {
|
||||
it('opens the bulk file attacher with the provided source books', async () => {
|
||||
const sourceBooks = [{id: 1}, {id: 2}] as never[];
|
||||
|
||||
service.openBulkBookFileAttacherDialog(sourceBooks);
|
||||
await service.openBulkBookFileAttacherDialog(sourceBooks);
|
||||
|
||||
expect(dialogLauncherService.openDialog).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
|
||||
+174
-141
@@ -1,23 +1,8 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {DialogLauncherService, DialogSize, DialogStyle} from '../../../../shared/services/dialog-launcher.service';
|
||||
import {ShelfAssignerComponent} from '../shelf-assigner/shelf-assigner.component';
|
||||
import {LockUnlockMetadataDialogComponent} from './lock-unlock-metadata-dialog/lock-unlock-metadata-dialog.component';
|
||||
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {BulkMetadataUpdateComponent} from '../../../metadata/component/bulk-metadata-update/bulk-metadata-update-component';
|
||||
import {MultiBookMetadataEditorComponent} from '../../../metadata/component/multi-book-metadata-editor/multi-book-metadata-editor-component';
|
||||
import {MultiBookMetadataFetchComponent} from '../../../metadata/component/multi-book-metadata-fetch/multi-book-metadata-fetch-component';
|
||||
import {FileMoverComponent} from '../../../../shared/components/file-mover/file-mover-component';
|
||||
import {ShelfCreatorComponent} from '../shelf-creator/shelf-creator.component';
|
||||
import {BookSenderComponent} from '../book-sender/book-sender.component';
|
||||
import {BookMetadataCenterComponent} from '../../../metadata/component/book-metadata-center/book-metadata-center.component';
|
||||
import {CoverSearchComponent} from '../../../metadata/component/cover-search/cover-search.component';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {AdditionalFileUploaderComponent} from '../additional-file-uploader/additional-file-uploader.component';
|
||||
import {BookFileAttacherComponent} from '../book-file-attacher/book-file-attacher.component';
|
||||
import {AddPhysicalBookDialogComponent} from '../add-physical-book-dialog/add-physical-book-dialog.component';
|
||||
import {BulkIsbnImportDialogComponent} from '../bulk-isbn-import-dialog/bulk-isbn-import-dialog.component';
|
||||
import {DuplicateMergerComponent} from '../duplicate-merger/duplicate-merger.component';
|
||||
|
||||
interface MetadataRefreshDialogContext {
|
||||
metadataRefreshType: MetadataRefreshType;
|
||||
@@ -34,180 +19,228 @@ export class BookDialogHelperService {
|
||||
return this.dialogLauncherService.openDialog(component, options);
|
||||
}
|
||||
|
||||
openBookDetailsDialog(bookId: number): DynamicDialogRef | null {
|
||||
return this.openDialog(BookMetadataCenterComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `book-details-dialog ${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookId: bookId,
|
||||
},
|
||||
async openBookDetailsDialog(bookId: number): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {BookMetadataCenterComponent} = await import('../../../metadata/component/book-metadata-center/book-metadata-center.component');
|
||||
return this.openDialog(BookMetadataCenterComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `book-details-dialog ${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookId: bookId,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openShelfAssignerDialog(book: Book | null, bookIds: Set<number> | null): DynamicDialogRef | null {
|
||||
const data: { isMultiBooks: boolean; book?: Book; bookIds?: Set<number> } = {
|
||||
isMultiBooks: false
|
||||
};
|
||||
if (book !== null) {
|
||||
data.book = book;
|
||||
} else if (bookIds !== null) {
|
||||
data.isMultiBooks = true;
|
||||
data.bookIds = bookIds;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return this.openDialog(ShelfAssignerComponent, {
|
||||
showHeader: false,
|
||||
data: data,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
async openShelfAssignerDialog(book: Book | null, bookIds: Set<number> | null): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const data: { isMultiBooks: boolean; book?: Book; bookIds?: Set<number> } = {
|
||||
isMultiBooks: false
|
||||
};
|
||||
if (book !== null) {
|
||||
data.book = book;
|
||||
} else if (bookIds !== null) {
|
||||
data.isMultiBooks = true;
|
||||
data.bookIds = bookIds;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
const {ShelfAssignerComponent} = await import('../shelf-assigner/shelf-assigner.component');
|
||||
return this.openDialog(ShelfAssignerComponent, {
|
||||
showHeader: false,
|
||||
data: data,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openShelfCreatorDialog(): DynamicDialogRef {
|
||||
return this.openDialog(ShelfCreatorComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
})!;
|
||||
}
|
||||
|
||||
openLockUnlockMetadataDialog(bookIds: Set<number>): DynamicDialogRef | null {
|
||||
return this.openDialog(LockUnlockMetadataDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookIds: Array.from(bookIds),
|
||||
},
|
||||
async openShelfCreatorDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {ShelfCreatorComponent} = await import('../shelf-creator/shelf-creator.component');
|
||||
return this.openDialog(ShelfCreatorComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openMetadataRefreshDialog(bookIds: Set<number>): DynamicDialogRef | null {
|
||||
async openLockUnlockMetadataDialog(bookIds: Set<number>): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {LockUnlockMetadataDialogComponent} = await import('./lock-unlock-metadata-dialog/lock-unlock-metadata-dialog.component');
|
||||
return this.openDialog(LockUnlockMetadataDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookIds: Array.from(bookIds),
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async openMetadataRefreshDialog(bookIds: Set<number>): Promise<DynamicDialogRef | null> {
|
||||
return this.openMetadataRefreshDialogWithContext({
|
||||
metadataRefreshType: MetadataRefreshType.BOOKS,
|
||||
bookIds: Array.from(bookIds)
|
||||
});
|
||||
}
|
||||
|
||||
openMetadataRefreshDialogWithContext(context: MetadataRefreshDialogContext): DynamicDialogRef | null {
|
||||
return this.openDialog(MultiBookMetadataFetchComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookIds: context.bookIds ?? [],
|
||||
libraryId: context.libraryId,
|
||||
metadataRefreshType: context.metadataRefreshType,
|
||||
},
|
||||
async openMetadataRefreshDialogWithContext(context: MetadataRefreshDialogContext): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {MultiBookMetadataFetchComponent} = await import('../../../metadata/component/multi-book-metadata-fetch/multi-book-metadata-fetch-component');
|
||||
return this.openDialog(MultiBookMetadataFetchComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookIds: context.bookIds ?? [],
|
||||
libraryId: context.libraryId,
|
||||
metadataRefreshType: context.metadataRefreshType,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openBulkMetadataEditDialog(bookIds: Set<number>): DynamicDialogRef | null {
|
||||
return this.openDialog(BulkMetadataUpdateComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookIds: Array.from(bookIds),
|
||||
},
|
||||
async openBulkMetadataEditDialog(bookIds: Set<number>): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {BulkMetadataUpdateComponent} = await import('../../../metadata/component/bulk-metadata-update/bulk-metadata-update-component');
|
||||
return this.openDialog(BulkMetadataUpdateComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookIds: Array.from(bookIds),
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openMultibookMetadataEditorDialog(bookIds: Set<number>): DynamicDialogRef | null {
|
||||
return this.openDialog(MultiBookMetadataEditorComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookIds: Array.from(bookIds),
|
||||
},
|
||||
async openMultibookMetadataEditorDialog(bookIds: Set<number>): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {MultiBookMetadataEditorComponent} = await import('../../../metadata/component/multi-book-metadata-editor/multi-book-metadata-editor-component');
|
||||
return this.openDialog(MultiBookMetadataEditorComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookIds: Array.from(bookIds),
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openFileMoverDialog(bookIds: Set<number>): DynamicDialogRef | null {
|
||||
return this.openDialog(FileMoverComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
maximizable: true,
|
||||
data: {
|
||||
bookIds: Array.from(bookIds),
|
||||
},
|
||||
async openFileMoverDialog(bookIds: Set<number>): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {FileMoverComponent} = await import('../../../../shared/components/file-mover/file-mover-component');
|
||||
return this.openDialog(FileMoverComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
maximizable: true,
|
||||
data: {
|
||||
bookIds: Array.from(bookIds),
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openCustomSendDialog(book: Book): DynamicDialogRef | null {
|
||||
return this.openDialog(BookSenderComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
book: book,
|
||||
},
|
||||
async openCustomSendDialog(book: Book): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {BookSenderComponent} = await import('../book-sender/book-sender.component');
|
||||
return this.openDialog(BookSenderComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
book: book,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openCoverSearchDialog(bookId: number, coverType?: 'ebook' | 'audiobook'): DynamicDialogRef | null {
|
||||
return this.openDialog(CoverSearchComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookId: bookId,
|
||||
coverType: coverType,
|
||||
},
|
||||
async openCoverSearchDialog(bookId: number, coverType?: 'ebook' | 'audiobook'): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {CoverSearchComponent} = await import('../../../metadata/component/cover-search/cover-search.component');
|
||||
return this.openDialog(CoverSearchComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
bookId: bookId,
|
||||
coverType: coverType,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openAdditionalFileUploaderDialog(book: Book): DynamicDialogRef | null {
|
||||
return this.openDialog(AdditionalFileUploaderComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
book: book,
|
||||
},
|
||||
async openAdditionalFileUploaderDialog(book: Book): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {AdditionalFileUploaderComponent} = await import('../additional-file-uploader/additional-file-uploader.component');
|
||||
return this.openDialog(AdditionalFileUploaderComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
book: book,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openBookFileAttacherDialog(sourceBook: Book): DynamicDialogRef | null {
|
||||
return this.openDialog(BookFileAttacherComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
sourceBook: sourceBook,
|
||||
},
|
||||
async openBookFileAttacherDialog(sourceBook: Book): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {BookFileAttacherComponent} = await import('../book-file-attacher/book-file-attacher.component');
|
||||
return this.openDialog(BookFileAttacherComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
sourceBook: sourceBook,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openBulkBookFileAttacherDialog(sourceBooks: Book[]): DynamicDialogRef | null {
|
||||
return this.openDialog(BookFileAttacherComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
sourceBooks: sourceBooks,
|
||||
},
|
||||
async openBulkBookFileAttacherDialog(sourceBooks: Book[]): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {BookFileAttacherComponent} = await import('../book-file-attacher/book-file-attacher.component');
|
||||
return this.openDialog(BookFileAttacherComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
sourceBooks: sourceBooks,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openDuplicateMergerDialog(libraryId: number): DynamicDialogRef | null {
|
||||
return this.openDialog(DuplicateMergerComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
libraryId: libraryId,
|
||||
},
|
||||
async openDuplicateMergerDialog(libraryId: number): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {DuplicateMergerComponent} = await import('../duplicate-merger/duplicate-merger.component');
|
||||
return this.openDialog(DuplicateMergerComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
libraryId: libraryId,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openAddPhysicalBookDialog(libraryId?: number): DynamicDialogRef | null {
|
||||
return this.openDialog(AddPhysicalBookDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
libraryId: libraryId,
|
||||
},
|
||||
async openAddPhysicalBookDialog(libraryId?: number): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {AddPhysicalBookDialogComponent} = await import('../add-physical-book-dialog/add-physical-book-dialog.component');
|
||||
return this.openDialog(AddPhysicalBookDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
libraryId: libraryId,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openBulkIsbnImportDialog(libraryId?: number): DynamicDialogRef | null {
|
||||
return this.openDialog(BulkIsbnImportDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
libraryId: libraryId,
|
||||
},
|
||||
async openBulkIsbnImportDialog(libraryId?: number): Promise<DynamicDialogRef | null> {
|
||||
return this.dialogLauncherService.launchLazyDialog(async () => {
|
||||
const {BulkIsbnImportDialogComponent} = await import('../bulk-isbn-import-dialog/bulk-isbn-import-dialog.component');
|
||||
return this.openDialog(BulkIsbnImportDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
libraryId: libraryId,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,8 +684,8 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
});
|
||||
}
|
||||
|
||||
openShelfAssigner(): void {
|
||||
this.dialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks());
|
||||
async openShelfAssigner() {
|
||||
this.dialogRef = await this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks());
|
||||
if (this.dialogRef) {
|
||||
this.dialogRef.onClose.pipe(take(1)).subscribe(result => {
|
||||
if (result?.assigned) {
|
||||
@@ -695,8 +695,8 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
}
|
||||
}
|
||||
|
||||
lockUnlockMetadata(): void {
|
||||
this.dialogRef = this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks());
|
||||
async lockUnlockMetadata() {
|
||||
this.dialogRef = await this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks());
|
||||
if (this.dialogRef) {
|
||||
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||
this.deselectAllBooks();
|
||||
@@ -713,12 +713,12 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
}).subscribe();
|
||||
}
|
||||
|
||||
fetchMetadata(): void {
|
||||
this.dialogHelperService.openMetadataRefreshDialog(this.selectedBooks());
|
||||
async fetchMetadata() {
|
||||
await this.dialogHelperService.openMetadataRefreshDialog(this.selectedBooks());
|
||||
}
|
||||
|
||||
bulkEditMetadata(): void {
|
||||
this.dialogRef = this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks());
|
||||
async bulkEditMetadata() {
|
||||
this.dialogRef = await this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks());
|
||||
if (this.dialogRef) {
|
||||
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||
this.deselectAllBooks();
|
||||
@@ -726,8 +726,8 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
}
|
||||
}
|
||||
|
||||
multiBookEditMetadata(): void {
|
||||
this.dialogRef = this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks());
|
||||
async multiBookEditMetadata() {
|
||||
this.dialogRef = await this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks());
|
||||
if (this.dialogRef) {
|
||||
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||
this.deselectAllBooks();
|
||||
@@ -817,8 +817,8 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
});
|
||||
}
|
||||
|
||||
moveFiles() {
|
||||
this.dialogHelperService.openFileMoverDialog(this.selectedBooks());
|
||||
async moveFiles() {
|
||||
await this.dialogHelperService.openFileMoverDialog(this.selectedBooks());
|
||||
}
|
||||
|
||||
user() {
|
||||
|
||||
@@ -87,9 +87,9 @@ describe('LibraryShelfMenuService', () => {
|
||||
navigate: vi.fn(),
|
||||
};
|
||||
const dialogLauncherService = {
|
||||
openLibraryEditDialog: vi.fn(),
|
||||
openShelfEditDialog: vi.fn(),
|
||||
openMagicShelfEditDialog: vi.fn(),
|
||||
openLibraryEditDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openShelfEditDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openMagicShelfEditDialog: vi.fn(() => Promise.resolve(null)),
|
||||
};
|
||||
const magicShelfService = {
|
||||
deleteShelf: vi.fn(() => of(undefined)),
|
||||
@@ -99,10 +99,10 @@ describe('LibraryShelfMenuService', () => {
|
||||
hide: vi.fn(),
|
||||
};
|
||||
const bookDialogHelperService = {
|
||||
openAddPhysicalBookDialog: vi.fn(),
|
||||
openBulkIsbnImportDialog: vi.fn(),
|
||||
openDuplicateMergerDialog: vi.fn(),
|
||||
openMetadataRefreshDialogWithContext: vi.fn(),
|
||||
openAddPhysicalBookDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openBulkIsbnImportDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openDuplicateMergerDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openMetadataRefreshDialogWithContext: vi.fn(() => Promise.resolve(null)),
|
||||
};
|
||||
const translocoService = {
|
||||
translate: vi.fn((key: string) => key),
|
||||
|
||||
@@ -45,22 +45,22 @@ export class LibraryShelfMenuService {
|
||||
label: this.t.translate('book.shelfMenuService.library.addPhysicalBook'),
|
||||
icon: 'pi pi-book',
|
||||
disabled: libraryId == null,
|
||||
command: () => {
|
||||
command: async () => {
|
||||
if (libraryId == null) {
|
||||
return;
|
||||
}
|
||||
this.bookDialogHelperService.openAddPhysicalBookDialog(libraryId);
|
||||
await this.bookDialogHelperService.openAddPhysicalBookDialog(libraryId).catch(() => undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: this.t.translate('book.shelfMenuService.library.bulkIsbnImport'),
|
||||
icon: 'pi pi-barcode',
|
||||
disabled: libraryId == null,
|
||||
command: () => {
|
||||
command: async () => {
|
||||
if (libraryId == null) {
|
||||
return;
|
||||
}
|
||||
this.bookDialogHelperService.openBulkIsbnImportDialog(libraryId);
|
||||
await this.bookDialogHelperService.openBulkIsbnImportDialog(libraryId).catch(() => undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -74,7 +74,7 @@ export class LibraryShelfMenuService {
|
||||
if (libraryId == null) {
|
||||
return;
|
||||
}
|
||||
this.dialogLauncherService.openLibraryEditDialog(libraryId);
|
||||
void this.dialogLauncherService.openLibraryEditDialog(libraryId).catch(() => undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -124,14 +124,14 @@ export class LibraryShelfMenuService {
|
||||
label: this.t.translate('book.shelfMenuService.library.customFetchMetadata'),
|
||||
icon: 'pi pi-sync',
|
||||
disabled: libraryId == null,
|
||||
command: () => {
|
||||
command: async () => {
|
||||
if (libraryId == null) {
|
||||
return;
|
||||
}
|
||||
this.bookDialogHelperService.openMetadataRefreshDialogWithContext({
|
||||
await this.bookDialogHelperService.openMetadataRefreshDialogWithContext({
|
||||
metadataRefreshType: MetadataRefreshType.LIBRARY,
|
||||
libraryId
|
||||
});
|
||||
}).catch(() => undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -152,11 +152,11 @@ export class LibraryShelfMenuService {
|
||||
label: this.t.translate('book.shelfMenuService.library.findDuplicates'),
|
||||
icon: 'pi pi-copy',
|
||||
disabled: libraryId == null,
|
||||
command: () => {
|
||||
command: async () => {
|
||||
if (libraryId == null) {
|
||||
return;
|
||||
}
|
||||
this.bookDialogHelperService.openDuplicateMergerDialog(libraryId);
|
||||
await this.bookDialogHelperService.openDuplicateMergerDialog(libraryId).catch(() => undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -227,7 +227,7 @@ export class LibraryShelfMenuService {
|
||||
return;
|
||||
}
|
||||
|
||||
this.dialogLauncherService.openShelfEditDialog(shelfId);
|
||||
void this.dialogLauncherService.openShelfEditDialog(shelfId).catch(() => undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -303,7 +303,7 @@ export class LibraryShelfMenuService {
|
||||
return;
|
||||
}
|
||||
|
||||
this.dialogLauncherService.openMagicShelfEditDialog(magicShelfId);
|
||||
void this.dialogLauncherService.openMagicShelfEditDialog(magicShelfId).catch(() => undefined);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user