Merge pull request #182 from adityachandelgit/develop

Merge Develop into Master - Release v0.3.0
This commit is contained in:
Aditya Chandel
2025-04-22 13:31:49 -06:00
committed by GitHub
21 changed files with 390 additions and 117 deletions
+25 -3
View File
@@ -1,4 +1,4 @@
name-template: 'v$NEXT_PATCH_VERSION 🌟' name-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION' tag-template: 'v$NEXT_PATCH_VERSION'
categories: categories:
@@ -23,9 +23,31 @@ categories:
- 'ci' - 'ci'
- 'cd' - 'cd'
- 'workflow' - 'workflow'
- title: '🗂️ Other'
labels:
- 'other'
- 'misc'
- '*'
change-template: '- $TITLE (#$NUMBER) by @$AUTHOR' change-template: '- $TITLE (#$NUMBER) by @$AUTHOR'
template: | template: |
## 🌟 Changes in this release: ## Release Notes:
$CHANGES
### 🚀 Features:
$FEATURES
### 🐛 Bug Fixes:
$BUGS
### 🛠️ Refactoring:
$REFACTOR
### 📖 Documentation:
$DOCS
### ⚙️ CI/CD:
$CICD
### 🗂️ Other:
$OTHER
@@ -47,7 +47,7 @@ public class WebSocketAuthInterceptor implements ChannelInterceptor {
} }
accessor.setUser(auth); accessor.setUser(auth);
log.info("WebSocket authentication successful for user: {}", auth.getName()); log.debug("WebSocket authentication successful for user: {}", auth.getName());
} }
return message; return message;
@@ -2,6 +2,7 @@ package com.adityachandel.booklore.exception;
import jakarta.validation.ConstraintViolationException; import jakarta.validation.ConstraintViolationException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.connector.ClientAbortException;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -10,6 +11,7 @@ import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.async.AsyncRequestNotUsableException;
import org.springframework.web.servlet.resource.NoResourceFoundException; import org.springframework.web.servlet.resource.NoResourceFoundException;
import java.util.List; import java.util.List;
@@ -72,6 +74,17 @@ public class GlobalExceptionHandler {
return new ResponseEntity<>(errorResponse, HttpStatus.NOT_FOUND); return new ResponseEntity<>(errorResponse, HttpStatus.NOT_FOUND);
} }
@ExceptionHandler(AsyncRequestNotUsableException.class)
public ResponseEntity<ErrorResponse> handleAsyncRequestNotUsableException(AsyncRequestNotUsableException ex) {
if (ex.getCause() instanceof ClientAbortException) {
log.info("Request was canceled by client: {}", ex.getMessage());
} else {
log.error("Unexpected error occurred during async request handling: ", ex);
}
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.OK.value(), "Request was canceled by the client.");
return new ResponseEntity<>(errorResponse, HttpStatus.OK);
}
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleGenericException(Exception ex) { public ResponseEntity<ErrorResponse> handleGenericException(Exception ex) {
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "An unexpected error occurred."); ErrorResponse errorResponse = new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "An unexpected error occurred.");
@@ -44,7 +44,6 @@ public class BookMetadata {
private String providerBookId; private String providerBookId;
private String thumbnailUrl; private String thumbnailUrl;
private Boolean allFieldsLocked;
private Boolean titleLocked; private Boolean titleLocked;
private Boolean subtitleLocked; private Boolean subtitleLocked;
private Boolean publisherLocked; private Boolean publisherLocked;
@@ -82,8 +82,6 @@ public class BookMetadataEntity {
private Integer goodreadsReviewCount; private Integer goodreadsReviewCount;
// Locking fields // Locking fields
@Column(name = "all_fields_locked")
private Boolean allFieldsLocked = Boolean.FALSE;
@Column(name = "title_locked") @Column(name = "title_locked")
private Boolean titleLocked = Boolean.FALSE; private Boolean titleLocked = Boolean.FALSE;
@@ -176,7 +174,6 @@ public class BookMetadataEntity {
private List<BookAwardEntity> awards; private List<BookAwardEntity> awards;
public void applyLockToAllFields(boolean lock) { public void applyLockToAllFields(boolean lock) {
this.allFieldsLocked = lock;
this.titleLocked = lock; this.titleLocked = lock;
this.subtitleLocked = lock; this.subtitleLocked = lock;
this.publisherLocked = lock; this.publisherLocked = lock;
@@ -200,4 +197,54 @@ public class BookMetadataEntity {
this.goodreadsRatingLocked = lock; this.goodreadsRatingLocked = lock;
this.goodreadsReviewCountLocked = lock; this.goodreadsReviewCountLocked = lock;
} }
public boolean isAnyFieldLocked() {
return Boolean.TRUE.equals(this.titleLocked)
|| Boolean.TRUE.equals(this.subtitleLocked)
|| Boolean.TRUE.equals(this.publisherLocked)
|| Boolean.TRUE.equals(this.publishedDateLocked)
|| Boolean.TRUE.equals(this.descriptionLocked)
|| Boolean.TRUE.equals(this.isbn13Locked)
|| Boolean.TRUE.equals(this.isbn10Locked)
|| Boolean.TRUE.equals(this.pageCountLocked)
|| Boolean.TRUE.equals(this.thumbnailLocked)
|| Boolean.TRUE.equals(this.languageLocked)
|| Boolean.TRUE.equals(this.ratingLocked)
|| Boolean.TRUE.equals(this.reviewCountLocked)
|| Boolean.TRUE.equals(this.coverLocked)
|| Boolean.TRUE.equals(this.seriesNameLocked)
|| Boolean.TRUE.equals(this.seriesNumberLocked)
|| Boolean.TRUE.equals(this.seriesTotalLocked)
|| Boolean.TRUE.equals(this.authorsLocked)
|| Boolean.TRUE.equals(this.categoriesLocked)
|| Boolean.TRUE.equals(this.amazonRatingLocked)
|| Boolean.TRUE.equals(this.amazonReviewCountLocked)
|| Boolean.TRUE.equals(this.goodreadsRatingLocked)
|| Boolean.TRUE.equals(this.goodreadsReviewCountLocked);
}
public boolean areAllFieldsLocked() {
return Boolean.TRUE.equals(this.titleLocked)
&& Boolean.TRUE.equals(this.subtitleLocked)
&& Boolean.TRUE.equals(this.publisherLocked)
&& Boolean.TRUE.equals(this.publishedDateLocked)
&& Boolean.TRUE.equals(this.descriptionLocked)
&& Boolean.TRUE.equals(this.isbn13Locked)
&& Boolean.TRUE.equals(this.isbn10Locked)
&& Boolean.TRUE.equals(this.pageCountLocked)
&& Boolean.TRUE.equals(this.thumbnailLocked)
&& Boolean.TRUE.equals(this.languageLocked)
&& Boolean.TRUE.equals(this.ratingLocked)
&& Boolean.TRUE.equals(this.reviewCountLocked)
&& Boolean.TRUE.equals(this.coverLocked)
&& Boolean.TRUE.equals(this.seriesNameLocked)
&& Boolean.TRUE.equals(this.seriesNumberLocked)
&& Boolean.TRUE.equals(this.seriesTotalLocked)
&& Boolean.TRUE.equals(this.authorsLocked)
&& Boolean.TRUE.equals(this.categoriesLocked)
&& Boolean.TRUE.equals(this.amazonRatingLocked)
&& Boolean.TRUE.equals(this.amazonReviewCountLocked)
&& Boolean.TRUE.equals(this.goodreadsRatingLocked)
&& Boolean.TRUE.equals(this.goodreadsReviewCountLocked);
}
} }
@@ -106,9 +106,8 @@ public class BookMetadataService {
List<BookEntity> books = getBookEntities(request); List<BookEntity> books = getBookEntities(request);
for (BookEntity bookEntity : books) { for (BookEntity bookEntity : books) {
try { try {
Boolean allFieldsLocked = bookEntity.getMetadata().getAllFieldsLocked(); if (bookEntity.getMetadata().areAllFieldsLocked()) {
if (Boolean.TRUE.equals(allFieldsLocked)) { log.info("Skipping metadata refresh for fully locked book: {}", bookEntity.getFileName());
log.info("Skipping metadata refresh for locked book: {}", bookEntity.getFileName());
continue; continue;
} }
Map<MetadataProvider, BookMetadata> metadataMap = fetchMetadataForBook(providers, bookEntity); Map<MetadataProvider, BookMetadata> metadataMap = fetchMetadataForBook(providers, bookEntity);
@@ -39,7 +39,7 @@ public class BookMetadataUpdater {
updateLocks(newMetadata, metadata); updateLocks(newMetadata, metadata);
if (Boolean.TRUE.equals(metadata.getAllFieldsLocked())) { if (metadata.areAllFieldsLocked()) {
log.warn("Attempted to update metadata for book with ID {}, but all fields are locked. No update performed.", bookId); log.warn("Attempted to update metadata for book with ID {}, but all fields are locked. No update performed.", bookId);
return metadata; return metadata;
} }
@@ -252,9 +252,6 @@ public class BookMetadataUpdater {
if (newMetadata.getCoverLocked() != null) { if (newMetadata.getCoverLocked() != null) {
metadata.setCoverLocked(newMetadata.getCoverLocked()); metadata.setCoverLocked(newMetadata.getCoverLocked());
} }
if (newMetadata.getAllFieldsLocked() != null) {
metadata.setAllFieldsLocked(newMetadata.getAllFieldsLocked());
}
} }
} }
@@ -17,6 +17,11 @@ spring:
url: ${DATABASE_URL:jdbc:mariadb://${DATABASE_HOST:${DB_HOST:mariadb}}:${DATABASE_PORT:3306}/${DATABASE_NAME:booklore}?createDatabaseIfNotExist=true} url: ${DATABASE_URL:jdbc:mariadb://${DATABASE_HOST:${DB_HOST:mariadb}}:${DATABASE_PORT:3306}/${DATABASE_NAME:booklore}?createDatabaseIfNotExist=true}
username: ${DATABASE_USERNAME:root} username: ${DATABASE_USERNAME:root}
password: ${DATABASE_PASSWORD:${MYSQL_ROOT_PASSWORD}} password: ${DATABASE_PASSWORD:${MYSQL_ROOT_PASSWORD}}
hikari:
max-lifetime: 580000 # 580 seconds
connection-test-query: SELECT 1
maximum-pool-size: 10
idle-timeout: 300000 # 5 minutes
jpa: jpa:
hibernate: hibernate:
naming: naming:
@@ -106,9 +106,9 @@
</div> </div>
<div class="book-card-container" *ngIf="bookState?.books as books"> <div class="book-card-container" *ngIf="bookState?.books as books">
<app-book-table *ngIf="gridOrTable === 'table' && books.length > 0" [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)" [sortOption]="selectedSort"></app-book-table> <app-book-table *ngIf="currentViewMode === 'table' && books.length > 0" [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)" [sortOption]="selectedSort!"></app-book-table>
<virtual-scroller *ngIf="gridOrTable === 'grid'" class="virtual-scroller" #scroll [items]="books"> <virtual-scroller *ngIf="currentViewMode === 'grid'" class="virtual-scroller" #scroll [items]="books">
<div class="grid grid-cols-12 gap-4" #container> <div class="grid grid-cols-12 gap-4" #container>
<div class="virtual-scroller-item" *ngFor="let book of scroll.viewPortItems"> <div class="virtual-scroller-item" *ngFor="let book of scroll.viewPortItems">
<app-book-card <app-book-card
@@ -1,6 +1,6 @@
import {AfterViewInit, Component, inject, OnInit, ViewChild} from '@angular/core'; import {AfterViewInit, ChangeDetectorRef, Component, inject, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {ConfirmationService, MenuItem, MessageService, PrimeTemplate} from 'primeng/api'; import {MenuItem, MessageService, PrimeTemplate} from 'primeng/api';
import {LibraryService} from '../../service/library.service'; import {LibraryService} from '../../service/library.service';
import {BookService} from '../../service/book.service'; import {BookService} from '../../service/book.service';
import {map, switchMap} from 'rxjs/operators'; import {map, switchMap} from 'rxjs/operators';
@@ -39,6 +39,23 @@ export enum EntityType {
ALL_BOOKS = 'All Books' ALL_BOOKS = 'All Books'
} }
const QUERY_PARAMS = {
VIEW: 'view',
SORT: 'sort',
DIRECTION: 'direction',
FILTER: 'filter'
};
const VIEW_MODES = {
GRID: 'grid',
TABLE: 'table',
};
const SORT_DIRECTION = {
ASCENDING: 'asc',
DESCENDING: 'desc',
};
@Component({ @Component({
selector: 'app-book-browser', selector: 'app-book-browser',
standalone: true, standalone: true,
@@ -77,12 +94,11 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
dynamicDialogRef: DynamicDialogRef | undefined; dynamicDialogRef: DynamicDialogRef | undefined;
EntityType = EntityType; EntityType = EntityType;
gridOrTable: string = 'grid';
@ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent; @ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent;
@ViewChild(BookFilterComponent) bookFilterComponent!: BookFilterComponent; @ViewChild(BookFilterComponent) bookFilterComponent!: BookFilterComponent;
selectedFilter = new BehaviorSubject<{ type: string; value: any } | null>(null); selectedFilter = new BehaviorSubject<{ type: string; value: any } | null>(null);
protected resetFilterSubject = new Subject<void>();
protected userService = inject(UserService); protected userService = inject(UserService);
private activatedRoute = inject(ActivatedRoute); private activatedRoute = inject(ActivatedRoute);
@@ -92,31 +108,34 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
private shelfService = inject(ShelfService); private shelfService = inject(ShelfService);
private dialogService = inject(DialogService); private dialogService = inject(DialogService);
private sortService = inject(SortService); private sortService = inject(SortService);
private router = inject(Router);
private cdr = inject(ChangeDetectorRef);
private libraryShelfMenuService = inject(LibraryShelfMenuService); private libraryShelfMenuService = inject(LibraryShelfMenuService);
private confirmationService = inject(ConfirmationService);
protected resetFilterSubject = new Subject<void>();
sortOptions: any[] = [ sortOptions: any[] = [
{label: 'Title', icon: '', field: 'title', command: () => this.sortBooks('title')}, {label: 'Title', icon: '', field: 'title', command: () => this.sortBooks('title')},
{label: 'Author', icon: '', field: 'author', command: () => this.sortBooks('author')}, {label: 'Author', icon: '', field: 'author', command: () => this.sortBooks('author')},
{label: 'Last Read', field: 'lastReadTime', command: () => this.sortBooks('lastReadTime')},
{label: 'Added On', field: 'addedOn', command: () => this.sortBooks('addedOn')},
{label: 'Locked', icon: '', field: 'locked', command: () => this.sortBooks('locked')},
{label: 'Publisher', icon: '', field: 'publisher', command: () => this.sortBooks('publisher')}, {label: 'Publisher', icon: '', field: 'publisher', command: () => this.sortBooks('publisher')},
{label: 'Published', icon: '', field: 'publishedDate', command: () => this.sortBooks('publishedDate')}, {label: 'Published Date', icon: '', field: 'publishedDate', command: () => this.sortBooks('publishedDate')},
{label: 'Pages', icon: '', field: 'pageCount', command: () => this.sortBooks('pageCount')}, {label: 'Amazon Rating', icon: '', field: 'amazonRating', command: () => this.sortBooks('amazonRating')},
{label: 'Rating', icon: '', field: 'rating', command: () => this.sortBooks('rating')}, {label: 'Amazon #', icon: '', field: 'amazonReviewCount', command: () => this.sortBooks('amazonReviewCount')},
{label: 'Reviews', icon: '', field: 'reviewCount', command: () => this.sortBooks('reviewCount')}, {label: 'Goodreads Rating', icon: '', field: 'goodreadsRating', command: () => this.sortBooks('goodreadsRating')},
{label: 'Goodreads #', icon: '', field: 'goodreadsReviewCount', command: () => this.sortBooks('goodreadsReviewCount')},
{label: 'Pages', icon: '', field: 'pageCount', command: () => this.sortBooks('pageCount')}
]; ];
selectedSort: SortOption = { selectedSort: SortOption | undefined = undefined;
label: 'Title', currentViewMode: string | undefined = undefined;
field: 'title', lastAppliedSort: SortOption | null = null;
direction: SortDirection.DESCENDING, filterVisibility = true;
};
ngOnInit(): void { ngOnInit(): void {
this.bookService.loadBooks(); this.bookService.loadBooks();
this.sortBooks(this.selectedSort.field);
const isAllBooksRoute = this.activatedRoute.snapshot.routeConfig?.path === 'all-books'; const isAllBooksRoute = this.activatedRoute.snapshot.routeConfig?.path === 'all-books';
if (isAllBooksRoute) { if (isAllBooksRoute) {
@@ -167,12 +186,17 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
return (entity as Library).paths !== undefined; return (entity as Library).paths !== undefined;
} }
toggleTableGrid() { toggleTableGrid(): void {
this.gridOrTable = this.gridOrTable === 'grid' ? 'table' : 'grid'; this.currentViewMode = this.currentViewMode === VIEW_MODES.GRID ? VIEW_MODES.TABLE : VIEW_MODES.GRID;
this.router.navigate([], {
queryParams: {view: this.currentViewMode},
queryParamsHandling: 'merge',
replaceUrl: true
});
} }
get viewIcon(): string { get viewIcon(): string {
return this.gridOrTable === 'grid' ? 'pi pi-objects-column' : 'pi pi-table'; return this.currentViewMode === VIEW_MODES.GRID ? 'pi pi-objects-column' : 'pi pi-table';
} }
private getEntityInfoFromRoute(): Observable<{ entityId: number; entityType: EntityType }> { private getEntityInfoFromRoute(): Observable<{ entityId: number; entityType: EntityType }> {
@@ -296,7 +320,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
map(bookState => { map(bookState => {
if (bookState.loaded && !bookState.error) { if (bookState.loaded && !bookState.error) {
const filteredBooks = bookState.books?.filter(bookFilter) || []; const filteredBooks = bookState.books?.filter(bookFilter) || [];
const sortedBooks = this.sortService.applySort(filteredBooks, this.selectedSort); const sortedBooks = this.sortService.applySort(filteredBooks, this.selectedSort!);
return {...bookState, books: sortedBooks}; return {...bookState, books: sortedBooks};
} }
return bookState; return bookState;
@@ -308,7 +332,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
private processBookState(bookState: BookState): BookState { private processBookState(bookState: BookState): BookState {
if (bookState.loaded && !bookState.error) { if (bookState.loaded && !bookState.error) {
const sortedBooks = this.sortService.applySort(bookState.books || [], this.selectedSort); const sortedBooks = this.sortService.applySort(bookState.books || [], this.selectedSort!);
return {...bookState, books: sortedBooks}; return {...bookState, books: sortedBooks};
} }
return bookState; return bookState;
@@ -386,19 +410,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
} }
} }
private setSelectedSortFromEntity(entity: Library | Shelf | null): void {
if (entity?.sort) {
const {field, direction} = entity.sort;
this.selectedSort = this.sortOptions.find(option => option.field === field && option.direction === direction) || null;
} else {
this.selectedSort = {
label: 'Title',
field: 'title',
direction: SortDirection.ASCENDING,
};
}
}
onBookTitleChange(newTitle: string): void { onBookTitleChange(newTitle: string): void {
this.bookOrAuthor$.next(newTitle); this.bookOrAuthor$.next(newTitle);
} }
@@ -448,6 +459,14 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
toggleFilterSidebar() { toggleFilterSidebar() {
this.bookFilterComponent.showFilters = !this.bookFilterComponent.showFilters; this.bookFilterComponent.showFilters = !this.bookFilterComponent.showFilters;
this.router.navigate([], {
queryParams: {
[QUERY_PARAMS.FILTER]: this.bookFilterComponent.showFilters.toString()
},
queryParamsHandling: 'merge',
replaceUrl: true
});
} }
get isFilterActive(): boolean { get isFilterActive(): boolean {
@@ -461,22 +480,44 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.clearSearch(); this.clearSearch();
} }
sortBooks(field: string) { sortBooks(field: string): void {
const existingSort = this.sortOptions.find(opt => opt.field === field);
if (!existingSort) return;
if (this.selectedSort?.field === field) { if (this.selectedSort?.field === field) {
this.selectedSort.direction = this.selectedSort.direction === SortDirection.ASCENDING ? SortDirection.DESCENDING : SortDirection.ASCENDING; this.selectedSort = {
...this.selectedSort,
direction: this.selectedSort.direction === SortDirection.ASCENDING
? SortDirection.DESCENDING
: SortDirection.ASCENDING
};
} else { } else {
this.selectedSort.field = field; this.selectedSort = {
this.selectedSort.direction = SortDirection.ASCENDING; label: existingSort.label,
field: existingSort.field,
direction: SortDirection.ASCENDING
};
} }
this.updateSortOptions(); this.updateSortOptions();
this.applySortOption(this.selectedSort) this.applySortOption(this.selectedSort);
this.router.navigate([], {
queryParams: {
sort: this.selectedSort.field,
direction: this.selectedSort.direction === SortDirection.ASCENDING ? SORT_DIRECTION.ASCENDING : SORT_DIRECTION.DESCENDING
},
queryParamsHandling: 'merge',
replaceUrl: true
});
} }
updateSortOptions() { updateSortOptions() {
const directionIcon = this.selectedSort.direction === SortDirection.ASCENDING ? 'pi pi-arrow-up' : 'pi pi-arrow-down'; const directionIcon = this.selectedSort!.direction === SortDirection.ASCENDING ? 'pi pi-arrow-up' : 'pi pi-arrow-down';
this.sortOptions = this.sortOptions.map((option) => ({ this.sortOptions = this.sortOptions.map((option) => ({
...option, ...option,
icon: option.field === this.selectedSort.field ? directionIcon : '', icon: option.field === this.selectedSort!.field ? directionIcon : '',
})); }));
} }
@@ -484,6 +525,62 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.bookFilterComponent.filterSelected.subscribe((item) => { this.bookFilterComponent.filterSelected.subscribe((item) => {
this.selectedFilter.next(item); this.selectedFilter.next(item);
}); });
this.activatedRoute.queryParamMap.subscribe(paramMap => {
const viewParam = paramMap.get(QUERY_PARAMS.VIEW);
const sortParam = paramMap.get(QUERY_PARAMS.SORT);
const directionParam = paramMap.get(QUERY_PARAMS.DIRECTION);
const filterParam = paramMap.get(QUERY_PARAMS.FILTER);
this.currentViewMode = viewParam === VIEW_MODES.TABLE || viewParam === VIEW_MODES.GRID ? viewParam : VIEW_MODES.GRID;
const matchingSort = this.sortOptions.find(opt => opt.field === sortParam);
const direction = directionParam === SORT_DIRECTION.DESCENDING ? SortDirection.DESCENDING : SortDirection.ASCENDING;
this.bookFilterComponent.showFilters = filterParam === 'true' || (filterParam === null && this.filterVisibility);
if (matchingSort) {
this.selectedSort = {
label: matchingSort.label,
field: matchingSort.field,
direction
};
} else {
this.selectedSort = {
label: 'Added On',
field: 'addedOn',
direction: SortDirection.DESCENDING
};
}
if (this.lastAppliedSort?.field !== this.selectedSort.field ||
this.lastAppliedSort?.direction !== this.selectedSort.direction) {
this.lastAppliedSort = {...this.selectedSort};
this.applySortOption(this.selectedSort);
}
const queryParams: any = {
[QUERY_PARAMS.VIEW]: this.currentViewMode,
[QUERY_PARAMS.SORT]: this.selectedSort.field,
[QUERY_PARAMS.DIRECTION]: this.selectedSort.direction === SortDirection.ASCENDING ? SORT_DIRECTION.ASCENDING : SORT_DIRECTION.DESCENDING,
[QUERY_PARAMS.FILTER]: this.bookFilterComponent.showFilters.toString()
};
const currentParams = this.activatedRoute.snapshot.queryParams;
if (
currentParams[QUERY_PARAMS.VIEW] !== queryParams[QUERY_PARAMS.VIEW] ||
currentParams[QUERY_PARAMS.SORT] !== queryParams[QUERY_PARAMS.SORT] ||
currentParams[QUERY_PARAMS.DIRECTION] !== queryParams[QUERY_PARAMS.DIRECTION] ||
currentParams[QUERY_PARAMS.FILTER] !== queryParams[QUERY_PARAMS.FILTER]
) {
this.router.navigate([], {
queryParams,
replaceUrl: true
});
}
});
this.cdr.detectChanges();
} }
lockUnlockMetadata() { lockUnlockMetadata() {
@@ -496,7 +593,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
} }
}); });
this.dynamicDialogRef.onClose.subscribe(() => { this.dynamicDialogRef.onClose.subscribe(() => {
this.deselectAllBooks(); this.deselectAllBooks();
}); });
} }
} }
@@ -30,8 +30,8 @@
<p class="m-0 pl-2"> <p class="m-0 pl-2">
<i <i
class="pi" class="pi"
[ngClass]="book.metadata?.allFieldsLocked ? 'pi-lock text-red-400' : 'pi-lock-open text-green-400'" [ngClass]="isMetadataFullyLocked(book.metadata!) ? 'pi-lock text-red-400' : 'pi-lock-open text-green-400'"
[title]="book.metadata?.allFieldsLocked ? 'Locked' : 'Unlocked'" [title]="isMetadataFullyLocked(book.metadata!) ? 'Locked' : 'Unlocked'"
style="font-size: 0.75rem;"> style="font-size: 0.75rem;">
</i> </i>
</p> </p>
@@ -1,5 +1,5 @@
import {Component, inject, Input, OnInit, ViewChild} from '@angular/core'; import {Component, inject, Input, OnInit, ViewChild} from '@angular/core';
import {Book} from '../../../model/book.model'; import {Book, BookMetadata} 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 {MenuItem, MessageService} from 'primeng/api'; import {MenuItem, MessageService} from 'primeng/api';
@@ -241,4 +241,10 @@ export class BookCardComponent implements OnInit {
private hasEmailBookPermission(): boolean { private hasEmailBookPermission(): boolean {
return this.userPermissions?.canEmailBook ?? false; return this.userPermissions?.canEmailBook ?? false;
} }
isMetadataFullyLocked(metadata: BookMetadata): boolean {
return Object.keys(metadata)
.filter(key => key.endsWith('Locked'))
.every(key => metadata[key] === true);
}
} }
@@ -21,13 +21,18 @@
<th pResizableColumn>Title</th> <th pResizableColumn>Title</th>
<th pResizableColumn>Authors</th> <th pResizableColumn>Authors</th>
<th pResizableColumn>Publisher</th> <th pResizableColumn>Publisher</th>
<th pResizableColumn>Genres</th>
<th>Published</th> <th>Published</th>
<th>Genres</th> <th>Last Read</th>
<th>ISBN</th> <th>Added</th>
<th>Language</th> <th>Lang</th>
<th>Rating</th>
<th>Pages</th> <th>Pages</th>
<th>Reviews</th> <th>Amazon</th>
<th>Amz #</th>
<th>Goodreads</th>
<th>GR #</th>
<th>Rating (L)</th>
<th>Reviews (L)</th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template #body let-book> <ng-template #body let-book>
@@ -37,10 +42,10 @@
</td> </td>
<td class="text-center"> <td class="text-center">
<p-button <p-button
[icon]="metadata.allFieldsLocked ? 'pi pi-lock' : 'pi pi-lock-open'" [icon]="isMetadataFullyLocked(metadata) ? 'pi pi-lock' : 'pi pi-lock-open'"
[severity]="metadata.allFieldsLocked ? 'danger' : 'success'" [severity]="isMetadataFullyLocked(metadata) ? 'danger' : 'success'"
[text]="true" [text]="true"
[title]="metadata.allFieldsLocked ? 'Locked' : 'Unlocked'" [title]="isMetadataFullyLocked(metadata) ? 'Locked' : 'Unlocked'"
size="small" size="small"
[style]="{ width: '1.5rem', height: '1.5rem', padding: '0', fontSize: '0.75rem' }" [style]="{ width: '1.5rem', height: '1.5rem', padding: '0', fontSize: '0.75rem' }"
(click)="toggleMetadataLock(metadata)"> (click)="toggleMetadataLock(metadata)">
@@ -49,25 +54,61 @@
<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-[15rem] max-w-[20rem] overflow-hidden truncate">{{ metadata.title }}</td> <td class="min-w-[15rem] max-w-[20rem] overflow-hidden truncate" [title]="metadata.title">{{ metadata.title }}</td>
<td class="min-w-[10rem] max-w-[13rem] overflow-hidden truncate">{{ getAuthorNames(metadata.authors) }}</td> <td class="min-w-[10rem] max-w-[15rem] overflow-hidden truncate" [title]="getAuthorNames(metadata.authors)">{{ getAuthorNames(metadata.authors) }}</td>
<td class="min-w-[12rem] max-w-[12rem] overflow-hidden truncate">{{ metadata.publisher }}</td> <td class="min-w-[9rem] max-w-[13rem] overflow-hidden truncate" [title]="metadata.publisher">{{ metadata.publisher }}</td>
<td class="min-w-[8rem] max-w-[8rem] overflow-hidden truncate">{{ metadata.publishedDate }}</td> <td class="min-w-[12rem] max-w-[18rem] overflow-hidden truncate" [title]="getGenres(metadata.categories)">{{ getGenres(metadata.categories) }}</td>
<td class="min-w-[8rem] max-w-[10rem] overflow-hidden truncate">{{ getGenres(metadata.categories) }}</td> <td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate">
<td class="overflow-hidden truncate min-w-[8rem] max-w-[8rem]">{{ metadata.isbn10 }}</td> {{ 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-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.language }}</td> <td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.language }}</td>
<td class="min-w-[8rem] max-w-[8rem] overflow-hidden truncate"> <td class="min-w-[4rem] max-w-[5rem] overflow-hidden truncate">{{ metadata.pageCount }}</td>
<ng-container> <td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.amazonRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.amazonRating)">
</p-rating>
<span *ngIf="metadata.amazonRating != null">({{ metadata.amazonRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.amazonReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.goodreadsRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.goodreadsRating)">
</p-rating>
<span *ngIf="metadata.goodreadsRating != null">({{ metadata.goodreadsRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[7rem] max-w-[7rem] overflow-hidden truncate text-right">
{{ metadata.goodreadsReviewCount ?? '' }}
</td>
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating <p-rating
[(ngModel)]="metadata.rating" [(ngModel)]="metadata.rating"
readonly readonly
stars="5" stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.rating)"> [style.--p-rating-icon-active-color]="getStarColor(metadata.rating)">
</p-rating> </p-rating>
</ng-container> <span *ngIf="metadata.rating != null">({{ metadata.rating?.toFixed(1) }})</span>
</span>
</td> </td>
<td class="min-w-[5rem] max-w-[5rem] overflow-hidden truncate">{{ metadata.pageCount }}</td> <td class="min-w-[3rem] max-w-[3rem] overflow-hidden truncate">{{ metadata.reviewCount }}</td>
<td class="min-w-[5rem] max-w-[5rem] overflow-hidden truncate">{{ metadata.reviewCount }}</td>
</tr> </tr>
</ng-template> </ng-template>
</p-table> </p-table>
@@ -1,6 +1,6 @@
import {Component, EventEmitter, inject, Input, OnChanges, Output} from '@angular/core'; import {Component, EventEmitter, inject, Input, OnChanges, Output} from '@angular/core';
import {TableModule} from 'primeng/table'; import {TableModule} from 'primeng/table';
import {NgIf} from '@angular/common'; import {DatePipe, NgIf} from '@angular/common';
import {Rating} from 'primeng/rating'; import {Rating} from 'primeng/rating';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {Book, BookMetadata} from '../../../model/book.model'; import {Book, BookMetadata} from '../../../model/book.model';
@@ -20,7 +20,8 @@ import {Router} from '@angular/router';
NgIf, NgIf,
Rating, Rating,
FormsModule, FormsModule,
Button Button,
DatePipe
], ],
styleUrl: './book-table.component.scss' styleUrl: './book-table.component.scss'
}) })
@@ -99,8 +100,17 @@ export class BookTableComponent implements OnChanges {
return genres?.join(', ') || ''; return genres?.join(', ') || '';
} }
isMetadataFullyLocked(metadata: BookMetadata): boolean {
return Object.keys(metadata)
.filter(key => key.endsWith('Locked'))
.every(key => metadata[key] === true);
}
toggleMetadataLock(metadata: BookMetadata): void { toggleMetadataLock(metadata: BookMetadata): void {
const lockAction = metadata.allFieldsLocked ? 'UNLOCK' : 'LOCK'; const lockKeys = Object.keys(metadata).filter(key => key.endsWith('Locked'));
const allLocked = lockKeys.every(key => metadata[key] === true);
const lockAction = allLocked ? 'UNLOCK' : 'LOCK';
this.bookService.toggleAllLock(new Set([metadata.bookId]), lockAction).subscribe({ this.bookService.toggleAllLock(new Set([metadata.bookId]), lockAction).subscribe({
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
@@ -44,7 +44,6 @@ export interface BookMetadata {
providerBookId?: string; providerBookId?: string;
thumbnailUrl?: string | null; thumbnailUrl?: string | null;
allFieldsLocked?: boolean;
titleLocked?: boolean; titleLocked?: boolean;
subtitleLocked?: boolean; subtitleLocked?: boolean;
publisherLocked?: boolean; publisherLocked?: boolean;
@@ -10,11 +10,21 @@ export class SortService {
private readonly fieldExtractors: Record<string, (book: Book) => any> = { private readonly fieldExtractors: Record<string, (book: Book) => any> = {
title: (book) => book.metadata?.title?.toLowerCase() || null, title: (book) => book.metadata?.title?.toLowerCase() || null,
author: (book) => book.metadata?.authors?.map(a => a.toLowerCase()).join(", ") || null, author: (book) => book.metadata?.authors?.map(a => a.toLowerCase()).join(", ") || null,
publishedDate: (book) =>book.metadata?.publishedDate === null ? null : new Date(book.metadata?.publishedDate!).getTime(), publishedDate: (book) => book.metadata?.publishedDate === null ? null : new Date(book.metadata?.publishedDate!).getTime(),
publisher: (book) => book.metadata?.publisher || null, publisher: (book) => book.metadata?.publisher || null,
pageCount: (book) => book.metadata?.pageCount || null, pageCount: (book) => book.metadata?.pageCount || null,
rating: (book) => book.metadata?.rating || null, rating: (book) => book.metadata?.rating || null,
reviewCount: (book) => book.metadata?.reviewCount || null, reviewCount: (book) => book.metadata?.reviewCount || null,
amazonRating: (book) => book.metadata?.amazonRating || null,
amazonReviewCount: (book) => book.metadata?.amazonReviewCount || null,
goodreadsRating: (book) => book.metadata?.goodreadsRating || null,
goodreadsReviewCount: (book) => book.metadata?.goodreadsReviewCount || null,
locked: (book) =>
Object.keys(book.metadata ?? {})
.filter((key) => key.endsWith('Locked'))
.every((key) => book.metadata?.[key] === true),
lastReadTime: (book) => book.lastReadTime ? new Date(book.lastReadTime).getTime() : null,
addedOn: (book) => book.addedOn ? new Date(book.addedOn).getTime() : null
}; };
applySort(books: Book[], selectedSort: SortOption | null): Book[] { applySort(books: Book[], selectedSort: SortOption | null): Book[] {
@@ -8,7 +8,7 @@ import {distinctUntilChanged, filter, map, switchMap, take} from 'rxjs/operators
import {BookService} from '../../book/service/book.service'; import {BookService} from '../../book/service/book.service';
import {AppSettingsService} from '../../core/service/app-settings.service'; import {AppSettingsService} from '../../core/service/app-settings.service';
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs'; import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
import {NgIf, NgTemplateOutlet} from '@angular/common'; import {NgIf} from '@angular/common';
import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component'; import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component';
import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component'; import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component';
import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component'; import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component';
@@ -27,8 +27,7 @@ import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.c
MetadataViewerComponent, MetadataViewerComponent,
TabPanel, TabPanel,
MetadataEditorComponent, MetadataEditorComponent,
MetadataSearcherComponent, MetadataSearcherComponent
NgTemplateOutlet
] ]
}) })
export class BookMetadataCenterComponent implements OnInit, OnDestroy { export class BookMetadataCenterComponent implements OnInit, OnDestroy {
@@ -12,10 +12,11 @@ import {BookMetadataCenterService} from '../book-metadata-center.service';
import {MultiSelect} from 'primeng/multiselect'; import {MultiSelect} from 'primeng/multiselect';
import {Book, BookMetadata} from '../../../book/model/book.model'; import {Book, BookMetadata} from '../../../book/model/book.model';
import {BookService} from '../../../book/service/book.service'; import {BookService} from '../../../book/service/book.service';
import {combineLatest, Observable, Subscription} from 'rxjs'; import {combineLatest, Observable, Subscription, Subject, takeUntil} from 'rxjs';
import {AppSettings} from '../../../core/model/app-settings.model'; import {AppSettings} from '../../../core/model/app-settings.model';
import {AppSettingsService} from '../../../core/service/app-settings.service'; import {AppSettingsService} from '../../../core/service/app-settings.service';
import {distinctUntilChanged, filter} from 'rxjs/operators'; import {distinctUntilChanged, filter, switchMap} from 'rxjs/operators';
import {ActivatedRoute, Router} from '@angular/router';
@Component({ @Component({
selector: 'app-metadata-searcher', selector: 'app-metadata-searcher',
@@ -36,8 +37,10 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
private metadataCenterService = inject(BookMetadataCenterService); private metadataCenterService = inject(BookMetadataCenterService);
private bookService = inject(BookService); private bookService = inject(BookService);
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private route = inject(ActivatedRoute);
private subscription: Subscription = new Subscription(); private subscription: Subscription = new Subscription();
private cancelRequest$ = new Subject<void>();
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$; appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
bookChanged$: Observable<Book | null> = this.metadataCenterService.bookChanged$; bookChanged$: Observable<Book | null> = this.metadataCenterService.bookChanged$;
@@ -52,34 +55,49 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.subscription.add( this.subscription.add(
combineLatest([this.bookChanged$, this.appSettings$]) this.route.paramMap.pipe(
.pipe( switchMap(params => {
filter(([book, settings]) => !!book && !!settings), const bookId = +params.get('id')!;
distinctUntilChanged(([prevBook], [currBook]) => prevBook?.id === currBook?.id) if (this.bookId !== bookId) {
) this.bookId = bookId;
.subscribe(([book, settings]) => { this.cancelRequest$.next();
const autoBookSearchEnabled = settings!.autoBookSearch ?? false; this.loading = false;
if (book) {
this.selectedFetchedMetadata = null; this.selectedFetchedMetadata = null;
this.allFetchedMetadata = []; this.allFetchedMetadata = [];
this.bookId = book.id;
this.form.patchValue({ this.form.patchValue({
provider: Object.values(MetadataProvider), provider: Object.values(MetadataProvider),
title: book.metadata?.title || null, title: '',
author: book.metadata?.authors?.length ? book.metadata.authors[0] : '' author: '',
}); });
if (autoBookSearchEnabled) {
this.onSubmit();
}
} }
}) return combineLatest([this.bookChanged$, this.appSettings$]);
}),
filter(([book, settings]) => !!book && !!settings),
distinctUntilChanged(([prevBook], [currBook]) => prevBook?.id === currBook?.id)
).subscribe(([book, settings]) => {
const autoBookSearchEnabled = settings!.autoBookSearch ?? false;
if (book) {
this.selectedFetchedMetadata = null;
this.allFetchedMetadata = [];
this.bookId = book.id;
this.form.patchValue({
provider: Object.values(MetadataProvider),
title: book.metadata?.title || null,
author: book.metadata?.authors?.length ? book.metadata.authors[0] : ''
});
if (autoBookSearchEnabled) {
this.onSubmit();
}
}
})
); );
} }
ngOnDestroy(): void { ngOnDestroy(): void {
this.cancelRequest$.next();
this.subscription.unsubscribe(); this.subscription.unsubscribe();
this.allFetchedMetadata = []; this.allFetchedMetadata = [];
this.selectedFetchedMetadata = null; this.selectedFetchedMetadata = null;
@@ -106,7 +124,9 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
author: this.form.get('author')?.value author: this.form.get('author')?.value
}; };
this.loading = true; this.loading = true;
this.cancelRequest$.next();
this.bookService.fetchBookMetadata(fetchRequest.bookId, fetchRequest) this.bookService.fetchBookMetadata(fetchRequest.bookId, fetchRequest)
.pipe(takeUntil(this.cancelRequest$))
.subscribe({ .subscribe({
next: (fetchedMetadata) => { next: (fetchedMetadata) => {
this.loading = false; this.loading = false;
@@ -16,10 +16,10 @@
<p class="text-2xl font-bold m-0">{{ metadata.title }}</p> <p class="text-2xl font-bold m-0">{{ metadata.title }}</p>
<i <i
class="pi" class="pi"
[ngClass]="metadata.allFieldsLocked ? 'pi-lock text-red-500' : 'pi-lock-open text-green-500'" [ngClass]="isMetadataFullyLocked(metadata) ? 'pi-lock text-red-500' : 'pi-lock-open text-green-500'"
[title]="metadata.allFieldsLocked ? 'Metadata is locked' : 'Metadata is unlocked'" [title]="isMetadataFullyLocked(metadata) ? 'Metadata is locked' : 'Metadata is unlocked'"
style="font-size: 1.25rem;" style="font-size: 1.25rem;"
pTooltip="{{ metadata.allFieldsLocked ? 'This book metadata is locked.' : 'This book metadata is unlocked.' }}" pTooltip="{{ isMetadataFullyLocked(metadata) ? 'This book metadata is locked.' : 'This book metadata is unlocked.' }}"
tooltipPosition="top"> tooltipPosition="top">
</i> </i>
</div> </div>
@@ -74,7 +74,7 @@
<p-divider></p-divider> <p-divider></p-divider>
<div *ngIf="metadata$ | async as metadata" class="flex-1 overflow-auto space-y-2 px-2 pb-4"> <div *ngIf="metadata$ | async as metadata" class="flex-1 overflow-auto space-y-2 px-2">
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }" <div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }"
class="transition-all duration-300 overflow-hidden description-container"> class="transition-all duration-300 overflow-hidden description-container">
<div class="description-content" [innerHTML]="metadata.description || 'No description available.'"></div> <div class="description-content" [innerHTML]="metadata.description || 'No description available.'"></div>
@@ -114,6 +114,7 @@
</ng-container> </ng-container>
<ng-container *ngIf="bookInSeries.length > 0"> <ng-container *ngIf="bookInSeries.length > 0">
<p-divider></p-divider>
<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>
<div class="dashboard-scroller-infinite" <div class="dashboard-scroller-infinite"
@@ -131,6 +132,8 @@
</div> </div>
</div> </div>
</div> </div>
<p-divider></p-divider>
</ng-container> </ng-container>
</div> </div>
</div> </div>
@@ -43,7 +43,7 @@
} }
.description-container { .description-container {
max-height: 60px; max-height: 58px;
overflow: hidden; overflow: hidden;
transition: max-height 0.3s ease-in-out; transition: max-height 0.3s ease-in-out;
} }
@@ -140,4 +140,10 @@ export class MetadataViewerComponent implements OnInit {
}, },
}); });
} }
isMetadataFullyLocked(metadata: BookMetadata): boolean {
return Object.keys(metadata)
.filter(key => key.endsWith('Locked'))
.every(key => metadata[key] === true);
}
} }