Support Hardcover as metadata provider
This commit is contained in:
committed by
Aditya Chandel
parent
d56d8181d0
commit
da6decb349
@@ -1,10 +1,7 @@
|
|||||||
package com.adityachandel.booklore.config;
|
package com.adityachandel.booklore.config;
|
||||||
|
|
||||||
import com.adityachandel.booklore.model.enums.MetadataProvider;
|
import com.adityachandel.booklore.model.enums.MetadataProvider;
|
||||||
import com.adityachandel.booklore.service.metadata.parser.AmazonBookParser;
|
import com.adityachandel.booklore.service.metadata.parser.*;
|
||||||
import com.adityachandel.booklore.service.metadata.parser.BookParser;
|
|
||||||
import com.adityachandel.booklore.service.metadata.parser.GoodReadsParser;
|
|
||||||
import com.adityachandel.booklore.service.metadata.parser.GoogleParser;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@@ -14,11 +11,13 @@ import java.util.Map;
|
|||||||
public class BookParserConfig {
|
public class BookParserConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Map<MetadataProvider, BookParser> parserMap(GoogleParser googleParser, AmazonBookParser amazonBookParser, GoodReadsParser goodReadsParser) {
|
public Map<MetadataProvider, BookParser> parserMap(GoogleParser googleParser, AmazonBookParser amazonBookParser,
|
||||||
|
GoodReadsParser goodReadsParser, HardcoverParser hardcoverParser) {
|
||||||
return Map.of(
|
return Map.of(
|
||||||
MetadataProvider.Amazon, amazonBookParser,
|
MetadataProvider.Amazon, amazonBookParser,
|
||||||
MetadataProvider.GoodReads, goodReadsParser,
|
MetadataProvider.GoodReads, goodReadsParser,
|
||||||
MetadataProvider.Google, googleParser
|
MetadataProvider.Google, googleParser,
|
||||||
|
MetadataProvider.Hardcover, hardcoverParser
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,16 @@ public class BookMetadata {
|
|||||||
private Integer pageCount;
|
private Integer pageCount;
|
||||||
private String language;
|
private String language;
|
||||||
private Double rating;
|
private Double rating;
|
||||||
|
@Deprecated
|
||||||
private Integer ratingCount;
|
private Integer ratingCount;
|
||||||
|
@Deprecated
|
||||||
private Integer reviewCount;
|
private Integer reviewCount;
|
||||||
private Double amazonRating;
|
private Double amazonRating;
|
||||||
private Integer amazonReviewCount;
|
private Integer amazonReviewCount;
|
||||||
private Double goodreadsRating;
|
private Double goodreadsRating;
|
||||||
private Integer goodreadsReviewCount;
|
private Integer goodreadsReviewCount;
|
||||||
|
private Double hardcoverRating;
|
||||||
|
private Integer hardcoverReviewCount;
|
||||||
private Instant coverUpdatedOn;
|
private Instant coverUpdatedOn;
|
||||||
private List<String> authors;
|
private List<String> authors;
|
||||||
private List<String> categories;
|
private List<String> categories;
|
||||||
@@ -64,6 +68,8 @@ public class BookMetadata {
|
|||||||
private Boolean amazonReviewCountLocked;
|
private Boolean amazonReviewCountLocked;
|
||||||
private Boolean goodreadsRatingLocked;
|
private Boolean goodreadsRatingLocked;
|
||||||
private Boolean goodreadsReviewCountLocked;
|
private Boolean goodreadsReviewCountLocked;
|
||||||
|
private Boolean hardcoverRatingLocked;
|
||||||
|
private Boolean hardcoverReviewCountLocked;
|
||||||
private Boolean coverLocked;
|
private Boolean coverLocked;
|
||||||
private Boolean authorsLocked;
|
private Boolean authorsLocked;
|
||||||
private Boolean categoriesLocked;
|
private Boolean categoriesLocked;
|
||||||
|
|||||||
+1
@@ -9,6 +9,7 @@ public enum AppSettingKey {
|
|||||||
OIDC_AUTO_PROVISION_DETAILS("oidc_auto_provision_details", true),
|
OIDC_AUTO_PROVISION_DETAILS("oidc_auto_provision_details", true),
|
||||||
SIDEBAR_LIBRARY_SORTING("sidebar_library_sorting", true),
|
SIDEBAR_LIBRARY_SORTING("sidebar_library_sorting", true),
|
||||||
SIDEBAR_SHELF_SORTING("sidebar_shelf_sorting", true),
|
SIDEBAR_SHELF_SORTING("sidebar_shelf_sorting", true),
|
||||||
|
METADATA_PROVIDER_SETTINGS("metadata_provider_settings", true),
|
||||||
|
|
||||||
AUTO_BOOK_SEARCH("auto_book_search", false),
|
AUTO_BOOK_SEARCH("auto_book_search", false),
|
||||||
COVER_IMAGE_RESOLUTION("cover_image_resolution", false),
|
COVER_IMAGE_RESOLUTION("cover_image_resolution", false),
|
||||||
|
|||||||
+1
@@ -24,4 +24,5 @@ public class AppSettings {
|
|||||||
private boolean oidcEnabled;
|
private boolean oidcEnabled;
|
||||||
private OidcProviderDetails oidcProviderDetails;
|
private OidcProviderDetails oidcProviderDetails;
|
||||||
private OidcAutoProvisionDetails oidcAutoProvisionDetails;
|
private OidcAutoProvisionDetails oidcAutoProvisionDetails;
|
||||||
|
private MetadataProviderSettings metadataProviderSettings;
|
||||||
}
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.adityachandel.booklore.model.dto.settings;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MetadataProviderSettings {
|
||||||
|
private Amazon amazon;
|
||||||
|
private Google google;
|
||||||
|
private Goodreads goodReads;
|
||||||
|
private Hardcover hardcover;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Amazon {
|
||||||
|
private boolean enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Google {
|
||||||
|
private boolean enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Goodreads {
|
||||||
|
private boolean enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Hardcover {
|
||||||
|
private boolean enabled;
|
||||||
|
private String apiKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
-2
@@ -84,6 +84,12 @@ public class BookMetadataEntity {
|
|||||||
@Column(name = "goodreads_review_count")
|
@Column(name = "goodreads_review_count")
|
||||||
private Integer goodreadsReviewCount;
|
private Integer goodreadsReviewCount;
|
||||||
|
|
||||||
|
@Column(name = "hardcover_rating")
|
||||||
|
private Double hardcoverRating;
|
||||||
|
|
||||||
|
@Column(name = "hardcover_review_count")
|
||||||
|
private Integer hardcoverReviewCount;
|
||||||
|
|
||||||
// Locking fields
|
// Locking fields
|
||||||
|
|
||||||
@Column(name = "title_locked")
|
@Column(name = "title_locked")
|
||||||
@@ -137,6 +143,12 @@ public class BookMetadataEntity {
|
|||||||
@Column(name = "goodreads_review_count_locked")
|
@Column(name = "goodreads_review_count_locked")
|
||||||
private Boolean goodreadsReviewCountLocked = Boolean.FALSE;
|
private Boolean goodreadsReviewCountLocked = Boolean.FALSE;
|
||||||
|
|
||||||
|
@Column(name = "hardcover_rating_locked")
|
||||||
|
private Boolean hardcoverRatingLocked = Boolean.FALSE;
|
||||||
|
|
||||||
|
@Column(name = "hardcover_review_count_locked")
|
||||||
|
private Boolean hardcoverReviewCountLocked = Boolean.FALSE;
|
||||||
|
|
||||||
@Column(name = "cover_locked")
|
@Column(name = "cover_locked")
|
||||||
private Boolean coverLocked = Boolean.FALSE;
|
private Boolean coverLocked = Boolean.FALSE;
|
||||||
|
|
||||||
@@ -203,6 +215,8 @@ public class BookMetadataEntity {
|
|||||||
this.amazonReviewCountLocked = lock;
|
this.amazonReviewCountLocked = lock;
|
||||||
this.goodreadsRatingLocked = lock;
|
this.goodreadsRatingLocked = lock;
|
||||||
this.goodreadsReviewCountLocked = lock;
|
this.goodreadsReviewCountLocked = lock;
|
||||||
|
this.hardcoverRatingLocked = lock;
|
||||||
|
this.hardcoverReviewCountLocked = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAnyFieldLocked() {
|
public boolean isAnyFieldLocked() {
|
||||||
@@ -228,7 +242,9 @@ public class BookMetadataEntity {
|
|||||||
|| Boolean.TRUE.equals(this.amazonRatingLocked)
|
|| Boolean.TRUE.equals(this.amazonRatingLocked)
|
||||||
|| Boolean.TRUE.equals(this.amazonReviewCountLocked)
|
|| Boolean.TRUE.equals(this.amazonReviewCountLocked)
|
||||||
|| Boolean.TRUE.equals(this.goodreadsRatingLocked)
|
|| Boolean.TRUE.equals(this.goodreadsRatingLocked)
|
||||||
|| Boolean.TRUE.equals(this.goodreadsReviewCountLocked);
|
|| Boolean.TRUE.equals(this.goodreadsReviewCountLocked)
|
||||||
|
|| Boolean.TRUE.equals(this.hardcoverRatingLocked)
|
||||||
|
|| Boolean.TRUE.equals(this.hardcoverReviewCountLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areAllFieldsLocked() {
|
public boolean areAllFieldsLocked() {
|
||||||
@@ -254,6 +270,9 @@ public class BookMetadataEntity {
|
|||||||
&& Boolean.TRUE.equals(this.amazonRatingLocked)
|
&& Boolean.TRUE.equals(this.amazonRatingLocked)
|
||||||
&& Boolean.TRUE.equals(this.amazonReviewCountLocked)
|
&& Boolean.TRUE.equals(this.amazonReviewCountLocked)
|
||||||
&& Boolean.TRUE.equals(this.goodreadsRatingLocked)
|
&& Boolean.TRUE.equals(this.goodreadsRatingLocked)
|
||||||
&& Boolean.TRUE.equals(this.goodreadsReviewCountLocked);
|
&& Boolean.TRUE.equals(this.goodreadsReviewCountLocked)
|
||||||
|
&& Boolean.TRUE.equals(this.hardcoverRatingLocked)
|
||||||
|
&& Boolean.TRUE.equals(this.hardcoverReviewCountLocked)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
package com.adityachandel.booklore.model.enums;
|
package com.adityachandel.booklore.model.enums;
|
||||||
|
|
||||||
public enum MetadataProvider {
|
public enum MetadataProvider {
|
||||||
Amazon, GoodReads, Google
|
Amazon, GoodReads, Google, Hardcover
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class AppSettingService {
|
|||||||
builder.metadataRefreshOptions(getJsonSetting(settingsMap, AppSettingKey.QUICK_BOOK_MATCH, MetadataRefreshOptions.class, null, false));
|
builder.metadataRefreshOptions(getJsonSetting(settingsMap, AppSettingKey.QUICK_BOOK_MATCH, MetadataRefreshOptions.class, null, false));
|
||||||
builder.oidcProviderDetails(getJsonSetting(settingsMap, AppSettingKey.OIDC_PROVIDER_DETAILS, OidcProviderDetails.class, null, false));
|
builder.oidcProviderDetails(getJsonSetting(settingsMap, AppSettingKey.OIDC_PROVIDER_DETAILS, OidcProviderDetails.class, null, false));
|
||||||
builder.oidcAutoProvisionDetails(getJsonSetting(settingsMap, AppSettingKey.OIDC_AUTO_PROVISION_DETAILS, OidcAutoProvisionDetails.class, null, false));
|
builder.oidcAutoProvisionDetails(getJsonSetting(settingsMap, AppSettingKey.OIDC_AUTO_PROVISION_DETAILS, OidcAutoProvisionDetails.class, null, false));
|
||||||
|
builder.metadataProviderSettings(getJsonSetting(settingsMap, AppSettingKey.METADATA_PROVIDER_SETTINGS, MetadataProviderSettings.class, getMetadataProviderSettings(), true));
|
||||||
|
|
||||||
builder.coverResolution(getOrCreateSetting(AppSettingKey.COVER_IMAGE_RESOLUTION, "250x350"));
|
builder.coverResolution(getOrCreateSetting(AppSettingKey.COVER_IMAGE_RESOLUTION, "250x350"));
|
||||||
builder.autoBookSearch(Boolean.parseBoolean(getOrCreateSetting(AppSettingKey.AUTO_BOOK_SEARCH, "true")));
|
builder.autoBookSearch(Boolean.parseBoolean(getOrCreateSetting(AppSettingKey.AUTO_BOOK_SEARCH, "true")));
|
||||||
@@ -121,4 +122,24 @@ public class AppSettingService {
|
|||||||
private String serializeSettingValue(AppSettingKey key, Object val) throws JsonProcessingException {
|
private String serializeSettingValue(AppSettingKey key, Object val) throws JsonProcessingException {
|
||||||
return key.isJson() ? objectMapper.writeValueAsString(val) : val.toString();
|
return key.isJson() ? objectMapper.writeValueAsString(val) : val.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static MetadataProviderSettings getMetadataProviderSettings() {
|
||||||
|
MetadataProviderSettings defaultMetadataProviderSettings = new MetadataProviderSettings();
|
||||||
|
|
||||||
|
MetadataProviderSettings.Amazon defaultAmazon = new MetadataProviderSettings.Amazon();
|
||||||
|
defaultAmazon.setEnabled(true);
|
||||||
|
MetadataProviderSettings.Google defaultGoogle = new MetadataProviderSettings.Google();
|
||||||
|
defaultGoogle.setEnabled(true);
|
||||||
|
MetadataProviderSettings.Goodreads defaultGoodreads = new MetadataProviderSettings.Goodreads();
|
||||||
|
defaultGoodreads.setEnabled(true);
|
||||||
|
MetadataProviderSettings.Hardcover defaultHardcover = new MetadataProviderSettings.Hardcover();
|
||||||
|
defaultHardcover.setEnabled(false);
|
||||||
|
defaultHardcover.setApiKey(null);
|
||||||
|
|
||||||
|
defaultMetadataProviderSettings.setAmazon(defaultAmazon);
|
||||||
|
defaultMetadataProviderSettings.setGoogle(defaultGoogle);
|
||||||
|
defaultMetadataProviderSettings.setGoodReads(defaultGoodreads);
|
||||||
|
defaultMetadataProviderSettings.setHardcover(defaultHardcover);
|
||||||
|
return defaultMetadataProviderSettings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+14
@@ -98,6 +98,14 @@ public class BookMetadataUpdater {
|
|||||||
metadata.setGoodreadsReviewCount(newMetadata.getGoodreadsReviewCount());
|
metadata.setGoodreadsReviewCount(newMetadata.getGoodreadsReviewCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((metadata.getHardcoverRatingLocked() == null || !metadata.getHardcoverRatingLocked()) && newMetadata.getHardcoverRating() != null) {
|
||||||
|
metadata.setHardcoverRating(newMetadata.getHardcoverRating());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((metadata.getHardcoverReviewCountLocked() == null || !metadata.getHardcoverReviewCountLocked()) && newMetadata.getHardcoverReviewCount() != null) {
|
||||||
|
metadata.setHardcoverReviewCount(newMetadata.getHardcoverReviewCount());
|
||||||
|
}
|
||||||
|
|
||||||
if ((metadata.getSeriesNameLocked() == null || !metadata.getSeriesNameLocked()) && newMetadata.getSeriesName() != null) {
|
if ((metadata.getSeriesNameLocked() == null || !metadata.getSeriesNameLocked()) && newMetadata.getSeriesName() != null) {
|
||||||
metadata.setSeriesName(newMetadata.getSeriesName());
|
metadata.setSeriesName(newMetadata.getSeriesName());
|
||||||
}
|
}
|
||||||
@@ -239,6 +247,12 @@ public class BookMetadataUpdater {
|
|||||||
if (newMetadata.getGoodreadsReviewCountLocked() != null) {
|
if (newMetadata.getGoodreadsReviewCountLocked() != null) {
|
||||||
metadata.setGoodreadsReviewCountLocked(newMetadata.getGoodreadsReviewCountLocked());
|
metadata.setGoodreadsReviewCountLocked(newMetadata.getGoodreadsReviewCountLocked());
|
||||||
}
|
}
|
||||||
|
if (newMetadata.getHardcoverRatingLocked() != null) {
|
||||||
|
metadata.setHardcoverRatingLocked(newMetadata.getHardcoverRatingLocked());
|
||||||
|
}
|
||||||
|
if (newMetadata.getHardcoverReviewCountLocked() != null) {
|
||||||
|
metadata.setHardcoverReviewCountLocked(newMetadata.getHardcoverReviewCountLocked());
|
||||||
|
}
|
||||||
if (newMetadata.getSeriesNameLocked() != null) {
|
if (newMetadata.getSeriesNameLocked() != null) {
|
||||||
metadata.setSeriesNameLocked(newMetadata.getSeriesNameLocked());
|
metadata.setSeriesNameLocked(newMetadata.getSeriesNameLocked());
|
||||||
}
|
}
|
||||||
|
|||||||
+83
@@ -0,0 +1,83 @@
|
|||||||
|
package com.adityachandel.booklore.service.metadata.parser;
|
||||||
|
|
||||||
|
import com.adityachandel.booklore.model.dto.Book;
|
||||||
|
import com.adityachandel.booklore.model.dto.BookMetadata;
|
||||||
|
import com.adityachandel.booklore.model.dto.request.FetchMetadataRequest;
|
||||||
|
import com.adityachandel.booklore.model.enums.MetadataProvider;
|
||||||
|
import com.adityachandel.booklore.service.metadata.parser.hardcover.GraphQLResponse;
|
||||||
|
import com.adityachandel.booklore.service.metadata.parser.hardcover.HardcoverBookSearchService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class HardcoverParser implements BookParser {
|
||||||
|
|
||||||
|
private final HardcoverBookSearchService hardcoverBookSearchService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BookMetadata> fetchMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
|
||||||
|
List<GraphQLResponse.Hit> hits = hardcoverBookSearchService.searchBooks(fetchMetadataRequest.getTitle());
|
||||||
|
|
||||||
|
return hits.stream().map(hit -> {
|
||||||
|
GraphQLResponse.Document doc = hit.getDocument();
|
||||||
|
BookMetadata metadata = new BookMetadata();
|
||||||
|
metadata.setProviderBookId(doc.getSlug());
|
||||||
|
metadata.setTitle(doc.getTitle());
|
||||||
|
metadata.setDescription(doc.getDescription());
|
||||||
|
metadata.setAuthors(doc.getAuthorNames());
|
||||||
|
|
||||||
|
if (doc.getFeaturedSeries() != null) {
|
||||||
|
if (doc.getFeaturedSeries().getSeries() != null) {
|
||||||
|
metadata.setSeriesName(doc.getFeaturedSeries().getSeries().getName());
|
||||||
|
metadata.setSeriesTotal(doc.getFeaturedSeries().getSeries().getBooksCount());
|
||||||
|
}
|
||||||
|
if (doc.getFeaturedSeries().getPosition() != null) {
|
||||||
|
try {
|
||||||
|
metadata.setSeriesNumber(Float.parseFloat(String.valueOf(doc.getFeaturedSeries().getPosition())));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.getRating() != null) {
|
||||||
|
BigDecimal roundedRating = BigDecimal.valueOf(doc.getRating()).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
metadata.setHardcoverRating(roundedRating.doubleValue());
|
||||||
|
}
|
||||||
|
metadata.setHardcoverReviewCount(doc.getRatingsCount());
|
||||||
|
metadata.setPageCount(doc.getPages());
|
||||||
|
metadata.setPublishedDate(doc.getReleaseDate() != null ? LocalDate.parse(doc.getReleaseDate()) : null);
|
||||||
|
metadata.setCategories(doc.getGenres());
|
||||||
|
|
||||||
|
if (doc.getIsbns() != null) {
|
||||||
|
metadata.setIsbn10(doc.getIsbns().stream()
|
||||||
|
.filter(isbn -> isbn.length() == 10)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null));
|
||||||
|
|
||||||
|
metadata.setIsbn13(doc.getIsbns().stream()
|
||||||
|
.filter(isbn -> isbn.length() == 13)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
metadata.setThumbnailUrl(doc.getImage() != null ? doc.getImage().getUrl() : null);
|
||||||
|
metadata.setProvider(MetadataProvider.Hardcover);
|
||||||
|
return metadata;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BookMetadata fetchTopMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
|
||||||
|
List<BookMetadata> bookMetadata = fetchMetadata(book, fetchMetadataRequest);
|
||||||
|
return bookMetadata.getFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.adityachandel.booklore.service.metadata.parser.hardcover;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GraphQLRequest {
|
||||||
|
private String query;
|
||||||
|
private String operationName;
|
||||||
|
}
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
package com.adityachandel.booklore.service.metadata.parser.hardcover;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class GraphQLResponse {
|
||||||
|
private DataWrapper data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class DataWrapper {
|
||||||
|
private SearchWrapper search;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class SearchWrapper {
|
||||||
|
private ResultsWrapper results;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class ResultsWrapper {
|
||||||
|
private List<Hit> hits;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class Hit {
|
||||||
|
private Document document;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class Document {
|
||||||
|
private String id;
|
||||||
|
private String slug;
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@JsonProperty("author_names")
|
||||||
|
private List<String> authorNames;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
private List<String> isbns;
|
||||||
|
private Double rating;
|
||||||
|
|
||||||
|
@JsonProperty("ratings_count")
|
||||||
|
private Integer ratingsCount;
|
||||||
|
|
||||||
|
private Integer pages;
|
||||||
|
|
||||||
|
@JsonProperty("release_date")
|
||||||
|
private String releaseDate;
|
||||||
|
|
||||||
|
private List<String> genres;
|
||||||
|
|
||||||
|
@JsonProperty("featured_series")
|
||||||
|
private FeaturedSeries featuredSeries;
|
||||||
|
|
||||||
|
private Image image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class Image {
|
||||||
|
private String url;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class FeaturedSeries {
|
||||||
|
private Integer position;
|
||||||
|
private Series series;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class Series {
|
||||||
|
private String name;
|
||||||
|
@JsonProperty("books_count")
|
||||||
|
private Integer booksCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package com.adityachandel.booklore.service.metadata.parser.hardcover;
|
||||||
|
|
||||||
|
import com.adityachandel.booklore.service.AppSettingService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestClient;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class HardcoverBookSearchService {
|
||||||
|
|
||||||
|
private final RestClient restClient;
|
||||||
|
private final AppSettingService appSettingService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public HardcoverBookSearchService(AppSettingService appSettingService) {
|
||||||
|
this.appSettingService = appSettingService;
|
||||||
|
String apiUrl = "https://api.hardcover.app/v1/graphql";
|
||||||
|
this.restClient = RestClient.builder()
|
||||||
|
.baseUrl(apiUrl)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GraphQLResponse.Hit> searchBooks(String query) {
|
||||||
|
String apiToken = appSettingService.getAppSettings().getMetadataProviderSettings().getHardcover().getApiKey();
|
||||||
|
if (apiToken == null || apiToken.isEmpty()) {
|
||||||
|
log.warn("Hardcover API token not set");
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
String graphqlQuery = """
|
||||||
|
query SearchBooks {
|
||||||
|
search(
|
||||||
|
query: "%s",
|
||||||
|
query_type: "Book",
|
||||||
|
per_page: 5,
|
||||||
|
page: 1
|
||||||
|
) {
|
||||||
|
results
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""".formatted(query);
|
||||||
|
|
||||||
|
GraphQLRequest body = new GraphQLRequest();
|
||||||
|
body.setQuery(graphqlQuery);
|
||||||
|
body.setOperationName("SearchBooks");
|
||||||
|
|
||||||
|
GraphQLResponse response = restClient.post()
|
||||||
|
.uri("")
|
||||||
|
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
.header(HttpHeaders.AUTHORIZATION, "Bearer " + apiToken)
|
||||||
|
.body(body)
|
||||||
|
.retrieve()
|
||||||
|
.body(GraphQLResponse.class);
|
||||||
|
|
||||||
|
return response.getData().getSearch().getResults().getHits();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
ALTER TABLE book_metadata
|
||||||
|
ADD COLUMN hardcover_rating FLOAT,
|
||||||
|
ADD COLUMN hardcover_review_count INT,
|
||||||
|
ADD COLUMN hardcover_rating_locked BOOLEAN DEFAULT FALSE,
|
||||||
|
ADD COLUMN hardcover_review_count_locked BOOLEAN DEFAULT FALSE
|
||||||
+20
-4
@@ -194,7 +194,7 @@
|
|||||||
|
|
||||||
<!-- Review Count, Rating, Page Count -->
|
<!-- Review Count, Rating, Page Count -->
|
||||||
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
|
<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 w-1/6">
|
||||||
<label for="amazonRatingCount">Amazon Rating Count</label>
|
<label for="amazonRatingCount">Amazon Rating Count</label>
|
||||||
<div class="flex justify-between items-center gap-2">
|
<div class="flex justify-between items-center gap-2">
|
||||||
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
|
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
|
||||||
@@ -202,7 +202,7 @@
|
|||||||
<p-button *ngIf="metadata['amazonReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
|
<p-button *ngIf="metadata['amazonReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1 w-1/4">
|
<div class="flex flex-col gap-1 w-1/6">
|
||||||
<label for="amazonRating">Amazon Rating</label>
|
<label for="amazonRating">Amazon Rating</label>
|
||||||
<div class="flex justify-between items-center gap-2">
|
<div class="flex justify-between items-center gap-2">
|
||||||
<input pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
|
<input pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
|
||||||
@@ -210,7 +210,7 @@
|
|||||||
<p-button *ngIf="metadata['amazonRatingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
|
<p-button *ngIf="metadata['amazonRatingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1 w-1/4">
|
<div class="flex flex-col gap-1 w-1/6">
|
||||||
<label for="goodreadsReviewCount">Goodreads Rating Count</label>
|
<label for="goodreadsReviewCount">Goodreads Rating Count</label>
|
||||||
<div class="flex justify-between items-center gap-2">
|
<div class="flex justify-between items-center gap-2">
|
||||||
<input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
|
<input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
<p-button *ngIf="metadata['goodreadsReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
|
<p-button *ngIf="metadata['goodreadsReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1 w-1/4">
|
<div class="flex flex-col gap-1 w-1/6">
|
||||||
<label for="goodreadsRating">Goodreads Rating</label>
|
<label for="goodreadsRating">Goodreads Rating</label>
|
||||||
<div class="flex justify-between items-center gap-2">
|
<div class="flex justify-between items-center gap-2">
|
||||||
<input pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
|
<input pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
|
||||||
@@ -226,6 +226,22 @@
|
|||||||
<p-button *ngIf="metadata['goodreadsRatingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
|
<p-button *ngIf="metadata['goodreadsRatingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-col gap-1 w-1/6">
|
||||||
|
<label for="hardcoverReviewCount">Hardcover Rating Count</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 class="flex flex-col gap-1 w-1/6">
|
||||||
|
<label for="hardcoverRating">Hardcover Rating</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>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+14
@@ -79,6 +79,8 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
amazonReviewCount: new FormControl(''),
|
amazonReviewCount: new FormControl(''),
|
||||||
goodreadsRating: new FormControl(''),
|
goodreadsRating: new FormControl(''),
|
||||||
goodreadsReviewCount: new FormControl(''),
|
goodreadsReviewCount: new FormControl(''),
|
||||||
|
hardcoverRating: new FormControl(''),
|
||||||
|
hardcoverReviewCount: new FormControl(''),
|
||||||
seriesName: new FormControl(''),
|
seriesName: new FormControl(''),
|
||||||
seriesNumber: new FormControl(''),
|
seriesNumber: new FormControl(''),
|
||||||
seriesTotal: new FormControl(''),
|
seriesTotal: new FormControl(''),
|
||||||
@@ -101,6 +103,8 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
amazonReviewCountLocked: new FormControl(false),
|
amazonReviewCountLocked: new FormControl(false),
|
||||||
goodreadsRatingLocked: new FormControl(false),
|
goodreadsRatingLocked: new FormControl(false),
|
||||||
goodreadsReviewCountLocked: new FormControl(false),
|
goodreadsReviewCountLocked: new FormControl(false),
|
||||||
|
hardcoverRatingLocked: new FormControl(false),
|
||||||
|
hardcoverReviewCountLocked: new FormControl(false),
|
||||||
seriesNameLocked: new FormControl(false),
|
seriesNameLocked: new FormControl(false),
|
||||||
seriesNumberLocked: new FormControl(false),
|
seriesNumberLocked: new FormControl(false),
|
||||||
seriesTotalLocked: new FormControl(false),
|
seriesTotalLocked: new FormControl(false),
|
||||||
@@ -137,6 +141,8 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
amazonReviewCount: metadata.amazonReviewCount || null,
|
amazonReviewCount: metadata.amazonReviewCount || null,
|
||||||
goodreadsRating: metadata.goodreadsRating || null,
|
goodreadsRating: metadata.goodreadsRating || null,
|
||||||
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
|
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
|
||||||
|
hardcoverRating: metadata.hardcoverRating || null,
|
||||||
|
hardcoverReviewCount: metadata.hardcoverReviewCount || null,
|
||||||
seriesName: metadata.seriesName || null,
|
seriesName: metadata.seriesName || null,
|
||||||
seriesNumber: metadata.seriesNumber || null,
|
seriesNumber: metadata.seriesNumber || null,
|
||||||
seriesTotal: metadata.seriesTotal || null,
|
seriesTotal: metadata.seriesTotal || null,
|
||||||
@@ -159,6 +165,8 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
|
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
|
||||||
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
|
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
|
||||||
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
|
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
|
||||||
|
hardcoverRatingLocked: metadata.hardcoverRatingLocked || false,
|
||||||
|
hardcoverReviewCountLocked: metadata.hardcoverReviewCountLocked || false,
|
||||||
seriesNameLocked: metadata.seriesNameLocked || false,
|
seriesNameLocked: metadata.seriesNameLocked || false,
|
||||||
seriesNumberLocked: metadata.seriesNumberLocked || false,
|
seriesNumberLocked: metadata.seriesNumberLocked || false,
|
||||||
seriesTotalLocked: metadata.seriesTotalLocked || false,
|
seriesTotalLocked: metadata.seriesTotalLocked || false,
|
||||||
@@ -180,6 +188,8 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
{ key: 'amazonRatingLocked', control: 'amazonRating' },
|
{ key: 'amazonRatingLocked', control: 'amazonRating' },
|
||||||
{ key: 'goodreadsReviewCountLocked', control: 'goodreadsReviewCount' },
|
{ key: 'goodreadsReviewCountLocked', control: 'goodreadsReviewCount' },
|
||||||
{ key: 'goodreadsRatingLocked', control: 'goodreadsRating' },
|
{ key: 'goodreadsRatingLocked', control: 'goodreadsRating' },
|
||||||
|
{ key: 'hardcoverReviewCountLocked', control: 'hardcoverReviewCount' },
|
||||||
|
{ key: 'hardcoverRatingLocked', control: 'hardcoverRating' },
|
||||||
{ key: 'pageCountLocked', control: 'pageCount' },
|
{ key: 'pageCountLocked', control: 'pageCount' },
|
||||||
{ key: 'descriptionLocked', control: 'description' },
|
{ key: 'descriptionLocked', control: 'description' },
|
||||||
{ key: 'seriesNameLocked', control: 'seriesName' },
|
{ key: 'seriesNameLocked', control: 'seriesName' },
|
||||||
@@ -295,6 +305,8 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value,
|
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value,
|
||||||
goodreadsRating: this.metadataForm.get('goodreadsRating')?.value,
|
goodreadsRating: this.metadataForm.get('goodreadsRating')?.value,
|
||||||
goodreadsReviewCount: this.metadataForm.get('goodreadsReviewCount')?.value,
|
goodreadsReviewCount: this.metadataForm.get('goodreadsReviewCount')?.value,
|
||||||
|
hardcoverRating: this.metadataForm.get('hardcoverRating')?.value,
|
||||||
|
hardcoverReviewCount: this.metadataForm.get('hardcoverReviewCount')?.value,
|
||||||
language: this.metadataForm.get('language')?.value,
|
language: this.metadataForm.get('language')?.value,
|
||||||
seriesName: this.metadataForm.get('seriesName')?.value,
|
seriesName: this.metadataForm.get('seriesName')?.value,
|
||||||
seriesNumber: this.metadataForm.get('seriesNumber')?.value,
|
seriesNumber: this.metadataForm.get('seriesNumber')?.value,
|
||||||
@@ -318,6 +330,8 @@ export class MetadataEditorComponent implements OnInit {
|
|||||||
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
||||||
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.value,
|
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.value,
|
||||||
goodreadsReviewCountLocked: this.metadataForm.get('goodreadsReviewCountLocked')?.value,
|
goodreadsReviewCountLocked: this.metadataForm.get('goodreadsReviewCountLocked')?.value,
|
||||||
|
hardcoverRatingLocked: this.metadataForm.get('hardcoverRatingLocked')?.value,
|
||||||
|
hardcoverReviewCountLocked: this.metadataForm.get('hardcoverReviewCountLocked')?.value,
|
||||||
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
|
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
|
||||||
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
||||||
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
|
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
|
||||||
|
|||||||
+16
@@ -59,6 +59,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
{label: 'Amazon Rating', controlName: 'amazonRating', lockedKey: 'amazonRatingLocked', fetchedKey: 'amazonRating'},
|
{label: 'Amazon Rating', controlName: 'amazonRating', lockedKey: 'amazonRatingLocked', fetchedKey: 'amazonRating'},
|
||||||
{label: 'Goodreads Reviews', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
|
{label: 'Goodreads Reviews', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
|
||||||
{label: 'Goodreads Rating', controlName: 'goodreadsRating', lockedKey: 'goodreadsRatingLocked', fetchedKey: 'goodreadsRating'},
|
{label: 'Goodreads Rating', controlName: 'goodreadsRating', lockedKey: 'goodreadsRatingLocked', fetchedKey: 'goodreadsRating'},
|
||||||
|
{label: 'Hardcover Reviews', controlName: 'hardcoverReviewCount', lockedKey: 'hardcoverReviewCountLocked', fetchedKey: 'hardcoverReviewCount'},
|
||||||
|
{label: 'Hardcover Rating', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
|
||||||
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'}
|
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'}
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -96,6 +98,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
amazonReviewCount: new FormControl(''),
|
amazonReviewCount: new FormControl(''),
|
||||||
goodreadsRating: new FormControl(''),
|
goodreadsRating: new FormControl(''),
|
||||||
goodreadsReviewCount: new FormControl(''),
|
goodreadsReviewCount: new FormControl(''),
|
||||||
|
hardcoverRating: new FormControl(''),
|
||||||
|
hardcoverReviewCount: new FormControl(''),
|
||||||
seriesName: new FormControl(''),
|
seriesName: new FormControl(''),
|
||||||
seriesNumber: new FormControl(''),
|
seriesNumber: new FormControl(''),
|
||||||
seriesTotal: new FormControl(''),
|
seriesTotal: new FormControl(''),
|
||||||
@@ -117,6 +121,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
amazonReviewCountLocked: new FormControl(false),
|
amazonReviewCountLocked: new FormControl(false),
|
||||||
goodreadsRatingLocked: new FormControl(false),
|
goodreadsRatingLocked: new FormControl(false),
|
||||||
goodreadsReviewCountLocked: new FormControl(false),
|
goodreadsReviewCountLocked: new FormControl(false),
|
||||||
|
hardcoverRatingLocked: new FormControl(false),
|
||||||
|
hardcoverReviewCountLocked: new FormControl(false),
|
||||||
seriesNameLocked: new FormControl(false),
|
seriesNameLocked: new FormControl(false),
|
||||||
seriesNumberLocked: new FormControl(false),
|
seriesNumberLocked: new FormControl(false),
|
||||||
seriesTotalLocked: new FormControl(false),
|
seriesTotalLocked: new FormControl(false),
|
||||||
@@ -147,6 +153,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
amazonReviewCount: metadata.amazonReviewCount || null,
|
amazonReviewCount: metadata.amazonReviewCount || null,
|
||||||
goodreadsRating: metadata.goodreadsRating || null,
|
goodreadsRating: metadata.goodreadsRating || null,
|
||||||
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
|
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
|
||||||
|
hardcoverRating: metadata.hardcoverRating || null,
|
||||||
|
hardcoverReviewCount: metadata.hardcoverReviewCount || null,
|
||||||
seriesName: metadata.seriesName || null,
|
seriesName: metadata.seriesName || null,
|
||||||
seriesNumber: metadata.seriesNumber || null,
|
seriesNumber: metadata.seriesNumber || null,
|
||||||
seriesTotal: metadata.seriesTotal || null,
|
seriesTotal: metadata.seriesTotal || null,
|
||||||
@@ -168,6 +176,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
|
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
|
||||||
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
|
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
|
||||||
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
|
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
|
||||||
|
hardcoverRatingLocked: metadata.hardcoverRatingLocked || false,
|
||||||
|
hardcoverReviewCountLocked: metadata.hardcoverReviewCountLocked || false,
|
||||||
seriesNameLocked: metadata.seriesNameLocked || false,
|
seriesNameLocked: metadata.seriesNameLocked || false,
|
||||||
seriesNumberLocked: metadata.seriesNumberLocked || false,
|
seriesNumberLocked: metadata.seriesNumberLocked || false,
|
||||||
seriesTotalLocked: metadata.seriesTotalLocked || false,
|
seriesTotalLocked: metadata.seriesTotalLocked || false,
|
||||||
@@ -188,6 +198,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
if (metadata.amazonRatingLocked) this.metadataForm.get('amazonRating')?.disable();
|
if (metadata.amazonRatingLocked) this.metadataForm.get('amazonRating')?.disable();
|
||||||
if (metadata.goodreadsReviewCountLocked) this.metadataForm.get('goodreadsReviewCount')?.disable();
|
if (metadata.goodreadsReviewCountLocked) this.metadataForm.get('goodreadsReviewCount')?.disable();
|
||||||
if (metadata.goodreadsRatingLocked) this.metadataForm.get('goodreadsRating')?.disable();
|
if (metadata.goodreadsRatingLocked) this.metadataForm.get('goodreadsRating')?.disable();
|
||||||
|
if (metadata.hardcoverReviewCountLocked) this.metadataForm.get('hardcoverReviewCount')?.disable();
|
||||||
|
if (metadata.hardcoverRatingLocked) this.metadataForm.get('hardcoverRating')?.disable();
|
||||||
if (metadata.pageCountLocked) this.metadataForm.get('pageCount')?.disable();
|
if (metadata.pageCountLocked) this.metadataForm.get('pageCount')?.disable();
|
||||||
if (metadata.descriptionLocked) this.metadataForm.get('description')?.disable();
|
if (metadata.descriptionLocked) this.metadataForm.get('description')?.disable();
|
||||||
if (metadata.seriesNameLocked) this.metadataForm.get('seriesName')?.disable();
|
if (metadata.seriesNameLocked) this.metadataForm.get('seriesName')?.disable();
|
||||||
@@ -234,6 +246,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value || this.copiedFields['amazonReviewCount'] ? this.getNumberOrCopied('amazonReviewCount') : null,
|
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value || this.copiedFields['amazonReviewCount'] ? this.getNumberOrCopied('amazonReviewCount') : null,
|
||||||
goodreadsRating: this.metadataForm.get('goodreadsRating')?.value || this.copiedFields['goodreadsRating'] ? this.getNumberOrCopied('goodreadsRating') : null,
|
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,
|
goodreadsReviewCount: this.metadataForm.get('goodreadsReviewCount')?.value || this.copiedFields['goodreadsReviewCount'] ? this.getNumberOrCopied('goodreadsReviewCount') : null,
|
||||||
|
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,
|
||||||
seriesName: this.metadataForm.get('seriesName')?.value || this.copiedFields['seriesName'] ? this.getValueOrCopied('seriesName') : '',
|
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,
|
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,
|
seriesTotal: this.metadataForm.get('seriesTotal')?.value || this.copiedFields['seriesTotal'] ? this.getNumberOrCopied('seriesTotal') : null,
|
||||||
@@ -255,6 +269,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
||||||
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.value,
|
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.value,
|
||||||
goodreadsReviewCountLocked: this.metadataForm.get('goodreadsReviewCountLocked')?.value,
|
goodreadsReviewCountLocked: this.metadataForm.get('goodreadsReviewCountLocked')?.value,
|
||||||
|
hardcoverRatingLocked: this.metadataForm.get('hardcoverRatingLocked')?.value,
|
||||||
|
hardcoverReviewCountLocked: this.metadataForm.get('hardcoverReviewCountLocked')?.value,
|
||||||
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
|
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
|
||||||
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
||||||
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
|
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
|
||||||
|
|||||||
+15
-9
@@ -4,7 +4,6 @@ import {Button} from 'primeng/button';
|
|||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {Divider} from 'primeng/divider';
|
import {Divider} from 'primeng/divider';
|
||||||
import {NgForOf, NgIf} from '@angular/common';
|
import {NgForOf, NgIf} from '@angular/common';
|
||||||
import {MetadataProvider} from '../../model/provider.model';
|
|
||||||
import {FetchMetadataRequest} from '../../model/request/fetch-metadata-request.model';
|
import {FetchMetadataRequest} from '../../model/request/fetch-metadata-request.model';
|
||||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||||
import {MetadataPickerComponent} from '../metadata-picker/metadata-picker.component';
|
import {MetadataPickerComponent} from '../metadata-picker/metadata-picker.component';
|
||||||
@@ -12,11 +11,11 @@ import {BookMetadataCenterService} from '../book-metadata-center.service';
|
|||||||
import {MultiSelect} from 'primeng/multiselect';
|
import {MultiSelect} from 'primeng/multiselect';
|
||||||
import {Book, BookMetadata} from '../../../model/book.model';
|
import {Book, BookMetadata} from '../../../model/book.model';
|
||||||
import {BookService} from '../../../service/book.service';
|
import {BookService} from '../../../service/book.service';
|
||||||
import {combineLatest, Observable, Subscription, Subject, takeUntil} from 'rxjs';
|
import {combineLatest, Observable, Subject, Subscription, takeUntil} from 'rxjs';
|
||||||
import {AppSettings} from '../../../../core/model/app-settings.model';
|
import {AppSettings} from '../../../../core/model/app-settings.model';
|
||||||
import {AppSettingsService} from '../../../../core/service/app-settings.service';
|
import {AppSettingsService} from '../../../../core/service/app-settings.service';
|
||||||
import {distinctUntilChanged, filter, switchMap} from 'rxjs/operators';
|
import {distinctUntilChanged, filter, switchMap} from 'rxjs/operators';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-searcher',
|
selector: 'app-metadata-searcher',
|
||||||
@@ -27,7 +26,7 @@ import {ActivatedRoute, Router} from '@angular/router';
|
|||||||
})
|
})
|
||||||
export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
providers = Object.values(MetadataProvider);
|
providers: string[] = [];
|
||||||
allFetchedMetadata: BookMetadata[] = [];
|
allFetchedMetadata: BookMetadata[] = [];
|
||||||
selectedFetchedMetadata!: BookMetadata | null;
|
selectedFetchedMetadata!: BookMetadata | null;
|
||||||
bookId!: number;
|
bookId!: number;
|
||||||
@@ -65,7 +64,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
|||||||
this.selectedFetchedMetadata = null;
|
this.selectedFetchedMetadata = null;
|
||||||
this.allFetchedMetadata = [];
|
this.allFetchedMetadata = [];
|
||||||
this.form.patchValue({
|
this.form.patchValue({
|
||||||
provider: Object.values(MetadataProvider),
|
provider: this.providers,
|
||||||
title: '',
|
title: '',
|
||||||
author: '',
|
author: '',
|
||||||
});
|
});
|
||||||
@@ -75,6 +74,13 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
|||||||
filter(([book, settings]) => !!book && !!settings),
|
filter(([book, settings]) => !!book && !!settings),
|
||||||
distinctUntilChanged(([prevBook], [currBook]) => prevBook?.id === currBook?.id)
|
distinctUntilChanged(([prevBook], [currBook]) => prevBook?.id === currBook?.id)
|
||||||
).subscribe(([book, settings]) => {
|
).subscribe(([book, settings]) => {
|
||||||
|
|
||||||
|
console.log(settings!.metadataProviderSettings)
|
||||||
|
|
||||||
|
this.providers = Object.entries(settings!.metadataProviderSettings)
|
||||||
|
.filter(([key, value]) => value.enabled)
|
||||||
|
.map(([key]) => key.charAt(0).toUpperCase() + key.slice(1));
|
||||||
|
|
||||||
const autoBookSearchEnabled = settings!.autoBookSearch ?? false;
|
const autoBookSearchEnabled = settings!.autoBookSearch ?? false;
|
||||||
|
|
||||||
if (book) {
|
if (book) {
|
||||||
@@ -83,7 +89,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
|||||||
this.bookId = book.id;
|
this.bookId = book.id;
|
||||||
|
|
||||||
this.form.patchValue({
|
this.form.patchValue({
|
||||||
provider: Object.values(MetadataProvider),
|
provider: this.providers,
|
||||||
title: book.metadata?.title || null,
|
title: book.metadata?.title || null,
|
||||||
author: book.metadata?.authors?.length ? book.metadata.authors[0] : ''
|
author: book.metadata?.authors?.length ? book.metadata.authors[0] : ''
|
||||||
});
|
});
|
||||||
@@ -111,9 +117,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
if (this.form.valid) {
|
if (this.form.valid) {
|
||||||
const providerKeys = Object.keys(MetadataProvider).filter(key =>
|
const providerKeys = this.form.get('provider')?.value;
|
||||||
(this.form.get('provider')?.value as string[]).includes(MetadataProvider[key as keyof typeof MetadataProvider])
|
|
||||||
);
|
|
||||||
if (!providerKeys) {
|
if (!providerKeys) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -155,6 +159,8 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
|||||||
return `<a href="https://www.goodreads.com/book/show/${metadata.providerBookId}" target="_blank">Goodreads</a>`;
|
return `<a href="https://www.goodreads.com/book/show/${metadata.providerBookId}" target="_blank">Goodreads</a>`;
|
||||||
case "Google":
|
case "Google":
|
||||||
return `<a href="https://books.google.com/books?id=${metadata.providerBookId}" target="_blank">Google</a>`;
|
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:
|
default:
|
||||||
throw new Error(`Unsupported provider: ${metadata.provider}`);
|
throw new Error(`Unsupported provider: ${metadata.provider}`);
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-17
@@ -41,28 +41,32 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-2 pt-2">
|
<div class="flex items-center gap-2 pt-2">
|
||||||
<ng-container *ngIf="metadata.amazonRating || metadata.goodreadsRating; else legacyRating">
|
<ng-container *ngIf="metadata.amazonRating || metadata.goodreadsRating || metadata.hardcoverRating; else legacyRating">
|
||||||
<p *ngIf="metadata.amazonRating" class="font-semibold">Amazon: {{ metadata.amazonRating }}</p>
|
<ng-container *ngIf="metadata.amazonRating">
|
||||||
<p-rating
|
<p class="font-semibold">Amazon: {{ metadata.amazonRating }}</p>
|
||||||
*ngIf="metadata.amazonRating"
|
<p-rating [ngModel]="metadata.amazonRating" readonly stars="5"
|
||||||
[(ngModel)]="metadata.amazonRating"
|
|
||||||
readonly
|
|
||||||
stars="5"
|
|
||||||
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
|
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
|
||||||
</p-rating>
|
</p-rating>
|
||||||
<p *ngIf="metadata.amazonRating" class="font-semibold"> ({{ metadata.amazonReviewCount | number:'1.0-0' }})</p>
|
<p class="font-semibold">({{ metadata.amazonReviewCount | number:'1.0-0' }})</p>
|
||||||
|
<span *ngIf="metadata.goodreadsRating || metadata.hardcoverRating">|</span>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<p *ngIf="metadata.amazonRating && metadata.goodreadsRating">|</p>
|
<ng-container *ngIf="metadata.goodreadsRating">
|
||||||
|
<p class="font-semibold">Goodreads: {{ metadata.goodreadsRating }}</p>
|
||||||
<p *ngIf="metadata.goodreadsRating" class="font-semibold">Goodreads: {{ metadata.goodreadsRating }}</p>
|
<p-rating [ngModel]="metadata.goodreadsRating" readonly stars="5"
|
||||||
<p-rating
|
|
||||||
*ngIf="metadata.goodreadsRating"
|
|
||||||
[(ngModel)]="metadata.goodreadsRating"
|
|
||||||
readonly
|
|
||||||
stars="5"
|
|
||||||
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
|
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
|
||||||
</p-rating>
|
</p-rating>
|
||||||
<p *ngIf="metadata.goodreadsRating" class="font-semibold"> ({{ metadata.goodreadsReviewCount | number:'1.0-0' }})</p>
|
<p class="font-semibold">({{ metadata.goodreadsReviewCount | number:'1.0-0' }})</p>
|
||||||
|
<span *ngIf="metadata.hardcoverRating">|</span>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngIf="metadata.hardcoverRating">
|
||||||
|
<p class="font-semibold">Hardcover: {{ metadata.hardcoverRating }}</p>
|
||||||
|
<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>
|
||||||
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-template #legacyRating>
|
<ng-template #legacyRating>
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
|||||||
|
|
||||||
@Output() metadataOptionsSubmitted: EventEmitter<MetadataRefreshOptions> = new EventEmitter<MetadataRefreshOptions>();
|
@Output() metadataOptionsSubmitted: EventEmitter<MetadataRefreshOptions> = new EventEmitter<MetadataRefreshOptions>();
|
||||||
fields: (keyof FieldOptions)[] = ['title', 'description', 'authors', 'categories', 'cover'];
|
fields: (keyof FieldOptions)[] = ['title', 'description', 'authors', 'categories', 'cover'];
|
||||||
providers: string[] = ['Amazon', 'Google', 'GoodReads'];
|
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover'];
|
||||||
refreshCovers: boolean = false;
|
refreshCovers: boolean = false;
|
||||||
mergeCategories: boolean = false;
|
mergeCategories: boolean = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
export enum MetadataProvider {
|
|
||||||
Amazon = "Amazon",
|
|
||||||
Google = "Google",
|
|
||||||
GoodReads = "GoodReads"
|
|
||||||
}
|
|
||||||
@@ -53,6 +53,8 @@ export interface BookMetadata {
|
|||||||
amazonReviewCount?: number | null;
|
amazonReviewCount?: number | null;
|
||||||
goodreadsRating?: number | null;
|
goodreadsRating?: number | null;
|
||||||
goodreadsReviewCount?: number | null;
|
goodreadsReviewCount?: number | null;
|
||||||
|
hardcoverRating?: number | null;
|
||||||
|
hardcoverReviewCount?: number | null;
|
||||||
coverUpdatedOn?: string;
|
coverUpdatedOn?: string;
|
||||||
authors: string[];
|
authors: string[];
|
||||||
categories: string[];
|
categories: string[];
|
||||||
@@ -80,6 +82,8 @@ export interface BookMetadata {
|
|||||||
amazonReviewCountLocked?: boolean;
|
amazonReviewCountLocked?: boolean;
|
||||||
goodreadsRatingLocked?: boolean;
|
goodreadsRatingLocked?: boolean;
|
||||||
goodreadsReviewCountLocked?: boolean;
|
goodreadsReviewCountLocked?: boolean;
|
||||||
|
hardcoverRatingLocked?: boolean;
|
||||||
|
hardcoverReviewCountLocked?: boolean;
|
||||||
coverUpdatedOnLocked?: boolean;
|
coverUpdatedOnLocked?: boolean;
|
||||||
authorsLocked?: boolean;
|
authorsLocked?: boolean;
|
||||||
categoriesLocked?: boolean;
|
categoriesLocked?: boolean;
|
||||||
|
|||||||
@@ -18,6 +18,30 @@ export interface OidcAutoProvisionDetails {
|
|||||||
defaultLibraryIds: number[];
|
defaultLibraryIds: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MetadataProviderSettings {
|
||||||
|
amazon: Amazon;
|
||||||
|
google: Google;
|
||||||
|
goodReads: Goodreads;
|
||||||
|
hardcover: Hardcover;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Amazon {
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Google {
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Goodreads {
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Hardcover {
|
||||||
|
enabled: boolean;
|
||||||
|
apiKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AppSettings {
|
export interface AppSettings {
|
||||||
autoBookSearch: boolean;
|
autoBookSearch: boolean;
|
||||||
similarBookRecommendation: boolean;
|
similarBookRecommendation: boolean;
|
||||||
@@ -31,6 +55,7 @@ export interface AppSettings {
|
|||||||
oidcAutoProvisionDetails: OidcAutoProvisionDetails;
|
oidcAutoProvisionDetails: OidcAutoProvisionDetails;
|
||||||
cbxCacheSizeInMb: number;
|
cbxCacheSizeInMb: number;
|
||||||
maxFileUploadSizeInMb: number;
|
maxFileUploadSizeInMb: number;
|
||||||
|
metadataProviderSettings: MetadataProviderSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AppSettingKey {
|
export enum AppSettingKey {
|
||||||
@@ -44,5 +69,6 @@ export enum AppSettingKey {
|
|||||||
OIDC_PROVIDER_DETAILS = 'OIDC_PROVIDER_DETAILS',
|
OIDC_PROVIDER_DETAILS = 'OIDC_PROVIDER_DETAILS',
|
||||||
OIDC_AUTO_PROVISION_DETAILS = 'OIDC_AUTO_PROVISION_DETAILS',
|
OIDC_AUTO_PROVISION_DETAILS = 'OIDC_AUTO_PROVISION_DETAILS',
|
||||||
CBX_CACHE_SIZE_IN_MB = 'CBX_CACHE_SIZE_IN_MB',
|
CBX_CACHE_SIZE_IN_MB = 'CBX_CACHE_SIZE_IN_MB',
|
||||||
MAX_FILE_UPLOAD_SIZE_IN_MB = 'MAX_FILE_UPLOAD_SIZE_IN_MB'
|
MAX_FILE_UPLOAD_SIZE_IN_MB = 'MAX_FILE_UPLOAD_SIZE_IN_MB',
|
||||||
|
METADATA_PROVIDER_SETTINGS = 'METADATA_PROVIDER_SETTINGS'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,14 @@
|
|||||||
<p-divider></p-divider>
|
<p-divider></p-divider>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="p-4">
|
||||||
|
<app-metadata-provider-settings></app-metadata-provider-settings>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-2 pb-4">
|
||||||
|
<p-divider></p-divider>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<app-opds-settings></app-opds-settings>
|
<app-opds-settings></app-opds-settings>
|
||||||
</div>
|
</div>
|
||||||
@@ -162,8 +170,7 @@
|
|||||||
style="cursor: pointer;">
|
style="cursor: pointer;">
|
||||||
</i>
|
</i>
|
||||||
</p>
|
</p>
|
||||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)"
|
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)" [currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
||||||
[currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {filter, take} from 'rxjs/operators';
|
|||||||
import {FileUploadPatternComponent} from './file-upload-pattern/file-upload-pattern.component';
|
import {FileUploadPatternComponent} from './file-upload-pattern/file-upload-pattern.component';
|
||||||
import {OpdsSettingsComponent} from './opds-settings/opds-settings.component';
|
import {OpdsSettingsComponent} from './opds-settings/opds-settings.component';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
|
import {MetadataProviderSettingsComponent} from './metadata-provider-settings/metadata-provider-settings.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-global-preferences',
|
selector: 'app-global-preferences',
|
||||||
@@ -34,7 +35,8 @@ import {InputText} from 'primeng/inputtext';
|
|||||||
MetadataAdvancedFetchOptionsComponent,
|
MetadataAdvancedFetchOptionsComponent,
|
||||||
FileUploadPatternComponent,
|
FileUploadPatternComponent,
|
||||||
OpdsSettingsComponent,
|
OpdsSettingsComponent,
|
||||||
InputText
|
InputText,
|
||||||
|
MetadataProviderSettingsComponent
|
||||||
],
|
],
|
||||||
templateUrl: './global-preferences.component.html',
|
templateUrl: './global-preferences.component.html',
|
||||||
styleUrl: './global-preferences.component.scss'
|
styleUrl: './global-preferences.component.scss'
|
||||||
|
|||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
<p class="text-lg flex items-center gap-2">
|
||||||
|
Enabled Metadata Providers:
|
||||||
|
<i
|
||||||
|
class="pi pi-info-circle"
|
||||||
|
pTooltip="Enable or configure third-party metadata sources for enhanced book information."
|
||||||
|
tooltipPosition="right"
|
||||||
|
style="cursor: pointer;">
|
||||||
|
</i>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-4 p-4">
|
||||||
|
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<p-checkbox [(ngModel)]="amazonEnabled" [binary]="true"></p-checkbox>
|
||||||
|
<label>Amazon</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<p-checkbox [(ngModel)]="goodreadsEnabled" [binary]="true"></p-checkbox>
|
||||||
|
<label>Goodreads</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<p-checkbox [(ngModel)]="googleEnabled" [binary]="true"></p-checkbox>
|
||||||
|
<label>Google</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<p-checkbox
|
||||||
|
[binary]="true"
|
||||||
|
[(ngModel)]="hardcoverEnabled"
|
||||||
|
[disabled]="!hardcoverToken">
|
||||||
|
</p-checkbox>
|
||||||
|
<label>Hardcover</label>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-4 pl-6">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
pInputText
|
||||||
|
placeholder="API Token"
|
||||||
|
class="w-full max-w-sm"
|
||||||
|
[(ngModel)]="hardcoverToken"
|
||||||
|
(ngModelChange)="onTokenChange($event)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-start px-4 pb-4">
|
||||||
|
<p-button label="Save" icon="pi pi-save" [outlined]="true" (click)="saveSettings()"></p-button>
|
||||||
|
</div>
|
||||||
+93
@@ -0,0 +1,93 @@
|
|||||||
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
|
import {TableModule} from 'primeng/table';
|
||||||
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
|
import {Checkbox} from 'primeng/checkbox';
|
||||||
|
import {InputText} from 'primeng/inputtext';
|
||||||
|
import {Button} from 'primeng/button';
|
||||||
|
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||||
|
import {filter, take} from 'rxjs/operators';
|
||||||
|
import {MessageService} from 'primeng/api';
|
||||||
|
import {AppSettingKey} from '../../../core/model/app-settings.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-metadata-provider-settings',
|
||||||
|
imports: [
|
||||||
|
ReactiveFormsModule,
|
||||||
|
TableModule,
|
||||||
|
Tooltip,
|
||||||
|
Checkbox,
|
||||||
|
InputText,
|
||||||
|
Button,
|
||||||
|
FormsModule
|
||||||
|
],
|
||||||
|
templateUrl: './metadata-provider-settings.component.html',
|
||||||
|
styleUrl: './metadata-provider-settings.component.scss'
|
||||||
|
})
|
||||||
|
export class MetadataProviderSettingsComponent implements OnInit {
|
||||||
|
hardcoverToken: string = '';
|
||||||
|
hardcoverEnabled: boolean = false;
|
||||||
|
amazonEnabled: boolean = false;
|
||||||
|
goodreadsEnabled: boolean = false;
|
||||||
|
googleEnabled: boolean = false;
|
||||||
|
|
||||||
|
private appSettingsService = inject(AppSettingsService);
|
||||||
|
private messageService = inject(MessageService);
|
||||||
|
|
||||||
|
private appSettings$ = this.appSettingsService.appSettings$;
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.appSettings$
|
||||||
|
.pipe(
|
||||||
|
filter(settings => settings != null),
|
||||||
|
take(1)
|
||||||
|
)
|
||||||
|
.subscribe(settings => {
|
||||||
|
const metadataProviderSettings = settings!.metadataProviderSettings;
|
||||||
|
this.amazonEnabled = metadataProviderSettings?.amazon?.enabled ?? false;
|
||||||
|
this.goodreadsEnabled = metadataProviderSettings?.goodReads?.enabled ?? false;
|
||||||
|
this.googleEnabled = metadataProviderSettings?.google?.enabled ?? false;
|
||||||
|
this.hardcoverToken = metadataProviderSettings?.hardcover?.apiKey ?? '';
|
||||||
|
this.hardcoverEnabled = metadataProviderSettings?.hardcover?.enabled ?? false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onTokenChange(newToken: string): void {
|
||||||
|
this.hardcoverToken = newToken;
|
||||||
|
if (!newToken.trim()) {
|
||||||
|
this.hardcoverEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saveSettings(): void {
|
||||||
|
const payload = [
|
||||||
|
{
|
||||||
|
key: AppSettingKey.METADATA_PROVIDER_SETTINGS,
|
||||||
|
newValue: {
|
||||||
|
amazon: {enabled: this.amazonEnabled},
|
||||||
|
goodReads: {enabled: this.goodreadsEnabled},
|
||||||
|
google: {enabled: this.googleEnabled},
|
||||||
|
hardcover: {
|
||||||
|
enabled: this.hardcoverEnabled,
|
||||||
|
apiKey: this.hardcoverToken.trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
this.appSettingsService.saveSettings(payload).subscribe({
|
||||||
|
next: () =>
|
||||||
|
this.messageService.add({
|
||||||
|
severity: 'success',
|
||||||
|
summary: 'Saved',
|
||||||
|
detail: 'Metadata provider settings saved.'
|
||||||
|
}),
|
||||||
|
error: () =>
|
||||||
|
this.messageService.add({
|
||||||
|
severity: 'error',
|
||||||
|
summary: 'Error',
|
||||||
|
detail: 'Failed to save metadata provider settings.'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<p-tab [value]="SettingsTab.ReaderSettings">Reader Preferences</p-tab>
|
<p-tab [value]="SettingsTab.ReaderSettings">Reader Preferences</p-tab>
|
||||||
<p-tab [value]="SettingsTab.ViewPreferences">View Preferences</p-tab>
|
<p-tab [value]="SettingsTab.ViewPreferences">View Preferences</p-tab>
|
||||||
<ng-container *ngIf="userData.permissions.admin">
|
<ng-container *ngIf="userData.permissions.admin">
|
||||||
<p-tab [value]="SettingsTab.GlobalSettings">Global Settings</p-tab>
|
<p-tab [value]="SettingsTab.AdminSettings">Admin Settings</p-tab>
|
||||||
<p-tab [value]="SettingsTab.UserManagement">User Management</p-tab>
|
<p-tab [value]="SettingsTab.UserManagement">User Management</p-tab>
|
||||||
<p-tab [value]="SettingsTab.EmailSettings">Email Setting</p-tab>
|
<p-tab [value]="SettingsTab.EmailSettings">Email Setting</p-tab>
|
||||||
<p-tab [value]="SettingsTab.AuthenticationSettings">Authentication Settings</p-tab>
|
<p-tab [value]="SettingsTab.AuthenticationSettings">Authentication Settings</p-tab>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<app-view-preferences-parent></app-view-preferences-parent>
|
<app-view-preferences-parent></app-view-preferences-parent>
|
||||||
</p-tabpanel>
|
</p-tabpanel>
|
||||||
<ng-container *ngIf="userData.permissions.admin">
|
<ng-container *ngIf="userData.permissions.admin">
|
||||||
<p-tabpanel [value]="SettingsTab.GlobalSettings">
|
<p-tabpanel [value]="SettingsTab.AdminSettings">
|
||||||
<app-global-preferences></app-global-preferences>
|
<app-global-preferences></app-global-preferences>
|
||||||
</p-tabpanel>
|
</p-tabpanel>
|
||||||
<p-tabpanel [value]="SettingsTab.UserManagement">
|
<p-tabpanel [value]="SettingsTab.UserManagement">
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export enum SettingsTab {
|
|||||||
ViewPreferences = 'view-settings',
|
ViewPreferences = 'view-settings',
|
||||||
UserManagement = 'user-management',
|
UserManagement = 'user-management',
|
||||||
EmailSettings = 'email-settings',
|
EmailSettings = 'email-settings',
|
||||||
GlobalSettings = 'global-settings',
|
AdminSettings = 'admin-settings',
|
||||||
AuthenticationSettings = 'auth-settings'
|
AuthenticationSettings = 'auth-settings'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user