Support Hardcover as metadata provider
This commit is contained in:
committed by
Aditya Chandel
parent
d56d8181d0
commit
da6decb349
+20
-4
@@ -194,7 +194,7 @@
|
||||
|
||||
<!-- Review Count, Rating, Page Count -->
|
||||
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 w-1/4">
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="amazonRatingCount">Amazon Rating Count</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
|
||||
@@ -202,7 +202,7 @@
|
||||
<p-button *ngIf="metadata['amazonReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/4">
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="amazonRating">Amazon Rating</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<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>
|
||||
</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>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<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>
|
||||
</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>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<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>
|
||||
</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>
|
||||
|
||||
+14
@@ -79,6 +79,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonReviewCount: new FormControl(''),
|
||||
goodreadsRating: new FormControl(''),
|
||||
goodreadsReviewCount: new FormControl(''),
|
||||
hardcoverRating: new FormControl(''),
|
||||
hardcoverReviewCount: new FormControl(''),
|
||||
seriesName: new FormControl(''),
|
||||
seriesNumber: new FormControl(''),
|
||||
seriesTotal: new FormControl(''),
|
||||
@@ -101,6 +103,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonReviewCountLocked: new FormControl(false),
|
||||
goodreadsRatingLocked: new FormControl(false),
|
||||
goodreadsReviewCountLocked: new FormControl(false),
|
||||
hardcoverRatingLocked: new FormControl(false),
|
||||
hardcoverReviewCountLocked: new FormControl(false),
|
||||
seriesNameLocked: new FormControl(false),
|
||||
seriesNumberLocked: new FormControl(false),
|
||||
seriesTotalLocked: new FormControl(false),
|
||||
@@ -137,6 +141,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonReviewCount: metadata.amazonReviewCount || null,
|
||||
goodreadsRating: metadata.goodreadsRating || null,
|
||||
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
|
||||
hardcoverRating: metadata.hardcoverRating || null,
|
||||
hardcoverReviewCount: metadata.hardcoverReviewCount || null,
|
||||
seriesName: metadata.seriesName || null,
|
||||
seriesNumber: metadata.seriesNumber || null,
|
||||
seriesTotal: metadata.seriesTotal || null,
|
||||
@@ -159,6 +165,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
|
||||
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
|
||||
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
|
||||
hardcoverRatingLocked: metadata.hardcoverRatingLocked || false,
|
||||
hardcoverReviewCountLocked: metadata.hardcoverReviewCountLocked || false,
|
||||
seriesNameLocked: metadata.seriesNameLocked || false,
|
||||
seriesNumberLocked: metadata.seriesNumberLocked || false,
|
||||
seriesTotalLocked: metadata.seriesTotalLocked || false,
|
||||
@@ -180,6 +188,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
{ key: 'amazonRatingLocked', control: 'amazonRating' },
|
||||
{ key: 'goodreadsReviewCountLocked', control: 'goodreadsReviewCount' },
|
||||
{ key: 'goodreadsRatingLocked', control: 'goodreadsRating' },
|
||||
{ key: 'hardcoverReviewCountLocked', control: 'hardcoverReviewCount' },
|
||||
{ key: 'hardcoverRatingLocked', control: 'hardcoverRating' },
|
||||
{ key: 'pageCountLocked', control: 'pageCount' },
|
||||
{ key: 'descriptionLocked', control: 'description' },
|
||||
{ key: 'seriesNameLocked', control: 'seriesName' },
|
||||
@@ -295,6 +305,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value,
|
||||
goodreadsRating: this.metadataForm.get('goodreadsRating')?.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,
|
||||
seriesName: this.metadataForm.get('seriesName')?.value,
|
||||
seriesNumber: this.metadataForm.get('seriesNumber')?.value,
|
||||
@@ -318,6 +330,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
||||
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.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,
|
||||
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.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: 'Goodreads Reviews', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
|
||||
{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'}
|
||||
];
|
||||
|
||||
@@ -96,6 +98,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonReviewCount: new FormControl(''),
|
||||
goodreadsRating: new FormControl(''),
|
||||
goodreadsReviewCount: new FormControl(''),
|
||||
hardcoverRating: new FormControl(''),
|
||||
hardcoverReviewCount: new FormControl(''),
|
||||
seriesName: new FormControl(''),
|
||||
seriesNumber: new FormControl(''),
|
||||
seriesTotal: new FormControl(''),
|
||||
@@ -117,6 +121,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonReviewCountLocked: new FormControl(false),
|
||||
goodreadsRatingLocked: new FormControl(false),
|
||||
goodreadsReviewCountLocked: new FormControl(false),
|
||||
hardcoverRatingLocked: new FormControl(false),
|
||||
hardcoverReviewCountLocked: new FormControl(false),
|
||||
seriesNameLocked: new FormControl(false),
|
||||
seriesNumberLocked: new FormControl(false),
|
||||
seriesTotalLocked: new FormControl(false),
|
||||
@@ -147,6 +153,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonReviewCount: metadata.amazonReviewCount || null,
|
||||
goodreadsRating: metadata.goodreadsRating || null,
|
||||
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
|
||||
hardcoverRating: metadata.hardcoverRating || null,
|
||||
hardcoverReviewCount: metadata.hardcoverReviewCount || null,
|
||||
seriesName: metadata.seriesName || null,
|
||||
seriesNumber: metadata.seriesNumber || null,
|
||||
seriesTotal: metadata.seriesTotal || null,
|
||||
@@ -168,6 +176,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
|
||||
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
|
||||
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
|
||||
hardcoverRatingLocked: metadata.hardcoverRatingLocked || false,
|
||||
hardcoverReviewCountLocked: metadata.hardcoverReviewCountLocked || false,
|
||||
seriesNameLocked: metadata.seriesNameLocked || false,
|
||||
seriesNumberLocked: metadata.seriesNumberLocked || false,
|
||||
seriesTotalLocked: metadata.seriesTotalLocked || false,
|
||||
@@ -188,6 +198,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
if (metadata.amazonRatingLocked) this.metadataForm.get('amazonRating')?.disable();
|
||||
if (metadata.goodreadsReviewCountLocked) this.metadataForm.get('goodreadsReviewCount')?.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.descriptionLocked) this.metadataForm.get('description')?.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,
|
||||
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,
|
||||
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') : '',
|
||||
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,
|
||||
@@ -255,6 +269,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
||||
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.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,
|
||||
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
||||
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
|
||||
|
||||
+15
-9
@@ -4,7 +4,6 @@ import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
import {MetadataProvider} from '../../model/provider.model';
|
||||
import {FetchMetadataRequest} from '../../model/request/fetch-metadata-request.model';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
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 {Book, BookMetadata} from '../../../model/book.model';
|
||||
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 {AppSettingsService} from '../../../../core/service/app-settings.service';
|
||||
import {distinctUntilChanged, filter, switchMap} from 'rxjs/operators';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-searcher',
|
||||
@@ -27,7 +26,7 @@ import {ActivatedRoute, Router} from '@angular/router';
|
||||
})
|
||||
export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
form: FormGroup;
|
||||
providers = Object.values(MetadataProvider);
|
||||
providers: string[] = [];
|
||||
allFetchedMetadata: BookMetadata[] = [];
|
||||
selectedFetchedMetadata!: BookMetadata | null;
|
||||
bookId!: number;
|
||||
@@ -65,7 +64,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
this.selectedFetchedMetadata = null;
|
||||
this.allFetchedMetadata = [];
|
||||
this.form.patchValue({
|
||||
provider: Object.values(MetadataProvider),
|
||||
provider: this.providers,
|
||||
title: '',
|
||||
author: '',
|
||||
});
|
||||
@@ -75,6 +74,13 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
filter(([book, settings]) => !!book && !!settings),
|
||||
distinctUntilChanged(([prevBook], [currBook]) => prevBook?.id === currBook?.id)
|
||||
).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;
|
||||
|
||||
if (book) {
|
||||
@@ -83,7 +89,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
this.bookId = book.id;
|
||||
|
||||
this.form.patchValue({
|
||||
provider: Object.values(MetadataProvider),
|
||||
provider: this.providers,
|
||||
title: book.metadata?.title || null,
|
||||
author: book.metadata?.authors?.length ? book.metadata.authors[0] : ''
|
||||
});
|
||||
@@ -111,9 +117,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
|
||||
onSubmit(): void {
|
||||
if (this.form.valid) {
|
||||
const providerKeys = Object.keys(MetadataProvider).filter(key =>
|
||||
(this.form.get('provider')?.value as string[]).includes(MetadataProvider[key as keyof typeof MetadataProvider])
|
||||
);
|
||||
const providerKeys = this.form.get('provider')?.value;
|
||||
if (!providerKeys) {
|
||||
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>`;
|
||||
case "Google":
|
||||
return `<a href="https://books.google.com/books?id=${metadata.providerBookId}" target="_blank">Google</a>`;
|
||||
case "Hardcover":
|
||||
return `<a href="https://hardcover.app/books/${metadata.providerBookId}" target="_blank">Hardcover</a>`;
|
||||
default:
|
||||
throw new Error(`Unsupported provider: ${metadata.provider}`);
|
||||
}
|
||||
|
||||
+24
-20
@@ -41,28 +41,32 @@
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 pt-2">
|
||||
<ng-container *ngIf="metadata.amazonRating || metadata.goodreadsRating; else legacyRating">
|
||||
<p *ngIf="metadata.amazonRating" class="font-semibold">Amazon: {{ metadata.amazonRating }}</p>
|
||||
<p-rating
|
||||
*ngIf="metadata.amazonRating"
|
||||
[(ngModel)]="metadata.amazonRating"
|
||||
readonly
|
||||
stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
|
||||
</p-rating>
|
||||
<p *ngIf="metadata.amazonRating" class="font-semibold"> ({{ metadata.amazonReviewCount | number:'1.0-0' }})</p>
|
||||
<ng-container *ngIf="metadata.amazonRating || metadata.goodreadsRating || metadata.hardcoverRating; else legacyRating">
|
||||
<ng-container *ngIf="metadata.amazonRating">
|
||||
<p class="font-semibold">Amazon: {{ metadata.amazonRating }}</p>
|
||||
<p-rating [ngModel]="metadata.amazonRating" readonly stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
|
||||
</p-rating>
|
||||
<p class="font-semibold">({{ metadata.amazonReviewCount | number:'1.0-0' }})</p>
|
||||
<span *ngIf="metadata.goodreadsRating || metadata.hardcoverRating">|</span>
|
||||
</ng-container>
|
||||
|
||||
<p *ngIf="metadata.amazonRating && metadata.goodreadsRating">|</p>
|
||||
<ng-container *ngIf="metadata.goodreadsRating">
|
||||
<p class="font-semibold">Goodreads: {{ metadata.goodreadsRating }}</p>
|
||||
<p-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>
|
||||
<p-rating
|
||||
*ngIf="metadata.goodreadsRating"
|
||||
[(ngModel)]="metadata.goodreadsRating"
|
||||
readonly
|
||||
stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
|
||||
</p-rating>
|
||||
<p *ngIf="metadata.goodreadsRating" class="font-semibold"> ({{ metadata.goodreadsReviewCount | number:'1.0-0' }})</p>
|
||||
<ng-container *ngIf="metadata.hardcoverRating">
|
||||
<p class="font-semibold">Hardcover: {{ metadata.hardcoverRating }}</p>
|
||||
<p-rating [ngModel]="metadata.hardcoverRating" readonly stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
|
||||
</p-rating>
|
||||
<p class="font-semibold">({{ metadata.hardcoverReviewCount | number:'1.0-0' }})</p>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #legacyRating>
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
|
||||
@Output() metadataOptionsSubmitted: EventEmitter<MetadataRefreshOptions> = new EventEmitter<MetadataRefreshOptions>();
|
||||
fields: (keyof FieldOptions)[] = ['title', 'description', 'authors', 'categories', 'cover'];
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads'];
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover'];
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export enum MetadataProvider {
|
||||
Amazon = "Amazon",
|
||||
Google = "Google",
|
||||
GoodReads = "GoodReads"
|
||||
}
|
||||
@@ -53,6 +53,8 @@ export interface BookMetadata {
|
||||
amazonReviewCount?: number | null;
|
||||
goodreadsRating?: number | null;
|
||||
goodreadsReviewCount?: number | null;
|
||||
hardcoverRating?: number | null;
|
||||
hardcoverReviewCount?: number | null;
|
||||
coverUpdatedOn?: string;
|
||||
authors: string[];
|
||||
categories: string[];
|
||||
@@ -80,6 +82,8 @@ export interface BookMetadata {
|
||||
amazonReviewCountLocked?: boolean;
|
||||
goodreadsRatingLocked?: boolean;
|
||||
goodreadsReviewCountLocked?: boolean;
|
||||
hardcoverRatingLocked?: boolean;
|
||||
hardcoverReviewCountLocked?: boolean;
|
||||
coverUpdatedOnLocked?: boolean;
|
||||
authorsLocked?: boolean;
|
||||
categoriesLocked?: boolean;
|
||||
|
||||
@@ -18,6 +18,30 @@ export interface OidcAutoProvisionDetails {
|
||||
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 {
|
||||
autoBookSearch: boolean;
|
||||
similarBookRecommendation: boolean;
|
||||
@@ -31,6 +55,7 @@ export interface AppSettings {
|
||||
oidcAutoProvisionDetails: OidcAutoProvisionDetails;
|
||||
cbxCacheSizeInMb: number;
|
||||
maxFileUploadSizeInMb: number;
|
||||
metadataProviderSettings: MetadataProviderSettings;
|
||||
}
|
||||
|
||||
export enum AppSettingKey {
|
||||
@@ -44,5 +69,6 @@ export enum AppSettingKey {
|
||||
OIDC_PROVIDER_DETAILS = 'OIDC_PROVIDER_DETAILS',
|
||||
OIDC_AUTO_PROVISION_DETAILS = 'OIDC_AUTO_PROVISION_DETAILS',
|
||||
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>
|
||||
</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">
|
||||
<app-opds-settings></app-opds-settings>
|
||||
</div>
|
||||
@@ -162,8 +170,7 @@
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)"
|
||||
[currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)" [currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -19,6 +19,7 @@ import {filter, take} from 'rxjs/operators';
|
||||
import {FileUploadPatternComponent} from './file-upload-pattern/file-upload-pattern.component';
|
||||
import {OpdsSettingsComponent} from './opds-settings/opds-settings.component';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {MetadataProviderSettingsComponent} from './metadata-provider-settings/metadata-provider-settings.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-global-preferences',
|
||||
@@ -34,7 +35,8 @@ import {InputText} from 'primeng/inputtext';
|
||||
MetadataAdvancedFetchOptionsComponent,
|
||||
FileUploadPatternComponent,
|
||||
OpdsSettingsComponent,
|
||||
InputText
|
||||
InputText,
|
||||
MetadataProviderSettingsComponent
|
||||
],
|
||||
templateUrl: './global-preferences.component.html',
|
||||
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.ViewPreferences">View Preferences</p-tab>
|
||||
<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.EmailSettings">Email Setting</p-tab>
|
||||
<p-tab [value]="SettingsTab.AuthenticationSettings">Authentication Settings</p-tab>
|
||||
@@ -20,7 +20,7 @@
|
||||
<app-view-preferences-parent></app-view-preferences-parent>
|
||||
</p-tabpanel>
|
||||
<ng-container *ngIf="userData.permissions.admin">
|
||||
<p-tabpanel [value]="SettingsTab.GlobalSettings">
|
||||
<p-tabpanel [value]="SettingsTab.AdminSettings">
|
||||
<app-global-preferences></app-global-preferences>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel [value]="SettingsTab.UserManagement">
|
||||
|
||||
@@ -16,7 +16,7 @@ export enum SettingsTab {
|
||||
ViewPreferences = 'view-settings',
|
||||
UserManagement = 'user-management',
|
||||
EmailSettings = 'email-settings',
|
||||
GlobalSettings = 'global-settings',
|
||||
AdminSettings = 'admin-settings',
|
||||
AuthenticationSettings = 'auth-settings'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user