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);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+3
-3
@@ -23,9 +23,9 @@ describe('BookdropFileReviewComponent', () => {
|
||||
const discardFiles = vi.fn();
|
||||
const finalizeImport = vi.fn();
|
||||
const rescan = vi.fn();
|
||||
const openBookdropFinalizeResultDialog = vi.fn();
|
||||
const openDialog = vi.fn();
|
||||
const openDirectoryPickerDialog = vi.fn();
|
||||
const openBookdropFinalizeResultDialog = vi.fn(() => Promise.resolve(null));
|
||||
const openDialog = vi.fn(() => Promise.resolve(null));
|
||||
const openDirectoryPickerDialog = vi.fn(() => Promise.resolve(null));
|
||||
const setPageTitle = vi.fn();
|
||||
const translate = vi.fn((key: string, params?: Record<string, unknown>) => {
|
||||
if (!params) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Router } from '@angular/router';
|
||||
import { of } from 'rxjs';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { getTranslocoModule } from '../../core/testing/transloco-testing';
|
||||
import { BookDialogHelperService } from '../book/components/book-browser/book-dialog-helper.service';
|
||||
import { Book } from '../book/model/book.model';
|
||||
@@ -65,20 +66,21 @@ describe('CommandPaletteService', () => {
|
||||
{ provide: MagicShelfService, useValue: { shelves: signal([]) } },
|
||||
{ provide: LibraryService, useValue: { libraries: signal([]) } },
|
||||
{ provide: UserService, useValue: { currentUser: signal({ permissions: {} }) } },
|
||||
{ provide: MessageService, useValue: { add: vi.fn() } },
|
||||
{ provide: UrlHelperService, useValue: urlHelper },
|
||||
{ provide: IconService, useValue: { getSvgIconContent: vi.fn(() => of('')) } },
|
||||
{
|
||||
provide: DialogLauncherService,
|
||||
useValue: {
|
||||
openLibraryCreateDialog: vi.fn(),
|
||||
openMagicShelfCreateDialog: vi.fn(),
|
||||
openFileUploadDialog: vi.fn(),
|
||||
openLibraryCreateDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openMagicShelfCreateDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openFileUploadDialog: vi.fn(() => Promise.resolve(null)),
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: BookDialogHelperService,
|
||||
useValue: {
|
||||
openShelfCreatorDialog: vi.fn(),
|
||||
openShelfCreatorDialog: vi.fn(() => Promise.resolve(null)),
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { computed, inject, Injectable, signal } from '@angular/core';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { Router } from '@angular/router';
|
||||
import { TranslocoService } from '@jsverse/transloco';
|
||||
@@ -50,6 +51,7 @@ export class CommandPaletteService {
|
||||
private readonly bookDialogHelperService = inject(BookDialogHelperService);
|
||||
private readonly iconService = inject(IconService);
|
||||
private readonly urlHelper = inject(UrlHelperService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
|
||||
private readonly _isOpen = signal(false);
|
||||
readonly isOpen = this._isOpen.asReadonly();
|
||||
@@ -131,7 +133,7 @@ export class CommandPaletteService {
|
||||
this.hide();
|
||||
queueMicrotask(() => {
|
||||
if (item.command) {
|
||||
item.command();
|
||||
void Promise.resolve(item.command()).catch(() => undefined);
|
||||
return;
|
||||
}
|
||||
if (item.route) {
|
||||
@@ -211,10 +213,10 @@ export class CommandPaletteService {
|
||||
const user = this.userService.currentUser();
|
||||
if (!user) return [];
|
||||
return buildQuickActionNavItems(this.translate, user.permissions, {
|
||||
createLibrary: () => this.dialogLauncherService.openLibraryCreateDialog(),
|
||||
createShelf: () => this.bookDialogHelperService.openShelfCreatorDialog(),
|
||||
createMagicShelf: () => this.dialogLauncherService.openMagicShelfCreateDialog(),
|
||||
uploadBook: () => this.dialogLauncherService.openFileUploadDialog(),
|
||||
createLibrary: () => void this.dialogLauncherService.openLibraryCreateDialog().catch(() => undefined),
|
||||
createShelf: () => void this.bookDialogHelperService.openShelfCreatorDialog().catch(() => undefined),
|
||||
createMagicShelf: () => void this.dialogLauncherService.openMagicShelfCreateDialog().catch(() => undefined),
|
||||
uploadBook: () => void this.dialogLauncherService.openFileUploadDialog().catch(() => undefined),
|
||||
}).map((item) => this.toPaletteNavItem(item, 'action'));
|
||||
});
|
||||
|
||||
@@ -320,5 +322,4 @@ export class CommandPaletteService {
|
||||
command: item.action,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -62,10 +62,10 @@ export class MainDashboardComponent {
|
||||
}
|
||||
|
||||
openDashboardSettings(): void {
|
||||
this.dialogLauncher.openDashboardSettingsDialog();
|
||||
void this.dialogLauncher.openDashboardSettingsDialog().catch(() => undefined);
|
||||
}
|
||||
|
||||
createNewLibrary() {
|
||||
this.dialogLauncher.openLibraryCreateDialog();
|
||||
void this.dialogLauncher.openLibraryCreateDialog().catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,8 +215,8 @@ export class LibraryCreatorComponent {
|
||||
return this.allBookFormats.some(f => this.getFormatWarning(f.type) !== null);
|
||||
}
|
||||
|
||||
openDirectoryPicker(): void {
|
||||
const ref = this.dialogLauncherService.openDirectoryPickerDialog();
|
||||
async openDirectoryPicker(): Promise<void> {
|
||||
const ref = await this.dialogLauncherService.openDirectoryPickerDialog().catch(() => null);
|
||||
ref?.onClose.subscribe((selectedFolders: string[] | null) => {
|
||||
if (selectedFolders && selectedFolders.length > 0) {
|
||||
this.folders.update(current => {
|
||||
|
||||
+4
-4
@@ -1114,8 +1114,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
this.closeDialogButtonClicked.emit();
|
||||
}
|
||||
|
||||
openCoverSearch() {
|
||||
const ref = this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'ebook');
|
||||
async openCoverSearch() {
|
||||
const ref = await this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'ebook');
|
||||
ref?.onClose.pipe(
|
||||
take(1),
|
||||
filter(result => !!result),
|
||||
@@ -1204,8 +1204,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
return this.bookMetadataManageService.getUploadAudiobookCoverUrl(this.currentBookId);
|
||||
}
|
||||
|
||||
openAudiobookCoverSearch() {
|
||||
const ref = this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'audiobook');
|
||||
async openAudiobookCoverSearch() {
|
||||
const ref = await this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'audiobook');
|
||||
ref?.onClose.pipe(
|
||||
take(1),
|
||||
filter(result => !!result),
|
||||
|
||||
+5
-5
@@ -67,11 +67,11 @@ describe('MetadataViewerComponent', () => {
|
||||
const deleteBookFile = vi.fn(() => of(void 0));
|
||||
const detachBookFile = vi.fn(() => of(void 0));
|
||||
|
||||
const openAdditionalFileUploaderDialog = vi.fn();
|
||||
const openCustomSendDialog = vi.fn();
|
||||
const openBookFileAttacherDialog = vi.fn();
|
||||
const openFileMoverDialog = vi.fn();
|
||||
const openShelfAssignerDialog = vi.fn();
|
||||
const openAdditionalFileUploaderDialog = vi.fn(() => Promise.resolve(null));
|
||||
const openCustomSendDialog = vi.fn(() => Promise.resolve(null));
|
||||
const openBookFileAttacherDialog = vi.fn(() => Promise.resolve(null));
|
||||
const openFileMoverDialog = vi.fn(() => Promise.resolve(null));
|
||||
const openShelfAssignerDialog = vi.fn(() => Promise.resolve(null));
|
||||
|
||||
const emailBookQuick = vi.fn(() => of(void 0));
|
||||
const refreshMetadataTask = vi.fn(() => of(void 0));
|
||||
|
||||
+11
-9
@@ -214,7 +214,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
||||
items.push({
|
||||
label: this.t.translate('metadata.viewer.menuShelf'),
|
||||
icon: 'pi pi-folder',
|
||||
command: () => this.assignShelf(book.id)
|
||||
command: () => {
|
||||
void this.assignShelf(book).catch(() => undefined);
|
||||
}
|
||||
});
|
||||
|
||||
if (permissions?.canManageLibrary || permissions?.admin) {
|
||||
@@ -235,7 +237,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
||||
label: this.t.translate('metadata.viewer.menuUploadFile'),
|
||||
icon: 'pi pi-upload',
|
||||
command: () => {
|
||||
this.bookDialogHelperService.openAdditionalFileUploaderDialog(book);
|
||||
void this.bookDialogHelperService.openAdditionalFileUploaderDialog(book).catch(() => undefined);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -247,7 +249,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
||||
label: this.t.translate('metadata.viewer.menuOrganizeFiles'),
|
||||
icon: 'pi pi-arrows-h',
|
||||
command: () => {
|
||||
this.openFileMoverDialog(book.id);
|
||||
void this.openFileMoverDialog(book.id).catch(() => undefined);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -266,7 +268,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
||||
label: this.t.translate('metadata.viewer.menuCustomSend'),
|
||||
icon: 'pi pi-cog',
|
||||
command: () => {
|
||||
this.bookDialogHelperService.openCustomSendDialog(book);
|
||||
void this.bookDialogHelperService.openCustomSendDialog(book).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -281,7 +283,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
||||
label: this.t.translate('metadata.viewer.menuAttachToAnotherBook'),
|
||||
icon: 'pi pi-link',
|
||||
command: () => {
|
||||
this.bookDialogHelperService.openBookFileAttacherDialog(book);
|
||||
void this.bookDialogHelperService.openBookFileAttacherDialog(book).catch(() => undefined);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -687,8 +689,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
||||
}
|
||||
}
|
||||
|
||||
assignShelf(bookId: number) {
|
||||
this.bookDialogHelperService.openShelfAssignerDialog((this.bookService.findBookById(bookId) as Book), null);
|
||||
async assignShelf(book: Book) {
|
||||
await this.bookDialogHelperService.openShelfAssignerDialog(book, null);
|
||||
}
|
||||
|
||||
updateReadStatus(status: ReadStatus): void {
|
||||
@@ -1251,8 +1253,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
||||
this.editDateFinished = null;
|
||||
}
|
||||
|
||||
openFileMoverDialog(bookId: number): void {
|
||||
this.bookDialogHelperService.openFileMoverDialog(new Set([bookId]));
|
||||
async openFileMoverDialog(bookId: number) {
|
||||
await this.bookDialogHelperService.openFileMoverDialog(new Set([bookId]));
|
||||
}
|
||||
|
||||
protected readonly ResetProgressTypes = ResetProgressTypes;
|
||||
|
||||
+2
-2
@@ -153,8 +153,8 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
openCreateProviderDialog() {
|
||||
this.ref = this.dialogLauncherService.openEmailProviderDialog();
|
||||
async openCreateProviderDialog() {
|
||||
this.ref = await this.dialogLauncherService.openEmailProviderDialog().catch(() => null);
|
||||
this.ref?.onClose.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((result) => {
|
||||
if (result) {
|
||||
this.loadEmailProviders();
|
||||
|
||||
+2
-2
@@ -140,8 +140,8 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
openAddRecipientDialog() {
|
||||
this.ref = this.dialogLauncherService.openEmailRecipientDialog();
|
||||
async openAddRecipientDialog() {
|
||||
this.ref = await this.dialogLauncherService.openEmailRecipientDialog().catch(() => null);
|
||||
this.ref?.onClose.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((result) => {
|
||||
if (result) {
|
||||
this.loadRecipientEmails();
|
||||
|
||||
@@ -100,8 +100,8 @@ export class UserManagementComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
openCreateUserDialog() {
|
||||
this.ref = this.dialogLauncherService.openCreateUserDialog();
|
||||
async openCreateUserDialog() {
|
||||
this.ref = await this.dialogLauncherService.openCreateUserDialog().catch(() => null);
|
||||
this.ref?.onClose.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((result) => {
|
||||
if (result) {
|
||||
this.loadUsers();
|
||||
|
||||
@@ -25,6 +25,9 @@ interface ChartConfig {
|
||||
category: string;
|
||||
}
|
||||
|
||||
import {provideCharts, withDefaultRegisterables} from 'ng2-charts';
|
||||
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-stats',
|
||||
standalone: true,
|
||||
@@ -44,6 +47,7 @@ interface ChartConfig {
|
||||
ReadingJourneyChartComponent,
|
||||
TranslocoDirective
|
||||
],
|
||||
providers: [provideCharts(withDefaultRegisterables(ChartDataLabels))],
|
||||
templateUrl: './library-stats.component.html',
|
||||
styleUrls: ['./library-stats.component.scss']
|
||||
})
|
||||
|
||||
@@ -29,6 +29,9 @@ import {PublicationEraChartComponent} from './charts/publication-era-chart/publi
|
||||
import {SessionArchetypesChartComponent} from './charts/session-archetypes-chart/session-archetypes-chart.component';
|
||||
import {UserChartConfig, UserChartConfigService} from './service/user-chart-config.service';
|
||||
|
||||
import {provideCharts, withDefaultRegisterables} from 'ng2-charts';
|
||||
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-stats',
|
||||
standalone: true,
|
||||
@@ -61,6 +64,7 @@ import {UserChartConfig, UserChartConfigService} from './service/user-chart-conf
|
||||
SessionArchetypesChartComponent,
|
||||
TranslocoDirective
|
||||
],
|
||||
providers: [provideCharts(withDefaultRegisterables(ChartDataLabels))],
|
||||
templateUrl: './user-stats.component.html',
|
||||
styleUrls: ['./user-stats.component.scss']
|
||||
})
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ describe('MetadataProgressWidgetComponent', () => {
|
||||
cancelTask: vi.fn(() => of({cancelled: true})),
|
||||
};
|
||||
dialogLauncherService = {
|
||||
openMetadataReviewDialog: vi.fn(),
|
||||
openMetadataReviewDialog: vi.fn(() => Promise.resolve(null)),
|
||||
};
|
||||
messageService = {
|
||||
add: vi.fn(),
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ export class MetadataProgressWidgetComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
reviewTask(taskId: string): void {
|
||||
this.dialogLauncherService.openMetadataReviewDialog(taskId);
|
||||
void this.dialogLauncherService.openMetadataReviewDialog(taskId).catch(() => undefined);
|
||||
}
|
||||
|
||||
cancelTask(taskId: string): void {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { computed, signal, WritableSignal } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { MessageService } from 'primeng/api';
|
||||
|
||||
import { getTranslocoModule } from '../../../core/testing/transloco-testing';
|
||||
import { BookDialogHelperService } from '../../../features/book/components/book-browser/book-dialog-helper.service';
|
||||
@@ -104,13 +105,13 @@ describe('AppSidebarComponent', () => {
|
||||
{
|
||||
provide: DialogLauncherService,
|
||||
useValue: {
|
||||
openLibraryCreateDialog: vi.fn(),
|
||||
openMagicShelfCreateDialog: vi.fn(),
|
||||
openFileUploadDialog: vi.fn(),
|
||||
openLibraryCreateDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openMagicShelfCreateDialog: vi.fn(() => Promise.resolve(null)),
|
||||
openFileUploadDialog: vi.fn(() => Promise.resolve(null)),
|
||||
},
|
||||
},
|
||||
{ provide: CommandPaletteService, useValue: commandPaletteService },
|
||||
{ provide: BookDialogHelperService, useValue: { openShelfCreatorDialog: vi.fn() } },
|
||||
{ provide: BookDialogHelperService, useValue: { openShelfCreatorDialog: vi.fn(() => Promise.resolve(null)) } },
|
||||
{ provide: AuthService, useValue: { logout: vi.fn() } },
|
||||
{ provide: MetadataProgressService, useValue: { activeTasks$, progressUpdates$ } },
|
||||
{ provide: BookdropFileService, useValue: { hasPendingFiles$ } },
|
||||
@@ -120,6 +121,7 @@ describe('AppSidebarComponent', () => {
|
||||
{ provide: MagicShelfService, useValue: { shelves: signal([]), bookCountByMagicShelfId: signal(new Map()) } },
|
||||
{ provide: SeriesDataService, useValue: { allSeries: signal([]) } },
|
||||
{ provide: AuthorService, useValue: { allAuthors: signal([]) } },
|
||||
{ provide: MessageService, useValue: { add: vi.fn() } },
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ import { AuthService } from '../../service/auth.service';
|
||||
import { LayoutService } from '../layout.service';
|
||||
import { TranslocoDirective, TranslocoPipe, TranslocoService } from '@jsverse/transloco';
|
||||
import { Tooltip } from 'primeng/tooltip';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { VersionService } from '../../service/version.service';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { NavItem, SidebarSection } from '../navigation/nav-item.model';
|
||||
import { buildCreateActionNavItems } from '../navigation/nav-catalog';
|
||||
@@ -40,7 +42,6 @@ import {
|
||||
buildShelfSection,
|
||||
buildToolsSection,
|
||||
} from './sidebar-sections';
|
||||
import { VersionService } from '../../service/version.service';
|
||||
import { MetadataProgressService } from '../../service/metadata-progress.service';
|
||||
import { BookdropFileService } from '../../../features/bookdrop/service/bookdrop-file.service';
|
||||
import { MetadataBatchProgressNotification, MetadataBatchStatus } from '../../model/metadata-batch-progress.model';
|
||||
@@ -119,7 +120,6 @@ export class AppSidebarComponent {
|
||||
private readonly commandPaletteService = inject(CommandPaletteService);
|
||||
private readonly bookDialogHelperService = inject(BookDialogHelperService);
|
||||
private readonly authService = inject(AuthService);
|
||||
private readonly router = inject(Router);
|
||||
readonly layoutService = inject(LayoutService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly versionService = inject(VersionService);
|
||||
@@ -128,9 +128,11 @@ export class AppSidebarComponent {
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly renderer = inject(Renderer2);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly metadataProgressService = inject(MetadataProgressService);
|
||||
private readonly bookdropFileService = inject(BookdropFileService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly metadataProgressService = inject(MetadataProgressService);
|
||||
private readonly bookdropFileService = inject(BookdropFileService);
|
||||
|
||||
readonly currentUser = this.userService.currentUser;
|
||||
private readonly allAuthors = this.authorService.allAuthors;
|
||||
@@ -199,10 +201,10 @@ export class AppSidebarComponent {
|
||||
if (!user) return [];
|
||||
|
||||
const actions = buildCreateActionNavItems(this.translate, user.permissions, {
|
||||
createLibrary: () => this.dialogLauncherService.openLibraryCreateDialog(),
|
||||
createShelf: () => this.bookDialogHelperService.openShelfCreatorDialog(),
|
||||
createMagicShelf: () => this.dialogLauncherService.openMagicShelfCreateDialog(),
|
||||
uploadBook: () => this.dialogLauncherService.openFileUploadDialog(),
|
||||
createLibrary: () => void this.dialogLauncherService.openLibraryCreateDialog().catch(() => undefined),
|
||||
createShelf: () => void this.bookDialogHelperService.openShelfCreatorDialog().catch(() => undefined),
|
||||
createMagicShelf: () => void this.dialogLauncherService.openMagicShelfCreateDialog().catch(() => undefined),
|
||||
uploadBook: () => void this.dialogLauncherService.openFileUploadDialog().catch(() => undefined),
|
||||
});
|
||||
return this.toMenuEntries(actions);
|
||||
});
|
||||
@@ -274,29 +276,28 @@ export class AppSidebarComponent {
|
||||
}
|
||||
|
||||
protected openAccountSettings(): void {
|
||||
this.dialogLauncherService.openUserProfileDialog();
|
||||
this.closeUserPopover();
|
||||
void this.dialogLauncherService.openUserProfileDialog().catch(() => undefined);
|
||||
this.closeUserPopover();
|
||||
}
|
||||
|
||||
protected openSettings(): void {
|
||||
this.router.navigate(['/settings']);
|
||||
this.closeUserPopover();
|
||||
this.router.navigate(['/settings']);
|
||||
this.closeUserPopover();
|
||||
}
|
||||
|
||||
protected openChangelogDialog(): void {
|
||||
this.dialogLauncherService.openVersionChangelogDialog();
|
||||
this.closeUserPopover();
|
||||
void this.dialogLauncherService.openVersionChangelogDialog().catch(() => undefined);
|
||||
this.closeUserPopover();
|
||||
}
|
||||
|
||||
protected openReadingStats(): void {
|
||||
this.router.navigate(['/reading-stats']);
|
||||
this.closeUserPopover();
|
||||
this.router.navigate(['/reading-stats']);
|
||||
this.closeUserPopover();
|
||||
}
|
||||
|
||||
protected openUploadDialog(): void {
|
||||
this.dialogLauncherService.openFileUploadDialog();
|
||||
void this.dialogLauncherService.openFileUploadDialog().catch(() => undefined);
|
||||
}
|
||||
|
||||
protected logout(): void {
|
||||
this.authService.logout();
|
||||
this.closeUserPopover();
|
||||
@@ -366,24 +367,24 @@ export class AppSidebarComponent {
|
||||
overlay.toggle(event);
|
||||
}
|
||||
|
||||
private subscribeToMetadataProgress(): void {
|
||||
this.metadataProgressService.progressUpdates$
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((progress) => {
|
||||
this.progressHighlight = progress.status === MetadataBatchStatus.IN_PROGRESS;
|
||||
});
|
||||
}
|
||||
private subscribeToMetadataProgress(): void {
|
||||
this.metadataProgressService.progressUpdates$
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((progress) => {
|
||||
this.progressHighlight = progress.status === MetadataBatchStatus.IN_PROGRESS;
|
||||
});
|
||||
}
|
||||
|
||||
private replaceLatestTasks(tasks: Record<string, MetadataBatchProgressNotification>): void {
|
||||
for (const key of Object.keys(this.latestTasks)) {
|
||||
delete this.latestTasks[key];
|
||||
}
|
||||
Object.assign(this.latestTasks, tasks);
|
||||
private replaceLatestTasks(tasks: Record<string, MetadataBatchProgressNotification>): void {
|
||||
for (const key of Object.keys(this.latestTasks)) {
|
||||
delete this.latestTasks[key];
|
||||
}
|
||||
Object.assign(this.latestTasks, tasks);
|
||||
}
|
||||
|
||||
private updateCompletedTaskCount(): void {
|
||||
const metadataTaskCount = Object.keys(this.latestTasks).length;
|
||||
const bookdropFileTaskCount = this.hasPendingBookdropFiles ? 1 : 0;
|
||||
this.completedTaskCount = metadataTaskCount + bookdropFileTaskCount;
|
||||
}
|
||||
private updateCompletedTaskCount(): void {
|
||||
const metadataTaskCount = Object.keys(this.latestTasks).length;
|
||||
const bookdropFileTaskCount = this.hasPendingBookdropFiles ? 1 : 0;
|
||||
this.completedTaskCount = metadataTaskCount + bookdropFileTaskCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('IconPickerService', () => {
|
||||
});
|
||||
|
||||
it('returns the icon selected by the dialog', async () => {
|
||||
dialogLauncherService.openIconPickerDialog.mockReturnValue({
|
||||
dialogLauncherService.openIconPickerDialog.mockResolvedValue({
|
||||
onClose: of({type: 'PRIME_NG', value: 'pi pi-book'}),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {EMPTY, from, Observable, switchMap} from 'rxjs';
|
||||
import {DialogLauncherService} from '../services/dialog-launcher.service';
|
||||
|
||||
export interface IconSelection {
|
||||
@@ -12,7 +12,13 @@ export class IconPickerService {
|
||||
private dialogLauncherService = inject(DialogLauncherService);
|
||||
|
||||
open(): Observable<IconSelection> {
|
||||
const ref = this.dialogLauncherService.openIconPickerDialog();
|
||||
return ref!.onClose as Observable<IconSelection>;
|
||||
return from(this.dialogLauncherService.openIconPickerDialog()).pipe(
|
||||
switchMap(ref => {
|
||||
if (!ref) {
|
||||
return EMPTY;
|
||||
}
|
||||
return ref.onClose as Observable<IconSelection>;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {getTranslocoModule} from '../../core/testing/transloco-testing';
|
||||
|
||||
import {DashboardSettingsComponent} from '../../features/dashboard/components/dashboard-settings/dashboard-settings.component';
|
||||
import {LibraryCreatorComponent} from '../../features/library-creator/library-creator.component';
|
||||
@@ -20,17 +22,19 @@ describe('DialogLauncherService', () => {
|
||||
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [getTranslocoModule()],
|
||||
providers: [
|
||||
DialogLauncherService,
|
||||
{provide: DialogService, useValue: dialogService},
|
||||
{provide: MessageService, useValue: {add: vi.fn()}},
|
||||
]
|
||||
});
|
||||
|
||||
service = TestBed.inject(DialogLauncherService);
|
||||
});
|
||||
|
||||
it('merges the default dialog options with caller overrides', () => {
|
||||
service.openDialog(LibraryCreatorComponent, {
|
||||
it('merges the default dialog options with caller overrides', async () => {
|
||||
await service.openDialog(LibraryCreatorComponent, {
|
||||
showHeader: false,
|
||||
data: {mode: 'create'},
|
||||
});
|
||||
@@ -51,8 +55,8 @@ describe('DialogLauncherService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('opens the dashboard settings dialog with the expected style class', () => {
|
||||
service.openDashboardSettingsDialog();
|
||||
it('opens the dashboard settings dialog with the expected style class', async () => {
|
||||
await service.openDashboardSettingsDialog();
|
||||
|
||||
expect(dialogService.open).toHaveBeenCalledWith(
|
||||
DashboardSettingsComponent,
|
||||
@@ -63,8 +67,8 @@ describe('DialogLauncherService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('passes the library id into the library edit dialog', () => {
|
||||
service.openLibraryEditDialog(12);
|
||||
it('passes the library id into the library edit dialog', async () => {
|
||||
await service.openLibraryEditDialog(12);
|
||||
|
||||
expect(dialogService.open).toHaveBeenCalledWith(
|
||||
LibraryCreatorComponent,
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
import {inject, Injectable, Type} from '@angular/core';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {LibraryCreatorComponent} from '../../features/library-creator/library-creator.component';
|
||||
import {BookUploaderComponent} from '../components/book-uploader/book-uploader.component';
|
||||
import {UserProfileDialogComponent} from '../../features/settings/user-profile-dialog/user-profile-dialog.component';
|
||||
import {MagicShelfComponent} from '../../features/magic-shelf/component/magic-shelf-component';
|
||||
import {DashboardSettingsComponent} from '../../features/dashboard/components/dashboard-settings/dashboard-settings.component';
|
||||
import {VersionChangelogDialogComponent} from '../layout/layout-sidebar/version-changelog-dialog/version-changelog-dialog.component';
|
||||
import {CreateUserDialogComponent} from '../../features/settings/user-management/create-user-dialog/create-user-dialog.component';
|
||||
import {CreateEmailRecipientDialogComponent} from '../../features/settings/email-v2/create-email-recipient-dialog/create-email-recipient-dialog.component';
|
||||
import {CreateEmailProviderDialogComponent} from '../../features/settings/email-v2/create-email-provider-dialog/create-email-provider-dialog.component';
|
||||
import {DirectoryPickerComponent} from '../components/directory-picker/directory-picker.component';
|
||||
import {BookdropFinalizeResultDialogComponent} from '../../features/bookdrop/component/bookdrop-finalize-result-dialog/bookdrop-finalize-result-dialog.component';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {MetadataRefreshType} from '../../features/metadata/model/request/metadata-refresh-type.enum';
|
||||
import {BookdropFinalizeResult} from '../../features/bookdrop/service/bookdrop.service';
|
||||
import {MetadataReviewDialogComponent} from '../../features/metadata/component/metadata-review-dialog/metadata-review-dialog-component';
|
||||
import {ShelfEditDialogComponent} from '../../features/book/components/shelf-edit-dialog/shelf-edit-dialog.component';
|
||||
import {IconPickerComponent} from '../components/icon-picker/icon-picker-component';
|
||||
|
||||
/**
|
||||
* Dialog size classes - use these to control dialog dimensions
|
||||
@@ -40,7 +29,9 @@ export const DialogStyle = {
|
||||
})
|
||||
export class DialogLauncherService {
|
||||
|
||||
dialogService = inject(DialogService);
|
||||
private readonly dialogService = inject(DialogService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
private defaultDialogOptions = {
|
||||
baseZIndex: 10,
|
||||
@@ -60,132 +51,206 @@ export class DialogLauncherService {
|
||||
});
|
||||
}
|
||||
|
||||
openDashboardSettingsDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(DashboardSettingsComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
launchLazyDialog(dialogFn: () => Promise<DynamicDialogRef | null>): Promise<DynamicDialogRef | null> {
|
||||
return dialogFn().catch(err => {
|
||||
console.error('Failed to load dialog', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('common.dialogLoadError')
|
||||
});
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
openLibraryCreateDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(LibraryCreatorComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
async openDashboardSettingsDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {DashboardSettingsComponent} = await import('../../features/dashboard/components/dashboard-settings/dashboard-settings.component');
|
||||
return this.openDialog(DashboardSettingsComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openDirectoryPickerDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(DirectoryPickerComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
async openLibraryCreateDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {LibraryCreatorComponent} = await import('../../features/library-creator/library-creator.component');
|
||||
return this.openDialog(LibraryCreatorComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openLibraryEditDialog(libraryId: number): DynamicDialogRef | null {
|
||||
return this.openDialog(LibraryCreatorComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
mode: 'edit',
|
||||
libraryId: libraryId
|
||||
}
|
||||
async openDirectoryPickerDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {DirectoryPickerComponent} = await import('../components/directory-picker/directory-picker.component');
|
||||
return this.openDialog(DirectoryPickerComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openShelfEditDialog(shelfId: number): DynamicDialogRef | null {
|
||||
return this.openDialog(ShelfEditDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
shelfId: shelfId
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
openFileUploadDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(BookUploaderComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
async openLibraryEditDialog(libraryId: number): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {LibraryCreatorComponent} = await import('../../features/library-creator/library-creator.component');
|
||||
return this.openDialog(LibraryCreatorComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
mode: 'edit',
|
||||
libraryId: libraryId
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openCreateUserDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(CreateUserDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
async openLibraryMetadataFetchDialog(libraryId: number): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {MetadataFetchOptionsComponent} = await import('../../features/metadata/component/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component');
|
||||
return this.openDialog(MetadataFetchOptionsComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
libraryId: libraryId,
|
||||
metadataRefreshType: MetadataRefreshType.LIBRARY,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openUserProfileDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(UserProfileDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
async openShelfEditDialog(shelfId: number): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {ShelfEditDialogComponent} = await import('../../features/book/components/shelf-edit-dialog/shelf-edit-dialog.component');
|
||||
return this.openDialog(ShelfEditDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
shelfId: shelfId
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openMagicShelfCreateDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(MagicShelfComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
async openFileUploadDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {BookUploaderComponent} = await import('../components/book-uploader/book-uploader.component');
|
||||
return this.openDialog(BookUploaderComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openMagicShelfEditDialog(shelfId: number): DynamicDialogRef | null {
|
||||
return this.openDialog(MagicShelfComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
id: shelfId,
|
||||
editMode: true,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
openVersionChangelogDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(VersionChangelogDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
async openCreateUserDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {CreateUserDialogComponent} = await import('../../features/settings/user-management/create-user-dialog/create-user-dialog.component');
|
||||
return this.openDialog(CreateUserDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openEmailRecipientDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(CreateEmailRecipientDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
async openUserProfileDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {UserProfileDialogComponent} = await import('../../features/settings/user-profile-dialog/user-profile-dialog.component');
|
||||
return this.openDialog(UserProfileDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openEmailProviderDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(CreateEmailProviderDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
async openMagicShelfCreateDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {MagicShelfComponent} = await import('../../features/magic-shelf/component/magic-shelf-component');
|
||||
return this.openDialog(MagicShelfComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openBookdropFinalizeResultDialog(result: BookdropFinalizeResult): DynamicDialogRef | null {
|
||||
return this.openDialog(BookdropFinalizeResultDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
result: result,
|
||||
},
|
||||
async openMagicShelfEditDialog(shelfId: number): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {MagicShelfComponent} = await import('../../features/magic-shelf/component/magic-shelf-component');
|
||||
return this.openDialog(MagicShelfComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
id: shelfId,
|
||||
editMode: true,
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openMetadataReviewDialog(taskId: string): DynamicDialogRef | null {
|
||||
return this.openDialog(MetadataReviewDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
taskId,
|
||||
},
|
||||
async openVersionChangelogDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {VersionChangelogDialogComponent} = await import('../layout/layout-sidebar/version-changelog-dialog/version-changelog-dialog.component');
|
||||
return this.openDialog(VersionChangelogDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openIconPickerDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(IconPickerComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
async openEmailRecipientDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {CreateEmailRecipientDialogComponent} = await import('../../features/settings/email-v2/create-email-recipient-dialog/create-email-recipient-dialog.component');
|
||||
return this.openDialog(CreateEmailRecipientDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async openEmailProviderDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {CreateEmailProviderDialogComponent} = await import('../../features/settings/email-v2/create-email-provider-dialog/create-email-provider-dialog.component');
|
||||
return this.openDialog(CreateEmailProviderDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async openBookdropFinalizeResultDialog(result: BookdropFinalizeResult): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {BookdropFinalizeResultDialogComponent} = await import('../../features/bookdrop/component/bookdrop-finalize-result-dialog/bookdrop-finalize-result-dialog.component');
|
||||
return this.openDialog(BookdropFinalizeResultDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
result: result,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async openMetadataReviewDialog(taskId: string): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {MetadataReviewDialogComponent} = await import('../../features/metadata/component/metadata-review-dialog/metadata-review-dialog-component');
|
||||
return this.openDialog(MetadataReviewDialogComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
|
||||
data: {
|
||||
taskId,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async openIconPickerDialog(): Promise<DynamicDialogRef | null> {
|
||||
return this.launchLazyDialog(async () => {
|
||||
const {IconPickerComponent} = await import('../components/icon-picker/icon-picker-component');
|
||||
return this.openDialog(IconPickerComponent, {
|
||||
showHeader: false,
|
||||
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,8 @@
|
||||
"magicShelfDeletedDetail": "Magic shelf was deleted",
|
||||
"magicShelfDeleteFailedDetail": "Failed to delete shelf",
|
||||
"magicShelfJsonCopiedDetail": "Magic shelf JSON copied to clipboard",
|
||||
"failedSummary": "Failed"
|
||||
"failedSummary": "Failed",
|
||||
"dialogLoadFailedDetail": "An error occurred while loading the dialog. Please try again."
|
||||
},
|
||||
"loading": {
|
||||
"deletingLibrary": "Deleting library '{{ name }}'..."
|
||||
|
||||
@@ -30,5 +30,6 @@
|
||||
"cardSizeControls": "Card size controls",
|
||||
"on": "On",
|
||||
"off": "Off",
|
||||
"moreActionsFor": "More actions for {{label}}"
|
||||
"moreActionsFor": "More actions for {{label}}",
|
||||
"dialogLoadError": "An error occurred while loading the dialog. Please try again."
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ import { GlobalErrorHandler } from './app/core/errors/global-error-handler';
|
||||
import { PwaUpdateService } from './app/core/services/pwa-update.service';
|
||||
import { initializeAuthFactory } from './app/core/security/auth-initializer';
|
||||
import { StartupService } from './app/shared/service/startup.service';
|
||||
import { provideCharts, withDefaultRegisterables } from 'ng2-charts';
|
||||
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
||||
import { provideServiceWorker } from '@angular/service-worker';
|
||||
import { provideTransloco } from '@jsverse/transloco';
|
||||
import { AVAILABLE_LANGS, TranslocoInlineLoader } from './app/core/config/transloco-loader';
|
||||
@@ -28,7 +26,6 @@ import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query-exper
|
||||
bootstrapApplication(AppComponent, {
|
||||
providers: [
|
||||
provideZonelessChangeDetection(),
|
||||
provideCharts(withDefaultRegisterables(), ChartDataLabels),
|
||||
provideTanStackQuery(new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
|
||||
Reference in New Issue
Block a user