feat(metadata): add configurable enabled fields for metadata editor and picker + UI tweaks (#2299)

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-16 19:13:17 -07:00
committed by GitHub
co-authored by acx10
parent 3a41e25aeb
commit 4dc5c0008c
49 changed files with 2631 additions and 1833 deletions
@@ -372,204 +372,230 @@
}
</div>
</div>
<div class="field-group metadata-id-field">
<label for="asin">Amazon ASIN</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="asin" formControlName="asin"/>
@if (!book.metadata!['asinLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
}
@if (book.metadata!['asinLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
}
@if (isFieldVisible('asin')) {
<div class="field-group metadata-id-field">
<label for="asin">Amazon ASIN</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="asin" formControlName="asin"/>
@if (!book.metadata!['asinLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
}
@if (book.metadata!['asinLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="amazonRating">Amazon ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="amazonRating" formControlName="amazonRating"/>
@if (!book.metadata!['amazonRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="success"></p-button>
}
@if (book.metadata!['amazonRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
}
}
@if (isFieldVisible('amazonRating')) {
<div class="field-group metadata-id-field">
<label for="amazonRating">Amazon ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="amazonRating" formControlName="amazonRating"/>
@if (!book.metadata!['amazonRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="success"></p-button>
}
@if (book.metadata!['amazonRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="amazonRatingCount">Amazon #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="amazonRatingCount" formControlName="amazonReviewCount"/>
@if (!book.metadata!['amazonReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
}
@if (book.metadata!['amazonReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
}
}
@if (isFieldVisible('amazonReviewCount')) {
<div class="field-group metadata-id-field">
<label for="amazonRatingCount">Amazon #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="amazonRatingCount" formControlName="amazonReviewCount"/>
@if (!book.metadata!['amazonReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
}
@if (book.metadata!['amazonReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="googleId">Google Books ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="googleId" formControlName="googleId"/>
@if (!book.metadata!['googleIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('googleId')" severity="success"></p-button>
}
@if (book.metadata!['googleIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
}
}
@if (isFieldVisible('googleId')) {
<div class="field-group metadata-id-field">
<label for="googleId">Google Books ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="googleId" formControlName="googleId"/>
@if (!book.metadata!['googleIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('googleId')" severity="success"></p-button>
}
@if (book.metadata!['googleIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
}
</div>
</div>
</div>
</div>
<div class="field-row metadata-ids-row">
<div class="field-group metadata-id-field">
<label for="goodreadsId">Goodreads ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsId" formControlName="goodreadsId"/>
@if (!book.metadata!['goodreadsIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="success"></p-button>
}
@if (book.metadata!['goodreadsIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
}
}
@if (isFieldVisible('goodreadsId')) {
<div class="field-group metadata-id-field">
<label for="goodreadsId">Goodreads ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsId" formControlName="goodreadsId"/>
@if (!book.metadata!['goodreadsIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="success"></p-button>
}
@if (book.metadata!['goodreadsIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="goodreadsRating">Goodreads ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsRating" formControlName="goodreadsRating"/>
@if (!book.metadata!['goodreadsRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="success"></p-button>
}
@if (book.metadata!['goodreadsRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
}
}
@if (isFieldVisible('goodreadsRating')) {
<div class="field-group metadata-id-field">
<label for="goodreadsRating">Goodreads ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsRating" formControlName="goodreadsRating"/>
@if (!book.metadata!['goodreadsRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="success"></p-button>
}
@if (book.metadata!['goodreadsRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="goodreadsReviewCount">Goodreads #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount"/>
@if (!book.metadata!['goodreadsReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
}
@if (book.metadata!['goodreadsReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
}
}
@if (isFieldVisible('goodreadsReviewCount')) {
<div class="field-group metadata-id-field">
<label for="goodreadsReviewCount">Goodreads #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount"/>
@if (!book.metadata!['goodreadsReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
}
@if (book.metadata!['goodreadsReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="hardcoverId">Hardcover ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverId" formControlName="hardcoverId"/>
@if (!book.metadata!['hardcoverIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="success"></p-button>
}
@if (book.metadata!['hardcoverIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
}
}
@if (isFieldVisible('hardcoverId')) {
<div class="field-group metadata-id-field">
<label for="hardcoverId">Hardcover ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverId" formControlName="hardcoverId"/>
@if (!book.metadata!['hardcoverIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="success"></p-button>
}
@if (book.metadata!['hardcoverIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="hardcoverBookId">Hardcover Book ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverBookId" formControlName="hardcoverBookId"/>
@if (!book.metadata!['hardcoverBookIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverBookId')" severity="success"></p-button>
}
@if (book.metadata!['hardcoverBookIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverBookId')" severity="warn"></p-button>
}
}
@if (isFieldVisible('hardcoverBookId')) {
<div class="field-group metadata-id-field">
<label for="hardcoverBookId">Hardcover Book ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverBookId" formControlName="hardcoverBookId"/>
@if (!book.metadata!['hardcoverBookIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverBookId')" severity="success"></p-button>
}
@if (book.metadata!['hardcoverBookIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverBookId')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="hardcoverRating">Hardcover ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverRating" formControlName="hardcoverRating"/>
@if (!book.metadata!['hardcoverRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="success"></p-button>
}
@if (book.metadata!['hardcoverRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
}
}
@if (isFieldVisible('hardcoverRating')) {
<div class="field-group metadata-id-field">
<label for="hardcoverRating">Hardcover ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverRating" formControlName="hardcoverRating"/>
@if (!book.metadata!['hardcoverRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="success"></p-button>
}
@if (book.metadata!['hardcoverRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="hardcoverReviewCount">Hardcover #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount"/>
@if (!book.metadata!['hardcoverReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
}
@if (book.metadata!['hardcoverReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
}
}
@if (isFieldVisible('hardcoverReviewCount')) {
<div class="field-group metadata-id-field">
<label for="hardcoverReviewCount">Hardcover #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount"/>
@if (!book.metadata!['hardcoverReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
}
@if (book.metadata!['hardcoverReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
}
</div>
</div>
</div>
</div>
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="field-group metadata-id-field">
<label for="lubimyczytacId">LC ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacId" formControlName="lubimyczytacId"/>
@if (!book.metadata!['lubimyczytacIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('lubimyczytacId')" severity="success"></p-button>
}
@if (book.metadata!['lubimyczytacIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('lubimyczytacId')" severity="warn"></p-button>
}
}
@if (isFieldVisible('lubimyczytacId')) {
<div class="field-group metadata-id-field">
<label for="lubimyczytacId">Lubimyczytac ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacId" formControlName="lubimyczytacId"/>
@if (!book.metadata!['lubimyczytacIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('lubimyczytacId')" severity="success"></p-button>
}
@if (book.metadata!['lubimyczytacIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('lubimyczytacId')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="lubimyczytacRating">LC ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacRating" formControlName="lubimyczytacRating"/>
@if (!book.metadata!['lubimyczytacRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('lubimyczytacRating')" severity="success"></p-button>
}
@if (book.metadata!['lubimyczytacRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('lubimyczytacRating')" severity="warn"></p-button>
}
}
@if (isFieldVisible('lubimyczytacRating')) {
<div class="field-group metadata-id-field">
<label for="lubimyczytacRating">Lubimyczytac ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacRating" formControlName="lubimyczytacRating"/>
@if (!book.metadata!['lubimyczytacRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('lubimyczytacRating')" severity="success"></p-button>
}
@if (book.metadata!['lubimyczytacRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('lubimyczytacRating')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-group metadata-id-field">
<label for="comicvineId">Comicvine ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="comicvineId" formControlName="comicvineId"/>
@if (!book.metadata!['comicvineIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="success"></p-button>
}
@if (book.metadata!['comicvineIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="warn"></p-button>
}
}
@if (isFieldVisible('comicvineId')) {
<div class="field-group metadata-id-field">
<label for="comicvineId">Comicvine ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="comicvineId" formControlName="comicvineId"/>
@if (!book.metadata!['comicvineIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="success"></p-button>
}
@if (book.metadata!['comicvineIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="ranobedbId">Ranobedb ID</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="ranobedbId" formControlName="ranobedbId" class="w-full"/>
@if (!book.metadata!['ranobedbIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="success"></p-button>
}
@if (book.metadata!['ranobedbIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="warn"></p-button>
}
}
@if (isFieldVisible('ranobedbId')) {
<div class="field-group metadata-id-field">
<label for="ranobedbId">Ranobedb ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbId" formControlName="ranobedbId"/>
@if (!book.metadata!['ranobedbIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="success"></p-button>
}
@if (book.metadata!['ranobedbIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="ranobedbRating">Ranobedb ★</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="ranobedbRating" formControlName="ranobedbRating" class="w-full"/>
@if (!book.metadata!['ranobedbRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="success"></p-button>
}
@if (book.metadata!['ranobedbRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="warn"></p-button>
}
}
@if (isFieldVisible('ranobedbRating')) {
<div class="field-group metadata-id-field">
<label for="ranobedbRating">Ranobedb ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbRating" formControlName="ranobedbRating"/>
@if (!book.metadata!['ranobedbRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="success"></p-button>
}
@if (book.metadata!['ranobedbRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="warn"></p-button>
}
</div>
</div>
</div>
}
</div>
<div class="description-section">
@@ -238,16 +238,19 @@ label {
}
.metadata-ids-row {
@media (min-width: 768px) {
.field-group {
width: calc(100% / 6);
}
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 1rem;
width: 100%;
.metadata-id-field {
min-width: 0;
}
}
.metadata-id-field {
@media (min-width: 768px) {
width: calc(100% / 6);
min-width: 0;
}
}
@@ -27,6 +27,8 @@ import {BookNavigationService} from '../../../../book/service/book-navigation.se
import {BookMetadataHostService} from '../../../../../shared/service/book-metadata-host.service';
import {Router} from '@angular/router';
import {UserService} from '../../../../settings/user-management/user.service';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model';
@Component({
selector: "app-metadata-editor",
@@ -70,6 +72,7 @@ export class MetadataEditorComponent implements OnInit {
private router = inject(Router);
private userService = inject(UserService);
private destroyRef = inject(DestroyRef);
private appSettingsService = inject(AppSettingsService);
metadataForm: FormGroup;
currentBookId!: number;
@@ -98,6 +101,25 @@ export class MetadataEditorComponent implements OnInit {
filteredSeries: string[] = [];
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
providerSpecificFields: MetadataProviderSpecificFields = {
asin: true,
amazonRating: true,
amazonReviewCount: true,
googleId: true,
goodreadsId: true,
goodreadsRating: true,
goodreadsReviewCount: true,
hardcoverId: true,
hardcoverBookId: true,
hardcoverRating: true,
hardcoverReviewCount: true,
comicvineId: true,
lubimyczytacId: true,
lubimyczytacRating: true,
ranobedbId: true,
ranobedbRating: true,
};
navigationState$ = this.bookNavigationService.getNavigationState();
filterCategories(event: { query: string }) {
@@ -239,6 +261,17 @@ export class MetadataEditorComponent implements OnInit {
this.metadataCenterViewMode = userState.user?.userSettings.metadataCenterViewMode ?? 'route';
this.autoSaveEnabled = userState.user?.userSettings.autoSaveMetadata ?? false;
});
this.appSettingsService.appSettings$
.pipe(
filter(settings => !!settings),
takeUntilDestroyed(this.destroyRef)
)
.subscribe(settings => {
if (settings?.metadataProviderSpecificFields) {
this.providerSpecificFields = settings.metadataProviderSpecificFields;
}
});
}
private prepareAutoComplete(): void {
@@ -493,9 +526,7 @@ export class MetadataEditorComponent implements OnInit {
this.updateMetadata(false);
}
private buildMetadataWrapper(
shouldLockAllFields?: boolean
): MetadataUpdateWrapper {
private buildMetadataWrapper(shouldLockAllFields?: boolean): MetadataUpdateWrapper {
const form = this.metadataForm;
const metadata: BookMetadata = {
@@ -839,5 +870,9 @@ export class MetadataEditorComponent implements OnInit {
return position ? `${position.current} of ${position.total}` : '';
}
isFieldVisible(field: keyof MetadataProviderSpecificFields): boolean {
return this.providerSpecificFields[field] ?? false;
}
protected readonly sample = sample;
}
@@ -1,23 +1,23 @@
@if (book$ | async; as book) {
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="flex flex-col h-full w-full">
<div class="flex-grow overflow-auto p-0 md:p-4">
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
<p class="ml-3 text-lg">Current Metadata</p>
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="form-container">
<div class="form-content">
<div class="metadata-header">
<p class="metadata-header-text">Current Metadata</p>
<p-button
severity="success"
severity="info"
icon='pi pi-angle-left'
[ngStyle]="{'padding-left': '3rem', 'padding-right': '0.5rem'}"
class="button-left"
[outlined]="true"
pTooltip="Move all missing fields" tooltipPosition="bottom"
(onClick)="copyMissing()"></p-button>
<p-button
severity="success"
severity="info"
icon='pi pi-angle-double-left'
[ngStyle]="{'padding-left': '0.5rem', 'padding-right': '2rem'}"
class="button-double-left"
[outlined]="true"
pTooltip="Move all fields" tooltipPosition="bottom"
(onClick)="copyAll()"></p-button>
<p class="text-lg">Fetched Metadata</p>
<p class="metadata-header-text">Fetched Metadata</p>
</div>
<div class="form-row">
<label class="label"></label>
@@ -103,9 +103,9 @@
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
<div class="w-full px-4">
<div class="autocomplete-container">
<p-autoComplete
class="w-full"
class="autocomplete-full-width"
formControlName="{{field.controlName}}"
[multiple]="true"
[dropdown]="false"
@@ -131,12 +131,12 @@
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
<div class="w-full px-4">
<div class="autocomplete-container">
<p-autoComplete
[ngModel]="fetchedMetadata[field.fetchedKey] ?? []"
[ngModelOptions]="{ standalone: true }"
[disabled]="true"
[multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" class="w-full">
[multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" class="autocomplete-full-width">
</p-autoComplete>
</div>
</div>
@@ -198,33 +198,33 @@
</div>
</div>
}
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
<p class="ml-3 text-lg">Current Metadata</p>
<div class="metadata-header">
<p class="metadata-header-text">Current Metadata</p>
<p-button
severity="success"
severity="info"
icon='pi pi-angle-left'
[ngStyle]="{'padding-left': '3rem', 'padding-right': '0.5rem'}"
class="button-left"
[outlined]="true"
pTooltip="Move all missing fields" tooltipPosition="bottom"
(onClick)="copyMissing()"></p-button>
<p-button
severity="success"
severity="info"
icon='pi pi-angle-double-left'
[ngStyle]="{'padding-left': '0.5rem', 'padding-right': '2rem'}"
class="button-double-left"
[outlined]="true"
pTooltip="Move all fields" tooltipPosition="bottom"
(onClick)="copyAll()"></p-button>
<p class="text-lg">Fetched Metadata</p>
<p class="metadata-header-text">Fetched Metadata</p>
</div>
</div>
@if (!reviewMode) {
<div class="mt-auto">
<div class="form-footer">
<p-divider></p-divider>
<div class="flex justify-between px-2 pt-4">
<div class="footer-buttons">
<p-button label="To Metadata List" icon="pi pi-arrow-left" severity="info" (onClick)="goBackClick()"></p-button>
<div class="flex gap-x-4 justify-end">
<div class="footer-buttons-right">
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
<p-divider layout="vertical"/>
@@ -1,3 +1,45 @@
.form-container {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
animation: fadeIn 0.3s ease-in;
}
.form-content {
flex-grow: 1;
overflow: auto;
padding: 0;
@media (min-width: 768px) {
padding: 1rem;
}
}
.metadata-header {
display: flex;
justify-content: center;
align-items: center;
padding-bottom: 0.75rem;
padding-left: 9.25rem;
margin-top: 1rem;
}
.metadata-header-text {
margin-left: 0.75rem;
font-size: 1.125rem;
}
.button-left {
padding-left: 3rem;
padding-right: 0.5rem;
}
.button-double-left {
padding-left: 0.5rem;
padding-right: 2rem;
}
.form-row {
display: flex;
align-items: center;
@@ -7,7 +49,7 @@
}
.label {
width: 7rem;
width: 8rem;
text-align: left;
}
@@ -25,6 +67,16 @@
margin: 0 1rem;
}
.autocomplete-container {
width: 100%;
padding-left: 1rem;
padding-right: 1rem;
}
.autocomplete-full-width {
width: 100%;
}
.thumbnail {
width: 15.625rem;
height: 21.875rem;
@@ -54,10 +106,31 @@
--p-button-outlined-primary-color: #E32636;
}
.form-footer {
margin-top: auto;
}
.footer-buttons {
display: flex;
justify-content: space-between;
padding: 1rem 0.5rem 0;
}
.footer-buttons-right {
display: flex;
gap: 1rem;
justify-content: flex-end;
}
::ng-deep .p-inputchips {
width: 100% !important;
}
.flex.flex-col.h-full.w-full {
animation: fadeIn 0.3s ease-in;
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@@ -4,7 +4,7 @@ import {MessageService} from 'primeng/api';
import {Button} from 'primeng/button';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {InputText} from 'primeng/inputtext';
import {AsyncPipe, NgClass, NgStyle} from '@angular/common';
import {AsyncPipe, NgClass} from '@angular/common';
import {Divider} from 'primeng/divider';
import {Observable} from 'rxjs';
import {Tooltip} from 'primeng/tooltip';
@@ -13,10 +13,11 @@ import {BookService} from '../../../../book/service/book.service';
import {Textarea} from 'primeng/textarea';
import {filter, map, take} from 'rxjs/operators';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {AutoComplete} from 'primeng/autocomplete';
import {AutoCompleteSelectEvent} from 'primeng/autocomplete';
import {AutoComplete, AutoCompleteSelectEvent} from 'primeng/autocomplete';
import {Image} from 'primeng/image';
import {LazyLoadImageModule} from 'ng-lazyload-image';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model';
@Component({
selector: 'app-metadata-picker',
@@ -30,7 +31,6 @@ import {LazyLoadImageModule} from 'ng-lazyload-image';
Divider,
ReactiveFormsModule,
NgClass,
NgStyle,
Tooltip,
AsyncPipe,
Textarea,
@@ -66,23 +66,23 @@ export class MetadataPickerComponent implements OnInit {
{label: 'Language', controlName: 'language', lockedKey: 'languageLocked', fetchedKey: 'language'},
{label: 'ISBN-10', controlName: 'isbn10', lockedKey: 'isbn10Locked', fetchedKey: 'isbn10'},
{label: 'ISBN-13', controlName: 'isbn13', lockedKey: 'isbn13Locked', fetchedKey: 'isbn13'},
{label: 'ASIN', controlName: 'asin', lockedKey: 'asinLocked', fetchedKey: 'asin'},
{label: 'Amz Reviews', controlName: 'amazonReviewCount', lockedKey: 'amazonReviewCountLocked', fetchedKey: 'amazonReviewCount'},
{label: 'Amz Rating', controlName: 'amazonRating', lockedKey: 'amazonRatingLocked', fetchedKey: 'amazonRating'},
{label: 'Comicvine ID', controlName: 'comicvineId', lockedKey: 'comicvineIdLocked', fetchedKey: 'comicvineId'},
{label: 'Goodreads ID', controlName: 'goodreadsId', lockedKey: 'goodreadsIdLocked', fetchedKey: 'goodreadsId'},
{label: 'GR Reviews', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
{label: 'GR Rating', controlName: 'goodreadsRating', lockedKey: 'goodreadsRatingLocked', fetchedKey: 'goodreadsRating'},
{label: 'Hardcover ID', controlName: 'hardcoverId', lockedKey: 'hardcoverIdLocked', fetchedKey: 'hardcoverId'},
{label: 'Hardcover Book ID', controlName: 'hardcoverBookId', lockedKey: 'hardcoverBookIdLocked', fetchedKey: 'hardcoverBookId'},
{label: 'HC Reviews', controlName: 'hardcoverReviewCount', lockedKey: 'hardcoverReviewCountLocked', fetchedKey: 'hardcoverReviewCount'},
{label: 'HC Rating', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
{label: 'LC ID', controlName: 'lubimyczytacId', lockedKey: 'lubimyczytacIdLocked', fetchedKey: 'lubimyczytacId'},
{label: 'LC Rating', controlName: 'lubimyczytacRating', lockedKey: 'lubimyczytacRatingLocked', fetchedKey: 'lubimyczytacRating'},
{label: 'Ranobedb ID', controlName: 'ranobedbId', lockedKey: 'ranobedbIdLocked', fetchedKey: 'ranobedbId'},
{label: 'RD Rating', controlName: 'ranobedbRating', lockedKey: 'ranobedbRatingLocked', fetchedKey: 'ranobedbRating'},
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'},
{label: 'Google ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleId'},
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'}
{label: 'ASIN', controlName: 'asin', lockedKey: 'asinLocked', fetchedKey: 'asin'},
{label: 'Amazon #', controlName: 'amazonReviewCount', lockedKey: 'amazonReviewCountLocked', fetchedKey: 'amazonReviewCount'},
{label: 'Amazon ★', controlName: 'amazonRating', lockedKey: 'amazonRatingLocked', fetchedKey: 'amazonRating'},
{label: 'Goodreads ID', controlName: 'goodreadsId', lockedKey: 'goodreadsIdLocked', fetchedKey: 'goodreadsId'},
{label: 'Goodreads ★', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
{label: 'Goodreads #', controlName: 'goodreadsRating', lockedKey: 'goodreadsRatingLocked', fetchedKey: 'goodreadsRating'},
{label: 'HC Book ID', controlName: 'hardcoverBookId', lockedKey: 'hardcoverBookIdLocked', fetchedKey: 'hardcoverBookId'},
{label: 'Hardcover ID', controlName: 'hardcoverId', lockedKey: 'hardcoverIdLocked', fetchedKey: 'hardcoverId'},
{label: 'Hardcover #', controlName: 'hardcoverReviewCount', lockedKey: 'hardcoverReviewCountLocked', fetchedKey: 'hardcoverReviewCount'},
{label: 'Hardcover ★', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
{label: 'Comicvine ID', controlName: 'comicvineId', lockedKey: 'comicvineIdLocked', fetchedKey: 'comicvineId'},
{label: 'LB ID', controlName: 'lubimyczytacId', lockedKey: 'lubimyczytacIdLocked', fetchedKey: 'lubimyczytacId'},
{label: 'LB ★', controlName: 'lubimyczytacRating', lockedKey: 'lubimyczytacRatingLocked', fetchedKey: 'lubimyczytacRating'},
{label: 'Ranobedb ID', controlName: 'ranobedbId', lockedKey: 'ranobedbIdLocked', fetchedKey: 'ranobedbId'},
{label: 'Ranobedb ★', controlName: 'ranobedbRating', lockedKey: 'ranobedbRatingLocked', fetchedKey: 'ranobedbRating'}
];
@Input() reviewMode!: boolean;
@@ -131,6 +131,9 @@ export class MetadataPickerComponent implements OnInit {
private bookService = inject(BookService);
protected urlHelper = inject(UrlHelperService);
private destroyRef = inject(DestroyRef);
private appSettingsService = inject(AppSettingsService);
private enabledProviderFields: MetadataProviderSpecificFields | null = null;
constructor() {
this.metadataForm = new FormGroup({
@@ -205,6 +208,17 @@ export class MetadataPickerComponent implements OnInit {
}
ngOnInit(): void {
this.appSettingsService.appSettings$
.pipe(
filter(settings => !!settings?.metadataProviderSpecificFields),
take(1)
)
.subscribe(settings => {
if (settings?.metadataProviderSpecificFields) {
this.enabledProviderFields = settings.metadataProviderSpecificFields;
this.filterMetadataFields();
}
});
this.bookService.bookState$
.pipe(
@@ -318,7 +332,6 @@ export class MetadataPickerComponent implements OnInit {
coverLocked: metadata.coverLocked || false,
});
// Always enable all fields before applying locked state
Object.keys(this.metadataForm.controls).forEach((key) => {
if (!key.endsWith('Locked')) {
this.metadataForm.get(key)?.enable({emitEvent: false});
@@ -362,6 +375,34 @@ export class MetadataPickerComponent implements OnInit {
});
}
private filterMetadataFields(): void {
if (!this.enabledProviderFields) return;
const providerFieldMap: Record<string, keyof MetadataProviderSpecificFields> = {
'asin': 'asin',
'amazonRating': 'amazonRating',
'amazonReviewCount': 'amazonReviewCount',
'googleId': 'googleId',
'goodreadsId': 'goodreadsId',
'goodreadsRating': 'goodreadsRating',
'goodreadsReviewCount': 'goodreadsReviewCount',
'hardcoverId': 'hardcoverId',
'hardcoverBookId': 'hardcoverId',
'hardcoverRating': 'hardcoverRating',
'hardcoverReviewCount': 'hardcoverReviewCount',
'comicvineId': 'comicvineId',
'lubimyczytacId': 'lubimyczytacId',
'lubimyczytacRating': 'lubimyczytacRating',
'ranobedbId': 'ranobedbId',
'ranobedbRating': 'ranobedbRating'
};
this.metadataFieldsBottom = this.metadataFieldsBottom.filter(field => {
const providerKey = providerFieldMap[field.controlName];
return !providerKey || this.enabledProviderFields![providerKey];
});
}
onAutoCompleteSelect(fieldName: string, event: AutoCompleteSelectEvent) {
const values = (this.metadataForm.get(fieldName)?.value as string[]) || [];
if (!values.includes(event.value as string)) {
@@ -387,7 +428,7 @@ export class MetadataPickerComponent implements OnInit {
onSave(): void {
this.isSaving = true;
const updatedBookMetadata = this.buildMetadataWrapper(undefined);
this.bookService.updateBookMetadata(this.currentBookId, updatedBookMetadata, true).subscribe({
this.bookService.updateBookMetadata(this.currentBookId, updatedBookMetadata, false).subscribe({
next: (bookMetadata) => {
this.isSaving = false;
Object.keys(this.copiedFields).forEach((field) => {
@@ -21,7 +21,7 @@
[options]="providers"
formControlName="provider"
placeholder="Select providers"
[styleClass]="'custom-multiselect'">
class="'custom-multiselect'">
</p-multiselect>
</div>
@@ -73,7 +73,7 @@
type="submit"
[disabled]="!isSearchEnabled || loading"
icon="pi pi-search"
[styleClass]="'custom-search-button'">
class="'custom-search-button'">
</p-button>
</div>
</div>
@@ -74,6 +74,23 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.subscription.add(
this.appSettings$
.pipe(filter(settings => !!settings))
.subscribe(settings => {
const providerSettings = settings!.metadataProviderSettings ?? {};
this.providers = Object.entries(providerSettings)
.filter(([_, value]) => !!value && typeof value === 'object' && 'enabled' in value && (value as any).enabled)
.map(([key]) => key.charAt(0).toUpperCase() + key.slice(1));
const currentProviders = this.form.get('provider')?.value || [];
const validProviders = currentProviders.filter((p: string) => this.providers.includes(p));
if (validProviders.length !== currentProviders.length) {
this.form.patchValue({provider: validProviders.length > 0 ? validProviders : null});
}
})
);
this.subscription.add(
this.route.paramMap
.pipe(
@@ -94,11 +111,6 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
distinctUntilChanged(([prevBook], [currBook]) => prevBook?.id === currBook?.id)
)
.subscribe(([book, settings]) => {
const providerSettings = settings?.metadataProviderSettings ?? {};
this.providers = Object.entries(providerSettings)
.filter(([_, value]) => !!value && typeof value === 'object' && 'enabled' in value && (value as any).enabled)
.map(([key]) => key.charAt(0).toUpperCase() + key.slice(1));
this.resetFormFromBook(book!);
if (settings!.autoBookSearch) {
@@ -127,6 +139,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {
this.cancelRequest$.next();
this.cancelRequest$.complete();
this.subscription.unsubscribe();
this.selectedFetchedMetadata$.complete();
}
@@ -25,17 +25,23 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
'title', 'subtitle', 'description', 'authors', 'publisher', 'publishedDate',
'seriesName', 'seriesNumber', 'seriesTotal', 'isbn13', 'isbn10',
'language', 'categories', 'cover', 'pageCount',
'asin', 'goodreadsId', 'comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId', 'ranobedbId',
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating', 'ranobedbRating',
'moods', 'tags'
'asin', 'amazonRating', 'amazonReviewCount',
'googleId',
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
'hardcoverId', 'hardcoverRating', 'hardcoverReviewCount', 'moods', 'tags',
'comicvineId',
'lubimyczytacId', 'lubimyczytacRating',
'ranobedbId', 'ranobedbRating'
];
providerSpecificFields: (keyof FieldOptions)[] = [
'asin', 'goodreadsId', 'comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId', 'ranobedbId',
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating', 'ranobedbRating',
'moods', 'tags'
'asin', 'amazonRating', 'amazonReviewCount',
'googleId',
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
'hardcoverId', 'hardcoverRating', 'hardcoverReviewCount', 'moods', 'tags',
'comicvineId',
'lubimyczytacId', 'lubimyczytacRating',
'ranobedbId', 'ranobedbRating',
];
nonProviderSpecificFields: (keyof FieldOptions)[] = [
@@ -64,9 +70,28 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
private justSubmitted = false;
private providerSpecificFieldsList = [
'asin', 'goodreadsId','comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId', 'ranobedbId',
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating', 'ranobedbRating',
// Amazon
'asin', 'amazonRating', 'amazonReviewCount',
// Google
'googleId',
// Goodreads
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
// Hardcover
'hardcoverId', 'hardcoverRating', 'hardcoverReviewCount',
// Comicvine
'comicvineId',
// Lubimyczytac
'lubimyczytacId', 'lubimyczytacRating',
// Ranobedb
'ranobedbId', 'ranobedbRating',
// Generic provider-specific
'moods', 'tags'
];
@@ -231,7 +256,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
'goodreadsReviewCount': 'Goodreads Review Count',
'hardcoverRating': 'Hardcover Rating',
'hardcoverReviewCount': 'Hardcover Review Count',
'lubimyczytacId': 'LC ID',
'lubimyczytacId': 'Lubimyczytac ID',
'lubimyczytacRating': 'Lubimyczytac Rating',
'ranobedbId': 'Ranobedb ID',
'ranobedbRating': 'Ranobedb Rating',
@@ -0,0 +1,38 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-list"></i>
Enabled Fields in Metadata Editor & Picker
</h3>
<p class="section-description">
Select which metadata fields to display when editing book information or picking metadata from providers. Disabled fields will be hidden from the interface.
</p>
</div>
<div class="section-body">
<div class="preferences-section">
<div class="provider-groups-container">
@for (group of providerGroups; track group.label) {
<div class="provider-group">
<div class="group-header">
<span class="group-icon pi pi-database"></span>
<h4 class="group-label">{{ group.label }}</h4>
</div>
<div class="field-list">
@for (field of group.fields; track field) {
<div class="field-checkbox">
<p-toggleswitch
[inputId]="field"
[ngModel]="selectedFields.includes(field)"
(ngModelChange)="toggleField(field, $event)">
</p-toggleswitch>
<label [for]="field">{{ fieldLabels[field] || field }}</label>
</div>
}
</div>
</div>
}
</div>
</div>
</div>
</div>
@@ -0,0 +1,146 @@
.preferences-section {
@media (min-width: 768px) {
padding: 0 0.5rem;
}
}
.section-header {
margin-bottom: 2rem;
padding-bottom: 0.5rem;
border-bottom: var(--card-border);
border-bottom-color: var(--p-content-border-color);
}
.section-title {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 1.25rem;
font-weight: 600;
color: var(--text-color);
margin: 0 0 0.5rem 0;
.pi {
color: var(--primary-color);
font-size: 1.125rem;
}
}
.section-description {
font-size: 0.875rem;
line-height: 1.5;
color: var(--p-text-muted-color);
margin: 0;
}
.provider-groups-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
gap: 1rem;
@media (max-width: 1200px) {
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}
@media (max-width: 768px) {
grid-template-columns: 1fr;
gap: 0.875rem;
}
}
.provider-group {
background: var(--card-background);
border: 1px solid var(--p-content-border-color);
border-radius: 8px;
padding: 0.875rem;
transition: all 0.2s ease;
display: flex;
flex-direction: column;
&:hover {
border-color: color-mix(in srgb, var(--primary-color) 40%, var(--p-content-border-color) 60%);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
@media (max-width: 768px) {
padding: 0.75rem;
}
}
.group-header {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.75rem;
padding-bottom: 0.625rem;
border-bottom: 1px solid var(--p-content-border-color);
.group-icon {
color: var(--primary-color);
font-size: 0.9375rem;
flex-shrink: 0;
}
.group-label {
font-size: 0.9375rem;
font-weight: 600;
color: var(--text-color);
margin: 0;
letter-spacing: -0.01em;
}
}
.field-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.field-checkbox {
display: flex;
align-items: center;
gap: 0.625rem;
padding: 0.2rem 0.5rem;
border-radius: 5px;
transition: background-color 0.15s ease;
&:hover {
background: color-mix(in srgb, var(--p-surface-800) 70%, transparent 30%);
}
label {
cursor: pointer;
font-size: 0.875rem;
font-weight: 400;
user-select: none;
color: var(--text-color);
margin-bottom: 0;
flex: 1;
}
@media (max-width: 768px) {
padding: 0.375rem 0.4rem;
}
}
.section-body {
> .setting-item {
margin-bottom: 0.75rem;
}
}
.settings-card {
display: flex;
flex-direction: column;
gap: 1rem;
background: var(--card-background);
border: 1px solid var(--p-content-border-color);
border-radius: 8px;
padding: 1.5rem;
@media (max-width: 768px) {
padding: 0.75rem;
gap: 0.875rem;
}
}
@@ -0,0 +1,121 @@
import {Component, inject, Input, OnInit} from '@angular/core';
import {ToggleSwitchModule} from 'primeng/toggleswitch';
import {FormsModule} from '@angular/forms';
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
import {AppSettingKey, MetadataProviderSpecificFields} from '../../../../shared/model/app-settings.model';
import {filter, take} from 'rxjs/operators';
@Component({
selector: 'app-metadata-provider-field-selector',
standalone: true,
imports: [ToggleSwitchModule, FormsModule],
templateUrl: './metadata-provider-field-selector.component.html',
styleUrl: './metadata-provider-field-selector.component.scss'
})
export class MetadataProviderFieldSelectorComponent implements OnInit {
@Input() selectedFields: string[] = [];
private appSettingsService = inject(AppSettingsService);
providerGroups: { label: string, fields: string[] }[] = [
{
label: 'Amazon',
fields: ['asin', 'amazonRating', 'amazonReviewCount']
},
{
label: 'Google Books',
fields: ['googleId']
},
{
label: 'Goodreads',
fields: ['goodreadsId', 'goodreadsRating', 'goodreadsReviewCount']
},
{
label: 'Hardcover',
fields: ['hardcoverId', 'hardcoverBookId', 'hardcoverRating', 'hardcoverReviewCount']
},
{
label: 'Comicvine',
fields: ['comicvineId']
},
{
label: 'Lubimyczytac',
fields: ['lubimyczytacId', 'lubimyczytacRating']
},
{
label: 'Ranobedb',
fields: ['ranobedbId', 'ranobedbRating']
}
];
fieldLabels: Record<string, string> = {
'asin': 'Amazon ASIN',
'amazonRating': 'Amazon Rating',
'amazonReviewCount': 'Amazon Review Count',
'googleId': 'Google Books ID',
'goodreadsId': 'Goodreads ID',
'goodreadsRating': 'Goodreads Rating',
'goodreadsReviewCount': 'Goodreads Review Count',
'hardcoverId': 'Hardcover ID',
'hardcoverBookId': 'Hardcover Book ID',
'hardcoverRating': 'Hardcover Rating',
'hardcoverReviewCount': 'Hardcover Review Count',
'comicvineId': 'Comicvine ID',
'lubimyczytacId': 'Lubimyczytac ID',
'lubimyczytacRating': 'Lubimyczytac Rating',
'ranobedbId': 'Ranobedb ID',
'ranobedbRating': 'Ranobedb Rating',
};
private readonly allFieldNames: (keyof MetadataProviderSpecificFields)[] = [
'asin', 'amazonRating', 'amazonReviewCount',
'googleId',
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
'hardcoverId', 'hardcoverBookId', 'hardcoverRating', 'hardcoverReviewCount',
'comicvineId',
'lubimyczytacId', 'lubimyczytacRating',
'ranobedbId', 'ranobedbRating'
];
ngOnInit(): void {
this.appSettingsService.appSettings$
.pipe(
filter(settings => !!settings?.metadataProviderSpecificFields),
take(1)
)
.subscribe(settings => {
if (settings?.metadataProviderSpecificFields) {
this.selectedFields = this.toFieldArray(settings.metadataProviderSpecificFields);
}
});
}
toggleField(field: string, checked: boolean) {
this.selectedFields = checked
? [...this.selectedFields, field]
: this.selectedFields.filter(f => f !== field);
this.appSettingsService.saveSettings([{
key: AppSettingKey.METADATA_PROVIDER_SPECIFIC_FIELDS ?? 'metadataProviderSpecificFields',
newValue: this.toFieldState(this.selectedFields)
}]).subscribe();
}
private toFieldArray(fieldState: MetadataProviderSpecificFields): string[] {
const selectedFields: string[] = [];
for (const [field, enabled] of Object.entries(fieldState)) {
if (enabled) {
selectedFields.push(field);
}
}
return selectedFields;
}
private toFieldState(selectedFields: string[]): MetadataProviderSpecificFields {
const fieldState: any = {};
for (const field of this.allFieldNames) {
fieldState[field] = selectedFields.includes(field);
}
return fieldState;
}
}