WIP: Move metadata arrow picker
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<div class="container pt-4 px-2 flex flex-col h-full">
|
||||
<div class="space-y-4 flex-grow">
|
||||
<div class="container pt-4 flex flex-col h-full">
|
||||
<div class="space-y-4 overflow-y-auto flex-1">
|
||||
<div class="flex w-full gap-x-4">
|
||||
<div class="flex flex-col gap-1 w-2/3">
|
||||
<label for="title">Title</label>
|
||||
@@ -77,11 +77,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-x-4 mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Cancel" severity="secondary"/>
|
||||
<p-button label="Save" (onClick)="onSave()"/>
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary"/>
|
||||
<p-button label="Save" icon="pi pi-check" (onClick)="onSave()"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<p-tab value="1">Match Book</p-tab>
|
||||
<p-tab value="2">Manage File</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels style="height: 100%; overflow: hidden;">
|
||||
<p-tabpanels style="height: 100%; overflow: hidden; padding-bottom: 0">
|
||||
<p-tabpanel value="0" style="height: 100%; overflow: hidden;">
|
||||
<app-book-details [bookForm]="metadataForm" (save)="saveBook($event)"></app-book-details>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="1" style="height: 100%; overflow: hidden;">
|
||||
<app-book-match [metadata]="metadataForm"></app-book-match>
|
||||
<app-book-match [book]="book"></app-book-match>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="2" style="height: 100%; overflow: hidden;">
|
||||
<p>I too work!!</p>
|
||||
|
||||
@@ -23,22 +23,13 @@ import {BookMatchComponent} from './book-match/book-match.component';
|
||||
TabPanel
|
||||
]
|
||||
})
|
||||
export class BookInfoTabsComponent implements OnInit {
|
||||
book: Book | undefined;
|
||||
export class BookInfoTabsComponent {
|
||||
book: Book;
|
||||
metadataForm: BookMetadataForm = {} as BookMetadataForm;
|
||||
|
||||
constructor(private bookService: BookService, private dynamicDialogConfig: DynamicDialogConfig,
|
||||
private messageService: MessageService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookService.getBookByIdFromAPI(this.dynamicDialogConfig.data.bookId, true).subscribe({
|
||||
next: (book) => {
|
||||
this.book = book;
|
||||
this.initializeBookForm();
|
||||
},
|
||||
error: (error) => {
|
||||
}
|
||||
});
|
||||
constructor(private bookService: BookService, private dynamicDialogConfig: DynamicDialogConfig, private messageService: MessageService) {
|
||||
this.book = this.dynamicDialogConfig.data.book;
|
||||
this.initializeBookForm();
|
||||
}
|
||||
|
||||
private initializeBookForm(): void {
|
||||
@@ -52,7 +43,6 @@ export class BookInfoTabsComponent implements OnInit {
|
||||
}
|
||||
|
||||
saveBook(bookMetadataForm: BookMetadataForm) {
|
||||
console.log(bookMetadataForm)
|
||||
this.bookService.updateMetadataV2(this.book?.id!, bookMetadataForm).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<form class="flex flex-col w-full h-full pt-4" [formGroup]="form" (ngSubmit)="onSubmit()">
|
||||
<div class="flex w-full gap-x-4 items-end px-2">
|
||||
<form *ngIf="!selectedMetadata" class="flex flex-col w-full h-full pt-4" [formGroup]="form" (ngSubmit)="onSubmit()">
|
||||
<div class="flex w-full gap-x-4 items-end">
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="provider">Provider</label>
|
||||
<p-select
|
||||
@@ -13,17 +13,17 @@
|
||||
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="isbn">ISBN</label>
|
||||
<input pInputText formControlName="isbn" id="isbn" class="w-full" />
|
||||
<input pInputText formControlName="isbn" id="isbn" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 w-2/6">
|
||||
<label for="title">Title</label>
|
||||
<input pInputText formControlName="title" id="title" class="w-full" />
|
||||
<input pInputText formControlName="title" id="title" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 w-2/6">
|
||||
<label for="author">Author</label>
|
||||
<input pInputText formControlName="author" id="author" class="w-full" />
|
||||
<input pInputText formControlName="author" id="author" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -32,13 +32,13 @@
|
||||
</div>
|
||||
|
||||
<div *ngIf="loading" class="flex justify-center items-center">
|
||||
<p-progress-spinner ariaLabel="loading" />
|
||||
<p-progress-spinner ariaLabel="loading"/>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!loading" class="mt-8 flex-1 overflow-y-auto">
|
||||
<div *ngFor="let book of books" class="book-item flex flex-col w-full">
|
||||
<div class="flex w-full flex-row book-item-content">
|
||||
<img [src]="book.thumbnailUrl" alt="Image" class="img-fixed-dimensions pr-2" />
|
||||
<div *ngFor="let book of fetchedMetadata" class="book-item flex flex-col w-full">
|
||||
<div class="flex w-full flex-row book-item-content" (click)="onBookClick(book)">
|
||||
<img [src]="book.thumbnailUrl" alt="Image" class="img-fixed-dimensions pr-2"/>
|
||||
<div class=" flex flex-col w-full m-2">
|
||||
<div class="flex flex-row gap-4 justify-between">
|
||||
<p class="font-bold">{{ truncateText(book['title'], 90) }}</p>
|
||||
@@ -57,5 +57,8 @@
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div *ngIf="selectedMetadata" class="h-full flex-auto">
|
||||
<app-metadata-searcher [book]="book!" [fetchedMetadata]="selectedMetadata"></app-metadata-searcher>
|
||||
</div>
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Select} from 'primeng/select';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {BookMetadataForm} from '../../book/model/book-metadata-form';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
import {Provider} from '../../book/model/provider.model';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {FetchMetadataRequest} from '../../book/model/fetch-metadata-request.model';
|
||||
import {FetchedMetadata} from '../../book/model/book.model';
|
||||
import {DomSanitizer} from '@angular/platform-browser';
|
||||
import {Book, FetchedMetadata} from '../../book/model/book.model';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {MetadataSearcherComponent} from '../metadata-searcher/metadata-searcher.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-match',
|
||||
@@ -25,19 +24,22 @@ import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
Divider,
|
||||
NgForOf,
|
||||
NgIf,
|
||||
ProgressSpinner
|
||||
ProgressSpinner,
|
||||
MetadataSearcherComponent
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
export class BookMatchComponent implements OnChanges {
|
||||
export class BookMatchComponent implements OnInit {
|
||||
|
||||
@Input() book!: Book;
|
||||
|
||||
@Input() metadata!: BookMetadataForm;
|
||||
form: FormGroup;
|
||||
providers = Object.values(Provider);
|
||||
books: FetchedMetadata[] = [];
|
||||
fetchedMetadata: FetchedMetadata[] = [];
|
||||
selectedMetadata!: FetchedMetadata;
|
||||
loading: boolean = false;
|
||||
|
||||
constructor(private fb: FormBuilder, private bookService: BookService, private sanitizer: DomSanitizer) {
|
||||
constructor(private fb: FormBuilder, private bookService: BookService) {
|
||||
this.form = this.fb.group({
|
||||
provider: [null],
|
||||
isbn: [''],
|
||||
@@ -46,15 +48,13 @@ export class BookMatchComponent implements OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['metadata'] && this.metadata) {
|
||||
const firstAuthor = this.metadata.authors && this.metadata.authors.length > 0 ? this.metadata.authors[0] : '';
|
||||
ngOnInit() {
|
||||
const firstAuthor = this.book!.metadata?.authors && this.book!.metadata?.authors.length > 0 ? this.book!.metadata?.authors[0].name : '';
|
||||
this.form.patchValue({
|
||||
isbn: this.metadata.isbn10 || '',
|
||||
title: this.metadata.title || '',
|
||||
isbn: this.book!.metadata?.isbn10 || '',
|
||||
title: this.book!.metadata?.title || '',
|
||||
author: firstAuthor,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get isSearchEnabled(): boolean {
|
||||
@@ -86,7 +86,7 @@ export class BookMatchComponent implements OnChanges {
|
||||
next: (fetchedMetadata) => {
|
||||
console.log('Metadata fetched successfully', fetchedMetadata);
|
||||
this.loading = false;
|
||||
this.books = fetchedMetadata.map((book) => ({
|
||||
this.fetchedMetadata = fetchedMetadata.map((book) => ({
|
||||
...book,
|
||||
thumbnailUrl: book.thumbnailUrl
|
||||
}));
|
||||
@@ -106,4 +106,7 @@ export class BookMatchComponent implements OnChanges {
|
||||
return safeText.length > length ? safeText.substring(0, length) + '...' : safeText;
|
||||
}
|
||||
|
||||
onBookClick(book: FetchedMetadata) {
|
||||
this.selectedMetadata = book;
|
||||
}
|
||||
}
|
||||
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<div class="h-full flex pt-4 flex-col">
|
||||
<div class="overflow-y-auto flex-1">
|
||||
<div class="form-row">
|
||||
<label for="title" class="label">Title</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="title" [(ngModel)]="toUpdateMetadata.title" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('title')"/>
|
||||
<input pInputText id="titleFetched" [(ngModel)]="fetchedMetadata.title" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="authors" class="label">Authors</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="authors" [(ngModel)]="currentAuthorsString" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('authors')"/>
|
||||
<input pInputText id="authorsFetched" [(ngModel)]="fetchedAuthorsString" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="categories" class="label">Categories</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="categories" [(ngModel)]="currentCategoriesString" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('categories')"/>
|
||||
<input pInputText id="categoriesFetched" [(ngModel)]="fetchedCategoriesString" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="publisher" class="label">Publisher</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="publisher" [(ngModel)]="toUpdateMetadata.publisher" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('publisher')"/>
|
||||
<input pInputText id="publisherFetched" [(ngModel)]="fetchedMetadata.publisher" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="publishedDate" class="label">Published</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="publishedDate" [(ngModel)]="toUpdateMetadata.publishedDate" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('publishedDate')"/>
|
||||
<input pInputText id="publishedDateFetched" [(ngModel)]="fetchedMetadata.publishedDate" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="isbn10" class="label">ISBN-10</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="isbn10" [(ngModel)]="toUpdateMetadata.isbn10" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('isbn10')"/>
|
||||
<input pInputText id="isbn10Fetched" [(ngModel)]="fetchedMetadata.isbn10" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="language" class="label">Language</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="language" [(ngModel)]="toUpdateMetadata.language" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('language')"/>
|
||||
<input pInputText id="languageFetched" [(ngModel)]="fetchedMetadata.language" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="language" class="label">Pages</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="pageCount" [(ngModel)]="toUpdateMetadata.pageCount" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('pageCount')"/>
|
||||
<input pInputText id="pageCountFetched" [(ngModel)]="fetchedMetadata.pageCount" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="description" class="label">Description</label>
|
||||
<div class="input-container">
|
||||
<textarea id="description" [(ngModel)]="toUpdateMetadata.description" class="input"></textarea>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('description')"/>
|
||||
<textarea id="descriptionFetched" [(ngModel)]="fetchedMetadata.description" class="input"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label class="label"></label>
|
||||
<div class="input-container">
|
||||
<img *ngIf="!updateThumbnail" [src]="coverImageSrc(book)" alt="Book Thumbnail" class="thumbnail"/>
|
||||
<img *ngIf="updateThumbnail" [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="shouldUpdateThumbnail()"/>
|
||||
<img [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-x-4 mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary"></p-button>
|
||||
<p-button label="Save" icon="pi pi-check" severity="primary" [disabled]="loading" (onClick)="saveMetadata()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 6rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.input-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 50%;
|
||||
padding: 0.5rem;
|
||||
border-radius: 0.25rem;
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
width: 15.625rem;
|
||||
height: 21.875rem;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
margin-left: 2.5rem;
|
||||
margin-right: 2.5rem;
|
||||
}
|
||||
|
||||
.arrow-button {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Book, BookMetadata, FetchedMetadata} from '../../book/model/book.model';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Button} from 'primeng/button';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {Divider} from 'primeng/divider';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-searcher',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-searcher.component.html',
|
||||
imports: [
|
||||
Button,
|
||||
FormsModule,
|
||||
InputText,
|
||||
NgIf,
|
||||
Divider
|
||||
],
|
||||
styleUrls: ['./metadata-searcher.component.scss']
|
||||
})
|
||||
export class MetadataSearcherComponent implements OnInit {
|
||||
|
||||
@Input() fetchedMetadata!: FetchedMetadata;
|
||||
@Input() book!: Book;
|
||||
toUpdateMetadata!: FetchedMetadata;
|
||||
loading: boolean = false;
|
||||
updateThumbnail: boolean = false;
|
||||
|
||||
constructor(private bookService: BookService, private messageService: MessageService) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.log(this.book)
|
||||
this.toUpdateMetadata = this.convertBookMetadataToFetchedMetadata(this.book!.metadata!);
|
||||
}
|
||||
|
||||
copyFetchedToCurrent(field: keyof FetchedMetadata) {
|
||||
if (this.fetchedMetadata && this.toUpdateMetadata) {
|
||||
this.toUpdateMetadata[field] = this.fetchedMetadata[field];
|
||||
}
|
||||
}
|
||||
|
||||
get currentAuthorsString(): string {
|
||||
return this.toUpdateMetadata.authors ? this.toUpdateMetadata.authors.map(author => author).join(', ') : '';
|
||||
}
|
||||
|
||||
set currentAuthorsString(value: string) {
|
||||
this.toUpdateMetadata.authors = value.split(',');
|
||||
}
|
||||
|
||||
get fetchedAuthorsString(): string {
|
||||
return this.fetchedMetadata.authors ? this.fetchedMetadata.authors.map(author => author).join(', ') : '';
|
||||
}
|
||||
|
||||
set fetchedAuthorsString(value: string) {
|
||||
this.fetchedMetadata.authors = value.split(',');
|
||||
}
|
||||
|
||||
get currentCategoriesString(): string {
|
||||
return this.toUpdateMetadata.categories ? this.toUpdateMetadata.categories.map(category => category).join(', ') : '';
|
||||
}
|
||||
|
||||
set currentCategoriesString(value: string) {
|
||||
this.toUpdateMetadata.categories = value.split(',');
|
||||
}
|
||||
|
||||
get fetchedCategoriesString(): string {
|
||||
return this.fetchedMetadata.categories ? this.fetchedMetadata.categories.map(category => category).join(', ') : '';
|
||||
}
|
||||
|
||||
set fetchedCategoriesString(value: string) {
|
||||
this.fetchedMetadata.categories = value.split(',');
|
||||
}
|
||||
|
||||
coverImageSrc(book: Book): string {
|
||||
return this.bookService.getBookCoverUrl(book.id);
|
||||
}
|
||||
|
||||
saveMetadata() {
|
||||
this.loading = true;
|
||||
this.updateFields();
|
||||
this.bookService.updateMetadata(this.book.id, this.toUpdateMetadata).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
this.loading = false;
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book metadata'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateFields() {
|
||||
if (!this.toUpdateMetadata.title && this.fetchedMetadata.title) {
|
||||
this.toUpdateMetadata.title = this.fetchedMetadata.title;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.subtitle && this.fetchedMetadata.subtitle) {
|
||||
this.toUpdateMetadata.subtitle = this.fetchedMetadata.subtitle;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.publisher && this.fetchedMetadata.publisher) {
|
||||
this.toUpdateMetadata.publisher = this.fetchedMetadata.publisher;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.publishedDate && this.fetchedMetadata.publishedDate) {
|
||||
this.toUpdateMetadata.publishedDate = this.fetchedMetadata.publishedDate;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.description && this.fetchedMetadata.description) {
|
||||
this.toUpdateMetadata.description = this.fetchedMetadata.description;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.isbn10 && this.fetchedMetadata.isbn10) {
|
||||
this.toUpdateMetadata.isbn10 = this.fetchedMetadata.isbn10;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.language && this.fetchedMetadata.language) {
|
||||
this.toUpdateMetadata.language = this.fetchedMetadata.language;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.pageCount && this.fetchedMetadata.pageCount) {
|
||||
this.toUpdateMetadata.pageCount = this.fetchedMetadata.pageCount;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.authors || this.toUpdateMetadata.authors.length === 0) {
|
||||
this.toUpdateMetadata.authors = this.fetchedMetadata.authors;
|
||||
}
|
||||
|
||||
if (!this.toUpdateMetadata.categories || this.toUpdateMetadata.categories.length === 0) {
|
||||
this.toUpdateMetadata.categories = this.fetchedMetadata.categories;
|
||||
}
|
||||
|
||||
if (this.updateThumbnail) {
|
||||
this.toUpdateMetadata.thumbnailUrl = this.fetchedMetadata.thumbnailUrl;
|
||||
}
|
||||
}
|
||||
|
||||
shouldUpdateThumbnail() {
|
||||
this.updateThumbnail = true;
|
||||
}
|
||||
|
||||
convertBookMetadataToFetchedMetadata(bookMetadata: BookMetadata): FetchedMetadata {
|
||||
return {
|
||||
bookId: null,
|
||||
googleBookId: bookMetadata.googleBookId || null,
|
||||
amazonBookId: '',
|
||||
title: bookMetadata.title || null,
|
||||
subtitle: bookMetadata.subtitle || null,
|
||||
publisher: bookMetadata.publisher || null,
|
||||
publishedDate: bookMetadata.publishedDate || null,
|
||||
description: bookMetadata.description || null,
|
||||
isbn13: '',
|
||||
isbn10: bookMetadata.isbn10 || null,
|
||||
pageCount: bookMetadata.pageCount || null,
|
||||
thumbnailUrl: '',
|
||||
language: bookMetadata.language || null,
|
||||
rating: null,
|
||||
reviewCount: null,
|
||||
authors: bookMetadata.authors.map(author => author.name),
|
||||
categories: bookMetadata.categories.map(category => category.name),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user