WIP: Move metadata arrow picker
This commit is contained in:
@@ -41,70 +41,69 @@ import {ProgressSpinnerModule} from 'primeng/progressspinner';
|
||||
import {provideAnimationsAsync} from '@angular/platform-browser/animations/async';
|
||||
import {providePrimeNG} from 'primeng/config';
|
||||
import Aura from '@primeng/themes/aura';
|
||||
import { MetadataSearcherComponent } from './metadata-searcher/metadata-searcher.component';
|
||||
import { MetadataSearcherComponent } from './book-info-tabs/metadata-searcher/metadata-searcher.component';
|
||||
import {IftaLabel} from 'primeng/iftalabel';
|
||||
import { LoadingOverlayComponent } from './loading-overlay/loading-overlay.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
DirectoryPickerComponent,
|
||||
LibraryCreatorComponent,
|
||||
ShelfAssignerComponent,
|
||||
BookBrowserComponent,
|
||||
MetadataSearcherComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
AppLayoutModule,
|
||||
FormsModule,
|
||||
InputTextModule,
|
||||
TableModule,
|
||||
Button,
|
||||
StepperModule,
|
||||
IconFieldModule,
|
||||
InputIconModule,
|
||||
ToggleButtonModule,
|
||||
PasswordModule,
|
||||
ToastModule,
|
||||
InfiniteScrollDirective,
|
||||
SearchComponent,
|
||||
DropdownModule,
|
||||
VirtualScrollerModule,
|
||||
LazyLoadImageModule,
|
||||
ConfirmDialogModule,
|
||||
CheckboxModule,
|
||||
DividerModule,
|
||||
DialogModule,
|
||||
BookCardComponent,
|
||||
SpeedDialModule,
|
||||
MenuModule,
|
||||
IconPickerComponent,
|
||||
ProgressSpinnerModule,
|
||||
IftaLabel,
|
||||
LoadingOverlayComponent,
|
||||
],
|
||||
providers: [
|
||||
DialogService,
|
||||
MessageService,
|
||||
ConfirmationService,
|
||||
{
|
||||
provide: RxStompService,
|
||||
useFactory: rxStompServiceFactory,
|
||||
},
|
||||
{
|
||||
provide: RouteReuseStrategy,
|
||||
useClass: CustomReuseStrategy
|
||||
},
|
||||
provideAnimationsAsync(),
|
||||
providePrimeNG({
|
||||
theme: {
|
||||
preset: Aura
|
||||
}
|
||||
})
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
declarations: [
|
||||
AppComponent,
|
||||
DirectoryPickerComponent,
|
||||
LibraryCreatorComponent,
|
||||
ShelfAssignerComponent,
|
||||
BookBrowserComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
AppLayoutModule,
|
||||
FormsModule,
|
||||
InputTextModule,
|
||||
TableModule,
|
||||
Button,
|
||||
StepperModule,
|
||||
IconFieldModule,
|
||||
InputIconModule,
|
||||
ToggleButtonModule,
|
||||
PasswordModule,
|
||||
ToastModule,
|
||||
InfiniteScrollDirective,
|
||||
SearchComponent,
|
||||
DropdownModule,
|
||||
VirtualScrollerModule,
|
||||
LazyLoadImageModule,
|
||||
ConfirmDialogModule,
|
||||
CheckboxModule,
|
||||
DividerModule,
|
||||
DialogModule,
|
||||
BookCardComponent,
|
||||
SpeedDialModule,
|
||||
MenuModule,
|
||||
IconPickerComponent,
|
||||
ProgressSpinnerModule,
|
||||
IftaLabel,
|
||||
LoadingOverlayComponent,
|
||||
],
|
||||
providers: [
|
||||
DialogService,
|
||||
MessageService,
|
||||
ConfirmationService,
|
||||
{
|
||||
provide: RxStompService,
|
||||
useFactory: rxStompServiceFactory,
|
||||
},
|
||||
{
|
||||
provide: RouteReuseStrategy,
|
||||
useClass: CustomReuseStrategy
|
||||
},
|
||||
provideAnimationsAsync(),
|
||||
providePrimeNG({
|
||||
theme: {
|
||||
preset: Aura
|
||||
}
|
||||
})
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="container pt-4 px-2 flex flex-col h-full">
|
||||
<div class="space-y-4 flex-grow">
|
||||
<div class="container pt-4 flex flex-col h-full">
|
||||
<div class="space-y-4 overflow-y-auto flex-1">
|
||||
<div class="flex w-full gap-x-4">
|
||||
<div class="flex flex-col gap-1 w-2/3">
|
||||
<label for="title">Title</label>
|
||||
@@ -77,11 +77,12 @@
|
||||
</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" severity="secondary"/>
|
||||
<p-button label="Save" (onClick)="onSave()"/>
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary"/>
|
||||
<p-button label="Save" icon="pi pi-check" (onClick)="onSave()"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<p-tab value="1">Match Book</p-tab>
|
||||
<p-tab value="2">Manage File</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels style="height: 100%; overflow: hidden;">
|
||||
<p-tabpanels style="height: 100%; overflow: hidden; padding-bottom: 0">
|
||||
<p-tabpanel value="0" style="height: 100%; overflow: hidden;">
|
||||
<app-book-details [bookForm]="metadataForm" (save)="saveBook($event)"></app-book-details>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="1" style="height: 100%; overflow: hidden;">
|
||||
<app-book-match [metadata]="metadataForm"></app-book-match>
|
||||
<app-book-match [book]="book"></app-book-match>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="2" style="height: 100%; overflow: hidden;">
|
||||
<p>I too work!!</p>
|
||||
|
||||
@@ -23,22 +23,13 @@ import {BookMatchComponent} from './book-match/book-match.component';
|
||||
TabPanel
|
||||
]
|
||||
})
|
||||
export class BookInfoTabsComponent implements OnInit {
|
||||
book: Book | undefined;
|
||||
export class BookInfoTabsComponent {
|
||||
book: Book;
|
||||
metadataForm: BookMetadataForm = {} as BookMetadataForm;
|
||||
|
||||
constructor(private bookService: BookService, private dynamicDialogConfig: DynamicDialogConfig,
|
||||
private messageService: MessageService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookService.getBookByIdFromAPI(this.dynamicDialogConfig.data.bookId, true).subscribe({
|
||||
next: (book) => {
|
||||
this.book = book;
|
||||
this.initializeBookForm();
|
||||
},
|
||||
error: (error) => {
|
||||
}
|
||||
});
|
||||
constructor(private bookService: BookService, private dynamicDialogConfig: DynamicDialogConfig, private messageService: MessageService) {
|
||||
this.book = this.dynamicDialogConfig.data.book;
|
||||
this.initializeBookForm();
|
||||
}
|
||||
|
||||
private initializeBookForm(): void {
|
||||
@@ -52,7 +43,6 @@ export class BookInfoTabsComponent implements OnInit {
|
||||
}
|
||||
|
||||
saveBook(bookMetadataForm: BookMetadataForm) {
|
||||
console.log(bookMetadataForm)
|
||||
this.bookService.updateMetadataV2(this.book?.id!, bookMetadataForm).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<form class="flex flex-col w-full h-full pt-4" [formGroup]="form" (ngSubmit)="onSubmit()">
|
||||
<div class="flex w-full gap-x-4 items-end px-2">
|
||||
<form *ngIf="!selectedMetadata" class="flex flex-col w-full h-full pt-4" [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">Provider</label>
|
||||
<p-select
|
||||
@@ -13,17 +13,17 @@
|
||||
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="isbn">ISBN</label>
|
||||
<input pInputText formControlName="isbn" id="isbn" class="w-full" />
|
||||
<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" />
|
||||
<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" />
|
||||
<input pInputText formControlName="author" id="author" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -32,13 +32,13 @@
|
||||
</div>
|
||||
|
||||
<div *ngIf="loading" class="flex justify-center items-center">
|
||||
<p-progress-spinner ariaLabel="loading" />
|
||||
<p-progress-spinner ariaLabel="loading"/>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!loading" class="mt-8 flex-1 overflow-y-auto">
|
||||
<div *ngFor="let book of books" class="book-item flex flex-col w-full">
|
||||
<div class="flex w-full flex-row book-item-content">
|
||||
<img [src]="book.thumbnailUrl" alt="Image" class="img-fixed-dimensions pr-2" />
|
||||
<div *ngFor="let book of fetchedMetadata" class="book-item flex flex-col w-full">
|
||||
<div class="flex w-full flex-row book-item-content" (click)="onBookClick(book)">
|
||||
<img [src]="book.thumbnailUrl" 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(book['title'], 90) }}</p>
|
||||
@@ -57,5 +57,8 @@
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div *ngIf="selectedMetadata" class="h-full flex-auto">
|
||||
<app-metadata-searcher [book]="book!" [fetchedMetadata]="selectedMetadata"></app-metadata-searcher>
|
||||
</div>
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Select} from 'primeng/select';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {BookMetadataForm} from '../../book/model/book-metadata-form';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
import {Provider} from '../../book/model/provider.model';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {FetchMetadataRequest} from '../../book/model/fetch-metadata-request.model';
|
||||
import {FetchedMetadata} from '../../book/model/book.model';
|
||||
import {DomSanitizer} from '@angular/platform-browser';
|
||||
import {Book, FetchedMetadata} from '../../book/model/book.model';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {MetadataSearcherComponent} from '../metadata-searcher/metadata-searcher.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-match',
|
||||
@@ -25,19 +24,22 @@ import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
Divider,
|
||||
NgForOf,
|
||||
NgIf,
|
||||
ProgressSpinner
|
||||
ProgressSpinner,
|
||||
MetadataSearcherComponent
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
export class BookMatchComponent implements OnChanges {
|
||||
export class BookMatchComponent implements OnInit {
|
||||
|
||||
@Input() book!: Book;
|
||||
|
||||
@Input() metadata!: BookMetadataForm;
|
||||
form: FormGroup;
|
||||
providers = Object.values(Provider);
|
||||
books: FetchedMetadata[] = [];
|
||||
fetchedMetadata: FetchedMetadata[] = [];
|
||||
selectedMetadata!: FetchedMetadata;
|
||||
loading: boolean = false;
|
||||
|
||||
constructor(private fb: FormBuilder, private bookService: BookService, private sanitizer: DomSanitizer) {
|
||||
constructor(private fb: FormBuilder, private bookService: BookService) {
|
||||
this.form = this.fb.group({
|
||||
provider: [null],
|
||||
isbn: [''],
|
||||
@@ -46,15 +48,13 @@ export class BookMatchComponent implements OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['metadata'] && this.metadata) {
|
||||
const firstAuthor = this.metadata.authors && this.metadata.authors.length > 0 ? this.metadata.authors[0] : '';
|
||||
ngOnInit() {
|
||||
const firstAuthor = this.book!.metadata?.authors && this.book!.metadata?.authors.length > 0 ? this.book!.metadata?.authors[0].name : '';
|
||||
this.form.patchValue({
|
||||
isbn: this.metadata.isbn10 || '',
|
||||
title: this.metadata.title || '',
|
||||
isbn: this.book!.metadata?.isbn10 || '',
|
||||
title: this.book!.metadata?.title || '',
|
||||
author: firstAuthor,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get isSearchEnabled(): boolean {
|
||||
@@ -86,7 +86,7 @@ export class BookMatchComponent implements OnChanges {
|
||||
next: (fetchedMetadata) => {
|
||||
console.log('Metadata fetched successfully', fetchedMetadata);
|
||||
this.loading = false;
|
||||
this.books = fetchedMetadata.map((book) => ({
|
||||
this.fetchedMetadata = fetchedMetadata.map((book) => ({
|
||||
...book,
|
||||
thumbnailUrl: book.thumbnailUrl
|
||||
}));
|
||||
@@ -106,4 +106,7 @@ export class BookMatchComponent implements OnChanges {
|
||||
return safeText.length > length ? safeText.substring(0, length) + '...' : safeText;
|
||||
}
|
||||
|
||||
onBookClick(book: FetchedMetadata) {
|
||||
this.selectedMetadata = book;
|
||||
}
|
||||
}
|
||||
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<div class="h-full flex pt-4 flex-col">
|
||||
<div class="overflow-y-auto flex-1">
|
||||
<div class="form-row">
|
||||
<label for="title" class="label">Title</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="title" [(ngModel)]="toUpdateMetadata.title" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('title')"/>
|
||||
<input pInputText id="titleFetched" [(ngModel)]="fetchedMetadata.title" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="authors" class="label">Authors</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="authors" [(ngModel)]="currentAuthorsString" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('authors')"/>
|
||||
<input pInputText id="authorsFetched" [(ngModel)]="fetchedAuthorsString" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="categories" class="label">Categories</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="categories" [(ngModel)]="currentCategoriesString" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('categories')"/>
|
||||
<input pInputText id="categoriesFetched" [(ngModel)]="fetchedCategoriesString" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="publisher" class="label">Publisher</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="publisher" [(ngModel)]="toUpdateMetadata.publisher" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('publisher')"/>
|
||||
<input pInputText id="publisherFetched" [(ngModel)]="fetchedMetadata.publisher" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="publishedDate" class="label">Published</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="publishedDate" [(ngModel)]="toUpdateMetadata.publishedDate" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('publishedDate')"/>
|
||||
<input pInputText id="publishedDateFetched" [(ngModel)]="fetchedMetadata.publishedDate" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="isbn10" class="label">ISBN-10</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="isbn10" [(ngModel)]="toUpdateMetadata.isbn10" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('isbn10')"/>
|
||||
<input pInputText id="isbn10Fetched" [(ngModel)]="fetchedMetadata.isbn10" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="language" class="label">Language</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="language" [(ngModel)]="toUpdateMetadata.language" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('language')"/>
|
||||
<input pInputText id="languageFetched" [(ngModel)]="fetchedMetadata.language" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="language" class="label">Pages</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="pageCount" [(ngModel)]="toUpdateMetadata.pageCount" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('pageCount')"/>
|
||||
<input pInputText id="pageCountFetched" [(ngModel)]="fetchedMetadata.pageCount" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="description" class="label">Description</label>
|
||||
<div class="input-container">
|
||||
<textarea id="description" [(ngModel)]="toUpdateMetadata.description" class="input"></textarea>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('description')"/>
|
||||
<textarea id="descriptionFetched" [(ngModel)]="fetchedMetadata.description" class="input"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label class="label"></label>
|
||||
<div class="input-container">
|
||||
<img *ngIf="!updateThumbnail" [src]="coverImageSrc(book)" alt="Book Thumbnail" class="thumbnail"/>
|
||||
<img *ngIf="updateThumbnail" [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="shouldUpdateThumbnail()"/>
|
||||
<img [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
</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"></p-button>
|
||||
<p-button label="Save" icon="pi pi-check" severity="primary" [disabled]="loading" (onClick)="saveMetadata()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
+1
-15
@@ -1,18 +1,4 @@
|
||||
.button-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
padding: 1.25rem;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.cancel-button {
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
@@ -23,7 +9,7 @@
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 8rem;
|
||||
width: 6rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
+26
-19
@@ -1,29 +1,41 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Book, BookMetadata, FetchedMetadata} from '../book/model/book.model';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {BookService} from '../book/service/book.service';
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Book, 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 {FormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {Divider} from 'primeng/divider';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-searcher',
|
||||
standalone: false,
|
||||
standalone: true,
|
||||
templateUrl: './metadata-searcher.component.html',
|
||||
imports: [
|
||||
Button,
|
||||
FormsModule,
|
||||
InputText,
|
||||
NgIf,
|
||||
Divider
|
||||
],
|
||||
styleUrls: ['./metadata-searcher.component.scss']
|
||||
})
|
||||
export class MetadataSearcherComponent {
|
||||
export class MetadataSearcherComponent implements OnInit {
|
||||
|
||||
fetchedMetadata: FetchedMetadata;
|
||||
toUpdateMetadata: FetchedMetadata;
|
||||
book: Book;
|
||||
@Input() fetchedMetadata!: FetchedMetadata;
|
||||
@Input() book!: Book;
|
||||
toUpdateMetadata!: FetchedMetadata;
|
||||
loading: boolean = false;
|
||||
updateThumbnail: boolean = false;
|
||||
|
||||
constructor(public dynamicDialogConfig: DynamicDialogConfig, private dynamicDialogRef: DynamicDialogRef,
|
||||
private bookService: BookService, private messageService: MessageService) {
|
||||
constructor(private bookService: BookService, private messageService: MessageService) {
|
||||
|
||||
this.fetchedMetadata = this.dynamicDialogConfig.data.fetchedMetadata;
|
||||
this.toUpdateMetadata = this.convertBookMetadataToFetchedMetadata(this.dynamicDialogConfig.data.currentMetadata);
|
||||
this.book = this.dynamicDialogConfig.data.book;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.log(this.book)
|
||||
this.toUpdateMetadata = this.convertBookMetadataToFetchedMetadata(this.book!.metadata!);
|
||||
}
|
||||
|
||||
copyFetchedToCurrent(field: keyof FetchedMetadata) {
|
||||
@@ -64,10 +76,6 @@ export class MetadataSearcherComponent {
|
||||
this.fetchedMetadata.categories = value.split(',');
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
|
||||
coverImageSrc(book: Book): string {
|
||||
return this.bookService.getBookCoverUrl(book.id);
|
||||
}
|
||||
@@ -79,7 +87,6 @@ export class MetadataSearcherComponent {
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
this.loading = false;
|
||||
this.dynamicDialogRef.close();
|
||||
},
|
||||
error: (error) => {
|
||||
this.loading = false;
|
||||
@@ -11,6 +11,7 @@ import {CheckboxModule} from 'primeng/checkbox';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookInfoTabsComponent} from '../../../book-info-tabs/book-info-tabs.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-card',
|
||||
@@ -74,13 +75,36 @@ export class BookCardComponent implements OnInit {
|
||||
{
|
||||
label: 'View metadata',
|
||||
icon: 'pi pi-info-circle',
|
||||
command: () => this.openBookInfo(this.book),
|
||||
command: () => this.openBookDetailsDialog(this.book.id),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
openBookDetailsDialog(bookId: number): void {
|
||||
this.bookService.getBookByIdFromAPI(bookId, true).subscribe(({
|
||||
next: (book) => {
|
||||
console.log(book)
|
||||
this.dialogService.open(BookInfoTabsComponent, {
|
||||
header: 'Open book details',
|
||||
modal: true,
|
||||
closable: true,
|
||||
width: '1200px',
|
||||
height: '835px',
|
||||
showHeader: false,
|
||||
closeOnEscape: true,
|
||||
data: {
|
||||
book: book
|
||||
}
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error fetching book:', error);
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
private openShelfDialog(book: Book): void {
|
||||
this.dialogService.open(ShelfAssignerComponent, {
|
||||
header: `Update Shelves: ${book.metadata?.title}`,
|
||||
|
||||
@@ -8,7 +8,7 @@ import {forkJoin, Subscription} from 'rxjs';
|
||||
import {TagModule} from 'primeng/tag';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {MetadataSearcherComponent} from '../../../metadata-searcher/metadata-searcher.component';
|
||||
import {MetadataSearcherComponent} from '../../../book-info-tabs/metadata-searcher/metadata-searcher.component';
|
||||
import {LoadingService} from '../../../loading.service';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
<div class="form-row">
|
||||
<label for="title" class="label">Title</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="title" [(ngModel)]="toUpdateMetadata.title" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('title')"/>
|
||||
<input pInputText id="titleFetched" [(ngModel)]="fetchedMetadata.title" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="authors" class="label">Authors</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="authors" [(ngModel)]="currentAuthorsString" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('authors')"/>
|
||||
<input pInputText id="authorsFetched" [(ngModel)]="fetchedAuthorsString" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="categories" class="label">Categories</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="categories" [(ngModel)]="currentCategoriesString" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('categories')"/>
|
||||
<input pInputText id="categoriesFetched" [(ngModel)]="fetchedCategoriesString" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="publisher" class="label">Publisher</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="publisher" [(ngModel)]="toUpdateMetadata.publisher" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('publisher')"/>
|
||||
<input pInputText id="publisherFetched" [(ngModel)]="fetchedMetadata.publisher" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="publishedDate" class="label">Published Date</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="publishedDate" [(ngModel)]="toUpdateMetadata.publishedDate" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('publishedDate')"/>
|
||||
<input pInputText id="publishedDateFetched" [(ngModel)]="fetchedMetadata.publishedDate" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="isbn10" class="label">ISBN-10</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="isbn10" [(ngModel)]="toUpdateMetadata.isbn10" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('isbn10')"/>
|
||||
<input pInputText id="isbn10Fetched" [(ngModel)]="fetchedMetadata.isbn10" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="language" class="label">Language</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="language" [(ngModel)]="toUpdateMetadata.language" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('language')"/>
|
||||
<input pInputText id="languageFetched" [(ngModel)]="fetchedMetadata.language" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="language" class="label">Page Count</label>
|
||||
<div class="input-container">
|
||||
<input pInputText id="pageCount" [(ngModel)]="toUpdateMetadata.pageCount" class="input"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('pageCount')"/>
|
||||
<input pInputText id="pageCountFetched" [(ngModel)]="fetchedMetadata.pageCount" class="input"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="description" class="label">Description</label>
|
||||
<div class="input-container">
|
||||
<textarea id="description" [(ngModel)]="toUpdateMetadata.description" class="input"></textarea>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="copyFetchedToCurrent('description')"/>
|
||||
<textarea id="descriptionFetched" [(ngModel)]="fetchedMetadata.description" class="input"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label class="label"></label>
|
||||
<div class="input-container">
|
||||
<img *ngIf="!updateThumbnail" [src]="coverImageSrc(book)" alt="Book Thumbnail" class="thumbnail"/>
|
||||
<img *ngIf="updateThumbnail" [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
<p-button icon="pi pi-arrow-left" [outlined]="true" class="arrow-button" (click)="shouldUpdateThumbnail()"/>
|
||||
<img [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="button-container">
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary" class="cancel-button" (onClick)="closeDialog()"></p-button>
|
||||
<p-button label="Save" icon="pi pi-check" severity="primary" class="save-button" [disabled]="loading" (onClick)="saveMetadata()"></p-button>
|
||||
</div>
|
||||
Reference in New Issue
Block a user