Support multi select for metadata

This commit is contained in:
aditya.chandel
2025-01-08 11:57:05 -07:00
parent 65b7e6df8d
commit ccc2fa23b6
16 changed files with 632 additions and 47 deletions
@@ -10,7 +10,7 @@
<th class="max-w-16">Cover</th>
<th class="w-1/2 max-w-52 overflow-hidden truncate" pResizableColumn>Title</th>
<th class="w-1/6 max-w-48 overflow-hidden truncate">Publisher</th>
<th class="w-1/12 max-w-40 overflow-hidden truncate" pResizableColumn>Subtitle</th>
<th class="w-1/8 max-w-44 overflow-hidden truncate" pResizableColumn>Subtitle</th>
<th class="w-1/8 max-w-36 overflow-hidden truncate">ISBN</th>
<th class="w-1/8 max-w-32 overflow-hidden truncate">Language</th>
<th class="w-1/8 max-w-36 overflow-hidden truncate">Rating</th>
@@ -21,12 +21,10 @@
</ng-template>
<ng-template #body let-book>
<tr style="height:46px">
<td class="w-6 h-6">
<img [src]="getBookCoverUrl(book.id)" alt="Book Cover" class="size-7"/>
</td>
<td class="w-1/2 max-w-52 overflow-hidden truncate" [title]="book.metadata?.title">{{ book.metadata?.title }}</td>
<td (click)="openMetadataCenter(book.id)" class="w-6 h-6"><img [src]="getBookCoverUrl(book.id)" alt="Book Cover" class="size-7"/></td>
<td (click)="openMetadataCenter(book.id)" class="w-1/2 max-w-52 overflow-hidden truncate" [title]="book.metadata?.title">{{ book.metadata?.title }} </td>
<td class="w-1/6 max-w-48 overflow-hidden truncate">{{ book.metadata?.publisher }}</td>
<td class="w-1/12 max-w-40 overflow-hidden truncate">{{ book.metadata?.subtitle }}</td>
<td class="w-1/8 max-w-44 overflow-hidden truncate">{{ book.metadata?.subtitle }}</td>
<td class="w-1/8 max-w-36 overflow-hidden truncate">{{ book.metadata?.isbn10 }}</td>
<td class="w-1/8 max-w-32 overflow-hidden truncate">{{ book.metadata?.language }}</td>
<td class="w-1/8 max-w-36 overflow-hidden truncate">
@@ -7,6 +7,8 @@ import {ProgressSpinner} from 'primeng/progressspinner';
import {BookService} from '../../service/book.service';
import {Rating} from 'primeng/rating';
import {FormsModule} from '@angular/forms';
import {BookMetadataCenterComponent} from '../../../book-metadata-center/book-metadata-center.component';
import {DialogService} from 'primeng/dynamicdialog';
@Component({
selector: 'app-book-table',
@@ -25,11 +27,38 @@ import {FormsModule} from '@angular/forms';
export class BookTableComponent {
bookState$: Observable<BookState>;
constructor(private bookService: BookService) {
constructor(private bookService: BookService, private dialogService: DialogService) {
this.bookState$ = this.bookService.bookState$;
}
getBookCoverUrl(bookId: number): string {
return this.bookService.getBookCoverUrl(bookId);
}
openMetadataCenter(id: number) {
this.openBookDetailsDialog(id);
}
openBookDetailsDialog(bookId: number): void {
this.bookService.getBookByIdFromAPI(bookId, true).subscribe(({
next: (book) => {
this.dialogService.open(BookMetadataCenterComponent, {
header: 'Open book details',
modal: true,
closable: true,
width: '1200px',
height: '835px',
showHeader: false,
closeOnEscape: true,
dismissableMask: true,
data: {
book: book
}
});
},
error: (error) => {
console.error('Error fetching book:', error);
}
}))
}
}
+4 -3
View File
@@ -1,5 +1,5 @@
import {Shelf} from './shelf.model';
import {SafeUrl} from '@angular/platform-browser';
import {Provider} from './provider.model';
export interface Book {
id: number;
@@ -30,8 +30,8 @@ export interface BookMetadata {
export interface FetchedMetadata {
bookId: number | null;
googleBookId: string | null;
amazonBookId: string | null;
provider: string,
providerBookId: string,
title: string | null;
subtitle?: string | null;
publisher: string | null;
@@ -39,6 +39,7 @@ export interface FetchedMetadata {
description: string | null;
isbn13: string | null;
isbn10: string | null;
asin: string | null;
pageCount: number | null;
thumbnailUrl: string | undefined;
language: string | null;
@@ -1,6 +1,6 @@
export interface FetchMetadataRequest {
bookId: number,
provider: string,
providers: string[],
title: string,
isbn: string,
author: string
@@ -1,5 +1,5 @@
export enum Provider {
AMAZON = 'Amazon',
GOOGLE_BOOKS = 'Google Books',
GOOGLE_BOOKS_API = 'Google Books (API)'
GOOGLE = 'Google Books',
GOOD_READS = 'Good Reads'
}