Add rating and review count. Remove asin.
This commit is contained in:
@@ -54,11 +54,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex w-full gap-x-4">
|
<div class="flex w-full gap-x-4">
|
||||||
<div class="flex flex-col w-1/2">
|
<div class="flex flex-col w-1/3">
|
||||||
<label for="aisn">AISN</label>
|
<label for="rating">Rating</label>
|
||||||
<input pInputText id="aisn" class="w-full" formControlName="asin"/>
|
<input pInputText id="rating" class="w-full" formControlName="rating"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col w-1/2">
|
<div class="flex flex-col w-1/3">
|
||||||
|
<label for="reviewCount">Review Count</label>
|
||||||
|
<input pInputText id="reviewCount" class="w-full" formControlName="reviewCount"/>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col w-1/3">
|
||||||
<label for="page-count">Page Count</label>
|
<label for="page-count">Page Count</label>
|
||||||
<input pInputText id="page-count" class="w-full" formControlName="pageCount"/>
|
<input pInputText id="page-count" class="w-full" formControlName="pageCount"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -46,10 +46,11 @@ export class BookDetailsComponent implements OnInit {
|
|||||||
publishedDate: new FormControl(''),
|
publishedDate: new FormControl(''),
|
||||||
isbn10: new FormControl(''),
|
isbn10: new FormControl(''),
|
||||||
isbn13: new FormControl(''),
|
isbn13: new FormControl(''),
|
||||||
asin: new FormControl(''),
|
|
||||||
description: new FormControl(''),
|
description: new FormControl(''),
|
||||||
pageCount: new FormControl(''),
|
pageCount: new FormControl(''),
|
||||||
language: new FormControl(''),
|
language: new FormControl(''),
|
||||||
|
rating: new FormControl(''),
|
||||||
|
reviewCount: new FormControl(''),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,10 +67,11 @@ export class BookDetailsComponent implements OnInit {
|
|||||||
publishedDate: bookMetadata.publishedDate,
|
publishedDate: bookMetadata.publishedDate,
|
||||||
isbn10: bookMetadata.isbn10,
|
isbn10: bookMetadata.isbn10,
|
||||||
isbn13: bookMetadata.isbn13,
|
isbn13: bookMetadata.isbn13,
|
||||||
asin: bookMetadata.asin ? bookMetadata.asin : '',
|
|
||||||
description: bookMetadata.description,
|
description: bookMetadata.description,
|
||||||
pageCount: bookMetadata.pageCount,
|
pageCount: bookMetadata.pageCount == 0 ? null : bookMetadata.pageCount,
|
||||||
language: bookMetadata.language
|
language: bookMetadata.language,
|
||||||
|
rating: bookMetadata.rating,
|
||||||
|
reviewCount: bookMetadata.reviewCount
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -86,9 +88,10 @@ export class BookDetailsComponent implements OnInit {
|
|||||||
publishedDate: this.bookMetadataForm.get('publishedDate')?.value,
|
publishedDate: this.bookMetadataForm.get('publishedDate')?.value,
|
||||||
isbn10: this.bookMetadataForm.get('isbn10')?.value,
|
isbn10: this.bookMetadataForm.get('isbn10')?.value,
|
||||||
isbn13: this.bookMetadataForm.get('isbn13')?.value,
|
isbn13: this.bookMetadataForm.get('isbn13')?.value,
|
||||||
asin: this.bookMetadataForm.get('asin')?.value,
|
|
||||||
description: this.bookMetadataForm.get('description')?.value,
|
description: this.bookMetadataForm.get('description')?.value,
|
||||||
pageCount: this.bookMetadataForm.get('pageCount')?.value,
|
pageCount: this.bookMetadataForm.get('pageCount')?.value,
|
||||||
|
rating: this.bookMetadataForm.get('rating')?.value,
|
||||||
|
reviewCount: this.bookMetadataForm.get('reviewCount')?.value,
|
||||||
language: this.bookMetadataForm.get('language')?.value
|
language: this.bookMetadataForm.get('language')?.value
|
||||||
};
|
};
|
||||||
this.bookService.updateMetadata(updatedBookMetadata.bookId, updatedBookMetadata).subscribe({
|
this.bookService.updateMetadata(updatedBookMetadata.bookId, updatedBookMetadata).subscribe({
|
||||||
|
|||||||
@@ -54,9 +54,10 @@ export class BookInfoTabsComponent implements OnInit {
|
|||||||
publishedDate: metadata?.publishedDate || '',
|
publishedDate: metadata?.publishedDate || '',
|
||||||
isbn10: metadata?.isbn10 || '',
|
isbn10: metadata?.isbn10 || '',
|
||||||
isbn13: metadata?.isbn13 || '',
|
isbn13: metadata?.isbn13 || '',
|
||||||
asin: metadata?.asin || '',
|
|
||||||
description: metadata?.description,
|
description: metadata?.description,
|
||||||
pageCount: metadata?.pageCount || 0,
|
pageCount: metadata?.pageCount || null,
|
||||||
|
reviewCount: metadata?.reviewCount || null,
|
||||||
|
rating: metadata?.rating || null,
|
||||||
language: metadata?.language || '',
|
language: metadata?.language || '',
|
||||||
googleBookId: metadata?.googleBookId || '',
|
googleBookId: metadata?.googleBookId || '',
|
||||||
};
|
};
|
||||||
|
|||||||
+71
-15
@@ -1,5 +1,18 @@
|
|||||||
<form [formGroup]="bookMetadataForm" (ngSubmit)="onSave()" class="h-full flex pt-4 flex-col">
|
<form [formGroup]="bookMetadataForm" (ngSubmit)="onSave()" class="h-full flex pt-1 flex-col">
|
||||||
<div class="overflow-y-scroll flex-1">
|
<div class="overflow-y-scroll flex-1">
|
||||||
|
|
||||||
|
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '4.95rem'}">
|
||||||
|
<p class="ml-3">Current Metadata</p>
|
||||||
|
<p-button
|
||||||
|
severity="info"
|
||||||
|
icon='pi pi-angle-double-left'
|
||||||
|
[ngStyle]="{'padding-left': '2rem', 'padding-right': '2rem'}"
|
||||||
|
[outlined]="true"
|
||||||
|
[pTooltip]="'Copy all missing metadata'"
|
||||||
|
(onClick)="copyMissing()"></p-button>
|
||||||
|
<p>Fetched Metadata</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="title" class="label">Title</label>
|
<label for="title" class="label">Title</label>
|
||||||
<div class="input-container">
|
<div class="input-container">
|
||||||
@@ -98,20 +111,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="pageCount" class="label">Pages</label>
|
|
||||||
<div class="input-container">
|
|
||||||
<input pInputText id="pageCount" formControlName="pageCount" class="input"/>
|
|
||||||
<p-button
|
|
||||||
[icon]="isValueSaved('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
|
||||||
[outlined]="true"
|
|
||||||
[ngClass]="{'green-outlined-button': isValueSaved('pageCount'), 'yellow-outlined-button': isValueCopied('pageCount')}"
|
|
||||||
class="arrow-button"
|
|
||||||
(click)="copyFetchedToCurrent('pageCount')"/>
|
|
||||||
<input pInputText [value]="fetchedMetadata.pageCount" class="input" readonly/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="description" class="label">Description</label>
|
<label for="description" class="label">Description</label>
|
||||||
<div class="input-container">
|
<div class="input-container">
|
||||||
@@ -140,6 +139,63 @@
|
|||||||
<img [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
<img [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="isbn13" class="label">ISBN-13</label>
|
||||||
|
<div class="input-container">
|
||||||
|
<input pInputText id="isbn13" formControlName="isbn13" class="input"/>
|
||||||
|
<p-button
|
||||||
|
[icon]="isValueSaved('isbn13') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||||
|
[outlined]="true"
|
||||||
|
[ngClass]="{'green-outlined-button': isValueSaved('isbn13'), 'yellow-outlined-button': isValueCopied('isbn13')}"
|
||||||
|
class="arrow-button"
|
||||||
|
(click)="copyFetchedToCurrent('isbn13')"/>
|
||||||
|
<input pInputText [value]="fetchedMetadata.isbn13" class="input" readonly/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="rating" class="label">Rating</label>
|
||||||
|
<div class="input-container">
|
||||||
|
<input pInputText id="rating" formControlName="rating" class="input"/>
|
||||||
|
<p-button
|
||||||
|
[icon]="isValueSaved('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||||
|
[outlined]="true"
|
||||||
|
[ngClass]="{'green-outlined-button': isValueSaved('rating'), 'yellow-outlined-button': isValueCopied('rating')}"
|
||||||
|
class="arrow-button"
|
||||||
|
(click)="copyFetchedToCurrent('rating')"/>
|
||||||
|
<input pInputText [value]="fetchedMetadata.rating" class="input" readonly/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="reviewCount" class="label">Rating</label>
|
||||||
|
<div class="input-container">
|
||||||
|
<input pInputText id="reviewCount" formControlName="reviewCount" class="input"/>
|
||||||
|
<p-button
|
||||||
|
[icon]="isValueSaved('reviewCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||||
|
[outlined]="true"
|
||||||
|
[ngClass]="{'green-outlined-button': isValueSaved('reviewCount'), 'yellow-outlined-button': isValueCopied('reviewCount')}"
|
||||||
|
class="arrow-button"
|
||||||
|
(click)="copyFetchedToCurrent('reviewCount')"/>
|
||||||
|
<input pInputText [value]="fetchedMetadata.reviewCount" class="input" readonly/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="pageCount" class="label">Pages</label>
|
||||||
|
<div class="input-container">
|
||||||
|
<input pInputText id="pageCount" formControlName="pageCount" class="input"/>
|
||||||
|
<p-button
|
||||||
|
[icon]="isValueSaved('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||||
|
[outlined]="true"
|
||||||
|
[ngClass]="{'green-outlined-button': isValueSaved('pageCount'), 'yellow-outlined-button': isValueCopied('pageCount')}"
|
||||||
|
class="arrow-button"
|
||||||
|
(click)="copyFetchedToCurrent('pageCount')"/>
|
||||||
|
<input pInputText [value]="fetchedMetadata.pageCount" class="input" readonly/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col gap-x-4 mt-auto">
|
<div class="flex flex-col gap-x-4 mt-auto">
|
||||||
|
|||||||
+45
-19
@@ -5,11 +5,12 @@ import {MessageService} from 'primeng/api';
|
|||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {NgClass, NgIf} from '@angular/common';
|
import {NgClass, NgIf, NgStyle} from '@angular/common';
|
||||||
import {Divider} from 'primeng/divider';
|
import {Divider} from 'primeng/divider';
|
||||||
import {BookInfoService} from '../book-info.service';
|
import {BookInfoService} from '../book-info.service';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {BookMetadataBI} from '../../book/model/book-metadata-for-book-info.model';
|
import {BookMetadataBI} from '../../book/model/book-metadata-for-book-info.model';
|
||||||
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-searcher',
|
selector: 'app-metadata-searcher',
|
||||||
@@ -23,7 +24,9 @@ import {BookMetadataBI} from '../../book/model/book-metadata-for-book-info.model
|
|||||||
NgIf,
|
NgIf,
|
||||||
Divider,
|
Divider,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
NgClass
|
NgClass,
|
||||||
|
NgStyle,
|
||||||
|
Tooltip
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class MetadataSearcherComponent implements OnInit {
|
export class MetadataSearcherComponent implements OnInit {
|
||||||
@@ -50,10 +53,11 @@ export class MetadataSearcherComponent implements OnInit {
|
|||||||
publishedDate: new FormControl(''),
|
publishedDate: new FormControl(''),
|
||||||
isbn10: new FormControl(''),
|
isbn10: new FormControl(''),
|
||||||
isbn13: new FormControl(''),
|
isbn13: new FormControl(''),
|
||||||
asin: new FormControl(''),
|
|
||||||
description: new FormControl(''),
|
description: new FormControl(''),
|
||||||
pageCount: new FormControl(''),
|
pageCount: new FormControl(''),
|
||||||
language: new FormControl(''),
|
language: new FormControl(''),
|
||||||
|
rating: new FormControl(''),
|
||||||
|
reviewCount: new FormControl(''),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,10 +74,11 @@ export class MetadataSearcherComponent implements OnInit {
|
|||||||
publishedDate: bookMetadata.publishedDate,
|
publishedDate: bookMetadata.publishedDate,
|
||||||
isbn10: bookMetadata.isbn10,
|
isbn10: bookMetadata.isbn10,
|
||||||
isbn13: bookMetadata.isbn13,
|
isbn13: bookMetadata.isbn13,
|
||||||
asin: bookMetadata.asin ? bookMetadata.asin : null,
|
|
||||||
description: bookMetadata.description,
|
description: bookMetadata.description,
|
||||||
pageCount: bookMetadata.pageCount == 0 ? null : bookMetadata.pageCount,
|
pageCount: bookMetadata.pageCount == 0 ? null : bookMetadata.pageCount,
|
||||||
language: bookMetadata.language
|
language: bookMetadata.language,
|
||||||
|
rating: bookMetadata.rating,
|
||||||
|
reviewCount: bookMetadata.reviewCount
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -94,22 +99,23 @@ export class MetadataSearcherComponent implements OnInit {
|
|||||||
onSave(): void {
|
onSave(): void {
|
||||||
const updatedBookMetadata: BookMetadataBI = {
|
const updatedBookMetadata: BookMetadataBI = {
|
||||||
bookId: this.currentBookId,
|
bookId: this.currentBookId,
|
||||||
title: this.getValueOrCopied('title'),
|
title: this.bookMetadataForm.get('title')?.value || this.copiedFields['title'] ? this.getValueOrCopied('title') : '',
|
||||||
subtitle: this.getValueOrCopied('subtitle'),
|
subtitle: this.bookMetadataForm.get('subtitle')?.value || this.copiedFields['subtitle'] ? this.getValueOrCopied('subtitle') : '',
|
||||||
authors: this.getArrayFromFormField('authors', this.fetchedMetadata.authors),
|
authors: this.bookMetadataForm.get('authors')?.value || this.copiedFields['authors'] ? this.getArrayFromFormField('authors', this.fetchedMetadata.authors) : [],
|
||||||
categories: this.getArrayFromFormField('categories', this.fetchedMetadata.categories),
|
categories: this.bookMetadataForm.get('categories')?.value || this.copiedFields['categories'] ? this.getArrayFromFormField('categories', this.fetchedMetadata.categories) : [],
|
||||||
publisher: this.getValueOrCopied('publisher'),
|
publisher: this.bookMetadataForm.get('publisher')?.value || this.copiedFields['publisher'] ? this.getValueOrCopied('publisher') : '',
|
||||||
publishedDate: this.getValueOrCopied('publishedDate'),
|
publishedDate: this.bookMetadataForm.get('publishedDate')?.value || this.copiedFields['publishedDate'] ? this.getValueOrCopied('publishedDate') : '',
|
||||||
isbn10: this.getValueOrCopied('isbn10'),
|
isbn10: this.bookMetadataForm.get('isbn10')?.value || this.copiedFields['isbn10'] ? this.getValueOrCopied('isbn10') : '',
|
||||||
isbn13: this.getValueOrCopied('isbn13'),
|
isbn13: this.bookMetadataForm.get('isbn13')?.value || this.copiedFields['isbn13'] ? this.getValueOrCopied('isbn13') : '',
|
||||||
asin: this.getValueOrCopied('asin'),
|
description: this.bookMetadataForm.get('description')?.value || this.copiedFields['description'] ? this.getValueOrCopied('description') : '',
|
||||||
description: this.getValueOrCopied('description'),
|
pageCount: this.bookMetadataForm.get('pageCount')?.value || this.copiedFields['pageCount'] ? this.getPageCountOrCopied() : null,
|
||||||
pageCount: this.getPageCountOrCopied(),
|
language: this.bookMetadataForm.get('language')?.value || this.copiedFields['language'] ? this.getValueOrCopied('language') : '',
|
||||||
language: this.getValueOrCopied('language'),
|
rating: this.bookMetadataForm.get('rating')?.value || this.copiedFields['rating'] ? this.getNumberOrCopied('rating') : null,
|
||||||
thumbnailUrl: this.updateThumbnailUrl ? this.fetchedMetadata.thumbnailUrl : undefined
|
reviewCount: this.bookMetadataForm.get('reviewCount')?.value || this.copiedFields['reviewCount'] ? this.getNumberOrCopied('reviewCount') : null,
|
||||||
|
thumbnailUrl: this.updateThumbnailUrl ? this.fetchedMetadata.thumbnailUrl : '',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.bookService.updateMetadata(updatedBookMetadata.bookId, updatedBookMetadata).subscribe({
|
this.bookService.updateMetadata(this.currentBookId, updatedBookMetadata).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
Object.keys(this.copiedFields).forEach((field) => {
|
Object.keys(this.copiedFields).forEach((field) => {
|
||||||
if (this.copiedFields[field]) {
|
if (this.copiedFields[field]) {
|
||||||
@@ -128,6 +134,24 @@ export class MetadataSearcherComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyMissing() {
|
||||||
|
Object.keys(this.fetchedMetadata).forEach((field) => {
|
||||||
|
if (!this.bookMetadataForm.get(field)?.value && this.fetchedMetadata[field]) {
|
||||||
|
this.copyFetchedToCurrent(field);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private getNumberOrCopied(field: string): number | null {
|
||||||
|
const formValue = this.bookMetadataForm.get(field)?.value;
|
||||||
|
if (formValue === '' || formValue === null || isNaN(formValue)) {
|
||||||
|
this.copiedFields[field] = true;
|
||||||
|
return this.fetchedMetadata[field] || null;
|
||||||
|
}
|
||||||
|
return Number(formValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private getPageCountOrCopied(): number | null {
|
private getPageCountOrCopied(): number | null {
|
||||||
const formValue = this.bookMetadataForm.get('pageCount')?.value;
|
const formValue = this.bookMetadataForm.get('pageCount')?.value;
|
||||||
if (formValue === '' || formValue === null || isNaN(formValue)) {
|
if (formValue === '' || formValue === null || isNaN(formValue)) {
|
||||||
@@ -165,6 +189,7 @@ export class MetadataSearcherComponent implements OnInit {
|
|||||||
const value = this.fetchedMetadata[field];
|
const value = this.fetchedMetadata[field];
|
||||||
if (value) {
|
if (value) {
|
||||||
this.bookMetadataForm.get(field)?.setValue(value);
|
this.bookMetadataForm.get(field)?.setValue(value);
|
||||||
|
this.copiedFields[field] = true;
|
||||||
this.highlightCopiedInput(field);
|
this.highlightCopiedInput(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,4 +213,5 @@ export class MetadataSearcherComponent implements OnInit {
|
|||||||
closeDialog() {
|
closeDialog() {
|
||||||
this.bookInfoService.closeDialog(true);
|
this.bookInfoService.closeDialog(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ export interface BookMetadataBI {
|
|||||||
publishedDate: string;
|
publishedDate: string;
|
||||||
isbn10: string;
|
isbn10: string;
|
||||||
isbn13: string;
|
isbn13: string;
|
||||||
asin?: string;
|
rating?: number | null;
|
||||||
|
reviewCount?: number | null;
|
||||||
description?: string;
|
description?: string;
|
||||||
pageCount?: number | null;
|
pageCount?: number | null;
|
||||||
language: string;
|
language: string;
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ export interface BookMetadata {
|
|||||||
publishedDate: string;
|
publishedDate: string;
|
||||||
isbn10: string;
|
isbn10: string;
|
||||||
isbn13: string;
|
isbn13: string;
|
||||||
asin: string;
|
|
||||||
description?: string;
|
description?: string;
|
||||||
pageCount: number;
|
pageCount: number;
|
||||||
|
rating: number;
|
||||||
|
reviewCount: number;
|
||||||
language: string;
|
language: string;
|
||||||
googleBookId: string;
|
googleBookId: string;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
@@ -45,7 +46,6 @@ export interface FetchedMetadata {
|
|||||||
reviewCount: number | null;
|
reviewCount: number | null;
|
||||||
authors: string[];
|
authors: string[];
|
||||||
categories: string[];
|
categories: string[];
|
||||||
asin: string | null;
|
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user