Add more metadata fields to quick metadata refresh feature
This commit is contained in:
committed by
Aditya Chandel
parent
128fa1c847
commit
5e1c997e25
+9
@@ -26,8 +26,17 @@ public class MetadataRefreshOptions {
|
||||
@AllArgsConstructor
|
||||
public static class FieldOptions {
|
||||
private FieldProvider title;
|
||||
private FieldProvider subtitle;
|
||||
private FieldProvider description;
|
||||
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 cover;
|
||||
}
|
||||
|
||||
+7
-7
@@ -15,43 +15,43 @@
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="allP3.value"
|
||||
(onChange)="syncProvider($event, 'p3')"
|
||||
placeholder="Select All"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="allP2.value"
|
||||
(onChange)="syncProvider($event, 'p2')"
|
||||
placeholder="Select All"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="allP1.value"
|
||||
(onChange)="syncProvider($event, 'p1')"
|
||||
placeholder="Select All"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<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">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
|
||||
placeholder="Unset"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
|
||||
placeholder="Unset"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
|
||||
placeholder="Unset"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
|
||||
+46
-5
@@ -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 {FormsModule} from '@angular/forms';
|
||||
import {NgForOf, TitleCasePipe} from '@angular/common';
|
||||
import {NgForOf} from '@angular/common';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MessageService} from 'primeng/api';
|
||||
@@ -10,14 +10,29 @@ import {FieldOptions, FieldProvider, MetadataRefreshOptions} from '../../model/r
|
||||
@Component({
|
||||
selector: 'app-metadata-advanced-fetch-options',
|
||||
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',
|
||||
standalone: true
|
||||
})
|
||||
export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
|
||||
@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'];
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
@@ -28,8 +43,17 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
|
||||
fieldOptions: FieldOptions = {
|
||||
title: {p3: null, p2: null, p1: null},
|
||||
subtitle: {p3: null, p2: null, p1: null},
|
||||
description: {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},
|
||||
cover: {p3: null, p2: null, p1: null}
|
||||
};
|
||||
@@ -43,7 +67,17 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
if (changes['currentMetadataOptions'] && this.currentMetadataOptions) {
|
||||
this.refreshCovers = this.currentMetadataOptions.refreshCovers || 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.allP2.value = this.currentMetadataOptions.allP2 || 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;
|
||||
categories: FieldProvider;
|
||||
cover: FieldProvider;
|
||||
subtitle: FieldProvider;
|
||||
publisher: FieldProvider;
|
||||
publishedDate: FieldProvider;
|
||||
seriesName: FieldProvider;
|
||||
seriesNumber: FieldProvider;
|
||||
seriesTotal: FieldProvider;
|
||||
isbn13: FieldProvider;
|
||||
isbn10: FieldProvider;
|
||||
language: FieldProvider;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user