diff --git a/booklore-ui/src/app/app-routing.module.ts b/booklore-ui/src/app/app-routing.module.ts index f8b771a45..e3f559859 100644 --- a/booklore-ui/src/app/app-routing.module.ts +++ b/booklore-ui/src/app/app-routing.module.ts @@ -4,7 +4,6 @@ import {PdfViewerComponent} from './book/component/pdf-viewer/pdf-viewer.compone import {DashboardComponent} from './book/component/dashboard/dashboard.component'; import {BookBrowserComponent} from './book/component/book-browser/book-browser.component'; import {AppLayoutComponent} from './book/component/layout/app.layout.component'; -import {BookTableComponent} from './book/component/book-table/book-table.component'; const routes: Routes = [ { diff --git a/booklore-ui/src/app/book/component/book-browser/book-browser.component.ts b/booklore-ui/src/app/book/component/book-browser/book-browser.component.ts index 9ac069fac..295d5e568 100644 --- a/booklore-ui/src/app/book/component/book-browser/book-browser.component.ts +++ b/booklore-ui/src/app/book/component/book-browser/book-browser.component.ts @@ -300,6 +300,10 @@ export class BookBrowserComponent implements OnInit { this.bookTitle$.next(newTitle); } + openMetadataOptionsDialog() { + + } + openShelfAssigner() { this.dynamicDialogRef = this.dialogService.open(ShelfAssignerComponent, { header: `Update Books Shelves`, diff --git a/booklore-ui/src/app/book/service/library-shelf-menu.service.ts b/booklore-ui/src/app/book/service/library-shelf-menu.service.ts index d6aa2812e..fbdf4da86 100644 --- a/booklore-ui/src/app/book/service/library-shelf-menu.service.ts +++ b/booklore-ui/src/app/book/service/library-shelf-menu.service.ts @@ -7,6 +7,8 @@ import {Library} from '../model/library.model'; import {Shelf} from '../model/shelf.model'; import {MetadataService} from './metadata.service'; import {MetadataProvider} from '../model/provider.model'; +import {DialogService} from 'primeng/dynamicdialog'; +import {MetadataFetchOptionsComponent} from '../../metadata-fetch-options/metadata-fetch-options.component'; @Injectable({ providedIn: 'root', @@ -18,8 +20,10 @@ export class LibraryShelfMenuService { private libraryService: LibraryService, private shelfService: ShelfService, private metadataService: MetadataService, - private router: Router - ) {} + private router: Router, + private dialogService: DialogService + ) { + } initializeLibraryMenuItems(entity: Library | Shelf | null): MenuItem[] { return [ @@ -85,7 +89,15 @@ export class LibraryShelfMenuService { label: 'Refresh Books Metadata', icon: 'pi pi-database', command: () => { - this.confirmationService.confirm({ + this.dialogService.open(MetadataFetchOptionsComponent, { + header: 'Metadata Refresh Options', + modal: true, + closable: true, + data: { + libraryId: entity?.id + } + }) + /*this.confirmationService.confirm({ message: `Are you sure you want to refresh the metadata for all books in the library: "${entity?.name}"?`, header: 'Confirm Library Metadata Refresh', rejectButtonProps: { @@ -120,7 +132,7 @@ export class LibraryShelfMenuService { } }); } - }); + });*/ } } ] diff --git a/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.html b/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.html new file mode 100644 index 000000000..a1ef36de4 --- /dev/null +++ b/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.html @@ -0,0 +1,77 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Book FieldBaseHigher PrecedenceHighest Precedence
+ + + + + + + + +
{{ field | titlecase }} + + + + + + + + +
+ +
+
+

Refresh covers:

+ +
+
+ + +
+ +
+ +
diff --git a/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.scss b/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.scss new file mode 100644 index 000000000..9176c9d05 --- /dev/null +++ b/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.scss @@ -0,0 +1,4 @@ +.custom-table { + border: 1px solid var(--border-color); + border-radius: var(--card-border); +} diff --git a/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.ts b/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.ts new file mode 100644 index 000000000..35295f0cb --- /dev/null +++ b/booklore-ui/src/app/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component.ts @@ -0,0 +1,83 @@ +import {Component} from '@angular/core'; +import {Select, SelectChangeEvent} from 'primeng/select'; +import {FormsModule} from '@angular/forms'; +import {NgForOf, TitleCasePipe} from '@angular/common'; +import {Checkbox} from 'primeng/checkbox'; +import {Button} from 'primeng/button'; +import {MessageService} from 'primeng/api'; + +interface FieldProvider { + defaultProvider: string | null; + higherPriorityProvider: string | null; + highestPriorityProvider: string | null; +} + +@Component({ + selector: 'app-metadata-advanced-fetch-options', + templateUrl: './metadata-advanced-fetch-options.component.html', + imports: [Select, FormsModule, NgForOf, Checkbox, Button, TitleCasePipe], + styleUrl: './metadata-advanced-fetch-options.component.scss', + standalone: true +}) +export class MetadataAdvancedFetchOptionsComponent { + + providers: string[] = ['Amazon', 'Google', 'GoodReads']; + refreshCovers: boolean = false; + + defaultProvider = { + placeholder: 'Select All', + value: '' + }; + higherPriorityProvider = { + placeholder: 'Select All', + value: '' + }; + highestPriorityProvider = { + placeholder: 'Select All', + value: '' + }; + + fields: string[] = ['title', 'description', 'authors', 'categories', 'cover']; + + tableState: Record = this.fields.reduce>((acc, field) => { + acc[field] = { + defaultProvider: null, + higherPriorityProvider: null, + highestPriorityProvider: null + }; + return acc; + }, {}); + + constructor(private messageService: MessageService) { + } + + + syncProvider(event: SelectChangeEvent, providerType: keyof FieldProvider) { + for (const field of Object.keys(this.tableState)) { + this.tableState[field][providerType] = event.value; + } + } + + individualProviderChanged(providerType: keyof FieldProvider) { + const providerMap: Record = { + defaultProvider: this.defaultProvider, + higherPriorityProvider: this.higherPriorityProvider, + highestPriorityProvider: this.highestPriorityProvider + }; + const provider = providerMap[providerType]; + provider.value = ''; + provider.placeholder = 'Overridden'; + } + + submit() { + const allProvidersSelected = Object.keys(this.tableState).every(field => { + return this.tableState[field].defaultProvider !== null; + }); + console.log(this.tableState) + if (allProvidersSelected) { + + } else { + this.messageService.add({severity: 'error', summary: 'Error', life: 5000, detail: 'Base provider must be selected for all the book fields.'}); + } + } +} diff --git a/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.html b/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.html new file mode 100644 index 000000000..0826adbb6 --- /dev/null +++ b/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.html @@ -0,0 +1,18 @@ +
+ + + + +
+

Refresh covers:

+ +
+ + + +
diff --git a/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.scss b/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.scss new file mode 100644 index 000000000..9b6ec299e --- /dev/null +++ b/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.scss @@ -0,0 +1,4 @@ +.custom-table { + border: 1px solid var(--border-color); /* Custom border color */ + border-radius: var(--card-border); /* Custom border radius */ +} diff --git a/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.ts b/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.ts new file mode 100644 index 000000000..fffaed6d7 --- /dev/null +++ b/booklore-ui/src/app/metadata-basic-fetch-options/metadata-basic-fetch-options.component.ts @@ -0,0 +1,23 @@ +import { Component } from '@angular/core'; +import {Button} from 'primeng/button'; +import {Checkbox} from 'primeng/checkbox'; +import {Select} from 'primeng/select'; +import {FormsModule} from '@angular/forms'; + +@Component({ + selector: 'app-metadata-basic-fetch-options', + standalone: true, + templateUrl: './metadata-basic-fetch-options.component.html', + imports: [ + Button, + Checkbox, + Select, + FormsModule + ], + styleUrl: './metadata-basic-fetch-options.component.scss' +}) +export class MetadataBasicFetchOptionsComponent { + providers: string[] = ['Amazon', 'Google', 'GoodReads']; + selectedProvider!: string; + refreshCovers: boolean = false; +} diff --git a/booklore-ui/src/app/metadata-fetch-options/metadata-fetch-options.component.html b/booklore-ui/src/app/metadata-fetch-options/metadata-fetch-options.component.html new file mode 100644 index 000000000..3fbce0715 --- /dev/null +++ b/booklore-ui/src/app/metadata-fetch-options/metadata-fetch-options.component.html @@ -0,0 +1,13 @@ +
+ + + + + + + + + + + +
diff --git a/booklore-ui/src/app/metadata-fetch-options/metadata-fetch-options.component.scss b/booklore-ui/src/app/metadata-fetch-options/metadata-fetch-options.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/booklore-ui/src/app/metadata-fetch-options/metadata-fetch-options.component.ts b/booklore-ui/src/app/metadata-fetch-options/metadata-fetch-options.component.ts new file mode 100644 index 000000000..92416b61a --- /dev/null +++ b/booklore-ui/src/app/metadata-fetch-options/metadata-fetch-options.component.ts @@ -0,0 +1,44 @@ +import {Component} from '@angular/core'; +import {DynamicDialogConfig} from 'primeng/dynamicdialog'; +import {MetadataAdvancedFetchOptionsComponent} from '../metadata-advanced-fetch-options/metadata-advanced-fetch-options.component'; +import {Divider} from 'primeng/divider'; +import {Button} from 'primeng/button'; +import {MetadataBasicFetchOptionsComponent} from '../metadata-basic-fetch-options/metadata-basic-fetch-options.component'; +import {NgIf} from '@angular/common'; + +@Component({ + selector: 'app-metadata-fetch-options', + standalone: true, + templateUrl: './metadata-fetch-options.component.html', + imports: [ + MetadataAdvancedFetchOptionsComponent, + Divider, + Button, + MetadataBasicFetchOptionsComponent, + NgIf + ], + styleUrl: './metadata-fetch-options.component.scss' +}) +export class MetadataFetchOptionsComponent { + isBasicMode: boolean = false; + isDialogVisible: boolean = false; + libraryId!: number; + + constructor(private dynamicDialogConfig: DynamicDialogConfig) { + this.libraryId = dynamicDialogConfig.data.libraryId; + } + + toggleMode() { + this.isBasicMode = !this.isBasicMode; + } + + openDialog() { + this.isDialogVisible = true; + } + + // Close the dialog (if needed) + closeDialog() { + this.isDialogVisible = false; + } + +}