Merge pull request #392 from adityachandelgit/develop
Merge Develop into Master for Release v0.13.0
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+15
-2
@@ -45,13 +45,15 @@ public class BookCreatorService {
|
|||||||
|
|
||||||
public void addCategoriesToBook(List<String> categories, BookEntity bookEntity) {
|
public void addCategoriesToBook(List<String> categories, BookEntity bookEntity) {
|
||||||
for (String category : categories) {
|
for (String category : categories) {
|
||||||
Optional<CategoryEntity> catOpt = categoryRepository.findByName(category);
|
// Truncate category name to fit in VARCHAR(255)
|
||||||
|
String truncatedCategory = truncate(category, 255);
|
||||||
|
Optional<CategoryEntity> catOpt = categoryRepository.findByName(truncatedCategory);
|
||||||
CategoryEntity categoryEntity;
|
CategoryEntity categoryEntity;
|
||||||
if (catOpt.isPresent()) {
|
if (catOpt.isPresent()) {
|
||||||
categoryEntity = catOpt.get();
|
categoryEntity = catOpt.get();
|
||||||
} else {
|
} else {
|
||||||
categoryEntity = CategoryEntity.builder()
|
categoryEntity = CategoryEntity.builder()
|
||||||
.name(category)
|
.name(truncatedCategory)
|
||||||
.build();
|
.build();
|
||||||
categoryEntity = categoryRepository.save(categoryEntity);
|
categoryEntity = categoryRepository.save(categoryEntity);
|
||||||
}
|
}
|
||||||
@@ -80,6 +82,17 @@ public class BookCreatorService {
|
|||||||
bookEntity.getMetadata().getAuthors().add(authorEntity);
|
bookEntity.getMetadata().getAuthors().add(authorEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Truncates a string to the specified maximum length
|
||||||
|
* @param input The input string
|
||||||
|
* @param maxLength The maximum length
|
||||||
|
* @return The truncated string, or null if input is null
|
||||||
|
*/
|
||||||
|
private String truncate(String input, int maxLength) {
|
||||||
|
if (input == null) return null;
|
||||||
|
return input.length() <= maxLength ? input : input.substring(0, maxLength);
|
||||||
|
}
|
||||||
|
|
||||||
public void saveConnections(BookEntity bookEntity) {
|
public void saveConnections(BookEntity bookEntity) {
|
||||||
if (bookEntity.getMetadata().getAuthors() != null && !bookEntity.getMetadata().getAuthors().isEmpty()) {
|
if (bookEntity.getMetadata().getAuthors() != null && !bookEntity.getMetadata().getAuthors().isEmpty()) {
|
||||||
|
|||||||
+23
-8
@@ -203,9 +203,12 @@ public class BookMetadataService {
|
|||||||
metadataCombined.setAsin(metadata.getAsin() != null ? metadata.getAsin() : metadataCombined.getAsin());
|
metadataCombined.setAsin(metadata.getAsin() != null ? metadata.getAsin() : metadataCombined.getAsin());
|
||||||
metadataCombined.setPageCount(metadata.getPageCount() != null ? metadata.getPageCount() : metadataCombined.getPageCount());
|
metadataCombined.setPageCount(metadata.getPageCount() != null ? metadata.getPageCount() : metadataCombined.getPageCount());
|
||||||
metadataCombined.setLanguage(metadata.getLanguage() != null ? metadata.getLanguage() : metadataCombined.getLanguage());
|
metadataCombined.setLanguage(metadata.getLanguage() != null ? metadata.getLanguage() : metadataCombined.getLanguage());
|
||||||
metadataCombined.setRating(metadata.getRating() != null ? metadata.getRating() : metadataCombined.getRating());
|
metadataCombined.setGoodreadsRating(metadata.getGoodreadsRating() != null ? metadata.getGoodreadsRating() : metadataCombined.getGoodreadsRating());
|
||||||
metadataCombined.setRatingCount(metadata.getRatingCount() != null ? metadata.getRatingCount() : metadataCombined.getRatingCount());
|
metadataCombined.setGoodreadsReviewCount(metadata.getGoodreadsReviewCount() != null ? metadata.getGoodreadsReviewCount() : metadataCombined.getGoodreadsReviewCount());
|
||||||
metadataCombined.setReviewCount(metadata.getReviewCount() != null ? metadata.getReviewCount() : metadataCombined.getReviewCount());
|
metadataCombined.setAmazonRating(metadata.getAmazonRating() != null ? metadata.getAmazonRating() : metadataCombined.getAmazonRating());
|
||||||
|
metadataCombined.setAmazonReviewCount(metadata.getAmazonReviewCount() != null ? metadata.getAmazonReviewCount() : metadataCombined.getAmazonReviewCount());
|
||||||
|
metadataCombined.setHardcoverRating(metadata.getHardcoverRating() != null ? metadata.getHardcoverRating() : metadataCombined.getHardcoverRating());
|
||||||
|
metadataCombined.setHardcoverReviewCount(metadata.getHardcoverReviewCount() != null ? metadata.getHardcoverReviewCount() : metadataCombined.getHardcoverReviewCount());
|
||||||
metadataCombined.setAwards(metadata.getAwards() != null ? metadata.getAwards() : metadataCombined.getAwards());
|
metadataCombined.setAwards(metadata.getAwards() != null ? metadata.getAwards() : metadataCombined.getAwards());
|
||||||
metadataCombined.setSeriesName(metadata.getSeriesName() != null ? metadata.getSeriesName() : metadataCombined.getSeriesName());
|
metadataCombined.setSeriesName(metadata.getSeriesName() != null ? metadata.getSeriesName() : metadataCombined.getSeriesName());
|
||||||
metadataCombined.setSeriesNumber(metadata.getSeriesNumber() != null ? metadata.getSeriesNumber() : metadataCombined.getSeriesNumber());
|
metadataCombined.setSeriesNumber(metadata.getSeriesNumber() != null ? metadata.getSeriesNumber() : metadataCombined.getSeriesNumber());
|
||||||
@@ -389,11 +392,23 @@ public class BookMetadataService {
|
|||||||
case "language":
|
case "language":
|
||||||
existingMetadata.setLanguageLocked(isLocked);
|
existingMetadata.setLanguageLocked(isLocked);
|
||||||
break;
|
break;
|
||||||
case "rating":
|
case "amazonRating":
|
||||||
existingMetadata.setRatingLocked(isLocked);
|
existingMetadata.setAmazonRatingLocked(isLocked);
|
||||||
break;
|
break;
|
||||||
case "reviewCount":
|
case "amazonReviewCount":
|
||||||
existingMetadata.setReviewCountLocked(isLocked);
|
existingMetadata.setAmazonReviewCountLocked(isLocked);
|
||||||
|
break;
|
||||||
|
case "goodreadsRating":
|
||||||
|
existingMetadata.setGoodreadsRatingLocked(isLocked);
|
||||||
|
break;
|
||||||
|
case "goodreadsReviewCount":
|
||||||
|
existingMetadata.setGoodreadsReviewCountLocked(isLocked);
|
||||||
|
break;
|
||||||
|
case "hardcoverRating":
|
||||||
|
existingMetadata.setHardcoverRatingLocked(isLocked);
|
||||||
|
break;
|
||||||
|
case "hardcoverReviewCount":
|
||||||
|
existingMetadata.setHardcoverReviewCountLocked(isLocked);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid field name: " + field);
|
throw new IllegalArgumentException("Invalid field name: " + field);
|
||||||
@@ -460,6 +475,6 @@ public class BookMetadataService {
|
|||||||
.peek(book -> book.getMetadata().applyLockToAllFields(lock))
|
.peek(book -> book.getMetadata().applyLockToAllFields(lock))
|
||||||
.toList();
|
.toList();
|
||||||
bookRepository.saveAll(books);
|
bookRepository.saveAll(books);
|
||||||
return books.stream().map(b ->bookMetadataMapper.toBookMetadata(b.getMetadata(), false)).collect(Collectors.toList());
|
return books.stream().map(b -> bookMetadataMapper.toBookMetadata(b.getMetadata(), false)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-15
@@ -47,27 +47,21 @@ public class BookMetadataUpdater {
|
|||||||
if ((metadata.getTitleLocked() == null || !metadata.getTitleLocked()) && newMetadata.getTitle() != null) {
|
if ((metadata.getTitleLocked() == null || !metadata.getTitleLocked()) && newMetadata.getTitle() != null) {
|
||||||
metadata.setTitle(newMetadata.getTitle().isEmpty() ? null : newMetadata.getTitle());
|
metadata.setTitle(newMetadata.getTitle().isEmpty() ? null : newMetadata.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getSubtitleLocked() == null || !metadata.getSubtitleLocked()) && newMetadata.getSubtitle() != null) {
|
if ((metadata.getSubtitleLocked() == null || !metadata.getSubtitleLocked()) && newMetadata.getSubtitle() != null) {
|
||||||
metadata.setSubtitle(newMetadata.getSubtitle().isBlank() ? null : newMetadata.getSubtitle());
|
metadata.setSubtitle(newMetadata.getSubtitle().isBlank() ? null : newMetadata.getSubtitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getPublisherLocked() == null || !metadata.getPublisherLocked()) && newMetadata.getPublisher() != null) {
|
if ((metadata.getPublisherLocked() == null || !metadata.getPublisherLocked()) && newMetadata.getPublisher() != null) {
|
||||||
metadata.setPublisher(newMetadata.getPublisher().isBlank() ? null : newMetadata.getPublisher());
|
metadata.setPublisher(newMetadata.getPublisher().isBlank() ? null : newMetadata.getPublisher());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getPublishedDateLocked() == null || !metadata.getPublishedDateLocked()) && newMetadata.getPublishedDate() != null) {
|
if ((metadata.getPublishedDateLocked() == null || !metadata.getPublishedDateLocked()) && newMetadata.getPublishedDate() != null) {
|
||||||
metadata.setPublishedDate(newMetadata.getPublishedDate());
|
metadata.setPublishedDate(newMetadata.getPublishedDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getLanguageLocked() == null || !metadata.getLanguageLocked()) && newMetadata.getLanguage() != null) {
|
if ((metadata.getLanguageLocked() == null || !metadata.getLanguageLocked()) && newMetadata.getLanguage() != null) {
|
||||||
metadata.setLanguage(newMetadata.getLanguage().isBlank() ? null : newMetadata.getLanguage());
|
metadata.setLanguage(newMetadata.getLanguage().isBlank() ? null : newMetadata.getLanguage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getIsbn10Locked() == null || !metadata.getIsbn10Locked()) && newMetadata.getIsbn10() != null) {
|
if ((metadata.getIsbn10Locked() == null || !metadata.getIsbn10Locked()) && newMetadata.getIsbn10() != null) {
|
||||||
metadata.setIsbn10(newMetadata.getIsbn10().isBlank() ? null : newMetadata.getIsbn10());
|
metadata.setIsbn10(newMetadata.getIsbn10().isBlank() ? null : newMetadata.getIsbn10());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getIsbn13Locked() == null || !metadata.getIsbn13Locked()) && newMetadata.getIsbn13() != null) {
|
if ((metadata.getIsbn13Locked() == null || !metadata.getIsbn13Locked()) && newMetadata.getIsbn13() != null) {
|
||||||
metadata.setIsbn13(newMetadata.getIsbn13().isBlank() ? null : newMetadata.getIsbn13());
|
metadata.setIsbn13(newMetadata.getIsbn13().isBlank() ? null : newMetadata.getIsbn13());
|
||||||
}
|
}
|
||||||
@@ -77,39 +71,36 @@ public class BookMetadataUpdater {
|
|||||||
if ((metadata.getDescriptionLocked() == null || !metadata.getDescriptionLocked()) && newMetadata.getDescription() != null) {
|
if ((metadata.getDescriptionLocked() == null || !metadata.getDescriptionLocked()) && newMetadata.getDescription() != null) {
|
||||||
metadata.setDescription(newMetadata.getDescription().isBlank() ? null : newMetadata.getDescription());
|
metadata.setDescription(newMetadata.getDescription().isBlank() ? null : newMetadata.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getPageCountLocked() == null || !metadata.getPageCountLocked()) && newMetadata.getPageCount() != null) {
|
if ((metadata.getPageCountLocked() == null || !metadata.getPageCountLocked()) && newMetadata.getPageCount() != null) {
|
||||||
metadata.setPageCount(newMetadata.getPageCount());
|
metadata.setPageCount(newMetadata.getPageCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getAmazonRatingLocked() == null || !metadata.getAmazonRatingLocked()) && newMetadata.getAmazonRating() != null) {
|
if ((metadata.getAmazonRatingLocked() == null || !metadata.getAmazonRatingLocked()) && newMetadata.getAmazonRating() != null) {
|
||||||
metadata.setAmazonRating(newMetadata.getAmazonRating());
|
metadata.setAmazonRating(newMetadata.getAmazonRating());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getAmazonReviewCountLocked() == null || !metadata.getAmazonReviewCountLocked()) && newMetadata.getAmazonReviewCount() != null) {
|
if ((metadata.getAmazonReviewCountLocked() == null || !metadata.getAmazonReviewCountLocked()) && newMetadata.getAmazonReviewCount() != null) {
|
||||||
metadata.setAmazonReviewCount(newMetadata.getAmazonReviewCount());
|
metadata.setAmazonReviewCount(newMetadata.getAmazonReviewCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getGoodreadsRatingLocked() == null || !metadata.getGoodreadsRatingLocked()) && newMetadata.getGoodreadsRating() != null) {
|
if ((metadata.getGoodreadsRatingLocked() == null || !metadata.getGoodreadsRatingLocked()) && newMetadata.getGoodreadsRating() != null) {
|
||||||
metadata.setGoodreadsRating(newMetadata.getGoodreadsRating());
|
metadata.setGoodreadsRating(newMetadata.getGoodreadsRating());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getGoodreadsReviewCountLocked() == null || !metadata.getGoodreadsReviewCountLocked()) && newMetadata.getGoodreadsReviewCount() != null) {
|
if ((metadata.getGoodreadsReviewCountLocked() == null || !metadata.getGoodreadsReviewCountLocked()) && newMetadata.getGoodreadsReviewCount() != null) {
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getSeriesNumberLocked() == null || !metadata.getSeriesNumberLocked()) && newMetadata.getSeriesNumber() != null) {
|
if ((metadata.getSeriesNumberLocked() == null || !metadata.getSeriesNumberLocked()) && newMetadata.getSeriesNumber() != null) {
|
||||||
metadata.setSeriesNumber(newMetadata.getSeriesNumber());
|
metadata.setSeriesNumber(newMetadata.getSeriesNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((metadata.getSeriesTotalLocked() == null || !metadata.getSeriesTotalLocked()) && newMetadata.getSeriesTotal() != null) {
|
if ((metadata.getSeriesTotalLocked() == null || !metadata.getSeriesTotalLocked()) && newMetadata.getSeriesTotal() != null) {
|
||||||
metadata.setSeriesTotal(newMetadata.getSeriesTotal());
|
metadata.setSeriesTotal(newMetadata.getSeriesTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newMetadata.getAwards() != null && !newMetadata.getAwards().isEmpty()) {
|
if (newMetadata.getAwards() != null && !newMetadata.getAwards().isEmpty()) {
|
||||||
HashSet<BookAwardEntity> newAwards = new HashSet<>();
|
HashSet<BookAwardEntity> newAwards = new HashSet<>();
|
||||||
newMetadata.getAwards()
|
newMetadata.getAwards()
|
||||||
@@ -239,6 +230,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());
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-1
@@ -10,6 +10,7 @@ import java.time.Instant;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -227,7 +228,40 @@ public class EpubProcessor implements FileProcessor {
|
|||||||
extractFromOpf(FileUtils.getBookFullPath(bookEntity), bookMetadata);
|
extractFromOpf(FileUtils.getBookFullPath(bookEntity), bookMetadata);
|
||||||
|
|
||||||
bookCreatorService.addAuthorsToBook(getAuthors(book), bookEntity);
|
bookCreatorService.addAuthorsToBook(getAuthors(book), bookEntity);
|
||||||
bookCreatorService.addCategoriesToBook(epubMetadata.getSubjects(), bookEntity);
|
|
||||||
|
// Get subjects and filter out invalid ones
|
||||||
|
List<String> subjects = epubMetadata.getSubjects();
|
||||||
|
List<String> validSubjects = new ArrayList<>();
|
||||||
|
|
||||||
|
if (subjects != null && !subjects.isEmpty()) {
|
||||||
|
for (String subject : subjects) {
|
||||||
|
// Skip null or empty subjects
|
||||||
|
if (subject == null || subject.trim().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip subjects that are too long (likely not real categories)
|
||||||
|
// Real categories are typically short, descriptive terms
|
||||||
|
if (subject.length() > 100) {
|
||||||
|
log.warn("Skipping suspiciously long subject in {}: length={}, value='{}'",
|
||||||
|
bookEntity.getFileName(), subject.length(),
|
||||||
|
subject.substring(0, Math.min(50, subject.length())) + "...");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip subjects that contain newlines or excessive whitespace (likely descriptions)
|
||||||
|
if (subject.contains("\n") || subject.contains("\r") || subject.contains(" ")) {
|
||||||
|
log.warn("Skipping subject with newlines/whitespace in {}: '{}'",
|
||||||
|
bookEntity.getFileName(),
|
||||||
|
subject.substring(0, Math.min(50, subject.length())) + "...");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
validSubjects.add(subject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bookCreatorService.addCategoriesToBook(validSubjects, bookEntity);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error loading epub file {}, error: {}", bookEntity.getFileName(), e.getMessage());
|
log.error("Error loading epub file {}, error: {}", bookEntity.getFileName(), e.getMessage());
|
||||||
|
|||||||
+4
-4
@@ -293,7 +293,7 @@ public class AmazonBookParser implements BookParser {
|
|||||||
if (seriesNameElement != null) {
|
if (seriesNameElement != null) {
|
||||||
return seriesNameElement.text();
|
return seriesNameElement.text();
|
||||||
} else {
|
} else {
|
||||||
log.warn("Failed to parse seriesName: Element not found.");
|
log.debug("Failed to parse seriesName: Element not found.");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to parse seriesName: {}", e.getMessage());
|
log.warn("Failed to parse seriesName: {}", e.getMessage());
|
||||||
@@ -311,7 +311,7 @@ public class AmazonBookParser implements BookParser {
|
|||||||
return Float.parseFloat(parts[1]);
|
return Float.parseFloat(parts[1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("Failed to parse seriesNumber: Element not found.");
|
log.debug("Failed to parse seriesNumber: Element not found.");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to parse seriesNumber: {}", e.getMessage());
|
log.warn("Failed to parse seriesNumber: {}", e.getMessage());
|
||||||
@@ -329,7 +329,7 @@ public class AmazonBookParser implements BookParser {
|
|||||||
return Integer.parseInt(parts[3]);
|
return Integer.parseInt(parts[3]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("Failed to parse seriesTotal: Element not found.");
|
log.debug("Failed to parse seriesTotal: Element not found.");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to parse seriesTotal: {}", e.getMessage());
|
log.warn("Failed to parse seriesTotal: {}", e.getMessage());
|
||||||
@@ -343,7 +343,7 @@ public class AmazonBookParser implements BookParser {
|
|||||||
if (languageElement != null) {
|
if (languageElement != null) {
|
||||||
return languageElement.text();
|
return languageElement.text();
|
||||||
}
|
}
|
||||||
log.warn("Failed to parse language: Element not found.");
|
log.debug("Failed to parse language: Element not found.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to parse language: {}", e.getMessage());
|
log.warn("Failed to parse language: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
+85
@@ -0,0 +1,85 @@
|
|||||||
|
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) {
|
||||||
|
log.info("Hardcover: Fetching metadata for book {}", fetchMetadataRequest.getTitle());
|
||||||
|
|
||||||
|
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.isEmpty() ? null : 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+76
@@ -0,0 +1,76 @@
|
|||||||
|
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 org.springframework.web.client.RestClientException;
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
try {
|
||||||
|
GraphQLResponse response = restClient.post()
|
||||||
|
.uri("")
|
||||||
|
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
.header(HttpHeaders.AUTHORIZATION, "Bearer " + apiToken)
|
||||||
|
.body(body)
|
||||||
|
.retrieve()
|
||||||
|
.body(GraphQLResponse.class);
|
||||||
|
|
||||||
|
if (response == null || response.getData() == null || response.getData().getSearch() == null || response.getData().getSearch().getResults() == null) {
|
||||||
|
log.warn("Empty or malformed response from Hardcover API");
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.getData().getSearch().getResults().getHits();
|
||||||
|
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
log.error("Failed to fetch data from Hardcover API, Error: {}", e.getMessage());
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -55,7 +55,6 @@ export function initializeAuthFactory() {
|
|||||||
} else if (settings.remoteAuthEnabled) {
|
} else if (settings.remoteAuthEnabled) {
|
||||||
authService.remoteLogin().subscribe({
|
authService.remoteLogin().subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
router.navigate(['/dashboard']);
|
|
||||||
resolve();
|
resolve();
|
||||||
},
|
},
|
||||||
error: resolve
|
error: resolve
|
||||||
|
|||||||
@@ -457,9 +457,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
bookIds: this.selectedBooks
|
bookIds: this.selectedBooks
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.dynamicDialogRef.onClose.subscribe(() => {
|
|
||||||
this.selectedBooks.clear();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMetadata() {
|
updateMetadata() {
|
||||||
|
|||||||
+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}`);
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-21
@@ -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"
|
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
|
||||||
readonly
|
</p-rating>
|
||||||
stars="5"
|
<p class="font-semibold">({{ metadata.amazonReviewCount | number:'1.0-0' }})</p>
|
||||||
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
|
<span *ngIf="metadata.goodreadsRating || metadata.hardcoverRating">|</span>
|
||||||
</p-rating>
|
</ng-container>
|
||||||
<p *ngIf="metadata.amazonRating" class="font-semibold"> ({{ metadata.amazonReviewCount | number:'1.0-0' }})</p>
|
|
||||||
|
|
||||||
<p *ngIf="metadata.amazonRating && metadata.goodreadsRating">|</p>
|
<ng-container *ngIf="metadata.goodreadsRating">
|
||||||
|
<p class="font-semibold">Goodreads: {{ metadata.goodreadsRating }}</p>
|
||||||
|
<p-rating [ngModel]="metadata.goodreadsRating" readonly stars="5"
|
||||||
|
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
|
||||||
|
</p-rating>
|
||||||
|
<p class="font-semibold">({{ metadata.goodreadsReviewCount | number:'1.0-0' }})</p>
|
||||||
|
<span *ngIf="metadata.hardcoverRating">|</span>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<p *ngIf="metadata.goodreadsRating" class="font-semibold">Goodreads: {{ metadata.goodreadsRating }}</p>
|
<ng-container *ngIf="metadata.hardcoverRating">
|
||||||
<p-rating
|
<p class="font-semibold">Hardcover: {{ metadata.hardcoverRating }}</p>
|
||||||
*ngIf="metadata.goodreadsRating"
|
<p-rating [ngModel]="metadata.hardcoverRating" readonly stars="5"
|
||||||
[(ngModel)]="metadata.goodreadsRating"
|
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
|
||||||
readonly
|
</p-rating>
|
||||||
stars="5"
|
<p class="font-semibold">({{ metadata.hardcoverReviewCount | number:'1.0-0' }})</p>
|
||||||
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
|
</ng-container>
|
||||||
</p-rating>
|
|
||||||
<p *ngIf="metadata.goodreadsRating" class="font-semibold"> ({{ metadata.goodreadsReviewCount | number:'1.0-0' }})</p>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-template #legacyRating>
|
<ng-template #legacyRating>
|
||||||
@@ -129,8 +133,10 @@
|
|||||||
<p-button label="Assign Shelf" icon="pi pi-folder" severity="info" outlined (onClick)="assignShelf(metadata.bookId)"></p-button>
|
<p-button label="Assign Shelf" icon="pi pi-folder" severity="info" outlined (onClick)="assignShelf(metadata.bookId)"></p-button>
|
||||||
<p-button *ngIf="userData.permissions.canDownload || userData.permissions.admin" label="Download" icon="pi pi-download" severity="info" outlined
|
<p-button *ngIf="userData.permissions.canDownload || userData.permissions.admin" label="Download" icon="pi pi-download" severity="info" outlined
|
||||||
(onClick)="download(metadata.bookId)"></p-button>
|
(onClick)="download(metadata.bookId)"></p-button>
|
||||||
<p-splitbutton *ngIf="userData.permissions.canEmailBook || userData.permissions.admin" label="Quick Send" icon="pi pi-send" [model]="items"
|
<p-splitbutton *ngIf="userData.permissions.canEmailBook || userData.permissions.admin" label="Quick Send" icon="pi pi-send" [model]="emailMenuItems"
|
||||||
(onClick)="quickSend(metadata.bookId)" outlined severity="info"/>
|
(onClick)="quickSend(metadata.bookId)" outlined severity="info"/>
|
||||||
|
<p-splitbutton *ngIf="userData.permissions.canEditMetadata || userData.permissions.admin" label="Quick Refresh" icon="pi pi-bolt" [model]="refreshMenuItems"
|
||||||
|
(onClick)="quickRefresh(metadata.bookId)" outlined severity="info"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+48
-11
@@ -24,6 +24,9 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
|||||||
import {Editor} from 'primeng/editor';
|
import {Editor} from 'primeng/editor';
|
||||||
import {ProgressBar} from 'primeng/progressbar';
|
import {ProgressBar} from 'primeng/progressbar';
|
||||||
import {ToggleButton} from 'primeng/togglebutton';
|
import {ToggleButton} from 'primeng/togglebutton';
|
||||||
|
import {MetadataFetchOptionsComponent} from '../../metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||||
|
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
||||||
|
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-viewer',
|
selector: 'app-metadata-viewer',
|
||||||
@@ -50,13 +53,14 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
private destroyRef = inject(DestroyRef);
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
metadata$: Observable<BookMetadata | null> = this.metadataCenterService.currentMetadata$;
|
metadata$: Observable<BookMetadata | null> = this.metadataCenterService.currentMetadata$;
|
||||||
items: MenuItem[] | undefined;
|
emailMenuItems: MenuItem[] | undefined;
|
||||||
|
refreshMenuItems: MenuItem[] | undefined;
|
||||||
bookInSeries: Book[] = [];
|
bookInSeries: Book[] = [];
|
||||||
isExpanded = false;
|
isExpanded = false;
|
||||||
showFilePath = false;
|
showFilePath = false;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.items = [
|
this.emailMenuItems = [
|
||||||
{
|
{
|
||||||
label: 'Custom Send',
|
label: 'Custom Send',
|
||||||
command: () => {
|
command: () => {
|
||||||
@@ -80,6 +84,24 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
this.refreshMenuItems = [
|
||||||
|
{
|
||||||
|
label: 'Granular Refresh',
|
||||||
|
icon: 'pi pi-database',
|
||||||
|
command: () => {
|
||||||
|
this.dialogService.open(MetadataFetchOptionsComponent, {
|
||||||
|
header: 'Metadata Refresh Options',
|
||||||
|
modal: true,
|
||||||
|
closable: true,
|
||||||
|
data: {
|
||||||
|
bookIds: [this.book!.id],
|
||||||
|
metadataRefreshType: MetadataRefreshType.BOOKS,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
this.metadata$
|
this.metadata$
|
||||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
.subscribe((metadata) => {
|
.subscribe((metadata) => {
|
||||||
@@ -134,6 +156,15 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
this.bookService.downloadFile(bookId);
|
this.bookService.downloadFile(bookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quickRefresh(bookId: number) {
|
||||||
|
const metadataRefreshRequest: MetadataRefreshRequest = {
|
||||||
|
quick: true,
|
||||||
|
refreshType: MetadataRefreshType.BOOKS,
|
||||||
|
bookIds: [bookId],
|
||||||
|
};
|
||||||
|
this.bookService.autoRefreshMetadata(metadataRefreshRequest).subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
quickSend(bookId: number) {
|
quickSend(bookId: number) {
|
||||||
this.emailService.emailBookQuick(bookId).subscribe({
|
this.emailService.emailBookQuick(bookId).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
@@ -191,7 +222,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
getProgressPercent(): number | undefined {
|
getProgressPercent(): number | undefined {
|
||||||
if (this.book?.bookType === 'PDF') {
|
if (this.book?.bookType === 'PDF') {
|
||||||
return this.book.pdfProgress?.percentage;
|
return this.book.pdfProgress?.percentage;
|
||||||
} else if(this.book?.bookType === 'CBX') {
|
} else if (this.book?.bookType === 'CBX') {
|
||||||
return this.book?.cbxProgress?.percentage;
|
return this.book?.cbxProgress?.percentage;
|
||||||
} else {
|
} else {
|
||||||
return this.book?.epubProgress?.percentage;
|
return this.book?.epubProgress?.percentage;
|
||||||
@@ -201,9 +232,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
copyFilePath() {
|
copyFilePath() {
|
||||||
if (this.book?.filePath) {
|
if (this.book?.filePath) {
|
||||||
navigator.clipboard.writeText(this.book.filePath).then(() => {
|
navigator.clipboard.writeText(this.book.filePath).then(() => {
|
||||||
this.messageService.add({ severity: 'success', summary: 'Copied', detail: 'File path copied to clipboard.' });
|
this.messageService.add({severity: 'success', summary: 'Copied', detail: 'File path copied to clipboard.'});
|
||||||
}, () => {
|
}, () => {
|
||||||
this.messageService.add({ severity: 'error', summary: 'Error', detail: 'Failed to copy file path.' });
|
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to copy file path.'});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,12 +250,18 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
if (!fileType) return 'bg-gray-500 text-white';
|
if (!fileType) return 'bg-gray-500 text-white';
|
||||||
|
|
||||||
switch (fileType.toLowerCase()) {
|
switch (fileType.toLowerCase()) {
|
||||||
case 'pdf': return 'bg-red-700 text-white';
|
case 'pdf':
|
||||||
case 'epub': return 'bg-yellow-600 text-gray-900';
|
return 'bg-red-700 text-white';
|
||||||
case 'cbz': return 'bg-green-700 text-white';
|
case 'epub':
|
||||||
case 'cbr': return 'bg-purple-700 text-white';
|
return 'bg-yellow-600 text-gray-900';
|
||||||
case 'cb7': return 'bg-blue-700 text-white';
|
case 'cbz':
|
||||||
default: return 'bg-gray-600 text-white';
|
return 'bg-green-700 text-white';
|
||||||
|
case 'cbr':
|
||||||
|
return 'bg-purple-700 text-white';
|
||||||
|
case 'cb7':
|
||||||
|
return 'bg-blue-700 text-white';
|
||||||
|
default:
|
||||||
|
return 'bg-gray-600 text-white';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -72,7 +72,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-6">
|
<div class="flex flex-row gap-6">
|
||||||
<p-button severity="warn" outlined="true" label="Reset" (onClick)="reset()"></p-button>
|
<p-button severity="warn" outlined="true" label="Reset" (onClick)="reset()"></p-button>
|
||||||
<p-button label="Save" outlined="true" (onClick)="submit()"></p-button>
|
<p-button [label]="submitButtonLabel" outlined="true" (onClick)="submit()"></p-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
+2
-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;
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
|||||||
|
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
@Input() currentMetadataOptions!: MetadataRefreshOptions;
|
@Input() currentMetadataOptions!: MetadataRefreshOptions;
|
||||||
|
@Input() submitButtonLabel!: string;
|
||||||
|
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
|||||||
+5
-3
@@ -1,5 +1,7 @@
|
|||||||
<div class="flex flex-col space-y-6">
|
<div class="flex flex-col space-y-6">
|
||||||
|
<app-metadata-advanced-fetch-options
|
||||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)"></app-metadata-advanced-fetch-options>
|
(metadataOptionsSubmitted)="onMetadataSubmit($event)"
|
||||||
|
[currentMetadataOptions]="currentMetadataOptions"
|
||||||
|
[submitButtonLabel]="'Start Refresh'">
|
||||||
|
</app-metadata-advanced-fetch-options>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+11
-1
@@ -1,10 +1,12 @@
|
|||||||
import {Component, inject} from '@angular/core';
|
import {Component, inject, Input} from '@angular/core';
|
||||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
import {MetadataAdvancedFetchOptionsComponent} from '../metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
|
import {MetadataAdvancedFetchOptionsComponent} from '../metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
|
||||||
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
|
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
|
||||||
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
||||||
import {MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
|
import {MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
|
||||||
import {BookService} from '../../../service/book.service';
|
import {BookService} from '../../../service/book.service';
|
||||||
|
import {AppSettingsService} from '../../../../core/service/app-settings.service';
|
||||||
|
import {filter, take} from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-fetch-options',
|
selector: 'app-metadata-fetch-options',
|
||||||
@@ -19,15 +21,23 @@ export class MetadataFetchOptionsComponent {
|
|||||||
libraryId!: number;
|
libraryId!: number;
|
||||||
bookIds!: number[];
|
bookIds!: number[];
|
||||||
metadataRefreshType!: MetadataRefreshType;
|
metadataRefreshType!: MetadataRefreshType;
|
||||||
|
currentMetadataOptions!: MetadataRefreshOptions;
|
||||||
|
|
||||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||||
private bookService = inject(BookService);
|
private bookService = inject(BookService);
|
||||||
|
private appSettingsService = inject(AppSettingsService);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.libraryId = this.dynamicDialogConfig.data.libraryId;
|
this.libraryId = this.dynamicDialogConfig.data.libraryId;
|
||||||
this.bookIds = this.dynamicDialogConfig.data.bookIds;
|
this.bookIds = this.dynamicDialogConfig.data.bookIds;
|
||||||
this.metadataRefreshType = this.dynamicDialogConfig.data.metadataRefreshType;
|
this.metadataRefreshType = this.dynamicDialogConfig.data.metadataRefreshType;
|
||||||
|
this.appSettingsService.appSettings$.pipe(
|
||||||
|
filter(settings => settings != null),
|
||||||
|
take(1)
|
||||||
|
).subscribe(settings => {
|
||||||
|
this.currentMetadataOptions = settings?.metadataRefreshOptions;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onMetadataSubmit(metadataRefreshOptions: MetadataRefreshOptions) {
|
onMetadataSubmit(metadataRefreshOptions: MetadataRefreshOptions) {
|
||||||
|
|||||||
@@ -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,11 @@
|
|||||||
style="cursor: pointer;">
|
style="cursor: pointer;">
|
||||||
</i>
|
</i>
|
||||||
</p>
|
</p>
|
||||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)"
|
<app-metadata-advanced-fetch-options
|
||||||
[currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
(metadataOptionsSubmitted)="onMetadataSubmit($event)"
|
||||||
|
[currentMetadataOptions]="currentMetadataOptions"
|
||||||
|
[submitButtonLabel]="'Save'">
|
||||||
|
</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