fix: Consistent dialogs (#1842)

* fix/consistent-dialogs

* fix: enforce consistent mobile dialog width

* fix: cover search dialog image size
This commit is contained in:
Muppetteer
2025-12-13 21:08:43 -07:00
committed by GitHub
parent b64c30f3bc
commit 0486a4f070
25 changed files with 333 additions and 420 deletions
@@ -6,15 +6,14 @@ import {ProgressBarModule} from 'primeng/progressbar';
import {ButtonModule} from 'primeng/button';
import {Divider} from 'primeng/divider';
import {Tooltip} from 'primeng/tooltip';
import {DialogService} from 'primeng/dynamicdialog';
import {MessageService} from 'primeng/api';
import {MetadataBatchProgressNotification, MetadataBatchStatus, MetadataBatchStatusLabels} from '../../model/metadata-batch-progress.model';
import {MetadataProgressService} from '../../service/metadata-progress-service';
import {MetadataReviewDialogComponent} from '../../../features/metadata/component/metadata-review-dialog/metadata-review-dialog-component';
import {MetadataTaskService} from '../../../features/book/service/metadata-task';
import {Tag} from 'primeng/tag';
import {TaskService} from '../../../features/settings/task-management/task.service';
import {DialogLauncherService} from '../../services/dialog-launcher.service';
@Component({
selector: 'app-metadata-progress-widget',
@@ -27,7 +26,7 @@ export class MetadataProgressWidgetComponent implements OnInit, OnDestroy {
activeTasks: { [taskId: string]: MetadataBatchProgressNotification } = {};
private destroy$ = new Subject<void>();
private dialogService = inject(DialogService);
private dialogLauncherService = inject(DialogLauncherService);
private metadataProgressService = inject(MetadataProgressService);
private metadataTaskService = inject(MetadataTaskService);
private taskService = inject(TaskService);
@@ -102,14 +101,7 @@ export class MetadataProgressWidgetComponent implements OnInit, OnDestroy {
}
reviewTask(taskId: string): void {
this.dialogService.open(MetadataReviewDialogComponent, {
showHeader: false,
width: '90vw',
height: '90vh',
data: {taskId},
closable: false,
modal: true
});
this.dialogLauncherService.openMetadataReviewDialog(taskId);
}
cancelTask(taskId: string): void {
@@ -9,10 +9,10 @@ import {ShelfService} from '../../../../features/book/service/shelf.service';
import {BookService} from '../../../../features/book/service/book.service';
import {LibraryShelfMenuService} from '../../../../features/book/service/library-shelf-menu.service';
import {AppVersion, VersionService} from '../../../service/version.service';
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
import {VersionChangelogDialogComponent} from './version-changelog-dialog/version-changelog-dialog.component';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {UserService} from '../../../../features/settings/user-management/user.service';
import {MagicShelfService, MagicShelfState} from '../../../../features/magic-shelf/service/magic-shelf.service';
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
@Component({
selector: 'app-menu',
@@ -34,7 +34,7 @@ export class AppMenuComponent implements OnInit {
private bookService = inject(BookService);
private versionService = inject(VersionService);
private libraryShelfMenuService = inject(LibraryShelfMenuService);
private dialogService = inject(DialogService);
private dialogLauncherService = inject(DialogLauncherService);
private userService = inject(UserService);
private magicShelfService = inject(MagicShelfService);
@@ -198,20 +198,7 @@ export class AppMenuComponent implements OnInit {
}
openChangelogDialog() {
const isMobile = window.innerWidth <= 768;
this.dynamicDialogRef = this.dialogService.open(VersionChangelogDialogComponent, {
header: 'What’s New',
modal: true,
closable: true,
style: {
position: 'absolute',
top: '10%',
bottom: '10%',
width: isMobile ? '90vw' : '800px',
maxWidth: isMobile ? '90vw' : '800px',
minWidth: isMobile ? '90vw' : '800px',
},
});
this.dialogLauncherService.openVersionChangelogDialog();
}
getVersionUrl(version: string | undefined): string {
@@ -155,13 +155,13 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
openDialog(item: any) {
if (item.type === 'library' && this.canManipulateLibrary) {
this.dialogLauncher.openLibraryCreatorDialog();
this.dialogLauncher.openLibraryCreateDialog();
}
if (item.type === 'magicShelf') {
this.dialogLauncher.openMagicShelfDialog();
this.dialogLauncher.openMagicShelfCreateDialog();
}
if (item.type === 'shelf') {
this.bookDialogHelperService.openShelfCreator();
this.bookDialogHelperService.openShelfCreatorDialog();
}
}
@@ -2,7 +2,7 @@ import {Component, ElementRef, OnDestroy, ViewChild} from '@angular/core';
import {MenuItem} from 'primeng/api';
import {LayoutService} from '../layout-main/service/app.layout.service';
import {Router, RouterLink} from '@angular/router';
import {DialogService as PrimeDialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {TooltipModule} from 'primeng/tooltip';
import {FormsModule} from '@angular/forms';
import {InputTextModule} from 'primeng/inputtext';
@@ -72,7 +72,6 @@ export class AppTopBarComponent implements OnDestroy {
constructor(
public layoutService: LayoutService,
public dialogService: PrimeDialogService,
private notificationService: NotificationEventService,
private router: Router,
private authService: AuthService,
@@ -120,7 +119,7 @@ export class AppTopBarComponent implements OnDestroy {
}
openLibraryCreatorDialog(): void {
this.dialogLauncher.openLibraryCreatorDialog();
this.dialogLauncher.openLibraryCreateDialog();
}
openFileUploadDialog(): void {
@@ -1,7 +1,6 @@
import {inject, Injectable} from '@angular/core';
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
import {IconPickerComponent} from '../components/icon-picker/icon-picker-component';
import {Observable} from 'rxjs';
import {DialogLauncherService} from '../services/dialog-launcher.service';
export interface IconSelection {
type: 'PRIME_NG' | 'CUSTOM_SVG';
@@ -10,23 +9,10 @@ export interface IconSelection {
@Injectable({providedIn: 'root'})
export class IconPickerService {
private dialog = inject(DialogService);
private dialogLauncherService = inject(DialogLauncherService);
open(): Observable<IconSelection> {
const isMobile = window.innerWidth <= 768;
const ref: DynamicDialogRef | null = this.dialog.open(IconPickerComponent, {
header: 'Choose an Icon',
modal: true,
closable: true,
style: {
position: 'absolute',
top: '10%',
bottom: '10%',
width: isMobile ? '90vw' : '800px',
maxWidth: isMobile ? '90vw' : '800px',
minWidth: isMobile ? '90vw' : '800px',
}
});
const ref = this.dialogLauncherService.openIconPickerDialog();
return ref!.onClose as Observable<IconSelection>;
}
}
@@ -5,6 +5,19 @@ import {LibraryCreatorComponent} from '../../features/library-creator/library-cr
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/component/layout-menu/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 {BookdropFinalizeResult} from '../../features/bookdrop/service/bookdrop.service';
import {MetadataReviewDialogComponent} from '../../features/metadata/component/metadata-review-dialog/metadata-review-dialog-component';
import {MetadataRefreshType} from '../../features/metadata/model/request/metadata-refresh-type.enum';
import {MetadataFetchOptionsComponent} from '../../features/metadata/component/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
import {ShelfEditDialogComponent} from '../../features/book/components/shelf-edit-dialog/shelf-edit-dialog.component';
import {IconPickerComponent} from '../components/icon-picker/icon-picker-component';
@Injectable({
providedIn: 'root',
@@ -13,73 +26,164 @@ export class DialogLauncherService {
dialogService = inject(DialogService);
open(options: { component: any; header: string; top?: string; width?: string; showHeader?: boolean; styleClass?: string }): DynamicDialogRef | null {
const isMobile = window.innerWidth <= 768;
const {component, header, top, width, showHeader = true, styleClass} = options;
private defaultDialogOptions = {
baseZIndex: 10,
closable: true,
dismissableMask: true,
draggable: false,
modal: true,
resizable: false,
showHeader: true,
}
openDialog(component: any, options: {}): DynamicDialogRef | null {
return this.dialogService.open(component, {
header,
showHeader,
modal: true,
closable: true,
styleClass: styleClass,
style: {
position: 'absolute',
...(top ? {top} : {}),
...(isMobile
? {
width: '90vw',
maxWidth: '90vw',
minWidth: '90vw',
}
: width
? {width}
: {}),
...this.defaultDialogOptions,
...options,
});
}
openDashboardSettingsDialog(): DynamicDialogRef | null {
return this.openDialog(DashboardSettingsComponent, {
header: 'Configure Dashboard',
});
}
openGithubSupportDialog(): DynamicDialogRef | null {
return this.openDialog(GithubSupportDialog, {
header: 'Support Booklore',
});
}
openLibraryCreateDialog(): DynamicDialogRef | null {
return this.openDialog(LibraryCreatorComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
});
}
openDirectoryPickerDialog(): DynamicDialogRef | null {
return this.openDialog(DirectoryPickerComponent, {
header: 'Select Media Directory',
styleClass: 'dynamic-dialog-minimal',
});
}
openLibraryEditDialog(libraryId: number): DynamicDialogRef | null {
return this.openDialog(LibraryCreatorComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
data: {
mode: 'edit',
libraryId: libraryId
}
});
}
openLibraryMetadataFetchDialog(libraryId: number): DynamicDialogRef | null {
return this.openDialog(MetadataFetchOptionsComponent, {
header: 'Metadata Refresh Options',
data: {
libraryId: libraryId,
metadataRefreshType: MetadataRefreshType.LIBRARY,
}
});
}
openShelfEditDialog(shelfId: number): DynamicDialogRef | null {
return this.openDialog(ShelfEditDialogComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
data: {
shelfId: shelfId
},
})
}
openFileUploadDialog(): DynamicDialogRef | null {
return this.openDialog(BookUploaderComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
});
}
openCreateUserDialog(): DynamicDialogRef | null {
return this.openDialog(CreateUserDialogComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
});
}
openUserProfileDialog(): DynamicDialogRef | null {
return this.openDialog(UserProfileDialogComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
});
}
openMagicShelfCreateDialog(): DynamicDialogRef | null {
return this.openDialog(MagicShelfComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
});
}
openMagicShelfEditDialog(shelfId: number): DynamicDialogRef | null {
return this.openDialog(MagicShelfComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
data: {
id: shelfId,
editMode: true,
}
})
}
openVersionChangelogDialog(): DynamicDialogRef | null {
return this.openDialog(VersionChangelogDialogComponent, {
header: "What's New",
styleClass: 'dialog-maximal',
});
}
openEmailRecipientDialog(): DynamicDialogRef | null {
return this.openDialog(CreateEmailRecipientDialogComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
});
}
openEmailProviderDialog(): DynamicDialogRef | null {
return this.openDialog(CreateEmailProviderDialogComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
});
}
openBookdropFinalizeResultDialog(result: BookdropFinalizeResult): DynamicDialogRef | null {
return this.openDialog(BookdropFinalizeResultDialogComponent, {
header: 'Import Summary',
data: {
result: result,
},
});
}
openGithubSupportDialog(): void {
this.open({
component: GithubSupportDialog,
header: 'Support Booklore',
showHeader: true,
top: '15%'
openMetadataReviewDialog(taskId: string): DynamicDialogRef | null {
return this.openDialog(MetadataReviewDialogComponent, {
header: 'Review Metadata Proposal',
data: {
taskId,
},
styleClass: 'dialog-maximal',
});
}
openLibraryCreatorDialog(): void {
this.open({
component: LibraryCreatorComponent,
header: 'Create New Library',
styleClass: 'dynamic-dialog-minimal',
showHeader: false
openIconPickerDialog(): DynamicDialogRef | null {
return this.openDialog(IconPickerComponent, {
header: 'Choose an Icon',
styleClass: 'dialog-maximal',
});
}
openFileUploadDialog(): void {
this.open({
component: BookUploaderComponent,
header: 'Book Uploader',
showHeader: false,
styleClass: 'dynamic-dialog-minimal'
});
}
openUserProfileDialog(): void {
this.open({
component: UserProfileDialogComponent,
header: 'User Profile Information',
styleClass: 'dynamic-dialog-minimal',
showHeader: false
});
}
openMagicShelfDialog(): void {
this.open({
component: MagicShelfComponent,
header: 'Magic Shelf Creator',
styleClass: 'dynamic-dialog-minimal',
showHeader: false
});
}
}
}