Introduce per-library settings for metadata fetching (#1239)
This commit is contained in:
+53
-54
@@ -7,46 +7,46 @@ import {
|
||||
OnInit,
|
||||
Output,
|
||||
} from "@angular/core";
|
||||
import { InputText } from "primeng/inputtext";
|
||||
import { Button } from "primeng/button";
|
||||
import { Divider } from "primeng/divider";
|
||||
import {InputText} from "primeng/inputtext";
|
||||
import {Button} from "primeng/button";
|
||||
import {Divider} from "primeng/divider";
|
||||
import {
|
||||
FormControl,
|
||||
FormGroup,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
} from "@angular/forms";
|
||||
import { Observable } from "rxjs";
|
||||
import { AsyncPipe } from "@angular/common";
|
||||
import { MessageService } from "primeng/api";
|
||||
import {Observable} from "rxjs";
|
||||
import {AsyncPipe} from "@angular/common";
|
||||
import {MessageService} from "primeng/api";
|
||||
import {
|
||||
Book,
|
||||
BookMetadata,
|
||||
MetadataClearFlags,
|
||||
MetadataUpdateWrapper,
|
||||
} from "../../../book/model/book.model";
|
||||
import { UrlHelperService } from "../../../utilities/service/url-helper.service";
|
||||
import {UrlHelperService} from "../../../utilities/service/url-helper.service";
|
||||
import {
|
||||
FileUpload,
|
||||
FileUploadErrorEvent,
|
||||
FileUploadEvent,
|
||||
} from "primeng/fileupload";
|
||||
import { HttpResponse } from "@angular/common/http";
|
||||
import { BookService } from "../../../book/service/book.service";
|
||||
import { ProgressSpinner } from "primeng/progressspinner";
|
||||
import { Tooltip } from "primeng/tooltip";
|
||||
import { filter, take } from "rxjs/operators";
|
||||
import { MetadataRestoreDialogComponent } from "../../../book/components/book-browser/metadata-restore-dialog-component/metadata-restore-dialog-component";
|
||||
import { DialogService } from "primeng/dynamicdialog";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { MetadataRefreshRequest } from "../../model/request/metadata-refresh-request.model";
|
||||
import { MetadataRefreshType } from "../../model/request/metadata-refresh-type.enum";
|
||||
import { AutoComplete } from "primeng/autocomplete";
|
||||
import { Textarea } from "primeng/textarea";
|
||||
import { IftaLabel } from "primeng/iftalabel";
|
||||
import { CoverSearchComponent } from "../../cover-search/cover-search.component";
|
||||
import { Image } from "primeng/image";
|
||||
import { LazyLoadImageModule } from "ng-lazyload-image";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {BookService} from "../../../book/service/book.service";
|
||||
import {ProgressSpinner} from "primeng/progressspinner";
|
||||
import {Tooltip} from "primeng/tooltip";
|
||||
import {filter, take} from "rxjs/operators";
|
||||
import {MetadataRestoreDialogComponent} from "../../../book/components/book-browser/metadata-restore-dialog-component/metadata-restore-dialog-component";
|
||||
import {DialogService} from "primeng/dynamicdialog";
|
||||
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
||||
import {MetadataRefreshRequest} from "../../model/request/metadata-refresh-request.model";
|
||||
import {MetadataRefreshType} from "../../model/request/metadata-refresh-type.enum";
|
||||
import {AutoComplete} from "primeng/autocomplete";
|
||||
import {Textarea} from "primeng/textarea";
|
||||
import {IftaLabel} from "primeng/iftalabel";
|
||||
import {CoverSearchComponent} from "../../cover-search/cover-search.component";
|
||||
import {Image} from "primeng/image";
|
||||
import {LazyLoadImageModule} from "ng-lazyload-image";
|
||||
|
||||
@Component({
|
||||
selector: "app-metadata-editor",
|
||||
@@ -270,36 +270,36 @@ export class MetadataEditorComponent implements OnInit {
|
||||
});
|
||||
|
||||
const lockableFields: { key: keyof BookMetadata; control: string }[] = [
|
||||
{ key: "titleLocked", control: "title" },
|
||||
{ key: "subtitleLocked", control: "subtitle" },
|
||||
{ key: "authorsLocked", control: "authors" },
|
||||
{ key: "categoriesLocked", control: "categories" },
|
||||
{ key: "publisherLocked", control: "publisher" },
|
||||
{ key: "publishedDateLocked", control: "publishedDate" },
|
||||
{ key: "languageLocked", control: "language" },
|
||||
{ key: "isbn10Locked", control: "isbn10" },
|
||||
{ key: "isbn13Locked", control: "isbn13" },
|
||||
{ key: "asinLocked", control: "asin" },
|
||||
{ key: "amazonReviewCountLocked", control: "amazonReviewCount" },
|
||||
{ key: "amazonRatingLocked", control: "amazonRating" },
|
||||
{ key: "personalRatingLocked", control: "personalRating" },
|
||||
{ key: "goodreadsIdLocked", control: "goodreadsId" },
|
||||
{ key: "comicvineIdLocked", control: "comicvineId" },
|
||||
{ key: "goodreadsReviewCountLocked", control: "goodreadsReviewCount" },
|
||||
{ key: "goodreadsRatingLocked", control: "goodreadsRating" },
|
||||
{ key: "hardcoverIdLocked", control: "hardcoverId" },
|
||||
{ key: "hardcoverReviewCountLocked", control: "hardcoverReviewCount" },
|
||||
{ key: "hardcoverRatingLocked", control: "hardcoverRating" },
|
||||
{ key: "googleIdLocked", control: "googleId" },
|
||||
{ key: "pageCountLocked", control: "pageCount" },
|
||||
{ key: "descriptionLocked", control: "description" },
|
||||
{ key: "seriesNameLocked", control: "seriesName" },
|
||||
{ key: "seriesNumberLocked", control: "seriesNumber" },
|
||||
{ key: "seriesTotalLocked", control: "seriesTotal" },
|
||||
{ key: "coverLocked", control: "thumbnailUrl" },
|
||||
{key: "titleLocked", control: "title"},
|
||||
{key: "subtitleLocked", control: "subtitle"},
|
||||
{key: "authorsLocked", control: "authors"},
|
||||
{key: "categoriesLocked", control: "categories"},
|
||||
{key: "publisherLocked", control: "publisher"},
|
||||
{key: "publishedDateLocked", control: "publishedDate"},
|
||||
{key: "languageLocked", control: "language"},
|
||||
{key: "isbn10Locked", control: "isbn10"},
|
||||
{key: "isbn13Locked", control: "isbn13"},
|
||||
{key: "asinLocked", control: "asin"},
|
||||
{key: "amazonReviewCountLocked", control: "amazonReviewCount"},
|
||||
{key: "amazonRatingLocked", control: "amazonRating"},
|
||||
{key: "personalRatingLocked", control: "personalRating"},
|
||||
{key: "goodreadsIdLocked", control: "goodreadsId"},
|
||||
{key: "comicvineIdLocked", control: "comicvineId"},
|
||||
{key: "goodreadsReviewCountLocked", control: "goodreadsReviewCount"},
|
||||
{key: "goodreadsRatingLocked", control: "goodreadsRating"},
|
||||
{key: "hardcoverIdLocked", control: "hardcoverId"},
|
||||
{key: "hardcoverReviewCountLocked", control: "hardcoverReviewCount"},
|
||||
{key: "hardcoverRatingLocked", control: "hardcoverRating"},
|
||||
{key: "googleIdLocked", control: "googleId"},
|
||||
{key: "pageCountLocked", control: "pageCount"},
|
||||
{key: "descriptionLocked", control: "description"},
|
||||
{key: "seriesNameLocked", control: "seriesName"},
|
||||
{key: "seriesNumberLocked", control: "seriesNumber"},
|
||||
{key: "seriesTotalLocked", control: "seriesTotal"},
|
||||
{key: "coverLocked", control: "thumbnailUrl"},
|
||||
];
|
||||
|
||||
for (const { key, control } of lockableFields) {
|
||||
for (const {key, control} of lockableFields) {
|
||||
const isLocked = metadata[key] === true;
|
||||
const formControl = this.metadataForm.get(control);
|
||||
if (formControl) {
|
||||
@@ -512,7 +512,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
cover: false,
|
||||
};
|
||||
|
||||
return { metadata, clearFlags };
|
||||
return {metadata, clearFlags};
|
||||
}
|
||||
|
||||
private updateMetadata(shouldLockAllFields: boolean | undefined): void {
|
||||
@@ -616,7 +616,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
this.bookService.getComicInfoMetadata(this.currentBookId).subscribe({
|
||||
next: (metadata) => {
|
||||
console.log("Retrieved ComicInfo.xml metadata:", metadata);
|
||||
|
||||
|
||||
if (metadata) {
|
||||
this.originalMetadata = structuredClone(metadata);
|
||||
this.populateFormFromMetadata(metadata);
|
||||
@@ -662,7 +662,6 @@ export class MetadataEditorComponent implements OnInit {
|
||||
this.refreshingBookIds.add(bookId);
|
||||
this.isAutoFetching = true;
|
||||
const request: MetadataRefreshRequest = {
|
||||
quick: true,
|
||||
refreshType: MetadataRefreshType.BOOKS,
|
||||
bookIds: [bookId],
|
||||
};
|
||||
|
||||
+1
-1
@@ -464,7 +464,7 @@
|
||||
@if (userState.user!.permissions.canEditMetadata || userState.user!.permissions.admin) {
|
||||
@if (refreshMenuItems$ | async; as refreshItems) {
|
||||
<p-splitbutton
|
||||
[label]="isAutoFetching ? 'Fetching...' : 'Fetch Metadata'"
|
||||
[label]="isAutoFetching ? 'Fetching...' : 'Auto Fetch'"
|
||||
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
|
||||
[outlined]="true"
|
||||
[model]="refreshItems"
|
||||
|
||||
+2
-3
@@ -115,8 +115,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
filter((book): book is Book => book !== null),
|
||||
map((book): MenuItem[] => [
|
||||
{
|
||||
label: 'Advanced Fetch',
|
||||
icon: 'pi pi-database',
|
||||
label: 'Custom Fetch',
|
||||
icon: 'pi pi-sync',
|
||||
command: () => {
|
||||
this.dialogService.open(MetadataFetchOptionsComponent, {
|
||||
header: 'Metadata Refresh Options',
|
||||
@@ -393,7 +393,6 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
quickRefresh(bookId: number) {
|
||||
this.isAutoFetching = true;
|
||||
const request: MetadataRefreshRequest = {
|
||||
quick: true,
|
||||
refreshType: MetadataRefreshType.BOOKS,
|
||||
bookIds: [bookId],
|
||||
};
|
||||
|
||||
+30
-5
@@ -3,16 +3,41 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">Book Field</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">4th Priority</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">3rd Priority</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">2nd Priority</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">1st Priority</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">
|
||||
4th Priority
|
||||
<i class="pi pi-question-circle ml-1 text-xs"
|
||||
pTooltip="Last fallback option - only used if 1st, 2nd, and 3rd priorities fail or are empty"
|
||||
tooltipPosition="top"></i>
|
||||
</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">
|
||||
3rd Priority
|
||||
<i class="pi pi-question-circle ml-1 text-xs"
|
||||
pTooltip="Third choice - used if 1st and 2nd priorities don't have data"
|
||||
tooltipPosition="top"></i>
|
||||
</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">
|
||||
2nd Priority
|
||||
<i class="pi pi-question-circle ml-1 text-xs"
|
||||
pTooltip="Second choice - used if 1st priority doesn't have data"
|
||||
tooltipPosition="top"></i>
|
||||
</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">
|
||||
1st Priority
|
||||
<i class="pi pi-question-circle ml-1 text-xs"
|
||||
pTooltip="First choice - always tried first for this field"
|
||||
tooltipPosition="top"></i>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="text-sm px-4 py-1.5 text-gray-300">All Other Fields</td>
|
||||
<td class="text-sm px-4 py-1.5 text-gray-300">
|
||||
All Other Fields
|
||||
<i class="pi pi-question-circle ml-1 text-xs"
|
||||
pTooltip="Quick way to set the same provider priority for all fields at once"
|
||||
tooltipPosition="right"></i>
|
||||
</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="allP4.value"
|
||||
(onChange)="syncProvider($event, 'p4')"
|
||||
|
||||
+12
-1
@@ -47,6 +47,8 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
|
||||
private messageService = inject(MessageService);
|
||||
|
||||
private justSubmitted = false;
|
||||
|
||||
private initializeFieldOptions(): FieldOptions {
|
||||
return this.fields.reduce((acc, field) => {
|
||||
acc[field] = {p1: null, p2: null, p3: null, p4: null};
|
||||
@@ -55,7 +57,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['currentMetadataOptions'] && this.currentMetadataOptions) {
|
||||
if (changes['currentMetadataOptions'] && this.currentMetadataOptions && !this.justSubmitted) {
|
||||
this.refreshCovers = this.currentMetadataOptions.refreshCovers || false;
|
||||
this.mergeCategories = this.currentMetadataOptions.mergeCategories || false;
|
||||
this.reviewBeforeApply = this.currentMetadataOptions.reviewBeforeApply || false;
|
||||
@@ -89,7 +91,10 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
);
|
||||
|
||||
if (allFieldsHaveProvider) {
|
||||
this.justSubmitted = true;
|
||||
|
||||
const metadataRefreshOptions: MetadataRefreshOptions = {
|
||||
libraryId: null,
|
||||
allP1: this.allP1.value,
|
||||
allP2: this.allP2.value,
|
||||
allP3: this.allP3.value,
|
||||
@@ -99,7 +104,12 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
reviewBeforeApply: this.reviewBeforeApply,
|
||||
fieldOptions: this.fieldOptions
|
||||
};
|
||||
|
||||
this.metadataOptionsSubmitted.emit(metadataRefreshOptions);
|
||||
|
||||
setTimeout(() => {
|
||||
this.justSubmitted = false;
|
||||
}, 1000);
|
||||
} else {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
@@ -111,6 +121,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.justSubmitted = false;
|
||||
this.allP1.value = null;
|
||||
this.allP2.value = null;
|
||||
this.allP3.value = null;
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ export class MetadataFetchOptionsComponent {
|
||||
filter(settings => settings != null),
|
||||
take(1)
|
||||
).subscribe(settings => {
|
||||
this.currentMetadataOptions = settings?.metadataRefreshOptions;
|
||||
this.currentMetadataOptions = settings?.defaultMetadataRefreshOptions;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export interface MetadataRefreshOptions {
|
||||
libraryId: number | null;
|
||||
allP4: string | null;
|
||||
allP3: string | null;
|
||||
allP2: string | null;
|
||||
|
||||
@@ -2,7 +2,6 @@ import {MetadataRefreshType} from './metadata-refresh-type.enum';
|
||||
import {MetadataRefreshOptions} from './metadata-refresh-options.model';
|
||||
|
||||
export interface MetadataRefreshRequest {
|
||||
quick?: boolean;
|
||||
refreshType: MetadataRefreshType;
|
||||
libraryId?: number;
|
||||
bookIds?: number[];
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ export class MultiBookMetadataFetchComponent implements OnInit, OnDestroy {
|
||||
this.appSettingsService.appSettings$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(settings => {
|
||||
this.currentMetadataOptions = settings!.metadataRefreshOptions;
|
||||
this.currentMetadataOptions = settings!.defaultMetadataRefreshOptions;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user