Organize code some more

This commit is contained in:
aditya.chandel
2025-10-12 02:13:10 -06:00
parent 4453115149
commit a7622f1df1
12 changed files with 34 additions and 34 deletions
@@ -0,0 +1,80 @@
import {inject, Injectable} from '@angular/core';
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
import {GithubSupportDialog} from '../components/github-support-dialog/github-support-dialog';
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';
@Injectable({
providedIn: 'root',
})
export class DialogLauncherService {
dialogService = inject(DialogService);
open(options: { component: any; header: string; top?: string; width?: string }): DynamicDialogRef {
const isMobile = window.innerWidth <= 768;
const {component, header, top, width} = options;
return this.dialogService.open(component, {
header,
modal: true,
closable: true,
contentStyle: {
overflowY: 'hidden',
},
style: {
position: 'absolute',
...(top ? {top} : {}),
...(isMobile
? {
width: '90vw',
maxWidth: '90vw',
minWidth: '90vw',
}
: width
? {width}
: {}),
},
});
}
openGithubSupportDialog(): void {
this.open({
component: GithubSupportDialog,
header: 'Support Booklore',
top: '15%'
});
}
openLibraryCreatorDialog(): void {
this.open({
component: LibraryCreatorComponent,
header: 'Create New Library',
top: '15%'
});
}
openFileUploadDialog(): void {
this.open({
component: BookUploaderComponent,
header: 'Book Uploader',
top: '10%'
});
}
openUserProfileDialog(): void {
this.open({
component: UserProfileDialogComponent,
header: 'User Profile Information',
top: '10%'
});
}
openMagicShelfDialog(): void {
this.open({
component: MagicShelfComponent,
header: 'Magic Shelf Creator'
});
}
}