Merge pull request #675 from adityachandelgit/develop

Merge Develop into Master for release
This commit is contained in:
Aditya Chandel
2025-07-09 22:47:54 -06:00
committed by GitHub
27 changed files with 1148 additions and 517 deletions
+194
View File
@@ -0,0 +1,194 @@
# Contributing to Booklore
🎉 Thanks for your interest in contributing to **Booklore**, a modern, self-hostable digital library system for books and comics. Whether you're fixing bugs, adding features, improving documentation, or asking questions - your contribution matters!
---
## 📚 Overview
**Booklore** is a self-hostable platform designed to manage and read books and comics. It includes:
- **Frontend**: Angular 20, TypeScript, PrimeNG 19, Tailwind CSS
- **Backend**: Java 21, Spring Boot 3.5
- **Authentication**: Local JWT + optional OIDC (e.g. Authentik)
- **Database**: MariaDB
- **Deployment**: Docker-compatible, reverse proxy-ready
---
## 📦 Project Structure
```
booklore/
├── booklore-ui/ # Angular frontend
├── booklore-api/ # Spring Boot backend
├── assets/ # Shared assets
```
---
## 🚀 Getting Started
1. **Fork the repository** on GitHub
2. **Clone your fork** locally:
```bash
git clone https://github.com/adityachandelgit/BookLore.git
cd booklore
```
---
## 🧱 Local Development Setup
### 1. Prerequisites
- **Java 21+**
- **Node.js 18+**
- **MariaDB**
- **Docker and Docker Compose**
---
### 2. Frontend Setup
To set up the Angular frontend:
```bash
cd booklore-ui
npm install
ng serve
```
The dev server runs at `http://localhost:4200/`.
> ⚠️ Use `--force` with `npm install` only as a last resort for dependency conflicts.
---
### 3. Backend Setup
#### a. Configure `application-dev.yml`
Create or edit `booklore-api/src/main/resources/application-dev.yml`:
```yaml
app:
path-book: '/path/to/booklore/books' # Directory for book/comic files
path-config: '/path/to/booklore/config' # Directory for thumbnails, metadata, etc.
spring:
datasource:
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:mariadb://localhost:3333/booklore?createDatabaseIfNotExist=true
username: root
password: Password123
```
> 🔧 Replace `/path/to/...` with actual local paths
#### b. Run the Backend
```bash
cd booklore-api
./gradlew bootRun
```
---
## 🧪 Testing
### Frontend
Run unit tests using:
```bash
cd booklore-ui
ng test
```
### Backend
Run backend tests using:
```bash
cd booklore-api
./gradlew test
```
---
## 🛠️ Contributing Guidelines
### 💡 Bug Reports
- Check [existing issues](https://github.com/adityachandelgit/BookLore/issues)
- Include reproduction steps, expected vs. actual behavior, and logs if possible
### 🌟 Feature Requests
- Clearly explain the use case and benefit
- Label the issue with `feature`
### 🔃 Code Contributions
- Create a feature branch:
```bash
git checkout -b feat/my-feature
```
- For bug fixes:
```bash
git checkout -b fix/my-fix
```
- Follow code conventions, keep PRs focused and scoped
- Link the relevant issue in your PR
- Test your changes
- Target the `master` branch when opening PRs
---
## 🧼 Code Style & Conventions
- **Angular**: Follow the [official style guide](https://angular.io/guide/styleguide)
- **Java**: Use modern features (Java 17+), clean structure
- **Format**: Use linters and Prettier where applicable
- **UI**: Use Tailwind CSS and PrimeNG components consistently
---
## 📝 Commit Message Format
Follow [Conventional Commits](https://www.conventionalcommits.org/):
Examples:
- `feat: add column visibility setting to book table`
- `fix: correct metadata locking behavior`
- `docs: improve contributing instructions`
---
## 🙏 Code of Conduct
Please be respectful, inclusive, and collaborative. Harassment, abuse, or discrimination of any kind will not be tolerated.
---
## 💬 Community & Support
- Use [GitHub Discussions](https://github.com/adityachandelgit/BookLore/discussions)
- Discord server: https://discord.gg/Ee5hd458Uz
---
## 📄 License
Booklore is open-source and licensed under the MIT License. See [`LICENSE`](./LICENSE) for details.
---
Happy contributing!
@@ -124,4 +124,11 @@ public class BookController {
bookService.updateReadStatus(bookId, request.status()); bookService.updateReadStatus(bookId, request.status());
return ResponseEntity.noContent().build(); return ResponseEntity.noContent().build();
} }
@PostMapping("/{bookId}/reset-progress")
@CheckBookAccess(bookIdParam = "bookId")
public ResponseEntity<Book> resetProgress(@PathVariable long bookId) {
Book book = bookService.resetProgress(bookId);
return ResponseEntity.ok(book);
}
} }
@@ -6,12 +6,14 @@ import com.adityachandel.booklore.model.dto.settings.SidebarSortOption;
import com.adityachandel.booklore.model.dto.settings.UserSettingKey; import com.adityachandel.booklore.model.dto.settings.UserSettingKey;
import com.adityachandel.booklore.model.entity.BookLoreUserEntity; import com.adityachandel.booklore.model.entity.BookLoreUserEntity;
import com.adityachandel.booklore.model.entity.UserSettingEntity; import com.adityachandel.booklore.model.entity.UserSettingEntity;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
@@ -58,6 +60,10 @@ public class BookLoreUserTransformer {
case SIDEBAR_LIBRARY_SORTING -> userSettings.setSidebarLibrarySorting(objectMapper.readValue(value, SidebarSortOption.class)); case SIDEBAR_LIBRARY_SORTING -> userSettings.setSidebarLibrarySorting(objectMapper.readValue(value, SidebarSortOption.class));
case SIDEBAR_SHELF_SORTING -> userSettings.setSidebarShelfSorting(objectMapper.readValue(value, SidebarSortOption.class)); case SIDEBAR_SHELF_SORTING -> userSettings.setSidebarShelfSorting(objectMapper.readValue(value, SidebarSortOption.class));
case ENTITY_VIEW_PREFERENCES -> userSettings.setEntityViewPreferences(objectMapper.readValue(value, BookLoreUser.UserSettings.EntityViewPreferences.class)); case ENTITY_VIEW_PREFERENCES -> userSettings.setEntityViewPreferences(objectMapper.readValue(value, BookLoreUser.UserSettings.EntityViewPreferences.class));
case TABLE_COLUMN_PREFERENCE -> userSettings.setTableColumnPreference(
objectMapper.readValue(value, new TypeReference<>() {
})
);
} }
} else { } else {
switch (settingKey) { switch (settingKey) {
@@ -42,9 +42,20 @@ public class BookLoreUser {
public SidebarSortOption sidebarLibrarySorting; public SidebarSortOption sidebarLibrarySorting;
public SidebarSortOption sidebarShelfSorting; public SidebarSortOption sidebarShelfSorting;
public EntityViewPreferences entityViewPreferences; public EntityViewPreferences entityViewPreferences;
public List<TableColumnPreference> tableColumnPreference;
public String filterSortingMode; public String filterSortingMode;
public String metadataCenterViewMode; public String metadataCenterViewMode;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class TableColumnPreference {
private String field;
private Boolean visible;
private Integer order;
}
@Data @Data
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@@ -12,6 +12,7 @@ public enum UserSettingKey {
SIDEBAR_LIBRARY_SORTING("sidebarLibrarySorting", true), SIDEBAR_LIBRARY_SORTING("sidebarLibrarySorting", true),
SIDEBAR_SHELF_SORTING("sidebarShelfSorting", true), SIDEBAR_SHELF_SORTING("sidebarShelfSorting", true),
ENTITY_VIEW_PREFERENCES("entityViewPreferences", true), ENTITY_VIEW_PREFERENCES("entityViewPreferences", true),
TABLE_COLUMN_PREFERENCE("tableColumnPreference", true),
FILTER_SORTING_MODE("filterSortingMode", false), FILTER_SORTING_MODE("filterSortingMode", false),
METADATA_CENTER_VIEW_MODE("metadataCenterViewMode", false); METADATA_CENTER_VIEW_MODE("metadataCenterViewMode", false);
@@ -10,7 +10,6 @@ import lombok.*;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.Set; import java.util.Set;
@Entity @Entity
@@ -41,10 +40,6 @@ public class BookEntity {
@Column(name = "metadata_match_score") @Column(name = "metadata_match_score")
private Float metadataMatchScore; private Float metadataMatchScore;
@Enumerated(EnumType.STRING)
@Column(name = "read_status")
private ReadStatus readStatus;
@OneToOne(mappedBy = "book", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) @OneToOne(mappedBy = "book", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private BookMetadataEntity metadata; private BookMetadataEntity metadata;
@@ -1,5 +1,6 @@
package com.adityachandel.booklore.model.entity; package com.adityachandel.booklore.model.entity;
import com.adityachandel.booklore.model.enums.ReadStatus;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.*; import lombok.*;
@@ -46,4 +47,8 @@ public class UserBookProgressEntity {
@Column(name = "cbx_progress_percent") @Column(name = "cbx_progress_percent")
private Float cbxProgressPercent; private Float cbxProgressPercent;
@Enumerated(EnumType.STRING)
@Column(name = "read_status")
private ReadStatus readStatus;
} }
@@ -10,10 +10,8 @@ import com.adityachandel.booklore.model.entity.*;
import com.adityachandel.booklore.model.enums.BookFileType; import com.adityachandel.booklore.model.enums.BookFileType;
import com.adityachandel.booklore.model.enums.ReadStatus; import com.adityachandel.booklore.model.enums.ReadStatus;
import com.adityachandel.booklore.repository.*; import com.adityachandel.booklore.repository.*;
import com.adityachandel.booklore.service.appsettings.AppSettingService;
import com.adityachandel.booklore.util.FileService; import com.adityachandel.booklore.util.FileService;
import com.adityachandel.booklore.util.FileUtils; import com.adityachandel.booklore.util.FileUtils;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.EnumUtils;
@@ -270,6 +268,7 @@ public class BookService {
.build()); .build());
} }
book.setFilePath(FileUtils.getBookFullPath(bookEntity)); book.setFilePath(FileUtils.getBookFullPath(bookEntity));
book.setReadStatus(String.valueOf(userProgress.getReadStatus()));
if (!withDescription) { if (!withDescription) {
book.getMetadata().setDescription(null); book.getMetadata().setDescription(null);
@@ -278,6 +277,24 @@ public class BookService {
return book; return book;
} }
public Book resetProgress(long bookId) {
BookLoreUser user = authenticationService.getAuthenticatedUser();
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
UserBookProgressEntity progress = userBookProgressRepository.findByUserIdAndBookId(user.getId(), bookId).orElse(new UserBookProgressEntity());
progress.setBook(bookEntity);
progress.setReadStatus(null);
progress.setLastReadTime(null);
progress.setPdfProgress(null);
progress.setPdfProgressPercent(null);
progress.setEpubProgress(null);
progress.setEpubProgressPercent(null);
progress.setCbxProgress(null);
progress.setCbxProgressPercent(null);
userBookProgressRepository.save(progress);
return bookMapper.toBook(bookEntity);
}
@Transactional @Transactional
public List<Book> assignShelvesToBooks(Set<Long> bookIds, Set<Long> shelfIdsToAssign, Set<Long> shelfIdsToUnassign) { public List<Book> assignShelvesToBooks(Set<Long> bookIds, Set<Long> shelfIdsToAssign, Set<Long> shelfIdsToUnassign) {
@@ -336,6 +353,18 @@ public class BookService {
userBookProgressRepository.save(userBookProgress); userBookProgressRepository.save(userBookProgress);
} }
@Transactional
public void updateReadStatus(Long bookId, String status) {
BookEntity book = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
BookLoreUser user = authenticationService.getAuthenticatedUser();
UserBookProgressEntity userBookProgress = userBookProgressRepository.findByUserIdAndBookId(user.getId(), book.getId()).orElse(new UserBookProgressEntity());
userBookProgress.setUser(userRepository.findById(user.getId()).orElseThrow(() -> new UsernameNotFoundException("User not found")));
userBookProgress.setBook(book);
ReadStatus readStatus = EnumUtils.getEnumIgnoreCase(ReadStatus.class, status);
userBookProgress.setReadStatus(readStatus);
userBookProgressRepository.save(userBookProgress);
}
public ResponseEntity<Resource> downloadBook(Long bookId) { public ResponseEntity<Resource> downloadBook(Long bookId) {
try { try {
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId)); BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
@@ -455,11 +484,4 @@ public class BookService {
} }
} }
} }
public void updateReadStatus(long bookId, @NotBlank String status) {
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
ReadStatus readStatus = EnumUtils.getEnumIgnoreCase(ReadStatus.class, status);
bookEntity.setReadStatus(readStatus);
bookRepository.save(bookEntity);
}
} }
@@ -29,6 +29,7 @@ public class DefaultUserSettingsProvider {
defaultSettings.put(UserSettingKey.SIDEBAR_LIBRARY_SORTING, this::buildDefaultSidebarLibrarySorting); defaultSettings.put(UserSettingKey.SIDEBAR_LIBRARY_SORTING, this::buildDefaultSidebarLibrarySorting);
defaultSettings.put(UserSettingKey.SIDEBAR_SHELF_SORTING, this::buildDefaultSidebarShelfSorting); defaultSettings.put(UserSettingKey.SIDEBAR_SHELF_SORTING, this::buildDefaultSidebarShelfSorting);
defaultSettings.put(UserSettingKey.ENTITY_VIEW_PREFERENCES, this::buildDefaultEntityViewPreferences); defaultSettings.put(UserSettingKey.ENTITY_VIEW_PREFERENCES, this::buildDefaultEntityViewPreferences);
defaultSettings.put(UserSettingKey.TABLE_COLUMN_PREFERENCE, () -> null);
defaultSettings.put(UserSettingKey.FILTER_SORTING_MODE, () -> "count"); defaultSettings.put(UserSettingKey.FILTER_SORTING_MODE, () -> "count");
defaultSettings.put(UserSettingKey.METADATA_CENTER_VIEW_MODE, () -> "route"); defaultSettings.put(UserSettingKey.METADATA_CENTER_VIEW_MODE, () -> "route");
} }
@@ -0,0 +1,2 @@
ALTER TABLE user_book_progress
ADD COLUMN read_status VARCHAR(20);
@@ -38,7 +38,7 @@
} }
</div> </div>
<div class="flex flex-wrap items-center gap-4 flex-shrink-0"> <div class="flex flex-wrap items-center gap-4 flex-shrink-0">
<div class="flex flex-wrap items-center gap-4"> <div class="flex flex-wrap items-center gap-4 md:gap-6">
@if (isFilterActive) { @if (isFilterActive) {
<a class="topbar-items topbar-item" (click)="clearFilter()"> <a class="topbar-items topbar-item" (click)="clearFilter()">
<i <i
@@ -48,6 +48,42 @@
</i> </i>
</a> </a>
} }
@if (currentViewMode === 'table') {
<div>
<a class="topbar-items topbar-item" (click)="columnPopover.toggle($event)">
<i
class="pi pi-eye"
pTooltip="Visible columns"
tooltipPosition="top">
</i>
</a>
<p-popover #columnPopover [dismissable]="true" appendTo="body">
<div class="w-[200px]">
<p-multiSelect
optionLabel="header"
[options]="columnPreferenceService.allColumns"
[(ngModel)]="visibleColumns"
(ngModelChange)="onVisibleColumnsChange($event)"
display="chip"
placeholder="Select Columns"
[style]="{ width: '100%' }"
[filter]="true"
[showClear]="true"
></p-multiSelect>
</div>
<div class="flex items-center gap-2 pt-4 pl-1">
<p>Set as default?</p>
<p-button
label="Save"
outlined
size="small"
(click)="columnPreferenceService.saveVisibleColumns(visibleColumns)"></p-button>
</div>
</p-popover>
</div>
}
<div> <div>
<a <a
class="topbar-items topbar-item" class="topbar-items topbar-item"
@@ -82,7 +118,7 @@
</div> </div>
</div> </div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<label class="font-medium text-sm">Sidbar Filter Sort:</label> <label class="font-medium text-sm">Sidebar Filter Sort:</label>
<div class="flex gap-4 justify-start"> <div class="flex gap-4 justify-start">
<p-select <p-select
size="small" size="small"
@@ -181,7 +217,6 @@
} }
</div> </div>
<p-button <p-button
class="pr-2" class="pr-2"
icon="pi pi-chevron-right" icon="pi pi-chevron-right"
@@ -223,6 +258,7 @@
[books]="books" [books]="books"
(selectedBooksChange)="onSelectedBooksChange($event)" (selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="this.bookSorter.selectedSort!" [sortOption]="this.bookSorter.selectedSort!"
[visibleColumns]="visibleColumns"
></app-book-table> ></app-book-table>
} }
@if (currentViewMode === 'grid') { @if (currentViewMode === 'grid') {
@@ -41,6 +41,8 @@ import {Slider} from 'primeng/slider';
import {Select} from 'primeng/select'; import {Select} from 'primeng/select';
import {FilterSortPreferenceService} from './filters/filter-sorting-preferences.service'; import {FilterSortPreferenceService} from './filters/filter-sorting-preferences.service';
import {Divider} from 'primeng/divider'; import {Divider} from 'primeng/divider';
import {MultiSelect} from 'primeng/multiselect';
import {TableColumnPreferenceService} from './table-column-preference-service';
export enum EntityType { export enum EntityType {
LIBRARY = 'Library', LIBRARY = 'Library',
@@ -73,7 +75,7 @@ const SORT_DIRECTION = {
standalone: true, standalone: true,
templateUrl: './book-browser.component.html', templateUrl: './book-browser.component.html',
styleUrls: ['./book-browser.component.scss'], styleUrls: ['./book-browser.component.scss'],
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, PrimeTemplate, NgStyle, OverlayPanelModule, DropdownModule, Checkbox, Popover, Slider, Select, Divider], imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, PrimeTemplate, NgStyle, OverlayPanelModule, DropdownModule, Checkbox, Popover, Slider, Select, Divider, MultiSelect],
providers: [SeriesCollapseFilter], providers: [SeriesCollapseFilter],
animations: [ animations: [
trigger('slideInOut', [ trigger('slideInOut', [
@@ -113,6 +115,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
@ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent; @ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent;
@ViewChild(BookFilterComponent) bookFilterComponent!: BookFilterComponent; @ViewChild(BookFilterComponent) bookFilterComponent!: BookFilterComponent;
visibleColumns: { field: string; header: string }[] = [];
selectedFilter = new BehaviorSubject<Record<string, any> | null>(null); selectedFilter = new BehaviorSubject<Record<string, any> | null>(null);
selectedFilterMode = new BehaviorSubject<'and' | 'or'>('and'); selectedFilterMode = new BehaviorSubject<'and' | 'or'>('and');
protected resetFilterSubject = new Subject<void>(); protected resetFilterSubject = new Subject<void>();
@@ -122,6 +126,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
protected userService = inject(UserService); protected userService = inject(UserService);
protected coverScalePreferenceService = inject(CoverScalePreferenceService); protected coverScalePreferenceService = inject(CoverScalePreferenceService);
protected filterSortPreferenceService = inject(FilterSortPreferenceService); protected filterSortPreferenceService = inject(FilterSortPreferenceService);
protected columnPreferenceService = inject(TableColumnPreferenceService);
private activatedRoute = inject(ActivatedRoute); private activatedRoute = inject(ActivatedRoute);
private messageService = inject(MessageService); private messageService = inject(MessageService);
@@ -142,7 +147,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
currentViewMode: string | undefined = undefined; currentViewMode: string | undefined = undefined;
lastAppliedSort: SortOption | null = null; lastAppliedSort: SortOption | null = null;
filterVisibility = true;
private settingFiltersFromUrl = false; private settingFiltersFromUrl = false;
protected metadataMenuItems: MenuItem[] | undefined; protected metadataMenuItems: MenuItem[] | undefined;
currentBooks: Book[] = []; currentBooks: Book[] = [];
@@ -161,6 +165,13 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.coverScalePreferenceService.setScale(this.coverScalePreferenceService.scaleFactor); this.coverScalePreferenceService.setScale(this.coverScalePreferenceService.scaleFactor);
} }
onVisibleColumnsChange(selected: any[]) {
const allFields = this.bookTableComponent.allColumns.map(col => col.field);
this.visibleColumns = selected.sort(
(a, b) => allFields.indexOf(a.field) - allFields.indexOf(b.field)
);
}
ngOnInit(): void { ngOnInit(): void {
this.coverScalePreferenceService.scaleChange$.pipe(debounceTime(1000)).subscribe(); this.coverScalePreferenceService.scaleChange$.pipe(debounceTime(1000)).subscribe();
@@ -218,6 +229,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
} }
ngAfterViewInit() { ngAfterViewInit() {
combineLatest({ combineLatest({
paramMap: this.activatedRoute.queryParamMap, paramMap: this.activatedRoute.queryParamMap,
user: this.userService.userState$.pipe( user: this.userService.userState$.pipe(
@@ -229,7 +241,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
const viewParam = paramMap.get(QUERY_PARAMS.VIEW); const viewParam = paramMap.get(QUERY_PARAMS.VIEW);
const sortParam = paramMap.get(QUERY_PARAMS.SORT); const sortParam = paramMap.get(QUERY_PARAMS.SORT);
const directionParam = paramMap.get(QUERY_PARAMS.DIRECTION); const directionParam = paramMap.get(QUERY_PARAMS.DIRECTION);
const sidebarParam = paramMap.get(QUERY_PARAMS.SIDEBAR);
const filterParams = paramMap.get(QUERY_PARAMS.FILTER); const filterParams = paramMap.get(QUERY_PARAMS.FILTER);
const parsedFilters: Record<string, string[]> = {}; const parsedFilters: Record<string, string[]> = {};
@@ -270,6 +281,9 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
const currentEntityTypeStr = this.entityType ? this.entityType.toString().toUpperCase() : undefined; const currentEntityTypeStr = this.entityType ? this.entityType.toString().toUpperCase() : undefined;
this.coverScalePreferenceService.initScaleValue(user?.userSettings?.entityViewPreferences?.global?.coverSize); this.coverScalePreferenceService.initScaleValue(user?.userSettings?.entityViewPreferences?.global?.coverSize);
this.filterSortPreferenceService.initValue(user?.userSettings?.filterSortingMode); this.filterSortPreferenceService.initValue(user?.userSettings?.filterSortingMode);
this.columnPreferenceService.initPreferences(user.userSettings?.tableColumnPreference);
this.visibleColumns = this.columnPreferenceService.visibleColumns;
const override = this.entityViewPreferences?.overrides?.find(o => const override = this.entityViewPreferences?.overrides?.find(o =>
o.entityType?.toUpperCase() === currentEntityTypeStr && o.entityType?.toUpperCase() === currentEntityTypeStr &&
@@ -4,6 +4,12 @@
(mouseout)="isHovered = false"> (mouseout)="isHovered = false">
<div class="cover-container" [ngClass]="{ 'shimmer': !isImageLoaded, 'center-info-btn': readButtonHidden }"> <div class="cover-container" [ngClass]="{ 'shimmer': !isImageLoaded, 'center-info-btn': readButtonHidden }">
<div
class="cover-container"
[ngClass]="{
'center-info-btn': readButtonHidden,
'loaded': isImageLoaded
}">
<img <img
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)" [src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
class="book-cover" class="book-cover"
@@ -11,6 +17,7 @@
alt="Cover of {{ book.metadata?.title }}" alt="Cover of {{ book.metadata?.title }}"
loading="lazy" loading="lazy"
(load)="onImageLoad()" /> (load)="onImageLoad()" />
</div>
@if (book.metadata?.seriesNumber != null) { @if (book.metadata?.seriesNumber != null) {
<div class="series-number-overlay"> <div class="series-number-overlay">
@@ -1,6 +1,6 @@
.book-card { .book-card {
background-color: var(--card-background); background-color: var(--card-background);
border-radius: 0 0 8px 8px; border-radius: 8px 8px 8px 8px;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
transition: border 0.2s; transition: border 0.2s;
@@ -13,25 +13,18 @@
.cover-container { .cover-container {
position: relative; position: relative;
width: 100%; width: 100%;
aspect-ratio: 5/7;
background-color: var(--card-background);
border-radius: 8px 8px 0 0;
overflow: hidden; overflow: hidden;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
transition: background-color 0.3s ease;
} }
.cover-container.shimmer { .cover-container.loaded {
/*background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%); background-color: transparent;
background-size: 200% 100%;
animation: shimmer 2.5s infinite linear;*/
}
@keyframes shimmer {
0% {
background-position: -200% 0;
}
100% {
background-position: 200% 0;
}
} }
.book-cover { .book-cover {
@@ -1,5 +1,5 @@
import {Component, ElementRef, EventEmitter, inject, Input, OnDestroy, OnInit, Optional, Output, ViewChild} from '@angular/core'; import {Component, ElementRef, EventEmitter, inject, Input, OnDestroy, OnInit, Output, ViewChild} from '@angular/core';
import {Book, BookMetadata} from '../../../model/book.model'; import {Book} from '../../../model/book.model';
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {MenuModule} from 'primeng/menu'; import {MenuModule} from 'primeng/menu';
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api'; import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
@@ -20,7 +20,6 @@ import {TieredMenu} from 'primeng/tieredmenu';
import {BookSenderComponent} from '../../book-sender/book-sender.component'; import {BookSenderComponent} from '../../book-sender/book-sender.component';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {ProgressBar} from 'primeng/progressbar'; import {ProgressBar} from 'primeng/progressbar';
import {BookMetadataHostService} from '../../../../book-metadata-host-service';
import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center/book-metadata-center.component'; import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center/book-metadata-center.component';
import {takeUntil} from 'rxjs/operators'; import {takeUntil} from 'rxjs/operators';
@@ -32,9 +31,10 @@ import {takeUntil} from 'rxjs/operators';
standalone: true standalone: true
}) })
export class BookCardComponent implements OnInit, OnDestroy { export class BookCardComponent implements OnInit, OnDestroy {
@Input() index!: number;
@Output() checkboxClick = new EventEmitter<{ index: number; bookId: number; selected: boolean; shiftKey: boolean }>(); @Output() checkboxClick = new EventEmitter<{ index: number; bookId: number; selected: boolean; shiftKey: boolean }>();
@Input() index!: number;
@Input() book!: Book; @Input() book!: Book;
@Input() isCheckboxEnabled: boolean = false; @Input() isCheckboxEnabled: boolean = false;
@Input() onBookSelect?: (bookId: number, selected: boolean) => void; @Input() onBookSelect?: (bookId: number, selected: boolean) => void;
@@ -62,7 +62,6 @@ export class BookCardComponent implements OnInit, OnDestroy {
private metadataCenterViewMode: 'route' | 'dialog' = 'route'; private metadataCenterViewMode: 'route' | 'dialog' = 'route';
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();
ngOnInit(): void { ngOnInit(): void {
this.userService.userState$ this.userService.userState$
.pipe( .pipe(
@@ -312,12 +311,6 @@ export class BookCardComponent implements OnInit, OnDestroy {
return this.isAdmin() || (this.userPermissions?.canDeleteBook ?? false); return this.isAdmin() || (this.userPermissions?.canDeleteBook ?? false);
} }
isMetadataFullyLocked(metadata: BookMetadata): boolean {
const lockedKeys = Object.keys(metadata).filter(key => key.endsWith('Locked'));
if (lockedKeys.length === 0) return false;
return lockedKeys.every(key => metadata[key] === true);
}
private lastMouseEvent: MouseEvent | null = null; private lastMouseEvent: MouseEvent | null = null;
captureMouseEvent(event: MouseEvent): void { captureMouseEvent(event: MouseEvent): void {
@@ -1,9 +1,12 @@
<p-table <p-table
[value]="books" [value]="books"
[columns]="visibleColumns"
[dataKey]="'id'" [dataKey]="'id'"
[resizableColumns]="true" [resizableColumns]="true"
[metaKeySelection]="true" [reorderableColumns]="true"
columnResizeMode="expand"
[rowTrackBy]="trackByBookId" [rowTrackBy]="trackByBookId"
[metaKeySelection]="true"
showGridlines showGridlines
stripedRows stripedRows
[scrollable]="true" [scrollable]="true"
@@ -13,39 +16,26 @@
[(selection)]="selectedBooks" [(selection)]="selectedBooks"
(onHeaderCheckboxToggle)="onHeaderCheckboxToggle($event)" (onHeaderCheckboxToggle)="onHeaderCheckboxToggle($event)"
(onRowSelect)="onRowSelect($event)" (onRowSelect)="onRowSelect($event)"
(onRowUnselect)="onRowUnselect($event)"> (onRowUnselect)="onRowUnselect($event)"
<ng-template #header> >
<ng-template pTemplate="header">
<tr> <tr>
<th> <th>
<p-tableHeaderCheckbox/> <p-tableHeaderCheckbox/>
</th> </th>
<th pResizableColumn></th> <th></th>
<th class="max-w-14 min-w-14"></th> <th class="max-w-14 min-w-14"></th>
<th pResizableColumn>Title</th> @for (col of visibleColumns; track col.field) {
<th pResizableColumn>Authors</th> <th pResizableColumn>{{ col.header }}</th>
<th pResizableColumn>Publisher</th> }
<th pResizableColumn>Series</th>
<th pResizableColumn>#</th>
<th pResizableColumn>Genres</th>
<th>Published</th>
<th>Last Read</th>
<th>Added</th>
<th>File Size</th>
<th>Lang</th>
<th>Pages</th>
<th>Amazon</th>
<th>Amz #</th>
<th>Goodreads</th>
<th>GR #</th>
<th>Hardcover</th>
<th>HC #</th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template #body let-book>
<ng-template pTemplate="body" let-book>
@if (book.metadata; as metadata) { @if (book.metadata; as metadata) {
<tr style="height:46px"> <tr style="height:46px">
<td class="max-w-16"> <td>
<p-tableCheckbox [value]="book"></p-tableCheckbox> <p-tableCheckbox [value]="book"/>
</td> </td>
<td class="text-center"> <td class="text-center">
<p-button <p-button
@@ -59,75 +49,30 @@
</p-button> </p-button>
</td> </td>
<td (click)="openMetadataCenter(book.id)"> <td (click)="openMetadataCenter(book.id)">
<img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata?.coverUpdatedOn)" alt="Book Cover" class="size-7"/> <img [attr.src]="urlHelper.getCoverUrl(metadata.bookId, metadata.coverUpdatedOn)" alt="Book Cover" class="size-7"/>
</td> </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-[20rem] overflow-hidden truncate" [title]="getAuthorNames(metadata.authors)">{{ getAuthorNames(metadata.authors) }}</td> @for (col of visibleColumns; track col.field) {
<td class="min-w-[10rem] max-w-[25rem] overflow-hidden truncate" [title]="metadata.publisher">{{ metadata.publisher }}</td> @if (col.field === 'amazonRating' || col.field === 'goodreadsRating' || col.field === 'hardcoverRating') {
<td class="min-w-[10rem] max-w-[25rem] overflow-hidden truncate" [title]="metadata.seriesName">{{ metadata.seriesName }}</td>
<td class="min-w-[1rem] max-w-[4rem] 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"> <td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1"> <span class="flex items-center gap-1">
<p-rating <p-rating
[(ngModel)]="metadata.amazonRating" [(ngModel)]="metadata[col.field]"
readonly readonly
stars="5" stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)"> [style.--p-rating-icon-active-color]="getStarColor(metadata[col.field])"
</p-rating> ></p-rating>
@if (metadata.amazonRating != null) { @if (metadata[col.field] != null) {
<span>({{ metadata.amazonRating?.toFixed(1) }})</span> <span>({{ metadata[col.field]?.toFixed(1) }})</span>
} }
</span> </span>
</td> </td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right"> } @else {
{{ metadata.amazonReviewCount ?? '' }} <td [title]="getCellValue(metadata, book, col.field)" class="overflow-hidden truncate text-right min-w-[6rem] max-w-[12rem]">
{{ getCellValue(metadata, book, col.field) }}
</td> </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> </tr>
} }
</ng-template> </ng-template>
@@ -1,4 +1,4 @@
import {Component, EventEmitter, inject, Input, OnChanges, OnInit, Output} from '@angular/core'; import {Component, EventEmitter, inject, Input, OnChanges, OnDestroy, OnInit, Output} from '@angular/core';
import {TableModule} from 'primeng/table'; import {TableModule} from 'primeng/table';
import {DatePipe} from '@angular/common'; import {DatePipe} from '@angular/common';
import {Rating} from 'primeng/rating'; import {Rating} from 'primeng/rating';
@@ -10,10 +10,11 @@ import {Button} from 'primeng/button';
import {BookService} from '../../../service/book.service'; import {BookService} from '../../../service/book.service';
import {MessageService} from 'primeng/api'; import {MessageService} from 'primeng/api';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {filter} from 'rxjs'; import {filter, Subject} from 'rxjs';
import {UserService} from '../../../../settings/user-management/user.service'; import {UserService} from '../../../../settings/user-management/user.service';
import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center/book-metadata-center.component'; import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center/book-metadata-center.component';
import {DialogService} from 'primeng/dynamicdialog'; import {DialogService} from 'primeng/dynamicdialog';
import {takeUntil} from 'rxjs/operators';
@Component({ @Component({
selector: 'app-book-table', selector: 'app-book-table',
@@ -23,18 +24,19 @@ import {DialogService} from 'primeng/dynamicdialog';
TableModule, TableModule,
Rating, Rating,
FormsModule, FormsModule,
Button, Button
DatePipe
], ],
styleUrl: './book-table.component.scss' styleUrls: ['./book-table.component.scss'],
providers: [DatePipe]
}) })
export class BookTableComponent implements OnInit, OnChanges { export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
selectedBooks: Book[] = []; selectedBooks: Book[] = [];
selectedBookIds = new Set<number>(); selectedBookIds = new Set<number>();
@Output() selectedBooksChange = new EventEmitter<Set<number>>(); @Output() selectedBooksChange = new EventEmitter<Set<number>>();
@Input() books: Book[] = []; @Input() books: Book[] = [];
@Input() sortOption: SortOption | null = null; @Input() sortOption: SortOption | null = null;
@Input() visibleColumns: any[] = [];
protected urlHelper = inject(UrlHelperService); protected urlHelper = inject(UrlHelperService);
private bookService = inject(BookService); private bookService = inject(BookService);
@@ -42,18 +44,43 @@ export class BookTableComponent implements OnInit, OnChanges {
private userService = inject(UserService); private userService = inject(UserService);
private dialogService = inject(DialogService); private dialogService = inject(DialogService);
private router = inject(Router); private router = inject(Router);
private datePipe = inject(DatePipe);
private metadataCenterViewMode: 'route' | 'dialog' = 'route'; private metadataCenterViewMode: 'route' | 'dialog' = 'route';
private destroy$ = new Subject<void>();
readonly allColumns = [
{field: 'title', header: 'Title'},
{field: 'authors', header: 'Authors'},
{field: 'publisher', header: 'Publisher'},
{field: 'seriesName', header: 'Series'},
{field: 'seriesNumber', header: 'Series #'},
{field: 'categories', header: 'Genres'},
{field: 'publishedDate', header: 'Published'},
{field: 'lastReadTime', header: 'Last Read'},
{field: 'addedOn', header: 'Added'},
{field: 'fileSizeKb', header: 'File Size'},
{field: 'language', header: 'Language'},
{field: 'pageCount', header: 'Pages'},
{field: 'amazonRating', header: 'Amazon'},
{field: 'amazonReviewCount', header: 'AZ #'},
{field: 'goodreadsRating', header: 'Goodreads'},
{field: 'goodreadsReviewCount', header: 'GR #'},
{field: 'hardcoverRating', header: 'Hardcover'},
{field: 'hardcoverReviewCount', header: 'HC #'}
];
ngOnInit(): void { ngOnInit(): void {
this.userService.userState$ this.userService.userState$
.pipe(filter(user => !!user)) .pipe(
.subscribe((user) => { filter(user => !!user),
takeUntil(this.destroy$)
)
.subscribe(user => {
this.metadataCenterViewMode = user?.userSettings.metadataCenterViewMode ?? 'route'; this.metadataCenterViewMode = user?.userSettings.metadataCenterViewMode ?? 'route';
}); });
} }
// Hack to set virtual-scroller height
ngOnChanges() { ngOnChanges() {
const wrapperElements: HTMLCollection = document.getElementsByClassName('p-virtualscroller'); const wrapperElements: HTMLCollection = document.getElementsByClassName('p-virtualscroller');
Array.prototype.forEach.call(wrapperElements, function (wrapperElement) { Array.prototype.forEach.call(wrapperElements, function (wrapperElement) {
@@ -147,6 +174,61 @@ export class BookTableComponent implements OnInit, OnChanges {
return mb >= 1 ? `${mb.toFixed(1)} MB` : `${mb.toFixed(2)} MB`; return mb >= 1 ? `${mb.toFixed(1)} MB` : `${mb.toFixed(2)} MB`;
} }
getCellValue(metadata: BookMetadata, book: Book, field: string): string | number {
switch (field) {
case 'title':
return metadata.title ?? '';
case 'authors':
return this.getAuthorNames(metadata.authors!);
case 'publisher':
return metadata.publisher ?? '';
case 'seriesName':
return metadata.seriesName ?? '';
case 'seriesNumber':
return metadata.seriesNumber ?? '';
case 'categories':
return this.getGenres(metadata.categories!);
case 'publishedDate':
return metadata.publishedDate ? this.datePipe.transform(metadata.publishedDate, 'dd-MMM-yyyy') ?? '' : '';
case 'lastReadTime':
return book.lastReadTime ? this.datePipe.transform(book.lastReadTime, 'dd-MMM-yyyy') ?? '' : '';
case 'addedOn':
return book.addedOn ? this.datePipe.transform(book.addedOn, 'dd-MMM-yyyy') ?? '' : '';
case 'fileSizeKb':
return this.formatFileSize(book.fileSizeKb);
case 'language':
return metadata.language ?? '';
case 'pageCount':
return metadata.pageCount ?? '';
case 'amazonRating':
case 'goodreadsRating':
case 'hardcoverRating': {
const rating = metadata[field];
return typeof rating === 'number' ? rating.toFixed(1) : '';
}
case 'amazonReviewCount':
case 'goodreadsReviewCount':
case 'hardcoverReviewCount':
return metadata[field] ?? '';
default:
return '';
}
}
toggleMetadataLock(metadata: BookMetadata): void { toggleMetadataLock(metadata: BookMetadata): void {
const lockKeys = Object.keys(metadata).filter(key => key.endsWith('Locked')); const lockKeys = Object.keys(metadata).filter(key => key.endsWith('Locked'));
const allLocked = lockKeys.every(key => metadata[key] === true); const allLocked = lockKeys.every(key => metadata[key] === true);
@@ -169,4 +251,9 @@ export class BookTableComponent implements OnInit, OnChanges {
} }
}); });
} }
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
} }
@@ -0,0 +1,109 @@
import {inject, Injectable} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {MessageService} from 'primeng/api';
import {TableColumnPreference, UserService} from '../../../settings/user-management/user.service';
@Injectable({
providedIn: 'root'
})
export class TableColumnPreferenceService {
private readonly userService = inject(UserService);
private readonly messageService = inject(MessageService);
private readonly preferencesSubject = new BehaviorSubject<TableColumnPreference[]>([]);
readonly preferences$ = this.preferencesSubject.asObservable();
private readonly allAvailableColumns = [
{field: 'title', header: 'Title'},
{field: 'authors', header: 'Authors'},
{field: 'publisher', header: 'Publisher'},
{field: 'seriesName', header: 'Series'},
{field: 'seriesNumber', header: 'Series #'},
{field: 'categories', header: 'Genres'},
{field: 'publishedDate', header: 'Published'},
{field: 'lastReadTime', header: 'Last Read'},
{field: 'addedOn', header: 'Added'},
{field: 'fileSizeKb', header: 'File Size'},
{field: 'language', header: 'Language'},
{field: 'pageCount', header: 'Pages'},
{field: 'amazonRating', header: 'Amazon'},
{field: 'amazonReviewCount', header: 'AZ #'},
{field: 'goodreadsRating', header: 'Goodreads'},
{field: 'goodreadsReviewCount', header: 'GR #'},
{field: 'hardcoverRating', header: 'Hardcover'},
{field: 'hardcoverReviewCount', header: 'HC #'}
];
private readonly fallbackPreferences: TableColumnPreference[] = this.allAvailableColumns.map((col, index) => ({
field: col.field,
visible: true,
order: index
}));
initPreferences(savedPrefs: TableColumnPreference[] | undefined): void {
const effectivePrefs = savedPrefs?.length ? savedPrefs : this.fallbackPreferences;
this.preferencesSubject.next(this.mergeWithAllColumns(effectivePrefs));
}
get allColumns(): { field: string; header: string }[] {
return this.allAvailableColumns;
}
get visibleColumns(): { field: string; header: string }[] {
return this.preferencesSubject.value
.filter(pref => pref.visible)
.sort((a, b) => a.order - b.order)
.map(pref => ({
field: pref.field,
header: this.getColumnHeader(pref.field)
}));
}
get preferences(): TableColumnPreference[] {
return this.preferencesSubject.value;
}
saveVisibleColumns(selectedColumns: { field: string }[]): void {
const selectedFieldSet = new Set(selectedColumns.map(c => c.field));
const updatedPreferences: TableColumnPreference[] = this.allAvailableColumns.map((col, index) => {
const selectionIndex = selectedColumns.findIndex(c => c.field === col.field);
return {
field: col.field,
visible: selectedFieldSet.has(col.field),
order: selectionIndex >= 0 ? selectionIndex : index
};
});
this.preferencesSubject.next(updatedPreferences);
const currentUser = this.userService.getCurrentUser();
if (!currentUser) return;
this.userService.updateUserSetting(currentUser.id, 'tableColumnPreference', updatedPreferences);
this.messageService.add({
severity: 'success',
summary: 'Preferences Saved',
detail: 'Your column layout has been saved.',
life: 1500
});
}
private getColumnHeader(field: string): string {
return this.allAvailableColumns.find(col => col.field === field)?.header ?? field;
}
private mergeWithAllColumns(savedPrefs: TableColumnPreference[]): TableColumnPreference[] {
const savedPrefMap = new Map(savedPrefs.map(p => [p.field, p]));
return this.allAvailableColumns.map((col, index) => {
const saved = savedPrefMap.get(col.field);
return {
field: col.field,
visible: saved?.visible ?? true,
order: saved?.order ?? index
};
});
}
}
@@ -1,14 +1,14 @@
@if (book$ | async; as book) { @if (book$ | async; as book) {
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="flex flex-col h-full min-w-[80rem]"> <form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="flex flex-col h-full md:min-w-[80rem]">
@if (isLoading) { @if (isLoading) {
<div class="absolute inset-0 bg-black opacity-25 z-10 "></div> <div class="absolute inset-0 bg-black opacity-25 z-10 "></div>
} }
@if (isLoading) { @if (isLoading) {
<p-progressSpinner [style]="{position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)'}"></p-progressSpinner> <p-progressSpinner [style]="{position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)'}"></p-progressSpinner>
} }
<div class="flex-grow overflow-auto py-2 px-2"> <div class="flex-grow overflow-auto md:py-2 md:px-2 ">
<div class="flex flex-row w-full gap-4"> <div class="flex flex-col md:flex-row w-full gap-4">
<div class="flex flex-col items-center gap-2 relative"> <div class="flex flex-col items-center gap-4 relative">
<img <img
[attr.src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)" [attr.src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
alt="Image" alt="Image"
@@ -56,8 +56,8 @@
</div> </div>
<div class="flex flex-col flex-grow pl-2"> <div class="flex flex-col flex-grow pl-2">
<div class="flex flex-row w-full gap-4 pb-1"> <div class="flex flex-col md:flex-row w-full gap-4 pb-1">
<div class="flex flex-col gap-1 w-2/3"> <div class="flex flex-col gap-1 md:w-2/3">
<label for="title">Title</label> <label for="title">Title</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="title" formControlName="title" class="w-full"/> <input pInputText id="title" formControlName="title" class="w-full"/>
@@ -69,7 +69,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/3"> <div class="flex flex-col gap-1 md:w-1/3">
<label for="subtitle">Subtitle</label> <label for="subtitle">Subtitle</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="subtitle" formControlName="subtitle" class="w-full"/> <input pInputText id="subtitle" formControlName="subtitle" class="w-full"/>
@@ -83,8 +83,8 @@
</div> </div>
</div> </div>
<div class="flex flex-row w-full gap-4 mt-2 pb-1"> <div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 basis-[71%]"> <div class="flex flex-col gap-1 md:basis-[71%]">
<label for="authors">Authors</label> <label for="authors">Authors</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<div class="w-full"> <div class="w-full">
@@ -98,7 +98,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 basis-[20%]"> <div class="flex flex-col gap-1 md:basis-[20%]">
<label for="publisher">Publisher</label> <label for="publisher">Publisher</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="publisher" formControlName="publisher" class="w-full"/> <input pInputText id="publisher" formControlName="publisher" class="w-full"/>
@@ -110,7 +110,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 basis-[14%]"> <div class="flex flex-col gap-1 md:basis-[14%]">
<label for="language">Language</label> <label for="language">Language</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="language" formControlName="language" class="w-full"/> <input pInputText id="language" formControlName="language" class="w-full"/>
@@ -124,7 +124,7 @@
</div> </div>
</div> </div>
<div class="flex flex-row w-full gap-4 mt-2 pb-1"> <div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-full"> <div class="flex flex-col gap-1 w-full">
<label for="categories">Categories</label> <label for="categories">Categories</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
@@ -140,8 +140,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="flex flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 basis-[75%]"> <div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 md:basis-[75%]">
<label for="seriesName">Series Name</label> <label for="seriesName">Series Name</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="seriesName" formControlName="seriesName" class="w-full"/> <input pInputText id="seriesName" formControlName="seriesName" class="w-full"/>
@@ -154,7 +155,7 @@
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 basis-[10%]"> <div class="flex flex-col gap-1 md:basis-[10%]">
<label for="seriesNumber">Book #</label> <label for="seriesNumber">Book #</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full"/> <input pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full"/>
@@ -167,7 +168,7 @@
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 basis-[10%]"> <div class="flex flex-col gap-1 md:basis-[10%]">
<label for="seriesTotal">Total Books</label> <label for="seriesTotal">Total Books</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full"/> <input pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full"/>
@@ -180,7 +181,7 @@
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 basis-[15%]"> <div class="flex flex-col gap-1 md:basis-[15%]">
<label for="publishedDate">Publish Date</label> <label for="publishedDate">Publish Date</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="publishedDate" formControlName="publishedDate" class="w-full"/> <input pInputText id="publishedDate" formControlName="publishedDate" class="w-full"/>
@@ -194,8 +195,8 @@
</div> </div>
</div> </div>
<div class="flex flex-row w-full gap-4 mt-2 pb-1"> <div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="isbn10">ISBN 10</label> <label for="isbn10">ISBN 10</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="isbn10" formControlName="isbn10" class="w-full"/> <input pInputText id="isbn10" formControlName="isbn10" class="w-full"/>
@@ -207,7 +208,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="isbn13">ISBN 13</label> <label for="isbn13">ISBN 13</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="isbn13" formControlName="isbn13" class="w-full"/> <input pInputText id="isbn13" formControlName="isbn13" class="w-full"/>
@@ -219,7 +220,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="asin">ASIN (Amazon ID)</label> <label for="asin">ASIN (Amazon ID)</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="asin" formControlName="asin" class="w-full"/> <input pInputText id="asin" formControlName="asin" class="w-full"/>
@@ -231,7 +232,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="amazonRating">Amazon ★</label> <label for="amazonRating">Amazon ★</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/> <input pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
@@ -243,7 +244,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="amazonRatingCount">Amazon Reviews</label> <label for="amazonRatingCount">Amazon Reviews</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/> <input pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
@@ -255,7 +256,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="googleId">Google Books ID</label> <label for="googleId">Google Books ID</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="googleId" formControlName="googleId" class="w-full"/> <input pInputText id="googleId" formControlName="googleId" class="w-full"/>
@@ -269,8 +270,8 @@
</div> </div>
</div> </div>
<div class="flex flex-row w-full gap-4 mt-2 pb-1"> <div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="goodreadsId">Goodreads ID</label> <label for="goodreadsId">Goodreads ID</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsId" formControlName="goodreadsId" class="w-full"/> <input pInputText id="goodreadsId" formControlName="goodreadsId" class="w-full"/>
@@ -282,7 +283,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="goodreadsRating">Goodreads ★</label> <label for="goodreadsRating">Goodreads ★</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/> <input pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
@@ -294,7 +295,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="goodreadsReviewCount">Goodreads Reviews</label> <label for="goodreadsReviewCount">Goodreads Reviews</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/> <input pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
@@ -306,7 +307,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="hardcoverId">Hardcover ID</label> <label for="hardcoverId">Hardcover ID</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverId" formControlName="hardcoverId" class="w-full"/> <input pInputText id="hardcoverId" formControlName="hardcoverId" class="w-full"/>
@@ -318,7 +319,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="hardcoverRating">Hardcover ★</label> <label for="hardcoverRating">Hardcover ★</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverRating" formControlName="hardcoverRating" class="w-full"/> <input pInputText id="hardcoverRating" formControlName="hardcoverRating" class="w-full"/>
@@ -330,7 +331,7 @@
} }
</div> </div>
</div> </div>
<div class="flex flex-col gap-1 w-1/6"> <div class="flex flex-col gap-1 md:w-1/6">
<label for="hardcoverReviewCount">Hardcover Reviews</label> <label for="hardcoverReviewCount">Hardcover Reviews</label>
<div class="flex justify-between items-center gap-2"> <div class="flex justify-between items-center gap-2">
<input pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/> <input pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/>
@@ -353,7 +354,7 @@
<p-tab value="editor">WYSIWYG Editor</p-tab> <p-tab value="editor">WYSIWYG Editor</p-tab>
<p-tab value="html">HTML Editor</p-tab> <p-tab value="html">HTML Editor</p-tab>
</p-tablist> </p-tablist>
<p-tabpanels> <p-tabpanels class="custom-tab-padding">
<p-tabpanel value="editor"> <p-tabpanel value="editor">
<form [formGroup]="metadataForm"> <form [formGroup]="metadataForm">
<p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '200px' }"> <p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '200px' }">
@@ -412,7 +413,10 @@
</div> </div>
<div class="mt-auto"> <div class="mt-auto">
<p-divider></p-divider> <p-divider></p-divider>
<div class="flex justify-between px-2 pt-1 pb-4 z-10"> <div class="flex flex-col gap-2 px-2 pt-1 md:pb-4 z-10">
<!-- Desktop Buttons -->
<div class="hidden sm:flex justify-between w-full gap-4">
@if (showNavigationButtons) { @if (showNavigationButtons) {
<div class="flex gap-x-4"> <div class="flex gap-x-4">
<p-button label="Close" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()"></p-button> <p-button label="Close" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()"></p-button>
@@ -421,9 +425,10 @@
<p-button label="Next Book" [disabled]="disableNext" icon="pi pi-arrow-right" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()"></p-button> <p-button label="Next Book" [disabled]="disableNext" icon="pi pi-arrow-right" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()"></p-button>
</div> </div>
} }
<div class="flex gap-x-4 items-center ml-auto"> <div class="flex gap-x-4 items-center ml-auto">
<p-button <p-button
[label]="isAutoFetching ? 'Fetching...' : 'Auto Fetch'" [label]="isAutoFetching ? 'Fetching…' : 'Auto Fetch'"
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'" [icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
[outlined]="true" [outlined]="true"
severity="info" severity="info"
@@ -432,16 +437,51 @@
pTooltip="Automatically fetch metadata using default sources" pTooltip="Automatically fetch metadata using default sources"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
@if (book.bookType === 'PDF' || book.bookType === 'EPUB') { @if (book.bookType === 'PDF' || book.bookType === 'EPUB') {
<p-button label="Restore" icon="pi pi-refresh" [outlined]="true" severity="danger" (onClick)="restoreMetadata()" pTooltip="Revert all changes to original metadata" tooltipPosition="top"></p-button> <p-button label="Restore" icon="pi pi-refresh" [outlined]="true" severity="danger" (onClick)="restoreMetadata()" pTooltip="Revert all changes to original metadata" tooltipPosition="top"></p-button>
<p-divider layout="vertical" /> <p-divider layout="vertical" />
} }
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()" pTooltip="Unlock all metadata fields for editing" tooltipPosition="top"></p-button> <p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()" pTooltip="Unlock all metadata fields for editing" tooltipPosition="top"></p-button>
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()" pTooltip="Lock all metadata fields to prevent changes" tooltipPosition="top"></p-button> <p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()" pTooltip="Lock all metadata fields to prevent changes" tooltipPosition="top"></p-button>
<p-divider layout="vertical" /> <p-divider layout="vertical" />
<p-button label="Save" icon="pi pi-check" [loading]="isSaving" [disabled]="isSaving" type="submit"></p-button> <p-button label="Save" icon="pi pi-check" [loading]="isSaving" [disabled]="isSaving" type="submit"></p-button>
</div> </div>
</div> </div>
<!-- Mobile Buttons -->
<div class="flex sm:hidden justify-between w-full flex-wrap">
@if (showNavigationButtons) {
<div class="flex gap-2 flex-wrap">
<p-button icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()" pTooltip="Close" tooltipPosition="top"></p-button>
<p-button icon="pi pi-arrow-left" [disabled]="disablePrevious" [outlined]="true" severity="info" (onClick)="onPrevious()" pTooltip="Previous Book" tooltipPosition="top"></p-button>
<p-button icon="pi pi-arrow-right" [disabled]="disableNext" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()" pTooltip="Next Book" tooltipPosition="top"></p-button>
</div>
}
<div class="flex gap-4 items-center flex-wrap ml-auto">
<p-button
icon="pi pi-bolt"
[outlined]="true"
severity="info"
(onClick)="autoFetch(book.id)"
[disabled]="isAutoFetching"
pTooltip="Auto Fetch"
tooltipPosition="top">
</p-button>
@if (book.bookType === 'PDF' || book.bookType === 'EPUB') {
<p-button icon="pi pi-refresh" [outlined]="true" severity="danger" (onClick)="restoreMetadata()" pTooltip="Restore" tooltipPosition="top"></p-button>
}
<p-button icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()" pTooltip="Unlock All" tooltipPosition="top"></p-button>
<p-button icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()" pTooltip="Lock All" tooltipPosition="top"></p-button>
<p-divider layout="vertical" />
<p-button label="Save" icon="pi pi-check" [loading]="isSaving" [disabled]="isSaving" type="submit"></p-button>
</div>
</div>
</div>
</div> </div>
</form> </form>
} }
@@ -0,0 +1,7 @@
::ng-deep .p-tabpanels .custom-tab-padding {
padding: 1rem 0rem 0rem 0.5rem !important;
@media (min-width: 640px) {
padding: var(--p-tabs-tabpanel-padding) !important;
}
}
@@ -1,6 +1,6 @@
@if (book$ | async; as book) { @if (book$ | async; as book) {
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="flex flex-col h-full w-full"> <form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="flex flex-col h-full w-full">
<div class="flex-grow overflow-auto p-4"> <div class="flex-grow overflow-auto p-0 md:p-4">
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}"> <div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
<p class="ml-3 text-lg">Current Metadata</p> <p class="ml-3 text-lg">Current Metadata</p>
<p-button <p-button
@@ -7,48 +7,72 @@
</app-metadata-picker> </app-metadata-picker>
</div> </div>
} @else { } @else {
<form class="flex flex-col w-full h-full pt-2 min-w-[60rem] pr-4" [formGroup]="form" (ngSubmit)="onSubmit()"> <form class="flex flex-col w-full h-full pt-2 min-w-full md:min-w-[60rem] pr-0 md:pr-2 pl-0 md:pl-2" [formGroup]="form" (ngSubmit)="onSubmit()">
<div class="flex w-full gap-x-4 items-end"> <!-- Responsive search inputs -->
<div class="flex flex-col gap-1 w-3/12"> <div class="grid grid-cols-1 md:flex md:flex-row w-full gap-4 md:items-end">
<label>Providers</label>
<p-multiselect id="provider" class="w-full" [filter]="false" showToggleAll="false" [options]="providers" formControlName="provider" <div class="flex flex-col gap-1 w-full max-w-full md:w-3/12">
placeholder="Select Providers"></p-multiselect> <label for="provider">Providers</label>
<p-multiselect
id="provider"
class="w-full"
[filter]="false"
showToggleAll="false"
[options]="providers"
formControlName="provider"
placeholder="Select Providers">
</p-multiselect>
</div> </div>
<div class="flex flex-col gap-1 w-5/12">
<div class="flex flex-col gap-1 w-full max-w-full md:w-5/12">
<label for="title">Title</label> <label for="title">Title</label>
<input pInputText formControlName="title" id="title" class="w-full"/> <input pInputText formControlName="title" id="title" class="w-full"/>
</div> </div>
<div class="flex flex-col gap-1 w-4/12">
<div class="flex flex-col gap-1 w-full max-w-full md:w-4/12">
<label for="author">Author</label> <label for="author">Author</label>
<input pInputText formControlName="author" id="author" class="w-full"/> <input pInputText formControlName="author" id="author" class="w-full"/>
</div> </div>
<div>
<p-button label="Search" type="submit" outlined="true" [disabled]="!isSearchEnabled || loading"></p-button> <div class="flex flex-col gap-1 w-full sm:w-fit md:w-auto">
<label class="invisible md:visible h-0 md:h-auto">Search</label>
<div class="flex justify-center md:justify-start">
<p-button
label="Search"
type="submit"
outlined="true"
[disabled]="!isSearchEnabled || loading"
class="w-full sm:w-fit md:w-auto">
</p-button>
</div> </div>
</div> </div>
</div>
@if (loading) { @if (loading) {
<div class="flex justify-center items-center"> <div class="flex justify-center items-center mt-8">
<p-progress-spinner ariaLabel="loading"/> <p-progress-spinner ariaLabel="loading"/>
</div> </div>
} }
@if (!loading) { @if (!loading) {
<div class="mt-8 flex-1 overflow-y-auto"> <div class="mt-4 md:mt-8 flex-1 overflow-y-auto">
@for (metadata of allFetchedMetadata; track metadata) { @for (metadata of allFetchedMetadata; track metadata) {
<div class="book-item flex flex-col w-full"> <div class="book-item flex flex-col w-full">
<div class="flex w-full flex-row book-item-content" (click)="onBookClick(metadata)"> <div class="flex flex-row w-full book-item-content cursor-pointer" (click)="onBookClick(metadata)">
<img [src]="metadata.thumbnailUrl || 'assets/images/missing-cover.jpg'" alt="Image" class="img-fixed-dimensions pr-2"/> <img [src]="metadata.thumbnailUrl || 'assets/images/missing-cover.jpg'" alt="Image" class="img-fixed-dimensions pr-0 md:pr-2 self-center md:self-start"/>
<div class="flex flex-col w-full m-2"> <div class="flex flex-col w-full m-2">
<div class="flex flex-row gap-4 justify-between"> <div class="flex flex-col md:flex-row gap-2 md:gap-4 justify-between">
<p class="font-bold">{{ truncateText(metadata['title']!, 90) }}</p> <p class="font-bold">{{ truncateText(metadata['title']!, 90) }}</p>
<div class="flex gap-2"> <div class="flex flex-wrap gap-2 text-sm">
<p>ISBN: {{ metadata['isbn10'] || metadata['asin'] }}</p> <p>ISBN: {{ metadata['isbn10'] || metadata['asin'] }}</p>
<p> | </p> <span class="hidden md:inline">|</span>
<p>Published: {{ metadata['publishedDate'] }}</p> <p>Published: {{ metadata['publishedDate'] }}</p>
</div> </div>
</div> </div>
<div class="flex gap-2"> <div class="flex flex-wrap gap-2 text-sm">
<p>by {{ truncateText(metadata['authors']!.join(', '), 70) }}</p> <p>by {{ truncateText(metadata['authors']!.join(', '), 70) }}</p>
<p> | </p> <span class="hidden md:inline">|</span>
<p>Source: <span [innerHTML]="buildProviderLink(metadata)"></span></p> <p>Source: <span [innerHTML]="buildProviderLink(metadata)"></span></p>
</div> </div>
<p class="mt-4 truncate-text p-secondary"> <p class="mt-4 truncate-text p-secondary">
@@ -1,56 +1,73 @@
<div class="pt-2 flex flex-col h-full px-2 w-full"> <div class="p-0 md:p-2 flex flex-col h-full w-full rounded-xl">
@if (book$ | async; as book) { @if (book$ | async; as book) {
<div> <div class="flex flex-col md:flex-row gap-6 pb-8">
<div class="flex flex-row">
<div class="cover-wrapper relative"> <div class="flex justify-center md:justify-start">
<div class="relative w-[250px] min-w-[250px] md:w-[250px]">
<img <img
[attr.src]="urlHelper.getCoverUrl(book?.metadata!.bookId, book?.metadata!.coverUpdatedOn)" [attr.src]="urlHelper.getCoverUrl(book?.metadata!.bookId, book?.metadata!.coverUpdatedOn)"
class="book-cover placeholder" class="rounded-xl w-full object-cover"
alt="Cover of {{ book?.metadata!.title }}" alt="Cover of {{ book?.metadata!.title }}"
loading="lazy" loading="lazy"
width="225"
style="min-width: 225px;"
/> />
@if (book?.metadata!.seriesNumber != null) { @if (book?.metadata!.seriesNumber != null) {
<div class="series-number-overlay"> <div class="absolute top-2 left-2 bg-black/60 text-white px-2 py-0.5 rounded-lg text-xs font-semibold">
#{{ book?.metadata!.seriesNumber }} #{{ book?.metadata!.seriesNumber }}
</div> </div>
} }
@if (getProgressPercent(book) !== null) { @if (getProgressPercent(book) !== null) {
<div class="absolute bottom-0 left-0 right-0">
<p-progressBar <p-progressBar
[value]="getProgressPercent(book)" [value]="getProgressPercent(book)"
[showValue]="true" [showValue]="false"
[ngClass]="{ 'progress-complete': getProgressPercent(book) === 100, 'progress-incomplete': getProgressPercent(book)! < 100 }" [ngClass]="{
[style]="{ height: '10px' }"> 'rounded-b-xl': true,
'progress-complete': getProgressPercent(book) === 100,
'progress-incomplete': getProgressPercent(book)! < 100
}"
[style]="{ height: '8px' }">
</p-progressBar> </p-progressBar>
</div>
} }
</div> </div>
<div class="flex flex-col justify-between"> </div>
<div class="pl-6 flex flex-col">
<div class="flex flex-row items-center justify-between"> <div class="flex flex-col justify-between flex-grow">
<div> <div class="space-y-4">
<div class="flex items-start justify-between">
<div class="flex flex-col text-center md:text-left w-full">
@if (book?.metadata?.seriesName) { @if (book?.metadata?.seriesName) {
<p class="underline hover:opacity-80 cursor-pointer" (click)="goToSeries(book?.metadata?.seriesName!)"> <p
class="text-blue-600 cursor-pointer hover:underline"
(click)="goToSeries(book?.metadata?.seriesName!)"
>
{{ book?.metadata?.seriesName }} {{ book?.metadata?.seriesName }}
@if (book?.metadata?.seriesNumber) { @if (book?.metadata?.seriesNumber) {
#{{ book?.metadata?.seriesNumber }} #{{ book?.metadata?.seriesNumber }}
} }
</p> </p>
} }
<div class="flex items-center gap-2">
<p class="text-2xl font-bold m-0">{{ book?.metadata!.title }}</p> <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-3xl font-extrabold text-gray-900 dark:text-white leading-tight">
{{ book?.metadata!.title }}
</h2>
<i <i
class="pi" class="pi align-middle"
[ngClass]="isMetadataFullyLocked(book?.metadata!) ? 'pi-lock text-red-500' : 'pi-lock-open text-green-500'" [ngClass]="isMetadataFullyLocked(book?.metadata!) ? 'pi-lock text-red-500' : 'pi-lock-open text-green-500'"
[title]="isMetadataFullyLocked(book?.metadata!) ? 'Metadata is locked' : 'Metadata is unlocked'" [title]="isMetadataFullyLocked(book?.metadata!) ? 'Metadata is locked' : 'Metadata is unlocked'"
style="font-size: 1.25rem;"
pTooltip="{{ isMetadataFullyLocked(book?.metadata!) ? 'This book metadata is locked.' : 'This book metadata is unlocked.' }}" pTooltip="{{ isMetadataFullyLocked(book?.metadata!) ? 'This book metadata is locked.' : 'This book metadata is unlocked.' }}"
tooltipPosition="top"> tooltipPosition="top"
</i> ></i>
</div> </div>
<p class="text-lg">
<p class="text-gray-600 dark:text-gray-300 text-lg">
@for (author of book?.metadata!.authors; track author; let isLast = $last) { @for (author of book?.metadata!.authors; track author; let isLast = $last) {
<a class="underline hover:opacity-80 cursor-pointer" (click)="goToAuthorBooks(author)"> <a class="hover:underline dark:text-blue-400 cursor-pointer" (click)="goToAuthorBooks(author)">
{{ author }} {{ author }}
</a> </a>
@if (!isLast) { @if (!isLast) {
@@ -60,12 +77,13 @@
</p> </p>
</div> </div>
</div> </div>
<div class="flex items-center gap-2 pt-2"> </div>
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-start text-sm w-full">
<div class="flex justify-center sm:justify-start">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<i class="pi pi-thumbs-up-fill" <i class="pi pi-thumbs-up-fill text-yellow-500" pTooltip="Personal Rating" tooltipPosition="top"></i>
pTooltip="Personal Rating"
tooltipPosition="top">
</i>
<p-rating <p-rating
[ngModel]="book?.metadata!.personalRating" [ngModel]="book?.metadata!.personalRating"
(onRate)="onPersonalRatingChange(book, $event)" (onRate)="onPersonalRatingChange(book, $event)"
@@ -73,101 +91,103 @@
[style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.personalRating, 10)"> [style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.personalRating, 10)">
</p-rating> </p-rating>
</div> </div>
@if (book?.metadata!.amazonRating || book?.metadata!.goodreadsRating || book?.metadata!.hardcoverRating) { </div>
@if (book?.metadata!.amazonRating) {
@if (book?.metadata!.asin) { @if (book?.metadata?.amazonRating || book?.metadata?.goodreadsRating || book?.metadata?.hardcoverRating || book?.metadata?.googleId) {
<span>|</span> <span class="hidden sm:inline text-gray-400 text-xl px-1 leading-none">|</span>
<a class="flex items-center gap-1" [href]="'https://www.amazon.com/dp/' + book?.metadata!.asin" target="_blank" rel="noopener noreferrer"> }
<img src="https://www.amazon.com/favicon.ico" alt="Amazon"
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"/> <div class="flex flex-wrap justify-center sm:justify-start gap-4 pt-1">
<p class="font-semibold">{{ book?.metadata!.amazonRating }}</p> @if (book?.metadata?.amazonRating) {
</a> <a
} @else { class="flex items-center gap-1"
<span class="flex items-center gap-1"> [href]="'https://www.amazon.com/dp/' + (book.metadata?.asin ?? '')"
<img src="https://www.amazon.com/favicon.ico" alt="Amazon" class="w-5 h-5 object-contain"/> target="_blank"
<p class="font-semibold">{{ book?.metadata!.amazonRating }}</p> rel="noopener noreferrer"
[pTooltip]="getRatingTooltip(book, 'amazon')"
tooltipPosition="top"
>
<img
src="https://www.amazon.com/favicon.ico"
alt="Amazon"
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"
/>
<span class="font-semibold">
{{ getRatingPercent(book.metadata!.amazonRating) }}%
</span> </span>
}
<p-rating [ngModel]="book?.metadata!.amazonRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.amazonRating)">
</p-rating>
<p class="font-semibold">({{ book?.metadata!.amazonReviewCount | number:'1.0-0' }})</p>
@if (book?.metadata!.goodreadsRating || book?.metadata!.hardcoverRating) {
<span>|</span>
}
}
@if (book?.metadata!.goodreadsRating) {
@if (book?.metadata!.goodreadsId) {
<a class="flex items-center gap-1" [href]="'https://www.goodreads.com/book/show/' + book?.metadata!.goodreadsId" target="_blank" rel="noopener noreferrer">
<img src="https://www.goodreads.com/favicon.ico" alt="Goodreads"
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"/>
<p class="font-semibold">{{ book?.metadata!.goodreadsRating }}</p>
</a> </a>
} @else { }
<span class="flex items-center gap-1">
<img src="https://www.goodreads.com/favicon.ico" alt="Goodreads" class="w-5 h-5 object-contain"/> @if (book?.metadata?.goodreadsRating) {
<p class="font-semibold">{{ book?.metadata!.goodreadsRating }}</p> <a
class="flex items-center gap-1"
[href]="'https://www.goodreads.com/book/show/' + (book.metadata?.goodreadsId ?? '')"
target="_blank"
rel="noopener noreferrer"
[pTooltip]="getRatingTooltip(book, 'goodreads')"
tooltipPosition="top"
>
<img
src="https://www.goodreads.com/favicon.ico"
alt="Goodreads"
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"
/>
<span class="font-semibold">
{{ getRatingPercent(book.metadata!.goodreadsRating) }}%
</span> </span>
}
<p-rating [ngModel]="book?.metadata!.goodreadsRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.goodreadsRating)">
</p-rating>
<p class="font-semibold">({{ book?.metadata!.goodreadsReviewCount | number:'1.0-0' }})</p>
@if (book?.metadata!.hardcoverRating) {
<span>|</span>
}
}
@if (book?.metadata!.hardcoverRating) {
@if (book?.metadata!.hardcoverId) {
<a class="flex items-center gap-1" [href]="'https://hardcover.app/books/' + book?.metadata!.hardcoverId" target="_blank" rel="noopener noreferrer">
<img src="https://assets.hardcover.app/static/favicon.ico" alt="Hardcover"
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"/>
<p class="font-semibold">{{ book?.metadata!.hardcoverRating }}</p>
</a> </a>
} @else { }
<span class="flex items-center gap-1">
<img src="https://assets.hardcover.app/static/favicon.ico" alt="Hardcover" class="w-5 h-5 object-contain"/> @if (book?.metadata?.hardcoverRating) {
<p class="font-semibold">{{ book?.metadata!.hardcoverRating }}</p> <a
class="flex items-center gap-1"
[href]="'https://hardcover.app/books/' + (book.metadata?.hardcoverId ?? '')"
target="_blank"
rel="noopener noreferrer"
[pTooltip]="getRatingTooltip(book, 'hardcover')"
tooltipPosition="top"
>
<img
src="https://assets.hardcover.app/static/favicon.ico"
alt="Hardcover"
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"
/>
<span class="font-semibold">
{{ getRatingPercent(book.metadata!.hardcoverRating) }}%
</span> </span>
}
<p-rating [ngModel]="book?.metadata!.hardcoverRating" readonly stars="5"
[style.--p-rating-icon-active-color]="getStarColorScaled(book?.metadata!.hardcoverRating)">
</p-rating>
<p class="font-semibold">({{ book?.metadata!.hardcoverReviewCount | number:'1.0-0' }})</p>
@if ((book?.metadata!.amazonRating || book?.metadata!.goodreadsRating || book?.metadata!.hardcoverRating) && book?.metadata!.googleId) {
<span>|</span>
}
}
@if (book?.metadata!.googleId) {
<a class="flex items-center gap-1" [href]="'https://books.google.com/books?id=' + book?.metadata!.googleId" target="_blank" rel="noopener noreferrer">
<img src="https://books.google.com/favicon.ico" alt="Google Books"
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"/>
</a> </a>
} }
@if (book?.metadata?.googleId) {
<a
class="flex items-center gap-1"
[href]="'https://books.google.com/books?id=' + book.metadata!.googleId"
target="_blank"
rel="noopener noreferrer"
>
<img
src="https://books.google.com/favicon.ico"
alt="Google Books"
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"
/>
</a>
} }
</div> </div>
<div class="overflow-x-auto pt-4 scrollbar-hide max-w-full w-full"> </div>
@if (book?.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]"> <div class="flex gap-2 w-max max-w-[1150px]">
@for (category of book?.metadata!.categories; track category) { @for (category of book.metadata!.categories; track category) {
<a (click)="goToCategory(category)" class="shrink-0 no-underline cursor-pointer"> <a (click)="goToCategory(category)" class="shrink-0 no-underline cursor-pointer">
<p-tag [value]="category"></p-tag> <p-tag [value]="category"></p-tag>
</a> </a>
} }
</div> </div>
</div> </div>
<div class="grid gap-x-20 gap-y-2 pt-6" style="grid-template-columns: repeat(5, max-content);"> }
<div>
<p class="whitespace-nowrap flex items-center gap-2"> <div class="grid md:grid-cols-3 gap-y-2.5 text-sm pt-2 md:pt-4 text-gray-700 dark:text-gray-300 max-w-5xl">
<span class="font-bold">Read Status:</span>
<p-tag
class="cursor-pointer text-white"
[severity]="getStatusSeverity(selectedReadStatus)"
(click)="menu.toggle($event)">
{{ getStatusLabel(selectedReadStatus) }}
</p-tag>
<p-menu #menu [popup]="true" [model]="readStatusMenuItems"></p-menu>
</p>
</div>
<p class="whitespace-nowrap max-w-[250px] overflow-hidden text-ellipsis"> <p class="whitespace-nowrap max-w-[250px] overflow-hidden text-ellipsis">
<span class="font-bold">Publisher: </span> <span class="font-bold">Publisher: </span>
@if (book?.metadata?.publisher) { @if (book?.metadata?.publisher) {
@@ -178,10 +198,8 @@
<span>-</span> <span>-</span>
} }
</p> </p>
<p class="whitespace-nowrap"><span class="font-bold">Published:</span> {{ book?.metadata!.publishedDate || '-' }}</p> <p><strong>Published:</strong> {{ book?.metadata!.publishedDate || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">Language:</span> {{ book?.metadata!.language || '-' }}</p> <p><strong>Language:</strong> {{ book?.metadata!.language || '-' }}</p>
<p class="whitespace-nowrap"><span class="font-bold">ISBN 10:</span> {{ book?.metadata!.isbn10 || '-' }}</p>
<p class="whitespace-nowrap flex items-center gap-2"> <p class="whitespace-nowrap flex items-center gap-2">
<span class="font-bold">File Type:</span> <span class="font-bold">File Type:</span>
<span <span
@@ -190,9 +208,53 @@
{{ getFileExtension(book?.filePath) || '-' }} {{ getFileExtension(book?.filePath) || '-' }}
</span> </span>
</p> </p>
<p><strong>File Size:</strong> {{ getFileSizeInMB(book) }}</p>
<p>
<strong>ISBN:</strong>
@if (book?.metadata?.isbn13 || book?.metadata?.isbn10) {
{{ book.metadata!.isbn13 }}
@if (book?.metadata?.isbn13 && book?.metadata?.isbn10) {
/
}
{{ book.metadata!.isbn10 }}
} @else {
<span>-</span>
}
</p>
<p class="whitespace-nowrap flex items-center gap-2"> <p class="whitespace-nowrap flex items-center gap-2">
<span class="font-bold">Metadata Score:</span> <span class="font-bold">Read Status:</span>
<span
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white cursor-pointer"
[ngClass]="getStatusSeverityClass(selectedReadStatus)"
(click)="menu.toggle($event)">
{{ getStatusLabel(selectedReadStatus) }}
</span>
<p-menu #menu [popup]="true" [model]="readStatusMenuItems"></p-menu>
</p>
<p class="whitespace-nowrap flex items-center">
<span class="font-bold mr-2">Progress:</span>
<span class="inline-flex items-center">
<span
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
[ngClass]="getProgressColorClass(getProgressPercent(book))">
{{ getProgressPercent(book) !== null ? getProgressPercent(book) + '%' : 'N/A' }}
</span>
@if (getProgressPercent(book) !== null) {
<p-button
pTooltip="Reset progress"
tooltipPosition="bottom"
icon="pi pi-refresh"
size="small"
severity="danger"
text
class="ml-1 custom-button-padding"
(onClick)="resetProgress(book)">
</p-button>
}
</span>
</p>
<p class="whitespace-nowrap flex items-center gap-2">
<span class="font-bold">Metadata Match:</span>
@if (book?.metadataMatchScore != null) { @if (book?.metadataMatchScore != null) {
<span <span
class="inline-block px-2 py-0.5 rounded-lg text-xs font-bold text-gray-200 border" class="inline-block px-2 py-0.5 rounded-lg text-xs font-bold text-gray-200 border"
@@ -203,42 +265,23 @@
<span>-</span> <span>-</span>
} }
</p> </p>
<p class="whitespace-nowrap flex items-center gap-2">
<span class="font-bold">Progress:</span>
<span
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
[ngClass]="getProgressColorClass(getProgressPercent(book))">
{{ getProgressPercent(book) !== null ? getProgressPercent(book) + '%' : 'N/A' }}
</span>
</p>
<p class="whitespace-nowrap"><span class="font-bold">File Size:</span> {{ getFileSizeInMB(book) }}</p>
<p class="whitespace-nowrap"><span class="font-bold">ISBN 13:</span> {{ book?.metadata!.isbn13 || '-' }}</p>
</div> </div>
<div class="pt-2 flex items-center gap-2">
<span class="font-semibold flex-shrink-0">File Path:</span> <div class="flex items-center gap-2">
<p-toggleButton <span class="font-semibold text-sm">File Path:</span>
[(ngModel)]="showFilePath" <i
onIcon="pi pi-eye-slash" class="pi cursor-pointer text-sm"
offIcon="pi pi-eye" [ngClass]="showFilePath ? 'pi-eye-slash' : 'pi-eye'"
onLabel="" (click)="showFilePath = !showFilePath"
offLabel="" ></i>
size="small"
class="flex-shrink-0 my-visibility-toggle"></p-toggleButton>
@if (showFilePath) { @if (showFilePath) {
<div <code class="text-xs font-mono truncate text-gray-300">{{ book?.filePath }}</code>
class="flex items-center gap-4 flex-grow"
style="min-width: 0;">
<p
class="font-mono text-sm text-gray-400 whitespace-nowrap flex-grow"
style="min-width: 0;">
{{ book?.filePath }}
</p>
</div>
} }
</div> </div>
</div> </div>
@if (userService.userState$ | async; as userData) { @if (userService.userState$ | async; as userData) {
<div class="pl-6 pt-4 flex flex-row w-full gap-4"> <div class="flex flex-wrap gap-3 pt-6">
@if (book!.bookType === 'PDF') { @if (book!.bookType === 'PDF') {
@if (readMenuItems$ | async; as readItems) { @if (readMenuItems$ | async; as readItems) {
<p-splitbutton <p-splitbutton
@@ -246,7 +289,7 @@
icon="pi pi-book" icon="pi pi-book"
[model]="readItems" [model]="readItems"
(onClick)="read(book.id, 'ngx')" (onClick)="read(book.id, 'ngx')"
severity="info"/> severity="primary"/>
} }
} }
@if (book!.bookType !== 'PDF') { @if (book!.bookType !== 'PDF') {
@@ -254,12 +297,12 @@
label="Read" label="Read"
icon="pi pi-book" icon="pi pi-book"
(onClick)="read(book?.metadata!.bookId, undefined)" (onClick)="read(book?.metadata!.bookId, undefined)"
severity="info"/> severity="primary"/>
} }
<p-button <p-button
label="Shelf" label="Shelf"
icon="pi pi-folder" icon="pi pi-folder"
severity="info" severity="secondary"
outlined outlined
(onClick)="assignShelf(book.id)"> (onClick)="assignShelf(book.id)">
</p-button> </p-button>
@@ -267,7 +310,7 @@
<p-button <p-button
label="Download" label="Download"
icon="pi pi-download" icon="pi pi-download"
severity="info" severity="success"
outlined outlined
(onClick)="download(book.id)"> (onClick)="download(book.id)">
</p-button> </p-button>
@@ -291,7 +334,7 @@
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'" [icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
[outlined]="true" [outlined]="true"
[model]="refreshItems" [model]="refreshItems"
severity="info" severity="warn"
(onClick)="quickRefresh(book.id)" (onClick)="quickRefresh(book.id)"
[disabled]="isAutoFetching" [disabled]="isAutoFetching"
pTooltip="Automatically fetch metadata using default sources" pTooltip="Automatically fetch metadata using default sources"
@@ -301,7 +344,7 @@
} }
@if (userData.permissions.canDeleteBook || userData.permissions.admin) { @if (userData.permissions.canDeleteBook || userData.permissions.admin) {
@if (otherItems$ | async; as otherItems) { @if (otherItems$ | async; as otherItems) {
<p-button icon="pi pi-ellipsis-v" outlined severity="info" (click)="entitymenu.toggle($event)"></p-button> <p-button icon="pi pi-ellipsis-v" outlined severity="danger" (click)="entitymenu.toggle($event)"></p-button>
<p-menu #entitymenu [model]="otherItems" [popup]="true" appendTo="body"></p-menu> <p-menu #entitymenu [model]="otherItems" [popup]="true" appendTo="body"></p-menu>
} }
} }
@@ -309,32 +352,29 @@
} }
</div> </div>
</div> </div>
</div>
<p-divider></p-divider> <div class="px-4 pb-2 pt-4 border border-[var(--border-color)] rounded-xl">
<div class="flex-1 space-y-2 px-2 min-w-[40rem]">
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }" class="transition-all duration-300 overflow-hidden description-container"> <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"> <div class="readonly-editor px-2">
<p-editor #quillEditor [readonly]="true" [style]="{height: '250px'}" [(ngModel)]="book.metadata!.description"> <p-editor #quillEditor [readonly]="true" [style]="{height: '225px'}" [(ngModel)]="book.metadata!.description">
<ng-template #header> <ng-template #header>
</ng-template> </ng-template>
</p-editor> </p-editor>
</div> </div>
</div> </div>
@if (book.metadata!.description && book.metadata!.description.length > 100) { @if (book.metadata!.description && book.metadata!.description.length > 500) {
<div class="text-left"> <p-button
<button pButton
type="button"
[label]="isExpanded ? 'Show less' : 'Show more'" [label]="isExpanded ? 'Show less' : 'Show more'"
[icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" [icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
iconPos="right" iconPos="right"
class="p-button-text p-button-sm" size="small"
text
(click)="toggleExpand()"> (click)="toggleExpand()">
</button> </p-button>
</div>
} }
<p-divider></p-divider> </div>
<div class="pt-4 space-y-4 pb-6">
@if (bookInSeries.length > 0) { @if (bookInSeries.length > 0) {
<div> <div>
<h3 class="text-xl font-semibold pt-2">More in the Series</h3> <h3 class="text-xl font-semibold pt-2">More in the Series</h3>
@@ -84,3 +84,11 @@
width: 100%; width: 100%;
} }
::ng-deep .custom-button-padding .p-button {
padding-block: 0rem !important;
}
::ng-deep .custom-tag-padding {
padding: 0.1rem !important;
}
@@ -1,12 +1,12 @@
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, Optional, SimpleChanges, ViewChild} from '@angular/core'; import {Component, DestroyRef, inject, Input, OnChanges, OnInit, Optional, SimpleChanges, ViewChild} from '@angular/core';
import {Button, ButtonDirective} from 'primeng/button'; import {Button} from 'primeng/button';
import {AsyncPipe, DecimalPipe, NgClass} from '@angular/common'; import {AsyncPipe, DecimalPipe, NgClass} from '@angular/common';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {BookService} from '../../../service/book.service'; import {BookService} from '../../../service/book.service';
import {Rating, RatingRateEvent} from 'primeng/rating'; import {Rating, RatingRateEvent} from 'primeng/rating';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {Tag} from 'primeng/tag'; import {Tag} from 'primeng/tag';
import {Book, BookMetadata, BookRecommendation, MetadataClearFlags, MetadataUpdateWrapper, ReadStatus} from '../../../model/book.model'; import {Book, BookMetadata, BookRecommendation, ReadStatus} from '../../../model/book.model';
import {Divider} from 'primeng/divider'; import {Divider} from 'primeng/divider';
import {UrlHelperService} from '../../../../utilities/service/url-helper.service'; import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
import {UserService} from '../../../../settings/user-management/user.service'; import {UserService} from '../../../../settings/user-management/user.service';
@@ -20,7 +20,6 @@ import {Tooltip} from 'primeng/tooltip';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {Editor} from 'primeng/editor'; import {Editor} from 'primeng/editor';
import {ProgressBar} from 'primeng/progressbar'; import {ProgressBar} from 'primeng/progressbar';
import {ToggleButton} from 'primeng/togglebutton';
import {MetadataFetchOptionsComponent} from '../../metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component'; import {MetadataFetchOptionsComponent} from '../../metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum'; import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model'; import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
@@ -35,7 +34,7 @@ import {BookCardLiteComponent} from '../../../components/book-card-lite/book-car
standalone: true, standalone: true,
templateUrl: './metadata-viewer.component.html', templateUrl: './metadata-viewer.component.html',
styleUrl: './metadata-viewer.component.scss', styleUrl: './metadata-viewer.component.scss',
imports: [Button, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, ButtonDirective, Editor, ProgressBar, ToggleButton, Menu, InfiniteScrollDirective, BookCardLiteComponent] imports: [Button, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, InfiniteScrollDirective, BookCardLiteComponent]
}) })
export class MetadataViewerComponent implements OnInit, OnChanges { export class MetadataViewerComponent implements OnInit, OnChanges {
@@ -341,6 +340,30 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
return 'bg-red-600 border-red-700'; return 'bg-red-600 border-red-700';
} }
getStatusSeverityClass(status: string): string {
const normalized = status?.toUpperCase();
switch (normalized) {
case 'UNREAD':
return 'bg-gray-500';
case 'PAUSED':
return 'bg-zinc-600';
case 'READING':
return 'bg-blue-600';
case 'RE_READING':
return 'bg-indigo-600';
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';
}
}
getProgressColorClass(progress: number | null | undefined): string { getProgressColorClass(progress: number | null | undefined): string {
if (progress == null) return 'bg-gray-600'; if (progress == null) return 'bg-gray-600';
return 'bg-blue-500'; return 'bg-blue-500';
@@ -410,14 +433,31 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
} }
} }
getStatusSeverity(status: string): 'success' | 'secondary' | 'info' | 'warn' | 'danger' | undefined { getRatingTooltip(book: Book, source: 'amazon' | 'goodreads' | 'hardcover'): string {
const normalized = status?.toUpperCase(); const meta = book?.metadata;
if (['UNREAD', 'PAUSED'].includes(normalized)) return 'secondary'; if (!meta) return '';
if (['READING', 'RE_READING'].includes(normalized)) return 'info';
if (['READ'].includes(normalized)) return 'success'; switch (source) {
if (['PARTIALLY_READ'].includes(normalized)) return 'warn'; case 'amazon':
if (['WONT_READ', 'ABANDONED'].includes(normalized)) return 'danger'; return meta.amazonRating != null
return undefined; ? `★ ${meta.amazonRating} | ${meta.amazonReviewCount?.toLocaleString() ?? '0'} reviews`
: '';
case 'goodreads':
return meta.goodreadsRating != null
? `★ ${meta.goodreadsRating} | ${meta.goodreadsReviewCount?.toLocaleString() ?? '0'} reviews`
: '';
case 'hardcover':
return meta.hardcoverRating != null
? `★ ${meta.hardcoverRating} | ${meta.hardcoverReviewCount?.toLocaleString() ?? '0'} reviews`
: '';
default:
return '';
}
}
getRatingPercent(rating: number | null | undefined): number {
if (rating == null) return 0;
return Math.round((rating / 5) * 100);
} }
readStatusMenuItems = this.readStatusOptions.map(option => ({ readStatusMenuItems = this.readStatusOptions.map(option => ({
@@ -426,7 +466,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
})); }));
getStatusLabel(value: string): string { getStatusLabel(value: string): string {
return this.readStatusOptions.find(o => o.value === value)?.label ?? 'Unknown'; return this.readStatusOptions.find(o => o.value === value)?.label.toUpperCase() ?? 'N/A';
} }
updateReadStatus(status: ReadStatus): void { updateReadStatus(status: ReadStatus): void {
@@ -461,4 +501,35 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
}); });
}); });
} }
resetProgress(book: Book): void {
this.confirmationService.confirm({
message: `Reset reading progress for "${book.metadata?.title}"?`,
header: 'Confirm Reset',
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Yes',
rejectLabel: 'Cancel',
acceptButtonStyleClass: 'p-button-danger',
accept: () => {
this.bookService.resetProgress(book.id).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Progress Reset',
detail: 'Reading progress has been reset.',
life: 1500
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Failed',
detail: 'Could not reset progress.',
life: 1500
});
}
});
}
});
}
} }
@@ -397,6 +397,12 @@ export class BookService {
); );
} }
resetProgress(bookId: number): Observable<Book> {
return this.http.post<Book>(`${this.url}/${bookId}/reset-progress`, null).pipe(
tap(updatedBook => this.handleBookUpdate(updatedBook))
);
}
/*------------------ All the websocket handlers go below ------------------*/ /*------------------ All the websocket handlers go below ------------------*/
@@ -70,6 +70,12 @@ export interface NewPdfReaderSetting {
pageViewMode: PdfPageViewMode; pageViewMode: PdfPageViewMode;
} }
export interface TableColumnPreference {
field: string;
visible: boolean;
order: number;
}
export interface UserSettings { export interface UserSettings {
perBookSetting: PerBookSetting; perBookSetting: PerBookSetting;
pdfReaderSetting: PdfReaderSetting; pdfReaderSetting: PdfReaderSetting;
@@ -81,6 +87,7 @@ export interface UserSettings {
filterSortingMode: 'alphabetical' | 'count'; filterSortingMode: 'alphabetical' | 'count';
metadataCenterViewMode: 'route' | 'dialog'; metadataCenterViewMode: 'route' | 'dialog';
entityViewPreferences: EntityViewPreferences; entityViewPreferences: EntityViewPreferences;
tableColumnPreference?: TableColumnPreference[];
} }
export interface User { export interface User {