Feature/999 add high resolution cover support upload storage and search (#1006)
* Add high-resolution cover support: upload, storage, and search * Disable tests until fixed
This commit is contained in:
+15
-30
@@ -1,32 +1,17 @@
|
||||
import { Component, inject, OnDestroy, OnInit, Optional } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { UserService } from '../../settings/user-management/user.service';
|
||||
import { Book, BookRecommendation } from '../../book/model/book.model';
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import {
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
map,
|
||||
shareReplay,
|
||||
switchMap,
|
||||
takeUntil,
|
||||
tap,
|
||||
take,
|
||||
} from 'rxjs/operators';
|
||||
import { BookService } from '../../book/service/book.service';
|
||||
import { AppSettingsService } from '../../core/service/app-settings.service';
|
||||
import {
|
||||
Tab,
|
||||
TabList,
|
||||
TabPanel,
|
||||
TabPanels,
|
||||
Tabs,
|
||||
} from 'primeng/tabs';
|
||||
import { MetadataViewerComponent } from './metadata-viewer/metadata-viewer.component';
|
||||
import { MetadataEditorComponent } from './metadata-editor/metadata-editor.component';
|
||||
import { MetadataSearcherComponent } from './metadata-searcher/metadata-searcher.component';
|
||||
import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
|
||||
import { BookMetadataHostService } from '../../utilities/service/book-metadata-host-service';
|
||||
import {Component, inject, OnDestroy, OnInit, Optional} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {UserService} from '../../settings/user-management/user.service';
|
||||
import {Book, BookRecommendation} from '../../book/model/book.model';
|
||||
import {BehaviorSubject, Observable, Subject} from 'rxjs';
|
||||
import {distinctUntilChanged, filter, map, shareReplay, switchMap, take, takeUntil,} from 'rxjs/operators';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {AppSettingsService} from '../../core/service/app-settings.service';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs,} from 'primeng/tabs';
|
||||
import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component';
|
||||
import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component';
|
||||
import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {BookMetadataHostService} from '../../utilities/service/book-metadata-host-service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-metadata-center',
|
||||
@@ -40,7 +25,7 @@ import { BookMetadataHostService } from '../../utilities/service/book-metadata-h
|
||||
TabPanel,
|
||||
MetadataViewerComponent,
|
||||
MetadataEditorComponent,
|
||||
MetadataSearcherComponent,
|
||||
MetadataSearcherComponent
|
||||
],
|
||||
styleUrls: ['./book-metadata-center.component.scss'],
|
||||
})
|
||||
|
||||
+142
-172
@@ -8,18 +8,21 @@
|
||||
}
|
||||
<div class="flex-grow overflow-auto md:py-2 md:px-2 ">
|
||||
<div class="flex flex-col md:flex-row w-full gap-4">
|
||||
<div class="flex flex-col items-center gap-4 relative">
|
||||
<img
|
||||
[attr.src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
<div class="flex flex-col items-center gap-0 relative">
|
||||
<p-image
|
||||
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
alt="Image"
|
||||
[ngClass]="{ 'brightness-50': isUploading }"
|
||||
class="w-[200px] md:w-[250px] transition-all duration-300 ease-in-out"/>
|
||||
width="250"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
@if (isUploading) {
|
||||
<p-progressSpinner
|
||||
class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-10">
|
||||
</p-progressSpinner>
|
||||
}
|
||||
<div class="flex items-center gap-6">
|
||||
<div class="flex items-center gap-2 pt-4">
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
(onClick)="regenerateCover(book.id)"
|
||||
@@ -27,9 +30,22 @@
|
||||
tooltipPosition="top"
|
||||
[outlined]="true"
|
||||
severity="warn"
|
||||
size="small"
|
||||
[disabled]="book.metadata!['coverLocked']">
|
||||
</p-button>
|
||||
<p-button
|
||||
[disabled]="book.metadata!['coverLocked']"
|
||||
outlined
|
||||
size="small"
|
||||
icon="pi pi-search"
|
||||
label="Search"
|
||||
(onClick)="openCoverSearch()"
|
||||
pTooltip="Search for cover"
|
||||
tooltipPosition="top"
|
||||
severity="info">
|
||||
</p-button>
|
||||
<p-fileupload
|
||||
[chooseStyleClass]="'p-button-sm p-button-outlined'"
|
||||
pTooltip="Upload cover"
|
||||
tooltipPosition="top"
|
||||
[disabled]="book.metadata!['coverLocked']"
|
||||
@@ -39,17 +55,17 @@
|
||||
chooseIcon="pi pi-upload"
|
||||
accept="image/jpeg,image/png"
|
||||
maxFileSize="5000000"
|
||||
chooseLabel="Cover"
|
||||
chooseLabel="Upload"
|
||||
(onUpload)="onUpload($event)"
|
||||
(onError)="onUploadError($event)"
|
||||
[auto]="true"
|
||||
(onBeforeUpload)="onBeforeSend()">
|
||||
</p-fileupload>
|
||||
@if (!book.metadata!['coverLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
|
||||
<p-button pTooltip="Lock Cover" tooltipPosition="top" size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['coverLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
|
||||
<p-button pTooltip="Unlock Cover" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -57,26 +73,26 @@
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 pb-1">
|
||||
<div class="flex flex-col gap-1 md:w-2/3">
|
||||
<label for="title">Title</label>
|
||||
<label class="text-sm" for="title">Title</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="title" formControlName="title" class="w-full"/>
|
||||
<input pSize="small" pInputText id="title" formControlName="title" class="w-full"/>
|
||||
@if (!book.metadata!['titleLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('title')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('title')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['titleLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('title')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('title')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/3">
|
||||
<label for="subtitle">Subtitle</label>
|
||||
<label class="text-sm" for="subtitle">Subtitle</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="subtitle" formControlName="subtitle" class="w-full"/>
|
||||
<input pSize="small" pInputText id="subtitle" formControlName="subtitle" class="w-full"/>
|
||||
@if (!book.metadata!['subtitleLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['subtitleLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -84,40 +100,40 @@
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 md:basis-[71%]">
|
||||
<label for="authors">Authors</label>
|
||||
<label class="text-sm" for="authors">Authors</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<div class="w-full">
|
||||
<p-autoComplete formControlName="authors" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" [showClear]="true" (onBlur)="onAutoCompleteBlur('authors', $event)" styleClass="w-full"></p-autoComplete>
|
||||
</div>
|
||||
@if (!book.metadata!['authorsLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('authors')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('authors')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['authorsLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('authors')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('authors')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:basis-[20%]">
|
||||
<label for="publisher">Publisher</label>
|
||||
<label class="text-sm" for="publisher">Publisher</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="publisher" formControlName="publisher" class="w-full"/>
|
||||
<input pSize="small" pInputText id="publisher" formControlName="publisher" class="w-full"/>
|
||||
@if (!book.metadata!['publisherLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publisher')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publisher')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['publisherLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publisher')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publisher')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:basis-[14%]">
|
||||
<label for="language">Language</label>
|
||||
<label class="text-sm" for="language">Language</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="language" formControlName="language" class="w-full"/>
|
||||
<input pSize="small" pInputText id="language" formControlName="language" class="w-full"/>
|
||||
@if (!book.metadata!['languageLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('language')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('language')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['languageLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('language')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('language')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -125,16 +141,16 @@
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
<label for="categories">Categories</label>
|
||||
<label class="text-sm" for="categories">Categories</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<div class="w-full">
|
||||
<p-autoComplete formControlName="categories" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" [showClear]="true" (onBlur)="onAutoCompleteBlur('categories', $event)" styleClass="w-full"></p-autoComplete>
|
||||
</div>
|
||||
@if (!book.metadata!['categoriesLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('categories')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('categories')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['categoriesLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('categories')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('categories')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,66 +158,66 @@
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 md:basis-[75%]">
|
||||
<label for="seriesName">Series Name</label>
|
||||
<label class="text-sm" for="seriesName">Series Name</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="seriesName" formControlName="seriesName" class="w-full"/>
|
||||
<input pSize="small" pInputText id="seriesName" formControlName="seriesName" class="w-full"/>
|
||||
@if (!book.metadata!['seriesNameLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['seriesNameLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 md:basis-[10%]">
|
||||
<label for="seriesNumber">Book #</label>
|
||||
<label class="text-sm" for="seriesNumber">Book #</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full min-w-12"/>
|
||||
<input pSize="small" pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full min-w-12"/>
|
||||
@if (!book.metadata!['seriesNumberLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['seriesNumberLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 md:basis-[10%]">
|
||||
<label for="seriesTotal">Total Books</label>
|
||||
<label class="text-sm" for="seriesTotal">Total Books</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full min-w-12"/>
|
||||
<input pSize="small" pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full min-w-12"/>
|
||||
@if (!book.metadata!['seriesTotalLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['seriesTotalLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 md:basis-[10%]">
|
||||
<label for="pageCount">Pages</label>
|
||||
<label class="text-sm" for="pageCount">Pages</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="pageCount" formControlName="pageCount" class="w-full min-w-16"/>
|
||||
<input pSize="small" pInputText id="pageCount" formControlName="pageCount" class="w-full min-w-16"/>
|
||||
@if (!book.metadata!['pageCountLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['pageCountLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 md:basis-[15%]">
|
||||
<label for="publishedDate">Publish Date</label>
|
||||
<label class="text-sm" for="publishedDate">Publish Date</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="publishedDate" formControlName="publishedDate" class="w-full min-w-32" />
|
||||
<input pSize="small" pInputText id="publishedDate" formControlName="publishedDate" class="w-full min-w-32"/>
|
||||
@if (!book.metadata!['publishedDateLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['publishedDateLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -209,74 +225,74 @@
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="isbn10">ISBN 10</label>
|
||||
<label class="text-sm" for="isbn10">ISBN 10</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="isbn10" formControlName="isbn10" class="w-full"/>
|
||||
<input pSize="small" pInputText id="isbn10" formControlName="isbn10" class="w-full"/>
|
||||
@if (!book.metadata!['isbn10Locked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['isbn10Locked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="isbn13">ISBN 13</label>
|
||||
<label class="text-sm" for="isbn13">ISBN 13</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="isbn13" formControlName="isbn13" class="w-full"/>
|
||||
<input pSize="small" pInputText id="isbn13" formControlName="isbn13" class="w-full"/>
|
||||
@if (!book.metadata!['isbn13Locked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['isbn13Locked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="asin">ASIN (Amazon ID)</label>
|
||||
<label class="text-sm" for="asin">ASIN (Amazon ID)</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="asin" formControlName="asin" class="w-full"/>
|
||||
<input pSize="small" pInputText id="asin" formControlName="asin" class="w-full"/>
|
||||
@if (!book.metadata!['asinLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['asinLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="amazonRating">Amazon ★</label>
|
||||
<label class="text-sm" for="amazonRating">Amazon ★</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
|
||||
<input pSize="small" pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
|
||||
@if (!book.metadata!['amazonRatingLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['amazonRatingLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="amazonRatingCount">Amazon Reviews</label>
|
||||
<label class="text-sm" for="amazonRatingCount">Amazon Reviews</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
|
||||
<input pSize="small" pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
|
||||
@if (!book.metadata!['amazonReviewCountLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['amazonReviewCountLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="googleId">Google Books ID</label>
|
||||
<label class="text-sm" for="googleId">Google Books ID</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="googleId" formControlName="googleId" class="w-full"/>
|
||||
<input pSize="small" pInputText id="googleId" formControlName="googleId" class="w-full"/>
|
||||
@if (!book.metadata!['googleIdLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('googleId')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('googleId')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['googleIdLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -284,155 +300,109 @@
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="goodreadsId">Goodreads ID</label>
|
||||
<label class="text-sm" for="goodreadsId">Goodreads ID</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="goodreadsId" formControlName="goodreadsId" class="w-full"/>
|
||||
<input pSize="small" pInputText id="goodreadsId" formControlName="goodreadsId" class="w-full"/>
|
||||
@if (!book.metadata!['goodreadsIdLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['goodreadsIdLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="goodreadsRating">Goodreads ★</label>
|
||||
<label class="text-sm" for="goodreadsRating">Goodreads ★</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
|
||||
<input pSize="small" pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
|
||||
@if (!book.metadata!['goodreadsRatingLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['goodreadsRatingLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="goodreadsReviewCount">Goodreads Reviews</label>
|
||||
<label class="text-sm" for="goodreadsReviewCount">Goodreads Reviews</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
|
||||
<input pSize="small" pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
|
||||
@if (!book.metadata!['goodreadsReviewCountLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['goodreadsReviewCountLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="hardcoverId">Hardcover ID</label>
|
||||
<label class="text-sm" for="hardcoverId">Hardcover ID</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="hardcoverId" formControlName="hardcoverId" class="w-full"/>
|
||||
<input pSize="small" pInputText id="hardcoverId" formControlName="hardcoverId" class="w-full"/>
|
||||
@if (!book.metadata!['hardcoverIdLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['hardcoverIdLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="hardcoverRating">Hardcover ★</label>
|
||||
<label class="text-sm" for="hardcoverRating">Hardcover ★</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="hardcoverRating" formControlName="hardcoverRating" class="w-full"/>
|
||||
<input pSize="small" pInputText id="hardcoverRating" formControlName="hardcoverRating" class="w-full"/>
|
||||
@if (!book.metadata!['hardcoverRatingLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['hardcoverRatingLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label for="hardcoverReviewCount">Hardcover Reviews</label>
|
||||
<label class="text-sm" for="hardcoverReviewCount">Hardcover Reviews</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/>
|
||||
<input pSize="small" pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/>
|
||||
@if (!book.metadata!['hardcoverReviewCountLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['hardcoverReviewCountLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="comicvineId">Comicvine ID</label>
|
||||
<label class="text-sm" for="comicvineId">Comicvine ID</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="comicvineId" formControlName="comicvineId" class="w-full"/>
|
||||
<input pSize="small" pInputText id="comicvineId" formControlName="comicvineId" class="w-full"/>
|
||||
@if (!book.metadata!['comicvineIdLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="success"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['comicvineIdLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="warn"></p-button>
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row w-full pb-1">
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<p-tabs value="editor" class="w-full">
|
||||
<p-tablist>
|
||||
<p-tab value="editor">WYSIWYG Editor</p-tab>
|
||||
<p-tab value="html">HTML Editor</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels class="custom-tab-padding">
|
||||
<p-tabpanel value="editor">
|
||||
<form [formGroup]="metadataForm">
|
||||
<p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '200px' }">
|
||||
<ng-template #header>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-bold" aria-label="Bold"></button>
|
||||
<button class="ql-italic" aria-label="Italic"></button>
|
||||
<button class="ql-underline" aria-label="Underline"></button>
|
||||
<button class="ql-strike" aria-label="Strikethrough"></button>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<select class="ql-size" aria-label="Font Size">
|
||||
<option value="small">Small</option>
|
||||
<option selected>Normal</option>
|
||||
<option value="large">Large</option>
|
||||
<option value="huge">Huge</option>
|
||||
</select>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-list" value="ordered" aria-label="Numbered List"></button>
|
||||
<button class="ql-list" value="bullet" aria-label="Bullet List"></button>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<select class="ql-color" aria-label="Text Color"></select>
|
||||
<select class="ql-background" aria-label="Background Color"></select>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-clean" aria-label="Remove Formatting"></button>
|
||||
</span>
|
||||
</ng-template>
|
||||
</p-editor>
|
||||
</form>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="html" class="w-full">
|
||||
<textarea
|
||||
class="w-full p-4"
|
||||
rows="9"
|
||||
[disabled]="quillDisabled()"
|
||||
[ngModel]="htmlTextarea"
|
||||
(ngModelChange)="onHtmlTextareaChange($event)"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
placeholder="Edit raw HTML here">
|
||||
</textarea>
|
||||
</p-tabpanel>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
@if (!book.metadata!['descriptionLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['descriptionLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('description')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex pt-8 w-full justify-between items-center gap-2">
|
||||
<p-iftalabel class="flex w-full">
|
||||
<textarea
|
||||
id="description"
|
||||
pTextarea
|
||||
formControlName="description"
|
||||
rows="12"
|
||||
class="w-full">
|
||||
</textarea>
|
||||
<label for="description">Description</label>
|
||||
</p-iftalabel>
|
||||
@if (!book.metadata!['descriptionLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['descriptionLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('description')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-auto">
|
||||
@@ -444,7 +414,7 @@
|
||||
@if (showNavigationButtons) {
|
||||
<div class="flex gap-x-4">
|
||||
<p-button label="Close" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()"></p-button>
|
||||
<p-divider layout="vertical" />
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button label="Previous Book" [disabled]="disablePrevious" icon="pi pi-arrow-left" [outlined]="true" severity="info" (onClick)="onPrevious()"></p-button>
|
||||
<p-button label="Next Book" [disabled]="disableNext" icon="pi pi-arrow-right" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()"></p-button>
|
||||
</div>
|
||||
@@ -464,12 +434,12 @@
|
||||
|
||||
@if (book.bookType === 'PDF' || book.bookType === 'EPUB') {
|
||||
<p-button label="Restore" icon="pi pi-refresh" [outlined]="true" severity="danger" (onClick)="restoreMetadata()" pTooltip="Revert all changes to original metadata" tooltipPosition="top"></p-button>
|
||||
<p-divider layout="vertical" />
|
||||
<p-divider layout="vertical"/>
|
||||
}
|
||||
|
||||
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()" pTooltip="Unlock all metadata fields for editing" tooltipPosition="top"></p-button>
|
||||
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()" pTooltip="Lock all metadata fields to prevent changes" tooltipPosition="top"></p-button>
|
||||
<p-divider layout="vertical" />
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button label="Save" icon="pi pi-check" [loading]="isSaving" [disabled]="isSaving" type="submit"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -478,9 +448,9 @@
|
||||
<div class="flex sm:hidden justify-between w-full flex-wrap">
|
||||
@if (showNavigationButtons) {
|
||||
<div class="flex gap-2 flex-wrap">
|
||||
<p-button icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()" pTooltip="Close" tooltipPosition="top"></p-button>
|
||||
<p-button icon="pi pi-arrow-left" [disabled]="disablePrevious" [outlined]="true" severity="info" (onClick)="onPrevious()" pTooltip="Previous Book" tooltipPosition="top"></p-button>
|
||||
<p-button icon="pi pi-arrow-right" [disabled]="disableNext" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()" pTooltip="Next Book" tooltipPosition="top"></p-button>
|
||||
<p-button size="small" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()" pTooltip="Close" tooltipPosition="top"></p-button>
|
||||
<p-button size="small" icon="pi pi-arrow-left" [disabled]="disablePrevious" [outlined]="true" severity="info" (onClick)="onPrevious()" pTooltip="Previous Book" tooltipPosition="top"></p-button>
|
||||
<p-button size="small" icon="pi pi-arrow-right" [disabled]="disableNext" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()" pTooltip="Next Book" tooltipPosition="top"></p-button>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -5,3 +5,7 @@
|
||||
padding: var(--p-tabs-tabpanel-padding) !important;
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep .p-autocomplete .p-chip .p-chip-label {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
+38
-22
@@ -4,7 +4,7 @@ import {Button} from 'primeng/button';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AsyncPipe, NgClass} from '@angular/common';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../book/model/book.model';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
@@ -15,13 +15,17 @@ import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {Editor} from 'primeng/editor';
|
||||
import {debounceTime} from 'rxjs/operators';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {MetadataRestoreDialogComponent} from '../../../book/components/book-browser/metadata-restore-dialog-component/metadata-restore-dialog-component';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
|
||||
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
||||
import {AutoComplete} from 'primeng/autocomplete';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
import {IftaLabel} from 'primeng/iftalabel';
|
||||
import {CoverSearchComponent} from '../../cover-search/cover-search.component';
|
||||
import {Image} from 'primeng/image';
|
||||
import {LazyLoadImageModule} from 'ng-lazyload-image';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-editor',
|
||||
@@ -37,15 +41,12 @@ import {AutoComplete} from 'primeng/autocomplete';
|
||||
ReactiveFormsModule,
|
||||
FileUpload,
|
||||
ProgressSpinner,
|
||||
NgClass,
|
||||
Tooltip,
|
||||
Editor,
|
||||
Tabs,
|
||||
TabList,
|
||||
Tab,
|
||||
TabPanels,
|
||||
TabPanel,
|
||||
AutoComplete
|
||||
AutoComplete,
|
||||
Textarea,
|
||||
IftaLabel,
|
||||
Image,
|
||||
LazyLoadImageModule
|
||||
]
|
||||
})
|
||||
export class MetadataEditorComponent implements OnInit {
|
||||
@@ -85,7 +86,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
if (inputValue) {
|
||||
const currentValue = this.metadataForm.get(fieldName)?.value || [];
|
||||
const values = Array.isArray(currentValue) ? currentValue :
|
||||
typeof currentValue === 'string' && currentValue ? currentValue.split(',').map((v: string) => v.trim()) : [];
|
||||
typeof currentValue === 'string' && currentValue ? currentValue.split(',').map((v: string) => v.trim()) : [];
|
||||
|
||||
// Add the new value if it's not already in the array
|
||||
if (!values.includes(inputValue)) {
|
||||
@@ -125,6 +126,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
seriesName: new FormControl(''),
|
||||
seriesNumber: new FormControl(''),
|
||||
seriesTotal: new FormControl(''),
|
||||
thumbnailUrl: new FormControl(''),
|
||||
|
||||
titleLocked: new FormControl(false),
|
||||
subtitleLocked: new FormControl(false),
|
||||
@@ -346,17 +348,6 @@ export class MetadataEditorComponent implements OnInit {
|
||||
return this.metadataForm.get('descriptionLocked')?.value === true;
|
||||
}
|
||||
|
||||
onHtmlTextareaChange(value: string): void {
|
||||
this.htmlTextarea = value;
|
||||
const control = this.metadataForm.get('description');
|
||||
if (control?.value !== value) {
|
||||
control?.patchValue(value, {emitEvent: false});
|
||||
if (this.quillEditor && this.quillEditor.quill) {
|
||||
this.quillEditor.quill.root.innerHTML = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private buildMetadataWrapper(shouldLockAllFields?: boolean): MetadataUpdateWrapper {
|
||||
const form = this.metadataForm;
|
||||
|
||||
@@ -390,6 +381,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
seriesName: form.get('seriesName')?.value,
|
||||
seriesNumber: form.get('seriesNumber')?.value,
|
||||
seriesTotal: form.get('seriesTotal')?.value,
|
||||
thumbnailUrl: form.get('thumbnailUrl')?.value,
|
||||
|
||||
// Locks
|
||||
titleLocked: form.get('titleLocked')?.value,
|
||||
@@ -577,4 +569,28 @@ export class MetadataEditorComponent implements OnInit {
|
||||
closeDialog() {
|
||||
this.closeDialogButtonClicked.emit();
|
||||
}
|
||||
|
||||
openCoverSearch() {
|
||||
const ref = this.dialogService.open(CoverSearchComponent, {
|
||||
header: 'Search Cover',
|
||||
modal: true,
|
||||
closable: true,
|
||||
data: {
|
||||
bookId: [this.currentBookId]
|
||||
},
|
||||
style: {
|
||||
width: '90vw',
|
||||
height: '90vh',
|
||||
maxWidth: '1200px',
|
||||
position: 'absolute'
|
||||
},
|
||||
});
|
||||
|
||||
ref.onClose.subscribe(result => {
|
||||
if (result) {
|
||||
this.metadataForm.get('thumbnailUrl')?.setValue(result);
|
||||
this.onSave();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+16
-2
@@ -28,7 +28,14 @@
|
||||
@if (book.metadata!['coverLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
|
||||
}
|
||||
<img [src]="metadataForm.get('thumbnailUrl')?.value" alt="Book Thumbnail" class="thumbnail"/>
|
||||
<p-image
|
||||
class="thumbnail"
|
||||
[src]="metadataForm.get('thumbnailUrl')?.value"
|
||||
alt="Image"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
<input type="hidden" id="thumbnailUrl" formControlName="thumbnailUrl" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : (hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||
@@ -44,7 +51,14 @@
|
||||
(mouseenter)="onMouseEnter('thumbnailUrl')"
|
||||
(mouseleave)="onMouseLeave('thumbnailUrl')"/>
|
||||
<input type="hidden" [value]="fetchedMetadata.thumbnailUrl" class="input" readonly/>
|
||||
<img [src]="fetchedMetadata.thumbnailUrl ?? null" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
<p-image
|
||||
class="thumbnail"
|
||||
[src]="fetchedMetadata.thumbnailUrl!"
|
||||
alt="Image"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
</div>
|
||||
</div>
|
||||
@for (field of metadataFieldsTop; track field) {
|
||||
|
||||
+6
-2
@@ -14,6 +14,8 @@ import {Textarea} from 'primeng/textarea';
|
||||
import {filter, map} from 'rxjs/operators';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {AutoComplete} from 'primeng/autocomplete';
|
||||
import {Image} from 'primeng/image';
|
||||
import {LazyLoadImageModule} from 'ng-lazyload-image';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-picker',
|
||||
@@ -31,7 +33,9 @@ import {AutoComplete} from 'primeng/autocomplete';
|
||||
Tooltip,
|
||||
AsyncPipe,
|
||||
Textarea,
|
||||
AutoComplete
|
||||
AutoComplete,
|
||||
Image,
|
||||
LazyLoadImageModule
|
||||
]
|
||||
})
|
||||
export class MetadataPickerComponent implements OnInit {
|
||||
@@ -183,7 +187,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
|
||||
if (metadata) {
|
||||
this.originalMetadata = metadata;
|
||||
this.originalMetadata.thumbnailUrl = this.urlHelper.getCoverUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||
this.originalMetadata.thumbnailUrl = this.urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||
this.currentBookId = metadata.bookId;
|
||||
this.metadataForm.patchValue({
|
||||
title: metadata.title || null,
|
||||
|
||||
+10
-8
@@ -4,12 +4,14 @@
|
||||
|
||||
<div class="flex justify-center md:justify-start">
|
||||
<div class="relative w-[175px] md:w-[250px]">
|
||||
<img
|
||||
[attr.src]="urlHelper.getCoverUrl(book?.metadata!.bookId, book?.metadata!.coverUpdatedOn)"
|
||||
class="rounded-lg w-full object-cover"
|
||||
alt="Cover of {{ book?.metadata!.title }}"
|
||||
loading="lazy"
|
||||
/>
|
||||
|
||||
<p-image
|
||||
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
alt="Image"
|
||||
width="250"
|
||||
appendTo="body"
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
|
||||
@if (book?.metadata!.seriesNumber != null) {
|
||||
<div class="absolute top-2 left-2 bg-black/60 text-white px-2 py-0.5 rounded-lg text-xs font-semibold">
|
||||
@@ -226,7 +228,7 @@
|
||||
}
|
||||
|
||||
<div class="px-1 md:px-0">
|
||||
<div class="grid md:grid-cols-4 gap-y-2.5 text-sm pt-2 md:pt-4 pb-2 text-gray-300 min-w-[60rem] max-w-[100rem]">
|
||||
<div class="grid md:grid-cols-4 gap-y-2.5 text-sm pt-2 md:pt-4 pb-2 text-gray-300 md:min-w-[60rem] md:max-w-[100rem]">
|
||||
<p class="whitespace-nowrap max-w-[250px] overflow-hidden text-ellipsis">
|
||||
<span class="font-bold">Publisher: </span>
|
||||
@if (book?.metadata?.publisher) {
|
||||
@@ -477,7 +479,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-4 pb-2 pt-4 mb-6 mx-2 border border-[var(--border-color)] rounded-xl">
|
||||
<div class="px-4 pb-2 pt-4 mb-4 md:mb-6 md:mx-2 border border-[var(--border-color)] rounded-xl">
|
||||
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }" class="transition-all duration-300 overflow-hidden description-container">
|
||||
<div class="readonly-editor px-2">
|
||||
<p-editor #quillEditor [readonly]="true" [style]="{height: '200px'}" [(ngModel)]="book.metadata!.description">
|
||||
|
||||
+10
-8
@@ -6,7 +6,7 @@ import {BookService} from '../../../book/service/book.service';
|
||||
import {Rating, RatingRateEvent} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Book, BookMetadata, BookRecommendation, ReadStatus, FileInfo} from '../../../book/model/book.model';
|
||||
import {Book, BookMetadata, BookRecommendation, FileInfo, ReadStatus} from '../../../book/model/book.model';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {SplitButton} from 'primeng/splitbutton';
|
||||
@@ -33,15 +33,17 @@ import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {BookReviewsComponent} from '../../../book/components/book-reviews/book-reviews.component';
|
||||
import {BookNotesComponent} from '../../../book/components/book-notes-component/book-notes-component';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
|
||||
import {TieredMenu} from 'primeng/tieredmenu';
|
||||
import {AdditionalFileUploaderComponent} from '../../../book/components/additional-file-uploader/additional-file-uploader.component';
|
||||
import {Image} from 'primeng/image';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-viewer.component.html',
|
||||
styleUrl: './metadata-viewer.component.scss',
|
||||
imports: [Button, AsyncPipe, Rating, FormsModule, Tag, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, InfiniteScrollDirective, BookCardLiteComponent, DatePicker, Tab, TabList, TabPanel, TabPanels, Tabs, BookReviewsComponent, BookNotesComponent, ProgressSpinner, TieredMenu]
|
||||
imports: [Button, AsyncPipe, Rating, FormsModule, Tag, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, InfiniteScrollDirective, BookCardLiteComponent, DatePicker, Tab, TabList, TabPanel, TabPanels, Tabs, BookReviewsComponent, BookNotesComponent, ProgressSpinner, TieredMenu, Image]
|
||||
})
|
||||
export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
@Input() book$!: Observable<Book | null>;
|
||||
@@ -140,7 +142,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
this.downloadMenuItems$ = this.book$.pipe(
|
||||
filter((book): book is Book => book !== null &&
|
||||
((book.alternativeFormats !== undefined && book.alternativeFormats.length > 0) ||
|
||||
(book.supplementaryFiles !== undefined && book.supplementaryFiles.length > 0))),
|
||||
(book.supplementaryFiles !== undefined && book.supplementaryFiles.length > 0))),
|
||||
map((book): MenuItem[] => {
|
||||
const items: MenuItem[] = [];
|
||||
|
||||
@@ -158,8 +160,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
// Add separator if both types exist
|
||||
if (book.alternativeFormats && book.alternativeFormats.length > 0 &&
|
||||
book.supplementaryFiles && book.supplementaryFiles.length > 0) {
|
||||
items.push({ separator: true });
|
||||
book.supplementaryFiles && book.supplementaryFiles.length > 0) {
|
||||
items.push({separator: true});
|
||||
}
|
||||
|
||||
// Add supplementary files
|
||||
@@ -229,7 +231,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
// Add delete additional files menu if there are any additional files
|
||||
if ((book.alternativeFormats && book.alternativeFormats.length > 0) ||
|
||||
(book.supplementaryFiles && book.supplementaryFiles.length > 0)) {
|
||||
(book.supplementaryFiles && book.supplementaryFiles.length > 0)) {
|
||||
const deleteFileItems: MenuItem[] = [];
|
||||
|
||||
// Add alternative formats
|
||||
@@ -246,8 +248,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
// Add separator if both types exist
|
||||
if (book.alternativeFormats && book.alternativeFormats.length > 0 &&
|
||||
book.supplementaryFiles && book.supplementaryFiles.length > 0) {
|
||||
deleteFileItems.push({ separator: true });
|
||||
book.supplementaryFiles && book.supplementaryFiles.length > 0) {
|
||||
deleteFileItems.push({separator: true});
|
||||
}
|
||||
|
||||
// Add supplementary files
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<div class="cover-search-container">
|
||||
<div class="search-section">
|
||||
<form [formGroup]="searchForm" (ngSubmit)="onSearch()">
|
||||
<div class="form-grid">
|
||||
<div class="form-field">
|
||||
<label for="title">Title *</label>
|
||||
<input
|
||||
pInputText
|
||||
id="title"
|
||||
formControlName="title"
|
||||
placeholder="Enter book title"
|
||||
/>
|
||||
@if (searchForm.get('title')?.invalid && searchForm.get('title')?.touched) {
|
||||
<small class="error-message">
|
||||
Title is required
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="author">Author</label>
|
||||
<input
|
||||
pInputText
|
||||
id="author"
|
||||
formControlName="author"
|
||||
placeholder="Enter author name"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label> </label>
|
||||
<div class="button-group">
|
||||
<p-button
|
||||
type="submit"
|
||||
outlined
|
||||
label="Search Covers"
|
||||
icon="pi pi-search"
|
||||
[loading]="loading"
|
||||
[disabled]="searchForm.invalid">
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
type="button"
|
||||
label="Clear"
|
||||
icon="pi pi-times"
|
||||
(click)="onClear()"
|
||||
styleClass="p-button-secondary p-button-outlined">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@if (hasSearched) {
|
||||
<div class="results-section">
|
||||
@if (loading) {
|
||||
<div class="loading-container">
|
||||
<p-progressSpinner></p-progressSpinner>
|
||||
<p>Searching for book covers...</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!loading && coverImages.length === 0) {
|
||||
<div class="no-results">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<p>No cover images found. Try adjusting your search terms.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!loading && coverImages.length > 0) {
|
||||
<div class="covers-grid">
|
||||
@for (cover of coverImages; track cover.url; let i = $index) {
|
||||
<div class="cover-item">
|
||||
<p-image
|
||||
[src]="cover.url"
|
||||
[alt]="'Book cover ' + (i + 1)"
|
||||
appendTo="body"
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
@if (cover.width && cover.height) {
|
||||
<div class="resolution-overlay">
|
||||
{{cover.width}} x {{cover.height}}
|
||||
</div>
|
||||
}
|
||||
<p-button
|
||||
class="select-button"
|
||||
(click)="selectAndSave(cover)"
|
||||
label="Pick & Save"
|
||||
severity="info"
|
||||
title="Select & Save this cover">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,148 @@
|
||||
.cover-search-container {
|
||||
margin: 0 auto;
|
||||
|
||||
.search-section {
|
||||
background: var(--surface-card);
|
||||
border: 1px solid var(--surface-border);
|
||||
border-radius: 8px;
|
||||
padding: 0 1.5rem 0 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
|
||||
h2 {
|
||||
margin: 0 0 1.5rem 0;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr auto;
|
||||
gap: 1rem;
|
||||
align-items: end;
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
label {
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: var(--red-500);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.results-section {
|
||||
padding: 0 1.5rem 0 1.5rem;
|
||||
|
||||
.loading-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 3rem;
|
||||
background: var(--surface-card);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--surface-border);
|
||||
|
||||
p {
|
||||
margin-top: 1rem;
|
||||
color: var(--text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.no-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 3rem;
|
||||
color: var(--text-color-secondary);
|
||||
background: var(--surface-card);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--surface-border);
|
||||
|
||||
i {
|
||||
font-size: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.covers-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||
gap: 1.5rem;
|
||||
padding: 1rem 0;
|
||||
|
||||
.cover-item {
|
||||
position: relative;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
padding: 4px;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.resolution-overlay {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
color: white;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.select-button {
|
||||
position: absolute !important;
|
||||
bottom: 8px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 120px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
z-index: 2;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&:hover .select-button {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.cover-search-container .search-section .form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
.form-field .button-group {
|
||||
justify-content: stretch;
|
||||
|
||||
::ng-deep .p-button {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
import {Component, inject, Input, OnInit} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||
import {BookCoverService, CoverFetchRequest, CoverImage} from '../../shared/services/book-cover.service';
|
||||
import {finalize} from 'rxjs/operators';
|
||||
import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Image} from 'primeng/image';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cover-search',
|
||||
templateUrl: './cover-search.component.html',
|
||||
imports: [
|
||||
Button,
|
||||
ReactiveFormsModule,
|
||||
FormsModule,
|
||||
InputText,
|
||||
ProgressSpinner,
|
||||
Image
|
||||
],
|
||||
styleUrls: ['./cover-search.component.scss']
|
||||
})
|
||||
export class CoverSearchComponent implements OnInit {
|
||||
@Input() bookId!: number;
|
||||
searchForm: FormGroup;
|
||||
coverImages: CoverImage[] = [];
|
||||
loading = false;
|
||||
hasSearched = false;
|
||||
showPreview = false;
|
||||
previewImageUrl = '';
|
||||
|
||||
private fb = inject(FormBuilder);
|
||||
private bookCoverService = inject(BookCoverService);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
protected dynamicDialogRef = inject(DynamicDialogRef);
|
||||
protected bookService = inject(BookService);
|
||||
|
||||
constructor() {
|
||||
this.searchForm = this.fb.group({
|
||||
title: ['', Validators.required],
|
||||
author: ['']
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.bookId = this.dynamicDialogConfig.data.bookId;
|
||||
let book = this.bookService.getBookByIdFromState(this.bookId);
|
||||
|
||||
if (book) {
|
||||
this.searchForm.patchValue({
|
||||
title: book.metadata?.title || '',
|
||||
author: book.metadata?.authors && book.metadata?.authors.length > 0 ? book.metadata?.authors[0] : ''
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onSearch() {
|
||||
if (this.searchForm.valid) {
|
||||
this.loading = true;
|
||||
const request: CoverFetchRequest = {
|
||||
title: this.searchForm.value.title,
|
||||
author: this.searchForm.value.author
|
||||
};
|
||||
|
||||
this.bookCoverService.fetchBookCovers(request)
|
||||
.pipe(finalize(() => this.loading = false))
|
||||
.subscribe({
|
||||
next: (images) => {
|
||||
console.log('API response received:', images);
|
||||
this.coverImages = images.sort((a, b) => a.index - b.index);
|
||||
this.hasSearched = true;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error fetching covers:', error);
|
||||
this.coverImages = [];
|
||||
this.hasSearched = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('Form invalid', {
|
||||
formErrors: this.searchForm.errors,
|
||||
titleErrors: this.searchForm.get('title')?.errors
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
selectAndSave(image: CoverImage) {
|
||||
this.dynamicDialogRef.close(image.url);
|
||||
}
|
||||
|
||||
previewImage(imageUrl: string) {
|
||||
this.previewImageUrl = imageUrl;
|
||||
this.showPreview = true;
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
closePreview() {
|
||||
this.showPreview = false;
|
||||
this.previewImageUrl = '';
|
||||
document.body.style.overflow = 'auto';
|
||||
}
|
||||
|
||||
onImageError(event: Event) {
|
||||
const target = event.target as HTMLImageElement;
|
||||
if (target) {
|
||||
target.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
onClear() {
|
||||
this.searchForm.reset();
|
||||
this.coverImages = [];
|
||||
this.hasSearched = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user