Migrate existing control flow directives to use new control-flow schematic

This commit is contained in:
aditya.chandel
2025-06-05 18:18:10 -06:00
committed by Aditya Chandel
parent 246efdaa34
commit 0f852ef068
86 changed files with 2567 additions and 2173 deletions
@@ -2,35 +2,47 @@
<div class="flex flex-col flex-grow">
<div class="flex justify-between items-center p-2 rounded-t-xl mb-4 bg-[var(--card-background)]">
<div class="flex items-center pl-2">
<ng-container *ngIf="entityType$ | async as entityType">
<p *ngIf="entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
{{ entityType }}: {{ (entity$ | async)?.name }}
</p>
<p *ngIf="entityType === EntityType.ALL_BOOKS" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
All Books
</p>
<p *ngIf="entityType === EntityType.UNSHELVED" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
Unshelved Books
</p>
<div *ngIf="userService.userState$ | async as userData">
<div *ngIf="entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED && (userData.permissions.admin || userData.permissions.canManipulateLibrary) ">
<p-button icon="pi pi-ellipsis-v" [rounded]="true" [text]="true" severity="info" (click)="entitymenu.toggle($event)"></p-button>
<p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu>
@if (entityType$ | async; as entityType) {
@if (entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
{{ entityType }}: {{ (entity$ | async)?.name }}
</p>
}
@if (entityType === EntityType.ALL_BOOKS) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
All Books
</p>
}
@if (entityType === EntityType.UNSHELVED) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
Unshelved Books
</p>
}
@if (userService.userState$ | async; as userData) {
<div>
@if (entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED && (userData.permissions.admin || userData.permissions.canManipulateLibrary) ) {
<div>
<p-button icon="pi pi-ellipsis-v" [rounded]="true" [text]="true" severity="info" (click)="entitymenu.toggle($event)"></p-button>
<p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu>
</div>
}
</div>
</div>
</ng-container>
}
}
</div>
<div class="flex items-center gap-8">
<div class="flex flex-row items-center gap-6">
<a *ngIf="isFilterActive" class="topbar-items topbar-item" (click)="clearFilter()">
<i
class="pi pi-filter-slash"
pTooltip="Clear applied filters"
tooltipPosition="top">
</i>
</a>
@if (isFilterActive) {
<a class="topbar-items topbar-item" (click)="clearFilter()">
<i
class="pi pi-filter-slash"
pTooltip="Clear applied filters"
tooltipPosition="top">
</i>
</a>
}
<div>
<a
@@ -38,7 +50,7 @@
(click)="sizeOverlay.toggle($event)"
pTooltip="Adjust grid item scale"
tooltipPosition="top"
>
>
<i class="pi pi-th-large"></i>
</a>
@@ -71,7 +83,9 @@
<ng-template pTemplate="item" let-item>
<div class="flex justify-between items-center px-4 py-2 cursor-pointer" (click)="sortBooks(item.field)">
<span>{{ item.label }}</span>
<i *ngIf="item.icon" [class]="item.icon"></i>
@if (item.icon) {
<i [class]="item.icon"></i>
}
</div>
</ng-template>
</p-menu>
@@ -96,16 +110,17 @@
[(ngModel)]="bookTitle"
(ngModelChange)="onSearchTermChange($event)"
class="search-input"
/>
<p-button
*ngIf="bookTitle"
icon="pi pi-times"
[text]="true"
size="small"
[rounded]="true"
class="absolute right-2 top-1/2 -translate-y-1/2"
(click)="clearSearch()">
</p-button>
/>
@if (bookTitle) {
<p-button
icon="pi pi-times"
[text]="true"
size="small"
[rounded]="true"
class="absolute right-2 top-1/2 -translate-y-1/2"
(click)="clearSearch()">
</p-button>
}
</div>
</p-fluid>
@@ -121,100 +136,118 @@
</div>
</div>
<div *ngIf="bookState$ | async as bookState">
<div *ngIf="!bookState?.loaded && !bookState?.error">
<p-progressSpinner></p-progressSpinner>
</div>
<div class="relative">
<div class="no-books-container" *ngIf="bookState?.error">
<p class="no-books-text">
{{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
</p>
</div>
<div class="no-books-container" *ngIf="!bookState?.error && bookState?.loaded && bookState?.books?.length === 0">
<p class="no-books-text">
This collection has no books!
</p>
</div>
<div class="book-card-container" *ngIf="bookState?.books as books">
<app-book-table *ngIf="currentViewMode === 'table' && books.length > 0" [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="selectedSort!"></app-book-table>
<virtual-scroller *ngIf="currentViewMode === 'grid'" class="virtual-scroller" #scroll [items]="books">
<div
class="grid"
#container
[ngStyle]="{'grid-template-columns': 'repeat(auto-fit, minmax(' + gridColumnMinWidth + ', 1fr))'}">
<div
class="virtual-scroller-item"
*ngFor="let book of scroll.viewPortItems"
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
<app-book-card
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
@if (bookState$ | async; as bookState) {
<div>
@if (!bookState?.loaded && !bookState?.error) {
<div>
<p-progressSpinner></p-progressSpinner>
</div>
}
<div class="relative">
@if (bookState?.error) {
<div class="no-books-container">
<p class="no-books-text">
{{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
</p>
</div>
}
@if (!bookState?.error && bookState?.loaded && bookState?.books?.length === 0) {
<div class="no-books-container">
<p class="no-books-text">
This collection has no books!
</p>
</div>
}
@if (bookState?.books; as books) {
<div class="book-card-container">
@if (currentViewMode === 'table' && books.length > 0) {
<app-book-table [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="selectedSort!"></app-book-table>
}
@if (currentViewMode === 'grid') {
<virtual-scroller class="virtual-scroller" #scroll [items]="books">
<div
class="grid"
#container
[ngStyle]="{'grid-template-columns': 'repeat(auto-fit, minmax(' + gridColumnMinWidth + ', 1fr))'}">
@for (book of scroll.viewPortItems; track book) {
<div
class="virtual-scroller-item"
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
<app-book-card
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
</div>
}
</div>
</virtual-scroller>
}
</div>
}
@if (selectedBooks.size > 0) {
<div class="book-browser-footer bg-[var(--card-background)] bg-opacity-10" [@slideInOut]>
<div class="flex justify-between gap-8">
@if (entityType$ | async; as entityType) {
@if (entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS || entityType === EntityType.UNSHELVED) {
<p-button
icon="pi pi-bookmark-fill"
outlined="true"
severity="info"
(onClick)="openShelfAssigner()"
pTooltip="Assign to shelf"
tooltipPosition="top">
</p-button>
}
@if (entityType === EntityType.SHELF) {
<p-button
icon="pi pi-bookmark"
outlined="true"
severity="info"
(click)="unshelfBooks()"
pTooltip="Remove from shelf"
tooltipPosition="top">
</p-button>
}
@if (userService.userState$ | async; as userData) {
<div>
@if (userData.permissions.canEditMetadata) {
<p-button
icon="pi pi-database"
outlined="true"
severity="info"
(click)="updateMetadata()"
pTooltip="Update metadata"
tooltipPosition="top">
</p-button>
}
</div>
}
<p-button
outlined="true"
icon="pi pi-lock"
severity="info"
(click)="lockUnlockMetadata()"
pTooltip="Lock/Unlock metadata"
tooltipPosition="top">
</p-button>
<p-button
outlined="true"
icon="pi pi-times"
severity="warn"
(click)="deselectAllBooks()"
pTooltip="Deselect all books"
tooltipPosition="top">
</p-button>
}
</div>
</div>
</virtual-scroller>
</div>
<div class="book-browser-footer bg-[var(--card-background)] bg-opacity-10" *ngIf="selectedBooks.size > 0" [@slideInOut]>
<div class="flex justify-between gap-8">
<ng-container *ngIf="entityType$ | async as entityType">
<p-button
*ngIf="entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS || entityType === EntityType.UNSHELVED"
icon="pi pi-bookmark-fill"
outlined="true"
severity="info"
(onClick)="openShelfAssigner()"
pTooltip="Assign to shelf"
tooltipPosition="top">
</p-button>
<p-button
*ngIf="entityType === EntityType.SHELF"
icon="pi pi-bookmark"
outlined="true"
severity="info"
(click)="unshelfBooks()"
pTooltip="Remove from shelf"
tooltipPosition="top">
</p-button>
<div *ngIf="userService.userState$ | async as userData">
<p-button
*ngIf="userData.permissions.canEditMetadata"
icon="pi pi-database"
outlined="true"
severity="info"
(click)="updateMetadata()"
pTooltip="Update metadata"
tooltipPosition="top">
</p-button>
</div>
<p-button
outlined="true"
icon="pi pi-lock"
severity="info"
(click)="lockUnlockMetadata()"
pTooltip="Lock/Unlock metadata"
tooltipPosition="top">
</p-button>
<p-button
outlined="true"
icon="pi pi-times"
severity="warn"
(click)="deselectAllBooks()"
pTooltip="Deselect all books"
tooltipPosition="top">
</p-button>
</ng-container>
</div>
}
</div>
</div>
</div>
}
</div>
<app-book-filter [entity$]="entity$" [entityType$]="entityType$" [resetFilter$]="resetFilterSubject"></app-book-filter>
@@ -20,7 +20,7 @@ import {animate, state, style, transition, trigger} from '@angular/animations';
import {MetadataFetchOptionsComponent} from '../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
import {Button} from 'primeng/button';
import {AsyncPipe, NgClass, NgForOf, NgIf, NgStyle} from '@angular/common';
import { AsyncPipe, NgClass, NgStyle } from '@angular/common';
import {VirtualScrollerModule} from '@iharbeck/ngx-virtual-scroller';
import {BookCardComponent} from './book-card/book-card.component';
import {ProgressSpinner} from 'primeng/progressspinner';
@@ -65,7 +65,7 @@ const SORT_DIRECTION = {
standalone: true,
templateUrl: './book-browser.component.html',
styleUrls: ['./book-browser.component.scss'],
imports: [Button, NgIf, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, NgForOf, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, Slider, Popover],
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, Slider, Popover],
animations: [
trigger('slideInOut', [
state('void', style({
@@ -1,7 +1,7 @@
<div class="book-card"
[class.selected]="isSelected"
(mouseover)="isHovered = true"
(mouseout)="isHovered = false">
[class.selected]="isSelected"
(mouseover)="isHovered = true"
(mouseout)="isHovered = false">
<div class="cover-container" [ngClass]="{ 'shimmer': !isImageLoaded, 'center-info-btn': readButtonHidden }">
<img
@@ -15,22 +15,24 @@
<p-button [rounded]="true" icon="pi pi-info" class="info-btn" (click)="openBookInfo(book)"></p-button>
<p-button [hidden]="readButtonHidden" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
<p-checkbox
*ngIf="isCheckboxEnabled"
[(ngModel)]="isSelected"
binary="true"
id="select-checkbox-{{book.id}}"
class="select-checkbox"
(ngModelChange)="toggleSelection(isSelected || false)">
</p-checkbox>
@if (isCheckboxEnabled) {
<p-checkbox
[(ngModel)]="isSelected"
binary="true"
id="select-checkbox-{{book.id}}"
class="select-checkbox"
(ngModelChange)="toggleSelection(isSelected || false)">
</p-checkbox>
}
<p-progressBar
*ngIf="progressPercentage !== null"
[value]="progressPercentage"
[showValue]="false"
class="cover-progress-bar"
[ngClass]="{ 'progress-complete': progressPercentage === 100, 'progress-incomplete': progressPercentage < 100 }">
</p-progressBar>
@if (progressPercentage !== null) {
<p-progressBar
[value]="progressPercentage"
[showValue]="false"
class="cover-progress-bar"
[ngClass]="{ 'progress-complete': progressPercentage === 100, 'progress-incomplete': progressPercentage < 100 }">
</p-progressBar>
}
</div>
<div [hidden]="bottomBarHidden">
@@ -12,7 +12,7 @@ import {MetadataFetchOptionsComponent} from '../../../metadata/metadata-options-
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
import {MetadataRefreshRequest} from '../../../metadata/model/request/metadata-refresh-request.model';
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
import {NgClass, NgIf} from '@angular/common';
import { NgClass } from '@angular/common';
import {UserService} from '../../../../settings/user-management/user.service';
import {filter} from 'rxjs';
import {EmailService} from '../../../../settings/email/email.service';
@@ -25,7 +25,7 @@ import {ProgressBar} from 'primeng/progressbar';
selector: 'app-book-card',
templateUrl: './book-card.component.html',
styleUrls: ['./book-card.component.scss'],
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgIf, NgClass, TieredMenu, ProgressBar],
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgClass, TieredMenu, ProgressBar],
standalone: true
})
export class BookCardComponent implements OnInit {
@@ -1,49 +1,59 @@
<div *ngIf="showFilters" class="w-[225px] ml-4 h-[calc(100vh-6.5rem)] rounded-xl bg-[var(--card-background)] overflow-hidden">
<div class="flex items-center justify-between px-4 py-4">
<span class="text font-semibold">Filter Mode</span>
<p-selectButton
[options]="filterModeOptions"
[(ngModel)]="selectedFilterMode"
optionLabel="label"
optionValue="value"
class="text-sm"
allowEmpty="false"
@if (showFilters) {
<div class="w-[225px] ml-4 h-[calc(100vh-6.5rem)] rounded-xl bg-[var(--card-background)] overflow-hidden">
<div class="flex items-center justify-between px-4 py-4">
<span class="text font-semibold">Filter Mode</span>
<p-selectButton
[options]="filterModeOptions"
[(ngModel)]="selectedFilterMode"
optionLabel="label"
optionValue="value"
class="text-sm"
allowEmpty="false"
styleClass="h-8"></p-selectButton>
</div>
<p-accordion [value]="0">
<p-accordion-panel *ngFor="let filterType of filterTypes; let i = index" [value]="i">
<p-accordion-header>
<span class="inline-flex items-center gap-1">
{{ filterLabels[filterType] || (filterType | titlecase) }}
<span *ngIf="activeFilters[filterType]?.length" class="text-sm text-[var(--primary-color)]">
({{ activeFilters[filterType].length }})
</span>
</span>
</p-accordion-header>
<p-accordion-content class="h-[31rem] !overflow-y-auto">
<div *ngIf="filterStreams[filterType] | async as filters">
<div *ngFor="let filter of filters">
<div
class="cursor-pointer transition-colors duration-200 ease-in-out pb-1 flex items-center gap-2"
</div>
<p-accordion [value]="0">
@for (filterType of filterTypes; track filterType; let i = $index) {
<p-accordion-panel [value]="i">
<p-accordion-header>
<span class="inline-flex items-center gap-1">
{{ filterLabels[filterType] || (filterType | titlecase) }}
@if (activeFilters[filterType]?.length) {
<span class="text-sm text-[var(--primary-color)]">
({{ activeFilters[filterType].length }})
</span>
}
</span>
</p-accordion-header>
<p-accordion-content class="h-[31rem] !overflow-y-auto">
@if (filterStreams[filterType] | async; as filters) {
<div>
@for (filter of filters; track filter) {
<div>
<div
class="cursor-pointer transition-colors duration-200 ease-in-out pb-1 flex items-center gap-2"
[ngClass]="{
'text-[var(--primary-color)]':
activeFilters[filterType]?.includes(filter.value?.id || filter.value)
}"
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
<p-badge [value]="filter.bookCount"></p-badge>
<ng-container *ngIf="filterType === 'amazonRating'; else defaultLabel">
<ng-container *ngIf="filterType === 'amazonRating'; else defaultLabel">
<span>{{ filter.value.name }}</span>
</ng-container>
</ng-container>
<ng-template #defaultLabel>
{{ filter.value.name || filter.value }}
</ng-template>
</div>
</div>
</div>
</p-accordion-content>
</p-accordion-panel>
</p-accordion>
</div>
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
<p-badge [value]="filter.bookCount"></p-badge>
@if (filterType === 'amazonRating') {
@if (filterType === 'amazonRating') {
<span>{{ filter.value.name }}</span>
} @else {
{{ filter.value.name || filter.value }}
}
} @else {
{{ filter.value.name || filter.value }}
}
</div>
</div>
}
</div>
}
</p-accordion-content>
</p-accordion-panel>
}
</p-accordion>
</div>
}
@@ -7,7 +7,7 @@ import {Shelf} from '../../../model/shelf.model';
import {EntityType} from '../book-browser.component';
import {Book} from '../../../model/book.model';
import {Accordion, AccordionContent, AccordionHeader, AccordionPanel} from 'primeng/accordion';
import {AsyncPipe, NgClass, NgForOf, NgIf, TitleCasePipe} from '@angular/common';
import { AsyncPipe, NgClass, TitleCasePipe } from '@angular/common';
import {Badge} from 'primeng/badge';
import {FormsModule} from '@angular/forms';
import {SelectButton} from 'primeng/selectbutton';
@@ -110,15 +110,13 @@ function getPageCountRangeFilters(pageCount?: number) {
AccordionPanel,
AccordionHeader,
AccordionContent,
NgIf,
NgForOf,
NgClass,
Badge,
AsyncPipe,
TitleCasePipe,
FormsModule,
SelectButton
]
]
})
export class BookFilterComponent implements OnInit {
@Output() filterSelected = new EventEmitter<Record<string, any> | null>();
@@ -39,85 +39,93 @@
</tr>
</ng-template>
<ng-template #body let-book>
<tr *ngIf="book.metadata as metadata" style="height:46px">
<td class="max-w-16">
<p-tableCheckbox [value]="book"></p-tableCheckbox>
</td>
<td class="text-center">
<p-button
[icon]="isMetadataFullyLocked(metadata) ? 'pi pi-lock' : 'pi pi-lock-open'"
[severity]="isMetadataFullyLocked(metadata) ? 'danger' : 'success'"
[text]="true"
[title]="isMetadataFullyLocked(metadata) ? 'Locked' : 'Unlocked'"
size="small"
[style]="{ width: '1.5rem', height: '1.5rem', padding: '0', fontSize: '0.75rem' }"
(click)="toggleMetadataLock(metadata)">
</p-button>
</td>
<td (click)="openMetadataCenter(book.id)">
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)" alt="Book Cover" class="size-7"/>
</td>
<td class="min-w-[18rem] max-w-[25rem] overflow-hidden truncate" [title]="metadata.title">{{ metadata.title }}</td>
<td class="min-w-[10rem] max-w-[15rem] overflow-hidden truncate" [title]="getAuthorNames(metadata.authors)">{{ getAuthorNames(metadata.authors) }}</td>
<td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.publisher">{{ metadata.publisher }}</td>
<td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.seriesName">{{ metadata.seriesName }}</td>
<td class="min-w-[1rem] max-w-[1rem] overflow-hidden truncate" [title]="metadata.seriesNumber">{{ metadata.seriesNumber }}</td>
<td class="min-w-[12rem] max-w-[18rem] overflow-hidden truncate" [title]="getGenres(metadata.categories)">{{ getGenres(metadata.categories) }}</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate">
{{ metadata.publishedDate ? (metadata.publishedDate | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
{{ book.lastReadTime ? (book.lastReadTime | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
{{ book.addedOn ? (book.addedOn | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[7rem] max-w-[9rem] overflow-hidden truncate"
@if (book.metadata; as metadata) {
<tr style="height:46px">
<td class="max-w-16">
<p-tableCheckbox [value]="book"></p-tableCheckbox>
</td>
<td class="text-center">
<p-button
[icon]="isMetadataFullyLocked(metadata) ? 'pi pi-lock' : 'pi pi-lock-open'"
[severity]="isMetadataFullyLocked(metadata) ? 'danger' : 'success'"
[text]="true"
[title]="isMetadataFullyLocked(metadata) ? 'Locked' : 'Unlocked'"
size="small"
[style]="{ width: '1.5rem', height: '1.5rem', padding: '0', fontSize: '0.75rem' }"
(click)="toggleMetadataLock(metadata)">
</p-button>
</td>
<td (click)="openMetadataCenter(book.id)">
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)" alt="Book Cover" class="size-7"/>
</td>
<td class="min-w-[18rem] max-w-[25rem] overflow-hidden truncate" [title]="metadata.title">{{ metadata.title }}</td>
<td class="min-w-[10rem] max-w-[15rem] overflow-hidden truncate" [title]="getAuthorNames(metadata.authors)">{{ getAuthorNames(metadata.authors) }}</td>
<td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.publisher">{{ metadata.publisher }}</td>
<td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.seriesName">{{ metadata.seriesName }}</td>
<td class="min-w-[1rem] max-w-[1rem] overflow-hidden truncate" [title]="metadata.seriesNumber">{{ metadata.seriesNumber }}</td>
<td class="min-w-[12rem] max-w-[18rem] overflow-hidden truncate" [title]="getGenres(metadata.categories)">{{ getGenres(metadata.categories) }}</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate">
{{ metadata.publishedDate ? (metadata.publishedDate | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
{{ book.lastReadTime ? (book.lastReadTime | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
{{ book.addedOn ? (book.addedOn | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[7rem] max-w-[9rem] overflow-hidden truncate"
[title]="book.fileSizeKb + ' KB'">
{{ formatFileSize(book.fileSizeKb) }}
</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.language }}</td>
<td class="min-w-[4rem] max-w-[5rem] overflow-hidden truncate">{{ metadata.pageCount }}</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.amazonRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
</p-rating>
<span *ngIf="metadata.amazonRating != null">({{ metadata.amazonRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.amazonReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.goodreadsRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
</p-rating>
<span *ngIf="metadata.goodreadsRating != null">({{ metadata.goodreadsRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.goodreadsReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.hardcoverRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
</p-rating>
<span *ngIf="metadata.hardcoverRating != null">({{ metadata.hardcoverRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.hardcoverReviewCount }}</td>
</tr>
{{ formatFileSize(book.fileSizeKb) }}
</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.language }}</td>
<td class="min-w-[4rem] max-w-[5rem] overflow-hidden truncate">{{ metadata.pageCount }}</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.amazonRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
</p-rating>
@if (metadata.amazonRating != null) {
<span>({{ metadata.amazonRating?.toFixed(1) }})</span>
}
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.amazonReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.goodreadsRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
</p-rating>
@if (metadata.goodreadsRating != null) {
<span>({{ metadata.goodreadsRating?.toFixed(1) }})</span>
}
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.goodreadsReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.hardcoverRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
</p-rating>
@if (metadata.hardcoverRating != null) {
<span>({{ metadata.hardcoverRating?.toFixed(1) }})</span>
}
</span>
</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.hardcoverReviewCount }}</td>
</tr>
}
</ng-template>
</p-table>
@@ -1,6 +1,6 @@
import {Component, EventEmitter, inject, Input, OnChanges, Output} from '@angular/core';
import {TableModule} from 'primeng/table';
import {DatePipe, NgIf} from '@angular/common';
import { DatePipe } from '@angular/common';
import {Rating} from 'primeng/rating';
import {FormsModule} from '@angular/forms';
import {Book, BookMetadata} from '../../../model/book.model';
@@ -17,12 +17,11 @@ import {Router} from '@angular/router';
templateUrl: './book-table.component.html',
imports: [
TableModule,
NgIf,
Rating,
FormsModule,
Button,
DatePipe
],
],
styleUrl: './book-table.component.scss'
})
export class BookTableComponent implements OnChanges {
@@ -1,15 +1,17 @@
<div class="p-4">
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-x-24 gap-y-4">
<div *ngFor="let field of lockableFields" class="flex items-center justify-between">
<label class="capitalize">{{ fieldLabels[field] || field }}</label>
<p-button
[outlined]="true"
[label]="getLockLabel(field)"
[icon]="getLockIcon(field)"
[severity]="fieldLocks[field] === true ? 'danger' : fieldLocks[field] === false ? 'success' : 'secondary'"
(click)="cycleLockState(field)"
></p-button>
</div>
@for (field of lockableFields; track field) {
<div class="flex items-center justify-between">
<label class="capitalize">{{ fieldLabels[field] || field }}</label>
<p-button
[outlined]="true"
[label]="getLockLabel(field)"
[icon]="getLockIcon(field)"
[severity]="fieldLocks[field] === true ? 'danger' : fieldLocks[field] === false ? 'success' : 'secondary'"
(click)="cycleLockState(field)"
></p-button>
</div>
}
</div>
</div>
@@ -1,7 +1,7 @@
import {Component, inject, OnInit} from '@angular/core';
import {Button} from 'primeng/button';
import {FormsModule} from '@angular/forms';
import {NgForOf} from '@angular/common';
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {MessageService} from 'primeng/api';
import {BookService} from '../../../service/book.service';
@@ -13,9 +13,8 @@ import {Divider} from 'primeng/divider';
imports: [
Button,
FormsModule,
NgForOf,
Divider
],
],
templateUrl: './lock-unlock-metadata-dialog.component.html',
styleUrl: './lock-unlock-metadata-dialog.component.scss'
})
@@ -9,32 +9,37 @@
(input)="onSearchInputChange()"
placeholder="Search books by title or author..."
class="search-input"
/>
<p-button *ngIf="searchQuery" icon="pi pi-times" (click)="clearSearch()" [text]="true" [rounded]="true" class="clear-btn" aria-label="Clear Search"></p-button>
/>
@if (searchQuery) {
<p-button icon="pi pi-times" (click)="clearSearch()" [text]="true" [rounded]="true" class="clear-btn" aria-label="Clear Search"></p-button>
}
</div>
<div class="search-dropdown layout-menu pt-4" [class.show]="(books.length > 0)">
<ng-container *ngIf="books.length > 0; else noResults">
<div class="search-dropdown-item flex flex-col" *ngFor="let book of books" (click)="onBookClick(book)">
<div class="flex flex-row w-full px-2">
<img [attr.src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)" alt="Book Cover" class="search-book-cover"/>
<div class="search-book-details">
<div class="flex items-center">
<p class="search-book-name text-lg font-medium truncate">{{ book.metadata?.title | slice:0:70 }}</p>
</div>
<div *ngIf="book.metadata?.authors?.length ?? 0 > 0" class="search-book-authors">
<p class="italic">by: {{ getAuthorNames(book.metadata?.authors) }}</p>
@if (books.length > 0) {
@for (book of books; track book) {
<div class="search-dropdown-item flex flex-col" (click)="onBookClick(book)">
<div class="flex flex-row w-full px-2">
<img [attr.src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)" alt="Book Cover" class="search-book-cover"/>
<div class="search-book-details">
<div class="flex items-center">
<p class="search-book-name text-lg font-medium truncate">{{ book.metadata?.title | slice:0:70 }}</p>
</div>
@if (book.metadata?.authors?.length ?? 0 > 0) {
<div class="search-book-authors">
<p class="italic">by: {{ getAuthorNames(book.metadata?.authors) }}</p>
</div>
}
</div>
</div>
<p-divider></p-divider>
</div>
<p-divider></p-divider>
</div>
</ng-container>
<ng-template #noResults>
}
} @else {
<div class="search-dropdown-item">
<span>No results found</span>
</div>
</ng-template>
}
</div>
</div>
@@ -6,7 +6,7 @@ import {FormsModule} from '@angular/forms';
import {InputTextModule} from 'primeng/inputtext';
import {BookService} from '../../service/book.service';
import {Button} from 'primeng/button';
import {NgForOf, NgIf, SlicePipe} from '@angular/common';
import { SlicePipe } from '@angular/common';
import {Divider} from 'primeng/divider';
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
import {Router} from '@angular/router';
@@ -18,11 +18,9 @@ import {Router} from '@angular/router';
FormsModule,
InputTextModule,
Button,
NgIf,
NgForOf,
SlicePipe,
Divider
],
],
styleUrls: ['./book-searcher.component.scss'],
standalone: true
})
@@ -7,7 +7,7 @@
[min]="1"
[max]="pages.length"
placeholder="Page"
/>
/>
<button
(click)="goToPageInput !== null && goToPage(goToPageInput)"
[disabled]="goToPageInput === null || goToPageInput < 1 || goToPageInput > pages.length">
@@ -27,9 +27,11 @@
</div>
<div class="spread-controls" style="display: flex; align-items: center; margin-left: auto;">
<button *ngIf="isTwoPageView" (click)="toggleSpreadDirection()" title="Toggle Spread Direction">
{{ pageSpread === 'ODD' ? '⬅️' : '➡️' }}
</button>
@if (isTwoPageView) {
<button (click)="toggleSpreadDirection()" title="Toggle Spread Direction">
{{ pageSpread === 'ODD' ? '⬅️' : '➡️' }}
</button>
}
<button (click)="toggleView()" title="Toggle View">
{{ isTwoPageView ? '1️⃣' : '2️⃣' }}
</button>
@@ -37,19 +39,19 @@
</div>
<div class="image-container" [class.two-page-view]="isTwoPageView">
<ng-container *ngIf="!isLoading; else loading">
<ng-container *ngIf="pages.length > 0; else noPages">
<img *ngFor="let url of imageUrls" [src]="url" alt="Page Image"/>
</ng-container>
</ng-container>
<ng-template #noPages>
<p>No pages available.</p>
</ng-template>
<ng-template #loading>
@if (!isLoading) {
@if (pages.length > 0) {
@for (url of imageUrls; track url) {
<img [src]="url" alt="Page Image"/>
}
} @else {
<p>No pages available.</p>
}
} @else {
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<p-progressSpinner></p-progressSpinner>
<p style="margin-top: 1rem; color: #ccc;">Processing pages... This may take a few seconds on first load. Future loads will be significantly faster.</p>
</div>
</ng-template>
}
</div>
</div>
@@ -1,5 +1,5 @@
import {Component, HostListener, inject, OnInit} from '@angular/core';
import {NgFor, NgIf} from '@angular/common';
import {ActivatedRoute} from '@angular/router';
import {CbxReaderService} from '../../service/cbx-reader.service';
import {BookService} from '../../service/book.service';
@@ -14,7 +14,7 @@ import {NewPdfReaderService} from '../../service/new-pdf-reader.service';
@Component({
selector: 'app-cbx-reader',
standalone: true,
imports: [NgIf, NgFor, ProgressSpinner, FormsModule],
imports: [ProgressSpinner, FormsModule],
templateUrl: './cbx-reader.component.html',
styleUrl: './cbx-reader.component.scss'
})
@@ -1,59 +1,65 @@
<div #epubContainer class="epub-viewer-container">
<div *ngIf="isLoading" class="spinner-wrapper">
<p-progressSpinner></p-progressSpinner>
</div>
<div *ngIf="!isLoading">
<div class="epub-header">
<div>
<p-button size="small" class="menu-toggle-button" (click)="toggleDrawer()" icon="pi pi-bars" severity="secondary"></p-button>
<p-drawer [(visible)]="isDrawerVisible" [modal]="false" [position]="'left'" header="Chapters">
<ul class="chapter-list">
<li *ngFor="let chapter of chapters" (click)="navigateToChapter(chapter); $event.stopPropagation()" class="chapter-item">
{{ chapter.label }}
</li>
</ul>
</p-drawer>
</div>
<p>{{ currentChapter }}</p>
<div>
<div class="flex gap-4">
<div *ngIf="!locationsReady" class="location-indicator" pTooltip="Saving progress not ready yet">
<span class="dot"></span>
</div>
<div>
<p-button size="small" class="settings-toggle-button" (click)="toggleSettingsDrawer()" icon="pi pi-cog" severity="secondary"></p-button>
<p-drawer [(visible)]="isSettingsDrawerVisible" [modal]="false" [position]="'right'" header="Settings">
<div class="flex flex-col">
<div class="settings-content">
<p>Font Size: {{ fontSize }}%</p>
<div class="flex flex-row gap-4">
<p-button icon="pi pi-minus" (click)="decreaseFontSize()" severity="info"></p-button>
<p-button icon="pi pi-plus" (click)="increaseFontSize()" severity="info"></p-button>
</div>
<p-divider></p-divider>
<label for="font-type">Font Type:</label>
<p-select id="font-type" [options]="fontTypes" [(ngModel)]="selectedFontType" (onChange)="changeFontType()"></p-select>
<p-divider></p-divider>
<label for="theme">Theme:</label>
<p-select id="theme" [options]="themes" [(ngModel)]="selectedTheme" (onChange)="changeThemes()"></p-select>
<p-divider></p-divider>
<label for="flow">Flow:</label>
<p-select id="flow" [options]="flows" [(ngModel)]="selectedFlow" (onChange)="changeScrollMode()"></p-select>
</div>
@if (isLoading) {
<div class="spinner-wrapper">
<p-progressSpinner></p-progressSpinner>
</div>
}
@if (!isLoading) {
<div>
<div class="epub-header">
<div>
<p-button size="small" class="menu-toggle-button" (click)="toggleDrawer()" icon="pi pi-bars" severity="secondary"></p-button>
<p-drawer [(visible)]="isDrawerVisible" [modal]="false" [position]="'left'" header="Chapters">
<ul class="chapter-list">
@for (chapter of chapters; track chapter) {
<li (click)="navigateToChapter(chapter); $event.stopPropagation()" class="chapter-item">
{{ chapter.label }}
</li>
}
</ul>
</p-drawer>
</div>
<p>{{ currentChapter }}</p>
<div>
<div class="flex gap-4">
@if (!locationsReady) {
<div class="location-indicator" pTooltip="Saving progress not ready yet">
<span class="dot"></span>
</div>
</p-drawer>
}
<div>
<p-button size="small" class="settings-toggle-button" (click)="toggleSettingsDrawer()" icon="pi pi-cog" severity="secondary"></p-button>
<p-drawer [(visible)]="isSettingsDrawerVisible" [modal]="false" [position]="'right'" header="Settings">
<div class="flex flex-col">
<div class="settings-content">
<p>Font Size: {{ fontSize }}%</p>
<div class="flex flex-row gap-4">
<p-button icon="pi pi-minus" (click)="decreaseFontSize()" severity="info"></p-button>
<p-button icon="pi pi-plus" (click)="increaseFontSize()" severity="info"></p-button>
</div>
<p-divider></p-divider>
<label for="font-type">Font Type:</label>
<p-select id="font-type" [options]="fontTypes" [(ngModel)]="selectedFontType" (onChange)="changeFontType()"></p-select>
<p-divider></p-divider>
<label for="theme">Theme:</label>
<p-select id="theme" [options]="themes" [(ngModel)]="selectedTheme" (onChange)="changeThemes()"></p-select>
<p-divider></p-divider>
<label for="flow">Flow:</label>
<p-select id="flow" [options]="flows" [(ngModel)]="selectedFlow" (onChange)="changeScrollMode()"></p-select>
</div>
</div>
</p-drawer>
</div>
</div>
</div>
</div>
<div id="epubContainer" #epubContainer></div>
@if (selectedFlow !== 'scrolled') {
<button class="epub-controls-left" (click)="prevPage()">←</button>
}
@if (selectedFlow !== 'scrolled') {
<button class="epub-controls-right" (click)="nextPage()">→</button>
}
</div>
<div id="epubContainer" #epubContainer></div>
<button *ngIf="selectedFlow !== 'scrolled'" class="epub-controls-left" (click)="prevPage()">←</button>
<button *ngIf="selectedFlow !== 'scrolled'" class="epub-controls-right" (click)="nextPage()">→</button>
</div>
}
</div>
@@ -2,7 +2,7 @@ import {Component, ElementRef, inject, OnDestroy, OnInit, ViewChild} from '@angu
import ePub, {EpubCFI} from 'epubjs';
import {Drawer} from 'primeng/drawer';
import {Button} from 'primeng/button';
import {NgForOf, NgIf} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {Divider} from 'primeng/divider';
import {ActivatedRoute} from '@angular/router';
@@ -66,7 +66,7 @@ export function getChapter(book: any, location: any) {
selector: 'app-epub-viewer',
templateUrl: './epub-viewer.component.html',
styleUrls: ['./epub-viewer.component.scss'],
imports: [Drawer, Button, NgForOf, FormsModule, Divider, Select, ProgressSpinner, NgIf, Tooltip],
imports: [Drawer, Button, FormsModule, Divider, Select, ProgressSpinner, Tooltip],
standalone: true
})
export class EpubViewerComponent implements OnInit, OnDestroy {
@@ -1,20 +1,23 @@
<div *ngIf="isLoading" class="flex justify-center items-center h-screen relative">
<p-progressSpinner></p-progressSpinner>
</div>
@if (isLoading) {
<div class="flex justify-center items-center h-screen relative">
<p-progressSpinner></p-progressSpinner>
</div>
}
<ngx-extended-pdf-viewer
*ngIf="!isLoading"
[src]="bookData"
[handTool]="handTool"
[height]="'auto'"
[page]="page"
[rotation]="rotation"
[sidebarVisible]="false"
[zoom]="zoom"
[spread]="spread"
[showBookModeButton]="false"
(pagesLoaded)="onPdfPagesLoaded($event)"
(pageChange)="onPageChange($event)"
(zoomChange)="onZoomChange($event)"
(spreadChange)="onSpreadChange($event)">
</ngx-extended-pdf-viewer>
@if (!isLoading) {
<ngx-extended-pdf-viewer
[src]="bookData"
[handTool]="handTool"
[height]="'auto'"
[page]="page"
[rotation]="rotation"
[sidebarVisible]="false"
[zoom]="zoom"
[spread]="spread"
[showBookModeButton]="false"
(pagesLoaded)="onPdfPagesLoaded($event)"
(pageChange)="onPageChange($event)"
(zoomChange)="onZoomChange($event)"
(spreadChange)="onSpreadChange($event)">
</ngx-extended-pdf-viewer>
}
@@ -5,14 +5,14 @@ import {BookService} from '../../service/book.service';
import {forkJoin, Subscription} from 'rxjs';
import {BookSetting} from '../../model/book.model';
import {UserService} from '../../../settings/user-management/user.service';
import {NgIf} from '@angular/common';
import {ProgressSpinner} from 'primeng/progressspinner';
import {MessageService} from 'primeng/api';
@Component({
selector: 'app-pdf-viewer',
standalone: true,
imports: [NgxExtendedPdfViewerModule, NgIf, ProgressSpinner],
imports: [NgxExtendedPdfViewerModule, ProgressSpinner],
templateUrl: './pdf-viewer.component.html',
})
export class PdfViewerComponent implements OnInit, OnDestroy {
@@ -2,12 +2,14 @@
<div class="flex flex-col flex-grow">
<!-- Dynamic shelves content -->
<div *ngFor="let shelf of (shelfState$ | async)?.shelves">
<div class="flex flex-row items-center gap-4 py-2">
<p-checkbox [inputId]="shelf.name" name="group" [value]="shelf" [(ngModel)]="selectedShelves"></p-checkbox>
<label [for]="shelf.id">{{ shelf.name }}</label>
@for (shelf of (shelfState$ | async)?.shelves; track shelf) {
<div>
<div class="flex flex-row items-center gap-4 py-2">
<p-checkbox [inputId]="shelf.name" name="group" [value]="shelf" [(ngModel)]="selectedShelves"></p-checkbox>
<label [for]="shelf.id">{{ shelf.name }}</label>
</div>
</div>
</div>
}
<!-- Button section, anchored to the bottom -->
<div class="flex justify-between items-center pt-4 mt-auto">
@@ -30,13 +32,17 @@
</div>
<div class="py-4">
<label>Shelf Icon</label>
<div *ngIf="!selectedIcon">
<p-button label="Select Icon" icon="pi pi-search" (onClick)="openIconPicker()"></p-button>
</div>
<div *ngIf="selectedIcon" class="flex items-center gap-4">
<i [class]="selectedIcon"></i>
<p-button icon="pi pi-times" text="true" outlined="true" severity="warn" (onClick)="clearSelectedIcon()"></p-button>
</div>
@if (!selectedIcon) {
<div>
<p-button label="Select Icon" icon="pi pi-search" (onClick)="openIconPicker()"></p-button>
</div>
}
@if (selectedIcon) {
<div class="flex items-center gap-4">
<i [class]="selectedIcon"></i>
<p-button icon="pi pi-times" text="true" outlined="true" severity="warn" (onClick)="clearSelectedIcon()"></p-button>
</div>
}
</div>
<ng-template pTemplate="footer">
<p-button label="Cancel" severity="secondary" (onClick)="closeShelfDialog()" class="p-button-text"></p-button>
@@ -10,7 +10,7 @@ import {Shelf} from '../../model/shelf.model';
import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component';
import {ShelfState} from '../../model/state/shelf-state.model';
import {Button} from 'primeng/button';
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
import { AsyncPipe } from '@angular/common';
import {Checkbox} from 'primeng/checkbox';
import {FormsModule} from '@angular/forms';
import {Dialog} from 'primeng/dialog';
@@ -22,16 +22,14 @@ import {InputText} from 'primeng/inputtext';
templateUrl: './shelf-assigner.component.html',
imports: [
Button,
NgForOf,
Checkbox,
AsyncPipe,
FormsModule,
IconPickerComponent,
Dialog,
InputText,
NgIf,
PrimeTemplate
],
],
styleUrls: ['./shelf-assigner.component.scss']
})
export class ShelfAssignerComponent implements OnInit {
@@ -6,13 +6,17 @@
</div>
<div class="flex items-center gap-5">
<p>Shelf Icon:</p>
<div *ngIf="!selectedIcon">
<p-button label="Select Icon" icon="pi pi-search" (onClick)="openIconPicker()"></p-button>
</div>
<div *ngIf="selectedIcon">
<i [class]="selectedIcon" class="text-xl mr-3"></i>
<p-button icon="pi pi-times" (onClick)="clearSelectedIcon()" [rounded]="true" [text]="true" [outlined]="true" severity="danger"></p-button>
</div>
@if (!selectedIcon) {
<div>
<p-button label="Select Icon" icon="pi pi-search" (onClick)="openIconPicker()"></p-button>
</div>
}
@if (selectedIcon) {
<div>
<i [class]="selectedIcon" class="text-xl mr-3"></i>
<p-button icon="pi pi-times" (onClick)="clearSelectedIcon()" [rounded]="true" [text]="true" [outlined]="true" severity="danger"></p-button>
</div>
}
</div>
</div>
<div class="flex justify-end">
@@ -4,7 +4,7 @@ import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {Button} from 'primeng/button';
import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component';
import {InputText} from 'primeng/inputtext';
import {NgIf} from '@angular/common';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {Shelf} from '../../model/shelf.model';
import {MessageService} from 'primeng/api';
@@ -15,10 +15,9 @@ import {MessageService} from 'primeng/api';
Button,
IconPickerComponent,
InputText,
NgIf,
ReactiveFormsModule,
FormsModule
],
],
templateUrl: './shelf-edit-dialog.component.html',
standalone: true,
styleUrl: './shelf-edit-dialog.component.scss'
@@ -2,19 +2,27 @@
<p-tabs [value]="tab" lazy="true">
<p-tablist>
<p-tab value="view">Book Details</p-tab>
<p-tab *ngIf="admin || canEditMetadata" value="edit">Edit Metadata</p-tab>
<p-tab *ngIf="admin || canEditMetadata" value="match">Search Metadata</p-tab>
@if (admin || canEditMetadata) {
<p-tab value="edit">Edit Metadata</p-tab>
}
@if (admin || canEditMetadata) {
<p-tab value="match">Search Metadata</p-tab>
}
</p-tablist>
<p-tabpanels class="h-[calc(100vh-10rem)]">
<p-tabpanel value="view">
<app-metadata-viewer [book]="book" [recommendedBooks]="recommendedBooks"></app-metadata-viewer>
</p-tabpanel>
<p-tabpanel *ngIf="admin || canEditMetadata" value="edit">
<app-metadata-editor></app-metadata-editor>
</p-tabpanel>
<p-tabpanel *ngIf="admin || canEditMetadata" value="match">
<app-metadata-searcher></app-metadata-searcher>
</p-tabpanel>
@if (admin || canEditMetadata) {
<p-tabpanel value="edit">
<app-metadata-editor></app-metadata-editor>
</p-tabpanel>
}
@if (admin || canEditMetadata) {
<p-tabpanel value="match">
<app-metadata-searcher></app-metadata-searcher>
</p-tabpanel>
}
</p-tabpanels>
</p-tabs>
</div>
@@ -8,7 +8,7 @@ import {distinctUntilChanged, filter, map, switchMap, take} from 'rxjs/operators
import {BookService} from '../../service/book.service';
import {AppSettingsService} from '../../../core/service/app-settings.service';
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
import {NgIf} from '@angular/common';
import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component';
import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component';
import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component';
@@ -22,13 +22,12 @@ import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.c
TabList,
Tabs,
Tab,
NgIf,
TabPanels,
MetadataViewerComponent,
TabPanel,
MetadataEditorComponent,
MetadataSearcherComponent
]
]
})
export class BookMetadataCenterComponent implements OnInit, OnDestroy {
@@ -1,339 +1,415 @@
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" *ngIf="bookMetadata$ | async as metadata" class="pt-2 flex flex-col h-full">
<div *ngIf="isLoading" class="absolute inset-0 bg-black opacity-25 z-10"></div>
<p-progressSpinner *ngIf="isLoading" [style]="{position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)'}"></p-progressSpinner>
<div class="overflow-y-scroll flex-1">
<div class="flex flex-row w-full gap-4">
<div class="flex flex-col items-center gap-2 relative">
<img
[attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)"
alt="Image"
width="250"
[ngClass]="{ 'brightness-50': isUploading }"
class="transition-all duration-300 ease-in-out"/>
<p-progressSpinner
*ngIf="isUploading"
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">
<p-button
icon="pi pi-refresh"
(onClick)="regenerateCover(metadata.bookId)"
pTooltip="Regenerate cover"
tooltipPosition="top"
[outlined]="true"
[disabled]="metadata['coverLocked']">
</p-button>
<p-fileupload
pTooltip="Upload cover"
tooltipPosition="top"
[disabled]="metadata['coverLocked']"
name="file"
[url]="getUploadCoverUrl()"
mode="basic"
chooseIcon="pi pi-upload"
accept="image/jpeg,image/png"
maxFileSize="5000000"
chooseLabel="Cover"
(onUpload)="onUpload($event)"
(onError)="onUploadError($event)"
[auto]="true"
(onBeforeUpload)="onBeforeSend()">
</p-fileupload>
<p-button *ngIf="!metadata['coverLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
<p-button *ngIf="metadata['coverLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
@if (bookMetadata$ | async; as metadata) {
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="pt-2 flex flex-col h-full">
@if (isLoading) {
<div class="absolute inset-0 bg-black opacity-25 z-10"></div>
}
@if (isLoading) {
<p-progressSpinner [style]="{position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)'}"></p-progressSpinner>
}
<div class="overflow-y-scroll flex-1">
<div class="flex flex-row w-full gap-4">
<div class="flex flex-col items-center gap-2 relative">
<img
[attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)"
alt="Image"
width="250"
[ngClass]="{ 'brightness-50': isUploading }"
class="transition-all duration-300 ease-in-out"/>
@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">
<p-button
icon="pi pi-refresh"
(onClick)="regenerateCover(metadata.bookId)"
pTooltip="Regenerate cover"
tooltipPosition="top"
[outlined]="true"
[disabled]="metadata['coverLocked']">
</p-button>
<p-fileupload
pTooltip="Upload cover"
tooltipPosition="top"
[disabled]="metadata['coverLocked']"
name="file"
[url]="getUploadCoverUrl()"
mode="basic"
chooseIcon="pi pi-upload"
accept="image/jpeg,image/png"
maxFileSize="5000000"
chooseLabel="Cover"
(onUpload)="onUpload($event)"
(onError)="onUploadError($event)"
[auto]="true"
(onBeforeUpload)="onBeforeSend()">
</p-fileupload>
@if (!metadata['coverLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
}
@if (metadata['coverLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="flex flex-col flex-grow pl-2">
<!-- Title and Subtitle -->
<div class="flex flex-row w-full gap-4 pb-1">
<div class="flex flex-col gap-1 w-2/3">
<label for="title">Title</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="title" formControlName="title" class="w-full"/>
<p-button *ngIf="!metadata['titleLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('title')" severity="success"></p-button>
<p-button *ngIf="metadata['titleLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('title')" severity="warn"></p-button>
<div class="flex flex-col flex-grow pl-2">
<!-- Title and Subtitle -->
<div class="flex flex-row w-full gap-4 pb-1">
<div class="flex flex-col gap-1 w-2/3">
<label for="title">Title</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="title" formControlName="title" class="w-full"/>
@if (!metadata['titleLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('title')" severity="success"></p-button>
}
@if (metadata['titleLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('title')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/3">
<label for="subtitle">Subtitle</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="subtitle" formControlName="subtitle" class="w-full"/>
@if (!metadata['subtitleLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="success"></p-button>
}
@if (metadata['subtitleLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="flex flex-col gap-1 w-1/3">
<label for="subtitle">Subtitle</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="subtitle" formControlName="subtitle" class="w-full"/>
<p-button *ngIf="!metadata['subtitleLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="success"></p-button>
<p-button *ngIf="metadata['subtitleLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="warn"></p-button>
<!-- Authors and Publisher -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-2/3">
<label for="authors">Authors</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="authors" formControlName="authors" class="w-full"/>
@if (!metadata['authorsLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('authors')" severity="success"></p-button>
}
@if (metadata['authorsLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('authors')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/3">
<label for="publisher">Publisher</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="publisher" formControlName="publisher" class="w-full"/>
@if (!metadata['publisherLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publisher')" severity="success"></p-button>
}
@if (metadata['publisherLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publisher')" severity="warn"></p-button>
}
</div>
</div>
</div>
<!-- Categories and Published Date -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-3/4">
<label for="categories">Categories</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="categories" formControlName="categories" class="w-full"/>
@if (!metadata['categoriesLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('categories')" severity="success"></p-button>
}
@if (metadata['categoriesLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('categories')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/8">
<label for="publishedDate">Publish Date</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="publishedDate" formControlName="publishedDate" class="w-full"/>
@if (!metadata['publishedDateLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="success"></p-button>
}
@if (metadata['publishedDateLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/8">
<label for="language">Language</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="language" formControlName="language" class="w-full"/>
@if (!metadata['languageLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('language')" severity="success"></p-button>
}
@if (metadata['languageLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('language')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 basis-3/4">
<label for="seriesName">Series Name</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesName" formControlName="seriesName" class="w-full"/>
@if (!metadata['seriesNameLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="success"></p-button>
}
@if (metadata['seriesNameLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 basis-1/8">
<label for="seriesNumber">Book Number</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full"/>
@if (!metadata['seriesNumberLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="success"></p-button>
}
@if (metadata['seriesNumberLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 basis-1/8">
<label for="seriesTotal">Books in Series</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full"/>
@if (!metadata['seriesTotalLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="success"></p-button>
}
@if (metadata['seriesTotalLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="warn"></p-button>
}
</div>
</div>
</div>
<!-- ISBN, ASIN, Language -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6">
<label for="isbn10">ISBN 10</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="isbn10" formControlName="isbn10" class="w-full"/>
@if (!metadata['isbn10Locked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="success"></p-button>
}
@if (metadata['isbn10Locked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="isbn13">ISBN 13</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="isbn13" formControlName="isbn13" class="w-full"/>
@if (!metadata['isbn13Locked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="success"></p-button>
}
@if (metadata['isbn13Locked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="asin">ASIN (Amazon ID)</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="asin" formControlName="asin" class="w-full"/>
@if (!metadata['asinLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
}
@if (metadata['asinLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="amazonRating">Amazon ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
@if (!metadata['amazonRatingLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="success"></p-button>
}
@if (metadata['amazonRatingLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="amazonRatingCount">Amazon Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
@if (!metadata['amazonReviewCountLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
}
@if (metadata['amazonReviewCountLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="googleId">Google Books ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="googleId" formControlName="googleId" class="w-full"/>
@if (!metadata['googleIdLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('googleId')" severity="success"></p-button>
}
@if (metadata['googleIdLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
}
</div>
</div>
</div>
<!-- Ratings and Reviews -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsId">Goodreads ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsId" formControlName="goodreadsId" class="w-full"/>
@if (!metadata['goodreadsIdLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="success"></p-button>
}
@if (metadata['goodreadsIdLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsRating">Goodreads ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
@if (!metadata['goodreadsRatingLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="success"></p-button>
}
@if (metadata['goodreadsRatingLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsReviewCount">Goodreads Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
@if (!metadata['goodreadsReviewCountLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
}
@if (metadata['goodreadsReviewCountLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverId">Hardcover ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverId" formControlName="hardcoverId" class="w-full"/>
@if (!metadata['hardcoverIdLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="success"></p-button>
}
@if (metadata['hardcoverIdLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverRating">Hardcover ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverRating" formControlName="hardcoverRating" class="w-full"/>
@if (!metadata['hardcoverRatingLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="success"></p-button>
}
@if (metadata['hardcoverRatingLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
}
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverReviewCount">Hardcover Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/>
@if (!metadata['hardcoverReviewCountLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
}
@if (metadata['hardcoverReviewCountLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
}
</div>
</div>
</div>
</div>
<!-- Authors and Publisher -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-2/3">
<label for="authors">Authors</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="authors" formControlName="authors" class="w-full"/>
<p-button *ngIf="!metadata['authorsLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('authors')" severity="success"></p-button>
<p-button *ngIf="metadata['authorsLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('authors')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/3">
<label for="publisher">Publisher</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="publisher" formControlName="publisher" class="w-full"/>
<p-button *ngIf="!metadata['publisherLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publisher')" severity="success"></p-button>
<p-button *ngIf="metadata['publisherLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publisher')" severity="warn"></p-button>
</div>
</div>
</div>
<!-- Categories and Published Date -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-3/4">
<label for="categories">Categories</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="categories" formControlName="categories" class="w-full"/>
<p-button *ngIf="!metadata['categoriesLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('categories')" severity="success"></p-button>
<p-button *ngIf="metadata['categoriesLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('categories')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/8">
<label for="publishedDate">Publish Date</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="publishedDate" formControlName="publishedDate" class="w-full"/>
<p-button *ngIf="!metadata['publishedDateLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="success"></p-button>
<p-button *ngIf="metadata['publishedDateLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/8">
<label for="language">Language</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="language" formControlName="language" class="w-full"/>
<p-button *ngIf="!metadata['languageLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('language')" severity="success"></p-button>
<p-button *ngIf="metadata['languageLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('language')" severity="warn"></p-button>
</div>
</div>
</div>
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 basis-3/4">
<label for="seriesName">Series Name</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesName" formControlName="seriesName" class="w-full"/>
<p-button *ngIf="!metadata['seriesNameLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesNameLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 basis-1/8">
<label for="seriesNumber">Book Number</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full"/>
<p-button *ngIf="!metadata['seriesNumberLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesNumberLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 basis-1/8">
<label for="seriesTotal">Books in Series</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full"/>
<p-button *ngIf="!metadata['seriesTotalLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="success"></p-button>
<p-button *ngIf="metadata['seriesTotalLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="warn"></p-button>
</div>
</div>
</div>
<!-- ISBN, ASIN, Language -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6">
<label for="isbn10">ISBN 10</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="isbn10" formControlName="isbn10" class="w-full"/>
<p-button *ngIf="!metadata['isbn10Locked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="success"></p-button>
<p-button *ngIf="metadata['isbn10Locked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="isbn13">ISBN 13</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="isbn13" formControlName="isbn13" class="w-full"/>
<p-button *ngIf="!metadata['isbn13Locked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="success"></p-button>
<p-button *ngIf="metadata['isbn13Locked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="asin">ASIN (Amazon ID)</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="asin" formControlName="asin" class="w-full"/>
<p-button *ngIf="!metadata['asinLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
<p-button *ngIf="metadata['asinLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="amazonRating">Amazon ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
<p-button *ngIf="!metadata['amazonRatingLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="success"></p-button>
<p-button *ngIf="metadata['amazonRatingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="amazonRatingCount">Amazon Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['amazonReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['amazonReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="googleId">Google Books ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="googleId" formControlName="googleId" class="w-full"/>
<p-button *ngIf="!metadata['googleIdLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('googleId')" severity="success"></p-button>
<p-button *ngIf="metadata['googleIdLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
</div>
</div>
</div>
<!-- Ratings and Reviews -->
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsId">Goodreads ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsId" formControlName="goodreadsId" class="w-full"/>
<p-button *ngIf="!metadata['goodreadsIdLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="success"></p-button>
<p-button *ngIf="metadata['goodreadsIdLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsRating">Goodreads ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
<p-button *ngIf="!metadata['goodreadsRatingLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="success"></p-button>
<p-button *ngIf="metadata['goodreadsRatingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="goodreadsReviewCount">Goodreads Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['goodreadsReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['goodreadsReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverId">Hardcover ID</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverId" formControlName="hardcoverId" class="w-full"/>
<p-button *ngIf="!metadata['hardcoverIdLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="success"></p-button>
<p-button *ngIf="metadata['hardcoverIdLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverRating">Hardcover ★</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverRating" formControlName="hardcoverRating" class="w-full"/>
<p-button *ngIf="!metadata['hardcoverRatingLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="success"></p-button>
<p-button *ngIf="metadata['hardcoverRatingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
</div>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="hardcoverReviewCount">Hardcover Reviews</label>
<div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/>
<p-button *ngIf="!metadata['hardcoverReviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
<p-button *ngIf="metadata['hardcoverReviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" 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>
<p-tabpanel value="editor">
<form [formGroup]="metadataForm">
<p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '215px' }">
<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="10"
[disabled]="quillDisabled()"
[ngModel]="htmlTextarea"
(ngModelChange)="onHtmlTextareaChange($event)"
[ngModelOptions]="{ standalone: true }"
placeholder="Edit raw HTML here">
</textarea>
</p-tabpanel>
</p-tabpanels>
</p-tabs>
<p-button *ngIf="!metadata['descriptionLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success"></p-button>
<p-button *ngIf="metadata['descriptionLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('description')" severity="warn"></p-button>
<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>
<p-tabpanel value="editor">
<form [formGroup]="metadataForm">
<p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '215px' }">
<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="10"
[disabled]="quillDisabled()"
[ngModel]="htmlTextarea"
(ngModelChange)="onHtmlTextareaChange($event)"
[ngModelOptions]="{ standalone: true }"
placeholder="Edit raw HTML here">
</textarea>
</p-tabpanel>
</p-tabpanels>
</p-tabs>
@if (!metadata['descriptionLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success"></p-button>
}
@if (metadata['descriptionLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('description')" severity="warn"></p-button>
}
</div>
</div>
</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="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
<p-divider layout="vertical"/>
<p-button label="Save" icon="pi pi-check" type="submit"></p-button>
<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="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
<p-divider layout="vertical"/>
<p-button label="Save" icon="pi pi-check" type="submit"></p-button>
</div>
</div>
</div>
</form>
</form>
}
@@ -5,7 +5,7 @@ import {Divider} from 'primeng/divider';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {Observable} from 'rxjs';
import {BookMetadataCenterService} from '../book-metadata-center.service';
import {AsyncPipe, NgClass, NgIf} from '@angular/common';
import { AsyncPipe, NgClass } from '@angular/common';
import {MessageService} from 'primeng/api';
import {BookMetadata} from '../../../model/book.model';
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
@@ -29,7 +29,6 @@ import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
Divider,
FormsModule,
AsyncPipe,
NgIf,
ReactiveFormsModule,
FileUpload,
ProgressSpinner,
@@ -41,7 +40,7 @@ import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
Tab,
TabPanels,
TabPanel
]
]
})
export class MetadataEditorComponent implements OnInit {
@@ -1,148 +1,166 @@
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" *ngIf="bookMetadata$ | async as metadata" class="h-full flex pt-1 flex-col">
<div class="overflow-y-scroll flex-1">
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
<p class="ml-3 text-lg">Current Metadata</p>
<p-button
severity="info"
icon='pi pi-angle-left'
[ngStyle]="{'padding-left': '2rem', 'padding-right': '0.5rem'}"
[outlined]="true"
pTooltip="Move all missing fields" tooltipPosition="bottom"
(onClick)="copyMissing()"></p-button>
<p-button
severity="info"
icon='pi pi-angle-double-left'
[ngStyle]="{'padding-left': '0.5rem', 'padding-right': '2rem'}"
[outlined]="true"
pTooltip="Move all fields" tooltipPosition="bottom"
(onClick)="copyAll()"></p-button>
<p class="text-lg">Fetched Metadata</p>
</div>
<div class="form-row">
<label class="label"></label>
<div class="input-container">
<p-button *ngIf="!metadata['coverLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
<p-button *ngIf="metadata['coverLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
<img [src]="metadataForm.get('thumbnailUrl')?.value" alt="Book Thumbnail" class="thumbnail"/>
<input type="hidden" id="thumbnailUrl" formControlName="thumbnailUrl" class="input"/>
@if (bookMetadata$ | async; as metadata) {
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="h-full flex pt-1 flex-col">
<div class="overflow-y-scroll flex-1">
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
<p class="ml-3 text-lg">Current Metadata</p>
<p-button
[icon]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : (hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"
severity="info"
icon='pi pi-angle-left'
[ngStyle]="{'padding-left': '2rem', 'padding-right': '0.5rem'}"
[outlined]="true"
pTooltip="Move all missing fields" tooltipPosition="bottom"
(onClick)="copyMissing()"></p-button>
<p-button
severity="info"
icon='pi pi-angle-double-left'
[ngStyle]="{'padding-left': '0.5rem', 'padding-right': '2rem'}"
[outlined]="true"
pTooltip="Move all fields" tooltipPosition="bottom"
(onClick)="copyAll()"></p-button>
<p class="text-lg">Fetched Metadata</p>
</div>
<div class="form-row">
<label class="label"></label>
<div class="input-container">
@if (!metadata['coverLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
}
@if (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"/>
<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')"
[outlined]="true"
[ngClass]="
{
'green-outlined-button': isValueSaved('thumbnailUrl'),
'yellow-outlined-button': isValueCopied('thumbnailUrl') && !hoveredFields['thumbnailUrl'],
'red-outlined-button': isValueCopied('thumbnailUrl') && hoveredFields['thumbnailUrl']
}"
class="arrow-button"
(click)="hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? resetField('thumbnailUrl') : copyFetchedToCurrent('thumbnailUrl')"
(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"/>
class="arrow-button"
(click)="hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? resetField('thumbnailUrl') : copyFetchedToCurrent('thumbnailUrl')"
(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"/>
</div>
</div>
</div>
<div *ngFor="let field of metadataFieldsTop" class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<p-button *ngIf="!metadata[field.lockedKey]" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
[outlined]="true"
@for (field of metadataFieldsTop; track field) {
<div class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
@if (!metadata[field.lockedKey]) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadata[field.lockedKey]) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
[outlined]="true"
[ngClass]="
{
'green-outlined-button': isValueSaved(field.controlName),
'yellow-outlined-button': isValueCopied(field.controlName) && !hoveredFields[field.controlName],
'red-outlined-button': isValueCopied(field.controlName) && hoveredFields[field.controlName]
}"
class="arrow-button"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
</div>
</div>
<div *ngFor="let field of metadataDescription" class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<p-button *ngIf="!metadata[field.lockedKey]" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
<textarea rows="6" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
[outlined]="true"
class="arrow-button"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
</div>
</div>
}
@for (field of metadataDescription; track field) {
<div class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
@if (!metadata[field.lockedKey]) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadata[field.lockedKey]) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
<textarea rows="6" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
[outlined]="true"
[ngClass]="
{
'green-outlined-button': isValueSaved(field.controlName),
'yellow-outlined-button': isValueCopied(field.controlName) && !hoveredFields[field.controlName],
'red-outlined-button': isValueCopied(field.controlName) && hoveredFields[field.controlName]
}"
class="arrow-button"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
<textarea rows="6" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly></textarea>
</div>
</div>
<div *ngFor="let field of metadataFieldsBottom" class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<p-button *ngIf="!metadata[field.lockedKey]" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
[outlined]="true"
class="arrow-button"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
<textarea rows="6" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly></textarea>
</div>
</div>
}
@for (field of metadataFieldsBottom; track field) {
<div class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
@if (!metadata[field.lockedKey]) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadata[field.lockedKey]) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
[outlined]="true"
[ngClass]="
{
'green-outlined-button': isValueSaved(field.controlName),
'yellow-outlined-button': isValueCopied(field.controlName) && !hoveredFields[field.controlName],
'red-outlined-button': isValueCopied(field.controlName) && hoveredFields[field.controlName]
}"
class="arrow-button"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
</div>
</div>
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
<p class="ml-3 text-lg">Current Metadata</p>
<p-button
severity="info"
icon='pi pi-angle-left'
[ngStyle]="{'padding-left': '2rem', 'padding-right': '0.5rem'}"
[outlined]="true"
pTooltip="Move all missing fields" tooltipPosition="bottom"
class="arrow-button"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
</div>
</div>
}
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
<p class="ml-3 text-lg">Current Metadata</p>
<p-button
severity="info"
icon='pi pi-angle-left'
[ngStyle]="{'padding-left': '2rem', 'padding-right': '0.5rem'}"
[outlined]="true"
pTooltip="Move all missing fields" tooltipPosition="bottom"
(onClick)="copyMissing()"></p-button>
<p-button
severity="info"
icon='pi pi-angle-double-left'
[ngStyle]="{'padding-left': '0.5rem', 'padding-right': '2rem'}"
[outlined]="true"
pTooltip="Move all fields" tooltipPosition="bottom"
<p-button
severity="info"
icon='pi pi-angle-double-left'
[ngStyle]="{'padding-left': '0.5rem', 'padding-right': '2rem'}"
[outlined]="true"
pTooltip="Move all fields" tooltipPosition="bottom"
(onClick)="copyAll()"></p-button>
<p class="text-lg">Fetched Metadata</p>
</div>
</div>
<div class="flex flex-col gap-x-4 mt-auto">
<p-divider></p-divider>
<div class="flex justify-between">
<p-button label="To Metadata List" icon="pi pi-arrow-left" severity="info" (onClick)="goBackClick()"></p-button>
<div class="flex gap-x-4 justify-end">
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
<p-divider layout="vertical"/>
<p-button label="Save" icon="pi pi-check" type="submit"></p-button>
<p class="text-lg">Fetched Metadata</p>
</div>
</div>
</div>
</form>
<div class="flex flex-col gap-x-4 mt-auto">
<p-divider></p-divider>
<div class="flex justify-between">
<p-button label="To Metadata List" icon="pi pi-arrow-left" severity="info" (onClick)="goBackClick()"></p-button>
<div class="flex gap-x-4 justify-end">
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
<p-divider layout="vertical"/>
<p-button label="Save" icon="pi pi-check" type="submit"></p-button>
</div>
</div>
</div>
</form>
}
@@ -4,7 +4,7 @@ import {MessageService} from 'primeng/api';
import {Button} from 'primeng/button';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {InputText} from 'primeng/inputtext';
import {AsyncPipe, NgClass, NgForOf, NgIf, NgStyle} from '@angular/common';
import { AsyncPipe, NgClass, NgStyle } from '@angular/common';
import {Divider} from 'primeng/divider';
import {BookMetadataCenterService} from '../book-metadata-center.service';
import {Observable} from 'rxjs';
@@ -22,16 +22,14 @@ import {Textarea} from 'primeng/textarea';
Button,
FormsModule,
InputText,
NgIf,
Divider,
ReactiveFormsModule,
NgClass,
NgStyle,
Tooltip,
AsyncPipe,
NgForOf,
Textarea
]
]
})
export class MetadataPickerComponent implements OnInit {
@@ -1,57 +1,62 @@
<form *ngIf="!selectedFetchedMetadata" class="flex flex-col w-full h-full pt-2" [formGroup]="form" (ngSubmit)="onSubmit()">
<div class="flex w-full gap-x-4 items-end">
<div class="flex flex-col gap-1 w-3/12">
<label>Providers</label>
<p-multiselect id="provider" class="w-full" [filter]="false" showToggleAll="false" [options]="providers" formControlName="provider" placeholder="Select Providers"></p-multiselect>
</div>
<div class="flex flex-col gap-1 w-5/12">
<label for="title">Title</label>
<input pInputText formControlName="title" id="title" class="w-full"/>
</div>
<div class="flex flex-col gap-1 w-4/12">
<label for="author">Author</label>
<input pInputText formControlName="author" id="author" class="w-full"/>
</div>
<div>
<p-button label="Search" type="submit" outlined="true" [disabled]="!isSearchEnabled || loading"></p-button>
</div>
</div>
<div *ngIf="loading" class="flex justify-center items-center">
<p-progress-spinner ariaLabel="loading"/>
</div>
<div *ngIf="!loading" class="mt-8 flex-1 overflow-y-auto">
<div *ngFor="let metadata of allFetchedMetadata" class="book-item flex flex-col w-full">
<div class="flex w-full flex-row book-item-content" (click)="onBookClick(metadata)">
<img [src]="metadata.thumbnailUrl || 'assets/images/missing-cover.jpg'" alt="Image" class="img-fixed-dimensions pr-2"/>
<div class=" flex flex-col w-full m-2">
<div class="flex flex-row gap-4 justify-between">
<p class="font-bold">{{ truncateText(metadata['title'], 90) }}</p>
<div class="flex gap-2">
<p>ISBN: {{ metadata['isbn10'] || metadata['asin'] }}</p>
<p> | </p>
<p>Published: {{ metadata['publishedDate'] }}</p>
</div>
</div>
<div class="flex gap-2">
<p>by {{ truncateText(metadata['authors'].join(', '), 70) }}</p>
<p> | </p>
<p>Source: <span [innerHTML]="buildProviderLink(metadata)"></span></p>
</div>
<p class="mt-4 truncate-text p-secondary">
{{ sanitizeHtml(metadata['description']) }}
</p>
</div>
@if (!selectedFetchedMetadata) {
<form class="flex flex-col w-full h-full pt-2" [formGroup]="form" (ngSubmit)="onSubmit()">
<div class="flex w-full gap-x-4 items-end">
<div class="flex flex-col gap-1 w-3/12">
<label>Providers</label>
<p-multiselect id="provider" class="w-full" [filter]="false" showToggleAll="false" [options]="providers" formControlName="provider" placeholder="Select Providers"></p-multiselect>
</div>
<div class="flex flex-col gap-1 w-5/12">
<label for="title">Title</label>
<input pInputText formControlName="title" id="title" class="w-full"/>
</div>
<div class="flex flex-col gap-1 w-4/12">
<label for="author">Author</label>
<input pInputText formControlName="author" id="author" class="w-full"/>
</div>
<div>
<p-button label="Search" type="submit" outlined="true" [disabled]="!isSearchEnabled || loading"></p-button>
</div>
<p-divider></p-divider>
</div>
</div>
</form>
@if (loading) {
<div class="flex justify-center items-center">
<p-progress-spinner ariaLabel="loading"/>
</div>
}
@if (!loading) {
<div class="mt-8 flex-1 overflow-y-auto">
@for (metadata of allFetchedMetadata; track metadata) {
<div class="book-item flex flex-col w-full">
<div class="flex w-full flex-row book-item-content" (click)="onBookClick(metadata)">
<img [src]="metadata.thumbnailUrl || 'assets/images/missing-cover.jpg'" alt="Image" class="img-fixed-dimensions pr-2"/>
<div class=" flex flex-col w-full m-2">
<div class="flex flex-row gap-4 justify-between">
<p class="font-bold">{{ truncateText(metadata['title'], 90) }}</p>
<div class="flex gap-2">
<p>ISBN: {{ metadata['isbn10'] || metadata['asin'] }}</p>
<p> | </p>
<p>Published: {{ metadata['publishedDate'] }}</p>
</div>
</div>
<div class="flex gap-2">
<p>by {{ truncateText(metadata['authors'].join(', '), 70) }}</p>
<p> | </p>
<p>Source: <span [innerHTML]="buildProviderLink(metadata)"></span></p>
</div>
<p class="mt-4 truncate-text p-secondary">
{{ sanitizeHtml(metadata['description']) }}
</p>
</div>
</div>
<p-divider></p-divider>
</div>
}
</div>
}
</form>
}
<div *ngIf="selectedFetchedMetadata" class="h-full flex-auto">
<app-metadata-picker [fetchedMetadata]="selectedFetchedMetadata" (goBack)="onGoBack()"></app-metadata-picker>
</div>
@if (selectedFetchedMetadata) {
<div class="h-full flex-auto">
<app-metadata-picker [fetchedMetadata]="selectedFetchedMetadata" (goBack)="onGoBack()"></app-metadata-picker>
</div>
}
@@ -3,7 +3,7 @@ import {FormBuilder, FormGroup, ReactiveFormsModule} from '@angular/forms';
import {Button} from 'primeng/button';
import {InputText} from 'primeng/inputtext';
import {Divider} from 'primeng/divider';
import {NgForOf, NgIf} from '@angular/common';
import {FetchMetadataRequest} from '../../model/request/fetch-metadata-request.model';
import {ProgressSpinner} from 'primeng/progressspinner';
import {MetadataPickerComponent} from '../metadata-picker/metadata-picker.component';
@@ -21,7 +21,7 @@ import {ActivatedRoute} from '@angular/router';
selector: 'app-metadata-searcher',
templateUrl: './metadata-searcher.component.html',
styleUrls: ['./metadata-searcher.component.scss'],
imports: [ReactiveFormsModule, Button, InputText, Divider, NgForOf, NgIf, ProgressSpinner, MetadataPickerComponent, MultiSelect],
imports: [ReactiveFormsModule, Button, InputText, Divider, ProgressSpinner, MetadataPickerComponent, MultiSelect],
standalone: true
})
export class MetadataSearcherComponent implements OnInit, OnDestroy {
@@ -1,114 +1,117 @@
<div class="pt-2 flex flex-col h-full overflow-hidden">
<div *ngIf="metadata$ | async as metadata">
<div class="flex flex-row">
<div class="cover-wrapper relative">
<img
[attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)"
class="book-cover placeholder"
alt="Cover of {{ metadata.title }}"
loading="lazy"
width="225"
style="min-width: 225px;"
/>
<p-progressBar
*ngIf="getProgressPercent() !== null"
[value]="getProgressPercent()"
[showValue]="true"
[ngClass]="{ 'progress-complete': getProgressPercent() === 100, 'progress-incomplete': getProgressPercent()! < 100 }"
[style]="{ height: '10px' }">
</p-progressBar>
</div>
<div class="flex flex-col justify-between">
<div class="pl-6 flex flex-col w-full">
<div class="flex flex-row items-center justify-between">
<div>
<p *ngIf="metadata.seriesName" class="italic">{{ metadata.seriesName }} #{{ metadata.seriesNumber }}</p>
<div class="flex items-center gap-2">
<p class="text-2xl font-bold m-0">{{ metadata.title }}</p>
<i
class="pi"
[ngClass]="isMetadataFullyLocked(metadata) ? 'pi-lock text-red-500' : 'pi-lock-open text-green-500'"
[title]="isMetadataFullyLocked(metadata) ? 'Metadata is locked' : 'Metadata is unlocked'"
style="font-size: 1.25rem;"
pTooltip="{{ isMetadataFullyLocked(metadata) ? 'This book metadata is locked.' : 'This book metadata is unlocked.' }}"
tooltipPosition="top">
</i>
@if (metadata$ | async; as metadata) {
<div>
<div class="flex flex-row">
<div class="cover-wrapper relative">
<img
[attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)"
class="book-cover placeholder"
alt="Cover of {{ metadata.title }}"
loading="lazy"
width="225"
style="min-width: 225px;"
/>
@if (getProgressPercent() !== null) {
<p-progressBar
[value]="getProgressPercent()"
[showValue]="true"
[ngClass]="{ 'progress-complete': getProgressPercent() === 100, 'progress-incomplete': getProgressPercent()! < 100 }"
[style]="{ height: '10px' }">
</p-progressBar>
}
</div>
<div class="flex flex-col justify-between">
<div class="pl-6 flex flex-col w-full">
<div class="flex flex-row items-center justify-between">
<div>
@if (metadata.seriesName) {
<p class="italic">{{ metadata.seriesName }} #{{ metadata.seriesNumber }}</p>
}
<div class="flex items-center gap-2">
<p class="text-2xl font-bold m-0">{{ metadata.title }}</p>
<i
class="pi"
[ngClass]="isMetadataFullyLocked(metadata) ? 'pi-lock text-red-500' : 'pi-lock-open text-green-500'"
[title]="isMetadataFullyLocked(metadata) ? 'Metadata is locked' : 'Metadata is unlocked'"
style="font-size: 1.25rem;"
pTooltip="{{ isMetadataFullyLocked(metadata) ? 'This book metadata is locked.' : 'This book metadata is unlocked.' }}"
tooltipPosition="top">
</i>
</div>
<p class="text-xl">{{ getAuthorNames(metadata?.authors || []) }}</p>
</div>
<p class="text-xl">{{ getAuthorNames(metadata?.authors || []) }}</p>
</div>
</div>
<div class="flex items-center gap-2 pt-2">
<ng-container *ngIf="metadata.amazonRating || metadata.goodreadsRating || metadata.hardcoverRating; else legacyRating">
<ng-container *ngIf="metadata.amazonRating">
<ng-container *ngIf="metadata.asin; else amazonStatic">
<a class="flex items-center gap-1" [href]="'https://www.amazon.com/dp/' + metadata.asin" target="_blank" rel="noopener noreferrer">
<img src="https://www.amazon.com/favicon.ico" alt="Amazon" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.amazonRating }}</p>
</a>
</ng-container>
<ng-template #amazonStatic>
<span class="flex items-center gap-1">
<img src="https://www.amazon.com/favicon.ico" alt="Amazon" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.amazonRating }}</p>
</span>
</ng-template>
<p-rating [ngModel]="metadata.amazonRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
</p-rating>
<p class="font-semibold">({{ metadata.amazonReviewCount | number:'1.0-0' }})</p>
<span *ngIf="metadata.goodreadsRating || metadata.hardcoverRating">|</span>
</ng-container>
<ng-container *ngIf="metadata.goodreadsRating">
<ng-container *ngIf="metadata.goodreadsId; else goodreadsStatic">
<a class="flex items-center gap-1" [href]="'https://www.goodreads.com/book/show/' + metadata.goodreadsId" target="_blank" rel="noopener noreferrer">
<img src="https://www.goodreads.com/favicon.ico" alt="Goodreads" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.goodreadsRating }}</p>
</a>
</ng-container>
<ng-template #goodreadsStatic>
<span class="flex items-center gap-1">
<img src="https://www.goodreads.com/favicon.ico" alt="Goodreads" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.goodreadsRating }}</p>
</span>
</ng-template>
<p-rating [ngModel]="metadata.goodreadsRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
</p-rating>
<p class="font-semibold">({{ metadata.goodreadsReviewCount | number:'1.0-0' }})</p>
<span *ngIf="metadata.hardcoverRating">|</span>
</ng-container>
<ng-container *ngIf="metadata.hardcoverRating">
<ng-container *ngIf="metadata.hardcoverId; else hardcoverStatic">
<a class="flex items-center gap-1" [href]="'https://hardcover.app/books/' + metadata.hardcoverId" target="_blank" rel="noopener noreferrer">
<img src="https://assets.hardcover.app/static/favicon.ico" alt="Hardcover" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.hardcoverRating }}</p>
</a>
</ng-container>
<ng-template #hardcoverStatic>
<span class="flex items-center gap-1">
<img src="https://assets.hardcover.app/static/favicon.ico" alt="Hardcover" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.hardcoverRating }}</p>
</span>
</ng-template>
<p-rating [ngModel]="metadata.hardcoverRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
</p-rating>
<p class="font-semibold">({{ metadata.hardcoverReviewCount | number:'1.0-0' }})</p>
<span *ngIf="(metadata.amazonRating || metadata.goodreadsRating || metadata.hardcoverRating) && metadata.googleId">|</span>
</ng-container>
<ng-container *ngIf="metadata.googleId">
<div class="flex items-center gap-2 pt-2">
@if (metadata.amazonRating || metadata.goodreadsRating || metadata.hardcoverRating) {
@if (metadata.amazonRating) {
@if (metadata.asin) {
<a class="flex items-center gap-1" [href]="'https://www.amazon.com/dp/' + metadata.asin" target="_blank" rel="noopener noreferrer">
<img src="https://www.amazon.com/favicon.ico" alt="Amazon" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.amazonRating }}</p>
</a>
} @else {
<span class="flex items-center gap-1">
<img src="https://www.amazon.com/favicon.ico" alt="Amazon" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.amazonRating }}</p>
</span>
}
<p-rating [ngModel]="metadata.amazonRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
</p-rating>
<p class="font-semibold">({{ metadata.amazonReviewCount | number:'1.0-0' }})</p>
@if (metadata.goodreadsRating || metadata.hardcoverRating) {
<span>|</span>
}
}
@if (metadata.goodreadsRating) {
@if (metadata.goodreadsId) {
<a class="flex items-center gap-1" [href]="'https://www.goodreads.com/book/show/' + metadata.goodreadsId" target="_blank" rel="noopener noreferrer">
<img src="https://www.goodreads.com/favicon.ico" alt="Goodreads" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.goodreadsRating }}</p>
</a>
} @else {
<span class="flex items-center gap-1">
<img src="https://www.goodreads.com/favicon.ico" alt="Goodreads" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.goodreadsRating }}</p>
</span>
}
<p-rating [ngModel]="metadata.goodreadsRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
</p-rating>
<p class="font-semibold">({{ metadata.goodreadsReviewCount | number:'1.0-0' }})</p>
@if (metadata.hardcoverRating) {
<span>|</span>
}
}
@if (metadata.hardcoverRating) {
@if (metadata.hardcoverId) {
<a class="flex items-center gap-1" [href]="'https://hardcover.app/books/' + metadata.hardcoverId" target="_blank" rel="noopener noreferrer">
<img src="https://assets.hardcover.app/static/favicon.ico" alt="Hardcover" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
<p class="font-semibold">{{ metadata.hardcoverRating }}</p>
</a>
} @else {
<span class="flex items-center gap-1">
<img src="https://assets.hardcover.app/static/favicon.ico" alt="Hardcover" class="w-5 h-5 object-contain" />
<p class="font-semibold">{{ metadata.hardcoverRating }}</p>
</span>
}
<p-rating [ngModel]="metadata.hardcoverRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
</p-rating>
<p class="font-semibold">({{ metadata.hardcoverReviewCount | number:'1.0-0' }})</p>
@if ((metadata.amazonRating || metadata.goodreadsRating || metadata.hardcoverRating) && metadata.googleId) {
<span>|</span>
}
}
@if (metadata.googleId) {
<a class="flex items-center gap-1" [href]="'https://books.google.com/books?id=' + metadata.googleId" target="_blank" rel="noopener noreferrer">
<img src="https://books.google.com/favicon.ico" alt="Google Books" class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg" />
</a>
</ng-container>
</ng-container>
}
} @else {
<ng-template #legacyRating>
<p-rating
[(ngModel)]="metadata.rating"
readonly
@@ -117,179 +120,184 @@
</p-rating>
<p class="font-semibold">
{{ metadata?.reviewCount ? '(' + (metadata?.reviewCount | number:'1.0-0') + ' Ratings)' : 'No Ratings' }}
</p>
}
</div>
<div class="flex gap-2 pt-4 overflow-x-auto scrollbar-hide">
@for (category of metadata.categories; track category) {
<p-tag [value]="category" class="shrink-0"></p-tag>
}
</div>
<div class="grid gap-x-20 gap-y-2 pt-6" style="grid-template-columns: repeat(5, max-content);">
<p class="whitespace-nowrap flex items-center gap-2">
<span class="font-bold">File Type:</span>
<span
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
[ngClass]="getFileTypeColorClass(getFileExtension(book?.filePath))">
{{ getFileExtension(book?.filePath) || '-' }}
</span>
</p>
</ng-template>
</div>
<div class="flex gap-2 pt-4 overflow-x-auto scrollbar-hide">
<p-tag *ngFor="let category of metadata.categories" [value]="category" class="shrink-0"></p-tag>
</div>
<div class="grid gap-x-20 gap-y-2 pt-6" style="grid-template-columns: repeat(5, max-content);">
<p class="whitespace-nowrap flex items-center gap-2">
<span class="font-bold">File Type:</span>
<span
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
[ngClass]="getFileTypeColorClass(getFileExtension(book?.filePath))">
{{ getFileExtension(book?.filePath) || '-' }}
</span>
</p>
<p class="whitespace-nowrap"><span class="font-bold">Publisher:</span> {{ metadata.publisher || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Published:</span> {{ metadata.publishedDate || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Language:</span> {{ metadata.language || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">ISBN 10:</span> {{ metadata.isbn10 || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">ISBN 13:</span> {{ metadata.isbn13 || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Page Count:</span> {{ metadata.pageCount || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">File Size:</span> {{ getFileSizeInMB() }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Progress:</span> {{ getProgressPercent() !== null ? getProgressPercent() + '%' : '-' }}</p>
</div>
<div class="pt-2 flex items-center gap-2 w-full">
<span class="font-semibold flex-shrink-0">File Path:</span>
<p-toggleButton
[(ngModel)]="showFilePath"
onIcon="pi pi-eye-slash"
offIcon="pi pi-eye"
onLabel=""
offLabel=""
size="small"
<p class="whitespace-nowrap"><span class="font-bold">Publisher:</span> {{ metadata.publisher || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Published:</span> {{ metadata.publishedDate || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Language:</span> {{ metadata.language || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">ISBN 10:</span> {{ metadata.isbn10 || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">ISBN 13:</span> {{ metadata.isbn13 || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Page Count:</span> {{ metadata.pageCount || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">File Size:</span> {{ getFileSizeInMB() }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Progress:</span> {{ getProgressPercent() !== null ? getProgressPercent() + '%' : '-' }}</p>
</div>
<div class="pt-2 flex items-center gap-2 w-full">
<span class="font-semibold flex-shrink-0">File Path:</span>
<p-toggleButton
[(ngModel)]="showFilePath"
onIcon="pi pi-eye-slash"
offIcon="pi pi-eye"
onLabel=""
offLabel=""
size="small"
class="flex-shrink-0"></p-toggleButton>
<div
class="flex items-center gap-4 flex-grow"
*ngIf="showFilePath"
style="min-width: 0;">
<p
class="font-mono text-sm text-gray-400 overflow-x-auto whitespace-nowrap flex-grow"
style="min-width: 0;">
{{ book?.filePath }}
</p>
@if (showFilePath) {
<div
class="flex items-center gap-4 flex-grow"
style="min-width: 0;">
<p
class="font-mono text-sm text-gray-400 overflow-x-auto whitespace-nowrap flex-grow"
style="min-width: 0;">
{{ book?.filePath }}
</p>
</div>
}
</div>
</div>
</div>
<div *ngIf="userService.userState$ | async as userData" class="pl-6 pt-4 flex flex-row w-full gap-4">
<p-splitbutton
*ngIf="book!.bookType === 'PDF'"
label="Read"
icon="pi pi-book"
[model]="readMenuItems"
(onClick)="read(metadata.bookId, 'ngx')"
severity="info"/>
<p-button
*ngIf="book!.bookType !== 'PDF'"
label="Read"
icon="pi pi-book"
(onClick)="read(metadata.bookId, undefined)"
severity="info"/>
<p-button
label="Assign Shelf"
icon="pi pi-folder"
severity="info"
outlined
(onClick)="assignShelf(metadata.bookId)">
</p-button>
<p-button
*ngIf="userData.permissions.canDownload || userData.permissions.admin"
label="Download"
icon="pi pi-download"
severity="info"
outlined
(onClick)="download(metadata.bookId)">
</p-button>
<p-splitbutton
*ngIf="userData.permissions.canEmailBook || userData.permissions.admin"
label="Quick Send"
icon="pi pi-send"
[model]="emailMenuItems"
(onClick)="quickSend(metadata.bookId)"
outlined
severity="info">
</p-splitbutton>
<p-splitbutton
*ngIf="userData.permissions.canEditMetadata || userData.permissions.admin"
label="Quick Refresh"
icon="pi pi-bolt"
[model]="refreshMenuItems"
(onClick)="quickRefresh(metadata.bookId)"
outlined
severity="info">
</p-splitbutton>
@if (userService.userState$ | async; as userData) {
<div class="pl-6 pt-4 flex flex-row w-full gap-4">
@if (book!.bookType === 'PDF') {
<p-splitbutton
label="Read"
icon="pi pi-book"
[model]="readMenuItems"
(onClick)="read(metadata.bookId, 'ngx')"
severity="info"/>
}
@if (book!.bookType !== 'PDF') {
<p-button
label="Read"
icon="pi pi-book"
(onClick)="read(metadata.bookId, undefined)"
severity="info"/>
}
<p-button
label="Assign Shelf"
icon="pi pi-folder"
severity="info"
outlined
(onClick)="assignShelf(metadata.bookId)">
</p-button>
@if (userData.permissions.canDownload || userData.permissions.admin) {
<p-button
label="Download"
icon="pi pi-download"
severity="info"
outlined
(onClick)="download(metadata.bookId)">
</p-button>
}
@if (userData.permissions.canEmailBook || userData.permissions.admin) {
<p-splitbutton
label="Quick Send"
icon="pi pi-send"
[model]="emailMenuItems"
(onClick)="quickSend(metadata.bookId)"
outlined
severity="info">
</p-splitbutton>
}
@if (userData.permissions.canEditMetadata || userData.permissions.admin) {
<p-splitbutton
label="Quick Refresh"
icon="pi pi-bolt"
[model]="refreshMenuItems"
(onClick)="quickRefresh(metadata.bookId)"
outlined
severity="info">
</p-splitbutton>
}
</div>
}
</div>
</div>
</div>
</div>
}
<p-divider></p-divider>
<div *ngIf="metadata$ | async as metadata" class="flex-1 overflow-auto space-y-2 px-2">
<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: '250px'}" [(ngModel)]="metadata.description">
<ng-template #header>
</ng-template>
</p-editor>
</div>
</div>
<div *ngIf="metadata.description && metadata.description.length > 100" class="text-left">
<button pButton
type="button"
[label]="isExpanded ? 'Show less' : 'Show more'"
[icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
iconPos="right"
class="p-button-text p-button-sm"
(click)="toggleExpand()">
</button>
</div>
<p-divider></p-divider>
<ng-container *ngIf="bookInSeries.length > 0">
<div>
<h3 class="text-xl font-semibold pt-2">More in the Series</h3>
<div class="dashboard-scroller-infinite"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
[horizontal]="true">
<div class="dashboard-scroller-card" *ngFor="let book of bookInSeries">
<app-book-card
[book]="book"
[isCheckboxEnabled]="false"
[readButtonHidden]="true"
[bottomBarHidden]="true">
</app-book-card>
</div>
@if (metadata$ | async; as metadata) {
<div class="flex-1 overflow-auto space-y-2 px-2">
<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: '250px'}" [(ngModel)]="metadata.description">
<ng-template #header>
</ng-template>
</p-editor>
</div>
</div>
@if (metadata.description && metadata.description.length > 100) {
<div class="text-left">
<button pButton
type="button"
[label]="isExpanded ? 'Show less' : 'Show more'"
[icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
iconPos="right"
class="p-button-text p-button-sm"
(click)="toggleExpand()">
</button>
</div>
}
<p-divider></p-divider>
</ng-container>
<ng-container *ngIf="recommendedBooks.length > 0">
<div>
<h3 class="text-xl font-semibold">Similar Books</h3>
<div class="dashboard-scroller-infinite"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
[horizontal]="true">
<div class="dashboard-scroller-card" *ngFor="let book of recommendedBooks">
<app-book-card
[book]="book.book"
[isCheckboxEnabled]="false"
[readButtonHidden]="true"
[bottomBarHidden]="true">
</app-book-card>
@if (bookInSeries.length > 0) {
<div>
<h3 class="text-xl font-semibold pt-2">More in the Series</h3>
<div class="dashboard-scroller-infinite"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
[horizontal]="true">
@for (book of bookInSeries; track book) {
<div class="dashboard-scroller-card">
<app-book-card
[book]="book"
[isCheckboxEnabled]="false"
[readButtonHidden]="true"
[bottomBarHidden]="true">
</app-book-card>
</div>
}
</div>
</div>
</div>
<p-divider></p-divider>
</ng-container>
</div>
<p-divider></p-divider>
}
@if (recommendedBooks.length > 0) {
<div>
<h3 class="text-xl font-semibold">Similar Books</h3>
<div class="dashboard-scroller-infinite"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
[horizontal]="true">
@for (book of recommendedBooks; track book) {
<div class="dashboard-scroller-card">
<app-book-card
[book]="book.book"
[isCheckboxEnabled]="false"
[readButtonHidden]="true"
[bottomBarHidden]="true">
</app-book-card>
</div>
}
</div>
</div>
<p-divider></p-divider>
}
</div>
}
</div>
@@ -1,6 +1,6 @@
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core';
import {Button, ButtonDirective} from 'primeng/button';
import {AsyncPipe, DecimalPipe, NgClass, NgForOf, NgIf} from '@angular/common';
import { AsyncPipe, DecimalPipe, NgClass } from '@angular/common';
import {first, Observable} from 'rxjs';
import {BookService} from '../../../service/book.service';
import {BookMetadataCenterService} from '../book-metadata-center.service';
@@ -33,7 +33,7 @@ import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-reque
standalone: true,
templateUrl: './metadata-viewer.component.html',
styleUrl: './metadata-viewer.component.scss',
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective, Editor, ProgressBar, ToggleButton]
imports: [Button, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective, Editor, ProgressBar, ToggleButton]
})
export class MetadataViewerComponent implements OnInit, OnChanges {
@@ -1,75 +1,77 @@
<div class="flex flex-col space-y-6 p-4">
<table class="min-w-full table-auto border-collapse custom-table">
<thead>
<tr>
<th class="px-4 py-2 text-left font-semibold text-gray-300">Book Field</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">4th Priority</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">3rd Priority</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">2nd Priority</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">1st Priority</th>
</tr>
<tr>
<th class="px-4 py-2 text-left font-semibold text-gray-300">Book Field</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">4th Priority</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">3rd Priority</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">2nd Priority</th>
<th class="px-4 py-2 text-left font-semibold text-gray-300">1st Priority</th>
</tr>
</thead>
<tbody>
<tr>
<td class="px-4 py-2 text-gray-300">All Other Fields</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP4.value"
(onChange)="syncProvider($event, 'p4')"
placeholder="Select All" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP3.value"
(onChange)="syncProvider($event, 'p3')"
placeholder="Select All" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP2.value"
(onChange)="syncProvider($event, 'p2')"
placeholder="Select All" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP1.value"
(onChange)="syncProvider($event, 'p1')"
placeholder="Select All" appendTo="body"
class="w-full">
</p-select>
</td>
</tr>
<tr>
<td class="px-4 py-2 text-gray-300">All Other Fields</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP4.value"
(onChange)="syncProvider($event, 'p4')"
placeholder="Select All" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP3.value"
(onChange)="syncProvider($event, 'p3')"
placeholder="Select All" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP2.value"
(onChange)="syncProvider($event, 'p2')"
placeholder="Select All" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="allP1.value"
(onChange)="syncProvider($event, 'p1')"
placeholder="Select All" appendTo="body"
class="w-full">
</p-select>
</td>
</tr>
<tr *ngFor="let field of fields" [hidden]="field === 'cover' && !refreshCovers">
<td class="px-4 py-2 text-gray-300">{{ formatLabel(field) }}</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p4"
placeholder="Unset" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
placeholder="Unset" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
placeholder="Unset" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
placeholder="Unset" appendTo="body"
class="w-full">
</p-select>
</td>
</tr>
@for (field of fields; track field) {
<tr [hidden]="field === 'cover' && !refreshCovers">
<td class="px-4 py-2 text-gray-300">{{ formatLabel(field) }}</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p4"
placeholder="Unset" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
placeholder="Unset" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
placeholder="Unset" appendTo="body"
class="w-full">
</p-select>
</td>
<td class="px-4 py-2">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
placeholder="Unset" appendTo="body"
class="w-full">
</p-select>
</td>
</tr>
}
</tbody>
</table>
@@ -3,7 +3,7 @@ import {
} from '@angular/core';
import {Select, SelectChangeEvent} from 'primeng/select';
import {FormsModule} from '@angular/forms';
import {NgForOf} from '@angular/common';
import {Checkbox} from 'primeng/checkbox';
import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api';
@@ -16,7 +16,7 @@ import {
@Component({
selector: 'app-metadata-advanced-fetch-options',
templateUrl: './metadata-advanced-fetch-options.component.html',
imports: [Select, FormsModule, NgForOf, Checkbox, Button],
imports: [Select, FormsModule, Checkbox, Button],
styleUrl: './metadata-advanced-fetch-options.component.scss',
standalone: true
})