WIP: New metadata engine

This commit is contained in:
aditya.chandel
2025-01-01 01:12:27 -07:00
parent 1d06f83de8
commit ea2ac58f03
30 changed files with 1145 additions and 83 deletions
@@ -74,7 +74,9 @@ export class BookCardComponent implements OnInit {
{
label: 'View metadata',
icon: 'pi pi-info-circle',
command: () => this.openBookInfo(this.book),
command: () => {
this.openBookInfo(this.book)
},
},
],
},
@@ -20,7 +20,7 @@
<div *ngFor="let metadata of bookMetadataList" class="book-metadata">
<div class="metadata-header">
<div class="book-image-container">
<img class="book-image" [src]="metadata.thumbnail || 'assets/book-cover-metadata.png'" alt="Book Cover"/>
<!--<img class="book-image" [src]="metadata.thumbnail || 'assets/book-cover-metadata.png'" alt="Book Cover"/>-->
<p-button class="select-button" (click)="selectMetadata(metadata)">Select</p-button>
</div>
<div>
@@ -37,7 +37,7 @@
{{ book?.metadata?.title }}<span *ngIf="book?.metadata?.subtitle">: {{ book?.metadata?.subtitle }}</span>
</h1>
<div class="button-group">
<p-button [rounded]="true" [raised]="true" [outlined]="true" (onClick)="openEditDialog(book?.id, book?.libraryId)" icon="pi pi-pencil"></p-button>
<p-button [rounded]="true" [raised]="true" [outlined]="true" (onClick)="openEditDialog(book?.id!, book?.libraryId!)" icon="pi pi-pencil"></p-button>
<p-button [rounded]="true" [raised]="true" [outlined]="true" (onClick)="readBook(book!)" icon="pi pi-eye"></p-button>
<p-button [rounded]="true" [raised]="true" [outlined]="true" icon="pi pi-download"></p-button>
</div>
@@ -9,6 +9,9 @@ import {Subscription} from 'rxjs';
import {TagModule} from 'primeng/tag';
import {BookService} from '../../service/book.service';
import {LibraryService} from '../../service/library.service';
import {MetadataSearcherComponent} from '../../../metadata-searcher/metadata-searcher.component';
import {ProgressSpinner} from 'primeng/progressspinner';
import {LoadingService} from '../../../loading.service';
@Component({
selector: 'app-book-metadata',
@@ -27,18 +30,18 @@ export class BookMetadataComponent implements OnInit, OnDestroy {
previousBookId: number | null = null;
private routeSubscription!: Subscription;
private dialogRef: DynamicDialogRef | undefined;
private dialogRef!: DynamicDialogRef;
private dialogSubscription?: Subscription;
constructor(
private bookService: BookService, private activatedRoute: ActivatedRoute,
private dialogService: DialogService, private router: Router,
private libraryService: LibraryService) {
private libraryService: LibraryService, private loadingService: LoadingService,) {
}
ngOnInit(): void {
this.routeSubscription = this.activatedRoute.paramMap.subscribe((paramMap) => {
const bookId = +paramMap.get('bookId')!;
const bookId = +paramMap.get('bookId')!;
const libraryId = +paramMap.get('libraryId')!;
if (bookId && libraryId) {
this.loadBookWithNeighbors(bookId, libraryId);
@@ -75,7 +78,47 @@ export class BookMetadataComponent implements OnInit, OnDestroy {
return 'No authors available';
}
openEditDialog(bookId: number | undefined, libraryId: number | undefined) {
openEditDialog(bookId: number, libraryId: number) {
this.loadingService.show();
this.bookService.getFetchBookMetadata(bookId).subscribe({
next: (fetchedMetadata) => {
this.loadingService.hide();
this.dialogRef = this.dialogService.open(MetadataSearcherComponent, {
header: 'Update Book Metadata',
modal: true,
closable: true,
width: '1350px',
height: '1000px',
contentStyle: {
'overflow-y': 'auto',
'max-height': 'calc(100vh - 150px)',
'padding': '1.25rem 1.25rem 0',
},
data: {
currentMetadata: this.book?.metadata,
fetchedMetadata: fetchedMetadata,
book: this.book
}
});
if (this.dialogRef) {
this.dialogSubscription = this.dialogRef.onClose.subscribe(() => {
if (this.book?.id && this.book?.libraryId) {
this.loadBookWithNeighbors(this.book.id, this.book.libraryId);
}
});
} else {
console.error('DialogRef is undefined or null');
}
},
error: (error) => {
this.loadingService.hide();
console.error('Error fetching metadata:', error);
}
});
}
/*openEditDialog1(bookId: number | undefined, libraryId: number | undefined) {
this.dialogRef = this.dialogService.open(BookMetadataDialogComponent, {
header: 'Metadata: Google Books',
modal: true,
@@ -94,7 +137,7 @@ export class BookMetadataComponent implements OnInit, OnDestroy {
this.loadBookWithNeighbors(this.book.id, this.book.libraryId);
}
});
}
}*/
coverImageSrc(bookId: number | undefined): string {
if (bookId === null) {