refactor(frontend): rename booklore-ui to frontend

- Frontend path:
  - rename the tracked Angular app tree from `booklore-ui/` to `frontend/`
  - preserve file contents during the move so this commit stays focused on the path change itself
- Frontend docs:
  - update the moved frontend README and contribution guide where they refer to the renamed folder
  - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
James Cox
2026-04-22 17:26:39 -04:00
committed by Zach Yale
parent c99aa87877
commit 874b013f75
1493 changed files with 3 additions and 3 deletions
@@ -0,0 +1,81 @@
import {computed, inject, Injectable} from '@angular/core';
import {BookService} from '../../book/service/book.service';
import {Book, computeSeriesReadStatus, ReadStatus} from '../../book/model/book.model';
import {SeriesSummary} from '../model/series.model';
@Injectable({
providedIn: 'root'
})
export class SeriesDataService {
private bookService = inject(BookService);
allSeries = computed(() => this.buildSeriesSummaries(this.bookService.books()));
private buildSeriesSummaries(books: Book[]): SeriesSummary[] {
const seriesMap = new Map<string, Book[]>();
for (const book of books) {
const seriesName = book.metadata?.seriesName;
if (!seriesName) continue;
const key = seriesName.trim().toLowerCase();
if (!seriesMap.has(key)) {
seriesMap.set(key, []);
}
seriesMap.get(key)!.push(book);
}
const summaries: SeriesSummary[] = [];
for (const seriesBooks of seriesMap.values()) {
const sorted = seriesBooks.sort((a, b) => {
const aNum = a.metadata?.seriesNumber ?? Number.MAX_SAFE_INTEGER;
const bNum = b.metadata?.seriesNumber ?? Number.MAX_SAFE_INTEGER;
return aNum - bNum;
});
const displayName = sorted[0].metadata?.seriesName?.trim() || '';
const authorSet = new Set<string>();
const categorySet = new Set<string>();
for (const book of sorted) {
book.metadata?.authors?.forEach(a => authorSet.add(a));
book.metadata?.categories?.forEach(c => categorySet.add(c));
}
const readCount = sorted.filter(b => b.readStatus === ReadStatus.READ).length;
const bookCount = sorted.length;
const lastReadTime = sorted
.map(b => b.lastReadTime)
.filter((t): t is string => !!t)
.sort((a, b) => new Date(b).getTime() - new Date(a).getTime())[0] || null;
const addedOn = sorted
.map(b => b.addedOn)
.filter((t): t is string => !!t)
.sort((a, b) => new Date(b).getTime() - new Date(a).getTime())[0] || null;
const nextUnread = sorted.find(b => b.readStatus !== ReadStatus.READ) || null;
summaries.push({
seriesName: displayName,
books: sorted,
authors: Array.from(authorSet),
categories: Array.from(categorySet),
bookCount,
readCount,
progress: bookCount > 0 ? readCount / bookCount : 0,
seriesStatus: computeSeriesReadStatus(sorted),
nextUnread,
lastReadTime,
coverBooks: sorted.slice(0, 7),
addedOn
});
}
return summaries;
}
}
@@ -0,0 +1,56 @@
import {inject, Injectable, signal} from '@angular/core';
import {LocalStorageService} from '../../../shared/service/local-storage.service';
@Injectable({
providedIn: 'root'
})
export class SeriesScalePreferenceService {
private readonly DEBOUNCE_MS = 1000;
private readonly STORAGE_KEY = 'seriesScalePreference';
private readonly localStorageService = inject(LocalStorageService);
private readonly _scaleFactor = signal(1.0);
readonly scaleFactor = this._scaleFactor.asReadonly();
private saveTimeout: ReturnType<typeof setTimeout> | null = null;
private lastPersistedScale = 1.0;
constructor() {
const initialScale = this.loadScaleFromStorage();
this._scaleFactor.set(initialScale);
this.lastPersistedScale = initialScale;
}
setScale(scale: number): void {
this._scaleFactor.set(scale);
if (scale === this.lastPersistedScale) {
return;
}
this.scheduleSave(scale);
}
private scheduleSave(scale: number): void {
if (this.saveTimeout) {
clearTimeout(this.saveTimeout);
}
this.saveTimeout = setTimeout(() => {
this.saveScalePreference(scale);
}, this.DEBOUNCE_MS);
}
private saveScalePreference(scale: number): void {
this.localStorageService.set(this.STORAGE_KEY, scale);
this.lastPersistedScale = scale;
}
private loadScaleFromStorage(): number {
const saved = this.localStorageService.get<number>(this.STORAGE_KEY);
if (saved !== null && !isNaN(saved)) {
return saved;
}
return 1.0;
}
}