Introduce multi-format book support, including audiobooks (#2486)

* fix: support reading alternative book formats using bookType query param

* feat: add streaming reader support for alternative EPUB formats

* refactor: extract tabs section into MetadataTabsComponent

* feat: implement per-file reading progress tracking

* feat: add configurable format priority with cascading fallback

* refactor: redesign library creator with single-page layout

* refactor: unify reading progress into ReadingProgressService

* refactor: improve delete options with clearer file format and book deletion

* refactor: improve book format matching with normalization and fuzzy fallback

* feat: add folder-based audiobook support with ZIP downloads and preparing state

* fix: display unique format types in metadata viewer

* refactor: auto-attach files to single book in folder during rescan

* feat: implement folder-centric book file grouping with fuzzy matching

* refactor: consolidate book grouping with organization mode support

* fix: use folder hash for folder-based audiobooks in auto-attach

* fix: delete only BookFileEntity on file removal, not entire book

* fix: set folderBased flag and correct file size for auto-attached audiobook folders

* fix: use count query to avoid lazy initialization in file delete handler

* fix: preserve book metadata when file is moved by detecting hash match

* fix: skip books with no files in restoration to avoid NPE

* fix: round all progress percentages to one decimal place before sending to UI

* style: improve library creator dialog spacing and layout

* fix: migrate FOLDER_AS_BOOK to BOOK_PER_FOLDER for backwards compatibility

* fix: FileMoveService now handles multi-file BookEntity properly

* style: redesign metadata-picker and file-mover UI components

* style: redesign file-naming-pattern UI and improve theme contrast

* style: relax spacing in library-creator component

* style: tighten directory-picker layout for consistency

* fix: PathPatternResolver now respects folderBased flag for audiobooks

* style: move checkmark column to left side and add pending status in file-mover

* refactor: consolidate BookFileType into BookType and add audiobook styling

* feat: show 'Continue Reading' button for in-progress books

* fix: preserve dots in folder names during grouping and prevent duplicate attachments

* style: reduce gap between download-all button and primary file section

* style: shorten 'Continue Reading' button to 'Read' on mobile

* feat: add DISK_TYPE config to disable file moves on network storage

* style: standardize settings pages with shared styles and consistent spacing

* style: revamp settings pages with modern card-based layouts

* style: revamp OPDS, auth, and task management settings layouts

* fix: update FileMoveService tests to include AppProperties parameter

* fix: derive BookFileType from extension when uploading additional book files

* feat: show format type and size in download button with dropdown for alternatives

* feat: add audiobook streaming player with HTTP Range support

* feat: add M4B chapter extraction and chapter navigation

* feat: add audiobook bookmarks and sleep timer

* refactor: split AudiobookReaderService into focused services

* feat: add Media Session API for background audio playback

* feat: display file extensions in format tags with distinct colors and add audiobook upload support

* feat: require bookFileId for viewer settings API

* fix: show split button for audiobooks with readable alternatives

* feat: improve reading sessions table with book type badges and better formatting

* feat: add audiobook play button in files tab

* feat: use file extension for format display and meaningful tab values

* feat: add extension field to BookFile DTO

* feat: use extension field for book card format pill

* fix: use mixed orientation for format priority drag-drop to support multi-line layout

* feat: add attach book files feature to consolidate single-file books

* fix: increase drag handle size for format priority chips

* fix: add missing BookFileRepository mock to BookServiceDeleteTests

* feat: add delete buttons to files tab and move shelf to other items menu

* feat: add physical books support for cataloging books without digital files

* refactor: redesign icon-picker component with improved styling

* refactor: redesign metadata-picker component with improved layout and alignment

* refactor: move Add Physical Book to top of library menu

* refactor: use p-autoComplete for authors/categories in add-physical-book dialog

* feat: add square cover search and display support for audiobooks

* fix: navigate to first page when opening unread ebooks

* fix: exclude API requests from service worker interception

* feat: support fileless books with automatic file attachment

* fix: bypass service worker for audiobook streaming requests

* refactor: remove alphabetical filter sorting, default to count, limit filters to 100

---------

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-27 10:12:50 -07:00
committed by GitHub
co-authored by acx10
parent c23e38b5a5
commit 3f334202b6
340 changed files with 23225 additions and 20727 deletions
@@ -24,8 +24,8 @@
class="p-datatable-sm">
<ng-template #header>
<tr>
<th>Start Time</th>
<th>End Time</th>
<th>Session</th>
<th>Type</th>
<th>Duration</th>
<th>Progress</th>
<th>Progress Delta</th>
@@ -34,8 +34,18 @@
</ng-template>
<ng-template #body let-session>
<tr>
<td>{{ formatDate(session.startTime) }}</td>
<td>{{ formatDate(session.endTime) }}</td>
<td>
<div class="session-time">
<span class="session-date">{{ formatSessionDate(session.startTime) }}</span>
<span class="session-range">{{ formatTime(session.startTime) }} → {{ formatTime(session.endTime) }}</span>
</div>
</td>
<td>
<span class="book-type-badge" [ngClass]="'book-type-' + session.bookType.toLowerCase()">
<i [class]="getBookTypeIcon(session.bookType)"></i>
<span>{{ formatBookType(session.bookType) }}</span>
</span>
</td>
<td>{{ getActualDuration(session) }}</td>
<td>
@if (session.startProgress !== null && session.startProgress !== undefined && session.endProgress !== null && session.endProgress !== undefined) {
@@ -46,14 +56,17 @@
</td>
<td>
@if (session.progressDelta !== null && session.progressDelta !== undefined) {
<p-tag [value]="(session.progressDelta > 0 ? '+' : '') + session.progressDelta + '%'" [severity]="getProgressColor(session.progressDelta)"></p-tag>
<span class="progress-delta-badge" [ngClass]="getProgressDeltaClass(session.progressDelta)">
<i [class]="getProgressDeltaIcon(session.progressDelta)"></i>
<span>{{ (session.progressDelta > 0 ? '+' : '') + session.progressDelta }}%</span>
</span>
} @else {
<span class="text-color-secondary">N/A</span>
<span class="text-color-secondary">-</span>
}
</td>
<td>
@if (session.startLocation && session.endLocation && isPageNumber(session.startLocation)) {
<span class="location-text">Page {{ session.startLocation }} → Page {{ session.endLocation }}</span>
@if (session.startLocation && session.endLocation) {
<span class="location-text">{{ formatLocation(session) }}</span>
} @else {
<span class="text-color-secondary">-</span>
}
@@ -27,6 +27,103 @@
color: var(--text-color);
}
.session-time {
display: flex;
flex-direction: column;
gap: 0.125rem;
.session-date {
font-weight: 500;
color: var(--text-color);
}
.session-range {
font-size: 0.8rem;
color: var(--text-color-secondary);
}
}
.book-type-badge {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.25rem 0.5rem;
border-radius: 0.375rem;
font-size: 0.8rem;
font-weight: 600;
i {
font-size: 0.8rem;
}
&.book-type-pdf {
color: var(--book-type-pdf-color);
background-color: rgba(220, 38, 38, 0.1);
}
&.book-type-epub {
color: var(--book-type-epub-color);
background-color: rgba(22, 163, 74, 0.1);
}
&.book-type-cbx,
&.book-type-cbz,
&.book-type-cbr,
&.book-type-cb7 {
color: var(--book-type-cbx-color);
background-color: rgba(59, 130, 246, 0.1);
}
&.book-type-fb2 {
color: var(--book-type-fb2-color);
background-color: rgba(236, 72, 153, 0.1);
}
&.book-type-mobi {
color: var(--book-type-mobi-color);
background-color: rgba(99, 102, 241, 0.1);
}
&.book-type-azw3 {
color: var(--book-type-azw3-color);
background-color: rgba(20, 184, 166, 0.1);
}
&.book-type-audiobook {
color: var(--book-type-audiobook-color);
background-color: rgba(234, 179, 8, 0.1);
}
}
.progress-delta-badge {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.25rem 0.5rem;
border-radius: 0.375rem;
font-size: 0.8rem;
font-weight: 600;
i {
font-size: 0.8rem;
}
&.progress-positive {
color: #16a34a;
background-color: rgba(22, 163, 74, 0.1);
}
&.progress-negative {
color: #dc2626;
background-color: rgba(220, 38, 38, 0.1);
}
&.progress-neutral {
color: var(--text-color-secondary);
background-color: rgba(128, 128, 128, 0.1);
}
}
:host ::ng-deep {
.p-datatable {
.p-datatable-thead > tr > th {
@@ -3,12 +3,10 @@ import {CommonModule} from '@angular/common';
import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
import {TableModule} from 'primeng/table';
import {ProgressSpinnerModule} from 'primeng/progressspinner';
import {TagModule} from 'primeng/tag';
@Component({
selector: 'app-book-reading-sessions',
standalone: true,
imports: [CommonModule, TableModule, ProgressSpinnerModule, TagModule],
imports: [CommonModule, TableModule, ProgressSpinnerModule],
templateUrl: './book-reading-sessions.component.html',
styleUrls: ['./book-reading-sessions.component.scss']
})
@@ -91,14 +89,79 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
return new Date(dateString).toLocaleString();
}
formatSessionDate(dateString: string): string {
return new Date(dateString).toLocaleDateString(undefined, {
month: 'short',
day: 'numeric',
year: 'numeric'
});
}
formatTime(dateString: string): string {
return new Date(dateString).toLocaleTimeString(undefined, {
hour: 'numeric',
minute: '2-digit'
});
}
getBookTypeIcon(bookType: string): string {
const iconMap: Record<string, string> = {
'PDF': 'pi pi-file-pdf',
'EPUB': 'pi pi-book',
'CBX': 'pi pi-images',
'CBZ': 'pi pi-images',
'CBR': 'pi pi-images',
'CB7': 'pi pi-images',
'FB2': 'pi pi-file',
'MOBI': 'pi pi-book',
'AZW3': 'pi pi-book',
'AUDIOBOOK': 'pi pi-headphones'
};
return iconMap[bookType] || 'pi pi-file';
}
formatBookType(bookType: string): string {
if (bookType === 'AUDIOBOOK') return 'Audio';
return bookType;
}
getProgressColor(delta: number): 'success' | 'secondary' | 'danger' {
if (delta > 0) return 'success';
if (delta < 0) return 'danger';
return 'secondary';
}
getProgressDeltaClass(delta: number): string {
if (delta > 0) return 'progress-positive';
if (delta < 0) return 'progress-negative';
return 'progress-neutral';
}
getProgressDeltaIcon(delta: number): string {
if (delta > 0) return 'pi pi-arrow-up';
if (delta < 0) return 'pi pi-arrow-down';
return 'pi pi-minus';
}
isPageNumber(location: string | undefined): boolean {
if (!location) return false;
return !isNaN(Number(location)) && location.trim() !== '';
}
formatLocation(session: ReadingSessionResponse): string {
const start = session.startLocation;
const end = session.endLocation;
if (!start || !end) return '-';
if (session.bookType === 'AUDIOBOOK') {
return `${start} → ${end}`;
}
if (this.isPageNumber(start)) {
return `Page ${start} → ${end}`;
}
return '-';
}
}
@@ -1,465 +1,354 @@
@if (book$ | async; as book) {
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="form-container">
<div class="form-content">
<div class="metadata-header desktop-only">
<p class="metadata-header-text">Current Metadata</p>
<p-button
severity="info"
icon='pi pi-angle-left'
class="button-left"
[outlined]="true"
pTooltip="Move all missing fields" tooltipPosition="bottom"
(onClick)="copyMissing()"></p-button>
<p-button
severity="info"
icon='pi pi-angle-double-left'
class="button-double-left"
[outlined]="true"
pTooltip="Move all fields" tooltipPosition="bottom"
(onClick)="copyAll()"></p-button>
<p class="metadata-header-text">Fetched Metadata</p>
</div>
<div class="metadata-header-mobile mobile-only">
<p-button
severity="info"
icon='pi pi-angle-up'
label="Copy Missing"
[outlined]="true"
size="small"
(onClick)="copyMissing()"></p-button>
<p-button
severity="info"
icon='pi pi-angle-double-up'
label="Copy All"
[outlined]="true"
size="small"
(onClick)="copyAll()"></p-button>
</div>
<!-- Thumbnail Row -->
<div class="form-row thumbnail-row">
<label class="label desktop-only"></label>
<div class="input-container thumbnail-container">
<!-- Mobile layout: current image -> lock -> arrow -> fetched image -->
<div class="mobile-thumbnail-row mobile-only">
<p-image
class="thumbnail"
[src]="metadataForm.get('thumbnailUrl')?.value"
alt="Image"
appendTo="body"
lazyLoad
[preview]="true">
</p-image>
@if (!metadataForm.get('coverLocked')?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success" size="small"></p-button>
}
@if (metadataForm.get('coverLocked')?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn" size="small"></p-button>
}
<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"
size="small"
(click)="hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? resetField('thumbnailUrl') : copyFetchedToCurrent('thumbnailUrl')"
(mouseenter)="onMouseEnter('thumbnailUrl')"
(mouseleave)="onMouseLeave('thumbnailUrl')"/>
<p-image
class="thumbnail"
[src]="fetchedMetadata.thumbnailUrl!"
alt="Image"
appendTo="body"
lazyLoad
[preview]="true">
</p-image>
</div>
<!-- Desktop layout -->
<div class="desktop-only desktop-field-row">
@if (!metadataForm.get('coverLocked')?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
}
@if (metadataForm.get('coverLocked')?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
}
<p-image
class="thumbnail"
[src]="metadataForm.get('thumbnailUrl')?.value"
alt="Image"
appendTo="body"
lazyLoad
[preview]="true">
</p-image>
<input type="hidden" id="thumbnailUrl" formControlName="thumbnailUrl" class="input"/>
<p-button
[icon]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : (hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"
[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/>
<p-image
class="thumbnail"
[src]="fetchedMetadata.thumbnailUrl!"
alt="Image"
appendTo="body"
lazyLoad
[preview]="true">
</p-image>
</div>
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="metadata-picker">
<div class="dialog-body">
<!-- Column Headers (Desktop) -->
<div class="column-headers desktop-only">
<div class="column-label current">
<i class="pi pi-file-edit"></i>
<span>Current</span>
</div>
<div class="column-actions">
<p-button
icon="pi pi-angle-left"
[rounded]="true"
[outlined]="true"
severity="secondary"
pTooltip="Copy missing fields"
tooltipPosition="bottom"
(onClick)="copyMissing()"
/>
<p-button
icon="pi pi-angle-double-left"
[rounded]="true"
[outlined]="true"
severity="primary"
pTooltip="Copy all fields"
tooltipPosition="bottom"
(onClick)="copyAll()"
/>
</div>
<div class="column-label fetched">
<i class="pi pi-cloud-download"></i>
<span>Fetched</span>
</div>
</div>
@for (field of metadataFieldsTop; track field) {
<div class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<!-- Mobile layout -->
<div class="mobile-field-row mobile-only">
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success" size="small"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn" size="small"></p-button>
}
@if (field.controlName === 'publishedDate') {
<input pSize="small" fluid pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input" placeholder="YYYY-MM-DD"/>
} @else {
<input pSize="small" fluid pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
}
</div>
<div class="mobile-field-row mobile-only">
<input pSize="small" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input fetched-input" readonly/>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-up')"
[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"
size="small"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
</div>
<!-- Desktop layout -->
<div class="desktop-only desktop-field-row">
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
@if (field.controlName === 'publishedDate') {
<input pSize="small" fluid pInputText formControlName="{{field.controlName}}" class="input" placeholder="YYYY-MM-DD"/>
} @else {
<input pSize="small" fluid pInputText 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 pSize="small" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
</div>
</div>
<!-- Cover Image Section -->
<section class="form-section">
<div class="section-header">
<i class="pi pi-image"></i>
<span>Cover Image</span>
</div>
}
@for (field of metadataChips; track field) {
<div class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<!-- Mobile layout -->
<div class="mobile-field-row mobile-only">
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success" size="small"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn" size="small"></p-button>
}
<div class="autocomplete-container">
<p-autoComplete
class="autocomplete-full-width"
formControlName="{{field.controlName}}"
[multiple]="true"
[dropdown]="false"
[forceSelection]="false"
[showClear]="true"
[suggestions]="getFiltered(field.controlName)"
(completeMethod)="filterItems($event, field.controlName)"
(onKeyUp)="onAutoCompleteKeyUp(field.controlName, $event)"
(onSelect)="onAutoCompleteSelect(field.controlName, $event)">
</p-autoComplete>
<div class="section-content">
<div class="field-row cover-field-row">
<label class="field-label">Cover</label>
<div class="field-content">
<div class="field-side current cover-side">
<span class="cover-label mobile-only">Current</span>
<div class="cover-wrapper">
<p-image
class="cover-image"
[src]="metadataForm.get('thumbnailUrl')?.value"
alt="Current cover"
appendTo="body"
lazyLoad
[preview]="true"
/>
<button
type="button"
class="lock-badge"
[class.locked]="metadataForm.get('coverLocked')?.value"
(click)="toggleLock('thumbnailUrl')"
[pTooltip]="metadataForm.get('coverLocked')?.value ? 'Unlock cover' : 'Lock cover'"
tooltipPosition="top"
>
<i [class]="metadataForm.get('coverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
</div>
</div>
</div>
<div class="mobile-field-row mobile-only">
<div class="autocomplete-container">
<p-autoComplete
[ngModel]="fetchedMetadata[field.fetchedKey] ?? []"
[ngModelOptions]="{ standalone: true }"
[disabled]="true"
[multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" class="autocomplete-full-width fetched-input">
</p-autoComplete>
</div>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-up')"
[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"
size="small"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
</div>
<!-- Desktop layout -->
<div class="desktop-only desktop-field-row">
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
<div class="autocomplete-container">
<p-autoComplete
class="autocomplete-full-width"
formControlName="{{field.controlName}}"
[multiple]="true"
[dropdown]="false"
[forceSelection]="false"
[showClear]="true"
[suggestions]="getFiltered(field.controlName)"
(completeMethod)="filterItems($event, field.controlName)"
(onKeyUp)="onAutoCompleteKeyUp(field.controlName, $event)"
(onSelect)="onAutoCompleteSelect(field.controlName, $event)">
</p-autoComplete>
</div>
<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)"/>
<div class="autocomplete-container">
<p-autoComplete
[ngModel]="fetchedMetadata[field.fetchedKey] ?? []"
[ngModelOptions]="{ standalone: true }"
[disabled]="true"
[multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" class="autocomplete-full-width">
</p-autoComplete>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved('thumbnailUrl')"
[class.copied]="isValueCopied('thumbnailUrl') && !hoveredFields['thumbnailUrl']"
[class.reset]="isValueCopied('thumbnailUrl') && hoveredFields['thumbnailUrl']"
(click)="hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? resetField('thumbnailUrl') : copyFetchedToCurrent('thumbnailUrl')"
(mouseenter)="onMouseEnter('thumbnailUrl')"
(mouseleave)="onMouseLeave('thumbnailUrl')"
>
<i [class]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : (hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched cover-side">
<span class="cover-label mobile-only">Fetched</span>
<div class="cover-wrapper">
<p-image
class="cover-image"
[src]="fetchedMetadata.thumbnailUrl!"
alt="Fetched cover"
appendTo="body"
lazyLoad
[preview]="true"
/>
</div>
</div>
</div>
</div>
</div>
}
</section>
@for (field of metadataDescription; track field) {
<div class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<!-- Mobile layout -->
<div class="mobile-field-row mobile-only">
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success" size="small"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn" size="small"></p-button>
}
<textarea rows="3" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
</div>
<div class="mobile-field-row mobile-only">
<textarea rows="3" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input fetched-input" readonly></textarea>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-up')"
[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"
size="small"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
</div>
<!-- Desktop layout -->
<div class="desktop-only desktop-field-row">
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
<textarea rows="3" pTextarea 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="3" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly></textarea>
</div>
</div>
<!-- Basic Information Section -->
<section class="form-section">
<div class="section-header">
<i class="pi pi-info-circle"></i>
<span>Basic Information</span>
</div>
}
@for (field of metadataFieldsBottom; track field) {
<div class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<!-- Mobile layout -->
<div class="mobile-field-row mobile-only">
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success" size="small"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn" size="small"></p-button>
}
<input pInputText pSize="small" id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
<div class="section-content">
@for (field of metadataFieldsTop; track field) {
<div class="field-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
@if (field.controlName === 'publishedDate') {
<input pInputText formControlName="{{field.controlName}}" class="field-input" placeholder="YYYY-MM-DD"/>
} @else {
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
}
</div>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched">
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-input" readonly/>
</div>
</div>
</div>
<div class="mobile-field-row mobile-only">
<input pInputText pSize="small" [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input fetched-input" readonly/>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-up')"
[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"
size="small"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"/>
</div>
<!-- Desktop layout -->
<div class="desktop-only desktop-field-row">
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
<input pInputText pSize="small" 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 pSize="small" [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
</div>
</div>
}
</div>
}
</section>
<div class="metadata-header desktop-only">
<p class="metadata-header-text">Current Metadata</p>
<p-button
severity="info"
icon='pi pi-angle-left'
class="button-left"
[outlined]="true"
pTooltip="Move all missing fields" tooltipPosition="bottom"
(onClick)="copyMissing()"></p-button>
<p-button
severity="info"
icon='pi pi-angle-double-left'
class="button-double-left"
[outlined]="true"
pTooltip="Move all fields" tooltipPosition="bottom"
(onClick)="copyAll()"></p-button>
<p class="metadata-header-text">Fetched Metadata</p>
</div>
<!-- Tags & Categories Section -->
<section class="form-section">
<div class="section-header">
<i class="pi pi-tags"></i>
<span>Tags & Categories</span>
</div>
<div class="section-content">
@for (field of metadataChips; track field) {
<div class="field-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
<p-autoComplete
class="chips-input"
formControlName="{{field.controlName}}"
[multiple]="true"
[dropdown]="false"
[forceSelection]="false"
[showClear]="true"
[suggestions]="getFiltered(field.controlName)"
(completeMethod)="filterItems($event, field.controlName)"
(onKeyUp)="onAutoCompleteKeyUp(field.controlName, $event)"
(onSelect)="onAutoCompleteSelect(field.controlName, $event)"
/>
</div>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched">
<p-autoComplete
[ngModel]="fetchedMetadata[field.fetchedKey] ?? []"
[ngModelOptions]="{ standalone: true }"
[disabled]="true"
[multiple]="true"
[typeahead]="false"
[dropdown]="false"
[forceSelection]="false"
class="chips-input readonly"
/>
</div>
</div>
</div>
}
</div>
</section>
<!-- Description Section -->
<section class="form-section">
<div class="section-header">
<i class="pi pi-align-left"></i>
<span>Description</span>
</div>
<div class="section-content">
@for (field of metadataDescription; track field) {
<div class="field-row textarea-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
<textarea pTextarea formControlName="{{field.controlName}}" class="field-textarea" rows="4"></textarea>
</div>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched">
<textarea pTextarea [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-textarea" rows="4" readonly></textarea>
</div>
</div>
</div>
}
</div>
</section>
<!-- Additional Details Section -->
@if (metadataFieldsBottom.length > 0) {
<section class="form-section">
<div class="section-header">
<i class="pi pi-list"></i>
<span>Additional Details</span>
</div>
<div class="section-content">
@for (field of metadataFieldsBottom; track field) {
<div class="field-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
</div>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched">
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-input" readonly/>
</div>
</div>
</div>
}
</div>
</section>
}
</div>
@if (!reviewMode) {
<div class="form-footer">
<p-divider></p-divider>
<!-- Mobile footer -->
<div class="footer-buttons mobile-only">
<p-button icon="pi pi-arrow-left" label="Metadata List" outlined severity="info" (onClick)="goBackClick()"></p-button>
<div class="footer-buttons-right">
<p-button icon="pi pi-lock-open" [outlined]="true" severity="success" pTooltip="Unlock All" (onClick)="unlockAll()"></p-button>
<p-button icon="pi pi-lock" [outlined]="true" severity="warn" pTooltip="Lock All" (onClick)="lockAll()"></p-button>
<p-button
[icon]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="isSaving"
[disabled]="isSaving"
label="Save"
type="submit"></p-button>
</div>
<footer class="dialog-footer">
<div class="footer-left">
<p-button
label="Back to List"
icon="pi pi-arrow-left"
severity="info"
[outlined]="true"
(onClick)="goBackClick()"
/>
</div>
<!-- Desktop footer -->
<div class="footer-buttons desktop-only">
<p-button label="To Metadata List" icon="pi pi-arrow-left" severity="info" (onClick)="goBackClick()"></p-button>
<div class="footer-buttons-right">
<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]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="isSaving"
[disabled]="isSaving"
type="submit"></p-button>
</div>
<div class="footer-right">
<p-button
icon="pi pi-lock-open"
severity="success"
[outlined]="true"
pTooltip="Unlock all fields"
tooltipPosition="top"
(onClick)="unlockAll()"
/>
<p-button
icon="pi pi-lock"
severity="warn"
[outlined]="true"
pTooltip="Lock all fields"
tooltipPosition="top"
(onClick)="lockAll()"
/>
<div class="footer-divider"></div>
<p-button
label="Save Changes"
[icon]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="isSaving"
[disabled]="isSaving"
severity="primary"
type="submit"
/>
</div>
</div>
</footer>
}
</form>
}
@@ -1,21 +1,12 @@
.form-container {
.metadata-picker {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
background: var(--card-background);
animation: fadeIn 0.3s ease-in;
}
.form-content {
flex-grow: 1;
overflow: auto;
padding: 0.5rem;
@media (min-width: 768px) {
padding: 1rem;
}
}
// Visibility utilities
.mobile-only {
display: flex;
@@ -33,254 +24,462 @@
}
}
// Desktop header
.metadata-header {
justify-content: center;
align-items: center;
padding-bottom: 0.75rem;
padding-left: 9.25rem;
margin-top: 1rem;
}
.metadata-header-text {
margin-left: 0.75rem;
font-size: 1.125rem;
}
// Mobile header
.metadata-header-mobile {
justify-content: center;
align-items: center;
gap: 0.75rem;
padding: 0.5rem 0;
margin-bottom: 0.5rem;
border-bottom: 1px solid var(--p-surface-700);
}
.button-left {
padding-left: 3rem;
padding-right: 0.5rem;
}
.button-double-left {
padding-left: 0.5rem;
padding-right: 2rem;
}
.form-row {
// Body
.dialog-body {
flex: 1;
overflow-y: auto;
padding: 1.25rem;
display: flex;
flex-direction: column;
align-items: flex-start;
margin-bottom: 0.75rem;
width: 100%;
padding: 0.5rem;
border-radius: 0.375rem;
border: 1px solid var(--p-surface-700);
gap: 1.5rem;
@media (min-width: 768px) {
flex-direction: row;
align-items: center;
margin-bottom: 0.5rem;
padding: 0;
border: none;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 3px;
&:hover {
background: var(--primary-color);
}
}
}
.thumbnail-row {
@media (max-width: 767px) {
// Column Headers - mirrors field-row structure for alignment (desktop only)
.column-headers {
display: none;
align-items: center;
padding: 0.875rem 1rem;
margin-bottom: 0.5rem;
background: var(--overlay-background);
border: 1px solid var(--border-color);
border-radius: 8px;
@media (min-width: 768px) {
display: flex;
}
// Spacer to match field-label width
&::before {
content: '';
min-width: 120px;
flex-shrink: 0;
}
.column-label {
display: flex;
align-items: center;
border: none;
padding: 0.5rem 0;
}
}
gap: 0.625rem;
font-size: 1rem;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.05em;
flex: 1;
.thumbnail-container {
@media (max-width: 767px) {
flex-direction: row;
i {
font-size: 1.125rem;
}
&.current {
color: var(--primary-color);
justify-content: flex-end;
padding-right: 1rem;
}
&.fetched {
color: var(--p-blue-400);
justify-content: flex-start;
padding-left: 1rem;
}
}
.column-actions {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
flex-shrink: 0;
margin-left: 0.75rem;
margin-right: 0.75rem;
}
}
.mobile-thumbnail-row {
// Sections
.form-section {
.section-header {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.75rem;
font-size: 0.85rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.03em;
color: var(--text-secondary-color);
i {
font-size: 0.9rem;
color: var(--primary-color);
}
}
.section-content {
background: var(--overlay-background);
border: 1px solid var(--border-color);
border-radius: 8px;
overflow: hidden;
}
}
// Cover Image
.cover-wrapper {
position: relative;
}
.cover-image {
width: 100px;
height: 150px;
border-radius: 6px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
@media (min-width: 768px) {
width: 120px;
height: 180px;
}
::ng-deep img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
.lock-badge {
position: absolute;
top: -6px;
right: -6px;
display: flex;
align-items: center;
justify-content: center;
gap: 0.375rem;
width: 100%;
}
width: 24px;
height: 24px;
background: var(--p-green-500);
border: 2px solid var(--card-background);
border-radius: 50%;
cursor: pointer;
transition: all 0.2s ease;
.label {
width: 100%;
text-align: left;
margin-bottom: 0.375rem;
font-weight: 600;
font-size: 0.8rem;
color: var(--p-text-color);
i {
font-size: 0.625rem;
color: white;
}
@media (min-width: 768px) {
width: 8rem;
margin-bottom: 0;
font-weight: normal;
font-size: 1rem;
&.locked {
background: var(--p-orange-500);
}
&:hover {
transform: scale(1.1);
}
}
.input-container {
display: flex;
flex-direction: column;
align-items: stretch;
width: 100%;
gap: 0.25rem;
@media (min-width: 768px) {
flex-direction: row;
align-items: center;
gap: 0;
}
}
// Mobile field rows - tight two-row layout
.mobile-field-row {
align-items: center;
gap: 0.5rem;
width: 100%;
.input {
flex: 1;
margin: 0;
}
.autocomplete-container {
flex: 1;
padding: 0;
}
}
.mobile-field-label {
font-size: 0.65rem;
.cover-label {
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.03em;
color: var(--p-primary-color);
min-width: 3rem;
color: var(--text-secondary-color);
}
&.muted {
color: var(--p-text-muted-color);
// Field Rows
.field-row {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 0.875rem 1rem;
border-bottom: 1px solid var(--border-color);
&:last-child {
border-bottom: none;
}
@media (min-width: 768px) {
flex-direction: row;
align-items: center;
padding: 0.75rem 1rem;
}
}
// Desktop field row
.desktop-field-row {
align-items: center;
width: 100%;
// Cover field row specific styles
.cover-field-row {
padding: 1.25rem 1rem;
.field-label {
text-align: center;
margin-bottom: 0.5rem;
@media (min-width: 768px) {
text-align: left;
margin-bottom: 0;
}
}
.field-content {
align-items: center;
gap: 1rem;
@media (min-width: 768px) {
gap: 1.5rem;
}
}
// On mobile, center covers and show labels
.field-side {
flex-direction: column;
align-items: center;
gap: 0.5rem;
@media (min-width: 768px) {
flex-direction: row;
}
}
// Position covers towards the arrow on desktop only
@media (min-width: 768px) {
padding: 1.5rem 1rem;
.field-side.current {
justify-content: flex-end;
}
.field-side.fetched {
justify-content: flex-start;
}
}
}
.thumbnail-row .desktop-field-row {
justify-content: center;
.field-label {
font-size: 0.85rem;
font-weight: 500;
color: var(--text-color);
min-width: 100px;
@media (min-width: 768px) {
min-width: 120px;
flex-shrink: 0;
}
}
.input {
width: 100%;
padding: 0.5rem;
border-radius: 0.25rem;
margin: 0;
.field-content {
display: flex;
flex-direction: column;
gap: 0.5rem;
flex: 1;
@media (min-width: 768px) {
width: 50%;
margin: 0 1rem;
flex-direction: row;
align-items: center;
gap: 0.75rem;
}
}
.fetched-input {
opacity: 0.6;
}
.field-side {
display: flex;
align-items: center;
gap: 0.5rem;
flex: 1;
min-width: 0;
.autocomplete-container {
width: 100%;
padding: 0;
@media (min-width: 768px) {
padding-left: 1rem;
padding-right: 1rem;
&.fetched {
.field-input,
.field-textarea,
.chips-input {
opacity: 0.7;
}
}
}
.autocomplete-full-width {
.lock-btn {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
background: var(--p-green-500);
border: none;
border-radius: 6px;
cursor: pointer;
flex-shrink: 0;
transition: all 0.2s ease;
i {
font-size: 0.75rem;
color: white;
}
&.locked {
background: var(--p-orange-500);
}
&:hover {
transform: scale(1.05);
}
}
.field-input {
flex: 1;
min-width: 0;
width: 100%;
}
.thumbnail {
width: 5rem;
height: 7rem;
border-radius: 0.375rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
.field-textarea {
flex: 1;
min-width: 0;
width: 100%;
resize: vertical;
}
@media (min-width: 768px) {
width: 15.625rem;
height: 21.875rem;
margin-left: 2.5rem;
margin-right: 2.5rem;
.chips-input {
flex: 1;
min-width: 0;
width: 100%;
&.readonly {
pointer-events: none;
}
}
.arrow-button {
.textarea-row {
.field-content {
@media (min-width: 768px) {
align-items: flex-start;
}
}
.field-side {
@media (min-width: 768px) {
align-items: flex-start;
}
}
.lock-btn {
@media (min-width: 768px) {
margin-top: 0.25rem;
}
}
.transfer-btn {
@media (min-width: 768px) {
margin-top: 0.25rem;
}
}
}
// Transfer Button
.transfer-btn {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
background: var(--card-background);
border: 1px solid var(--border-color);
border-radius: 6px;
cursor: pointer;
flex-shrink: 0;
transition: all 0.2s ease;
i {
font-size: 0.875rem;
color: var(--text-secondary-color);
}
&:hover {
border-color: var(--primary-color);
background: var(--primary-color);
i {
color: var(--primary-contrast-color);
}
}
&.saved {
border-color: var(--p-green-500);
background: var(--p-green-500);
i {
color: white;
}
}
&.copied {
border-color: var(--p-yellow-500);
background: rgba(234, 179, 8, 0.15);
i {
color: var(--p-yellow-500);
}
}
&.reset {
border-color: var(--p-red-500);
background: rgba(239, 68, 68, 0.15);
i {
color: var(--p-red-500);
}
}
}
// Footer
.dialog-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 1rem 1.25rem;
background: var(--overlay-background);
border-top: 1px solid var(--border-color);
flex-shrink: 0;
}
.yellow-outlined-button {
--p-button-outlined-primary-border-color: yellow;
--p-button-outlined-primary-color: yellow;
}
.green-outlined-button {
--p-button-outlined-primary-border-color: limegreen;
--p-button-outlined-primary-color: limegreen;
}
.red-outlined-button {
--p-button-outlined-primary-border-color: #E32636;
--p-button-outlined-primary-color: #E32636;
}
.form-footer {
margin-top: auto;
padding: 0 0.5rem;
@media (min-width: 768px) {
padding: 0;
}
}
.footer-buttons {
padding-top: 1rem;
&.mobile-only {
flex-direction: row;
justify-content: space-between;
align-items: center;
}
&.desktop-only {
justify-content: space-between;
padding: 1rem 0.5rem 0;
}
}
.footer-buttons-right {
.footer-left {
display: flex;
gap: 0.5rem;
align-items: center;
}
.desktop-only & {
gap: 1rem;
.footer-right {
display: flex;
align-items: center;
gap: 0.5rem;
}
.footer-divider {
width: 1px;
height: 24px;
background: var(--border-color);
margin: 0 0.25rem;
}
// AutoComplete overrides
::ng-deep .p-autocomplete {
width: 100% !important;
.p-autocomplete-multiple-container {
width: 100%;
}
}
::ng-deep .p-inputchips {
width: 100% !important;
}
// Animation
@keyframes fadeIn {
from {
opacity: 0;
@@ -289,3 +488,28 @@
opacity: 1;
}
}
// Mobile optimizations
@media (max-width: 767px) {
.dialog-body {
padding: 1rem;
gap: 1.25rem;
}
.dialog-footer {
flex-direction: column;
padding: 0.875rem 1rem;
gap: 0.75rem;
.footer-left,
.footer-right {
width: 100%;
justify-content: center;
}
}
.field-label {
font-size: 0.8rem;
font-weight: 600;
}
}
@@ -4,8 +4,7 @@ import {MessageService} from 'primeng/api';
import {Button} from 'primeng/button';
import {FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {InputText} from 'primeng/inputtext';
import {AsyncPipe, NgClass} from '@angular/common';
import {Divider} from 'primeng/divider';
import {AsyncPipe} from '@angular/common';
import {Observable} from 'rxjs';
import {Tooltip} from 'primeng/tooltip';
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
@@ -29,9 +28,7 @@ import {ALL_METADATA_FIELDS, getArrayFields, getBottomFields, getTextareaFields,
Button,
FormsModule,
InputText,
Divider,
ReactiveFormsModule,
NgClass,
Tooltip,
AsyncPipe,
Textarea,
@@ -0,0 +1,310 @@
<p-tabs lazy class="custom-p-tabs" [value]="defaultTabValue" scrollable>
<p-tablist>
@if (bookInSeries.length > 1) {
<p-tab value="series">
<i class="pi pi-ethereum"></i> More in Series
</p-tab>
}
<p-tab value="similar">
<i class="pi pi-bookmark"></i> Similar Books
</p-tab>
<p-tab value="files">
<i class="pi pi-folder-open"></i> Files
</p-tab>
<p-tab value="notes">
<i class="pi pi-pen-to-square"></i> Notes
</p-tab>
<p-tab value="sessions">
<i class="pi pi-clock"></i> Reading Sessions
</p-tab>
<p-tab value="reviews">
<i class="pi pi-comments"></i> Reviews
</p-tab>
</p-tablist>
<p-tabpanels>
<p-tabpanel value="series">
<ng-template #content>
<div class="tab-content">
@if (bookInSeries.length > 1) {
<div class="dashboard-scroller-infinite" infiniteScroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="50" [horizontal]="true">
@for (bookInSeriesItem of bookInSeries; track bookInSeriesItem) {
@if (bookInSeriesItem.id !== book.id) {
<div class="dashboard-scroller-card">
<app-book-card-lite-component [book]="bookInSeriesItem" [showSeriesNumber]="true" [isActive]="bookInSeriesItem.id === book.id"></app-book-card-lite-component>
</div>
}
}
</div>
}
</div>
</ng-template>
</p-tabpanel>
<p-tabpanel value="similar">
<ng-template #content>
<div class="tab-content">
@if (recommendedBooks.length > 0) {
<div class="dashboard-scroller-infinite" infiniteScroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="50" [horizontal]="true">
@for (recBook of recommendedBooks; track recBook.book.id) {
<div class="dashboard-scroller-card">
<app-book-card-lite-component [book]="recBook.book"></app-book-card-lite-component>
</div>
}
</div>
}
</div>
</ng-template>
</p-tabpanel>
<p-tabpanel value="notes">
<ng-template #content>
<app-book-notes-component [bookId]="book.id"></app-book-notes-component>
</ng-template>
</p-tabpanel>
<p-tabpanel value="sessions">
<ng-template #content>
<app-book-reading-sessions [bookId]="book.id"></app-book-reading-sessions>
</ng-template>
</p-tabpanel>
<p-tabpanel value="reviews">
<ng-template #content>
<app-book-reviews [bookId]="book.id"></app-book-reviews>
</ng-template>
</p-tabpanel>
<p-tabpanel value="files">
<ng-template #content>
<div class="files-tab-content">
@if (isPhysicalBook()) {
<div class="empty-state">
<i class="pi pi-book empty-state-icon"></i>
<h4 class="empty-state-title">Physical Book</h4>
<p class="empty-state-message">This is a physical book. No digital files are associated with this book.</p>
<p class="empty-state-hint">You can upload a digital version using the "Upload File" option in the menu.</p>
</div>
} @else {
@if (hasMultipleFiles(book)) {
<div class="files-section download-all-section">
<p-button
label="Download All ({{ getTotalFileCount(book) }} files)"
icon="pi pi-download"
severity="info"
outlined
(onClick)="downloadAll(book)"
pTooltip="Download all files as a ZIP archive"
tooltipPosition="top">
</p-button>
</div>
}
@if (book.primaryFile) {
<div class="files-section">
<h4 class="files-section-title">Primary File</h4>
<div class="files-list">
<div class="file-item primary-file">
<div class="file-info">
<span class="file-type-badge" [style.background-color]="getFileTypeBgColor(book.primaryFile.extension)">
{{ book.primaryFile.extension | uppercase }}
</span>
<span class="file-name" [pTooltip]="book.primaryFile.filePath" tooltipPosition="top">{{ book.primaryFile.fileName }}</span>
<span class="file-size">{{ getFileSizeInMB(book.primaryFile) }}</span>
</div>
<div class="file-actions">
@if (book.primaryFile.bookType === 'PDF') {
<p-button
icon="pi pi-book"
size="small"
text
severity="primary"
pTooltip="Read"
tooltipPosition="top"
(onClick)="read(book.id)">
</p-button>
<p-button
icon="pi pi-play"
size="small"
text
severity="info"
pTooltip="Streaming Reader"
tooltipPosition="top"
(onClick)="read(book.id, 'pdf-streaming')">
</p-button>
} @else if (book.primaryFile.bookType === 'EPUB') {
<p-button
icon="pi pi-book"
size="small"
text
severity="primary"
pTooltip="Read"
tooltipPosition="top"
(onClick)="read(book.id)">
</p-button>
<p-button
icon="pi pi-play"
size="small"
text
severity="info"
pTooltip="Streaming Reader"
tooltipPosition="top"
(onClick)="read(book.id, 'epub-streaming')">
</p-button>
} @else if (book.primaryFile.bookType && ['FB2', 'MOBI', 'AZW3', 'CBX'].includes(book.primaryFile.bookType)) {
<p-button
icon="pi pi-book"
size="small"
text
severity="primary"
pTooltip="Read"
tooltipPosition="top"
(onClick)="read(book.id)">
</p-button>
} @else if (book.primaryFile.bookType === 'AUDIOBOOK') {
<p-button
icon="pi pi-play"
size="small"
text
severity="primary"
pTooltip="Play"
tooltipPosition="top"
(onClick)="read(book.id)">
</p-button>
}
<p-button
icon="pi pi-download"
size="small"
text
severity="success"
pTooltip="Download"
tooltipPosition="top"
(onClick)="download(book)">
</p-button>
<p-button
icon="pi pi-trash"
size="small"
text
severity="danger"
pTooltip="Delete"
tooltipPosition="top"
(onClick)="deleteFile(book, book.primaryFile!.id, book.primaryFile!.fileName || 'file', true)">
</p-button>
</div>
</div>
</div>
</div>
}
@if (book.alternativeFormats && book.alternativeFormats.length > 0) {
<div class="files-section">
<h4 class="files-section-title">Alternative Formats</h4>
<div class="files-list">
@for (format of book.alternativeFormats; track format.id) {
<div class="file-item">
<div class="file-info">
<span class="file-type-badge" [style.background-color]="getFileTypeBgColor(format.extension)">
{{ format.extension | uppercase }}
</span>
<span class="file-name" [pTooltip]="format.filePath" tooltipPosition="top">{{ format.fileName }}</span>
<span class="file-size">{{ getFileSizeInMB(format) }}</span>
</div>
<div class="file-actions">
@if (format.bookType === 'PDF' || format.bookType === 'EPUB') {
<p-button
icon="pi pi-book"
size="small"
text
severity="primary"
pTooltip="Read"
tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)">
</p-button>
<p-button
icon="pi pi-play"
size="small"
text
severity="info"
pTooltip="Streaming Reader"
tooltipPosition="top"
(onClick)="read(book.id, format.bookType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', format.bookType)">
</p-button>
} @else if (format.bookType && ['FB2', 'MOBI', 'AZW3', 'CBX'].includes(format.bookType)) {
<p-button
icon="pi pi-book"
size="small"
text
severity="primary"
pTooltip="Read"
tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)">
</p-button>
} @else if (format.bookType === 'AUDIOBOOK') {
<p-button
icon="pi pi-play"
size="small"
text
severity="primary"
pTooltip="Play"
tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)">
</p-button>
}
<p-button
icon="pi pi-download"
size="small"
text
severity="success"
pTooltip="Download"
tooltipPosition="top"
(onClick)="downloadAdditionalFile(book, format.id)">
</p-button>
<p-button
icon="pi pi-trash"
size="small"
text
severity="danger"
pTooltip="Delete"
tooltipPosition="top"
(onClick)="deleteFile(book, format.id, format.fileName || 'file', false)">
</p-button>
</div>
</div>
}
</div>
</div>
}
@if (book.supplementaryFiles && book.supplementaryFiles.length > 0) {
<div class="files-section">
<h4 class="files-section-title">Supplementary Files</h4>
<div class="files-list">
@for (file of book.supplementaryFiles; track file.id) {
<div class="file-item">
<div class="file-info">
<i [class]="getFileIcon(getFileExtension(file.filePath))" class="file-icon"></i>
<span class="file-name" [pTooltip]="file.filePath" tooltipPosition="top">{{ file.fileName }}</span>
<span class="file-size">{{ getFileSizeInMB(file) }}</span>
</div>
<div class="file-actions">
<p-button
icon="pi pi-download"
size="small"
text
severity="success"
pTooltip="Download"
tooltipPosition="top"
(onClick)="downloadAdditionalFile(book, file.id)">
</p-button>
<p-button
icon="pi pi-trash"
size="small"
text
severity="danger"
pTooltip="Delete"
tooltipPosition="top"
(onClick)="deleteSupplementary(book.id, file.id, file.fileName || 'file')">
</p-button>
</div>
</div>
}
</div>
</div>
}
}
</div>
</ng-template>
</p-tabpanel>
</p-tabpanels>
</p-tabs>
@@ -0,0 +1,216 @@
.custom-p-tabs ::ng-deep .p-tabpanels {
padding: 0.5rem 0 0 0 !important;
}
.tab-content {
padding: 0.5rem 0;
}
.dashboard-scroller-infinite {
display: flex;
overflow-x: auto;
overflow-y: hidden;
scroll-snap-type: x mandatory;
padding: 0.5rem;
gap: 1rem;
width: 100%;
scrollbar-width: thin;
scrollbar-color: var(--border-color) transparent;
}
.dashboard-scroller-infinite::-webkit-scrollbar {
height: 8px;
}
.dashboard-scroller-infinite::-webkit-scrollbar-track {
background: transparent;
}
.dashboard-scroller-infinite::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 4px;
}
.dashboard-scroller-infinite::-webkit-scrollbar-thumb:hover {
background: var(--text-secondary-color);
}
.dashboard-scroller-card {
width: 115px;
flex-basis: 115px;
flex-shrink: 0;
flex-grow: 0;
scroll-snap-align: start;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
border-radius: 0.5rem;
}
.dashboard-scroller-card:hover {
transform: translateY(-6px);
}
.dashboard-scroller-card:hover::after {
opacity: 1;
}
.dashboard-scroller-card::after {
content: '';
position: absolute;
bottom: -4px;
left: 10%;
right: 10%;
height: 4px;
background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
border-radius: 50%;
opacity: 0;
transition: opacity 0.3s ease;
filter: blur(4px);
}
// Files tab styles
.files-tab-content {
display: flex;
flex-direction: column;
gap: 1.5rem;
padding: 0.5rem 0;
}
.files-section {
display: flex;
flex-direction: column;
gap: 0.75rem;
&.download-all-section {
align-items: flex-end;
margin-bottom: -1.5rem;
margin-top: 1rem;
}
}
.files-section-title {
font-size: 0.875rem;
font-weight: 600;
color: var(--text-color);
margin: 0;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--border-color);
}
.files-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.file-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.75rem;
background: var(--card-background);
border: 1px solid var(--border-color);
border-radius: 0.5rem;
transition: background 0.2s ease, border-color 0.2s ease;
&:hover {
background: var(--highlight-background);
border-color: var(--primary-color);
}
&.primary-file {
border-left: 3px solid var(--primary-color);
}
}
.file-info {
display: flex;
align-items: center;
gap: 0.75rem;
min-width: 0;
flex: 1;
}
.file-type-badge {
padding: 0.25rem 0.5rem;
border-radius: 0.25rem;
font-size: 0.8rem;
font-weight: 600;
color: #fff;
flex-shrink: 0;
}
.file-icon {
font-size: 1.25rem;
color: var(--text-color-secondary);
flex-shrink: 0;
}
.file-name {
font-size: 0.9rem;
color: var(--text-color);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
min-width: 0;
}
.file-size {
font-size: 0.8rem;
color: var(--text-color-secondary);
flex-shrink: 0;
}
.file-actions {
display: flex;
align-items: center;
gap: 0.25rem;
flex-shrink: 0;
::ng-deep .p-button-sm {
width: 2rem;
height: 2rem;
.p-button-icon {
font-size: 1rem;
}
}
}
// Empty state for physical books
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 3rem 1rem;
text-align: center;
color: var(--text-color-secondary);
}
.empty-state-icon {
font-size: 3rem;
color: var(--book-type-physical-color);
margin-bottom: 1rem;
}
.empty-state-title {
font-size: 1.25rem;
font-weight: 600;
color: var(--text-color);
margin: 0 0 0.5rem 0;
}
.empty-state-message {
font-size: 0.9rem;
margin: 0 0 0.5rem 0;
max-width: 400px;
}
.empty-state-hint {
font-size: 0.8rem;
font-style: italic;
margin: 0;
opacity: 0.8;
}
@@ -0,0 +1,164 @@
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {UpperCasePipe} from '@angular/common';
import {Book, BookRecommendation, BookType, FileInfo} from '../../../../../book/model/book.model';
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
import {InfiniteScrollDirective} from 'ngx-infinite-scroll';
import {BookCardLiteComponent} from '../../../../../book/components/book-card-lite/book-card-lite-component';
import {BookReviewsComponent} from '../../../../../book/components/book-reviews/book-reviews.component';
import {BookNotesComponent} from '../../../../../book/components/book-notes/book-notes-component';
import {BookReadingSessionsComponent} from '../../book-reading-sessions/book-reading-sessions.component';
import {Button} from 'primeng/button';
import {Tooltip} from 'primeng/tooltip';
export interface ReadEvent {
bookId: number;
reader?: 'pdf-streaming' | 'epub-streaming';
bookType?: BookType;
}
export interface DownloadEvent {
book: Book;
}
export interface DownloadAdditionalFileEvent {
book: Book;
fileId: number;
}
export interface DownloadAllFilesEvent {
book: Book;
}
export interface DeleteBookFileEvent {
book: Book;
fileId: number;
fileName: string;
isPrimary: boolean;
isOnlyFormat: boolean;
}
export interface DeleteSupplementaryFileEvent {
bookId: number;
fileId: number;
fileName: string;
}
@Component({
selector: 'app-metadata-tabs',
standalone: true,
imports: [
Tab,
TabList,
TabPanel,
TabPanels,
Tabs,
InfiniteScrollDirective,
BookCardLiteComponent,
BookReviewsComponent,
BookNotesComponent,
BookReadingSessionsComponent,
Button,
Tooltip,
UpperCasePipe
],
templateUrl: './metadata-tabs.component.html',
styleUrl: './metadata-tabs.component.scss'
})
export class MetadataTabsComponent {
@Input() book!: Book;
@Input() bookInSeries: Book[] = [];
@Input() recommendedBooks: BookRecommendation[] = [];
@Output() readBook = new EventEmitter<ReadEvent>();
@Output() downloadBook = new EventEmitter<DownloadEvent>();
@Output() downloadFile = new EventEmitter<DownloadAdditionalFileEvent>();
@Output() downloadAllFiles = new EventEmitter<DownloadAllFilesEvent>();
@Output() deleteBookFile = new EventEmitter<DeleteBookFileEvent>();
@Output() deleteSupplementaryFile = new EventEmitter<DeleteSupplementaryFileEvent>();
get defaultTabValue(): string {
return this.bookInSeries && this.bookInSeries.length > 1 ? 'series' : 'similar';
}
read(bookId: number, reader?: 'pdf-streaming' | 'epub-streaming', bookType?: BookType): void {
this.readBook.emit({ bookId, reader, bookType });
}
download(book: Book): void {
this.downloadBook.emit({ book });
}
downloadAdditionalFile(book: Book, fileId: number): void {
this.downloadFile.emit({ book, fileId });
}
downloadAll(book: Book): void {
this.downloadAllFiles.emit({ book });
}
deleteFile(book: Book, fileId: number, fileName: string, isPrimary: boolean): void {
const isOnlyFormat = !book.alternativeFormats?.length;
this.deleteBookFile.emit({ book, fileId, fileName, isPrimary, isOnlyFormat });
}
deleteSupplementary(bookId: number, fileId: number, fileName: string): void {
this.deleteSupplementaryFile.emit({ bookId, fileId, fileName });
}
hasMultipleFiles(book: Book): boolean {
const primaryCount = book.primaryFile ? 1 : 0;
const altCount = book.alternativeFormats?.length ?? 0;
return (primaryCount + altCount) > 1;
}
getTotalFileCount(book: Book): number {
const primaryCount = book.primaryFile ? 1 : 0;
const altCount = book.alternativeFormats?.length ?? 0;
return primaryCount + altCount;
}
getFileSizeInMB(fileInfo: FileInfo | null | undefined): string {
const sizeKb = fileInfo?.fileSizeKb;
return sizeKb != null ? `${(sizeKb / 1024).toFixed(2)} MB` : '-';
}
getFileExtension(filePath?: string): string | null {
if (!filePath) return null;
const parts = filePath.split('.');
if (parts.length < 2) return null;
return parts.pop()?.toUpperCase() || null;
}
getFileIcon(fileType: string | null): string {
if (!fileType) return 'pi pi-file';
switch (fileType.toLowerCase()) {
case 'pdf':
return 'pi pi-file-pdf';
case 'epub':
case 'mobi':
case 'azw3':
return 'pi pi-book';
case 'cbz':
case 'cbr':
case 'cbx':
return 'pi pi-image';
case 'audiobook':
case 'm4b':
case 'm4a':
case 'mp3':
return 'pi pi-headphones';
default:
return 'pi pi-file';
}
}
getFileTypeBgColor(fileType: string | null | undefined): string {
if (!fileType) return 'var(--p-gray-500)';
const type = fileType.toLowerCase();
return `var(--book-type-${type}-color, var(--p-gray-500))`;
}
isPhysicalBook(): boolean {
return !this.book?.primaryFile && (!this.book?.alternativeFormats || this.book.alternativeFormats.length === 0);
}
}
@@ -346,18 +346,26 @@
</div>
<div class="metadata-item">
<span class="metadata-key">File Type:</span>
@if (getFileExtension(book?.filePath)) {
<span (click)="goToFileType(book?.filePath)" style="cursor: pointer;">
<app-tag size="3xs" variant="pill" [customBgColor]="getFileTypeBgColor(getFileExtension(book?.filePath))" customTextColor="#fff">
{{ (getFileExtension(book?.filePath) | uppercase) || '-' }}
</app-tag>
</span>
} @else {
<app-tag size="3xs" variant="pill" [customBgColor]="getFileTypeBgColor(getFileExtension(book?.filePath))" customTextColor="#fff">
-
</app-tag>
}
<span class="metadata-key">Formats:</span>
<span class="metadata-value-group format-tags">
@if (getDisplayFormat(book?.primaryFile); as displayFormat) {
<span (click)="goToFileType(book?.primaryFile?.filePath)" style="cursor: pointer;" [pTooltip]="'Primary: ' + (book?.primaryFile?.fileName ?? '')" tooltipPosition="top">
<app-tag size="3xs" variant="pill" [customBgColor]="getFileTypeBgColor(displayFormat)" customTextColor="#fff">
{{ displayFormat }}
</app-tag>
</span>
}
@for (formatExt of getUniqueAlternativeFormats(book); track formatExt) {
<span (click)="goToFileType('.' + formatExt)" style="cursor: pointer;" [pTooltip]="formatExt" tooltipPosition="top">
<app-tag size="3xs" variant="pill" [customBgColor]="getFileTypeBgColor(formatExt)" customTextColor="#fff">
{{ formatExt }}
</app-tag>
</span>
}
@if (!book?.primaryFile?.filePath && !book?.alternativeFormats?.length) {
<app-tag size="3xs" variant="pill" [customBgColor]="'var(--book-type-physical-color)'" customTextColor="#fff">PHYSICAL</app-tag>
}
</span>
</div>
<div class="metadata-item">
@@ -502,25 +510,29 @@
}
</div>
<div class="metadata-item">
<span class="metadata-key">File Size:</span>
@if (book?.fileSizeKb) {
<span class="metadata-value metadata-link" (click)="goToFileSizeRange(book?.fileSizeKb!)">
{{ getFileSizeInMB(book) }}
</span>
} @else {
<span class="metadata-value">-</span>
}
</div>
</div>
<div class="file-path-section">
<span class="metadata-key">File Path:</span>
<i class="pi eye-icon" [ngClass]="showFilePath ? 'pi-eye-slash' : 'pi-eye'" (click)="showFilePath = !showFilePath"></i>
@if (showFilePath) {
<code class="file-path-code">{{ book?.filePath }}</code>
@if (hasDigitalFile(book)) {
<div class="metadata-item">
<span class="metadata-key">File Size:</span>
@if (book?.primaryFile?.fileSizeKb) {
<span class="metadata-value metadata-link" (click)="goToFileSizeRange(book?.primaryFile?.fileSizeKb!)">
{{ formatFileSize(book?.primaryFile) }}
</span>
} @else {
<span class="metadata-value">-</span>
}
</div>
}
</div>
@if (hasDigitalFile(book)) {
<div class="file-path-section">
<span class="metadata-key">File Path:</span>
<i class="pi eye-icon" [ngClass]="showFilePath ? 'pi-eye-slash' : 'pi-eye'" (click)="showFilePath = !showFilePath"></i>
@if (showFilePath) {
<code class="file-path-code">{{ book?.primaryFile?.filePath }}</code>
}
</div>
}
</div>
@if (userService.userState$ | async; as userState) {
@@ -554,34 +566,31 @@
</div>
<p-divider layout="vertical" class="action-divider"></p-divider>
}
@if (book!.bookType === 'PDF') {
@if (pdfReadMenuItems$ | async; as readItems) {
<p-splitbutton label="Read" outlined icon="pi pi-book" [model]="readItems" (onClick)="read(book.id)" severity="primary"/>
}
}
@if (book!.bookType === 'EPUB') {
@if (epubReadMenuItems$ | async; as readItems) {
<p-splitbutton label="Read" outlined icon="pi pi-book" [model]="readItems" (onClick)="read(book.id)" severity="primary"/>
}
}
@if (book!.bookType !== 'PDF' && book!.bookType !== 'EPUB') {
<p-button label="Read" outlined icon="pi pi-book" (onClick)="read(book?.metadata!.bookId, undefined)" severity="primary"/>
}
<p-divider layout="vertical"></p-divider>
<p-button label="Shelf" icon="pi pi-folder" severity="info" outlined (onClick)="assignShelf(book.id)" class="mobile-icon-only"></p-button>
@if (userState.user!.permissions.canDownload || userState.user!.permissions.admin) {
@if ((book!.alternativeFormats && book!.alternativeFormats.length > 0) || (book!.supplementaryFiles && book!.supplementaryFiles.length > 0)) {
@if (downloadMenuItems$ | async; as downloadItems) {
<p-splitbutton label="Download" icon="pi pi-download" [model]="downloadItems" (onClick)="download(book)" severity="success" outlined class="mobile-icon-only"/>
@if (hasDigitalFile(book)) {
@if (readMenuItems$ | async; as readItems) {
@if (readItems.length > 0) {
<p-splitbutton [label]="getReadButtonLabel(book)" [icon]="getReadButtonIcon(book)" [model]="readItems" (onClick)="read(book.id)" outlined severity="primary" class="read-button-responsive"/>
} @else {
<p-button [label]="getReadButtonLabel(book)" [icon]="getReadButtonIcon(book)" (onClick)="read(book.id)" outlined severity="primary" class="read-button-responsive"/>
}
} @else {
<p-button label="Download" icon="pi pi-download" severity="success" outlined (onClick)="download(book)" class="mobile-icon-only"></p-button>
<p-button [label]="getReadButtonLabel(book)" [icon]="getReadButtonIcon(book)" (onClick)="read(book.id)" outlined severity="primary" class="read-button-responsive"/>
}
<p-divider layout="vertical"></p-divider>
}
@if ((userState.user!.permissions.canDownload || userState.user!.permissions.admin) && hasAnyFiles(book)) {
@if ((book!.alternativeFormats && book!.alternativeFormats.length > 0) || (book!.supplementaryFiles && book!.supplementaryFiles.length > 0)) {
@if (downloadMenuItems$ | async; as downloadItems) {
<p-splitbutton [label]="(getDisplayFormat(book.primaryFile) ?? 'File') + ' · ' + formatFileSize(book.primaryFile)" icon="pi pi-download" [model]="downloadItems" (onClick)="download(book)" severity="success" outlined class="mobile-icon-only"/>
}
} @else {
<p-button [label]="(getDisplayFormat(book.primaryFile) ?? 'File') + ' · ' + formatFileSize(book.primaryFile)" icon="pi pi-download" severity="success" outlined (onClick)="download(book)" class="mobile-icon-only"></p-button>
}
}
@if (userState.user!.permissions.canEditMetadata || userState.user!.permissions.admin) {
@if (refreshMenuItems$ | async; as refreshItems) {
<p-splitbutton
[label]="isAutoFetching ? 'Fetching...' : 'Fetch'"
[label]="isAutoFetching ? 'Fetching...' : 'Fetch Metadata'"
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
[outlined]="true"
[model]="refreshItems"
@@ -596,7 +605,7 @@
}
@if (otherItems$ | async; as otherItems) {
@if (otherItems.length > 0) {
<p-button icon="pi pi-ellipsis-v" outlined severity="danger" (click)="entitymenu.toggle($event)"></p-button>
<p-button icon="pi pi-ellipsis-v" outlined severity="info" (click)="entitymenu.toggle($event)"></p-button>
<p-tieredMenu #entitymenu [model]="otherItems" [popup]="true" appendTo="body"></p-tieredMenu>
}
}
@@ -625,76 +634,17 @@
}
</div>
<p-tabs lazy class="custom-p-tabs" [value]="defaultTabValue" scrollable>
<p-tablist>
@if (bookInSeries.length > 1) {
<p-tab [value]="1">
<i class="pi pi-ethereum"></i> More in Series
</p-tab>
}
<p-tab [value]="2">
<i class="pi pi-bookmark"></i> Similar Books
</p-tab>
<p-tab [value]="3">
<i class="pi pi-pen-to-square"></i> Notes
</p-tab>
<p-tab [value]="4">
<i class="pi pi-clock"></i> Reading Sessions
</p-tab>
<p-tab [value]="5">
<i class="pi pi-comments"></i> Reviews
</p-tab>
</p-tablist>
<p-tabpanels>
<p-tabpanel [value]="1">
<ng-template #content>
<div class="tab-content">
@if (bookInSeries.length > 1) {
<div class="dashboard-scroller-infinite" infiniteScroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="50" [horizontal]="true">
@for (bookInSeriesItem of bookInSeries; track bookInSeriesItem) {
@if (bookInSeriesItem.id !== book.id) {
<div class="dashboard-scroller-card">
<app-book-card-lite-component [book]="bookInSeriesItem" [showSeriesNumber]="true" [isActive]="bookInSeriesItem.id === book.id"></app-book-card-lite-component>
</div>
}
}
</div>
}
</div>
</ng-template>
</p-tabpanel>
<p-tabpanel [value]="2">
<ng-template #content>
<div class="tab-content">
@if (recommendedBooks.length > 0) {
<div class="dashboard-scroller-infinite" infiniteScroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="50" [horizontal]="true">
@for (book of recommendedBooks; track book.book.id) {
<div class="dashboard-scroller-card">
<app-book-card-lite-component [book]="book.book"></app-book-card-lite-component>
</div>
}
</div>
}
</div>
</ng-template>
</p-tabpanel>
<p-tabpanel [value]="3">
<ng-template #content>
<app-book-notes-component [bookId]="book.id"></app-book-notes-component>
</ng-template>
</p-tabpanel>
<p-tabpanel [value]="4">
<ng-template #content>
<app-book-reading-sessions [bookId]="book.id"></app-book-reading-sessions>
</ng-template>
</p-tabpanel>
<p-tabpanel [value]="5">
<ng-template #content>
<app-book-reviews [bookId]="book.id"></app-book-reviews>
</ng-template>
</p-tabpanel>
</p-tabpanels>
</p-tabs>
<app-metadata-tabs
[book]="book"
[bookInSeries]="bookInSeries"
[recommendedBooks]="recommendedBooks"
(readBook)="onReadBook($event)"
(downloadBook)="onDownloadBook($event)"
(downloadFile)="onDownloadFile($event)"
(downloadAllFiles)="onDownloadAllFiles($event)"
(deleteBookFile)="onDeleteBookFile($event)"
(deleteSupplementaryFile)="onDeleteSupplementaryFile($event)">
</app-metadata-tabs>
</div>
} @else {
<div class="loading-state">
@@ -413,6 +413,10 @@
gap: 0.375rem;
}
.format-tags {
flex-wrap: wrap;
}
.metadata-link {
color: var(--primary-text-color);
cursor: pointer;
@@ -504,6 +508,17 @@
min-width: auto !important;
padding: 10px !important;
}
::ng-deep .read-button-responsive .p-button-label,
::ng-deep .read-button-responsive.p-splitbutton .p-button-label {
font-size: 0 !important;
}
::ng-deep .read-button-responsive .p-button-label::after,
::ng-deep .read-button-responsive.p-splitbutton .p-button-label::after {
content: "Read";
font-size: 0.875rem;
}
}
.navigation-buttons-desktop {
@@ -586,76 +601,6 @@
font-size: 0.875rem !important;
}
.custom-p-tabs ::ng-deep .p-tabpanels {
padding: 0.5rem 0 0 0 !important;
}
.tab-content {
padding: 0.5rem 0;
}
.dashboard-scroller-infinite {
display: flex;
overflow-x: auto;
overflow-y: hidden;
scroll-snap-type: x mandatory;
padding: 0.5rem;
gap: 1rem;
width: 100%;
scrollbar-width: thin;
scrollbar-color: var(--border-color) transparent;
}
.dashboard-scroller-infinite::-webkit-scrollbar {
height: 8px;
}
.dashboard-scroller-infinite::-webkit-scrollbar-track {
background: transparent;
}
.dashboard-scroller-infinite::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 4px;
}
.dashboard-scroller-infinite::-webkit-scrollbar-thumb:hover {
background: var(--text-secondary-color);
}
.dashboard-scroller-card {
width: 115px;
flex-basis: 115px;
flex-shrink: 0;
flex-grow: 0;
scroll-snap-align: start;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
border-radius: 0.5rem;
}
.dashboard-scroller-card:hover {
transform: translateY(-6px);
}
.dashboard-scroller-card:hover::after {
opacity: 1;
}
.dashboard-scroller-card::after {
content: '';
position: absolute;
bottom: -4px;
left: 10%;
right: 10%;
height: 4px;
background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
border-radius: 50%;
opacity: 0;
transition: opacity 0.3s ease;
filter: blur(4px);
}
.loading-state {
display: flex;
flex-direction: column;
@@ -1,11 +1,11 @@
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core';
import {Button} from 'primeng/button';
import {AsyncPipe, DecimalPipe, NgClass, UpperCasePipe} from '@angular/common';
import {Observable} from 'rxjs';
import {AsyncPipe, DecimalPipe, NgClass} from '@angular/common';
import {combineLatest, Observable} from 'rxjs';
import {BookService} from '../../../../book/service/book.service';
import {Rating, RatingRateEvent} from 'primeng/rating';
import {FormsModule} from '@angular/forms';
import {Book, BookMetadata, BookRecommendation, FileInfo, ReadStatus} from '../../../../book/model/book.model';
import {Book, BookFile, BookMetadata, BookRecommendation, BookType, FileInfo, ReadStatus} from '../../../../book/model/book.model';
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
import {UserService} from '../../../../settings/user-management/user.service';
import {SplitButton} from 'primeng/splitbutton';
@@ -20,36 +20,28 @@ import {MetadataRefreshType} from '../../../model/request/metadata-refresh-type.
import {Router} from '@angular/router';
import {filter, map, switchMap, take, tap} from 'rxjs/operators';
import {Menu} from 'primeng/menu';
import {InfiniteScrollDirective} from 'ngx-infinite-scroll';
import {BookCardLiteComponent} from '../../../../book/components/book-card-lite/book-card-lite-component';
import {ResetProgressType, ResetProgressTypes} from '../../../../../shared/constants/reset-progress-type';
import {DatePicker} from 'primeng/datepicker';
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
import {BookReviewsComponent} from '../../../../book/components/book-reviews/book-reviews.component';
import {ProgressSpinner} from 'primeng/progressspinner';
import {TieredMenu} from 'primeng/tieredmenu';
import {Image} from 'primeng/image';
import {BookDialogHelperService} from '../../../../book/components/book-browser/book-dialog-helper.service';
import {TagColor, TagComponent} from '../../../../../shared/components/tag/tag.component';
import {BookNotesComponent} from '../../../../book/components/book-notes/book-notes-component';
import {TaskHelperService} from '../../../../settings/task-management/task-helper.service';
import {
fileSizeRanges,
matchScoreRanges,
pageCountRanges
} from '../../../../book/components/book-browser/book-filter/book-filter.component';
import {fileSizeRanges, matchScoreRanges, pageCountRanges} from '../../../../book/components/book-browser/book-filter/book-filter.component';
import {BookNavigationService} from '../../../../book/service/book-navigation.service';
import {Divider} from 'primeng/divider';
import {BookMetadataHostService} from '../../../../../shared/service/book-metadata-host.service';
import { BookReadingSessionsComponent } from '../book-reading-sessions/book-reading-sessions.component';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {DeleteBookFileEvent, DeleteSupplementaryFileEvent, DownloadAdditionalFileEvent, DownloadAllFilesEvent, DownloadEvent, MetadataTabsComponent, ReadEvent} from './metadata-tabs/metadata-tabs.component';
@Component({
selector: 'app-metadata-viewer',
standalone: true,
templateUrl: './metadata-viewer.component.html',
styleUrl: './metadata-viewer.component.scss',
imports: [Button, AsyncPipe, Rating, FormsModule, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, InfiniteScrollDirective, BookCardLiteComponent, DatePicker, Tab, TabList, TabPanel, TabPanels, Tabs, BookReviewsComponent, BookNotesComponent, ProgressSpinner, TieredMenu, Image, TagComponent, UpperCasePipe, Divider, BookReadingSessionsComponent]
imports: [Button, AsyncPipe, Rating, FormsModule, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, DatePicker, ProgressSpinner, TieredMenu, Image, TagComponent, Divider, MetadataTabsComponent]
})
export class MetadataViewerComponent implements OnInit, OnChanges {
@Input() book$!: Observable<Book | null>;
@@ -70,8 +62,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
private destroyRef = inject(DestroyRef);
private dialogRef?: DynamicDialogRef;
pdfReadMenuItems$!: Observable<MenuItem[]>;
epubReadMenuItems$!: Observable<MenuItem[]>;
readMenuItems$!: Observable<MenuItem[]>;
refreshMenuItems$!: Observable<MenuItem[]>;
otherItems$!: Observable<MenuItem[]>;
downloadMenuItems$!: Observable<MenuItem[]>;
@@ -117,24 +108,72 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
])
);
this.pdfReadMenuItems$ = this.book$.pipe(
this.readMenuItems$ = this.book$.pipe(
filter((book): book is Book => book !== null),
map((book): MenuItem[] => [
{
label: 'Streaming Reader',
command: () => this.read(book.id, 'pdf-streaming')
}
])
);
map((book): MenuItem[] => {
const items: MenuItem[] = [];
const primaryType = book.primaryFile?.bookType;
this.epubReadMenuItems$ = this.book$.pipe(
filter((book): book is Book => book !== null),
map((book): MenuItem[] => [
{
label: 'Streaming Reader (Beta)',
command: () => this.read(book.id, 'epub-streaming')
// Add streaming reader option for primary file
if (primaryType === 'PDF') {
items.push({
label: 'Streaming Reader',
icon: 'pi pi-play',
command: () => this.read(book.id, 'pdf-streaming')
});
} else if (primaryType === 'EPUB') {
items.push({
label: 'Streaming Reader',
icon: 'pi pi-play',
command: () => this.read(book.id, 'epub-streaming')
});
}
])
// Get readable alternative formats and group by type
const readableAlternatives = book.alternativeFormats?.filter(f =>
f.bookType && ['PDF', 'EPUB', 'FB2', 'MOBI', 'AZW3', 'CBX', 'AUDIOBOOK'].includes(f.bookType)
) ?? [];
// Get unique format types from alternatives
const uniqueAltTypes = [...new Set(readableAlternatives.map(f => f.bookType))];
if (uniqueAltTypes.length > 0) {
if (items.length > 0) {
items.push({separator: true});
}
uniqueAltTypes.forEach(formatType => {
if (formatType === 'PDF' || formatType === 'EPUB') {
// For PDF/EPUB, offer both standard and streaming readers
items.push({
label: formatType,
icon: this.getFileIcon(formatType),
items: [
{
label: 'Standard Reader',
icon: 'pi pi-book',
command: () => this.read(book.id, undefined, formatType)
},
{
label: 'Streaming Reader',
icon: 'pi pi-play',
command: () => this.read(book.id, formatType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', formatType)
}
]
});
} else {
// For other formats, just show the type
items.push({
label: formatType,
icon: this.getFileIcon(formatType ?? null),
command: () => this.read(book.id, undefined, formatType)
});
}
});
}
return items;
})
);
this.downloadMenuItems$ = this.book$.pipe(
@@ -144,13 +183,12 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
map((book): MenuItem[] => {
const items: MenuItem[] = [];
// Add alternative formats
// Add alternative formats with type and size
if (book.alternativeFormats && book.alternativeFormats.length > 0) {
book.alternativeFormats.forEach(format => {
const extension = this.getFileExtension(format.filePath);
items.push({
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
icon: this.getFileIcon(extension),
label: `${format.bookType ?? 'File'} · ${this.formatFileSize(format)}`,
icon: this.getFileIcon(format.bookType ?? null),
command: () => this.downloadAdditionalFile(book, format.id)
});
});
@@ -167,8 +205,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
book.supplementaryFiles.forEach(file => {
const extension = this.getFileExtension(file.filePath);
items.push({
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
label: `${this.truncateFileName(file.fileName, 20)} · ${this.formatFileSize(file)}`,
icon: this.getFileIcon(extension),
tooltipOptions: {tooltipLabel: file.fileName, tooltipPosition: 'left'},
command: () => this.downloadAdditionalFile(book, file.id)
});
});
@@ -181,11 +220,19 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
this.otherItems$ = this.book$.pipe(
filter((book): book is Book => book !== null),
switchMap(book =>
this.userService.userState$.pipe(
take(1),
map(userState => {
combineLatest([
this.userService.userState$.pipe(take(1)),
this.appSettingsService.appSettings$.pipe(take(1))
]).pipe(
map(([userState, appSettings]) => {
const items: MenuItem[] = [];
items.push({
label: 'Shelf',
icon: 'pi pi-folder',
command: () => this.assignShelf(book.id)
});
// Add allowed submenus based on user permissions
if (userState?.user?.permissions.canUpload || userState?.user?.permissions.admin) {
@@ -198,7 +245,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
});
}
if (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin) {
const hasFiles = this.hasAnyFiles(book);
if (hasFiles && (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin) && appSettings?.diskType === 'LOCAL') {
items.push({
label: 'Organize Files',
icon: 'pi pi-arrows-h',
@@ -208,7 +257,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
});
}
if (userState?.user?.permissions.canEmailBook || userState?.user?.permissions.admin) {
if (hasFiles && (userState?.user?.permissions.canEmailBook || userState?.user?.permissions.admin)) {
items.push({
label: 'Send Book',
icon: 'pi pi-send',
@@ -229,18 +278,113 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
});
}
if (userState?.user?.permissions.canDeleteBook || userState?.user?.permissions.admin) {
// Show "Attach to Another Book" for single-file books (detached books) - not for physical books
const isSingleFileBook = hasFiles && !book.alternativeFormats?.length;
if (isSingleFileBook && (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin)) {
items.push({
label: 'Delete Book',
label: 'Attach to Another Book',
icon: 'pi pi-link',
command: () => {
this.bookDialogHelperService.openBookFileAttacherDialog(book);
},
});
}
if (userState?.user?.permissions.canDeleteBook || userState?.user?.permissions.admin) {
// Delete File Formats submenu - allows deleting individual book format files
const deleteFormatItems: MenuItem[] = [];
const hasMultipleFormats = (book.alternativeFormats?.length ?? 0) > 0;
// Add primary file if it exists
if (book.primaryFile) {
const extension = this.getFileExtension(book.primaryFile.filePath);
const isPrimaryOnly = !hasMultipleFormats;
const truncatedName = this.truncateFileName(book.primaryFile.fileName, 25);
deleteFormatItems.push({
label: `${truncatedName} (${this.formatFileSize(book.primaryFile)}) [Primary]`,
icon: this.getFileIcon(extension),
tooltipOptions: {tooltipLabel: book.primaryFile.fileName, tooltipPosition: 'left'},
command: () => this.deleteBookFile(book, book.primaryFile!.id, book.primaryFile!.fileName || 'file', true, isPrimaryOnly)
});
}
// Add alternative formats
if (book.alternativeFormats && book.alternativeFormats.length > 0) {
book.alternativeFormats.forEach(format => {
const extension = this.getFileExtension(format.filePath);
const truncatedName = this.truncateFileName(format.fileName, 25);
deleteFormatItems.push({
label: `${truncatedName} (${this.formatFileSize(format)})`,
icon: this.getFileIcon(extension),
tooltipOptions: {tooltipLabel: format.fileName, tooltipPosition: 'left'},
command: () => this.deleteBookFile(book, format.id, format.fileName || 'file', false, false)
});
});
}
if (deleteFormatItems.length > 0) {
items.push({
label: 'Delete File Formats',
icon: 'pi pi-file',
items: deleteFormatItems
});
}
// Delete Supplementary Files submenu - for non-book files
if (book.supplementaryFiles && book.supplementaryFiles.length > 0) {
const deleteSupplementaryItems: MenuItem[] = [];
book.supplementaryFiles.forEach(file => {
const extension = this.getFileExtension(file.filePath);
const truncatedName = this.truncateFileName(file.fileName, 25);
deleteSupplementaryItems.push({
label: `${truncatedName} (${this.formatFileSize(file)})`,
icon: this.getFileIcon(extension),
tooltipOptions: {tooltipLabel: file.fileName, tooltipPosition: 'left'},
command: () => this.deleteAdditionalFile(book.id, file.id, file.fileName || 'file')
});
});
items.push({
label: 'Delete Supplementary Files',
icon: 'pi pi-paperclip',
items: deleteSupplementaryItems
});
}
// Delete Book & All Files - deletes the entire book entity
const allFormats: string[] = [];
if (book.primaryFile?.fileName) {
allFormats.push(book.primaryFile.fileName);
}
book.alternativeFormats?.forEach(f => {
if (f.fileName) allFormats.push(f.fileName);
});
book.supplementaryFiles?.forEach(f => {
if (f.fileName) allFormats.push(f.fileName);
});
const isPhysical = !hasFiles;
const fileListMessage = allFormats.length > 0
? `\n\nThe following files will be permanently deleted:\n• ${allFormats.join('\n• ')}`
: '';
const deleteLabel = isPhysical ? 'Delete Book' : 'Delete Book & All Files';
const deleteMessage = isPhysical
? `Are you sure you want to delete "${book.metadata?.title}"?\n\nThis will permanently remove the book record from your library.\n\nThis action cannot be undone.`
: `Are you sure you want to delete "${book.metadata?.title}"?\n\nThis will permanently remove the book record AND all associated files from your filesystem.${fileListMessage}\n\nThis action cannot be undone.`;
const deleteAcceptLabel = isPhysical ? 'Delete' : 'Delete Everything';
items.push({
label: deleteLabel,
icon: 'pi pi-trash',
command: () => {
this.confirmationService.confirm({
message: `Are you sure you want to delete "${book.metadata?.title}"?\n\nThis will permanently remove the book file from your filesystem.\n\nThis action cannot be undone.`,
header: 'Confirm Deletion',
message: deleteMessage,
header: deleteLabel,
icon: 'pi pi-exclamation-triangle',
acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times',
acceptLabel: 'Delete',
acceptLabel: deleteAcceptLabel,
rejectLabel: 'Cancel',
acceptButtonStyleClass: 'p-button-danger',
rejectButtonStyleClass: 'p-button-outlined',
@@ -260,48 +404,6 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
});
},
});
// Add delete additional files menu if there are any additional files
if ((book.alternativeFormats && book.alternativeFormats.length > 0) ||
(book.supplementaryFiles && book.supplementaryFiles.length > 0)) {
const deleteFileItems: MenuItem[] = [];
// Add alternative formats
if (book.alternativeFormats && book.alternativeFormats.length > 0) {
book.alternativeFormats.forEach(format => {
const extension = this.getFileExtension(format.filePath);
deleteFileItems.push({
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
icon: this.getFileIcon(extension),
command: () => this.deleteAdditionalFile(book.id, format.id, format.fileName || 'file')
});
});
}
// Add separator if both types exist
if (book.alternativeFormats && book.alternativeFormats.length > 0 &&
book.supplementaryFiles && book.supplementaryFiles.length > 0) {
deleteFileItems.push({separator: true});
}
// Add supplementary files
if (book.supplementaryFiles && book.supplementaryFiles.length > 0) {
book.supplementaryFiles.forEach(file => {
const extension = this.getFileExtension(file.filePath);
deleteFileItems.push({
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
icon: this.getFileIcon(extension),
command: () => this.deleteAdditionalFile(book.id, file.id, file.fileName || 'file')
});
});
}
items.push({
label: 'Delete Additional Files',
icon: 'pi pi-trash',
items: deleteFileItems
});
}
}
return items;
@@ -375,16 +477,29 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
);
}
get defaultTabValue(): number {
return this.bookInSeries && this.bookInSeries.length > 1 ? 1 : 2;
}
toggleExpand(): void {
this.isExpanded = !this.isExpanded;
}
read(bookId: number | undefined, reader?: "pdf-streaming" | "epub-streaming"): void {
if (bookId) this.bookService.readBook(bookId, reader);
read(bookId: number | undefined, reader?: "pdf-streaming" | "epub-streaming", bookType?: BookType): void {
if (bookId) this.bookService.readBook(bookId, reader, bookType);
}
isInProgressStatus(): boolean {
return [ReadStatus.READING, ReadStatus.PAUSED, ReadStatus.RE_READING].includes(this.selectedReadStatus);
}
getReadButtonLabel(book: Book): string {
const isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK';
if (this.isInProgressStatus()) {
return isAudiobook ? 'Continue' : 'Continue Reading';
}
return isAudiobook ? 'Play' : 'Read';
}
getReadButtonIcon(book: Book): string {
const isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK';
return (isAudiobook || this.isInProgressStatus()) ? 'pi pi-play' : 'pi pi-book';
}
download(book: Book) {
@@ -395,13 +510,39 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
this.bookService.downloadAdditionalFile(book, fileId);
}
// Event handlers for MetadataTabsComponent
onReadBook(event: ReadEvent): void {
this.read(event.bookId, event.reader, event.bookType);
}
onDownloadBook(event: DownloadEvent): void {
this.download(event.book);
}
onDownloadFile(event: DownloadAdditionalFileEvent): void {
this.downloadAdditionalFile(event.book, event.fileId);
}
onDownloadAllFiles(event: DownloadAllFilesEvent): void {
this.bookService.downloadAllFiles(event.book);
}
onDeleteBookFile(event: DeleteBookFileEvent): void {
this.deleteBookFile(event.book, event.fileId, event.fileName, event.isPrimary, event.isOnlyFormat);
}
onDeleteSupplementaryFile(event: DeleteSupplementaryFileEvent): void {
this.deleteAdditionalFile(event.bookId, event.fileId, event.fileName);
}
deleteAdditionalFile(bookId: number, fileId: number, fileName: string) {
this.confirmationService.confirm({
message: `Are you sure you want to delete the additional file "${fileName}"?`,
header: 'Confirm File Deletion',
message: `Are you sure you want to delete the supplementary file "${fileName}"?\n\nThis file will be permanently removed from your filesystem.`,
header: 'Delete Supplementary File',
icon: 'pi pi-exclamation-triangle',
acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times',
rejectButtonStyleClass: 'p-button-secondary',
acceptButtonStyleClass: 'p-button-danger',
accept: () => {
this.bookService.deleteAdditionalFile(bookId, fileId).subscribe({
@@ -409,14 +550,63 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Additional file "${fileName}" deleted successfully`
detail: `Supplementary file "${fileName}" deleted successfully`
});
},
error: (error) => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: `Failed to delete additional file: ${error.message || 'Unknown error'}`
detail: `Failed to delete supplementary file: ${error.message || 'Unknown error'}`
});
}
});
}
});
}
deleteBookFile(book: Book, fileId: number, fileName: string, isPrimary: boolean, isOnlyFormat: boolean) {
let message: string;
let header: string;
if (isOnlyFormat) {
// This is the only book format file - warn user strongly
message = `Are you sure you want to delete "${fileName}"?\n\nThis is the ONLY book format file for this book. After deletion, the book will have no readable content.\n\nConsider using "Delete Book & All Files" instead to completely remove the book.\n\nThis file will be permanently removed from your filesystem.`;
header = 'Delete Only Book Format';
} else if (isPrimary) {
// This is the primary format but there are alternatives
message = `Are you sure you want to delete "${fileName}"?\n\nThis is currently the PRIMARY format for this book. After deletion, an alternative format will become the new primary.\n\nThis file will be permanently removed from your filesystem.`;
header = 'Delete Primary Format';
} else {
// This is an alternative format
message = `Are you sure you want to delete "${fileName}"?\n\nThis file will be permanently removed from your filesystem.`;
header = 'Delete Book Format';
}
this.confirmationService.confirm({
message,
header,
icon: 'pi pi-exclamation-triangle',
acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times',
acceptLabel: 'Delete File',
rejectLabel: 'Cancel',
rejectButtonStyleClass: 'p-button-secondary',
acceptButtonStyleClass: 'p-button-danger',
accept: () => {
this.bookService.deleteBookFile(book.id, fileId, isPrimary).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Book format "${fileName}" deleted successfully`
});
},
error: (error) => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: `Failed to delete book format: ${error.message || 'Unknown error'}`
});
}
});
@@ -674,9 +864,42 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
return lockedKeys.length > 0 && lockedKeys.every(k => metadata[k] === true);
}
getFileSizeInMB(fileInfo: FileInfo | null | undefined): string {
formatFileSize(fileInfo: FileInfo | null | undefined): string {
const sizeKb = fileInfo?.fileSizeKb;
return sizeKb != null ? `${(sizeKb / 1024).toFixed(2)} MB` : '-';
if (sizeKb == null) return '-';
const units = ['KB', 'MB', 'GB', 'TB'];
let size = sizeKb;
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
const decimals = size >= 100 ? 0 : size >= 10 ? 1 : 2;
return `${size.toFixed(decimals)} ${units[unitIndex]}`;
}
truncateFileName(fileName: string | undefined, maxLength: number = 30): string {
if (!fileName) return '';
if (fileName.length <= maxLength) return fileName;
const lastDotIndex = fileName.lastIndexOf('.');
if (lastDotIndex === -1) {
// No extension - just truncate
return fileName.substring(0, maxLength - 3) + '...';
}
const extension = fileName.substring(lastDotIndex);
const nameWithoutExt = fileName.substring(0, lastDotIndex);
const availableLength = maxLength - extension.length - 3; // 3 for "..."
if (availableLength <= 0) {
return '...' + extension;
}
return nameWithoutExt.substring(0, availableLength) + '...' + extension;
}
getProgressPercent(book: Book): number | null {
@@ -689,6 +912,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
if (book.cbxProgress?.percentage != null) {
return book.cbxProgress.percentage;
}
if (book.audiobookProgress?.percentage != null) {
return book.audiobookProgress.percentage;
}
return null;
}
@@ -721,6 +947,38 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
return parts.pop()?.toUpperCase() || null;
}
getUniqueAlternativeFormatTypes(book: Book): BookType[] {
if (!book.alternativeFormats?.length) return [];
const primaryType = book.primaryFile?.bookType;
const uniqueTypes = new Set<BookType>();
for (const format of book.alternativeFormats) {
if (format.bookType && format.bookType !== primaryType) {
uniqueTypes.add(format.bookType);
}
}
return [...uniqueTypes];
}
getDisplayFormat(bookFile?: BookFile | null): string | null {
if (bookFile?.extension) {
return bookFile.extension.toUpperCase();
}
return this.getFileExtension(bookFile?.filePath);
}
getUniqueAlternativeFormats(book: Book): string[] {
if (!book.alternativeFormats?.length) return [];
const primaryFormat = this.getDisplayFormat(book.primaryFile);
const uniqueFormats = new Set<string>();
for (const format of book.alternativeFormats) {
const formatType = this.getDisplayFormat(format);
if (formatType && formatType !== primaryFormat) {
uniqueFormats.add(formatType);
}
}
return [...uniqueFormats];
}
getFileIcon(fileType: string | null): string {
if (!fileType) return 'pi pi-file';
switch (fileType.toLowerCase()) {
@@ -734,6 +992,11 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
case 'cbr':
case 'cbx':
return 'pi pi-image';
case 'audiobook':
case 'm4b':
case 'm4a':
case 'mp3':
return 'pi pi-headphones';
default:
return 'pi pi-file';
}
@@ -956,4 +1219,16 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
const position = this.bookNavigationService.getCurrentPosition();
return position ? `${position.current} of ${position.total}` : '';
}
hasDigitalFile(book: Book): boolean {
return !!book?.primaryFile;
}
hasAnyFiles(book: Book): boolean {
return !!book?.primaryFile || (book?.alternativeFormats?.length ?? 0) > 0;
}
isPhysicalBook(book: Book): boolean {
return !this.hasAnyFiles(book);
}
}
@@ -1,5 +1,4 @@
import {Component, inject, Input, OnInit} from '@angular/core';
import {Toast} from 'primeng/toast';
import {MessageService} from 'primeng/api';
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
import {BookCoverService, CoverFetchRequest, CoverImage} from '../../../../shared/services/book-cover.service';
@@ -32,6 +31,7 @@ export class CoverSearchComponent implements OnInit {
coverImages: CoverImage[] = [];
loading = false;
hasSearched = false;
isAudiobook = false;
private fb = inject(FormBuilder);
private bookCoverService = inject(BookCoverService);
@@ -52,6 +52,7 @@ export class CoverSearchComponent implements OnInit {
const book = this.bookService.getBookByIdFromState(this.bookId);
if (book) {
this.isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK';
this.searchForm.patchValue({
title: book.metadata?.title || '',
author: book.metadata?.authors && book.metadata?.authors.length > 0 ? book.metadata?.authors[0] : ''
@@ -68,7 +69,8 @@ export class CoverSearchComponent implements OnInit {
this.loading = true;
const request: CoverFetchRequest = {
title: this.searchForm.value.title,
author: this.searchForm.value.author
author: this.searchForm.value.author,
squareCover: this.isAudiobook
};
this.bookCoverService.fetchBookCovers(request)