feat: Series Enhancements (#1086)
* show active comic in the series banner * Hide pi-info button in series banner when book is active * When collapsed series: displays series title instead of book title, substitutes series number overlay by series count * New series page w/ redirections from other pages * Update booklore-ui/src/app/book/components/book-card-lite/book-card-lite-component.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update booklore-ui/src/app/book/components/series-page/series-page.component.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * removed commented unused status * cleaned minor warnings --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import {OidcCallbackComponent} from './core/security/oidc-callback/oidc-callback
|
||||
import {CbxReaderComponent} from './book/components/cbx-reader/cbx-reader.component';
|
||||
import {BookdropFileReviewComponent} from './bookdrop/bookdrop-file-review-component/bookdrop-file-review.component';
|
||||
import {MainDashboardComponent} from './dashboard/components/main-dashboard/main-dashboard.component';
|
||||
import {SeriesPageComponent} from './book/components/series-page/series-page.component';
|
||||
import {StatsComponent} from './stats-component/stats-component';
|
||||
|
||||
export const routes: Routes = [
|
||||
@@ -42,6 +43,7 @@ export const routes: Routes = [
|
||||
{path: 'library/:libraryId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'shelf/:shelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'unshelved-books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'series/:seriesName', component: SeriesPageComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'magic-shelf/:magicShelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard] },
|
||||
{path: 'book/:bookId', component: BookMetadataCenterComponent, canActivate: [AuthGuard]},
|
||||
{path: 'bookdrop', component: BookdropFileReviewComponent, canActivate: [AuthGuard]},
|
||||
|
||||
@@ -277,15 +277,16 @@
|
||||
<div
|
||||
class="virtual-scroller-item relative"
|
||||
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
||||
<app-book-card
|
||||
[index]="i"
|
||||
[book]="book"
|
||||
[isCheckboxEnabled]="true"
|
||||
[onBookSelect]="handleBookSelect.bind(this)"
|
||||
[isSeriesCollapsed]="seriesCollapseFilter.isSeriesCollapsed"
|
||||
(checkboxClick)="onCheckboxClicked($event)"
|
||||
[isSelected]="selectedBooks.has(book.id)">
|
||||
</app-book-card>
|
||||
<app-book-card
|
||||
[index]="i"
|
||||
[book]="book"
|
||||
[isCheckboxEnabled]="true"
|
||||
[readButtonHidden]="book.seriesCount ? true : false"
|
||||
[onBookSelect]="handleBookSelect.bind(this)"
|
||||
[isSeriesCollapsed]="seriesCollapseFilter.isSeriesCollapsed"
|
||||
(checkboxClick)="onCheckboxClicked($event)"
|
||||
[isSelected]="selectedBooks.has(book.id)">
|
||||
</app-book-card>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
+11
-7
@@ -14,24 +14,28 @@
|
||||
[src]="urlHelper.getThumbnailUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
class="book-cover"
|
||||
[class.loaded]="isImageLoaded"
|
||||
alt="Cover of {{ book.metadata?.title }}"
|
||||
alt="Cover of {{ displayTitle }}"
|
||||
loading="lazy"
|
||||
(load)="onImageLoad()"/>
|
||||
</div>
|
||||
|
||||
@if (book.metadata?.seriesNumber != null) {
|
||||
@if (!book.seriesCount && book.metadata?.seriesNumber != null) {
|
||||
<div class="series-number-overlay">
|
||||
#{{ book.metadata?.seriesNumber }}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (book.seriesCount != null && book.seriesCount! > 1) {
|
||||
<div class="series-count-overlay">
|
||||
@if (book.seriesCount && book.seriesCount! >= 1) {
|
||||
<div class="series-items-count-overlay">
|
||||
{{ book.seriesCount }}
|
||||
</div>
|
||||
}
|
||||
|
||||
<p-button [rounded]="true" icon="pi pi-info" class="info-btn" (click)="openBookInfo(book)"></p-button>
|
||||
@if (book.seriesCount && book.seriesCount! >= 1) {
|
||||
<p-button [rounded]="true" icon="pi pi-info" class="info-btn" (click)="openSeriesInfo()"></p-button>
|
||||
} @else {
|
||||
<p-button [rounded]="true" icon="pi pi-info" class="info-btn" (click)="openBookInfo(book)"></p-button>
|
||||
}
|
||||
|
||||
<p-button [hidden]="readButtonHidden" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
|
||||
|
||||
@@ -70,8 +74,8 @@
|
||||
<h4 class="book-title m-0 pl-2"
|
||||
tooltipPosition="bottom"
|
||||
tooltipStyleClass="text-xs text-center"
|
||||
[pTooltip]="book.metadata?.title">
|
||||
{{ book.metadata?.title }}
|
||||
[pTooltip]="displayTitle">
|
||||
{{ displayTitle }}
|
||||
</h4>
|
||||
<p-tieredmenu #menu [model]="items" [popup]="true" appendTo="body"></p-tieredmenu>
|
||||
<p-button
|
||||
|
||||
@@ -157,9 +157,9 @@
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.series-count-overlay {
|
||||
.series-items-count-overlay {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
top: 8px;
|
||||
left: 8px;
|
||||
background-color: var(--primary-color);
|
||||
color: var(--primary-text-color-dark);
|
||||
|
||||
@@ -109,6 +109,11 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
return null;
|
||||
}
|
||||
|
||||
get displayTitle(): string | undefined {
|
||||
return (this.isSeriesCollapsed && this.book.metadata?.seriesName) ? this.book.metadata?.seriesName : this.book.metadata?.title;
|
||||
// return (this.isSeriesCollapsed && this.book.metadata?.seriesName) ? this.book.metadata.seriesName : this.book.metadata?.title;
|
||||
}
|
||||
|
||||
onImageLoad(): void {
|
||||
this.isImageLoaded = true;
|
||||
}
|
||||
@@ -462,6 +467,15 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
openSeriesInfo(): void {
|
||||
const seriesName = this.book?.metadata?.seriesName;
|
||||
if (this.isSeriesCollapsed && seriesName) {
|
||||
this.router.navigate(['/series', seriesName]);
|
||||
} else {
|
||||
this.openBookInfo(this.book);
|
||||
}
|
||||
}
|
||||
|
||||
openBookInfo(book: Book): void {
|
||||
if (this.metadataCenterViewMode === 'route') {
|
||||
this.router.navigate(['/book', book.id], {
|
||||
|
||||
@@ -5,13 +5,15 @@
|
||||
alt="Cover of {{ book.metadata?.title }}"
|
||||
loading="lazy"/>
|
||||
|
||||
<p-button
|
||||
icon="pi pi-info"
|
||||
class="info-btn"
|
||||
[rounded]="true"
|
||||
[pTooltip]="book.metadata?.title"
|
||||
tooltipPosition="top"
|
||||
[ngClass]="{ 'visible': isHovered }"
|
||||
(onClick)="openBookInfo(book)">
|
||||
</p-button>
|
||||
@if (!this.isActive) {
|
||||
<p-button
|
||||
icon="pi pi-info"
|
||||
class="info-btn"
|
||||
[rounded]="true"
|
||||
[pTooltip]="book.metadata?.title"
|
||||
tooltipPosition="top"
|
||||
[ngClass]="{ 'visible': isHovered }"
|
||||
(onClick)="openBookInfo(book)">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,7 @@ import {TooltipModule} from 'primeng/tooltip';
|
||||
})
|
||||
export class BookCardLiteComponent implements OnInit, OnDestroy {
|
||||
@Input() book!: Book;
|
||||
@Input() isActive: boolean = false;
|
||||
|
||||
private router = inject(Router);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
@if (filteredBooks$ | async; as books) {
|
||||
<div class="rounded-xl overflow-hidden">
|
||||
<p-tabs [value]="tab" lazy="true" scrollable>
|
||||
<p-tablist>
|
||||
<p-tab value="view">
|
||||
<i [class]="'pi pi-crown'"></i>
|
||||
Series Details
|
||||
</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels class="tabpanels-responsive overflow-auto">
|
||||
<p-tabpanel value="view">
|
||||
|
||||
@if (books[0]; as firstBook) {
|
||||
<div class="flex flex-col justify-between flex-grow">
|
||||
<div class="space-y-4 ">
|
||||
|
||||
<!-- <div class="flex items-start justify-between"> -->
|
||||
<div class="flex flex-col text-center gap-4 md:text-left w-full">
|
||||
|
||||
<div class="flex flex-col items-center md:items-start gap-1">
|
||||
<div class="flex items-center gap-2 justify-center md:justify-start flex-wrap text-center md:text-left">
|
||||
<h2 class="text-2xl md:text-3xl font-extrabold leading-tight">
|
||||
{{ seriesTitle$ | async }}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<p class="text-lg">
|
||||
@for (author of firstBook.metadata?.authors; track $index; let isLast = $last) {
|
||||
<a class="hover:underline dark:text-blue-400 cursor-pointer" (click)="goToAuthorBooks(author)">
|
||||
{{ author }}
|
||||
</a>
|
||||
@if (!isLast) {
|
||||
<span>, </span>
|
||||
}
|
||||
}
|
||||
</p>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
|
||||
@if (firstBook.metadata?.categories?.length) {
|
||||
<div class="overflow-x-auto scrollbar-hide max-w-7xl pt-2 md:pt-0">
|
||||
<div class="flex gap-2 w-max max-w-[1150px]">
|
||||
@for (category of firstBook.metadata?.categories; track category) {
|
||||
<a (click)="goToCategory(category)" class="shrink-0 no-underline cursor-pointer">
|
||||
<p-tag [value]="category"></p-tag>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="px-1 md:px-0">
|
||||
<div
|
||||
class="grid md:grid-cols-5 p-3 gap-y-2.5 text-sm pt-2 md:pt-4 pb-2 text-gray-300 md:min-w-[60rem] md:max-w-[100rem]">
|
||||
<p>
|
||||
<span class="font-bold">Publisher: </span>
|
||||
@if (firstBook.metadata?.publisher; as publisher) {
|
||||
<span class="underline hover:opacity-80 cursor-pointer" (click)="goToPublisher(publisher)">
|
||||
{{publisher}}
|
||||
</span>
|
||||
} @else {
|
||||
<span>-</span>
|
||||
}
|
||||
</p>
|
||||
<p><strong>Years:</strong> {{ (yearsRange$ | async) || '-' }}</p>
|
||||
<p><strong>Number of books:</strong> {{ books.length || 0}}</p>
|
||||
<p><strong>Language:</strong> {{ firstBook.metadata?.language || "-"}}</p>
|
||||
<p><strong>Read Status: </strong>
|
||||
@let s = seriesReadStatus$ | async;
|
||||
<span class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
|
||||
[ngClass]="getStatusSeverityClass(s || 'UNREAD')">
|
||||
{{ getStatusLabel(s) }}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- DESCRIPTION -->
|
||||
<div class="px-4 pb-2 pt-4 mb-4 md:mb-6 md:mx-2 border border-[var(--border-color)] rounded-xl">
|
||||
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }"
|
||||
class="transition-all duration-300 overflow-hidden description-container">
|
||||
<div class="readonly-editor px-2"
|
||||
[innerHTML]="(firstDescription$ | async) || 'No description available.'"></div>
|
||||
</div>
|
||||
@let desc = firstDescription$ | async;
|
||||
@if ((desc?.length ?? 0) > 500) {
|
||||
<p-button [label]="isExpanded ? 'Show less' : 'Show more'"
|
||||
[icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" iconPos="right" size="small" text
|
||||
(click)="toggleExpand()">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="grid series-items-grid overflow-y-auto" #Container
|
||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
||||
<div class="grid-item" *ngFor="let book of books; let i = index"
|
||||
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
||||
<app-book-card [index]="i" [book]="book" [isCheckboxEnabled]="false" [isSelected]="false"
|
||||
[isSeriesCollapsed]="false">
|
||||
</app-book-card>
|
||||
</div>
|
||||
<div *ngIf="books.length === 0" class="empty-state">No books found for this series.</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
</p-tabpanel>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
</div>
|
||||
|
||||
} @else {
|
||||
<div class="flex flex-col justify-center items-center h-full gap-4">
|
||||
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s">
|
||||
</p-progressSpinner>
|
||||
<p style="color: var(--primary-color);">
|
||||
Loading series details...
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
@if (filteredBooks$ | async; as books) {
|
||||
<div class="rounded-xl overflow-hidden series-page">
|
||||
<p-tabs [value]="tab" lazy="true" scrollable>
|
||||
<p-tablist>
|
||||
<p-tab value="view">
|
||||
<i [class]="'pi pi-crown'"></i>
|
||||
Series Details
|
||||
</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels class="tabpanels-responsive overflow-auto">
|
||||
<p-tabpanel value="view">
|
||||
|
||||
<!-- <ng-container *ngIf="filteredBooks$ | async as books"> -->
|
||||
|
||||
<div class="flex flex-col justify-between flex-grow">
|
||||
<div class="space-y-4 ">
|
||||
|
||||
<!-- <div class="flex items-start justify-between"> -->
|
||||
<div class="flex flex-col text-center gap-4 md:text-left w-full">
|
||||
|
||||
<!-- TITLE, AUTHOR -->
|
||||
<div class="flex flex-col items-center md:items-start gap-1">
|
||||
<div
|
||||
class="flex items-center gap-2 justify-center md:justify-start flex-wrap text-center md:text-left">
|
||||
<h2 class="text-2xl md:text-3xl font-extrabold leading-tight">
|
||||
{{ seriesTitle$ | async }}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<p class="text-lg">
|
||||
@for (author of books[0]?.metadata?.authors; track $index; let isLast = $last) {
|
||||
<a class="hover:underline dark:text-blue-400 cursor-pointer">
|
||||
<!--(click)="goToAuthorBooks(author)"-->
|
||||
{{ author }}
|
||||
</a>
|
||||
@if (!isLast) {
|
||||
<span>, </span>
|
||||
}
|
||||
}
|
||||
</p>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
|
||||
<!-- CATEGORIES -->
|
||||
@if (books[0]?.metadata?.categories?.length) {
|
||||
<div class="overflow-x-auto scrollbar-hide max-w-7xl pt-2 md:pt-0">
|
||||
<div class="flex gap-2 w-max max-w-[1150px]">
|
||||
@for (category of books[0].metadata!.categories; track category) {
|
||||
<a class="shrink-0 no-underline cursor-pointer">
|
||||
<p-tag [value]="category"></p-tag>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- METADATA: Number of books, Publisher, Year, Language -->
|
||||
<div class="px-1 md:px-0">
|
||||
<div
|
||||
class="grid md:grid-cols-4 gap-y-2.5 text-sm pt-2 md:pt-4 pb-2 text-gray-300 md:min-w-[60rem] md:max-w-[100rem]">
|
||||
<p><strong>Number of books:</strong> {{ books.length || 0}}</p>
|
||||
<p><strong>Publisher:</strong> {{ books[0]?.metadata?.publisher || "-"}}</p>
|
||||
<p><strong>Year:</strong> {{ books[0]?.metadata?.publishedDate || "-"}}</p>
|
||||
<p><strong>Language:</strong> {{ books[0]?.metadata?.language || "-"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- DESCRIPTION -->
|
||||
<!-- TODO: Show first book description (currently showing empty)-->
|
||||
<div class="px-4 pb-2 pt-4 mb-4 md:mb-6 md:mx-2 border border-[var(--border-color)] rounded-xl">
|
||||
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }"
|
||||
class="transition-all duration-300 overflow-hidden description-container">
|
||||
<div class="readonly-editor px-2">
|
||||
<!-- <p-editor #quillEditor [readonly]="true" [style]="{height: '200px'}"
|
||||
[ngModel]="books[0]?.metadata!.description || 'No description available.'">
|
||||
<ng-template #header>
|
||||
</ng-template>
|
||||
</p-editor> -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- @if (books[0]?.metadata!.description && books[0]?.metadata!.description.length > 500) {
|
||||
<p-button [label]="isExpanded ? 'Show less' : 'Show more'"
|
||||
[icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" iconPos="right" size="small" text
|
||||
(click)="toggleExpand()">
|
||||
</p-button>
|
||||
} -->
|
||||
</div>
|
||||
|
||||
<!-- BOOKS GRID -->
|
||||
<!-- <virtual-scroller class="virtual-scroller" #scroll [items]="books">
|
||||
<div class="grid" #Container
|
||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
||||
@for (book of scroll.viewPortItems; let i = $index; track book) {
|
||||
<div class="virtual-scroller-item relative"
|
||||
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
||||
<app-book-card [index]="i" [book]="book" [isCheckboxEnabled]="false" [isSelected]="false"
|
||||
[isSeriesCollapsed]="false">
|
||||
</app-book-card>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</virtual-scroller> -->
|
||||
|
||||
<!-- <virtual-scroller class="virtual-scroller" #scroll [items]="books">
|
||||
<div class="grid" #Container
|
||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
||||
<div class="grid-item" *ngFor="let book of books; let i = index"
|
||||
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
||||
<app-book-card [index]="i" [book]="book" [isCheckboxEnabled]="false" [isSelected]="false"
|
||||
[isSeriesCollapsed]="false">
|
||||
</app-book-card>
|
||||
</div>
|
||||
<div *ngIf="books.length === 0" class="empty-state">No books found for this series.</div>
|
||||
</div>
|
||||
</virtual-scroller> -->
|
||||
|
||||
<div class="grid series-items-grid overflow-y-auto" #Container
|
||||
[ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
|
||||
<div class="grid-item" *ngFor="let book of books; let i = index"
|
||||
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
|
||||
<app-book-card [index]="i" [book]="book" [isCheckboxEnabled]="false" [isSelected]="false"
|
||||
[isSeriesCollapsed]="false">
|
||||
</app-book-card>
|
||||
</div>
|
||||
<div *ngIf="books.length === 0" class="empty-state">No books found for this series.</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- </ng-container> -->
|
||||
|
||||
</p-tabpanel>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="flex flex-col justify-center items-center h-full gap-4">
|
||||
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s">
|
||||
</p-progressSpinner>
|
||||
<p style="color: var(--primary-color);">
|
||||
Loading series details...
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
.tabpanels-responsive {
|
||||
height: calc(100dvh - 9.7rem);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.tabpanels-responsive {
|
||||
height: calc(100dvh - 8.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(1px, 1fr));
|
||||
gap: 1.3rem;
|
||||
align-items: start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
import { Component, inject, ViewChild } from "@angular/core";
|
||||
import { FormsModule } from "@angular/forms";
|
||||
import { Button } from "primeng/button";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { AsyncPipe, NgClass, NgFor, NgIf, NgStyle } from "@angular/common";
|
||||
import { map, filter, switchMap } from "rxjs/operators";
|
||||
import { Observable, combineLatest } from "rxjs";
|
||||
import { Book, ReadStatus } from "../../model/book.model";
|
||||
import { BookService } from "../../service/book.service";
|
||||
import { BookCardComponent } from "../book-browser/book-card/book-card.component";
|
||||
import { CoverScalePreferenceService } from "../book-browser/cover-scale-preference.service";
|
||||
import { Tab, TabList, TabPanel, TabPanels, Tabs } from "primeng/tabs";
|
||||
import { Tag } from "primeng/tag";
|
||||
import { VirtualScrollerModule } from "@iharbeck/ngx-virtual-scroller";
|
||||
import { ProgressSpinner } from "primeng/progressspinner";
|
||||
import { DialogService, DynamicDialogRef } from "primeng/dynamicdialog";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
@Component({
|
||||
selector: "app-series-page",
|
||||
standalone: true,
|
||||
templateUrl: "./series-page.component.html",
|
||||
styleUrls: ["./series-page.component.scss"],
|
||||
imports: [
|
||||
AsyncPipe,
|
||||
Button,
|
||||
FormsModule,
|
||||
NgIf,
|
||||
NgFor,
|
||||
NgStyle,
|
||||
NgClass,
|
||||
BookCardComponent,
|
||||
ProgressSpinner,
|
||||
Tabs,
|
||||
TabList,
|
||||
Tab,
|
||||
TabPanels,
|
||||
TabPanel,
|
||||
Tag,
|
||||
|
||||
VirtualScrollerModule,
|
||||
],
|
||||
})
|
||||
export class SeriesPageComponent {
|
||||
|
||||
private route = inject(ActivatedRoute);
|
||||
private bookService = inject(BookService);
|
||||
protected coverScalePreferenceService = inject(CoverScalePreferenceService);
|
||||
private metadataCenterViewMode: "route" | "dialog" = "route";
|
||||
private dialogRef?: DynamicDialogRef;
|
||||
private router = inject(Router);
|
||||
|
||||
tab: string = "view";
|
||||
isExpanded = false;
|
||||
|
||||
|
||||
seriesParam$: Observable<string> = this.route.paramMap.pipe(
|
||||
map((params) => params.get("seriesName") || ""),
|
||||
map((name) => decodeURIComponent(name))
|
||||
);
|
||||
|
||||
booksInSeries$: Observable<Book[]> = this.bookService.bookState$.pipe(
|
||||
filter((state) => state.loaded && !!state.books),
|
||||
map((state) => state.books || [])
|
||||
);
|
||||
|
||||
filteredBooks$: Observable<Book[]> = combineLatest([
|
||||
this.seriesParam$.pipe(map((n) => n.trim().toLowerCase())),
|
||||
this.booksInSeries$,
|
||||
]).pipe(
|
||||
map(([seriesName, books]) => {
|
||||
const inSeries = books.filter(
|
||||
(b) => b.metadata?.seriesName?.toLowerCase() === seriesName
|
||||
);
|
||||
return inSeries.sort((a, b) => {
|
||||
const aNum = a.metadata?.seriesNumber ?? Number.MAX_SAFE_INTEGER;
|
||||
const bNum = b.metadata?.seriesNumber ?? Number.MAX_SAFE_INTEGER;
|
||||
return aNum - bNum;
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
seriesTitle$: Observable<string> = combineLatest([
|
||||
this.seriesParam$,
|
||||
this.filteredBooks$,
|
||||
]).pipe(map(([param, books]) => books[0]?.metadata?.seriesName || param));
|
||||
|
||||
yearsRange$: Observable<string | null> = this.filteredBooks$.pipe(
|
||||
map((books) => {
|
||||
const years = books
|
||||
.map((b) => b.metadata?.publishedDate)
|
||||
.filter((d): d is string => !!d)
|
||||
.map((d) => {
|
||||
const match = d.match(/\d{4}/);
|
||||
return match ? parseInt(match[0], 10) : null;
|
||||
})
|
||||
.filter((y): y is number => y !== null);
|
||||
|
||||
if (years.length === 0) return null;
|
||||
const min = Math.min(...years);
|
||||
const max = Math.max(...years);
|
||||
return min === max ? String(min) : `${min}-${max}`;
|
||||
})
|
||||
);
|
||||
|
||||
firstBookWithDesc$: Observable<Book> = this.filteredBooks$.pipe(
|
||||
map((books) => books[0]),
|
||||
filter((b): b is Book => !!b),
|
||||
switchMap((b) => this.bookService.getBookByIdFromAPI(b.id, true))
|
||||
);
|
||||
|
||||
firstDescription$: Observable<string> = this.firstBookWithDesc$.pipe(
|
||||
map((b) => b.metadata?.description || "")
|
||||
);
|
||||
|
||||
seriesReadStatus$: Observable<ReadStatus> = this.filteredBooks$.pipe(
|
||||
map((books) => {
|
||||
if (!books || books.length === 0) return ReadStatus.UNREAD;
|
||||
const statuses = books.map((b) => (b.readStatus as ReadStatus) ?? ReadStatus.UNREAD);
|
||||
|
||||
const hasWontRead = statuses.includes(ReadStatus.WONT_READ);
|
||||
if (hasWontRead) return ReadStatus.WONT_READ;
|
||||
|
||||
const hasAbandoned = statuses.includes(ReadStatus.ABANDONED);
|
||||
if (hasAbandoned) return ReadStatus.ABANDONED;
|
||||
|
||||
const allRead = statuses.every((s) => s === ReadStatus.READ);
|
||||
if (allRead) return ReadStatus.READ;
|
||||
|
||||
const someRead = statuses.some((s) => s === ReadStatus.READ);
|
||||
if (someRead) return ReadStatus.PARTIALLY_READ;
|
||||
|
||||
const allUnread = statuses.every((s) => s === ReadStatus.UNREAD);
|
||||
if (allUnread) return ReadStatus.UNREAD;
|
||||
|
||||
return ReadStatus.PARTIALLY_READ;
|
||||
})
|
||||
);
|
||||
|
||||
get currentCardSize() {
|
||||
return this.coverScalePreferenceService.currentCardSize;
|
||||
}
|
||||
|
||||
get gridColumnMinWidth(): string {
|
||||
return this.coverScalePreferenceService.gridColumnMinWidth;
|
||||
}
|
||||
|
||||
goToAuthorBooks(author: string): void {
|
||||
this.handleMetadataClick("author", author);
|
||||
}
|
||||
|
||||
goToCategory(category: string): void {
|
||||
this.handleMetadataClick("category", category);
|
||||
}
|
||||
|
||||
goToPublisher(publisher: string): void {
|
||||
this.handleMetadataClick("publisher", publisher);
|
||||
}
|
||||
|
||||
private navigateToFilteredBooks(
|
||||
filterKey: string,
|
||||
filterValue: string
|
||||
): void {
|
||||
this.router.navigate(["/all-books"], {
|
||||
queryParams: {
|
||||
view: "grid",
|
||||
sort: "title",
|
||||
direction: "asc",
|
||||
sidebar: true,
|
||||
filter: `${filterKey}:${filterValue}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private handleMetadataClick(filterKey: string, filterValue: string): void {
|
||||
if (this.metadataCenterViewMode === "dialog") {
|
||||
this.dialogRef?.close();
|
||||
setTimeout(
|
||||
() => this.navigateToFilteredBooks(filterKey, filterValue),
|
||||
200
|
||||
);
|
||||
} else {
|
||||
this.navigateToFilteredBooks(filterKey, filterValue);
|
||||
}
|
||||
}
|
||||
|
||||
toggleExpand(): void {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
}
|
||||
|
||||
getStatusLabel(value: string | ReadStatus | null | undefined): string {
|
||||
const v = (value ?? '').toString().toUpperCase();
|
||||
switch (v) {
|
||||
case ReadStatus.UNREAD:
|
||||
return 'UNREAD';
|
||||
case ReadStatus.READ:
|
||||
return 'READ';
|
||||
case ReadStatus.PARTIALLY_READ:
|
||||
return 'PARTIALLY READ';
|
||||
case ReadStatus.ABANDONED:
|
||||
return 'ABANDONED';
|
||||
case ReadStatus.WONT_READ:
|
||||
return "WON'T READ";
|
||||
default:
|
||||
return 'UNSET';
|
||||
}
|
||||
}
|
||||
|
||||
getStatusSeverityClass(status: string): string {
|
||||
const normalized = status?.toUpperCase();
|
||||
switch (normalized) {
|
||||
case "UNREAD":
|
||||
return "bg-gray-500";
|
||||
case "READ":
|
||||
return "bg-green-600";
|
||||
case "PARTIALLY_READ":
|
||||
return "bg-yellow-600";
|
||||
case "ABANDONED":
|
||||
return "bg-red-600";
|
||||
case "WONT_READ":
|
||||
return "bg-pink-700";
|
||||
default:
|
||||
return "bg-gray-600";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -578,10 +578,7 @@ export class BookService {
|
||||
}
|
||||
|
||||
const seriesName = currentBook.metadata.seriesName.toLowerCase();
|
||||
return allBooks.filter(b =>
|
||||
b.id !== bookId &&
|
||||
b.metadata?.seriesName?.toLowerCase() === seriesName
|
||||
);
|
||||
return allBooks.filter(b => b.metadata?.seriesName?.toLowerCase() === seriesName);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
+3
-3
@@ -527,9 +527,9 @@
|
||||
[infiniteScrollDistance]="2"
|
||||
[infiniteScrollThrottle]="50"
|
||||
[horizontal]="true">
|
||||
@for (book of bookInSeries; track book.id) {
|
||||
@for (bookInSeriesItem of bookInSeries; track bookInSeriesItem) {
|
||||
<div class="dashboard-scroller-card">
|
||||
<app-book-card-lite-component [book]="book"></app-book-card-lite-component>
|
||||
<app-book-card-lite-component [book]="bookInSeriesItem" [isActive]="bookInSeriesItem.id === book.id"></app-book-card-lite-component>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -548,7 +548,7 @@
|
||||
[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>
|
||||
<app-book-card-lite-component [book]="book.book" ></app-book-card-lite-component>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -543,7 +543,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
goToSeries(seriesName: string): void {
|
||||
this.handleMetadataClick('series', seriesName);
|
||||
this.router.navigate(['/series', seriesName]);
|
||||
}
|
||||
|
||||
goToPublisher(publisher: string): void {
|
||||
|
||||
Reference in New Issue
Block a user