feat(read-status): Add Read Status tracking and filtering support

- Introduced `ReadStatus` enum and added `readStatus` field to `BookEntity`
- Updated database schema with Flyway migration to store read status
- Extended DTOs and backend API to handle read status updates
- Added `updateBookReadStatus()` in backend service and controller
- Integrated read status in Angular: display, update, and toast feedback
- Added read status filters and labels across book listing, sidebar filter, and viewer
- Refactored `MetadataViewerComponent` and extracted read status UI logic
- Simplified read status label resolution using a mapping function
This commit is contained in:
aditya.chandel
2025-06-22 00:26:12 -06:00
committed by Aditya Chandel
parent cd4e14c8ad
commit 6bfbff5d34
13 changed files with 176 additions and 20 deletions
@@ -2,7 +2,7 @@ import {inject, Injectable} from '@angular/core';
import {BehaviorSubject, first, Observable, of, throwError} from 'rxjs';
import {HttpClient, HttpParams} from '@angular/common/http';
import {catchError, filter, map, tap} from 'rxjs/operators';
import {Book, BookDeletionResponse, BookMetadata, BookRecommendation, BookSetting, BulkMetadataUpdateRequest} from '../model/book.model';
import {Book, BookDeletionResponse, BookMetadata, BookRecommendation, BookSetting, BulkMetadataUpdateRequest, ReadStatus} from '../model/book.model';
import {BookState} from '../model/state/book-state.model';
import {API_CONFIG} from '../../config/api-config';
import {FetchMetadataRequest} from '../metadata/model/request/fetch-metadata-request.model';
@@ -180,7 +180,7 @@ export class BookService {
const idList = Array.from(ids);
const params = new HttpParams().set('ids', idList.join(','));
return this.http.delete<BookDeletionResponse>(this.url, { params }).pipe(
return this.http.delete<BookDeletionResponse>(this.url, {params}).pipe(
tap(response => {
const currentState = this.bookStateSubject.value;
const remainingBooks = (currentState.books || []).filter(
@@ -487,4 +487,8 @@ export class BookService {
getBackupMetadata(bookId: number) {
return this.http.get<any>(`${this.url}/${bookId}/metadata/restore`);
}
updateBookReadStatus(id: number, status: ReadStatus): Observable<void> {
return this.http.put<void>(`${this.url}/${id}/read-status`, {status});
}
}