WIP: Arrange UI files for better structuring
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<p-tabs value="0" style="height: 100%; overflow: hidden;">
|
||||
<p-tablist>
|
||||
<p-tab value="0">Book Details</p-tab>
|
||||
<p-tab value="1">Edit Details</p-tab>
|
||||
<p-tab value="2">Match Book</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels style="height: 100%; overflow: hidden; padding-bottom: 0">
|
||||
<p-tabpanel value="0" style="height: 100%; overflow: hidden;">
|
||||
<app-metadata-viewer></app-metadata-viewer>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="1" style="height: 100%; overflow: hidden;">
|
||||
<app-metadata-editor></app-metadata-editor>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="2" style="height: 100%; overflow: hidden;">
|
||||
<app-metadata-searcher></app-metadata-searcher>
|
||||
</p-tabpanel>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component';
|
||||
import {BookMetadataCenterService} from './book-metadata-center.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookMetadataBI} from '../../book/model/book-metadata-for-book-info.model';
|
||||
import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-metadata-center',
|
||||
standalone: true,
|
||||
templateUrl: './book-metadata-center.component.html',
|
||||
styleUrl: './book-metadata-center.component.scss',
|
||||
imports: [
|
||||
Tabs,
|
||||
TabList,
|
||||
Tab,
|
||||
TabPanels,
|
||||
MetadataEditorComponent,
|
||||
TabPanel,
|
||||
MetadataSearcherComponent,
|
||||
MetadataViewerComponent,
|
||||
],
|
||||
})
|
||||
export class BookMetadataCenterComponent implements OnInit {
|
||||
|
||||
constructor(private dynamicDialogConfig: DynamicDialogConfig, private dynamicDialogRef: DynamicDialogRef, private bookInfoService: BookMetadataCenterService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const initialBook = this.dynamicDialogConfig.data.book;
|
||||
if (initialBook?.metadata) {
|
||||
this.bookInfoService.emit(this.convertToBookMetadataBI(initialBook));
|
||||
}
|
||||
this.bookInfoService.dialogClose$.subscribe((close) => {
|
||||
if(close) {
|
||||
this.bookInfoService.closeDialog(false);
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private convertToBookMetadataBI(book: Book): BookMetadataBI {
|
||||
const metadata = book.metadata;
|
||||
return {
|
||||
bookId: book.id,
|
||||
title: metadata?.title || '',
|
||||
subtitle: metadata?.subtitle,
|
||||
authors: metadata?.authors?.map((author) => author.name) || [],
|
||||
categories: metadata?.categories?.map((category) => category.name) || [],
|
||||
publisher: metadata?.publisher || '',
|
||||
publishedDate: metadata?.publishedDate || '',
|
||||
isbn10: metadata?.isbn10 || '',
|
||||
isbn13: metadata?.isbn13 || '',
|
||||
description: metadata?.description,
|
||||
pageCount: metadata?.pageCount || null,
|
||||
reviewCount: metadata?.reviewCount || null,
|
||||
rating: metadata?.rating || null,
|
||||
language: metadata?.language || '',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
import {BookMetadataBI} from '../../book/model/book-metadata-for-book-info.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class BookMetadataCenterService {
|
||||
|
||||
private bookMetadataSubject = new BehaviorSubject<BookMetadataBI | null>(null);
|
||||
bookMetadata$ = this.bookMetadataSubject.asObservable();
|
||||
|
||||
private dialogCloseSubject = new BehaviorSubject<boolean | null>(null);
|
||||
dialogClose$ = this.dialogCloseSubject.asObservable();
|
||||
|
||||
emit(bookMetadata: BookMetadataBI) {
|
||||
this.bookMetadataSubject.next(bookMetadata);
|
||||
}
|
||||
|
||||
closeDialog(close: boolean) {
|
||||
return this.dialogCloseSubject.next(close);
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<form [formGroup]="bookMetadataForm" (ngSubmit)="onSave()" *ngIf="bookMetadata$ | async as bookMetadata" class="pt-2 flex flex-col h-full">
|
||||
|
||||
<div class="overflow-y-scroll flex-1">
|
||||
|
||||
<div class="flex flex-row w-full gap-4">
|
||||
|
||||
<p-image [src]="coverImageSrc(bookMetadata.bookId)" alt="Image" width="225"></p-image>
|
||||
|
||||
<div class="flex flex-col flex-grow pl-2">
|
||||
|
||||
<div class="flex flex-row w-full gap-4 pb-1">
|
||||
<div class="flex flex-col gap-1 w-2/3">
|
||||
<label for="title">Title</label>
|
||||
<input pInputText id="title" formControlName="title" class="w-full"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="subtitle">Subtitle</label>
|
||||
<input pInputText id="subtitle" formControlName="subtitle" class="w-full"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 w-2/3">
|
||||
<label for="authors">Authors</label>
|
||||
<input pInputText id="authors" formControlName="authors" class="w-full"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="publisher">Publisher</label>
|
||||
<input pInputText id="publisher" formControlName="publisher" class="w-full"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 w-2/3">
|
||||
<label for="categories">Categories</label>
|
||||
<input pInputText id="categories" formControlName="categories" class="w-full"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="publishedDate">Publish Date</label>
|
||||
<input pInputText id="publishedDate" formControlName="publishedDate" class="w-full"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Language, ISBN 10, and ISBN 13 -->
|
||||
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="language">Language</label>
|
||||
<input pInputText id="language" formControlName="language" class="w-full"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="isbn10">ISBN 10</label>
|
||||
<input pInputText id="isbn10" formControlName="isbn10" class="w-full"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="isbn13">ISBN 13</label>
|
||||
<input pInputText id="isbn13" formControlName="isbn13" class="w-full"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="reviewCount">Review Count</label>
|
||||
<input pInputText id="reviewCount" formControlName="reviewCount" class="w-full"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="rating">Rating</label>
|
||||
<input pInputText id="rating" formControlName="rating" class="w-full"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="pageCount">Page Count</label>
|
||||
<input pInputText id="pageCount" formControlName="pageCount" class="w-full"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
<label for="description">Description</label>
|
||||
<!--<p-editor class="w-full" formControlName="description" id="description" [style]="{ height: '18rem' }">
|
||||
<ng-template #header>
|
||||
<span class="ql-formats">
|
||||
<button type="button" class="ql-bold" aria-label="Bold"></button>
|
||||
<button type="button" class="ql-italic" aria-label="Italic"></button>
|
||||
<button type="button" class="ql-underline" aria-label="Underline"></button>
|
||||
</span>
|
||||
</ng-template>
|
||||
</p-editor>-->
|
||||
<textarea rows="12" pTextarea id="description" formControlName="description" class="w-full"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-x-4 mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary" (onClick)="closeDialog()"></p-button>
|
||||
<p-button label="Save" icon="pi pi-check" type="submit"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
import {Image} from 'primeng/image';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookMetadataCenterService} from '../book-metadata-center.service';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {BookMetadataBI} from '../../../book/model/book-metadata-for-book-info.model';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {MetadataService} from '../../../book/service/metadata.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-editor',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-editor.component.html',
|
||||
styleUrl: './metadata-editor.component.scss',
|
||||
imports: [
|
||||
InputText,
|
||||
Textarea,
|
||||
Image,
|
||||
Button,
|
||||
Divider,
|
||||
FormsModule,
|
||||
AsyncPipe,
|
||||
NgIf,
|
||||
ReactiveFormsModule
|
||||
]
|
||||
})
|
||||
export class MetadataEditorComponent implements OnInit {
|
||||
|
||||
bookMetadata$: Observable<BookMetadataBI | null>;
|
||||
bookMetadataForm: FormGroup;
|
||||
currentBookId!: number;
|
||||
|
||||
constructor(private bookInfoService: BookMetadataCenterService,
|
||||
private bookService: BookService,
|
||||
private messageService: MessageService,
|
||||
private metadataService: MetadataService) {
|
||||
|
||||
this.bookMetadata$ = this.bookInfoService.bookMetadata$;
|
||||
this.bookMetadataForm = new FormGroup({
|
||||
title: new FormControl(''),
|
||||
subtitle: new FormControl(''),
|
||||
authors: new FormControl(''),
|
||||
categories: new FormControl(''),
|
||||
publisher: new FormControl(''),
|
||||
publishedDate: new FormControl(''),
|
||||
isbn10: new FormControl(''),
|
||||
isbn13: new FormControl(''),
|
||||
description: new FormControl(''),
|
||||
pageCount: new FormControl(''),
|
||||
language: new FormControl(''),
|
||||
rating: new FormControl(''),
|
||||
reviewCount: new FormControl(''),
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookMetadata$.subscribe((bookMetadata) => {
|
||||
if (bookMetadata) {
|
||||
this.currentBookId = bookMetadata.bookId;
|
||||
this.bookMetadataForm.setValue({
|
||||
title: bookMetadata.title,
|
||||
subtitle: bookMetadata.subtitle,
|
||||
authors: bookMetadata.authors.join(', '),
|
||||
categories: bookMetadata.categories.join(', '),
|
||||
publisher: bookMetadata.publisher,
|
||||
publishedDate: bookMetadata.publishedDate,
|
||||
isbn10: bookMetadata.isbn10,
|
||||
isbn13: bookMetadata.isbn13,
|
||||
description: bookMetadata.description,
|
||||
pageCount: bookMetadata.pageCount == 0 ? null : bookMetadata.pageCount,
|
||||
language: bookMetadata.language,
|
||||
rating: bookMetadata.rating,
|
||||
reviewCount: bookMetadata.reviewCount
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
const updatedBookMetadata: BookMetadataBI = {
|
||||
bookId: this.currentBookId,
|
||||
title: this.bookMetadataForm.get('title')?.value,
|
||||
subtitle: this.bookMetadataForm.get('subtitle')?.value,
|
||||
authors: this.bookMetadataForm.get('authors')?.value.split(',').map((author: string) => author.trim()),
|
||||
categories: this.bookMetadataForm.get('categories')?.value.split(',').map((category: string) => category.trim()),
|
||||
publisher: this.bookMetadataForm.get('publisher')?.value,
|
||||
publishedDate: this.bookMetadataForm.get('publishedDate')?.value,
|
||||
isbn10: this.bookMetadataForm.get('isbn10')?.value,
|
||||
isbn13: this.bookMetadataForm.get('isbn13')?.value,
|
||||
description: this.bookMetadataForm.get('description')?.value,
|
||||
pageCount: this.bookMetadataForm.get('pageCount')?.value,
|
||||
rating: this.bookMetadataForm.get('rating')?.value,
|
||||
reviewCount: this.bookMetadataForm.get('reviewCount')?.value,
|
||||
language: this.bookMetadataForm.get('language')?.value
|
||||
};
|
||||
this.metadataService.updateBookMetadata(updatedBookMetadata.bookId, updatedBookMetadata).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
this.bookInfoService.emit(updatedBookMetadata);
|
||||
},
|
||||
error: (error) => {
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book metadata'});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
coverImageSrc(bookId: number): string {
|
||||
return this.bookService.getBookCoverUrl(bookId);
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.bookInfoService.closeDialog(true);
|
||||
}
|
||||
}
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
<form [formGroup]="bookMetadataForm" (ngSubmit)="onSave()" class="h-full flex pt-1 flex-col">
|
||||
<div class="overflow-y-scroll flex-1">
|
||||
|
||||
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '4.95rem'}">
|
||||
<p class="ml-3">Current Metadata</p>
|
||||
<p-button
|
||||
severity="info"
|
||||
icon='pi pi-angle-double-left'
|
||||
[ngStyle]="{'padding-left': '2rem', 'padding-right': '2rem'}"
|
||||
[outlined]="true"
|
||||
pTooltip="Select all missing field" tooltipPosition="bottom"
|
||||
(onClick)="copyMissing()"></p-button>
|
||||
<p>Fetched Metadata</p>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="title" class="label">Title</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="title" formControlName="title" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('title') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('title'), 'yellow-outlined-button': isValueCopied('title')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('title')"/>
|
||||
<input pInputText [value]="fetchedMetadata.title" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="authors" class="label">Authors</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="authors" formControlName="authors" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('authors') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('authors'), 'yellow-outlined-button': isValueCopied('authors')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('authors')"/>
|
||||
<input pInputText [value]="fetchedAuthorsString()" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="categories" class="label">Categories</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="categories" formControlName="categories" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('categories') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('categories'), 'yellow-outlined-button': isValueCopied('categories')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('categories')"/>
|
||||
<input pInputText [value]="fetchedCategoriesString()" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="publisher" class="label">Publisher</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="publisher" formControlName="publisher" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('publisher') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('publisher'), 'yellow-outlined-button': isValueCopied('publisher')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('publisher')"/>
|
||||
<input pInputText [value]="fetchedMetadata.publisher" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="publishedDate" class="label">Published</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="publishedDate" formControlName="publishedDate" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('publishedDate') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('publishedDate'), 'yellow-outlined-button': isValueCopied('publishedDate')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('publishedDate')"/>
|
||||
<input pInputText [value]="fetchedMetadata.publishedDate" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="isbn10" class="label">ISBN-10</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="isbn10" formControlName="isbn10" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('isbn10') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('isbn10'), 'yellow-outlined-button': isValueCopied('isbn10')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('isbn10')"/>
|
||||
<input pInputText [value]="fetchedMetadata.isbn10" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="language" class="label">Language</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="language" formControlName="language" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('language') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('language'), 'yellow-outlined-button': isValueCopied('language')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('language')"/>
|
||||
<input pInputText [value]="fetchedMetadata.language" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="description" class="label">Description</label>
|
||||
<div class="input-container">
|
||||
<textarea id="description" formControlName="description" class="input"></textarea>
|
||||
<p-button
|
||||
[icon]="isValueSaved('description') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('description'), 'yellow-outlined-button': isValueCopied('description')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('description')"/>
|
||||
<textarea [value]="fetchedMetadata.description" class="input" readonly></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label class="label"></label>
|
||||
<div class="input-container">
|
||||
<img *ngIf="!updateThumbnailUrl" [src]="coverImageSrc(currentBookId)" alt="Book Thumbnail" class="thumbnail"/>
|
||||
<img *ngIf="updateThumbnailUrl" [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
<p-button
|
||||
[icon]="thumbnailSaved ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': thumbnailSaved, 'yellow-outlined-button': updateThumbnailUrl}"
|
||||
class="arrow-button"
|
||||
(click)="shouldUpdateThumbnail()"/>
|
||||
<img [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="isbn13" class="label">ISBN-13</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="isbn13" formControlName="isbn13" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('isbn13') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('isbn13'), 'yellow-outlined-button': isValueCopied('isbn13')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('isbn13')"/>
|
||||
<input pInputText [value]="fetchedMetadata.isbn13" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="rating" class="label">Rating</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="rating" formControlName="rating" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('rating'), 'yellow-outlined-button': isValueCopied('rating')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('rating')"/>
|
||||
<input pInputText [value]="fetchedMetadata.rating" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="reviewCount" class="label">Rating</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="reviewCount" formControlName="reviewCount" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('reviewCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('reviewCount'), 'yellow-outlined-button': isValueCopied('reviewCount')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('reviewCount')"/>
|
||||
<input pInputText [value]="fetchedMetadata.reviewCount" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="pageCount" class="label">Pages</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="pageCount" formControlName="pageCount" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('pageCount'), 'yellow-outlined-button': isValueCopied('pageCount')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('pageCount')"/>
|
||||
<input pInputText [value]="fetchedMetadata.pageCount" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '4.95rem'}">
|
||||
<p class="ml-3">Current Metadata</p>
|
||||
<p-button
|
||||
severity="info"
|
||||
icon='pi pi-angle-double-left'
|
||||
[ngStyle]="{'padding-left': '2rem', 'padding-right': '2rem'}"
|
||||
[outlined]="true"
|
||||
pTooltip="Select all missing field" tooltipPosition="top"
|
||||
(onClick)="copyMissing()"></p-button>
|
||||
<p>Fetched Metadata</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-x-4 mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex justify-between">
|
||||
<p-button label="Back" icon="pi pi-arrow-left" severity="info" (onClick)="goBackClick()"></p-button>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Close" icon="pi pi-times" severity="secondary" (onClick)="closeDialog()"></p-button>
|
||||
<p-button label="Save" icon="pi pi-check" severity="primary" type="submit"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
.form-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 0.75rem;
|
||||
width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 6rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.input-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 50%;
|
||||
padding: 0.5rem;
|
||||
border-radius: 0.25rem;
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
width: 15.625rem;
|
||||
height: 21.875rem;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
margin-left: 2.5rem;
|
||||
margin-right: 2.5rem;
|
||||
}
|
||||
|
||||
.arrow-button {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
.yellow-outlined-button {
|
||||
--p-button-outlined-primary-border-color: yellow;
|
||||
--p-button-outlined-primary-color: yellow;
|
||||
}
|
||||
|
||||
.green-outlined-button {
|
||||
--p-button-outlined-primary-border-color: limegreen;
|
||||
--p-button-outlined-primary-color: limegreen;
|
||||
}
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||
import {BookMetadata, FetchedMetadata} from '../../../book/model/book.model';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Button} from 'primeng/button';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {NgClass, NgIf, NgStyle} from '@angular/common';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {BookMetadataCenterService} from '../book-metadata-center.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookMetadataBI} from '../../../book/model/book-metadata-for-book-info.model';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {MetadataService} from '../../../book/service/metadata.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-picker',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-picker.component.html',
|
||||
styleUrls: ['./metadata-picker.component.scss'],
|
||||
imports: [
|
||||
Button,
|
||||
FormsModule,
|
||||
InputText,
|
||||
NgIf,
|
||||
Divider,
|
||||
ReactiveFormsModule,
|
||||
NgClass,
|
||||
NgStyle,
|
||||
Tooltip
|
||||
]
|
||||
})
|
||||
export class MetadataPickerComponent implements OnInit {
|
||||
|
||||
@Input() fetchedMetadata!: FetchedMetadata;
|
||||
@Output() goBack = new EventEmitter<boolean>();
|
||||
|
||||
bookMetadataForm: FormGroup;
|
||||
bookMetadata$: Observable<BookMetadataBI | null>;
|
||||
currentBookId!: number;
|
||||
updateThumbnailUrl: boolean = false;
|
||||
thumbnailSaved: boolean = false;
|
||||
copiedFields: { [key: string]: boolean } = {};
|
||||
savedFields: { [key: string]: boolean } = {};
|
||||
|
||||
constructor(private bookService: BookService,
|
||||
private bookInfoService: BookMetadataCenterService,
|
||||
private messageService: MessageService,
|
||||
private metadataService: MetadataService) {
|
||||
|
||||
this.bookMetadata$ = this.bookInfoService.bookMetadata$;
|
||||
this.bookMetadataForm = new FormGroup({
|
||||
title: new FormControl(''),
|
||||
subtitle: new FormControl(''),
|
||||
authors: new FormControl(''),
|
||||
categories: new FormControl(''),
|
||||
publisher: new FormControl(''),
|
||||
publishedDate: new FormControl(''),
|
||||
isbn10: new FormControl(''),
|
||||
isbn13: new FormControl(''),
|
||||
description: new FormControl(''),
|
||||
pageCount: new FormControl(''),
|
||||
language: new FormControl(''),
|
||||
rating: new FormControl(''),
|
||||
reviewCount: new FormControl(''),
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookMetadata$.subscribe((bookMetadata) => {
|
||||
if (bookMetadata) {
|
||||
this.currentBookId = bookMetadata.bookId;
|
||||
this.bookMetadataForm.setValue({
|
||||
title: bookMetadata.title,
|
||||
subtitle: bookMetadata.subtitle,
|
||||
authors: bookMetadata.authors.join(', '),
|
||||
categories: bookMetadata.categories.join(', '),
|
||||
publisher: bookMetadata.publisher,
|
||||
publishedDate: bookMetadata.publishedDate,
|
||||
isbn10: bookMetadata.isbn10,
|
||||
isbn13: bookMetadata.isbn13,
|
||||
description: bookMetadata.description,
|
||||
pageCount: bookMetadata.pageCount == 0 ? null : bookMetadata.pageCount,
|
||||
language: bookMetadata.language,
|
||||
rating: bookMetadata.rating,
|
||||
reviewCount: bookMetadata.reviewCount
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fetchedAuthorsString(): string {
|
||||
return this.fetchedMetadata.authors ? this.fetchedMetadata.authors.map(author => author).join(', ') : '';
|
||||
}
|
||||
|
||||
fetchedCategoriesString(): string {
|
||||
return this.fetchedMetadata.categories ? this.fetchedMetadata.categories.map(category => category).join(', ') : '';
|
||||
}
|
||||
|
||||
coverImageSrc(bookId: number): string {
|
||||
return this.bookService.getBookCoverUrl(bookId);
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
const updatedBookMetadata: BookMetadataBI = {
|
||||
bookId: this.currentBookId,
|
||||
title: this.bookMetadataForm.get('title')?.value || this.copiedFields['title'] ? this.getValueOrCopied('title') : '',
|
||||
subtitle: this.bookMetadataForm.get('subtitle')?.value || this.copiedFields['subtitle'] ? this.getValueOrCopied('subtitle') : '',
|
||||
authors: this.bookMetadataForm.get('authors')?.value || this.copiedFields['authors'] ? this.getArrayFromFormField('authors', this.fetchedMetadata.authors) : [],
|
||||
categories: this.bookMetadataForm.get('categories')?.value || this.copiedFields['categories'] ? this.getArrayFromFormField('categories', this.fetchedMetadata.categories) : [],
|
||||
publisher: this.bookMetadataForm.get('publisher')?.value || this.copiedFields['publisher'] ? this.getValueOrCopied('publisher') : '',
|
||||
publishedDate: this.bookMetadataForm.get('publishedDate')?.value || this.copiedFields['publishedDate'] ? this.getValueOrCopied('publishedDate') : '',
|
||||
isbn10: this.bookMetadataForm.get('isbn10')?.value || this.copiedFields['isbn10'] ? this.getValueOrCopied('isbn10') : '',
|
||||
isbn13: this.bookMetadataForm.get('isbn13')?.value || this.copiedFields['isbn13'] ? this.getValueOrCopied('isbn13') : '',
|
||||
description: this.bookMetadataForm.get('description')?.value || this.copiedFields['description'] ? this.getValueOrCopied('description') : '',
|
||||
pageCount: this.bookMetadataForm.get('pageCount')?.value || this.copiedFields['pageCount'] ? this.getPageCountOrCopied() : null,
|
||||
language: this.bookMetadataForm.get('language')?.value || this.copiedFields['language'] ? this.getValueOrCopied('language') : '',
|
||||
rating: this.bookMetadataForm.get('rating')?.value || this.copiedFields['rating'] ? this.getNumberOrCopied('rating') : null,
|
||||
reviewCount: this.bookMetadataForm.get('reviewCount')?.value || this.copiedFields['reviewCount'] ? this.getNumberOrCopied('reviewCount') : null,
|
||||
thumbnailUrl: this.updateThumbnailUrl ? this.fetchedMetadata.thumbnailUrl : '',
|
||||
};
|
||||
|
||||
this.metadataService.updateBookMetadata(this.currentBookId, updatedBookMetadata).subscribe({
|
||||
next: (bookMetadata) => {
|
||||
Object.keys(this.copiedFields).forEach((field) => {
|
||||
if (this.copiedFields[field]) {
|
||||
this.savedFields[field] = true;
|
||||
}
|
||||
});
|
||||
if (this.updateThumbnailUrl) {
|
||||
this.thumbnailSaved = true;
|
||||
}
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
this.bookInfoService.emit(updatedBookMetadata);
|
||||
},
|
||||
error: (error) => {
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book metadata'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
copyMissing() {
|
||||
Object.keys(this.fetchedMetadata).forEach((field) => {
|
||||
if (!this.bookMetadataForm.get(field)?.value && this.fetchedMetadata[field]) {
|
||||
this.copyFetchedToCurrent(field);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getNumberOrCopied(field: string): number | null {
|
||||
const formValue = this.bookMetadataForm.get(field)?.value;
|
||||
if (formValue === '' || formValue === null || isNaN(formValue)) {
|
||||
this.copiedFields[field] = true;
|
||||
return this.fetchedMetadata[field] || null;
|
||||
}
|
||||
return Number(formValue);
|
||||
}
|
||||
|
||||
private getPageCountOrCopied(): number | null {
|
||||
const formValue = this.bookMetadataForm.get('pageCount')?.value;
|
||||
if (formValue === '' || formValue === null || isNaN(formValue)) {
|
||||
this.copiedFields['pageCount'] = true;
|
||||
return this.fetchedMetadata.pageCount || null;
|
||||
}
|
||||
return Number(formValue);
|
||||
}
|
||||
|
||||
private getValueOrCopied(field: string): string {
|
||||
const formValue = this.bookMetadataForm.get(field)?.value;
|
||||
if (!formValue || formValue === '') {
|
||||
this.copiedFields[field] = true;
|
||||
return this.fetchedMetadata[field] || '';
|
||||
}
|
||||
return formValue;
|
||||
}
|
||||
|
||||
getArrayFromFormField(field: string, fallbackValue: any): any[] {
|
||||
const fieldValue = this.bookMetadataForm.get(field)?.value;
|
||||
if (!fieldValue) {
|
||||
return fallbackValue ? (Array.isArray(fallbackValue) ? fallbackValue : [fallbackValue]) : [];
|
||||
}
|
||||
if (typeof fieldValue === 'string') {
|
||||
return fieldValue.split(',').map(item => item.trim());
|
||||
}
|
||||
return Array.isArray(fieldValue) ? fieldValue : [];
|
||||
}
|
||||
|
||||
shouldUpdateThumbnail() {
|
||||
this.updateThumbnailUrl = true;
|
||||
}
|
||||
|
||||
copyFetchedToCurrent(field: string): void {
|
||||
const value = this.fetchedMetadata[field];
|
||||
if (value) {
|
||||
this.bookMetadataForm.get(field)?.setValue(value);
|
||||
this.copiedFields[field] = true;
|
||||
this.highlightCopiedInput(field);
|
||||
}
|
||||
}
|
||||
|
||||
highlightCopiedInput(field: string): void {
|
||||
this.copiedFields = {...this.copiedFields, [field]: true};
|
||||
}
|
||||
|
||||
isValueCopied(field: string): boolean {
|
||||
return this.copiedFields[field];
|
||||
}
|
||||
|
||||
isValueSaved(field: string): boolean {
|
||||
return this.savedFields[field];
|
||||
}
|
||||
|
||||
goBackClick() {
|
||||
this.goBack.emit(true);
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.bookInfoService.closeDialog(true);
|
||||
}
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<form *ngIf="!selectedFetchedMetadata" class="flex flex-col w-full h-full pt-2" [formGroup]="form" (ngSubmit)="onSubmit()">
|
||||
<div class="flex w-full gap-x-4 items-end">
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="provider">Providers</label>
|
||||
<p-multiselect id="provider" class="w-full" [filter]="false" showToggleAll="false" [options]="providers" formControlName="provider" placeholder="Select Providers"></p-multiselect>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="isbn">ISBN</label>
|
||||
<input pInputText formControlName="isbn" id="isbn" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 w-2/6">
|
||||
<label for="title">Title</label>
|
||||
<input pInputText formControlName="title" id="title" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 w-2/6">
|
||||
<label for="author">Author</label>
|
||||
<input pInputText formControlName="author" id="author" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p-button label="Search" type="submit" [disabled]="!isSearchEnabled || loading"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="loading" class="flex justify-center items-center">
|
||||
<p-progress-spinner ariaLabel="loading"/>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!loading" class="mt-8 flex-1 overflow-y-auto">
|
||||
<div *ngFor="let metadata of allFetchedMetadata" class="book-item flex flex-col w-full">
|
||||
<div class="flex w-full flex-row book-item-content" (click)="onBookClick(metadata)">
|
||||
<img [src]="metadata.thumbnailUrl || 'assets/book-cover-metadata.png'" alt="Image" class="img-fixed-dimensions pr-2"/>
|
||||
<div class=" flex flex-col w-full m-2">
|
||||
<div class="flex flex-row gap-4 justify-between">
|
||||
<p class="font-bold">{{ truncateText(metadata['title'], 90) }}</p>
|
||||
<div class="flex gap-2">
|
||||
<p>ISBN: {{ metadata['isbn10'] || metadata['asin'] }}</p>
|
||||
<p> | </p>
|
||||
<p>Published: {{ metadata['publishedDate'] }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<p>by {{ truncateText(metadata['authors'].join(', '), 70) }}</p>
|
||||
<p> | </p>
|
||||
<p>Source: <span [innerHTML]="buildProviderLink(metadata)"></span></p>
|
||||
</div>
|
||||
<p class="mt-4 truncate-text p-secondary">
|
||||
{{ sanitizeHtml(metadata['description']) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div *ngIf="selectedFetchedMetadata" class="h-full flex-auto">
|
||||
<app-metadata-picker [fetchedMetadata]="selectedFetchedMetadata" (goBack)="onGoBack()"></app-metadata-picker>
|
||||
</div>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
.truncate-text {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 4;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.img-fixed-dimensions {
|
||||
height: 150px;
|
||||
width: 100px;
|
||||
object-fit: fill;
|
||||
}
|
||||
|
||||
.book-item {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.book-item-content {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.book-item:hover .book-item-content::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(255, 255, 255, 0.075);
|
||||
}
|
||||
|
||||
.book-item:hover .book-item-content {
|
||||
box-shadow: 0 0 0 rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
import {MetadataProvider} from '../../../book/model/provider.model';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {FetchMetadataRequest} from '../../model/request/fetch-metadata-request.model';
|
||||
import {FetchedMetadata} from '../../../book/model/book.model';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {MetadataPickerComponent} from '../metadata-picker/metadata-picker.component';
|
||||
import {BookMetadataCenterService} from '../book-metadata-center.service';
|
||||
import {MultiSelect} from 'primeng/multiselect';
|
||||
import {MetadataService} from '../../../book/service/metadata.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-searcher',
|
||||
templateUrl: './metadata-searcher.component.html',
|
||||
styleUrls: ['./metadata-searcher.component.scss'],
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
Button,
|
||||
InputText,
|
||||
Divider,
|
||||
NgForOf,
|
||||
NgIf,
|
||||
ProgressSpinner,
|
||||
MetadataPickerComponent,
|
||||
MultiSelect
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
export class MetadataSearcherComponent implements OnInit {
|
||||
|
||||
form: FormGroup;
|
||||
providers = Object.values(MetadataProvider);
|
||||
allFetchedMetadata: FetchedMetadata[] = [];
|
||||
selectedFetchedMetadata!: FetchedMetadata | null;
|
||||
bookId!: number;
|
||||
loading: boolean = false;
|
||||
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private bookInfoService: BookMetadataCenterService,
|
||||
private metadataService: MetadataService) {
|
||||
this.form = this.formBuilder.group({
|
||||
provider: null,
|
||||
isbn: [''],
|
||||
title: [''],
|
||||
author: [''],
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.bookInfoService.bookMetadata$.subscribe((bookMetadata => {
|
||||
if (bookMetadata) {
|
||||
this.bookId = bookMetadata.bookId;
|
||||
this.form.setValue(({
|
||||
provider: null,
|
||||
isbn: bookMetadata.isbn10,
|
||||
title: bookMetadata.title,
|
||||
author: bookMetadata.authors.length > 0 ? bookMetadata.authors[0] : ''
|
||||
}))
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
get isSearchEnabled(): boolean {
|
||||
const providerSelected = !!this.form.get('provider')?.value;
|
||||
const isbnOrTitle = this.form.get('isbn')?.value || this.form.get('title')?.value;
|
||||
return providerSelected && isbnOrTitle;
|
||||
}
|
||||
|
||||
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])
|
||||
);
|
||||
if (!providerKeys) {
|
||||
console.error('Invalid provider selected.');
|
||||
return;
|
||||
}
|
||||
const fetchRequest: FetchMetadataRequest = {
|
||||
bookId: this.bookId,
|
||||
providers: providerKeys,
|
||||
title: this.form.get('title')?.value,
|
||||
isbn: this.form.get('isbn')?.value,
|
||||
author: this.form.get('author')?.value
|
||||
};
|
||||
this.loading = true;
|
||||
this.metadataService.fetchBookMetadata(fetchRequest.bookId, fetchRequest)
|
||||
.subscribe({
|
||||
next: (fetchedMetadata) => {
|
||||
this.loading = false;
|
||||
this.allFetchedMetadata = fetchedMetadata.map((book) => ({
|
||||
...book,
|
||||
thumbnailUrl: book.thumbnailUrl
|
||||
}));
|
||||
},
|
||||
error: (e) => {
|
||||
this.loading = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn('Form is invalid. Please fill in all required fields.');
|
||||
}
|
||||
}
|
||||
|
||||
buildProviderLink(metadata: { provider: string; providerBookId: string }): string {
|
||||
if (!metadata.provider || !metadata.providerBookId) {
|
||||
throw new Error("Invalid metadata: 'provider' or 'providerBookId' is missing.");
|
||||
}
|
||||
switch (metadata.provider) {
|
||||
case "Amazon":
|
||||
return `<a href="https://www.amazon.com/dp/${metadata.providerBookId}" target="_blank">Amazon</a>`;
|
||||
case "GoodReads":
|
||||
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>`;
|
||||
default:
|
||||
throw new Error(`Unsupported provider: ${metadata.provider}`);
|
||||
}
|
||||
}
|
||||
|
||||
truncateText(text: string | null, length: number): string {
|
||||
const safeText = text ?? '';
|
||||
return safeText.length > length ? safeText.substring(0, length) + '...' : safeText;
|
||||
}
|
||||
|
||||
onBookClick(fetchedMetadata: FetchedMetadata) {
|
||||
this.selectedFetchedMetadata = fetchedMetadata;
|
||||
}
|
||||
|
||||
onGoBack() {
|
||||
this.selectedFetchedMetadata = null;
|
||||
}
|
||||
|
||||
sanitizeHtml(htmlString: string | null | undefined): string {
|
||||
if (!htmlString) {
|
||||
return '';
|
||||
}
|
||||
return htmlString.replace(/<\/?[^>]+(>|$)/g, '').trim();
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<div class="container pt-2 flex flex-col h-full">
|
||||
<div class="book-metadata-container flex-shrink-0" *ngIf="bookMetadata$ | async as bookMetadata">
|
||||
<div class="flex flex-row w-full">
|
||||
|
||||
<img [src]="coverImageSrc(bookMetadata.bookId)" class="book-cover placeholder" alt="Cover of {{ bookMetadata.title }}" loading="lazy" width="225"/>
|
||||
|
||||
<div class="pl-6 flex flex-col w-full space-y-4">
|
||||
<div class="flex flex-row items-center justify-between">
|
||||
<div>
|
||||
<p class="text-lg font-bold">{{ bookMetadata.title }}</p>
|
||||
<div class="flex items-center gap-4 pt-1">
|
||||
<p-rating [(ngModel)]="bookMetadata.rating" readonly stars="5"></p-rating>
|
||||
<p class="font-semibold">({{ bookMetadata.reviewCount || 0 }} Reviews)</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-4 pr-4">
|
||||
<p-button [rounded]="true" [raised]="true" severity="info" (onClick)="readBook(bookMetadata.bookId)" icon="pi pi-eye"></p-button>
|
||||
<p-button [rounded]="true" [raised]="true" severity="info" icon="pi pi-download"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center">
|
||||
<p class="font-semibold text-lg">Authors:</p>
|
||||
<div class="flex flex-wrap gap-2 ml-2">
|
||||
<p class="text-lg" *ngFor="let author of bookMetadata.authors">
|
||||
{{ author }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<p><span class="font-bold">Publisher:</span> {{ bookMetadata.publisher || 'N/A' }}</p>
|
||||
<p><span class="font-bold">Published:</span> {{ bookMetadata.publishedDate || 'Unknown' }}</p>
|
||||
<p><span class="font-bold">Language:</span> {{ bookMetadata.language || 'Unknown' }}</p>
|
||||
<p><span class="font-bold">ISBN:</span> {{ bookMetadata.isbn10 || 'Unknown' }}</p>
|
||||
<p><span class="font-bold">Page Count:</span> {{ bookMetadata.pageCount || 'Unknown' }}</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<p-tag *ngFor="let category of bookMetadata.categories" value="{{category}}"></p-tag>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--<p-divider></p-divider>-->
|
||||
|
||||
<div *ngIf="bookMetadata$ | async as bookMetadata" class="book-description space-y-4 overflow-y-auto flex-1">
|
||||
<!--<p class="pt-2 px-2" [innerHTML]="bookMetadata.description || 'No description available.'"></p>-->
|
||||
<div class="pt-6">
|
||||
<p-editor [(ngModel)]="bookMetadata.description" [style]="{ height: '350px' }" [readonly]="true">
|
||||
<ng-template #header>
|
||||
</ng-template>
|
||||
</p-editor>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-x-4 mt-auto">
|
||||
<!--<p-divider></p-divider>-->
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Close" icon="pi pi-times" severity="secondary" (onClick)="closeDialog()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
::ng-deep .ql-toolbar.ql-snow {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
::ng-deep .p-editor .p-editor-toolbar.ql-snow {
|
||||
border: 0.5px solid var(--p-editor-toolbar-border-color) !important;
|
||||
}
|
||||
|
||||
::ng-deep .p-editor .p-editor-content {
|
||||
border-end-end-radius: 0 !important;
|
||||
border-end-start-radius: 0 !important;
|
||||
}
|
||||
|
||||
::ng-deep .ql-container {
|
||||
font-size: 14px !important;
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {BookMetadataBI} from '../../../book/model/book-metadata-for-book-info.model';
|
||||
import {BookMetadataCenterService} from '../book-metadata-center.service';
|
||||
import {Rating} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Editor} from 'primeng/editor';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-viewer.component.html',
|
||||
styleUrl: './metadata-viewer.component.scss',
|
||||
imports: [
|
||||
Button,
|
||||
NgForOf,
|
||||
NgIf,
|
||||
AsyncPipe,
|
||||
Rating,
|
||||
FormsModule,
|
||||
Tag,
|
||||
Editor
|
||||
]
|
||||
})
|
||||
export class MetadataViewerComponent implements OnInit {
|
||||
|
||||
bookMetadata$: Observable<BookMetadataBI | null>;
|
||||
currentBookId!: number;
|
||||
|
||||
constructor(private bookService: BookService, private router: Router, private bookInfoService: BookMetadataCenterService) {
|
||||
this.bookMetadata$ = this.bookInfoService.bookMetadata$;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookMetadata$.subscribe((bookMetadata) => {
|
||||
if(bookMetadata) {
|
||||
this.currentBookId = bookMetadata?.bookId;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
navigateToBook(bookId: number | null, libraryId: number | null): void {
|
||||
if (bookId && libraryId) {
|
||||
this.router.navigate(['/library', libraryId, 'book', bookId, 'info']);
|
||||
}
|
||||
}
|
||||
|
||||
getAuthorNames(book: Book | null): string {
|
||||
if (book && book.metadata && book.metadata.authors) {
|
||||
return book.metadata.authors.map((author) => author.name).join(', ');
|
||||
}
|
||||
return 'No authors available';
|
||||
}
|
||||
|
||||
coverImageSrc(bookId: number | undefined): string {
|
||||
if (bookId === null) {
|
||||
return 'assets/book-cover-metadata.png';
|
||||
}
|
||||
return this.bookService.getBookCoverUrl(bookId!);
|
||||
}
|
||||
|
||||
readBook(bookId: number) {
|
||||
this.bookService.readBook(bookId);
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
return this.bookInfoService.closeDialog(true);
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
<div class="flex flex-col space-y-6 p-4">
|
||||
<table class="min-w-full table-auto border-collapse custom-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">Book Field</th>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">Base</th>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">Higher Precedence</th>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">Highest Precedence</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="px-4 py-2 text-gray-300"></td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="allDefault.value"
|
||||
(onChange)="syncProvider($event, 'default')"
|
||||
placeholder="Select All"
|
||||
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"
|
||||
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"
|
||||
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">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].default"
|
||||
placeholder="Unset"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
|
||||
placeholder="Unset"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
|
||||
placeholder="Unset"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="flex flex-row items-center justify-between">
|
||||
<div class="flex flex-row items-center gap-4 justify-start">
|
||||
<p>Refresh covers: </p>
|
||||
<p-checkbox [(ngModel)]="refreshCovers" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
<div class="flex flex-row gap-6">
|
||||
<p-button severity="warn" label="Reset" (onClick)="reset()"></p-button>
|
||||
<p-button label="Submit" (onClick)="submit()"></p-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
.custom-table {
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--card-border);
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
import {Component, Output, EventEmitter} from '@angular/core';
|
||||
import {Select, SelectChangeEvent} from 'primeng/select';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgForOf, TitleCasePipe} from '@angular/common';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {FieldOptions, FieldProvider, MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-advanced-fetch-options',
|
||||
templateUrl: './metadata-advanced-fetch-options.component.html',
|
||||
imports: [Select, FormsModule, NgForOf, Checkbox, Button, TitleCasePipe],
|
||||
styleUrl: './metadata-advanced-fetch-options.component.scss',
|
||||
standalone: true
|
||||
})
|
||||
export class MetadataAdvancedFetchOptionsComponent {
|
||||
|
||||
@Output() metadataOptionsSubmitted: EventEmitter<MetadataRefreshOptions> = new EventEmitter<MetadataRefreshOptions>();
|
||||
fields: (keyof FieldOptions)[] = ['title', 'description', 'authors', 'categories', 'cover'];
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads'];
|
||||
refreshCovers: boolean = false;
|
||||
|
||||
allDefault = {placeholder: 'Set All', value: ''};
|
||||
allP2 = {placeholder: 'Set All', value: ''};
|
||||
allP1 = {placeholder: 'Set All', value: ''};
|
||||
|
||||
fieldOptions: FieldOptions = {
|
||||
title: {default: null, p2: null, p1: null},
|
||||
description: {default: null, p2: null, p1: null},
|
||||
authors: {default: null, p2: null, p1: null},
|
||||
categories: {default: null, p2: null, p1: null},
|
||||
cover: {default: null, p2: null, p1: null}
|
||||
};
|
||||
|
||||
constructor(private messageService: MessageService) {
|
||||
}
|
||||
|
||||
syncProvider(event: SelectChangeEvent, providerType: keyof FieldProvider) {
|
||||
for (const field of Object.keys(this.fieldOptions)) {
|
||||
this.fieldOptions[field as keyof FieldOptions][providerType] = event.value;
|
||||
}
|
||||
}
|
||||
|
||||
submit() {
|
||||
const allProvidersSelected = Object.keys(this.fieldOptions).every(field => {
|
||||
return this.fieldOptions[field as keyof FieldOptions].default !== null;
|
||||
});
|
||||
if (allProvidersSelected) {
|
||||
const metadataRefreshOptions: MetadataRefreshOptions = {
|
||||
defaultProvider: this.allDefault.value,
|
||||
refreshCovers: this.refreshCovers,
|
||||
fieldOptions: this.fieldOptions
|
||||
};
|
||||
|
||||
this.metadataOptionsSubmitted.emit(metadataRefreshOptions);
|
||||
} else {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
life: 5000,
|
||||
detail: 'Base provider must be selected for all the book fields.'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.allDefault.value = '';
|
||||
this.allP2.value = '';
|
||||
this.allP1.value = '';
|
||||
for (const field of Object.keys(this.fieldOptions)) {
|
||||
this.fieldOptions[field as keyof FieldOptions] = {
|
||||
default: null,
|
||||
p2: null,
|
||||
p1: null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<div class="flex flex-col gap-6 p-6 min-w-96">
|
||||
|
||||
<p-select fluid [options]="providers" [(ngModel)]="selectedProvider" placeholder="Select Provider" class="flex-grow"></p-select>
|
||||
|
||||
<div class="flex flex-row items-center gap-4">
|
||||
<p class="pl-2">Refresh covers: </p>
|
||||
<p-checkbox [(ngModel)]="refreshCovers" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
|
||||
<p-button class="flex pt-4 justify-end" label="Submit" [disabled]="!selectedProvider" (onClick)="submit()"></p-button>
|
||||
</div>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
.custom-table {
|
||||
border: 1px solid var(--border-color); /* Custom border color */
|
||||
border-radius: var(--card-border); /* Custom border radius */
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
import {Component, EventEmitter, Output} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {Select} from 'primeng/select';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-basic-fetch-options',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-basic-fetch-options.component.html',
|
||||
styleUrl: './metadata-basic-fetch-options.component.scss',
|
||||
imports: [Button, Checkbox, Select, FormsModule]
|
||||
})
|
||||
export class MetadataBasicFetchOptionsComponent {
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads'];
|
||||
selectedProvider!: string;
|
||||
refreshCovers: boolean = false;
|
||||
|
||||
@Output() metadataOptionsSubmitted: EventEmitter<MetadataRefreshOptions> = new EventEmitter<MetadataRefreshOptions>();
|
||||
|
||||
submit() {
|
||||
const metadataRefreshOptions: MetadataRefreshOptions = {
|
||||
defaultProvider: this.selectedProvider,
|
||||
refreshCovers: this.refreshCovers,
|
||||
};
|
||||
this.metadataOptionsSubmitted.emit(metadataRefreshOptions);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<div class="flex flex-col space-y-6">
|
||||
<ng-container *ngIf="isBasicMode; else advancedOptions">
|
||||
<app-metadata-basic-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)"></app-metadata-basic-fetch-options>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #advancedOptions>
|
||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)"></app-metadata-advanced-fetch-options>
|
||||
</ng-template>
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<p-button severity="info" label="{{ isBasicMode ? 'Switch to Advanced' : 'Switch to Basic' }}" (onClick)="toggleMode()" class="w-full"></p-button>
|
||||
</div>
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {MetadataAdvancedFetchOptionsComponent} from '../metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MetadataBasicFetchOptionsComponent} from '../metadata-basic-fetch-options/metadata-basic-fetch-options.component';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {MetadataService} from '../../../book/service/metadata.service';
|
||||
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
|
||||
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-fetch-options',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-fetch-options.component.html',
|
||||
imports: [
|
||||
MetadataAdvancedFetchOptionsComponent,
|
||||
Divider,
|
||||
Button,
|
||||
MetadataBasicFetchOptionsComponent,
|
||||
NgIf
|
||||
],
|
||||
styleUrl: './metadata-fetch-options.component.scss'
|
||||
})
|
||||
export class MetadataFetchOptionsComponent {
|
||||
isBasicMode: boolean = true;
|
||||
libraryId!: number;
|
||||
bookIds!: Set<number>;
|
||||
metadataRefreshType!: MetadataRefreshType;
|
||||
|
||||
constructor(private dynamicDialogConfig: DynamicDialogConfig,
|
||||
private dynamicDialogRef: DynamicDialogRef,
|
||||
private metadataService: MetadataService,
|
||||
private messageService: MessageService) {
|
||||
this.libraryId = dynamicDialogConfig.data.libraryId;
|
||||
this.bookIds = dynamicDialogConfig.data.bookIds;
|
||||
this.metadataRefreshType = dynamicDialogConfig.data.metadataRefreshType;
|
||||
}
|
||||
|
||||
toggleMode() {
|
||||
this.isBasicMode = !this.isBasicMode;
|
||||
}
|
||||
|
||||
onMetadataSubmit(metadataRefreshOptions: MetadataRefreshOptions) {
|
||||
const metadataRefreshRequest: MetadataRefreshRequest = {
|
||||
refreshType: this.metadataRefreshType,
|
||||
refreshOptions: metadataRefreshOptions,
|
||||
...(this.metadataRefreshType === 'BOOKS' && this.bookIds != null && {bookIds: this.bookIds}),
|
||||
...(this.metadataRefreshType === 'LIBRARY' && this.libraryId != null && {libraryId: this.libraryId})
|
||||
};
|
||||
this.metadataService.autoRefreshMetadata(metadataRefreshRequest).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Metadata Update Scheduled',
|
||||
detail: 'The metadata update for the selected books has been successfully scheduled.'
|
||||
});
|
||||
},
|
||||
error: (e) => {
|
||||
if (e.status === 409) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Task Already Running',
|
||||
life: 5000,
|
||||
detail: 'A metadata refresh task is already in progress. Please wait for it to complete before starting another one.'
|
||||
});
|
||||
} else {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Metadata Update Failed',
|
||||
life: 5000,
|
||||
detail: 'An unexpected error occurred while scheduling the metadata update. Please try again later or contact support if the issue persists.'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import {MetadataProvider} from '../../../book/model/provider.model';
|
||||
|
||||
export interface BookAutoMetadataRefresh {
|
||||
bookIds: number[],
|
||||
metadataProvider: MetadataProvider,
|
||||
replaceCover: boolean
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export interface FetchMetadataRequest {
|
||||
bookId: number,
|
||||
providers: string[],
|
||||
title: string,
|
||||
isbn: string,
|
||||
author: string
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import {MetadataProvider} from '../../../book/model/provider.model';
|
||||
|
||||
export interface LibraryAutoMetadataRefreshRequest {
|
||||
libraryId: number,
|
||||
metadataProvider: MetadataProvider,
|
||||
replaceCover: boolean
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
export interface MetadataRefreshOptions {
|
||||
defaultProvider: string;
|
||||
refreshCovers: boolean;
|
||||
fieldOptions?: FieldOptions;
|
||||
}
|
||||
|
||||
export interface FieldProvider {
|
||||
default: string | null;
|
||||
p2: string | null;
|
||||
p1: string | null;
|
||||
}
|
||||
|
||||
export interface FieldOptions {
|
||||
title: FieldProvider;
|
||||
description: FieldProvider;
|
||||
authors: FieldProvider;
|
||||
categories: FieldProvider;
|
||||
cover: FieldProvider;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import {MetadataRefreshType} from './metadata-refresh-type.enum';
|
||||
import {MetadataRefreshOptions} from './metadata-refresh-options.model';
|
||||
|
||||
export interface MetadataRefreshRequest {
|
||||
refreshType: MetadataRefreshType;
|
||||
libraryId?: number;
|
||||
bookIds?: Set<number>;
|
||||
refreshOptions: MetadataRefreshOptions;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export enum MetadataRefreshType {
|
||||
BOOKS = 'BOOKS',
|
||||
LIBRARY = 'LIBRARY'
|
||||
}
|
||||
Reference in New Issue
Block a user