Support individual “write to file” settings per book type, with configurable file size limits (#2206)

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-08 15:18:20 -07:00
committed by GitHub
co-authored by acx10
parent f75eb840c6
commit 15de049f3d
49 changed files with 3071 additions and 2815 deletions
@@ -378,10 +378,11 @@ describe('BookService', () => {
it('should update book metadata', async () => {
httpMock.put.mockReturnValue(of({bookId: 1}));
service.handleBookMetadataUpdate = vi.fn();
const spy = vi.spyOn(BookService.prototype, 'handleBookMetadataUpdate');
const result = await firstValueFrom(service.updateBookMetadata(1, {} as any, true));
expect(result).toEqual({bookId: 1});
expect(service.handleBookMetadataUpdate).toHaveBeenCalledWith(1, {bookId: 1});
expect(spy).toHaveBeenCalledWith(1, {bookId: 1});
spy.mockRestore();
});
it('should update books metadata', async () => {
@@ -445,14 +446,6 @@ describe('BookService', () => {
expect(service.getUploadCoverUrl(1)).toContain('/1/metadata/cover/upload');
});
it('should upload cover from url and handleBookMetadataUpdate', async () => {
httpMock.post.mockReturnValue(of({bookId: 1}));
service.handleBookMetadataUpdate = vi.fn();
const result = await firstValueFrom(service.uploadCoverFromUrl(1, 'url'));
expect(result).toEqual({bookId: 1});
expect(service.handleBookMetadataUpdate).toHaveBeenCalledWith(1, {bookId: 1});
});
it('should regenerate covers', async () => {
httpMock.post.mockReturnValue(of(void 0));
const result = await firstValueFrom(service.regenerateCovers());
@@ -529,13 +529,7 @@ export class BookService {
}
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)
)
);
return this.http.post<BookMetadata>(`${this.url}/${bookId}/metadata/cover/from-url`, {url});
}
regenerateCovers(): Observable<void> {
@@ -1,14 +1,14 @@
@if (book$ | async; as book) {
<form [formGroup]="metadataForm" class="flex flex-col h-full md:min-w-[60rem]">
<form [formGroup]="metadataForm" class="metadata-form">
@if (isLoading) {
<div class="absolute inset-0 bg-black opacity-25 z-10 "></div>
<div class="loading-overlay"></div>
}
@if (isLoading) {
<p-progressSpinner [style]="{position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)'}"></p-progressSpinner>
<p-progressSpinner class="loading-spinner"></p-progressSpinner>
}
<div class="flex flex-col flex-grow overflow-auto md:py-2 md:px-2 ">
<div class="flex flex-col md:flex-row w-full gap-4 mb-4">
<div class="flex flex-col items-center gap-0 relative w-[250px] flex-shrink-0" style="margin: 0 auto;">
<div class="form-content">
<div class="main-section">
<div class="cover-section">
<p-image
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
alt="Cover Image"
@@ -18,11 +18,9 @@
[preview]="true">
</p-image>
@if (isUploading) {
<p-progressSpinner
class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-10">
</p-progressSpinner>
<p-progressSpinner class="upload-spinner"></p-progressSpinner>
}
<div class="flex items-center gap-3 pt-3">
<div class="cover-actions">
<p-button
icon="pi pi-refresh"
(onClick)="regenerateCover(book.id)"
@@ -78,13 +76,13 @@
}
</div>
</div>
<div class="flex flex-col flex-grow md:pl-2">
<div class="fields-section">
<div class="flex flex-col md:flex-row w-full gap-4 pb-1">
<div class="flex flex-col gap-1 md:basis-[45%] flex-shrink-0">
<label class="text-sm" for="title">Title</label>
<div class="flex withbutton">
<input pInputText id="title" formControlName="title" class="w-full"/>
<div class="field-row">
<div class="field-group title-field">
<label for="title">Title</label>
<div class="field-with-lock">
<input pInputText id="title" formControlName="title"/>
@if (!book.metadata!['titleLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('title')" severity="success"></p-button>
}
@@ -94,10 +92,10 @@
</div>
</div>
<div class="flex flex-col gap-1 md:basis-[40%]">
<label class="text-sm" for="subtitle">Subtitle</label>
<div class="flex withbutton">
<input pInputText id="subtitle" formControlName="subtitle" class="w-full"/>
<div class="field-group subtitle-field">
<label for="subtitle">Subtitle</label>
<div class="field-with-lock">
<input pInputText id="subtitle" formControlName="subtitle"/>
@if (!book.metadata!['subtitleLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('subtitle')" severity="success"></p-button>
}
@@ -107,10 +105,10 @@
</div>
</div>
<div class="flex flex-col gap-1 md:w-[9rem]">
<label class="text-sm" for="language">Language</label>
<div class="flex withbutton">
<input pInputText id="language" formControlName="language" class="w-full"/>
<div class="field-group language-field">
<label for="language">Language</label>
<div class="field-with-lock">
<input pInputText id="language" formControlName="language"/>
@if (!book.metadata!['languageLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('language')" severity="success"></p-button>
}
@@ -121,12 +119,11 @@
</div>
</div>
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 md:basis-[45%] flex-shrink-0">
<label class="text-sm" for="authors">Authors</label>
<div class="flex withbutton">
<div class="field-row">
<div class="field-group authors-field">
<label for="authors">Authors</label>
<div class="field-with-lock">
<p-autoComplete
class="w-full"
formControlName="authors"
[multiple]="true"
[fluid]="true"
@@ -146,11 +143,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:basis-[35%]">
<label class="text-sm" for="publisher">Publisher</label>
<div class="flex withbutton">
<div class="field-group publisher-field">
<label for="publisher">Publisher</label>
<div class="field-with-lock">
<p-autoComplete
class="w-full"
inputStyleClass="w-full"
formControlName="publisher"
inputId="publisher"
@@ -169,11 +165,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:basis-[20%]">
<label class="text-sm" for="publishedDate">Publish Date</label>
<div class="flex withbutton">
<div class="field-group date-field">
<label for="publishedDate">Publish Date</label>
<div class="field-with-lock">
<p-datepicker
class="w-full md:min-w-[7.5rem]"
formControlName="publishedDate"
inputId="publishedDate"
dataType="string"
@@ -194,13 +189,12 @@
</div>
</div>
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-full">
<label class="text-sm" for="categories">Genres</label>
<div class="flex withbutton">
<div class="w-full">
<div class="field-row">
<div class="field-group full-width">
<label for="categories">Genres</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
<p-autoComplete
class="w-full"
formControlName="categories"
[multiple]="true"
[dropdown]="false"
@@ -222,13 +216,12 @@
</div>
</div>
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-full">
<label class="text-sm" for="moods">Moods</label>
<div class="flex withbutton">
<div class="w-full">
<div class="field-row">
<div class="field-group full-width">
<label for="moods">Moods</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
<p-autoComplete
class="w-full"
formControlName="moods"
[multiple]="true"
[dropdown]="false"
@@ -249,13 +242,12 @@
</div>
</div>
</div>
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 w-full">
<label class="text-sm" for="tags">Tags</label>
<div class="flex withbutton">
<div class="w-full">
<div class="field-row">
<div class="field-group full-width">
<label for="tags">Tags</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
<p-autoComplete
class="w-full"
formControlName="tags"
[multiple]="true"
[dropdown]="false"
@@ -277,12 +269,11 @@
</div>
</div>
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 md:basis-[75%]">
<label class="text-sm" for="seriesName">Series Name</label>
<div class="flex withbutton">
<div class="field-row">
<div class="field-group series-name-field">
<label for="seriesName">Series Name</label>
<div class="field-with-lock">
<p-autoComplete
class="w-full"
inputStyleClass="w-full"
formControlName="seriesName"
inputId="seriesName"
@@ -302,10 +293,10 @@
</div>
</div>
<div class="flex flex-col gap-1 md:w-[9rem]">
<label class="text-sm" for="seriesNumber">Series #</label>
<div class="flex withbutton">
<input pInputText id="seriesNumber" formControlName="seriesNumber" class="w-full"/>
<div class="field-group small-field">
<label for="seriesNumber">Series #</label>
<div class="field-with-lock">
<input pInputText id="seriesNumber" formControlName="seriesNumber"/>
@if (!book.metadata!['seriesNumberLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="success"></p-button>
}
@@ -315,10 +306,10 @@
</div>
</div>
<div class="flex flex-col gap-1 md:w-[9rem]">
<label class="text-sm" for="seriesTotal">Series Total</label>
<div class="flex withbutton">
<input pInputText id="seriesTotal" formControlName="seriesTotal" class="w-full"/>
<div class="field-group small-field">
<label for="seriesTotal">Series Total</label>
<div class="field-with-lock">
<input pInputText id="seriesTotal" formControlName="seriesTotal"/>
@if (!book.metadata!['seriesTotalLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="success"></p-button>
}
@@ -328,10 +319,10 @@
</div>
</div>
<div class="flex flex-col gap-1 md:w-[9rem]">
<label class="text-sm" for="pageCount">Pages</label>
<div class="flex withbutton">
<input pInputText id="pageCount" formControlName="pageCount" class="w-full"/>
<div class="field-group small-field">
<label for="pageCount">Pages</label>
<div class="field-with-lock">
<input pInputText id="pageCount" formControlName="pageCount"/>
@if (!book.metadata!['pageCountLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="success"></p-button>
}
@@ -344,11 +335,11 @@
</div>
</div>
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="reviews">Public Reviews</label>
<div class="flex withbutton">
<input pSize="small" pInputText class="w-full" [disabled]="true" value="No Value"/>
<div class="field-row metadata-ids-row">
<div class="field-group metadata-id-field">
<label for="reviews">Public Reviews</label>
<div class="field-with-lock">
<input pSize="small" pInputText [disabled]="true" value="No Value"/>
@if (!book.metadata!['reviewsLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('reviews')" severity="success"></p-button>
}
@@ -357,10 +348,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="isbn10">ISBN 10</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="isbn10" formControlName="isbn10" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="isbn10">ISBN 10</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="isbn10" formControlName="isbn10"/>
@if (!book.metadata!['isbn10Locked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="success"></p-button>
}
@@ -369,10 +360,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="isbn13">ISBN 13</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="isbn13" formControlName="isbn13" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="isbn13">ISBN 13</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="isbn13" formControlName="isbn13"/>
@if (!book.metadata!['isbn13Locked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="success"></p-button>
}
@@ -381,10 +372,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="asin">Amazon ASIN</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="asin" formControlName="asin" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="asin">Amazon ASIN</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="asin" formControlName="asin"/>
@if (!book.metadata!['asinLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
}
@@ -393,10 +384,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="amazonRating">Amazon ★</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="amazonRating" formControlName="amazonRating" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="amazonRating">Amazon ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="amazonRating" formControlName="amazonRating"/>
@if (!book.metadata!['amazonRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="success"></p-button>
}
@@ -405,10 +396,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="amazonRatingCount">Amazon #</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="amazonRatingCount" formControlName="amazonReviewCount" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="amazonRatingCount">Amazon #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="amazonRatingCount" formControlName="amazonReviewCount"/>
@if (!book.metadata!['amazonReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="success"></p-button>
}
@@ -417,10 +408,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="googleId">Google Books ID</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="googleId" formControlName="googleId" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="googleId">Google Books ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="googleId" formControlName="googleId"/>
@if (!book.metadata!['googleIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('googleId')" severity="success"></p-button>
}
@@ -431,11 +422,11 @@
</div>
</div>
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="goodreadsId">Goodreads ID</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="goodreadsId" formControlName="goodreadsId" class="w-full"/>
<div class="field-row metadata-ids-row">
<div class="field-group metadata-id-field">
<label for="goodreadsId">Goodreads ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsId" formControlName="goodreadsId"/>
@if (!book.metadata!['goodreadsIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="success"></p-button>
}
@@ -444,10 +435,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="goodreadsRating">Goodreads ★</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="goodreadsRating" formControlName="goodreadsRating" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="goodreadsRating">Goodreads ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsRating" formControlName="goodreadsRating"/>
@if (!book.metadata!['goodreadsRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="success"></p-button>
}
@@ -456,10 +447,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="goodreadsReviewCount">Goodreads #</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="goodreadsReviewCount">Goodreads #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount"/>
@if (!book.metadata!['goodreadsReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="success"></p-button>
}
@@ -468,10 +459,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="hardcoverId">Hardcover ID</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="hardcoverId" formControlName="hardcoverId" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="hardcoverId">Hardcover ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverId" formControlName="hardcoverId"/>
@if (!book.metadata!['hardcoverIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="success"></p-button>
}
@@ -480,10 +471,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="hardcoverBookId">Hardcover Book ID</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="hardcoverBookId" formControlName="hardcoverBookId" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="hardcoverBookId">Hardcover Book ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverBookId" formControlName="hardcoverBookId"/>
@if (!book.metadata!['hardcoverBookIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverBookId')" severity="success"></p-button>
}
@@ -492,10 +483,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="hardcoverRating">Hardcover ★</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="hardcoverRating" formControlName="hardcoverRating" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="hardcoverRating">Hardcover ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverRating" formControlName="hardcoverRating"/>
@if (!book.metadata!['hardcoverRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="success"></p-button>
}
@@ -504,10 +495,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="hardcoverReviewCount">Hardcover #</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="hardcoverReviewCount">Hardcover #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount"/>
@if (!book.metadata!['hardcoverReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="success"></p-button>
}
@@ -516,10 +507,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="lubimyczytacId">LC ID</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="lubimyczytacId" formControlName="lubimyczytacId" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="lubimyczytacId">LC ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacId" formControlName="lubimyczytacId"/>
@if (!book.metadata!['lubimyczytacIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('lubimyczytacId')" severity="success"></p-button>
}
@@ -528,10 +519,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="lubimyczytacRating">LC ★</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="lubimyczytacRating" formControlName="lubimyczytacRating" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="lubimyczytacRating">LC ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacRating" formControlName="lubimyczytacRating"/>
@if (!book.metadata!['lubimyczytacRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('lubimyczytacRating')" severity="success"></p-button>
}
@@ -540,10 +531,10 @@
}
</div>
</div>
<div class="flex flex-col gap-1 md:w-1/6">
<label class="text-sm" for="comicvineId">Comicvine ID</label>
<div class="flex withbutton">
<input pSize="small" pInputText id="comicvineId" formControlName="comicvineId" class="w-full"/>
<div class="field-group metadata-id-field">
<label for="comicvineId">Comicvine ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="comicvineId" formControlName="comicvineId"/>
@if (!book.metadata!['comicvineIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="success"></p-button>
}
@@ -554,16 +545,15 @@
</div>
</div>
<div class="flex flex-col flex-grow md:flex-row w-full gap-4 mt-4 mb-4">
<div class="flex flex-col gap-1 w-full h-full">
<label class="text-sm" for="description">Description</label>
<div class="flex flex-grow w-full withbutton">
<div class="description-section">
<div class="field-group description-field">
<label for="description">Description</label>
<div class="field-with-lock description-with-lock">
<textarea
id="description"
pTextarea
formControlName="description"
rows="10"
class="w-full h-full">
rows="10">
</textarea>
@if (!book.metadata!['descriptionLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success"></p-button>
@@ -575,14 +565,14 @@
</div>
</div>
</div>
<div class="mt-auto">
<div class="form-footer">
<p-divider></p-divider>
<div class="flex flex-col gap-2 px-0 md:px-2 pt-4 md:pb-4 z-10">
<div class="footer-actions">
<!-- Desktop Buttons -->
<div class="hidden sm:flex justify-between w-full gap-4">
<div class="desktop-actions">
@if (showNavigationButtons) {
<div class="flex gap-x-4">
<div class="navigation-left">
<p-button label="Close" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()"></p-button>
<p-divider layout="vertical"/>
<p-button label="Previous Book" [disabled]="disablePrevious" icon="pi pi-arrow-left" [outlined]="true" severity="info" (onClick)="onPrevious()"></p-button>
@@ -591,7 +581,7 @@
}
@if (navigationState$ | async) {
<div class="flex gap-2 items-center">
<div class="navigation-center">
<p-button
icon="pi pi-chevron-left"
[disabled]="!canNavigatePrevious()"
@@ -602,7 +592,7 @@
pTooltip="Go to previous book"
tooltipPosition="bottom">
</p-button>
<span class="text-sm text-surface-600 dark:text-surface-400">
<span class="navigation-position">
{{ getNavigationPosition() }}
</span>
<p-button
@@ -619,7 +609,7 @@
</div>
}
<div class="flex gap-x-4 items-center ml-auto">
<div class="actions-right">
<p-button
[label]="isAutoFetching ? 'Fetching…' : 'Auto Fetch'"
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
@@ -639,18 +629,18 @@
</div>
<!-- Mobile Buttons -->
<div class="flex sm:hidden justify-between w-full flex-wrap">
<div class="mobile-actions">
@if (showNavigationButtons) {
<div class="flex gap-2 flex-wrap">
<div class="mobile-nav-buttons">
<p-button size="small" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()" pTooltip="Close" tooltipPosition="top"></p-button>
<p-button size="small" icon="pi pi-arrow-left" [disabled]="disablePrevious" [outlined]="true" severity="info" (onClick)="onPrevious()" pTooltip="Previous Book" tooltipPosition="top"></p-button>
<p-button size="small" icon="pi pi-arrow-right" [disabled]="disableNext" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()" pTooltip="Next Book" tooltipPosition="top"></p-button>
</div>
}
<div class="flex justify-between items-center w-full gap-4">
<div class="mobile-actions-row">
@if (navigationState$ | async) {
<div class="flex gap-2 items-center">
<div class="navigation-center">
<p-button
icon="pi pi-chevron-left"
[disabled]="!canNavigatePrevious()"
@@ -661,7 +651,7 @@
pTooltip="Go to previous book"
tooltipPosition="bottom">
</p-button>
<span class="text-sm text-surface-600 dark:text-surface-400">
<span class="navigation-position">
{{ getNavigationPosition() }}
</span>
<p-button
@@ -677,7 +667,7 @@
</p-button>
</div>
}
<div class="flex gap-4">
<div class="mobile-lock-actions">
<p-button
icon="pi pi-bolt"
[outlined]="true"
@@ -707,7 +697,7 @@
</p-button>
</div>
<div>
<div class="mobile-save-action">
<p-button
label="Save"
icon="pi pi-check"
@@ -39,15 +39,19 @@
}
::ng-deep .withbutton input,
::ng-deep .withbutton ul {
::ng-deep .withbutton ul,
::ng-deep .field-with-lock input,
::ng-deep .field-with-lock ul {
border-radius: 6px 0 0 6px;
}
.withbutton textarea {
.withbutton textarea,
.field-with-lock textarea {
border-radius: 6px 0 6px 6px;
}
::ng-deep .withbutton button {
::ng-deep .withbutton button,
::ng-deep .field-with-lock button {
border-color: var(--p-inputtext-border-color) !important;
border-radius: 0 6px 6px 0 !important;
border-left: 0px !important;
@@ -65,3 +69,322 @@ label {
color: var(--text-color-secondary);
white-space: nowrap;
}
.metadata-form {
display: flex;
flex-direction: column;
height: 100%;
animation: fadeIn 0.3s ease-in;
@media (min-width: 768px) {
min-width: 60rem;
}
}
.loading-overlay {
position: absolute;
inset: 0;
background-color: black;
opacity: 0.25;
z-index: 10;
}
.loading-spinner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.form-content {
display: flex;
flex-direction: column;
flex-grow: 1;
overflow: auto;
@media (min-width: 768px) {
padding: 0.5rem;
}
}
.main-section {
display: flex;
flex-direction: column;
width: 100%;
gap: 1rem;
margin-bottom: 1rem;
@media (min-width: 768px) {
flex-direction: row;
}
}
.cover-section {
display: flex;
flex-direction: column;
align-items: center;
gap: 0;
position: relative;
width: 250px;
flex-shrink: 0;
margin: 0 auto;
}
.upload-spinner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
}
.cover-actions {
display: flex;
align-items: center;
gap: 0.75rem;
padding-top: 0.75rem;
}
.fields-section {
display: flex;
flex-direction: column;
flex-grow: 1;
@media (min-width: 768px) {
padding-left: 0.5rem;
}
}
.field-row {
display: flex;
flex-direction: column;
width: 100%;
gap: 1rem;
margin-top: 0.5rem;
padding-bottom: 0.25rem;
@media (min-width: 768px) {
flex-direction: row;
}
}
.field-group {
display: flex;
flex-direction: column;
gap: 0.25rem;
label {
font-size: 0.875rem;
}
}
.title-field {
@media (min-width: 768px) {
flex-basis: 45%;
flex-shrink: 0;
}
}
.subtitle-field {
@media (min-width: 768px) {
flex-basis: 40%;
}
}
.language-field {
@media (min-width: 768px) {
width: 9rem;
}
}
.authors-field {
@media (min-width: 768px) {
flex-basis: 45%;
flex-shrink: 0;
}
}
.publisher-field {
@media (min-width: 768px) {
flex-basis: 35%;
}
}
.date-field {
@media (min-width: 768px) {
flex-basis: 20%;
p-datepicker {
width: 100%;
min-width: 7.5rem;
}
}
}
.full-width {
width: 100%;
}
.series-name-field {
@media (min-width: 768px) {
flex-basis: 75%;
}
}
.small-field {
@media (min-width: 768px) {
width: 9rem;
}
}
.metadata-ids-row {
@media (min-width: 768px) {
.field-group {
width: calc(100% / 6);
}
}
}
.metadata-id-field {
@media (min-width: 768px) {
width: calc(100% / 6);
}
}
.description-section {
display: flex;
flex-direction: column;
flex-grow: 1;
width: 100%;
gap: 1rem;
margin-top: 1rem;
margin-bottom: 1rem;
@media (min-width: 768px) {
flex-direction: row;
}
}
.description-field {
width: 100%;
height: 100%;
}
.description-with-lock {
display: flex;
flex-grow: 1;
width: 100%;
textarea {
width: 100%;
height: 100%;
}
}
.field-with-lock {
display: flex;
input,
p-autocomplete,
p-datepicker {
width: 100%;
}
}
.autocomplete-wrapper {
width: 100%;
p-autocomplete {
width: 100%;
}
}
.form-footer {
margin-top: auto;
}
.footer-actions {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 0;
padding-top: 1rem;
z-index: 10;
@media (min-width: 768px) {
padding: 0.5rem;
padding-bottom: 1rem;
}
}
.desktop-actions {
display: none;
justify-content: space-between;
width: 100%;
gap: 1rem;
@media (min-width: 640px) {
display: flex;
}
}
.navigation-left {
display: flex;
gap: 1rem;
}
.navigation-center {
display: flex;
gap: 0.5rem;
align-items: center;
}
.navigation-position {
font-size: 0.875rem;
color: var(--surface-600);
:host-context(.dark) & {
color: var(--surface-400);
}
}
.actions-right {
display: flex;
gap: 1rem;
align-items: center;
margin-left: auto;
}
.mobile-actions {
display: flex;
justify-content: space-between;
width: 100%;
flex-wrap: wrap;
@media (min-width: 640px) {
display: none;
}
}
.mobile-nav-buttons {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.mobile-actions-row {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
gap: 1rem;
}
.mobile-lock-actions {
display: flex;
gap: 1rem;
}
.mobile-save-action {
display: flex;
}
@@ -13,11 +13,10 @@ import {HttpResponse} from "@angular/common/http";
import {BookService} from "../../../../book/service/book.service";
import {ProgressSpinner} from "primeng/progressspinner";
import {Tooltip} from "primeng/tooltip";
import {filter, take, finalize} from "rxjs/operators";
import {filter, finalize, take} from "rxjs/operators";
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
import {MetadataRefreshType} from "../../../model/request/metadata-refresh-type.enum";
import {AutoComplete} from "primeng/autocomplete";
import {AutoCompleteSelectEvent} from "primeng/autocomplete";
import {AutoComplete, AutoCompleteSelectEvent} from "primeng/autocomplete";
import {DatePicker} from "primeng/datepicker";
import {Textarea} from "primeng/textarea";
import {Image} from "primeng/image";
@@ -640,11 +639,6 @@ export class MetadataEditorComponent implements OnInit {
const response: HttpResponse<unknown> =
event.originalEvent as HttpResponse<unknown>;
if (response && response.status === 200) {
const bookMetadata: BookMetadata = response.body as BookMetadata;
this.bookService.handleBookMetadataUpdate(
this.currentBookId,
bookMetadata
);
this.isUploading = false;
} else {
this.isUploading = false;
@@ -57,3 +57,7 @@
::ng-deep .p-inputchips {
width: 100% !important;
}
.flex.flex-col.h-full.w-full {
animation: fadeIn 0.3s ease-in;
}
@@ -20,17 +20,6 @@ $provider-colors: (
animation: fadeIn 0.3s ease-in;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.search-header {
margin-bottom: 1.5rem;
@@ -5,6 +5,7 @@
padding: 0;
width: 100%;
min-height: 100%;
animation: fadeIn 0.3s ease-in;
@media (min-width: 768px) {
padding: 0.5rem;
@@ -7,6 +7,11 @@
</h2>
<p class="settings-description">
Organize, merge, split, rename, and standardize authors, genres, moods, and tags across your library.
<i
class="pi pi-exclamation-triangle info-icon"
pTooltip="Important: If 'Write to file' is enabled in settings, operations will modify all relevant files. For libraries with thousands of books, disable 'Write to file' before using this feature to prevent performance issues and potential data corruption."
tooltipPosition="right"
[escape]="false"></i>
</p>
</div>
@@ -156,6 +156,56 @@
font-size: 0.875rem;
line-height: 1.5;
margin-bottom: 1rem;
display: flex;
align-items: center;
gap: 0.5rem;
.info-icon {
font-size: 1.125rem;
color: red;
cursor: help;
transition: opacity 0.2s;
&:hover {
opacity: 1;
}
}
}
::ng-deep {
.p-tooltip {
max-width: 500px;
}
}
.warning-message {
display: flex;
align-items: flex-start;
gap: 0.5rem;
padding: 0.5rem 0.75rem;
margin-bottom: 1.25rem;
background: rgba(251, 146, 60, 0.05);
border: 1px solid rgba(251, 146, 60, 0.3);
border-radius: 6px;
color: var(--p-text-color-secondary);
.pi-exclamation-triangle {
font-size: 1rem;
color: rgba(251, 146, 60, 0.7);
flex-shrink: 0;
margin-top: 0.1rem;
}
p {
margin: 0;
font-size: 0.8125rem;
line-height: 1.45;
strong {
font-weight: 500;
color: var(--p-text-color);
}
}
}
.settings-content {
@@ -10,39 +10,150 @@
<div class="warning-notice">
<i class="pi pi-exclamation-triangle"></i>
<div>
<strong>Network Storage Notice:</strong> These features are designed for local file systems and have not been tested with network storage (NAS/cloud). Functionality cannot be guaranteed on network file systems.
<strong>Network Storage Warning:</strong> These features directly modify and move book files on disk (including rewriting metadata and renaming files). They are designed for local file systems only. Using them on NAS or cloud-backed storage is untested and may lead to file corruption,
incomplete writes, or permanent data loss. Github issues related to network storage will not be supported.
</div>
</div>
<!-- EPUB Settings -->
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Write Metadata to File</label>
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile"
(onChange)="onPersistenceToggle('saveToOriginalFile')">
</p-toggleswitch>
</div>
<label class="setting-label">Write Metadata to EPUB</label>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Write metadata directly into the original file. (Only Epub and PDF formats are currently supported.)
Write metadata directly into EPUB files when editing book information.
</p>
<div class="setting-item setting-item-indented">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enabled:</label>
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.epub.enabled"
(onChange)="onSaveToOriginalFileToggle('epub')">
</p-toggleswitch>
</div>
@if (metadataPersistence.saveToOriginalFile.epub.enabled) {
<div class="filesize-input" style="margin-top: 0.5rem;">
<label>Max File Size (MB):</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.epub.maxFileSizeInMb"
(change)="onFilesizeChange('epub')"
min="1"
max="1000"
class="filesize-field">
<i
class="pi pi-info-circle text-blue-500"
pTooltip="Only files up to this size (MB) will be updated. Larger files are ignored."
tooltipPosition="right"
style="cursor: help; margin-left: 4px;"
></i>
</div>
}
</div>
</div>
</div>
</div>
<!-- CBX Settings -->
<div class="setting-item">
<div class="setting-info">
<label class="setting-label">Write Metadata to CBX</label>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Write metadata directly into CBX files when editing book information.
</p>
<div class="setting-item setting-item-indented">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enabled:</label>
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.cbx.enabled"
(onChange)="onSaveToOriginalFileToggle('cbx')">
</p-toggleswitch>
</div>
@if (metadataPersistence.saveToOriginalFile.cbx.enabled) {
<div class="filesize-input" style="margin-top: 0.5rem;">
<label>Max File Size (MB):</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.cbx.maxFileSizeInMb"
(change)="onFilesizeChange('cbx')"
min="1"
max="1000"
class="filesize-field">
<i
class="pi pi-info-circle text-blue-500"
pTooltip="Only files up to this size (MB) will be updated. Larger files are ignored."
tooltipPosition="right"
style="cursor: help; margin-left: 4px;"
></i>
</div>
}
</div>
</div>
</div>
</div>
<!-- PDF Settings -->
<div class="setting-item">
<div class="setting-info">
<label class="setting-label">Write Metadata to PDF</label>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Write metadata directly into PDF files when editing book information. <br>
Note: PDFs do not support embedded covers, and only a limited set of metadata can be updated (Title, Authors, Publisher, Categories, Description, Language, Published Date). This is a limitation of the PDF format.
</p>
<div class="setting-item setting-item-indented">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enabled:</label>
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.pdf.enabled"
(onChange)="onSaveToOriginalFileToggle('pdf')">
</p-toggleswitch>
</div>
@if (metadataPersistence.saveToOriginalFile.pdf.enabled) {
<div class="filesize-input" style="margin-top: 0.5rem;">
<label>Max File Size (MB):</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.pdf.maxFileSizeInMb"
(change)="onFilesizeChange('pdf')"
min="1"
max="1000"
class="filesize-field">
<i
class="pi pi-info-circle text-blue-500"
pTooltip="Only files up to this size (MB) will be updated. Larger files are ignored."
tooltipPosition="right"
style="cursor: help; margin-left: 4px;"
></i>
</div>
}
</div>
</div>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Auto-Move Files on Metadata Update</label>
<p-toggleswitch
[ngModel]="metadataPersistence.moveFilesToLibraryPattern"
(onChange)="onPersistenceToggle('moveFilesToLibraryPattern')">
</p-toggleswitch>
</div>
<label class="setting-label">Auto-Move Files on Metadata Update</label>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Automatically move and rename files according to their library's naming pattern when metadata is updated, either through manual editing or auto-fetch operations.
</p>
<div class="setting-item setting-item-indented">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enabled:</label>
<p-toggleswitch
[ngModel]="metadataPersistence.moveFilesToLibraryPattern"
(onChange)="onPersistenceToggle('moveFilesToLibraryPattern')">
</p-toggleswitch>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -40,6 +40,7 @@
display: flex;
align-items: flex-start;
gap: 2rem;
flex-wrap: wrap;
&:last-child {
border-bottom: none;
@@ -47,9 +48,10 @@
}
&.setting-item-indented {
margin-top: 1rem;
margin-left: 1.5rem;
padding-left: 1rem;
border-left: 2px solid var(--p-content-border-color);
border-left: 2px solid var(--p-border-color);
position: relative;
&::before {
@@ -140,19 +142,74 @@
.warning-notice {
display: flex;
align-items: flex-start;
gap: 0.5rem;
color: var(--p-red-400);
font-size: 0.875rem;
line-height: 1.5;
gap: 0.75rem;
font-size: 0.9rem;
line-height: 1.55;
padding: 0.875rem 1rem;
border-radius: 10px;
background: color-mix(
in srgb,
var(--p-surface-900) 85%,
var(--p-red-600) 15%
);
border-left: 4px solid var(--p-red-500);
color: var(--p-text-color);
.pi-exclamation-triangle {
color: var(--p-red-500);
margin-top: 0.125rem;
color: var(--p-red-400);
margin-top: 0.15rem;
flex-shrink: 0;
}
strong {
font-weight: 700;
color: var(--p-red-300);
}
}
.nested-settings {
margin-top: 1rem;
margin-left: 1.5rem;
padding-left: 1rem;
border-left: 2px solid var(--surface-border);
}
.format-setting {
margin-bottom: 1rem;
&:last-child {
margin-bottom: 0;
}
}
.filesize-input {
display: flex;
align-items: center;
gap: 0.5rem;
label {
font-size: 0.875rem;
font-weight: 600;
color: var(--p-red-500);
white-space: nowrap;
}
.filesize-field {
width: 100px;
padding: 0.5rem;
border: 1px solid var(--p-content-border-color);
border-radius: 6px;
background: var(--p-content-background);
color: var(--p-text-color);
&:focus {
outline: none;
border-color: var(--p-primary-color);
box-shadow: 0 0 0 2px var(--p-primary-color-transparent);
}
}
}
@@ -1,17 +1,19 @@
import {Component, inject, OnInit} from '@angular/core';
import {ToggleSwitch} from 'primeng/toggleswitch';
import {FormsModule} from '@angular/forms';
import {AppSettingKey, AppSettings, MetadataPersistenceSettings} from '../../../../shared/model/app-settings.model';
import {AppSettingKey, AppSettings, MetadataPersistenceSettings, SaveToOriginalFileSettings} from '../../../../shared/model/app-settings.model';
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
import {SettingsHelperService} from '../../../../shared/service/settings-helper.service';
import {Observable} from 'rxjs';
import {filter, take} from 'rxjs/operators';
import {Tooltip} from 'primeng/tooltip';
@Component({
selector: 'app-metadata-persistence-settings-component',
imports: [
ToggleSwitch,
FormsModule
FormsModule,
Tooltip
],
templateUrl: './metadata-persistence-settings-component.html',
styleUrl: './metadata-persistence-settings-component.scss'
@@ -19,7 +21,20 @@ import {filter, take} from 'rxjs/operators';
export class MetadataPersistenceSettingsComponent implements OnInit {
metadataPersistence: MetadataPersistenceSettings = {
saveToOriginalFile: false,
saveToOriginalFile: {
epub: {
enabled: false,
maxFileSizeInMb: 250
},
pdf: {
enabled: false,
maxFileSizeInMb: 250
},
cbx: {
enabled: false,
maxFileSizeInMb: 250
}
},
convertCbrCb7ToCbz: false,
moveFilesToLibraryPattern: false
};
@@ -34,7 +49,19 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
}
onPersistenceToggle(key: keyof MetadataPersistenceSettings): void {
this.updatePersistenceSettings(key);
if (key !== 'saveToOriginalFile') {
this.metadataPersistence[key] = !this.metadataPersistence[key];
this.settingsHelper.saveSetting(AppSettingKey.METADATA_PERSISTENCE_SETTINGS, this.metadataPersistence);
}
}
onSaveToOriginalFileToggle(format: keyof SaveToOriginalFileSettings): void {
this.metadataPersistence.saveToOriginalFile[format].enabled =
!this.metadataPersistence.saveToOriginalFile[format].enabled;
this.settingsHelper.saveSetting(AppSettingKey.METADATA_PERSISTENCE_SETTINGS, this.metadataPersistence);
}
onFilesizeChange(format: keyof SaveToOriginalFileSettings): void {
this.settingsHelper.saveSetting(AppSettingKey.METADATA_PERSISTENCE_SETTINGS, this.metadataPersistence);
}
@@ -53,19 +80,25 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
private initializeSettings(settings: AppSettings): void {
if (settings.metadataPersistenceSettings) {
this.metadataPersistence = {...settings.metadataPersistenceSettings};
}
}
const persistenceSettings = settings.metadataPersistenceSettings;
private updatePersistenceSettings(key: keyof MetadataPersistenceSettings): void {
if (key === 'saveToOriginalFile') {
this.metadataPersistence.saveToOriginalFile = !this.metadataPersistence.saveToOriginalFile;
if (!this.metadataPersistence.saveToOriginalFile) {
this.metadataPersistence.convertCbrCb7ToCbz = false;
}
} else {
this.metadataPersistence[key] = !this.metadataPersistence[key];
this.metadataPersistence = {
...persistenceSettings,
saveToOriginalFile: {
epub: {
enabled: persistenceSettings.saveToOriginalFile?.epub?.enabled ?? false,
maxFileSizeInMb: persistenceSettings.saveToOriginalFile?.epub?.maxFileSizeInMb ?? 100
},
pdf: {
enabled: persistenceSettings.saveToOriginalFile?.pdf?.enabled ?? false,
maxFileSizeInMb: persistenceSettings.saveToOriginalFile?.pdf?.maxFileSizeInMb ?? 100
},
cbx: {
enabled: persistenceSettings.saveToOriginalFile?.cbx?.enabled ?? false,
maxFileSizeInMb: persistenceSettings.saveToOriginalFile?.cbx?.maxFileSizeInMb ?? 250
}
}
};
}
}
}