refactor(ui): remove old book browser (#2575)

This commit is contained in:
Alex
2026-09-26 12:55:46 +01:00
committed by GitHub
parent 62bb79e860
commit 4923b62f88
127 changed files with 217 additions and 13280 deletions
@@ -0,0 +1,250 @@
import {inject, Injectable} from '@angular/core';
import {DynamicDialogRef} from '@openng/optimus-ui/dynamicdialog';
import {DialogLauncherService, DialogSize, DialogStyle} from '../../../shared/services/dialog-launcher.service';
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
import {Book} from '../model/book.model';
import {type BookSenderSource} from '../components/book-sender/book-sender.component';
import {type BookFileAttacherSourceBook} from '../components/book-file-attacher/book-file-attacher.component';
interface MetadataRefreshDialogContext {
metadataRefreshType: MetadataRefreshType;
bookIds?: number[];
libraryId?: number;
}
@Injectable({providedIn: 'root'})
export class BookDialogHelperService {
private dialogLauncherService = inject(DialogLauncherService);
private openDialog(component: unknown, options: object): DynamicDialogRef | null {
return this.dialogLauncherService.openDialog(component, options);
}
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,
},
});
});
}
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('../components/shelf-assigner/shelf-assigner.component');
return this.openDialog(ShelfAssignerComponent, {
showHeader: false,
data: data,
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
});
});
}
async openShelfCreatorDialog(): Promise<DynamicDialogRef | null> {
return this.dialogLauncherService.launchLazyDialog(async () => {
const {ShelfCreatorComponent} = await import('../components/shelf-creator/shelf-creator.component');
return this.openDialog(ShelfCreatorComponent, {
showHeader: false,
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
});
});
}
async openLockUnlockMetadataDialog(bookIds: Set<number>): Promise<DynamicDialogRef | null> {
return this.dialogLauncherService.launchLazyDialog(async () => {
const {LockUnlockMetadataDialogComponent} = await import('../components/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)
});
}
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,
},
});
});
}
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),
},
});
});
}
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),
},
});
});
}
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),
},
});
});
}
async openCustomSendDialog(book: BookSenderSource): Promise<DynamicDialogRef | null> {
return this.dialogLauncherService.launchLazyDialog(async () => {
const {BookSenderComponent} = await import('../components/book-sender/book-sender.component');
return this.openDialog(BookSenderComponent, {
showHeader: false,
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
data: {
book: book,
},
});
});
}
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,
},
});
});
}
async openAdditionalFileUploaderDialog(book: Book): Promise<DynamicDialogRef | null> {
return this.dialogLauncherService.launchLazyDialog(async () => {
const {AdditionalFileUploaderComponent} = await import('../components/additional-file-uploader/additional-file-uploader.component');
return this.openDialog(AdditionalFileUploaderComponent, {
showHeader: false,
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
data: {
book: book,
},
});
});
}
async openBookFileAttacherDialog(sourceBook: Book): Promise<DynamicDialogRef | null> {
return this.dialogLauncherService.launchLazyDialog(async () => {
const {BookFileAttacherComponent} = await import('../components/book-file-attacher/book-file-attacher.component');
return this.openDialog(BookFileAttacherComponent, {
showHeader: false,
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
data: {
sourceBook: sourceBook,
},
});
});
}
async openBulkBookFileAttacherDialog(
sourceBooks: readonly BookFileAttacherSourceBook[],
): Promise<DynamicDialogRef | null> {
return this.dialogLauncherService.launchLazyDialog(async () => {
const {BookFileAttacherComponent} = await import('../components/book-file-attacher/book-file-attacher.component');
return this.openDialog(BookFileAttacherComponent, {
showHeader: false,
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
data: {
sourceBooks: sourceBooks,
},
});
});
}
async openDuplicateMergerDialog(libraryId: number): Promise<DynamicDialogRef | null> {
return this.dialogLauncherService.launchLazyDialog(async () => {
const {DuplicateMergerComponent} = await import('../components/duplicate-merger/duplicate-merger.component');
return this.openDialog(DuplicateMergerComponent, {
showHeader: false,
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
data: {
libraryId: libraryId,
},
});
});
}
async openAddPhysicalBookDialog(libraryId?: number): Promise<DynamicDialogRef | null> {
return this.dialogLauncherService.launchLazyDialog(async () => {
const {AddPhysicalBookDialogComponent} = await import('../components/add-physical-book-dialog/add-physical-book-dialog.component');
return this.openDialog(AddPhysicalBookDialogComponent, {
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('../components/bulk-isbn-import-dialog/bulk-isbn-import-dialog.component');
return this.openDialog(BulkIsbnImportDialogComponent, {
showHeader: false,
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
data: {
libraryId: libraryId,
},
});
});
}
}