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

This commit is contained in:
aditya.chandel
2025-06-05 18:18:10 -06:00
committed by Aditya Chandel
parent 246efdaa34
commit 0f852ef068
86 changed files with 2567 additions and 2173 deletions
@@ -2,35 +2,47 @@
<div class="flex flex-col flex-grow">
<div class="flex justify-between items-center p-2 rounded-t-xl mb-4 bg-[var(--card-background)]">
<div class="flex items-center pl-2">
<ng-container *ngIf="entityType$ | async as entityType">
<p *ngIf="entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
{{ entityType }}: {{ (entity$ | async)?.name }}
</p>
<p *ngIf="entityType === EntityType.ALL_BOOKS" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
All Books
</p>
<p *ngIf="entityType === EntityType.UNSHELVED" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
Unshelved Books
</p>
<div *ngIf="userService.userState$ | async as userData">
<div *ngIf="entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED && (userData.permissions.admin || userData.permissions.canManipulateLibrary) ">
<p-button icon="pi pi-ellipsis-v" [rounded]="true" [text]="true" severity="info" (click)="entitymenu.toggle($event)"></p-button>
<p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu>
@if (entityType$ | async; as entityType) {
@if (entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
{{ entityType }}: {{ (entity$ | async)?.name }}
</p>
}
@if (entityType === EntityType.ALL_BOOKS) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
All Books
</p>
}
@if (entityType === EntityType.UNSHELVED) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
Unshelved Books
</p>
}
@if (userService.userState$ | async; as userData) {
<div>
@if (entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED && (userData.permissions.admin || userData.permissions.canManipulateLibrary) ) {
<div>
<p-button icon="pi pi-ellipsis-v" [rounded]="true" [text]="true" severity="info" (click)="entitymenu.toggle($event)"></p-button>
<p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu>
</div>
}
</div>
</div>
</ng-container>
}
}
</div>
<div class="flex items-center gap-8">
<div class="flex flex-row items-center gap-6">
<a *ngIf="isFilterActive" class="topbar-items topbar-item" (click)="clearFilter()">
<i
class="pi pi-filter-slash"
pTooltip="Clear applied filters"
tooltipPosition="top">
</i>
</a>
@if (isFilterActive) {
<a class="topbar-items topbar-item" (click)="clearFilter()">
<i
class="pi pi-filter-slash"
pTooltip="Clear applied filters"
tooltipPosition="top">
</i>
</a>
}
<div>
<a
@@ -38,7 +50,7 @@
(click)="sizeOverlay.toggle($event)"
pTooltip="Adjust grid item scale"
tooltipPosition="top"
>
>
<i class="pi pi-th-large"></i>
</a>
@@ -71,7 +83,9 @@
<ng-template pTemplate="item" let-item>
<div class="flex justify-between items-center px-4 py-2 cursor-pointer" (click)="sortBooks(item.field)">
<span>{{ item.label }}</span>
<i *ngIf="item.icon" [class]="item.icon"></i>
@if (item.icon) {
<i [class]="item.icon"></i>
}
</div>
</ng-template>
</p-menu>
@@ -96,16 +110,17 @@
[(ngModel)]="bookTitle"
(ngModelChange)="onSearchTermChange($event)"
class="search-input"
/>
<p-button
*ngIf="bookTitle"
icon="pi pi-times"
[text]="true"
size="small"
[rounded]="true"
class="absolute right-2 top-1/2 -translate-y-1/2"
(click)="clearSearch()">
</p-button>
/>
@if (bookTitle) {
<p-button
icon="pi pi-times"
[text]="true"
size="small"
[rounded]="true"
class="absolute right-2 top-1/2 -translate-y-1/2"
(click)="clearSearch()">
</p-button>
}
</div>
</p-fluid>
@@ -121,100 +136,118 @@
</div>
</div>
<div *ngIf="bookState$ | async as bookState">
<div *ngIf="!bookState?.loaded && !bookState?.error">
<p-progressSpinner></p-progressSpinner>
</div>
<div class="relative">
<div class="no-books-container" *ngIf="bookState?.error">
<p class="no-books-text">
{{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
</p>
</div>
<div class="no-books-container" *ngIf="!bookState?.error && bookState?.loaded && bookState?.books?.length === 0">
<p class="no-books-text">
This collection has no books!
</p>
</div>
<div class="book-card-container" *ngIf="bookState?.books as books">
<app-book-table *ngIf="currentViewMode === 'table' && books.length > 0" [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="selectedSort!"></app-book-table>
<virtual-scroller *ngIf="currentViewMode === 'grid'" class="virtual-scroller" #scroll [items]="books">
<div
class="grid"
#container
[ngStyle]="{'grid-template-columns': 'repeat(auto-fit, minmax(' + gridColumnMinWidth + ', 1fr))'}">
<div
class="virtual-scroller-item"
*ngFor="let book of scroll.viewPortItems"
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
<app-book-card
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
@if (bookState$ | async; as bookState) {
<div>
@if (!bookState?.loaded && !bookState?.error) {
<div>
<p-progressSpinner></p-progressSpinner>
</div>
}
<div class="relative">
@if (bookState?.error) {
<div class="no-books-container">
<p class="no-books-text">
{{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
</p>
</div>
}
@if (!bookState?.error && bookState?.loaded && bookState?.books?.length === 0) {
<div class="no-books-container">
<p class="no-books-text">
This collection has no books!
</p>
</div>
}
@if (bookState?.books; as books) {
<div class="book-card-container">
@if (currentViewMode === 'table' && books.length > 0) {
<app-book-table [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="selectedSort!"></app-book-table>
}
@if (currentViewMode === 'grid') {
<virtual-scroller class="virtual-scroller" #scroll [items]="books">
<div
class="grid"
#container
[ngStyle]="{'grid-template-columns': 'repeat(auto-fit, minmax(' + gridColumnMinWidth + ', 1fr))'}">
@for (book of scroll.viewPortItems; track book) {
<div
class="virtual-scroller-item"
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
<app-book-card
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
</div>
}
</div>
</virtual-scroller>
}
</div>
}
@if (selectedBooks.size > 0) {
<div class="book-browser-footer bg-[var(--card-background)] bg-opacity-10" [@slideInOut]>
<div class="flex justify-between gap-8">
@if (entityType$ | async; as entityType) {
@if (entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS || entityType === EntityType.UNSHELVED) {
<p-button
icon="pi pi-bookmark-fill"
outlined="true"
severity="info"
(onClick)="openShelfAssigner()"
pTooltip="Assign to shelf"
tooltipPosition="top">
</p-button>
}
@if (entityType === EntityType.SHELF) {
<p-button
icon="pi pi-bookmark"
outlined="true"
severity="info"
(click)="unshelfBooks()"
pTooltip="Remove from shelf"
tooltipPosition="top">
</p-button>
}
@if (userService.userState$ | async; as userData) {
<div>
@if (userData.permissions.canEditMetadata) {
<p-button
icon="pi pi-database"
outlined="true"
severity="info"
(click)="updateMetadata()"
pTooltip="Update metadata"
tooltipPosition="top">
</p-button>
}
</div>
}
<p-button
outlined="true"
icon="pi pi-lock"
severity="info"
(click)="lockUnlockMetadata()"
pTooltip="Lock/Unlock metadata"
tooltipPosition="top">
</p-button>
<p-button
outlined="true"
icon="pi pi-times"
severity="warn"
(click)="deselectAllBooks()"
pTooltip="Deselect all books"
tooltipPosition="top">
</p-button>
}
</div>
</div>
</virtual-scroller>
</div>
<div class="book-browser-footer bg-[var(--card-background)] bg-opacity-10" *ngIf="selectedBooks.size > 0" [@slideInOut]>
<div class="flex justify-between gap-8">
<ng-container *ngIf="entityType$ | async as entityType">
<p-button
*ngIf="entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS || entityType === EntityType.UNSHELVED"
icon="pi pi-bookmark-fill"
outlined="true"
severity="info"
(onClick)="openShelfAssigner()"
pTooltip="Assign to shelf"
tooltipPosition="top">
</p-button>
<p-button
*ngIf="entityType === EntityType.SHELF"
icon="pi pi-bookmark"
outlined="true"
severity="info"
(click)="unshelfBooks()"
pTooltip="Remove from shelf"
tooltipPosition="top">
</p-button>
<div *ngIf="userService.userState$ | async as userData">
<p-button
*ngIf="userData.permissions.canEditMetadata"
icon="pi pi-database"
outlined="true"
severity="info"
(click)="updateMetadata()"
pTooltip="Update metadata"
tooltipPosition="top">
</p-button>
</div>
<p-button
outlined="true"
icon="pi pi-lock"
severity="info"
(click)="lockUnlockMetadata()"
pTooltip="Lock/Unlock metadata"
tooltipPosition="top">
</p-button>
<p-button
outlined="true"
icon="pi pi-times"
severity="warn"
(click)="deselectAllBooks()"
pTooltip="Deselect all books"
tooltipPosition="top">
</p-button>
</ng-container>
</div>
}
</div>
</div>
</div>
}
</div>
<app-book-filter [entity$]="entity$" [entityType$]="entityType$" [resetFilter$]="resetFilterSubject"></app-book-filter>
@@ -20,7 +20,7 @@ import {animate, state, style, transition, trigger} from '@angular/animations';
import {MetadataFetchOptionsComponent} from '../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
import {Button} from 'primeng/button';
import {AsyncPipe, NgClass, NgForOf, NgIf, NgStyle} from '@angular/common';
import { AsyncPipe, NgClass, NgStyle } from '@angular/common';
import {VirtualScrollerModule} from '@iharbeck/ngx-virtual-scroller';
import {BookCardComponent} from './book-card/book-card.component';
import {ProgressSpinner} from 'primeng/progressspinner';
@@ -65,7 +65,7 @@ const SORT_DIRECTION = {
standalone: true,
templateUrl: './book-browser.component.html',
styleUrls: ['./book-browser.component.scss'],
imports: [Button, NgIf, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, NgForOf, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, Slider, Popover],
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, Slider, Popover],
animations: [
trigger('slideInOut', [
state('void', style({
@@ -1,7 +1,7 @@
<div class="book-card"
[class.selected]="isSelected"
(mouseover)="isHovered = true"
(mouseout)="isHovered = false">
[class.selected]="isSelected"
(mouseover)="isHovered = true"
(mouseout)="isHovered = false">
<div class="cover-container" [ngClass]="{ 'shimmer': !isImageLoaded, 'center-info-btn': readButtonHidden }">
<img
@@ -15,22 +15,24 @@
<p-button [rounded]="true" icon="pi pi-info" class="info-btn" (click)="openBookInfo(book)"></p-button>
<p-button [hidden]="readButtonHidden" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
<p-checkbox
*ngIf="isCheckboxEnabled"
[(ngModel)]="isSelected"
binary="true"
id="select-checkbox-{{book.id}}"
class="select-checkbox"
(ngModelChange)="toggleSelection(isSelected || false)">
</p-checkbox>
@if (isCheckboxEnabled) {
<p-checkbox
[(ngModel)]="isSelected"
binary="true"
id="select-checkbox-{{book.id}}"
class="select-checkbox"
(ngModelChange)="toggleSelection(isSelected || false)">
</p-checkbox>
}
<p-progressBar
*ngIf="progressPercentage !== null"
[value]="progressPercentage"
[showValue]="false"
class="cover-progress-bar"
[ngClass]="{ 'progress-complete': progressPercentage === 100, 'progress-incomplete': progressPercentage < 100 }">
</p-progressBar>
@if (progressPercentage !== null) {
<p-progressBar
[value]="progressPercentage"
[showValue]="false"
class="cover-progress-bar"
[ngClass]="{ 'progress-complete': progressPercentage === 100, 'progress-incomplete': progressPercentage < 100 }">
</p-progressBar>
}
</div>
<div [hidden]="bottomBarHidden">
@@ -12,7 +12,7 @@ import {MetadataFetchOptionsComponent} from '../../../metadata/metadata-options-
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
import {MetadataRefreshRequest} from '../../../metadata/model/request/metadata-refresh-request.model';
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
import {NgClass, NgIf} from '@angular/common';
import { NgClass } from '@angular/common';
import {UserService} from '../../../../settings/user-management/user.service';
import {filter} from 'rxjs';
import {EmailService} from '../../../../settings/email/email.service';
@@ -25,7 +25,7 @@ import {ProgressBar} from 'primeng/progressbar';
selector: 'app-book-card',
templateUrl: './book-card.component.html',
styleUrls: ['./book-card.component.scss'],
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgIf, NgClass, TieredMenu, ProgressBar],
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgClass, TieredMenu, ProgressBar],
standalone: true
})
export class BookCardComponent implements OnInit {
@@ -1,49 +1,59 @@
<div *ngIf="showFilters" class="w-[225px] ml-4 h-[calc(100vh-6.5rem)] rounded-xl bg-[var(--card-background)] overflow-hidden">
<div class="flex items-center justify-between px-4 py-4">
<span class="text font-semibold">Filter Mode</span>
<p-selectButton
[options]="filterModeOptions"
[(ngModel)]="selectedFilterMode"
optionLabel="label"
optionValue="value"
class="text-sm"
allowEmpty="false"
@if (showFilters) {
<div class="w-[225px] ml-4 h-[calc(100vh-6.5rem)] rounded-xl bg-[var(--card-background)] overflow-hidden">
<div class="flex items-center justify-between px-4 py-4">
<span class="text font-semibold">Filter Mode</span>
<p-selectButton
[options]="filterModeOptions"
[(ngModel)]="selectedFilterMode"
optionLabel="label"
optionValue="value"
class="text-sm"
allowEmpty="false"
styleClass="h-8"></p-selectButton>
</div>
<p-accordion [value]="0">
<p-accordion-panel *ngFor="let filterType of filterTypes; let i = index" [value]="i">
<p-accordion-header>
<span class="inline-flex items-center gap-1">
{{ filterLabels[filterType] || (filterType | titlecase) }}
<span *ngIf="activeFilters[filterType]?.length" class="text-sm text-[var(--primary-color)]">
({{ activeFilters[filterType].length }})
</span>
</span>
</p-accordion-header>
<p-accordion-content class="h-[31rem] !overflow-y-auto">
<div *ngIf="filterStreams[filterType] | async as filters">
<div *ngFor="let filter of filters">
<div
class="cursor-pointer transition-colors duration-200 ease-in-out pb-1 flex items-center gap-2"
</div>
<p-accordion [value]="0">
@for (filterType of filterTypes; track filterType; let i = $index) {
<p-accordion-panel [value]="i">
<p-accordion-header>
<span class="inline-flex items-center gap-1">
{{ filterLabels[filterType] || (filterType | titlecase) }}
@if (activeFilters[filterType]?.length) {
<span class="text-sm text-[var(--primary-color)]">
({{ activeFilters[filterType].length }})
</span>
}
</span>
</p-accordion-header>
<p-accordion-content class="h-[31rem] !overflow-y-auto">
@if (filterStreams[filterType] | async; as filters) {
<div>
@for (filter of filters; track filter) {
<div>
<div
class="cursor-pointer transition-colors duration-200 ease-in-out pb-1 flex items-center gap-2"
[ngClass]="{
'text-[var(--primary-color)]':
activeFilters[filterType]?.includes(filter.value?.id || filter.value)
}"
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
<p-badge [value]="filter.bookCount"></p-badge>
<ng-container *ngIf="filterType === 'amazonRating'; else defaultLabel">
<ng-container *ngIf="filterType === 'amazonRating'; else defaultLabel">
<span>{{ filter.value.name }}</span>
</ng-container>
</ng-container>
<ng-template #defaultLabel>
{{ filter.value.name || filter.value }}
</ng-template>
</div>
</div>
</div>
</p-accordion-content>
</p-accordion-panel>
</p-accordion>
</div>
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
<p-badge [value]="filter.bookCount"></p-badge>
@if (filterType === 'amazonRating') {
@if (filterType === 'amazonRating') {
<span>{{ filter.value.name }}</span>
} @else {
{{ filter.value.name || filter.value }}
}
} @else {
{{ filter.value.name || filter.value }}
}
</div>
</div>
}
</div>
}
</p-accordion-content>
</p-accordion-panel>
}
</p-accordion>
</div>
}
@@ -7,7 +7,7 @@ import {Shelf} from '../../../model/shelf.model';
import {EntityType} from '../book-browser.component';
import {Book} from '../../../model/book.model';
import {Accordion, AccordionContent, AccordionHeader, AccordionPanel} from 'primeng/accordion';
import {AsyncPipe, NgClass, NgForOf, NgIf, TitleCasePipe} from '@angular/common';
import { AsyncPipe, NgClass, TitleCasePipe } from '@angular/common';
import {Badge} from 'primeng/badge';
import {FormsModule} from '@angular/forms';
import {SelectButton} from 'primeng/selectbutton';
@@ -110,15 +110,13 @@ function getPageCountRangeFilters(pageCount?: number) {
AccordionPanel,
AccordionHeader,
AccordionContent,
NgIf,
NgForOf,
NgClass,
Badge,
AsyncPipe,
TitleCasePipe,
FormsModule,
SelectButton
]
]
})
export class BookFilterComponent implements OnInit {
@Output() filterSelected = new EventEmitter<Record<string, any> | null>();
@@ -39,85 +39,93 @@
</tr>
</ng-template>
<ng-template #body let-book>
<tr *ngIf="book.metadata as metadata" style="height:46px">
<td class="max-w-16">
<p-tableCheckbox [value]="book"></p-tableCheckbox>
</td>
<td class="text-center">
<p-button
[icon]="isMetadataFullyLocked(metadata) ? 'pi pi-lock' : 'pi pi-lock-open'"
[severity]="isMetadataFullyLocked(metadata) ? 'danger' : 'success'"
[text]="true"
[title]="isMetadataFullyLocked(metadata) ? 'Locked' : 'Unlocked'"
size="small"
[style]="{ width: '1.5rem', height: '1.5rem', padding: '0', fontSize: '0.75rem' }"
(click)="toggleMetadataLock(metadata)">
</p-button>
</td>
<td (click)="openMetadataCenter(book.id)">
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)" alt="Book Cover" class="size-7"/>
</td>
<td class="min-w-[18rem] max-w-[25rem] overflow-hidden truncate" [title]="metadata.title">{{ metadata.title }}</td>
<td class="min-w-[10rem] max-w-[15rem] overflow-hidden truncate" [title]="getAuthorNames(metadata.authors)">{{ getAuthorNames(metadata.authors) }}</td>
<td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.publisher">{{ metadata.publisher }}</td>
<td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.seriesName">{{ metadata.seriesName }}</td>
<td class="min-w-[1rem] max-w-[1rem] overflow-hidden truncate" [title]="metadata.seriesNumber">{{ metadata.seriesNumber }}</td>
<td class="min-w-[12rem] max-w-[18rem] overflow-hidden truncate" [title]="getGenres(metadata.categories)">{{ getGenres(metadata.categories) }}</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate">
{{ metadata.publishedDate ? (metadata.publishedDate | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
{{ book.lastReadTime ? (book.lastReadTime | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
{{ book.addedOn ? (book.addedOn | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[7rem] max-w-[9rem] overflow-hidden truncate"
@if (book.metadata; as metadata) {
<tr style="height:46px">
<td class="max-w-16">
<p-tableCheckbox [value]="book"></p-tableCheckbox>
</td>
<td class="text-center">
<p-button
[icon]="isMetadataFullyLocked(metadata) ? 'pi pi-lock' : 'pi pi-lock-open'"
[severity]="isMetadataFullyLocked(metadata) ? 'danger' : 'success'"
[text]="true"
[title]="isMetadataFullyLocked(metadata) ? 'Locked' : 'Unlocked'"
size="small"
[style]="{ width: '1.5rem', height: '1.5rem', padding: '0', fontSize: '0.75rem' }"
(click)="toggleMetadataLock(metadata)">
</p-button>
</td>
<td (click)="openMetadataCenter(book.id)">
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)" alt="Book Cover" class="size-7"/>
</td>
<td class="min-w-[18rem] max-w-[25rem] overflow-hidden truncate" [title]="metadata.title">{{ metadata.title }}</td>
<td class="min-w-[10rem] max-w-[15rem] overflow-hidden truncate" [title]="getAuthorNames(metadata.authors)">{{ getAuthorNames(metadata.authors) }}</td>
<td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.publisher">{{ metadata.publisher }}</td>
<td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.seriesName">{{ metadata.seriesName }}</td>
<td class="min-w-[1rem] max-w-[1rem] overflow-hidden truncate" [title]="metadata.seriesNumber">{{ metadata.seriesNumber }}</td>
<td class="min-w-[12rem] max-w-[18rem] overflow-hidden truncate" [title]="getGenres(metadata.categories)">{{ getGenres(metadata.categories) }}</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate">
{{ metadata.publishedDate ? (metadata.publishedDate | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
{{ book.lastReadTime ? (book.lastReadTime | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
{{ book.addedOn ? (book.addedOn | date: 'dd-MMM-yyyy') : '' }}
</td>
<td class="min-w-[7rem] max-w-[9rem] overflow-hidden truncate"
[title]="book.fileSizeKb + ' KB'">
{{ formatFileSize(book.fileSizeKb) }}
</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.language }}</td>
<td class="min-w-[4rem] max-w-[5rem] overflow-hidden truncate">{{ metadata.pageCount }}</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.amazonRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
</p-rating>
<span *ngIf="metadata.amazonRating != null">({{ metadata.amazonRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.amazonReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.goodreadsRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
</p-rating>
<span *ngIf="metadata.goodreadsRating != null">({{ metadata.goodreadsRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.goodreadsReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.hardcoverRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
</p-rating>
<span *ngIf="metadata.hardcoverRating != null">({{ metadata.hardcoverRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.hardcoverReviewCount }}</td>
</tr>
{{ formatFileSize(book.fileSizeKb) }}
</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.language }}</td>
<td class="min-w-[4rem] max-w-[5rem] overflow-hidden truncate">{{ metadata.pageCount }}</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.amazonRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
</p-rating>
@if (metadata.amazonRating != null) {
<span>({{ metadata.amazonRating?.toFixed(1) }})</span>
}
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.amazonReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.goodreadsRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
</p-rating>
@if (metadata.goodreadsRating != null) {
<span>({{ metadata.goodreadsRating?.toFixed(1) }})</span>
}
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.goodreadsReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.hardcoverRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
</p-rating>
@if (metadata.hardcoverRating != null) {
<span>({{ metadata.hardcoverRating?.toFixed(1) }})</span>
}
</span>
</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.hardcoverReviewCount }}</td>
</tr>
}
</ng-template>
</p-table>
@@ -1,6 +1,6 @@
import {Component, EventEmitter, inject, Input, OnChanges, Output} from '@angular/core';
import {TableModule} from 'primeng/table';
import {DatePipe, NgIf} from '@angular/common';
import { DatePipe } from '@angular/common';
import {Rating} from 'primeng/rating';
import {FormsModule} from '@angular/forms';
import {Book, BookMetadata} from '../../../model/book.model';
@@ -17,12 +17,11 @@ import {Router} from '@angular/router';
templateUrl: './book-table.component.html',
imports: [
TableModule,
NgIf,
Rating,
FormsModule,
Button,
DatePipe
],
],
styleUrl: './book-table.component.scss'
})
export class BookTableComponent implements OnChanges {
@@ -1,15 +1,17 @@
<div class="p-4">
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-x-24 gap-y-4">
<div *ngFor="let field of lockableFields" class="flex items-center justify-between">
<label class="capitalize">{{ fieldLabels[field] || field }}</label>
<p-button
[outlined]="true"
[label]="getLockLabel(field)"
[icon]="getLockIcon(field)"
[severity]="fieldLocks[field] === true ? 'danger' : fieldLocks[field] === false ? 'success' : 'secondary'"
(click)="cycleLockState(field)"
></p-button>
</div>
@for (field of lockableFields; track field) {
<div class="flex items-center justify-between">
<label class="capitalize">{{ fieldLabels[field] || field }}</label>
<p-button
[outlined]="true"
[label]="getLockLabel(field)"
[icon]="getLockIcon(field)"
[severity]="fieldLocks[field] === true ? 'danger' : fieldLocks[field] === false ? 'success' : 'secondary'"
(click)="cycleLockState(field)"
></p-button>
</div>
}
</div>
</div>
@@ -1,7 +1,7 @@
import {Component, inject, OnInit} from '@angular/core';
import {Button} from 'primeng/button';
import {FormsModule} from '@angular/forms';
import {NgForOf} from '@angular/common';
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {MessageService} from 'primeng/api';
import {BookService} from '../../../service/book.service';
@@ -13,9 +13,8 @@ import {Divider} from 'primeng/divider';
imports: [
Button,
FormsModule,
NgForOf,
Divider
],
],
templateUrl: './lock-unlock-metadata-dialog.component.html',
styleUrl: './lock-unlock-metadata-dialog.component.scss'
})