Provide a hyperlink to the official book provider website

This commit is contained in:
aditya.chandel
2025-06-05 13:49:06 -06:00
committed by Aditya Chandel
parent 32bf75dcfe
commit c3f54e0a88
15 changed files with 306 additions and 139 deletions
@@ -26,7 +26,6 @@ public class BookMetadata {
private Integer seriesTotal;
private String isbn13;
private String isbn10;
private String asin;
private Integer pageCount;
private String language;
private Double rating;
@@ -34,18 +33,22 @@ public class BookMetadata {
private Integer ratingCount;
@Deprecated
private Integer reviewCount;
private String asin;
private Double amazonRating;
private Integer amazonReviewCount;
private String goodreadsId;
private Double goodreadsRating;
private Integer goodreadsReviewCount;
private String hardcoverId;
private Double hardcoverRating;
private Integer hardcoverReviewCount;
private String googleId;
private Instant coverUpdatedOn;
private List<String> authors;
private List<String> categories;
private MetadataProvider provider;
private String providerBookId;
private String thumbnailUrl;
private Boolean titleLocked;
@@ -59,6 +62,10 @@ public class BookMetadata {
private Boolean isbn13Locked;
private Boolean isbn10Locked;
private Boolean asinLocked;
private Boolean amazonIdLocked;
private Boolean goodreadsIdLocked;
private Boolean hardcoverIdLocked;
private Boolean googleIdLocked;
private Boolean pageCountLocked;
private Boolean languageLocked;
private Boolean ratingLocked;
@@ -51,9 +51,6 @@ public class BookMetadataEntity {
@Column(name = "isbn_10", length = 10)
private String isbn10;
@Column(name = "asin", length = 10)
private String asin;
@Column(name = "page_count")
private Integer pageCount;
@@ -90,6 +87,18 @@ public class BookMetadataEntity {
@Column(name = "hardcover_review_count")
private Integer hardcoverReviewCount;
@Column(name = "asin", length = 10)
private String asin;
@Column(name = "goodreads_id", length = 100)
private String goodreadsId;
@Column(name = "hardcover_id", length = 100)
private String hardcoverId;
@Column(name = "google_id", length = 100)
private String googleId;
// Locking fields
@Column(name = "title_locked")
@@ -167,6 +176,15 @@ public class BookMetadataEntity {
@Column(name = "categories_locked")
private Boolean categoriesLocked = Boolean.FALSE;
@Column(name = "goodreads_id_locked")
private Boolean goodreadsIdLocked = Boolean.FALSE;
@Column(name = "hardcover_id_locked")
private Boolean hardcoverIdLocked = Boolean.FALSE;
@Column(name = "google_id_locked")
private Boolean googleIdLocked = Boolean.FALSE;
@OneToOne(fetch = FetchType.LAZY)
@MapsId
@JoinColumn(name = "book_id")
@@ -214,6 +232,9 @@ public class BookMetadataEntity {
this.goodreadsReviewCountLocked = lock;
this.hardcoverRatingLocked = lock;
this.hardcoverReviewCountLocked = lock;
this.goodreadsIdLocked = lock;
this.hardcoverIdLocked = lock;
this.googleIdLocked = lock;
}
public boolean areAllFieldsLocked() {
@@ -239,6 +260,9 @@ public class BookMetadataEntity {
&& Boolean.TRUE.equals(this.goodreadsReviewCountLocked)
&& Boolean.TRUE.equals(this.hardcoverRatingLocked)
&& Boolean.TRUE.equals(this.hardcoverReviewCountLocked)
&& Boolean.TRUE.equals(this.goodreadsIdLocked)
&& Boolean.TRUE.equals(this.hardcoverIdLocked)
&& Boolean.TRUE.equals(this.googleIdLocked)
;
}
}
@@ -174,6 +174,17 @@ public class BookMetadataService {
metadata.setTitle(resolveFieldAsString(metadataMap, fieldOptions.getTitle(), BookMetadata::getTitle));
metadata.setDescription(resolveFieldAsString(metadataMap, fieldOptions.getDescription(), BookMetadata::getDescription));
metadata.setAuthors(resolveFieldAsList(metadataMap, fieldOptions.getAuthors(), BookMetadata::getAuthors));
if (metadataMap.containsKey(GoodReads)) {
metadata.setGoodreadsId(metadataMap.get(GoodReads).getGoodreadsId());
}
if (metadataMap.containsKey(Hardcover)) {
metadata.setHardcoverId(metadataMap.get(Hardcover).getHardcoverId());
}
if (metadataMap.containsKey(Google)) {
metadata.setGoogleId(metadataMap.get(Google).getGoogleId());
}
if (request.getRefreshOptions().isMergeCategories()) {
metadata.setCategories(getAllCategories(metadataMap, fieldOptions.getCategories(), BookMetadata::getCategories));
} else {
@@ -42,6 +42,15 @@ public class BookMetadataUpdater {
return metadata;
}
if ((metadata.getGoodreadsIdLocked() == null || !metadata.getGoodreadsIdLocked()) && newMetadata.getGoodreadsId() != null) {
metadata.setGoodreadsId(newMetadata.getGoodreadsId().isBlank() ? null : newMetadata.getGoodreadsId());
}
if ((metadata.getHardcoverIdLocked() == null || !metadata.getHardcoverIdLocked()) && newMetadata.getHardcoverId() != null) {
metadata.setHardcoverId(newMetadata.getHardcoverId().isBlank() ? null : newMetadata.getHardcoverId());
}
if ((metadata.getGoogleIdLocked() == null || !metadata.getGoogleIdLocked()) && newMetadata.getGoogleId() != null) {
metadata.setGoogleId(newMetadata.getGoogleId().isBlank() ? null : newMetadata.getGoogleId());
}
if ((metadata.getTitleLocked() == null || !metadata.getTitleLocked()) && newMetadata.getTitle() != null) {
metadata.setTitle(newMetadata.getTitle().isEmpty() ? null : newMetadata.getTitle());
}
@@ -179,6 +188,15 @@ public class BookMetadataUpdater {
if (newMetadata.getAsinLocked() != null) {
metadata.setAsinLocked(newMetadata.getAsinLocked());
}
if (newMetadata.getGoodreadsIdLocked() != null) {
metadata.setGoodreadsIdLocked(newMetadata.getGoodreadsIdLocked());
}
if (newMetadata.getHardcoverIdLocked() != null) {
metadata.setHardcoverIdLocked(newMetadata.getHardcoverIdLocked());
}
if (newMetadata.getGoogleIdLocked() != null) {
metadata.setGoogleIdLocked(newMetadata.getGoogleIdLocked());
}
if (newMetadata.getPageCountLocked() != null) {
metadata.setPageCountLocked(newMetadata.getPageCountLocked());
}
@@ -142,7 +142,6 @@ public class AmazonBookParser implements BookParser {
log.info("Amazon: Fetching metadata for: {}", amazonBookId);
Document doc = fetchDocument(BASE_BOOK_URL + amazonBookId);
return BookMetadata.builder()
.providerBookId(amazonBookId)
.provider(MetadataProvider.Amazon)
.title(getTitle(doc))
.subtitle(getSubtitle(doc))
@@ -58,21 +58,21 @@ public class GoodReadsParser implements BookParser {
for (BookMetadata preview : previews) {
log.info("GoodReads: Fetching metadata for: {}", preview.getTitle());
try {
Document document = fetchDoc(BASE_BOOK_URL + preview.getProviderBookId());
BookMetadata detailedMetadata = parseBookDetails(document, preview.getProviderBookId());
Document document = fetchDoc(BASE_BOOK_URL + preview.getGoodreadsId());
BookMetadata detailedMetadata = parseBookDetails(document, preview.getGoodreadsId());
if (detailedMetadata != null) {
fetchedMetadata.add(detailedMetadata);
}
Thread.sleep(Duration.ofSeconds(1));
} catch (Exception e) {
log.error("Error fetching metadata for book: {}", preview.getProviderBookId(), e);
log.error("Error fetching metadata for book: {}", preview.getGoodreadsId(), e);
}
}
return fetchedMetadata;
}
private BookMetadata parseBookDetails(Document document, String providerBookId) {
BookMetadata.BookMetadataBuilder builder = BookMetadata.builder().providerBookId(providerBookId);
private BookMetadata parseBookDetails(Document document, String goodreadsId) {
BookMetadata.BookMetadataBuilder builder = BookMetadata.builder().goodreadsId(goodreadsId);
builder.provider(MetadataProvider.GoodReads);
try {
JSONObject apolloStateJson = getJson(document)
@@ -87,7 +87,7 @@ public class GoodReadsParser implements BookParser {
extractBookDetails(apolloStateJson, keySet, builder);
extractWorkDetails(apolloStateJson, keySet, builder);
} catch (Exception e) {
log.error("Error parsing book details for providerBookId: {}", providerBookId, e);
log.error("Error parsing book details for providerBookId: {}", goodreadsId, e);
return null;
}
@@ -331,7 +331,7 @@ public class GoodReadsParser implements BookParser {
}
}
BookMetadata previewMetadata = BookMetadata.builder()
.providerBookId(String.valueOf(extractGoodReadsIdPreview(previewBook)))
.goodreadsId(String.valueOf(extractGoodReadsIdPreview(previewBook)))
.title(extractTitlePreview(previewBook))
.authors(authors)
.build();
@@ -88,7 +88,7 @@ public class GoogleParser implements BookParser {
return BookMetadata.builder()
.provider(MetadataProvider.Google)
.providerBookId(item.getId())
.googleId(item.getId())
.title(volumeInfo.getTitle())
.subtitle(volumeInfo.getSubtitle())
.publisher(volumeInfo.getPublisher())
@@ -57,7 +57,7 @@ public class HardcoverParser implements BookParser {
.map(hit -> {
GraphQLResponse.Document doc = hit.getDocument();
BookMetadata metadata = new BookMetadata();
metadata.setProviderBookId(doc.getSlug());
metadata.setHardcoverId(doc.getSlug());
metadata.setTitle(doc.getTitle());
metadata.setDescription(doc.getDescription());
metadata.setAuthors(doc.getAuthorNames());
@@ -0,0 +1,7 @@
ALTER TABLE book_metadata
ADD COLUMN goodreads_id VARCHAR(100),
ADD COLUMN hardcover_id VARCHAR(100),
ADD COLUMN google_id VARCHAR(100),
ADD COLUMN goodreads_id_locked BOOLEAN DEFAULT FALSE,
ADD COLUMN hardcover_id_locked BOOLEAN DEFAULT FALSE,
ADD COLUMN google_id_locked BOOLEAN DEFAULT FALSE;
@@ -98,7 +98,7 @@
<!-- Categories and Published Date -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-2/3">
<div class="flex flex-col gap-1 w-3/4">
<label for="categories">Categories</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="categories" formControlName="categories" class="w-full"/>
@@ -106,7 +106,7 @@
<p-button *ngIf="metadata['categoriesLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('categories')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/3">
<div class="flex flex-col gap-1 w-1/8">
<label for="publishedDate">Publish Date</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="publishedDate" formControlName="publishedDate" class="w-full"/>
@@ -114,39 +114,7 @@
<p-button *ngIf="metadata['publishedDateLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="warn"></p-button>
</div>
</div>
</div>
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 basis-3/6">
<label for="seriesName">Series Name</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesName" formControlName="seriesName" class="w-full"/>
<p-button *ngIf="!metadata['seriesNameLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesNameLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 basis-1/6">
<label for="seriesNumber">Book Number</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full"/>
<p-button *ngIf="!metadata['seriesNumberLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesNumberLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 basis-1/6">
<label for="seriesTotal">Books in Series</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full"/>
<p-button *ngIf="!metadata['seriesTotalLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesTotalLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 basis-1/6">
<div class="flex flex-col gap-1 w-1/8">
<label for="language">Language</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="language" formControlName="language" class="w-full"/>
@@ -156,9 +124,40 @@
</div>
</div>
<!-- ISBN, Language, Review Count -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/4">
<div class="flex flex-col gap-1 basis-3/4">
<label for="seriesName">Series Name</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesName" formControlName="seriesName" class="w-full"/>
<p-button *ngIf="!metadata['seriesNameLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesNameLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 basis-1/8">
<label for="seriesNumber">Book Number</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full"/>
<p-button *ngIf="!metadata['seriesNumberLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesNumberLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 basis-1/8">
<label for="seriesTotal">Books in Series</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full"/>
<p-button *ngIf="!metadata['seriesTotalLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesTotalLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="warn"></p-button>
</div>
</div>
</div>
<!-- ISBN, ASIN, Language -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6">
<label for="isbn10">ISBN 10</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="isbn10" formControlName="isbn10" class="w-full"/>
@@ -166,7 +165,7 @@
<p-button *ngIf="metadata['isbn10Locked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/4">
<div class="flex flex-col gap-1 w-1/6">
<label for="isbn13">ISBN 13</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="isbn13" formControlName="isbn13" class="w-full"/>
@@ -174,36 +173,16 @@
<p-button *ngIf="metadata['isbn13Locked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/4">
<label for="asin">ASIN</label>
<div class="flex flex-col gap-1 w-1/6">
<label for="asin">ASIN (Amazon ID)</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="asin" formControlName="asin" class="w-full"/>
<p-button *ngIf="!metadata['asinLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
<p-button *ngIf="metadata['asinLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 basis-1/4">
<label for="pageCount">Page Count</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="pageCount" formControlName="pageCount" class="w-full"/>
<p-button *ngIf="!metadata['pageCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="success"></p-button>
<p-button *ngIf="metadata['pageCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="warn"></p-button>
</div>
</div>
</div>
<!-- Review Count, Rating, Page Count -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6">
<label for="amazonRatingCount">Amazon Rating Count</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['amazonReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['amazonReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="amazonRating">Amazon Rating</label>
<label for="amazonRating">Amazon ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
<p-button *ngIf="!metadata['amazonRatingLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="success"></p-button>
@@ -211,15 +190,35 @@
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsReviewCount">Goodreads Rating Count</label>
<label for="amazonRatingCount">Amazon Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['goodreadsReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['goodreadsReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['amazonReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['amazonReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsRating">Goodreads Rating</label>
<label for="googleId">Google Books ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="googleId" formControlName="googleId" class="w-full"/>
<p-button *ngIf="!metadata['googleIdLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('googleId')" severity="success"></p-button>
<p-button *ngIf="metadata['googleIdLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
</div>
</div>
</div>
<!-- Ratings and Reviews -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsId">Goodreads ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsId" formControlName="goodreadsId" class="w-full"/>
<p-button *ngIf="!metadata['goodreadsIdLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="success"></p-button>
<p-button *ngIf="metadata['goodreadsIdLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsRating">Goodreads ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
<p-button *ngIf="!metadata['goodreadsRatingLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="success"></p-button>
@@ -227,21 +226,37 @@
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverReviewCount">Hardcover Rating Count</label>
<label for="goodreadsReviewCount">Goodreads Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['hardcoverReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['hardcoverReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
<input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['goodreadsReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['goodreadsReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverRating">Hardcover Rating</label>
<label for="hardcoverId">Hardcover ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverId" formControlName="hardcoverId" class="w-full"/>
<p-button *ngIf="!metadata['hardcoverIdLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="success"></p-button>
<p-button *ngIf="metadata['hardcoverIdLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverRating">Hardcover ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverRating" formControlName="hardcoverRating" class="w-full"/>
<p-button *ngIf="!metadata['hardcoverRatingLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="success"></p-button>
<p-button *ngIf="metadata['hardcoverRatingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverReviewCount">Hardcover Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['hardcoverReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['hardcoverReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
</div>
</div>
</div>
</div>
@@ -69,18 +69,21 @@ export class MetadataEditorComponent implements OnInit {
publishedDate: new FormControl(''),
isbn10: new FormControl(''),
isbn13: new FormControl(''),
asin: new FormControl(''),
description: new FormControl(''),
pageCount: new FormControl(''),
language: new FormControl(''),
rating: new FormControl(''),
reviewCount: new FormControl(''),
asin: new FormControl(''),
amazonRating: new FormControl(''),
amazonReviewCount: new FormControl(''),
goodreadsId: new FormControl(''),
goodreadsRating: new FormControl(''),
goodreadsReviewCount: new FormControl(''),
hardcoverId: new FormControl(''),
hardcoverRating: new FormControl(''),
hardcoverReviewCount: new FormControl(''),
googleId: new FormControl(''),
seriesName: new FormControl(''),
seriesNumber: new FormControl(''),
seriesTotal: new FormControl(''),
@@ -93,18 +96,21 @@ export class MetadataEditorComponent implements OnInit {
publishedDateLocked: new FormControl(false),
isbn10Locked: new FormControl(false),
isbn13Locked: new FormControl(false),
asinLocked: new FormControl(false),
descriptionLocked: new FormControl(false),
pageCountLocked: new FormControl(false),
languageLocked: new FormControl(false),
ratingLocked: new FormControl(false),
reviewCountLocked: new FormControl(false),
asinLocked: new FormControl(false),
amazonRatingLocked: new FormControl(false),
amazonReviewCountLocked: new FormControl(false),
goodreadsIdLocked: new FormControl(''),
goodreadsRatingLocked: new FormControl(false),
goodreadsReviewCountLocked: new FormControl(false),
hardcoverIdLocked: new FormControl(false),
hardcoverRatingLocked: new FormControl(false),
hardcoverReviewCountLocked: new FormControl(false),
googleIdLocked: new FormControl(false),
seriesNameLocked: new FormControl(false),
seriesNumberLocked: new FormControl(false),
seriesTotalLocked: new FormControl(false),
@@ -131,18 +137,21 @@ export class MetadataEditorComponent implements OnInit {
publishedDate: metadata.publishedDate || null,
isbn10: metadata.isbn10 || null,
isbn13: metadata.isbn13 || null,
asin: metadata.asin || null,
description: metadata.description || null,
pageCount: metadata.pageCount || null,
language: metadata.language || null,
rating: metadata.rating || null,
reviewCount: metadata.reviewCount || null,
asin: metadata.asin || null,
amazonRating: metadata.amazonRating || null,
amazonReviewCount: metadata.amazonReviewCount || null,
goodreadsId: metadata.goodreadsId || null,
goodreadsRating: metadata.goodreadsRating || null,
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
hardcoverId: metadata.hardcoverId || null,
hardcoverRating: metadata.hardcoverRating || null,
hardcoverReviewCount: metadata.hardcoverReviewCount || null,
googleId: metadata.googleId || null,
seriesName: metadata.seriesName || null,
seriesNumber: metadata.seriesNumber || null,
seriesTotal: metadata.seriesTotal || null,
@@ -155,18 +164,21 @@ export class MetadataEditorComponent implements OnInit {
publishedDateLocked: metadata.publishedDateLocked || false,
isbn10Locked: metadata.isbn10Locked || false,
isbn13Locked: metadata.isbn13Locked || false,
asinLocked: metadata.asinLocked || false,
descriptionLocked: metadata.descriptionLocked || false,
pageCountLocked: metadata.pageCountLocked || false,
languageLocked: metadata.languageLocked || false,
ratingLocked: metadata.ratingLocked || false,
reviewCountLocked: metadata.reviewCountLocked || false,
asinLocked: metadata.asinLocked || false,
amazonRatingLocked: metadata.amazonRatingLocked || false,
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
goodreadsIdLocked: metadata.goodreadsIdLocked || false,
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
hardcoverIdLocked: metadata.hardcoverIdLocked || false,
hardcoverRatingLocked: metadata.hardcoverRatingLocked || false,
hardcoverReviewCountLocked: metadata.hardcoverReviewCountLocked || false,
googleIdLocked: metadata.googleIdLocked || false,
seriesNameLocked: metadata.seriesNameLocked || false,
seriesNumberLocked: metadata.seriesNumberLocked || false,
seriesTotalLocked: metadata.seriesTotalLocked || false,
@@ -174,30 +186,33 @@ export class MetadataEditorComponent implements OnInit {
});
const lockableFields: { key: keyof BookMetadata, control: string }[] = [
{ key: 'titleLocked', control: 'title' },
{ key: 'subtitleLocked', control: 'subtitle' },
{ key: 'authorsLocked', control: 'authors' },
{ key: 'categoriesLocked', control: 'categories' },
{ key: 'publisherLocked', control: 'publisher' },
{ key: 'publishedDateLocked', control: 'publishedDate' },
{ key: 'languageLocked', control: 'language' },
{ key: 'isbn10Locked', control: 'isbn10' },
{ key: 'isbn13Locked', control: 'isbn13' },
{ key: 'asinLocked', control: 'asin'},
{ key: 'amazonReviewCountLocked', control: 'amazonReviewCount' },
{ key: 'amazonRatingLocked', control: 'amazonRating' },
{ key: 'goodreadsReviewCountLocked', control: 'goodreadsReviewCount' },
{ key: 'goodreadsRatingLocked', control: 'goodreadsRating' },
{ key: 'hardcoverReviewCountLocked', control: 'hardcoverReviewCount' },
{ key: 'hardcoverRatingLocked', control: 'hardcoverRating' },
{ key: 'pageCountLocked', control: 'pageCount' },
{ key: 'descriptionLocked', control: 'description' },
{ key: 'seriesNameLocked', control: 'seriesName' },
{ key: 'seriesNumberLocked', control: 'seriesNumber' },
{ key: 'seriesTotalLocked', control: 'seriesTotal' }
{key: 'titleLocked', control: 'title'},
{key: 'subtitleLocked', control: 'subtitle'},
{key: 'authorsLocked', control: 'authors'},
{key: 'categoriesLocked', control: 'categories'},
{key: 'publisherLocked', control: 'publisher'},
{key: 'publishedDateLocked', control: 'publishedDate'},
{key: 'languageLocked', control: 'language'},
{key: 'isbn10Locked', control: 'isbn10'},
{key: 'isbn13Locked', control: 'isbn13'},
{key: 'asinLocked', control: 'asin'},
{key: 'amazonReviewCountLocked', control: 'amazonReviewCount'},
{key: 'amazonRatingLocked', control: 'amazonRating'},
{key: 'goodreadsIdLocked', control: 'goodreadsId'},
{key: 'goodreadsReviewCountLocked', control: 'goodreadsReviewCount'},
{key: 'goodreadsRatingLocked', control: 'goodreadsRating'},
{key: 'hardcoverIdLocked', control: 'hardcoverId'},
{key: 'hardcoverReviewCountLocked', control: 'hardcoverReviewCount'},
{key: 'hardcoverRatingLocked', control: 'hardcoverRating'},
{key: 'googleIdLocked', control: 'googleId'},
{key: 'pageCountLocked', control: 'pageCount'},
{key: 'descriptionLocked', control: 'description'},
{key: 'seriesNameLocked', control: 'seriesName'},
{key: 'seriesNumberLocked', control: 'seriesNumber'},
{key: 'seriesTotalLocked', control: 'seriesTotal'}
];
lockableFields.forEach(({ key, control }) => {
lockableFields.forEach(({key, control}) => {
const isLocked = metadata[key] === true;
const formControl = this.metadataForm.get(control);
if (formControl) {
@@ -278,7 +293,7 @@ export class MetadataEditorComponent implements OnInit {
this.htmlTextarea = value;
const control = this.metadataForm.get('description');
if (control?.value !== value) {
control?.patchValue(value, { emitEvent: false });
control?.patchValue(value, {emitEvent: false});
if (this.quillEditor && this.quillEditor.quill) {
this.quillEditor.quill.root.innerHTML = value;
}
@@ -296,17 +311,20 @@ export class MetadataEditorComponent implements OnInit {
publishedDate: this.metadataForm.get('publishedDate')?.value,
isbn10: this.metadataForm.get('isbn10')?.value,
isbn13: this.metadataForm.get('isbn13')?.value,
asin: this.metadataForm.get('asin')?.value,
description: this.metadataForm.get('description')?.value,
pageCount: this.metadataForm.get('pageCount')?.value,
rating: this.metadataForm.get('rating')?.value,
reviewCount: this.metadataForm.get('reviewCount')?.value,
asin: this.metadataForm.get('asin')?.value,
amazonRating: this.metadataForm.get('amazonRating')?.value,
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value,
goodreadsId: this.metadataForm.get('goodreadsId')?.value,
goodreadsRating: this.metadataForm.get('goodreadsRating')?.value,
goodreadsReviewCount: this.metadataForm.get('goodreadsReviewCount')?.value,
hardcoverId: this.metadataForm.get('hardcoverId')?.value,
hardcoverRating: this.metadataForm.get('hardcoverRating')?.value,
hardcoverReviewCount: this.metadataForm.get('hardcoverReviewCount')?.value,
googleId: this.metadataForm.get('googleId')?.value,
language: this.metadataForm.get('language')?.value,
seriesName: this.metadataForm.get('seriesName')?.value,
seriesNumber: this.metadataForm.get('seriesNumber')?.value,
@@ -320,18 +338,21 @@ export class MetadataEditorComponent implements OnInit {
publishedDateLocked: this.metadataForm.get('publishedDateLocked')?.value,
isbn10Locked: this.metadataForm.get('isbn10Locked')?.value,
isbn13Locked: this.metadataForm.get('isbn13Locked')?.value,
asinLocked: this.metadataForm.get('asinLocked')?.value,
descriptionLocked: this.metadataForm.get('descriptionLocked')?.value,
pageCountLocked: this.metadataForm.get('pageCountLocked')?.value,
languageLocked: this.metadataForm.get('languageLocked')?.value,
ratingLocked: this.metadataForm.get('ratingLocked')?.value,
asinLocked: this.metadataForm.get('asinLocked')?.value,
reviewCountLocked: this.metadataForm.get('reviewCountLocked')?.value,
amazonRatingLocked: this.metadataForm.get('amazonRatingLocked')?.value,
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
goodreadsIdLocked: this.metadataForm.get('goodreadsIdLocked')?.value,
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.value,
goodreadsReviewCountLocked: this.metadataForm.get('goodreadsReviewCountLocked')?.value,
hardcoverIdLocked: this.metadataForm.get('hardcoverIdLocked')?.value,
hardcoverRatingLocked: this.metadataForm.get('hardcoverRatingLocked')?.value,
hardcoverReviewCountLocked: this.metadataForm.get('hardcoverReviewCountLocked')?.value,
googleIdLocked: this.metadataForm.get('googleIdLocked')?.value,
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
@@ -54,13 +54,16 @@ export class MetadataPickerComponent implements OnInit {
{label: 'Book #', controlName: 'seriesNumber', lockedKey: 'seriesNumberLocked', fetchedKey: 'seriesNumber'},
{label: 'Total Books', controlName: 'seriesTotal', lockedKey: 'seriesTotalLocked', fetchedKey: 'seriesTotal'},
{label: 'ISBN-13', controlName: 'isbn13', lockedKey: 'isbn13Locked', fetchedKey: 'isbn13'},
{label: 'ASIN', controlName: 'asin', lockedKey: 'asinLocked', fetchedKey: 'asin'},
{label: 'Amazon ID (ASIN)', controlName: 'asin', lockedKey: 'asinLocked', fetchedKey: 'asin'},
{label: 'Amazon Reviews', controlName: 'amazonReviewCount', lockedKey: 'amazonReviewCountLocked', fetchedKey: 'amazonReviewCount'},
{label: 'Amazon Rating', controlName: 'amazonRating', lockedKey: 'amazonRatingLocked', fetchedKey: 'amazonRating'},
{label: 'Goodreads ID', controlName: 'goodreadsId', lockedKey: 'goodreadsIdLocked', fetchedKey: 'goodreadsId'},
{label: 'Goodreads Reviews', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
{label: 'Goodreads Rating', controlName: 'goodreadsRating', lockedKey: 'goodreadsRatingLocked', fetchedKey: 'goodreadsRating'},
{label: 'Hardcover ID', controlName: 'hardcoverId', lockedKey: 'hardcoverIdLocked', fetchedKey: 'hardcoverId'},
{label: 'Hardcover Reviews', controlName: 'hardcoverReviewCount', lockedKey: 'hardcoverReviewCountLocked', fetchedKey: 'hardcoverReviewCount'},
{label: 'Hardcover Rating', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
{label: 'Google Books ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleIdRating'},
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'}
];
@@ -90,16 +93,19 @@ export class MetadataPickerComponent implements OnInit {
publishedDate: new FormControl(''),
isbn10: new FormControl(''),
isbn13: new FormControl(''),
asin: new FormControl(''),
description: new FormControl(''),
pageCount: new FormControl(''),
language: new FormControl(''),
asin: new FormControl(''),
amazonRating: new FormControl(''),
amazonReviewCount: new FormControl(''),
goodreadsId: new FormControl(''),
goodreadsRating: new FormControl(''),
goodreadsReviewCount: new FormControl(''),
hardcoverId: new FormControl(''),
hardcoverRating: new FormControl(''),
hardcoverReviewCount: new FormControl(''),
googleId: new FormControl(''),
seriesName: new FormControl(''),
seriesNumber: new FormControl(''),
seriesTotal: new FormControl(''),
@@ -113,16 +119,19 @@ export class MetadataPickerComponent implements OnInit {
publishedDateLocked: new FormControl(false),
isbn10Locked: new FormControl(false),
isbn13Locked: new FormControl(false),
asinLocked: new FormControl(false),
descriptionLocked: new FormControl(false),
pageCountLocked: new FormControl(false),
languageLocked: new FormControl(false),
asinLocked: new FormControl(false),
amazonRatingLocked: new FormControl(false),
amazonReviewCountLocked: new FormControl(false),
goodreadsIdLocked: new FormControl(false),
goodreadsRatingLocked: new FormControl(false),
goodreadsReviewCountLocked: new FormControl(false),
hardcoverIdLocked: new FormControl(false),
hardcoverRatingLocked: new FormControl(false),
hardcoverReviewCountLocked: new FormControl(false),
googleIdLocked: new FormControl(false),
seriesNameLocked: new FormControl(false),
seriesNumberLocked: new FormControl(false),
seriesTotalLocked: new FormControl(false),
@@ -145,16 +154,19 @@ export class MetadataPickerComponent implements OnInit {
publishedDate: metadata.publishedDate || null,
isbn10: metadata.isbn10 || null,
isbn13: metadata.isbn13 || null,
asin: metadata.asin || null,
description: metadata.description || null,
pageCount: metadata.pageCount || null,
language: metadata.language || null,
asin: metadata.asin || null,
amazonRating: metadata.amazonRating || null,
amazonReviewCount: metadata.amazonReviewCount || null,
goodreadsId: metadata.goodreadsId || null,
goodreadsRating: metadata.goodreadsRating || null,
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
hardcoverId: metadata.hardcoverId || null,
hardcoverRating: metadata.hardcoverRating || null,
hardcoverReviewCount: metadata.hardcoverReviewCount || null,
googleId: metadata.googleId || null,
seriesName: metadata.seriesName || null,
seriesNumber: metadata.seriesNumber || null,
seriesTotal: metadata.seriesTotal || null,
@@ -168,16 +180,19 @@ export class MetadataPickerComponent implements OnInit {
publishedDateLocked: metadata.publishedDateLocked || false,
isbn10Locked: metadata.isbn10Locked || false,
isbn13Locked: metadata.isbn13Locked || false,
asinLocked: metadata.asinLocked || false,
descriptionLocked: metadata.descriptionLocked || false,
pageCountLocked: metadata.pageCountLocked || false,
languageLocked: metadata.languageLocked || false,
asinLocked: metadata.asinLocked || false,
amazonRatingLocked: metadata.amazonRatingLocked || false,
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
goodreadsIdLocked: metadata.goodreadsIdLocked || false,
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
hardcoverIdLocked: metadata.hardcoverIdLocked || false,
hardcoverRatingLocked: metadata.hardcoverRatingLocked || false,
hardcoverReviewCountLocked: metadata.hardcoverReviewCountLocked || false,
googleIdLocked: metadata.googleIdLocked || false,
seriesNameLocked: metadata.seriesNameLocked || false,
seriesNumberLocked: metadata.seriesNumberLocked || false,
seriesTotalLocked: metadata.seriesTotalLocked || false,
@@ -196,10 +211,13 @@ export class MetadataPickerComponent implements OnInit {
if (metadata.asinLocked) this.metadataForm.get('asin')?.disable();
if (metadata.amazonReviewCountLocked) this.metadataForm.get('amazonReviewCount')?.disable();
if (metadata.amazonRatingLocked) this.metadataForm.get('amazonRating')?.disable();
if (metadata.googleIdLocked) this.metadataForm.get('googleIdCount')?.disable();
if (metadata.goodreadsReviewCountLocked) this.metadataForm.get('goodreadsReviewCount')?.disable();
if (metadata.goodreadsRatingLocked) this.metadataForm.get('goodreadsRating')?.disable();
if (metadata.hardcoverIdLocked) this.metadataForm.get('hardcoverId')?.disable();
if (metadata.hardcoverReviewCountLocked) this.metadataForm.get('hardcoverReviewCount')?.disable();
if (metadata.hardcoverRatingLocked) this.metadataForm.get('hardcoverRating')?.disable();
if (metadata.googleIdLocked) this.metadataForm.get('googleId')?.disable();
if (metadata.pageCountLocked) this.metadataForm.get('pageCount')?.disable();
if (metadata.descriptionLocked) this.metadataForm.get('description')?.disable();
if (metadata.seriesNameLocked) this.metadataForm.get('seriesName')?.disable();
@@ -238,16 +256,19 @@ export class MetadataPickerComponent implements OnInit {
publishedDate: this.metadataForm.get('publishedDate')?.value || this.copiedFields['publishedDate'] ? this.getValueOrCopied('publishedDate') : '',
isbn10: this.metadataForm.get('isbn10')?.value || this.copiedFields['isbn10'] ? this.getValueOrCopied('isbn10') : '',
isbn13: this.metadataForm.get('isbn13')?.value || this.copiedFields['isbn13'] ? this.getValueOrCopied('isbn13') : '',
asin: this.metadataForm.get('asin')?.value || this.copiedFields['asin'] ? this.getValueOrCopied('asin') : '',
description: this.metadataForm.get('description')?.value || this.copiedFields['description'] ? this.getValueOrCopied('description') : '',
pageCount: this.metadataForm.get('pageCount')?.value || this.copiedFields['pageCount'] ? this.getPageCountOrCopied() : null,
language: this.metadataForm.get('language')?.value || this.copiedFields['language'] ? this.getValueOrCopied('language') : '',
asin: this.metadataForm.get('asin')?.value || this.copiedFields['asin'] ? this.getValueOrCopied('asin') : '',
amazonRating: this.metadataForm.get('amazonRating')?.value || this.copiedFields['amazonRating'] ? this.getNumberOrCopied('amazonRating') : null,
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value || this.copiedFields['amazonReviewCount'] ? this.getNumberOrCopied('amazonReviewCount') : null,
goodreadsId: this.metadataForm.get('goodreadsId')?.value || this.copiedFields['goodreadsId'] ? this.getValueOrCopied('goodreadsId') : '',
goodreadsRating: this.metadataForm.get('goodreadsRating')?.value || this.copiedFields['goodreadsRating'] ? this.getNumberOrCopied('goodreadsRating') : null,
goodreadsReviewCount: this.metadataForm.get('goodreadsReviewCount')?.value || this.copiedFields['goodreadsReviewCount'] ? this.getNumberOrCopied('goodreadsReviewCount') : null,
hardcoverId: this.metadataForm.get('hardcoverId')?.value || this.copiedFields['hardcoverId'] ? this.getValueOrCopied('hardcoverId') : '',
hardcoverRating: this.metadataForm.get('hardcoverRating')?.value || this.copiedFields['hardcoverRating'] ? this.getNumberOrCopied('hardcoverRating') : null,
hardcoverReviewCount: this.metadataForm.get('hardcoverReviewCount')?.value || this.copiedFields['hardcoverReviewCount'] ? this.getNumberOrCopied('hardcoverReviewCount') : null,
googleId: this.metadataForm.get('googleId')?.value || this.copiedFields['googleId'] ? this.getValueOrCopied('googleId') : '',
seriesName: this.metadataForm.get('seriesName')?.value || this.copiedFields['seriesName'] ? this.getValueOrCopied('seriesName') : '',
seriesNumber: this.metadataForm.get('seriesNumber')?.value || this.copiedFields['seriesNumber'] ? this.getNumberOrCopied('seriesNumber') : null,
seriesTotal: this.metadataForm.get('seriesTotal')?.value || this.copiedFields['seriesTotal'] ? this.getNumberOrCopied('seriesTotal') : null,
@@ -261,16 +282,19 @@ export class MetadataPickerComponent implements OnInit {
publishedDateLocked: this.metadataForm.get('publishedDateLocked')?.value,
isbn10Locked: this.metadataForm.get('isbn10Locked')?.value,
isbn13Locked: this.metadataForm.get('isbn13Locked')?.value,
asinLocked: this.metadataForm.get('asinLocked')?.value,
descriptionLocked: this.metadataForm.get('descriptionLocked')?.value,
pageCountLocked: this.metadataForm.get('pageCountLocked')?.value,
languageLocked: this.metadataForm.get('languageLocked')?.value,
asinLocked: this.metadataForm.get('asinLocked')?.value,
amazonRatingLocked: this.metadataForm.get('amazonRatingLocked')?.value,
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
goodreadsIdLocked: this.metadataForm.get('goodreadsIdLocked')?.value,
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.value,
goodreadsReviewCountLocked: this.metadataForm.get('goodreadsReviewCountLocked')?.value,
hardcoverIdLocked: this.metadataForm.get('hardcoverIdLocked')?.value,
hardcoverRatingLocked: this.metadataForm.get('hardcoverRatingLocked')?.value,
hardcoverReviewCountLocked: this.metadataForm.get('hardcoverReviewCountLocked')?.value,
googleIdLocked: this.metadataForm.get('googleIdLocked')?.value,
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
@@ -147,21 +147,17 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
}
buildProviderLink(metadata: BookMetadata): string {
if (!metadata.provider || !metadata.providerBookId) {
throw new Error("Invalid metadata: 'provider' or 'providerBookId' is missing.");
}
switch (metadata.provider) {
case "Amazon":
return `<a href="https://www.amazon.com/dp/${metadata.providerBookId}" target="_blank">Amazon</a>`;
case "GoodReads":
return `<a href="https://www.goodreads.com/book/show/${metadata.providerBookId}" target="_blank">Goodreads</a>`;
case "Google":
return `<a href="https://books.google.com/books?id=${metadata.providerBookId}" target="_blank">Google</a>`;
case "Hardcover":
return `<a href="https://hardcover.app/books/${metadata.providerBookId}" target="_blank">Hardcover</a>`;
default:
throw new Error(`Unsupported provider: ${metadata.provider}`);
if (metadata.asin) {
return `<a href="https://www.amazon.com/dp/${metadata.asin}" target="_blank">Amazon</a>`;
} else if (metadata.goodreadsId) {
return `<a href="https://www.goodreads.com/book/show/${metadata.goodreadsId}" target="_blank">Goodreads</a>`;
} else if (metadata.googleId) {
return `<a href="https://books.google.com/books?id=${metadata.googleId}" target="_blank">Google</a>`;
} else if (metadata.hardcoverId) {
return `<a href="https://hardcover.app/books/${metadata.hardcoverId}" target="_blank">Hardcover</a>`;
}
throw new Error("No provider ID found in metadata.");
}
truncateText(text: string | null, length: number): string {
@@ -43,7 +43,18 @@
<div class="flex items-center gap-2 pt-2">
<ng-container *ngIf="metadata.amazonRating || metadata.goodreadsRating || metadata.hardcoverRating; else legacyRating">
<ng-container *ngIf="metadata.amazonRating">
<p class="font-semibold">Amazon: {{ metadata.amazonRating }}</p>
<ng-container *ngIf="metadata.asin; else amazonStatic">
<a class="flex items-center gap-1" [href]="'https://www.amazon.com/dp/' + metadata.asin" target="_blank" rel="noopener noreferrer">
<img src="https://www.amazon.com/favicon.ico" alt="Amazon" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.amazonRating }}</p>
</a>
</ng-container>
<ng-template #amazonStatic>
<span class="flex items-center gap-1">
<img src="https://www.amazon.com/favicon.ico" alt="Amazon" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.amazonRating }}</p>
</span>
</ng-template>
<p-rating [ngModel]="metadata.amazonRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
</p-rating>
@@ -52,7 +63,18 @@
</ng-container>
<ng-container *ngIf="metadata.goodreadsRating">
<p class="font-semibold">Goodreads: {{ metadata.goodreadsRating }}</p>
<ng-container *ngIf="metadata.goodreadsId; else goodreadsStatic">
<a class="flex items-center gap-1" [href]="'https://www.goodreads.com/book/show/' + metadata.goodreadsId" target="_blank" rel="noopener noreferrer">
<img src="https://www.goodreads.com/favicon.ico" alt="Goodreads" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.goodreadsRating }}</p>
</a>
</ng-container>
<ng-template #goodreadsStatic>
<span class="flex items-center gap-1">
<img src="https://www.goodreads.com/favicon.ico" alt="Goodreads" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.goodreadsRating }}</p>
</span>
</ng-template>
<p-rating [ngModel]="metadata.goodreadsRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
</p-rating>
@@ -61,11 +83,28 @@
</ng-container>
<ng-container *ngIf="metadata.hardcoverRating">
<p class="font-semibold">Hardcover: {{ metadata.hardcoverRating }}</p>
<ng-container *ngIf="metadata.hardcoverId; else hardcoverStatic">
<a class="flex items-center gap-1" [href]="'https://hardcover.app/books/' + metadata.hardcoverId" target="_blank" rel="noopener noreferrer">
<img src="https://assets.hardcover.app/static/favicon.ico" alt="Hardcover" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.hardcoverRating }}</p>
</a>
</ng-container>
<ng-template #hardcoverStatic>
<span class="flex items-center gap-1">
<img src="https://assets.hardcover.app/static/favicon.ico" alt="Hardcover" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.hardcoverRating }}</p>
</span>
</ng-template>
<p-rating [ngModel]="metadata.hardcoverRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
</p-rating>
<p class="font-semibold">({{ metadata.hardcoverReviewCount | number:'1.0-0' }})</p>
<span *ngIf="(metadata.amazonRating || metadata.goodreadsRating || metadata.hardcoverRating) && metadata.googleId">|</span>
</ng-container>
<ng-container *ngIf="metadata.googleId">
<a class="flex items-center gap-1" [href]="'https://books.google.com/books?id=' + metadata.googleId" target="_blank" rel="noopener noreferrer">
<img src="https://books.google.com/favicon.ico" alt="Google Books" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
</a>
</ng-container>
</ng-container>
@@ -46,6 +46,9 @@ export interface BookMetadata {
isbn13?: string;
isbn10?: string;
asin?: string;
goodreadsId?: string;
hardcoverId?: string;
googleId?: string;
pageCount?: number | null;
language?: string;
rating?: number | null;
@@ -74,6 +77,9 @@ export interface BookMetadata {
isbn13Locked?: boolean;
isbn10Locked?: boolean;
asinLocked?: boolean;
goodreadsIdLocked?: boolean;
hardcoverIdLocked?: boolean;
googleIdLocked?: boolean;
pageCountLocked?: boolean;
languageLocked?: boolean;
ratingLocked?: boolean;