Refactor book service in BE and FE (#2013)
* Refactor book service in BE and FE * Add missing method --------- Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {IconService} from '../../shared/services/icon.service';
|
||||
import {forkJoin, Observable, of} from 'rxjs';
|
||||
import {catchError, map} from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PostLoginInitializerService {
|
||||
|
||||
private iconService = inject(IconService);
|
||||
|
||||
initialize(): Observable<void> {
|
||||
return forkJoin([
|
||||
this.preloadIcons(),
|
||||
]).pipe(
|
||||
map(() => undefined)
|
||||
);
|
||||
}
|
||||
|
||||
private preloadIcons(): Observable<void> {
|
||||
return this.iconService.preloadAllIcons().pipe(
|
||||
catchError((err) => {
|
||||
console.error('Failed to preload icons:', err);
|
||||
return of(void 0);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {tap} from 'rxjs/operators';
|
||||
import {Book, ReadStatus} from '../model/book.model';
|
||||
import {BookStateService} from './book-state.service';
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
import {ResetProgressType, ResetProgressTypes} from '../../../shared/constants/reset-progress-type';
|
||||
import {BookStatusUpdateResponse, PersonalRatingUpdateResponse} from './book.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BookPatchService {
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/books`;
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private bookStateService = inject(BookStateService);
|
||||
|
||||
updateBookShelves(bookIds: Set<number | undefined>, shelvesToAssign: Set<number | null | undefined>, shelvesToUnassign: Set<number | null | undefined>): Observable<Book[]> {
|
||||
const requestPayload = {
|
||||
bookIds: Array.from(bookIds),
|
||||
shelvesToAssign: Array.from(shelvesToAssign),
|
||||
shelvesToUnassign: Array.from(shelvesToUnassign),
|
||||
};
|
||||
return this.http.post<Book[]>(`${this.url}/shelves`, requestPayload).pipe(
|
||||
tap(updatedBooks => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const currentBooks = currentState.books || [];
|
||||
updatedBooks.forEach(updatedBook => {
|
||||
const index = currentBooks.findIndex(b => b.id === updatedBook.id);
|
||||
if (index !== -1) {
|
||||
currentBooks[index] = updatedBook;
|
||||
}
|
||||
});
|
||||
this.bookStateService.updateBookState({...currentState, books: [...currentBooks]});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
savePdfProgress(bookId: number, page: number, percentage: number): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
pdfProgress: {
|
||||
page: page,
|
||||
percentage: percentage
|
||||
}
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
}
|
||||
|
||||
saveEpubProgress(bookId: number, cfi: string, percentage: number): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
epubProgress: {
|
||||
cfi: cfi,
|
||||
percentage: percentage
|
||||
}
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
}
|
||||
|
||||
saveCbxProgress(bookId: number, page: number, percentage: number): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
cbxProgress: {
|
||||
page: page,
|
||||
percentage: percentage
|
||||
}
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
}
|
||||
|
||||
updateDateFinished(bookId: number, dateFinished: string | null): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
dateFinished: dateFinished
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body).pipe(
|
||||
tap(() => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
if (currentState.books) {
|
||||
const updatedBooks = currentState.books.map(book => {
|
||||
if (book.id === bookId) {
|
||||
return {...book, dateFinished: dateFinished || undefined};
|
||||
}
|
||||
return book;
|
||||
});
|
||||
this.bookStateService.updateBookState({
|
||||
...currentState,
|
||||
books: updatedBooks
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
resetProgress(bookIds: number | number[], type: ResetProgressType): Observable<BookStatusUpdateResponse[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
const params = new HttpParams().set('type', ResetProgressTypes[type]);
|
||||
|
||||
return this.http.post<BookStatusUpdateResponse[]>(`${this.url}/reset-progress`, ids, {params}).pipe(
|
||||
tap(responses => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
const response = responses.find(r => r.bookId === book.id);
|
||||
if (response) {
|
||||
return {
|
||||
...book,
|
||||
readStatus: response.readStatus,
|
||||
readStatusModifiedTime: response.readStatusModifiedTime,
|
||||
dateFinished: response.dateFinished
|
||||
};
|
||||
}
|
||||
return book;
|
||||
});
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
updateBookReadStatus(bookIds: number | number[], status: ReadStatus): Observable<BookStatusUpdateResponse[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
const requestBody = {
|
||||
bookIds: ids,
|
||||
status: status
|
||||
};
|
||||
|
||||
return this.http.post<BookStatusUpdateResponse[]>(`${this.url}/status`, requestBody).pipe(
|
||||
tap(responses => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
const response = responses.find(r => r.bookId === book.id);
|
||||
if (response) {
|
||||
return {
|
||||
...book,
|
||||
readStatus: response.readStatus,
|
||||
readStatusModifiedTime: response.readStatusModifiedTime,
|
||||
dateFinished: response.dateFinished
|
||||
};
|
||||
}
|
||||
return book;
|
||||
});
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
resetPersonalRating(bookIds: number | number[]): Observable<PersonalRatingUpdateResponse[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
|
||||
return this.http.post<PersonalRatingUpdateResponse[]>(`${this.url}/reset-personal-rating`, ids).pipe(
|
||||
tap(responses => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
const response = responses.find(r => r.bookId === book.id);
|
||||
if (response) {
|
||||
return {
|
||||
...book,
|
||||
personalRating: response.personalRating
|
||||
};
|
||||
}
|
||||
return book;
|
||||
});
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
updatePersonalRating(bookIds: number | number[], rating: number): Observable<PersonalRatingUpdateResponse[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
|
||||
return this.http.put<PersonalRatingUpdateResponse[]>(`${this.url}/personal-rating`, {ids, rating}).pipe(
|
||||
tap(responses => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
const response = responses.find(r => r.bookId === book.id);
|
||||
if (response) {
|
||||
return {
|
||||
...book,
|
||||
personalRating: response.personalRating
|
||||
};
|
||||
}
|
||||
return book;
|
||||
});
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
updateLastReadTime(bookId: number): void {
|
||||
const timestamp = new Date().toISOString();
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book =>
|
||||
book.id === bookId ? {...book, lastReadTime: timestamp} : book
|
||||
);
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {BookStateService} from './book-state.service';
|
||||
import {Book, BookMetadata} from '../model/book.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BookSocketService {
|
||||
private bookStateService = inject(BookStateService);
|
||||
|
||||
handleNewlyCreatedBook(book: Book): void {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = currentState.books ? [...currentState.books] : [];
|
||||
const bookIndex = updatedBooks.findIndex(existingBook => existingBook.id === book.id);
|
||||
if (bookIndex > -1) {
|
||||
updatedBooks[bookIndex] = book;
|
||||
} else {
|
||||
updatedBooks.push(book);
|
||||
}
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
handleRemovedBookIds(removedBookIds: number[]): void {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const filteredBooks = (currentState.books || []).filter(book => !removedBookIds.includes(book.id));
|
||||
this.bookStateService.updateBookState({...currentState, books: filteredBooks});
|
||||
}
|
||||
|
||||
handleBookUpdate(updatedBook: Book): void {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book =>
|
||||
book.id === updatedBook.id ? updatedBook : book
|
||||
);
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
handleMultipleBookUpdates(updatedBooks: Book[]): void {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const currentBooks = currentState.books || [];
|
||||
|
||||
const updatedMap = new Map(updatedBooks.map(book => [book.id, book]));
|
||||
|
||||
const mergedBooks = currentBooks.map(book =>
|
||||
updatedMap.has(book.id) ? updatedMap.get(book.id)! : book
|
||||
);
|
||||
|
||||
this.bookStateService.updateBookState({...currentState, books: mergedBooks});
|
||||
}
|
||||
|
||||
handleBookMetadataUpdate(bookId: number, updatedMetadata: BookMetadata): void {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
return book.id === bookId ? {...book, metadata: updatedMetadata} : book;
|
||||
});
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
handleMultipleBookCoverPatches(patches: { id: number; coverUpdatedOn: string }[]): void {
|
||||
if (!patches || patches.length === 0) return;
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const books = currentState.books || [];
|
||||
patches.forEach(p => {
|
||||
const index = books.findIndex(b => b.id === p.id);
|
||||
if (index !== -1 && books[index].metadata) {
|
||||
books[index].metadata.coverUpdatedOn = p.coverUpdatedOn;
|
||||
}
|
||||
});
|
||||
this.bookStateService.updateBookState({...currentState, books});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {BookState} from '../model/state/book-state.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BookStateService {
|
||||
private bookStateSubject = new BehaviorSubject<BookState>({
|
||||
books: null,
|
||||
loaded: false,
|
||||
error: null,
|
||||
});
|
||||
|
||||
public readonly bookState$ = this.bookStateSubject.asObservable();
|
||||
|
||||
getCurrentBookState(): BookState {
|
||||
return this.bookStateSubject.value;
|
||||
}
|
||||
|
||||
updateBookState(state: BookState): void {
|
||||
this.bookStateSubject.next(state);
|
||||
}
|
||||
|
||||
updatePartialBookState(partialState: Partial<BookState>): void {
|
||||
this.bookStateSubject.next({
|
||||
...this.bookStateSubject.value,
|
||||
...partialState
|
||||
});
|
||||
}
|
||||
|
||||
resetBookState(): void {
|
||||
this.bookStateSubject.next({
|
||||
books: null,
|
||||
loaded: true,
|
||||
error: null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,31 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, first, Observable, of, throwError} from 'rxjs';
|
||||
import {first, Observable, of, throwError} from 'rxjs';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {catchError, filter, map, tap, shareReplay, finalize, distinctUntilChanged} from 'rxjs/operators';
|
||||
import {Book, BookDeletionResponse, BookMetadata, BookRecommendation, BookSetting, BulkMetadataUpdateRequest, MetadataUpdateWrapper, ReadStatus, AdditionalFileType, AdditionalFile} from '../model/book.model';
|
||||
import {catchError, distinctUntilChanged, filter, finalize, map, shareReplay, tap} from 'rxjs/operators';
|
||||
import {AdditionalFile, AdditionalFileType, Book, BookDeletionResponse, BookMetadata, BookRecommendation, BookSetting, BulkMetadataUpdateRequest, MetadataUpdateWrapper, ReadStatus} from '../model/book.model';
|
||||
import {BookState} from '../model/state/book-state.model';
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
import {FetchMetadataRequest} from '../../metadata/model/request/fetch-metadata-request.model';
|
||||
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {ResetProgressType, ResetProgressTypes} from '../../../shared/constants/reset-progress-type';
|
||||
import {ResetProgressType} from '../../../shared/constants/reset-progress-type';
|
||||
import {AuthService} from '../../../shared/service/auth.service';
|
||||
import {FileDownloadService} from '../../../shared/service/file-download.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {BookStateService} from './book-state.service';
|
||||
import {BookSocketService} from './book-socket.service';
|
||||
import {BookPatchService} from './book-patch.service';
|
||||
|
||||
export interface BookStatusUpdateResponse {
|
||||
bookId: number;
|
||||
readStatus: ReadStatus;
|
||||
readStatusModifiedTime: string;
|
||||
dateFinished?: string;
|
||||
}
|
||||
|
||||
export interface PersonalRatingUpdateResponse {
|
||||
bookId: number;
|
||||
personalRating?: number;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -25,12 +39,9 @@ export class BookService {
|
||||
private authService = inject(AuthService);
|
||||
private fileDownloadService = inject(FileDownloadService);
|
||||
private router = inject(Router);
|
||||
|
||||
private bookStateSubject = new BehaviorSubject<BookState>({
|
||||
books: null,
|
||||
loaded: false,
|
||||
error: null,
|
||||
});
|
||||
private bookStateService = inject(BookStateService);
|
||||
private bookSocketService = inject(BookSocketService);
|
||||
private bookPatchService = inject(BookPatchService);
|
||||
|
||||
private loading$: Observable<Book[]> | null = null;
|
||||
|
||||
@@ -39,16 +50,12 @@ export class BookService {
|
||||
distinctUntilChanged()
|
||||
).subscribe(token => {
|
||||
if (token === null) {
|
||||
this.bookStateSubject.next({
|
||||
books: null,
|
||||
loaded: true,
|
||||
error: null,
|
||||
});
|
||||
this.bookStateService.resetBookState();
|
||||
this.loading$ = null;
|
||||
} else {
|
||||
const current = this.bookStateSubject.value;
|
||||
const current = this.bookStateService.getCurrentBookState();
|
||||
if (current.loaded && !current.books) {
|
||||
this.bookStateSubject.next({
|
||||
this.bookStateService.updateBookState({
|
||||
books: null,
|
||||
loaded: false,
|
||||
error: null,
|
||||
@@ -59,7 +66,9 @@ export class BookService {
|
||||
});
|
||||
}
|
||||
|
||||
bookState$ = this.bookStateSubject.asObservable().pipe(
|
||||
/*------------------ State Management ------------------*/
|
||||
|
||||
bookState$ = this.bookStateService.bookState$.pipe(
|
||||
tap(state => {
|
||||
if (!state.loaded && !state.error && !this.loading$) {
|
||||
this.loading$ = this.fetchBooks().pipe(
|
||||
@@ -72,21 +81,21 @@ export class BookService {
|
||||
);
|
||||
|
||||
getCurrentBookState(): BookState {
|
||||
return this.bookStateSubject.value;
|
||||
return this.bookStateService.getCurrentBookState();
|
||||
}
|
||||
|
||||
private fetchBooks(): Observable<Book[]> {
|
||||
return this.http.get<Book[]>(this.url).pipe(
|
||||
tap(books => {
|
||||
this.bookStateSubject.next({
|
||||
this.bookStateService.updateBookState({
|
||||
books: books || [],
|
||||
loaded: true,
|
||||
error: null,
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
const curr = this.bookStateSubject.value;
|
||||
this.bookStateSubject.next({
|
||||
const curr = this.bookStateService.getCurrentBookState();
|
||||
this.bookStateService.updateBookState({
|
||||
books: curr.books,
|
||||
loaded: true,
|
||||
error: error.message,
|
||||
@@ -99,14 +108,14 @@ export class BookService {
|
||||
refreshBooks(): void {
|
||||
this.http.get<Book[]>(this.url).pipe(
|
||||
tap(books => {
|
||||
this.bookStateSubject.next({
|
||||
this.bookStateService.updateBookState({
|
||||
books: books || [],
|
||||
loaded: true,
|
||||
error: null,
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.bookStateSubject.next({
|
||||
this.bookStateService.updateBookState({
|
||||
books: null,
|
||||
loaded: true,
|
||||
error: error.message,
|
||||
@@ -116,118 +125,39 @@ export class BookService {
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
removeBooksByLibraryId(libraryId: number): void {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const currentBooks = currentState.books || [];
|
||||
const filteredBooks = currentBooks.filter(book => book.libraryId !== libraryId);
|
||||
this.bookStateService.updateBookState({...currentState, books: filteredBooks});
|
||||
}
|
||||
|
||||
removeBooksFromShelf(shelfId: number): void {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const currentBooks = currentState.books || [];
|
||||
const updatedBooks = currentBooks.map(book => ({
|
||||
...book,
|
||||
shelves: book.shelves?.filter(shelf => shelf.id !== shelfId),
|
||||
}));
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
/*------------------ Book Retrieval ------------------*/
|
||||
|
||||
getBookByIdFromState(bookId: number): Book | undefined {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
return currentState.books?.find(book => +book.id === +bookId);
|
||||
}
|
||||
|
||||
getBooksByIdsFromState(bookIds: number[]): Book[] {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
if (!currentState.books || bookIds.length === 0) return [];
|
||||
|
||||
const idSet = new Set(bookIds.map(id => +id));
|
||||
return currentState.books.filter(book => idSet.has(+book.id));
|
||||
}
|
||||
|
||||
updateBookShelves(bookIds: Set<number | undefined>, shelvesToAssign: Set<number | null | undefined>, shelvesToUnassign: Set<number | null | undefined>): Observable<Book[]> {
|
||||
const requestPayload = {
|
||||
bookIds: Array.from(bookIds),
|
||||
shelvesToAssign: Array.from(shelvesToAssign),
|
||||
shelvesToUnassign: Array.from(shelvesToUnassign),
|
||||
};
|
||||
return this.http.post<Book[]>(`${this.url}/shelves`, requestPayload).pipe(
|
||||
map(updatedBooks => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentBooks = currentState.books || [];
|
||||
updatedBooks.forEach(updatedBook => {
|
||||
const index = currentBooks.findIndex(b => b.id === updatedBook.id);
|
||||
if (index !== -1) {
|
||||
currentBooks[index] = updatedBook;
|
||||
}
|
||||
});
|
||||
this.bookStateSubject.next({...currentState, books: [...currentBooks]});
|
||||
return updatedBooks;
|
||||
}),
|
||||
catchError(error => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
this.bookStateSubject.next({...currentState, error: error.message});
|
||||
throw error;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
removeBooksByLibraryId(libraryId: number): void {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentBooks = currentState.books || [];
|
||||
const filteredBooks = currentBooks.filter(book => book.libraryId !== libraryId);
|
||||
this.bookStateSubject.next({...currentState, books: filteredBooks});
|
||||
}
|
||||
|
||||
removeBooksFromShelf(shelfId: number): void {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentBooks = currentState.books || [];
|
||||
const updatedBooks = currentBooks.map(book => ({
|
||||
...book,
|
||||
shelves: book.shelves?.filter(shelf => shelf.id !== shelfId),
|
||||
}));
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
getBookSetting(bookId: number): Observable<BookSetting> {
|
||||
return this.http.get<BookSetting>(`${this.url}/${bookId}/viewer-setting`);
|
||||
}
|
||||
|
||||
updateViewerSetting(bookSetting: BookSetting, bookId: number): Observable<void> {
|
||||
return this.http.put<void>(`${this.url}/${bookId}/viewer-setting`, bookSetting);
|
||||
}
|
||||
|
||||
updateLastReadTime(bookId: number) {
|
||||
const timestamp = new Date().toISOString();
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const updatedBooks = (currentState.books || []).map(book =>
|
||||
book.id === bookId ? {...book, lastReadTime: timestamp} : book
|
||||
);
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
readBook(bookId: number, reader?: 'ngx' | 'streaming'): void {
|
||||
const book = this.bookStateSubject.value.books?.find(b => b.id === bookId);
|
||||
if (!book) {
|
||||
console.error('Book not found');
|
||||
return;
|
||||
}
|
||||
|
||||
let url: string;
|
||||
|
||||
switch (book.bookType) {
|
||||
case 'PDF':
|
||||
url = !reader || reader === 'ngx'
|
||||
? `/pdf-reader/book/${book.id}`
|
||||
: `/cbx-reader/book/${book.id}`;
|
||||
break;
|
||||
|
||||
case 'EPUB':
|
||||
url = `/epub-reader/book/${book.id}`;
|
||||
break;
|
||||
|
||||
case 'CBX':
|
||||
url = `/cbx-reader/book/${book.id}`;
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error('Unsupported book type:', book.bookType);
|
||||
return;
|
||||
}
|
||||
|
||||
this.router.navigate([url]);
|
||||
this.updateLastReadTime(book.id);
|
||||
}
|
||||
|
||||
getFileContent(bookId: number): Observable<Blob> {
|
||||
return this.http.get<Blob>(`${this.url}/${bookId}/content`, {responseType: 'blob' as 'json'});
|
||||
}
|
||||
|
||||
getBookByIdFromAPI(bookId: number, withDescription: boolean) {
|
||||
getBookByIdFromAPI(bookId: number, withDescription: boolean): Observable<Book> {
|
||||
return this.http.get<Book>(`${this.url}/${bookId}`, {
|
||||
params: {
|
||||
withDescription: withDescription.toString()
|
||||
@@ -235,18 +165,44 @@ export class BookService {
|
||||
});
|
||||
}
|
||||
|
||||
getBooksInSeries(bookId: number): Observable<Book[]> {
|
||||
return this.bookStateService.bookState$.pipe(
|
||||
filter(state => state.loaded),
|
||||
first(),
|
||||
map(state => {
|
||||
const allBooks = state.books || [];
|
||||
const currentBook = allBooks.find(b => b.id === bookId);
|
||||
|
||||
if (!currentBook || !currentBook.metadata?.seriesName) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const seriesName = currentBook.metadata.seriesName.toLowerCase();
|
||||
return allBooks.filter(b => b.metadata?.seriesName?.toLowerCase() === seriesName);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
getBookRecommendations(bookId: number, limit: number = 20): Observable<BookRecommendation[]> {
|
||||
return this.http.get<BookRecommendation[]>(`${this.url}/${bookId}/recommendations`, {
|
||||
params: {limit: limit.toString()}
|
||||
});
|
||||
}
|
||||
|
||||
/*------------------ Book Operations ------------------*/
|
||||
|
||||
deleteBooks(ids: Set<number>): Observable<BookDeletionResponse> {
|
||||
const idList = Array.from(ids);
|
||||
const params = new HttpParams().set('ids', idList.join(','));
|
||||
|
||||
return this.http.delete<BookDeletionResponse>(this.url, {params}).pipe(
|
||||
tap(response => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const remainingBooks = (currentState.books || []).filter(
|
||||
book => !ids.has(book.id)
|
||||
);
|
||||
|
||||
this.bookStateSubject.next({
|
||||
this.bookStateService.updateBookState({
|
||||
books: remainingBooks,
|
||||
loaded: true,
|
||||
error: null,
|
||||
@@ -277,11 +233,72 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
updateBookShelves(bookIds: Set<number | undefined>, shelvesToAssign: Set<number | null | undefined>, shelvesToUnassign: Set<number | null | undefined>): Observable<Book[]> {
|
||||
return this.bookPatchService.updateBookShelves(bookIds, shelvesToAssign, shelvesToUnassign).pipe(
|
||||
catchError(error => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
this.bookStateService.updateBookState({...currentState, error: error.message});
|
||||
throw error;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/*------------------ Reading & Viewer Settings ------------------*/
|
||||
|
||||
readBook(bookId: number, reader: 'ngx' | 'streaming' = 'ngx'): void {
|
||||
const book = this.bookStateService
|
||||
.getCurrentBookState()
|
||||
.books?.find(b => b.id === bookId);
|
||||
|
||||
if (!book) {
|
||||
console.error('Book not found');
|
||||
return;
|
||||
}
|
||||
|
||||
const baseUrl =
|
||||
book.bookType === 'PDF'
|
||||
? reader === 'ngx'
|
||||
? 'pdf-reader'
|
||||
: 'cbx-reader'
|
||||
: book.bookType === 'EPUB'
|
||||
? 'epub-reader'
|
||||
: book.bookType === 'CBX'
|
||||
? 'cbx-reader'
|
||||
: null;
|
||||
|
||||
if (!baseUrl) {
|
||||
console.error('Unsupported book type:', book.bookType);
|
||||
return;
|
||||
}
|
||||
|
||||
this.router.navigate([`/${baseUrl}/book/${book.id}`]);
|
||||
this.updateLastReadTime(book.id);
|
||||
}
|
||||
|
||||
getBookSetting(bookId: number): Observable<BookSetting> {
|
||||
return this.http.get<BookSetting>(`${this.url}/${bookId}/viewer-setting`);
|
||||
}
|
||||
|
||||
updateViewerSetting(bookSetting: BookSetting, bookId: number): Observable<void> {
|
||||
return this.http.put<void>(`${this.url}/${bookId}/viewer-setting`, bookSetting);
|
||||
}
|
||||
|
||||
/*------------------ File Operations ------------------*/
|
||||
|
||||
getFileContent(bookId: number): Observable<Blob> {
|
||||
return this.http.get<Blob>(`${this.url}/${bookId}/content`, {responseType: 'blob' as 'json'});
|
||||
}
|
||||
|
||||
downloadFile(book: Book): void {
|
||||
const downloadUrl = `${this.url}/${book.id}/download`;
|
||||
this.fileDownloadService.downloadFile(downloadUrl, book.fileName!);
|
||||
}
|
||||
|
||||
deleteAdditionalFile(bookId: number, fileId: number): Observable<void> {
|
||||
const deleteUrl = `${this.url}/${bookId}/files/${fileId}`;
|
||||
return this.http.delete<void>(deleteUrl).pipe(
|
||||
tap(() => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
if (book.id === bookId) {
|
||||
return {
|
||||
@@ -293,7 +310,7 @@ export class BookService {
|
||||
return book;
|
||||
});
|
||||
|
||||
this.bookStateSubject.next({
|
||||
this.bookStateService.updateBookState({
|
||||
...currentState,
|
||||
books: updatedBooks
|
||||
});
|
||||
@@ -325,7 +342,7 @@ export class BookService {
|
||||
|
||||
return this.http.post<AdditionalFile>(`${this.url}/${bookId}/files`, formData).pipe(
|
||||
tap((newFile) => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
if (book.id === bookId) {
|
||||
const updatedBook = {...book};
|
||||
@@ -339,7 +356,7 @@ export class BookService {
|
||||
return book;
|
||||
});
|
||||
|
||||
this.bookStateSubject.next({
|
||||
this.bookStateService.updateBookState({
|
||||
...currentState,
|
||||
books: updatedBooks
|
||||
});
|
||||
@@ -361,96 +378,53 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
downloadFile(book: Book): void {
|
||||
const downloadUrl = `${this.url}/${book.id}/download`;
|
||||
this.fileDownloadService.downloadFile(downloadUrl, book.fileName!);
|
||||
}
|
||||
|
||||
downloadAdditionalFile(book: Book, fileId: number): void {
|
||||
const additionalFile = book.alternativeFormats!.find((f: AdditionalFile) => f.id === fileId);
|
||||
const downloadUrl = `${this.url}/${additionalFile!.id}/files/${fileId}/download`;
|
||||
this.fileDownloadService.downloadFile(downloadUrl, additionalFile!.fileName!);
|
||||
}
|
||||
|
||||
/*------------------ Progress & Status Tracking ------------------*/
|
||||
|
||||
updateLastReadTime(bookId: number): void {
|
||||
this.bookPatchService.updateLastReadTime(bookId);
|
||||
}
|
||||
|
||||
savePdfProgress(bookId: number, page: number, percentage: number): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
pdfProgress: {
|
||||
page: page,
|
||||
percentage: percentage
|
||||
}
|
||||
}
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
return this.bookPatchService.savePdfProgress(bookId, page, percentage);
|
||||
}
|
||||
|
||||
saveEpubProgress(bookId: number, cfi: string, percentage: number): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
epubProgress: {
|
||||
cfi: cfi,
|
||||
percentage: percentage
|
||||
}
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
return this.bookPatchService.saveEpubProgress(bookId, cfi, percentage);
|
||||
}
|
||||
|
||||
saveCbxProgress(bookId: number, page: number, percentage: number): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
cbxProgress: {
|
||||
page: page,
|
||||
percentage: percentage
|
||||
}
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
return this.bookPatchService.saveCbxProgress(bookId, page, percentage);
|
||||
}
|
||||
|
||||
updateDateFinished(bookId: number, dateFinished: string | null): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
dateFinished: dateFinished
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body).pipe(
|
||||
tap(() => {
|
||||
// Update the book in the state
|
||||
const currentState = this.bookStateSubject.value;
|
||||
if (currentState.books) {
|
||||
const updatedBooks = currentState.books.map(book => {
|
||||
if (book.id === bookId) {
|
||||
return {...book, dateFinished: dateFinished || undefined};
|
||||
}
|
||||
return book;
|
||||
});
|
||||
this.bookStateSubject.next({
|
||||
...currentState,
|
||||
books: updatedBooks
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
return this.bookPatchService.updateDateFinished(bookId, dateFinished);
|
||||
}
|
||||
|
||||
regenerateCovers(): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/regenerate-covers`, {});
|
||||
resetProgress(bookIds: number | number[], type: ResetProgressType): Observable<BookStatusUpdateResponse[]> {
|
||||
return this.bookPatchService.resetProgress(bookIds, type);
|
||||
}
|
||||
|
||||
regenerateCover(bookId: number): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/${bookId}/regenerate-cover`, {});
|
||||
updateBookReadStatus(bookIds: number | number[], status: ReadStatus): Observable<BookStatusUpdateResponse[]> {
|
||||
return this.bookPatchService.updateBookReadStatus(bookIds, status);
|
||||
}
|
||||
|
||||
regenerateCoversForBooks(bookIds: number[]): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/bulk-regenerate-covers`, { bookIds });
|
||||
/*------------------ Personal Rating ------------------*/
|
||||
|
||||
resetPersonalRating(bookIds: number | number[]): Observable<PersonalRatingUpdateResponse[]> {
|
||||
return this.bookPatchService.resetPersonalRating(bookIds);
|
||||
}
|
||||
|
||||
bulkUploadCover(bookIds: number[], file: File): Observable<void> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('bookIds', bookIds.join(','));
|
||||
return this.http.post<void>(`${this.url}/bulk-upload-cover`, formData);
|
||||
updatePersonalRating(bookIds: number | number[], rating: number): Observable<PersonalRatingUpdateResponse[]> {
|
||||
return this.bookPatchService.updatePersonalRating(bookIds, rating);
|
||||
}
|
||||
|
||||
|
||||
/*------------------ All the metadata related calls go here ------------------*/
|
||||
/*------------------ Metadata Operations ------------------*/
|
||||
|
||||
fetchBookMetadata(bookId: number, request: FetchMetadataRequest): Observable<BookMetadata[]> {
|
||||
return this.http.post<BookMetadata[]>(`${this.url}/${bookId}/metadata/prospective`, request);
|
||||
@@ -458,12 +432,7 @@ export class BookService {
|
||||
|
||||
updateBookMetadata(bookId: number | undefined, wrapper: MetadataUpdateWrapper, mergeCategories: boolean): Observable<BookMetadata> {
|
||||
const params = new HttpParams().set('mergeCategories', mergeCategories.toString());
|
||||
return this.http.put<BookMetadata>(`${this.url}/${bookId}/metadata`, wrapper, {params}).pipe(
|
||||
map(updatedMetadata => {
|
||||
this.handleBookMetadataUpdate(bookId!, updatedMetadata);
|
||||
return updatedMetadata;
|
||||
})
|
||||
);
|
||||
return this.http.put<BookMetadata>(`${this.url}/${bookId}/metadata`, wrapper, {params});
|
||||
}
|
||||
|
||||
updateBooksMetadata(request: BulkMetadataUpdateRequest): Observable<void> {
|
||||
@@ -479,12 +448,12 @@ export class BookService {
|
||||
};
|
||||
return this.http.put<BookMetadata[]>(`${this.url}/metadata/toggle-all-lock`, requestBody).pipe(
|
||||
tap((updatedMetadataList) => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
const updatedMetadata = updatedMetadataList.find(meta => meta.bookId === book.id);
|
||||
return updatedMetadata ? {...book, metadata: updatedMetadata} : book;
|
||||
});
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
|
||||
}),
|
||||
map(() => void 0),
|
||||
catchError((error) => {
|
||||
@@ -493,73 +462,43 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
getUploadCoverUrl(bookId: number): string {
|
||||
return this.url + '/' + bookId + "/metadata/cover/upload"
|
||||
}
|
||||
toggleFieldLocks(bookIds: number[] | Set<number>, fieldActions: Record<string, 'LOCK' | 'UNLOCK'>): Observable<void> {
|
||||
const bookIdSet = bookIds instanceof Set ? bookIds : new Set(bookIds);
|
||||
|
||||
uploadCoverFromUrl(bookId: number, url: string): Observable<BookMetadata> {
|
||||
return this.http
|
||||
.post<BookMetadata>(`${this.url}/${bookId}/metadata/cover/from-url`, {url})
|
||||
.pipe(
|
||||
tap(updatedMetadata =>
|
||||
this.handleBookMetadataUpdate(bookId, updatedMetadata)
|
||||
)
|
||||
);
|
||||
}
|
||||
const requestBody = {
|
||||
bookIds: Array.from(bookIdSet),
|
||||
fieldActions
|
||||
};
|
||||
|
||||
getBookRecommendations(bookId: number, limit: number = 20): Observable<BookRecommendation[]> {
|
||||
return this.http.get<BookRecommendation[]>(`${this.url}/${bookId}/recommendations`, {
|
||||
params: {limit: limit.toString()}
|
||||
});
|
||||
}
|
||||
|
||||
getBooksInSeries(bookId: number): Observable<Book[]> {
|
||||
return this.bookStateSubject.asObservable().pipe(
|
||||
filter(state => state.loaded),
|
||||
first(),
|
||||
map(state => {
|
||||
const allBooks = state.books || [];
|
||||
const currentBook = allBooks.find(b => b.id === bookId);
|
||||
|
||||
if (!currentBook || !currentBook.metadata?.seriesName) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const seriesName = currentBook.metadata.seriesName.toLowerCase();
|
||||
return allBooks.filter(b => b.metadata?.seriesName?.toLowerCase() === seriesName);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
resetProgress(bookIds: number | number[], type: ResetProgressType): Observable<Book[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
const params = new HttpParams().set('type', ResetProgressTypes[type]);
|
||||
return this.http.post<Book[]>(`${this.url}/reset-progress`, ids, {params}).pipe(
|
||||
tap(updatedBooks => updatedBooks.forEach(book => this.handleBookUpdate(book)))
|
||||
);
|
||||
}
|
||||
|
||||
updateBookReadStatus(bookIds: number | number[], status: ReadStatus): Observable<Book[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
return this.http.put<Book[]>(`${this.url}/read-status`, {ids, status}).pipe(
|
||||
tap(updatedBooks => {
|
||||
updatedBooks.forEach(updatedBook => this.handleBookUpdate(updatedBook));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
resetPersonalRating(bookIds: number | number[]): Observable<Book[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
return this.http.post<Book[]>(`${this.url}/reset-personal-rating`, ids).pipe(
|
||||
tap(updatedBooks => updatedBooks.forEach(book => this.handleBookUpdate(book)))
|
||||
);
|
||||
}
|
||||
|
||||
updatePersonalRating(bookIds: number | number[], rating: number): Observable<Book[]> {
|
||||
const ids = Array.isArray(bookIds) ? bookIds : [bookIds];
|
||||
return this.http.put<Book[]>(`${this.url}/personal-rating`, {ids, rating}).pipe(
|
||||
tap(updatedBooks => {
|
||||
updatedBooks.forEach(updatedBook => this.handleBookUpdate(updatedBook));
|
||||
return this.http.put<void>(`${this.url}/metadata/toggle-field-locks`, requestBody).pipe(
|
||||
tap(() => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
if (!bookIdSet.has(book.id)) return book;
|
||||
const updatedMetadata = {...book.metadata};
|
||||
for (const [field, action] of Object.entries(fieldActions)) {
|
||||
const lockField = field.endsWith('Locked') ? field : `${field}Locked`;
|
||||
if (lockField in updatedMetadata) {
|
||||
(updatedMetadata as any)[lockField] = action === 'LOCK';
|
||||
}
|
||||
}
|
||||
return {
|
||||
...book,
|
||||
metadata: updatedMetadata
|
||||
};
|
||||
});
|
||||
this.bookStateService.updateBookState({
|
||||
...currentState,
|
||||
books: updatedBooks as Book[]
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Field Lock Update Failed',
|
||||
detail: 'Failed to update metadata field locks. Please try again.',
|
||||
});
|
||||
throw error;
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -582,113 +521,64 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
/*------------------ Cover Operations ------------------*/
|
||||
|
||||
/*------------------ All the websocket handlers go below ------------------*/
|
||||
getUploadCoverUrl(bookId: number): string {
|
||||
return this.url + '/' + bookId + "/metadata/cover/upload"
|
||||
}
|
||||
|
||||
uploadCoverFromUrl(bookId: number, url: string): Observable<BookMetadata> {
|
||||
return this.http
|
||||
.post<BookMetadata>(`${this.url}/${bookId}/metadata/cover/from-url`, {url})
|
||||
.pipe(
|
||||
tap(updatedMetadata =>
|
||||
this.handleBookMetadataUpdate(bookId, updatedMetadata)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
regenerateCovers(): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/regenerate-covers`, {});
|
||||
}
|
||||
|
||||
regenerateCover(bookId: number): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/${bookId}/regenerate-cover`, {});
|
||||
}
|
||||
|
||||
regenerateCoversForBooks(bookIds: number[]): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/bulk-regenerate-covers`, {bookIds});
|
||||
}
|
||||
|
||||
bulkUploadCover(bookIds: number[], file: File): Observable<void> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('bookIds', bookIds.join(','));
|
||||
return this.http.post<void>(`${this.url}/bulk-upload-cover`, formData);
|
||||
}
|
||||
|
||||
/*------------------ Websocket Handlers ------------------*/
|
||||
|
||||
handleNewlyCreatedBook(book: Book): void {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const updatedBooks = currentState.books ? [...currentState.books] : [];
|
||||
const bookIndex = updatedBooks.findIndex(existingBook => existingBook.id === book.id);
|
||||
if (bookIndex > -1) {
|
||||
updatedBooks[bookIndex] = book;
|
||||
} else {
|
||||
updatedBooks.push(book);
|
||||
}
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
this.bookSocketService.handleNewlyCreatedBook(book);
|
||||
}
|
||||
|
||||
handleRemovedBookIds(removedBookIds: number[]): void {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const filteredBooks = (currentState.books || []).filter(book => !removedBookIds.includes(book.id));
|
||||
this.bookStateSubject.next({...currentState, books: filteredBooks});
|
||||
this.bookSocketService.handleRemovedBookIds(removedBookIds);
|
||||
}
|
||||
|
||||
handleBookUpdate(updatedBook: Book) {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const updatedBooks = (currentState.books || []).map(book =>
|
||||
book.id === updatedBook.id ? updatedBook : book
|
||||
);
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
handleBookUpdate(updatedBook: Book): void {
|
||||
this.bookSocketService.handleBookUpdate(updatedBook);
|
||||
}
|
||||
|
||||
handleMultipleBookUpdates(updatedBooks: Book[]): void {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentBooks = currentState.books || [];
|
||||
|
||||
const updatedMap = new Map(updatedBooks.map(book => [book.id, book]));
|
||||
|
||||
const mergedBooks = currentBooks.map(book =>
|
||||
updatedMap.has(book.id) ? updatedMap.get(book.id)! : book
|
||||
);
|
||||
|
||||
this.bookStateSubject.next({...currentState, books: mergedBooks});
|
||||
this.bookSocketService.handleMultipleBookUpdates(updatedBooks);
|
||||
}
|
||||
|
||||
handleBookMetadataUpdate(bookId: number, updatedMetadata: BookMetadata) {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
return book.id == bookId ? {...book, metadata: updatedMetadata} : book
|
||||
});
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks})
|
||||
handleBookMetadataUpdate(bookId: number, updatedMetadata: BookMetadata): void {
|
||||
this.bookSocketService.handleBookMetadataUpdate(bookId, updatedMetadata);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Incoming payload: [{ id: number, coverUpdatedOn: "2025-12-25T00:48:17Z" }, ...]
|
||||
* Apply minimal patch to local state so UI updates the cover image (and can use cache-busting).
|
||||
*/
|
||||
handleMultipleBookCoverPatches(patches: { id: number; coverUpdatedOn: string }[]): void {
|
||||
if (!patches || patches.length === 0) return;
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const books = currentState.books || [];
|
||||
patches.forEach(p => {
|
||||
const index = books.findIndex(b=>b.id === p.id);
|
||||
if (index !== -1 && books[index].metadata) {
|
||||
books[index].metadata.coverUpdatedOn = p.coverUpdatedOn;
|
||||
}
|
||||
});
|
||||
this.bookStateSubject.next({...currentState, books});
|
||||
this.bookSocketService.handleMultipleBookCoverPatches(patches);
|
||||
}
|
||||
|
||||
toggleFieldLocks(bookIds: number[] | Set<number>, fieldActions: Record<string, 'LOCK' | 'UNLOCK'>): Observable<void> {
|
||||
const bookIdSet = bookIds instanceof Set ? bookIds : new Set(bookIds);
|
||||
|
||||
const requestBody = {
|
||||
bookIds: Array.from(bookIdSet),
|
||||
fieldActions
|
||||
};
|
||||
|
||||
return this.http.put<void>(`${this.url}/metadata/toggle-field-locks`, requestBody).pipe(
|
||||
tap(() => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
if (!bookIdSet.has(book.id)) return book;
|
||||
const updatedMetadata = {...book.metadata};
|
||||
for (const [field, action] of Object.entries(fieldActions)) {
|
||||
const lockField = field.endsWith('Locked') ? field : `${field}Locked`;
|
||||
if (lockField in updatedMetadata) {
|
||||
(updatedMetadata as any)[lockField] = action === 'LOCK';
|
||||
}
|
||||
}
|
||||
return {
|
||||
...book,
|
||||
metadata: updatedMetadata
|
||||
};
|
||||
});
|
||||
this.bookStateSubject.next({
|
||||
...currentState,
|
||||
books: updatedBooks as Book[]
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Field Lock Update Failed',
|
||||
detail: 'Failed to update metadata field locks. Please try again.',
|
||||
});
|
||||
throw error;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+28
@@ -213,5 +213,33 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Telemetry Setting Section -->
|
||||
<div class="preferences-section">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-chart-bar"></i>
|
||||
Telemetry
|
||||
<app-external-doc-link docType="telemetry"></app-external-doc-link>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="settings-card">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Enable Telemetry</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="toggles.enableTelemetry"
|
||||
(onChange)="onToggleChange('enableTelemetry', $event.checked)">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Help improve Booklore by sharing anonymous usage statistics. This data lets the developers see which features are most used, identify bugs, and spot performance issues so they know what to work on next. No personal information, book content, or any identifiable data is ever sent. Data
|
||||
is sent to the Booklore server automatically once every 24 hours. It’s completely safe and very helpful to the developers. </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+6
-1
@@ -11,6 +11,7 @@ import {AppSettingKey, AppSettings, CoverCroppingSettings} from '../../../shared
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Slider} from 'primeng/slider';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-global-preferences',
|
||||
@@ -20,7 +21,8 @@ import {Slider} from 'primeng/slider';
|
||||
ToggleSwitch,
|
||||
FormsModule,
|
||||
InputText,
|
||||
Slider
|
||||
Slider,
|
||||
ExternalDocLinkComponent
|
||||
],
|
||||
templateUrl: './global-preferences.component.html',
|
||||
styleUrl: './global-preferences.component.scss'
|
||||
@@ -30,6 +32,7 @@ export class GlobalPreferencesComponent implements OnInit {
|
||||
toggles = {
|
||||
autoBookSearch: false,
|
||||
similarBookRecommendation: false,
|
||||
enableTelemetry: true,
|
||||
};
|
||||
|
||||
coverCroppingSettings: CoverCroppingSettings = {
|
||||
@@ -63,6 +66,7 @@ export class GlobalPreferencesComponent implements OnInit {
|
||||
}
|
||||
this.toggles.autoBookSearch = settings.autoBookSearch ?? false;
|
||||
this.toggles.similarBookRecommendation = settings.similarBookRecommendation ?? false;
|
||||
this.toggles.enableTelemetry = settings?.telemetryEnabled ?? true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,6 +75,7 @@ export class GlobalPreferencesComponent implements OnInit {
|
||||
const toggleKeyMap: Record<string, AppSettingKey> = {
|
||||
autoBookSearch: AppSettingKey.AUTO_BOOK_SEARCH,
|
||||
similarBookRecommendation: AppSettingKey.SIMILAR_BOOK_RECOMMENDATION,
|
||||
enableTelemetry: AppSettingKey.TELEMETRY_ENABLED,
|
||||
};
|
||||
const keyToSend = toggleKeyMap[settingKey];
|
||||
if (keyToSend) {
|
||||
|
||||
+13
-15
@@ -13,10 +13,17 @@ interface ReadingStatusStats {
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
const CHART_COLORS = [
|
||||
'#28a745', '#17a2b8', '#ffc107', '#6f42c1',
|
||||
'#fd7e14', '#6c757d', '#dc3545', '#343a40', '#e9ecef'
|
||||
] as const;
|
||||
const STATUS_COLOR_MAP: Record<string, string> = {
|
||||
'Unread': '#6c757d', // Gray
|
||||
'Currently Reading': '#17a2b8', // Cyan
|
||||
'Re-reading': '#6f42c1', // Purple
|
||||
'Read': '#28a745', // Green
|
||||
'Partially Read': '#ffc107', // Yellow
|
||||
'Paused': '#fd7e14', // Orange
|
||||
"Won't Read": '#dc3545', // Red
|
||||
'Abandoned': '#e74c3c', // Light Red
|
||||
'No Status': '#343a40' // Dark Gray
|
||||
} as const;
|
||||
|
||||
const CHART_DEFAULTS = {
|
||||
borderColor: '#ffffff',
|
||||
@@ -89,7 +96,7 @@ export class ReadStatusChartComponent implements OnInit, OnDestroy {
|
||||
labels: [],
|
||||
datasets: [{
|
||||
data: [],
|
||||
backgroundColor: [...CHART_COLORS],
|
||||
backgroundColor: [...Object.values(STATUS_COLOR_MAP)],
|
||||
...CHART_DEFAULTS
|
||||
}]
|
||||
});
|
||||
@@ -122,7 +129,7 @@ export class ReadStatusChartComponent implements OnInit, OnDestroy {
|
||||
try {
|
||||
const labels = stats.map(s => s.status);
|
||||
const dataValues = stats.map(s => s.count);
|
||||
const colors = this.getColorsForData(stats.length);
|
||||
const colors = stats.map(s => STATUS_COLOR_MAP[s.status] || '#6c757d');
|
||||
|
||||
this.chartDataSubject.next({
|
||||
labels,
|
||||
@@ -137,14 +144,6 @@ export class ReadStatusChartComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
private getColorsForData(dataLength: number): string[] {
|
||||
const colors = [...CHART_COLORS];
|
||||
while (colors.length < dataLength) {
|
||||
colors.push(...CHART_COLORS);
|
||||
}
|
||||
return colors.slice(0, dataLength);
|
||||
}
|
||||
|
||||
private calculateReadingStatusStats(): ReadingStatusStats[] {
|
||||
const currentState = this.bookService.getCurrentBookState();
|
||||
|
||||
@@ -246,4 +245,3 @@ export class ReadStatusChartComponent implements OnInit, OnDestroy {
|
||||
return `${label}: ${value} books (${percentage}%)`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -14,7 +14,12 @@ interface ReadingProgressStats {
|
||||
}
|
||||
|
||||
const CHART_COLORS = [
|
||||
'#6c757d', '#ffc107', '#fd7e14', '#17a2b8', '#6f42c1', '#28a745'
|
||||
'#6c757d', // Gray - Not Started (0%)
|
||||
'#ffc107', // Yellow - Just Started (1-25%)
|
||||
'#fd7e14', // Orange - Getting Into It (26-50%)
|
||||
'#17a2b8', // Cyan - Halfway Through (51-75%)
|
||||
'#6f42c1', // Purple - Almost Finished (76-99%)
|
||||
'#28a745' // Green - Completed (100%)
|
||||
] as const;
|
||||
|
||||
const CHART_DEFAULTS = {
|
||||
|
||||
+2
-1
@@ -3,7 +3,7 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
|
||||
export type DocType = 'kobo' | 'opds' | 'metadataManager' | 'koReader' | 'email'
|
||||
| 'amazonCookie' | 'fetchConfig' | 'hardcover' | 'taskManagement' | 'fileNamePatterns'
|
||||
| 'authentication';
|
||||
| 'authentication' | 'telemetry';
|
||||
|
||||
@Component({
|
||||
selector: 'app-external-doc-link',
|
||||
@@ -39,6 +39,7 @@ export class ExternalDocLinkComponent {
|
||||
taskManagement: `${this.BASE_URL}/tools/task-manager`,
|
||||
fileNamePatterns: `${this.BASE_URL}/metadata/file-naming-patterns`,
|
||||
authentication: `${this.BASE_URL}/authentication/overview#setting-up-oidc`,
|
||||
telemetry: `${this.BASE_URL}/tools/telemetry`
|
||||
};
|
||||
|
||||
@Input() docType!: DocType;
|
||||
|
||||
@@ -12,7 +12,7 @@ import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
|
||||
template: `
|
||||
@if (icon) {
|
||||
@if (icon.type === 'PRIME_NG') {
|
||||
<i [class]="getPrimeNgIconClass(icon.value)" [ngClass]="iconClass" [ngStyle]="iconStyle"></i>
|
||||
<i [class]="getPrimeNgIconClass(icon.value)" [ngClass]="iconClass" [ngStyle]="getPrimeNgStyle()"></i>
|
||||
} @else {
|
||||
<div
|
||||
class="svg-icon-inline"
|
||||
@@ -67,7 +67,7 @@ export class IconDisplayComponent implements OnInit, OnChanges {
|
||||
const previousIcon = changes['icon'].previousValue;
|
||||
|
||||
if (currentIcon?.type === 'CUSTOM_SVG' &&
|
||||
currentIcon?.value !== previousIcon?.value) {
|
||||
currentIcon?.value !== previousIcon?.value) {
|
||||
this.loadIconIfNeeded();
|
||||
}
|
||||
}
|
||||
@@ -114,4 +114,20 @@ export class IconDisplayComponent implements OnInit, OnChanges {
|
||||
...this.iconStyle
|
||||
};
|
||||
}
|
||||
|
||||
getPrimeNgStyle(): Record<string, string> {
|
||||
const fontSize = this.size.endsWith('px')
|
||||
? `${parseInt(this.size) * 0.85}px`
|
||||
: `calc(${this.size} * 0.85)`;
|
||||
|
||||
return {
|
||||
fontSize: fontSize,
|
||||
width: this.size,
|
||||
height: this.size,
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
...this.iconStyle
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,16 +44,20 @@
|
||||
@if (versionInfo) {
|
||||
<div style="margin-top: auto;" class="p-4 text-center w-full text-sm">
|
||||
<div class="text-gray-200">
|
||||
<a
|
||||
[href]="getVersionUrl(versionInfo.current)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="hover:underline hover:text-gray-100 text-sm"
|
||||
>
|
||||
{{ versionInfo.current }}
|
||||
</a>
|
||||
@if (isSemanticVersion(versionInfo.current)) {
|
||||
<a
|
||||
[href]="getVersionUrl(versionInfo.current)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="hover:underline hover:text-gray-100 text-sm"
|
||||
>
|
||||
{{ versionInfo.current }}
|
||||
</a>
|
||||
} @else {
|
||||
<span class="text-sm">{{ versionInfo.current }}</span>
|
||||
}
|
||||
</div>
|
||||
@if (versionInfo.latest && versionInfo.latest !== versionInfo.current) {
|
||||
@if (isSemanticVersion(versionInfo.current) && versionInfo.latest && versionInfo.latest !== versionInfo.current) {
|
||||
<div>
|
||||
<a
|
||||
(click)="openChangelogDialog()"
|
||||
|
||||
@@ -208,6 +208,12 @@ export class AppMenuComponent implements OnInit {
|
||||
: `https://github.com/booklore-app/booklore/commit/${version}`;
|
||||
}
|
||||
|
||||
isSemanticVersion(version: string | undefined): boolean {
|
||||
if (!version) return false;
|
||||
const semanticVersionPattern = /^v\d+\.\d+\.\d+$/;
|
||||
return semanticVersionPattern.test(version);
|
||||
}
|
||||
|
||||
private sortArray<T>(array: T[], field: 'name' | 'id', order: 'asc' | 'desc'): T[] {
|
||||
return [...array].sort((a, b) => {
|
||||
const aVal = (a as any)[field] ?? '';
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<app-icon-display
|
||||
[icon]="getIconSelection()"
|
||||
iconClass="layout-menuitem-icon"
|
||||
size="16px"
|
||||
size="18px"
|
||||
></app-icon-display>
|
||||
<span class="layout-menuitem-text menu-item-text">
|
||||
{{ item.label }}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin-left: 0.5rem;
|
||||
margin-left: 0.35rem;
|
||||
}
|
||||
|
||||
.menu-item-end-content {
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
}
|
||||
|
||||
@if (!loading && changelog.length > 0) {
|
||||
<div class="space-y-6 p-4 max-h-[70vh] overflow-auto">
|
||||
<div class="space-y-6 p-4 overflow-auto">
|
||||
@for (release of changelog; track release) {
|
||||
<div class="border-b pb-4">
|
||||
<p class="font-bold text-2xl pb-2">
|
||||
|
||||
+12
-2
@@ -59,7 +59,12 @@
|
||||
(click)="shouldShowStatsMenu ? statsMenu.toggle($event) : handleStatsButtonClick($event)"
|
||||
[pTooltip]="statsTooltip"
|
||||
tooltipPosition="bottom">
|
||||
<i class="pi pi-chart-bar text-surface-100"></i>
|
||||
<svg class="multi-color-chart-icon" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="1.25" y="10" width="2.5" height="9" rx="0.5" fill="#ef4444"/>
|
||||
<rect x="6.25" y="7" width="2.5" height="12" rx="0.5" fill="#f59e0b"/>
|
||||
<rect x="11.25" y="3" width="2.5" height="16" rx="0.5" fill="#10b981"/>
|
||||
<rect x="16.25" y="5" width="2.5" height="14" rx="0.5" fill="#3b82f6"/>
|
||||
</svg>
|
||||
</button>
|
||||
@if (shouldShowStatsMenu) {
|
||||
<p-menu #statsMenu [model]="statsMenuItems" [popup]="true" appendTo="body" />
|
||||
@@ -213,7 +218,12 @@
|
||||
class="flex items-center gap-2 w-full text-left p-2 hover:bg-surface-200 dark:hover:bg-surface-700 rounded"
|
||||
(click)="shouldShowStatsMenu ? statsMenuMobile.toggle($event) : handleStatsButtonClick($event)"
|
||||
>
|
||||
<i class="pi pi-chart-bar text-surface-100"></i>
|
||||
<svg class="multi-color-chart-icon" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="1" y="13" width="2.5" height="6" rx="0.5" fill="#ef4444"/>
|
||||
<rect x="5" y="10" width="2.5" height="9" rx="0.5" fill="#f59e0b"/>
|
||||
<rect x="9" y="6" width="2.5" height="13" rx="0.5" fill="#10b981"/>
|
||||
<rect x="13" y="8" width="2.5" height="11" rx="0.5" fill="#3b82f6"/>
|
||||
</svg>
|
||||
Charts
|
||||
</button>
|
||||
@if (shouldShowStatsMenu) {
|
||||
|
||||
@@ -135,6 +135,7 @@ export interface AppSettings {
|
||||
koboSettings: KoboSettings;
|
||||
coverCroppingSettings: CoverCroppingSettings;
|
||||
metadataDownloadOnBookdrop: boolean;
|
||||
telemetryEnabled: boolean;
|
||||
}
|
||||
|
||||
export enum AppSettingKey {
|
||||
@@ -155,5 +156,6 @@ export enum AppSettingKey {
|
||||
METADATA_DOWNLOAD_ON_BOOKDROP = 'METADATA_DOWNLOAD_ON_BOOKDROP',
|
||||
METADATA_PUBLIC_REVIEWS_SETTINGS = 'METADATA_PUBLIC_REVIEWS_SETTINGS',
|
||||
KOBO_SETTINGS = 'KOBO_SETTINGS',
|
||||
COVER_CROPPING_SETTINGS = 'COVER_CROPPING_SETTINGS'
|
||||
COVER_CROPPING_SETTINGS = 'COVER_CROPPING_SETTINGS',
|
||||
TELEMETRY_ENABLED = 'TELEMETRY_ENABLED',
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {API_CONFIG} from '../../core/config/api-config';
|
||||
import {createRxStompConfig} from '../websocket/rx-stomp.config';
|
||||
import {OAuthService, OAuthStorage} from 'angular-oauth2-oidc';
|
||||
import {Router} from '@angular/router';
|
||||
import {PostLoginInitializerService} from '../../core/services/post-login-initializer.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -14,23 +15,25 @@ export class AuthService {
|
||||
|
||||
private apiUrl = `${API_CONFIG.BASE_URL}/api/v1/auth`;
|
||||
private rxStompService?: RxStompService;
|
||||
private postLoginInitialized = false;
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private injector = inject(Injector);
|
||||
private oAuthService = inject(OAuthService);
|
||||
private oAuthStorage = inject(OAuthStorage);
|
||||
private router = inject(Router);
|
||||
private postLoginInitializer = inject(PostLoginInitializerService);
|
||||
|
||||
public tokenSubject = new BehaviorSubject<string | null>(this.getOidcAccessToken() || this.getInternalAccessToken());
|
||||
public token$ = this.tokenSubject.asObservable();
|
||||
|
||||
|
||||
internalLogin(credentials: { username: string; password: string }): Observable<{ accessToken: string; refreshToken: string, isDefaultPassword: string }> {
|
||||
return this.http.post<{ accessToken: string; refreshToken: string, isDefaultPassword: string }>(`${this.apiUrl}/login`, credentials).pipe(
|
||||
tap((response) => {
|
||||
if (response.accessToken && response.refreshToken) {
|
||||
this.saveInternalTokens(response.accessToken, response.refreshToken);
|
||||
this.initializeWebSocketConnection();
|
||||
this.handleSuccessfulAuth();
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -53,6 +56,7 @@ export class AuthService {
|
||||
if (response.accessToken && response.refreshToken) {
|
||||
this.saveInternalTokens(response.accessToken, response.refreshToken);
|
||||
this.initializeWebSocketConnection();
|
||||
this.handleSuccessfulAuth();
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -93,9 +97,8 @@ export class AuthService {
|
||||
this.oAuthStorage.removeItem("refresh_token");
|
||||
this.oAuthStorage.removeItem("id_token");
|
||||
this.tokenSubject.next(null);
|
||||
this.postLoginInitialized = false;
|
||||
this.getRxStompService().deactivate();
|
||||
|
||||
// Force reload so user's data is not cached for next user that logs in
|
||||
window.location.href = '/login';
|
||||
}
|
||||
|
||||
@@ -114,6 +117,19 @@ export class AuthService {
|
||||
const config = createRxStompConfig(this);
|
||||
stompService.updateConfig(config);
|
||||
stompService.activate();
|
||||
|
||||
if (!this.postLoginInitialized) {
|
||||
this.handleSuccessfulAuth();
|
||||
}
|
||||
}
|
||||
|
||||
private handleSuccessfulAuth() {
|
||||
if (this.postLoginInitialized) return;
|
||||
this.postLoginInitialized = true;
|
||||
this.postLoginInitializer.initialize().subscribe({
|
||||
next: () => console.log('AuthService: Post-login initialization completed'),
|
||||
error: (err) => console.error('AuthService: Post-login initialization failed:', err)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ export class DialogLauncherService {
|
||||
openVersionChangelogDialog(): DynamicDialogRef | null {
|
||||
return this.openDialog(VersionChangelogDialogComponent, {
|
||||
header: "What's New",
|
||||
styleClass: 'dialog-maximal',
|
||||
styleClass: 'dialog-medium',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -164,3 +164,9 @@
|
||||
.half-title {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.multi-color-chart-icon {
|
||||
width: 1.3rem;
|
||||
height: 1.3rem;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ import {initializeAuthFactory} from './app/core/security/auth-initializer';
|
||||
import {StartupService} from './app/shared/service/startup.service';
|
||||
import {provideCharts, withDefaultRegisterables} from 'ng2-charts';
|
||||
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
||||
import {IconService} from './app/shared/services/icon.service';
|
||||
import {firstValueFrom} from 'rxjs';
|
||||
|
||||
export function storageFactory(): OAuthStorage {
|
||||
return localStorage;
|
||||
@@ -38,10 +36,6 @@ bootstrapApplication(AppComponent, {
|
||||
const startup = inject(StartupService);
|
||||
return startup.load();
|
||||
}),
|
||||
provideAppInitializer(() => {
|
||||
const iconService = inject(IconService);
|
||||
return firstValueFrom(iconService.preloadAllIcons());
|
||||
}),
|
||||
provideHttpClient(withInterceptors([AuthInterceptorService])),
|
||||
provideOAuthClient(),
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user