Add more metadata fields to quick metadata refresh feature

This commit is contained in:
aditya.chandel
2025-05-31 16:00:19 -06:00
committed by Aditya Chandel
parent 128fa1c847
commit 5e1c997e25
4 changed files with 71 additions and 12 deletions
@@ -26,8 +26,17 @@ public class MetadataRefreshOptions {
@AllArgsConstructor @AllArgsConstructor
public static class FieldOptions { public static class FieldOptions {
private FieldProvider title; private FieldProvider title;
private FieldProvider subtitle;
private FieldProvider description; private FieldProvider description;
private FieldProvider authors; private FieldProvider authors;
private FieldProvider publisher;
private FieldProvider publishedDate;
private FieldProvider seriesName;
private FieldProvider seriesNumber;
private FieldProvider seriesTotal;
private FieldProvider isbn13;
private FieldProvider isbn10;
private FieldProvider language;
private FieldProvider categories; private FieldProvider categories;
private FieldProvider cover; private FieldProvider cover;
} }
@@ -15,43 +15,43 @@
<td class="px-4 py-2"> <td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP3.value" <p-select [options]="providers" [(ngModel)]="allP3.value"
(onChange)="syncProvider($event, 'p3')" (onChange)="syncProvider($event, 'p3')"
placeholder="Select All" placeholder="Select All" appendTo="body"
class="w-full"> class="w-full">
</p-select> </p-select>
</td> </td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP2.value" <p-select [options]="providers" [(ngModel)]="allP2.value"
(onChange)="syncProvider($event, 'p2')" (onChange)="syncProvider($event, 'p2')"
placeholder="Select All" placeholder="Select All" appendTo="body"
class="w-full"> class="w-full">
</p-select> </p-select>
</td> </td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP1.value" <p-select [options]="providers" [(ngModel)]="allP1.value"
(onChange)="syncProvider($event, 'p1')" (onChange)="syncProvider($event, 'p1')"
placeholder="Select All" placeholder="Select All" appendTo="body"
class="w-full"> class="w-full">
</p-select> </p-select>
</td> </td>
</tr> </tr>
<tr *ngFor="let field of fields" [hidden]="field === 'cover' && !refreshCovers"> <tr *ngFor="let field of fields" [hidden]="field === 'cover' && !refreshCovers">
<td class="px-4 py-2 text-gray-300">{{ field | titlecase }}</td> <td class="px-4 py-2 text-gray-300">{{formatLabel(field) }}</td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3" <p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
placeholder="Unset" placeholder="Unset" appendTo="body"
class="w-full"> class="w-full">
</p-select> </p-select>
</td> </td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2" <p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
placeholder="Unset" placeholder="Unset" appendTo="body"
class="w-full"> class="w-full">
</p-select> </p-select>
</td> </td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1" <p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
placeholder="Unset" placeholder="Unset" appendTo="body"
class="w-full"> class="w-full">
</p-select> </p-select>
</td> </td>
@@ -1,7 +1,7 @@
import {Component, Output, EventEmitter, inject, Input, OnInit, OnChanges, SimpleChanges} from '@angular/core'; import {Component, EventEmitter, inject, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
import {Select, SelectChangeEvent} from 'primeng/select'; import {Select, SelectChangeEvent} from 'primeng/select';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {NgForOf, TitleCasePipe} from '@angular/common'; import {NgForOf} from '@angular/common';
import {Checkbox} from 'primeng/checkbox'; import {Checkbox} from 'primeng/checkbox';
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api'; import {MessageService} from 'primeng/api';
@@ -10,14 +10,29 @@ import {FieldOptions, FieldProvider, MetadataRefreshOptions} from '../../model/r
@Component({ @Component({
selector: 'app-metadata-advanced-fetch-options', selector: 'app-metadata-advanced-fetch-options',
templateUrl: './metadata-advanced-fetch-options.component.html', templateUrl: './metadata-advanced-fetch-options.component.html',
imports: [Select, FormsModule, NgForOf, Checkbox, Button, TitleCasePipe], imports: [Select, FormsModule, NgForOf, Checkbox, Button],
styleUrl: './metadata-advanced-fetch-options.component.scss', styleUrl: './metadata-advanced-fetch-options.component.scss',
standalone: true standalone: true
}) })
export class MetadataAdvancedFetchOptionsComponent implements OnChanges { export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
@Output() metadataOptionsSubmitted: EventEmitter<MetadataRefreshOptions> = new EventEmitter<MetadataRefreshOptions>(); @Output() metadataOptionsSubmitted: EventEmitter<MetadataRefreshOptions> = new EventEmitter<MetadataRefreshOptions>();
fields: (keyof FieldOptions)[] = ['title', 'description', 'authors', 'categories', 'cover']; fields: (keyof FieldOptions)[] = [
'title',
'subtitle',
'description',
'authors',
'publisher',
'publishedDate',
'seriesName',
'seriesNumber',
'seriesTotal',
'isbn13',
'isbn10',
'language',
'categories',
'cover'
];
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover']; providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover'];
refreshCovers: boolean = false; refreshCovers: boolean = false;
mergeCategories: boolean = false; mergeCategories: boolean = false;
@@ -28,8 +43,17 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
fieldOptions: FieldOptions = { fieldOptions: FieldOptions = {
title: {p3: null, p2: null, p1: null}, title: {p3: null, p2: null, p1: null},
subtitle: {p3: null, p2: null, p1: null},
description: {p3: null, p2: null, p1: null}, description: {p3: null, p2: null, p1: null},
authors: {p3: null, p2: null, p1: null}, authors: {p3: null, p2: null, p1: null},
publisher: {p3: null, p2: null, p1: null},
publishedDate: {p3: null, p2: null, p1: null},
seriesName: {p3: null, p2: null, p1: null},
seriesNumber: {p3: null, p2: null, p1: null},
seriesTotal: {p3: null, p2: null, p1: null},
isbn13: {p3: null, p2: null, p1: null},
isbn10: {p3: null, p2: null, p1: null},
language: {p3: null, p2: null, p1: null},
categories: {p3: null, p2: null, p1: null}, categories: {p3: null, p2: null, p1: null},
cover: {p3: null, p2: null, p1: null} cover: {p3: null, p2: null, p1: null}
}; };
@@ -43,7 +67,17 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
if (changes['currentMetadataOptions'] && this.currentMetadataOptions) { if (changes['currentMetadataOptions'] && this.currentMetadataOptions) {
this.refreshCovers = this.currentMetadataOptions.refreshCovers || false; this.refreshCovers = this.currentMetadataOptions.refreshCovers || false;
this.mergeCategories = this.currentMetadataOptions.mergeCategories || false; this.mergeCategories = this.currentMetadataOptions.mergeCategories || false;
this.fieldOptions = this.currentMetadataOptions.fieldOptions || this.fieldOptions;
const backendFieldOptions = this.currentMetadataOptions.fieldOptions as FieldOptions || {};
for (const field of this.fields) {
if (!backendFieldOptions[field]) {
backendFieldOptions[field] = {p3: null, p2: null, p1: null};
}
}
this.fieldOptions = backendFieldOptions;
this.allP3.value = this.currentMetadataOptions.allP3 || null; this.allP3.value = this.currentMetadataOptions.allP3 || null;
this.allP2.value = this.currentMetadataOptions.allP2 || null; this.allP2.value = this.currentMetadataOptions.allP2 || null;
this.allP1.value = this.currentMetadataOptions.allP1 || null; this.allP1.value = this.currentMetadataOptions.allP1 || null;
@@ -95,4 +129,11 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
} }
} }
formatLabel(field: string): string {
return field
.replace(/([A-Z])/g, ' $1')
.replace(/^./, str => str.toUpperCase())
.trim();
}
} }
@@ -19,4 +19,13 @@ export interface FieldOptions {
authors: FieldProvider; authors: FieldProvider;
categories: FieldProvider; categories: FieldProvider;
cover: FieldProvider; cover: FieldProvider;
subtitle: FieldProvider;
publisher: FieldProvider;
publishedDate: FieldProvider;
seriesName: FieldProvider;
seriesNumber: FieldProvider;
seriesTotal: FieldProvider;
isbn13: FieldProvider;
isbn10: FieldProvider;
language: FieldProvider;
} }