feat: comic metadata picker, lazy-load providers, and UI improvements (#2679)

* feat: add comic metadata support to metadata picker and fix Comicvine parser

* feat: lazy-load Comicvine issue details on selection

* feat: lazy-load detail metadata for Amazon, GoodReads, and Audible parsers

* fix: prevent spurious comic_metadata row creation for non-comic books

* fix: extract rich previews from Audible search and reorder picker sections

* feat: redesign metadata editor layout with collapsible sections and boolean selects

* fix: implement per-field comic metadata locks replacing grouped locks

* feat: add comic metadata filters and fix visibleFilters backend support

* fix: use human-readable role labels in comic creator filter

* fix: auto-populate comic metadata from ComicVine during metadata fetch

* refactor: clean up ComicvineBookParser remove duplication and comments

* fix: use ComicMetadata webLink for ComicVine favicon URL

* fix: cache library options to prevent Set All dropdowns from resetting

* fix: stream book content from disk instead of loading entire file into memory

* fix: increase max visible filters from 15 to 20

* feat: replace filter multiselect with drag-and-drop reorderable list

* fix: use audiobook-specific cover paths and cache busting for audiobook thumbnail updates

* chore: enforce mandatory screenshots and stricter testing requirements in PR template

* fix: update BookServiceTest to match Resource return type after streaming change

---------

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-02-09 16:43:53 -07:00
committed by GitHub
co-authored by acx10
parent bc7ba8b933
commit ffd4615b87
79 changed files with 2548 additions and 1051 deletions
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="closeDialog()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -25,7 +25,7 @@
optionLabel="label"
optionValue="value"
placeholder="Select file type"
styleClass="full-width"
class="full-width"
[disabled]="isUploading"
></p-select>
@@ -36,7 +36,7 @@
[(ngModel)]="description"
rows="3"
placeholder="Add a description for this file..."
styleClass="full-width"
class="full-width"
[disabled]="isUploading"
></p-textarea>
</div>
@@ -9,7 +9,7 @@
optionValue="value"
class="filter-mode-select"
allowEmpty="false"
styleClass="h-8"></p-selectButton>
class="h-8"></p-selectButton>
</div>
<div class="filter-content">
@@ -20,7 +20,8 @@ export type FilterType =
| 'personalRating' | 'publisher' | 'matchScore' | 'library' | 'shelf'
| 'shelfStatus' | 'tag' | 'publishedDate' | 'fileSize' | 'amazonRating'
| 'goodreadsRating' | 'hardcoverRating' | 'language' | 'pageCount' | 'mood'
| 'ageRating' | 'contentRating';
| 'ageRating' | 'contentRating'
| 'comicCharacter' | 'comicTeam' | 'comicLocation' | 'comicCreator';
export type SortMode = 'count' | 'sortIndex';
@@ -156,7 +157,11 @@ export const FILTER_LABELS: Readonly<Record<FilterType, string>> = {
pageCount: 'Page Count',
mood: 'Mood',
ageRating: 'Age Rating',
contentRating: 'Content Rating'
contentRating: 'Content Rating',
comicCharacter: 'Comic Character',
comicTeam: 'Comic Team',
comicLocation: 'Comic Location',
comicCreator: 'Comic Creator'
};
// ============================================================================
@@ -230,6 +235,34 @@ export const FILTER_EXTRACTORS: Readonly<Record<Exclude<FilterType, 'library'>,
if (!rating) return [];
const label = CONTENT_RATING_LABELS[rating] ?? rating;
return [{id: rating, name: label}];
},
comicCharacter: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.characters),
comicTeam: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.teams),
comicLocation: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.locations),
comicCreator: (book) => {
const comic = book.metadata?.comicMetadata;
if (!comic) return [];
const creators: FilterValue[] = [];
const roleLabels: Record<string, string> = {
penciller: 'Penciller', inker: 'Inker', colorist: 'Colorist',
letterer: 'Letterer', coverArtist: 'Cover Artist', editor: 'Editor'
};
const roles: [string[] | undefined, string][] = [
[comic.pencillers, 'penciller'],
[comic.inkers, 'inker'],
[comic.colorists, 'colorist'],
[comic.letterers, 'letterer'],
[comic.coverArtists, 'coverArtist'],
[comic.editors, 'editor']
];
for (const [names, role] of roles) {
if (names) {
for (const name of names) {
creators.push({id: `${name}:${role}`, name: `${name} (${roleLabels[role]})`});
}
}
}
return creators;
}
};
@@ -254,5 +287,9 @@ export const FILTER_CONFIGS: Readonly<Record<Exclude<FilterType, 'library'>, Omi
pageCount: {label: 'Page Count', sortMode: 'sortIndex', isNumericId: true},
mood: {label: 'Mood', sortMode: 'count'},
ageRating: {label: 'Age Rating', sortMode: 'sortIndex', isNumericId: true},
contentRating: {label: 'Content Rating', sortMode: 'count'}
contentRating: {label: 'Content Rating', sortMode: 'count'},
comicCharacter: {label: 'Comic Character', sortMode: 'count'},
comicTeam: {label: 'Comic Team', sortMode: 'count'},
comicLocation: {label: 'Comic Location', sortMode: 'count'},
comicCreator: {label: 'Comic Creator', sortMode: 'count'}
};
@@ -10,7 +10,7 @@ import {BookRuleEvaluatorService} from '../../../../magic-shelf/service/book-rul
import {GroupRule} from '../../../../magic-shelf/component/magic-shelf-component';
import {EntityType} from '../book-browser.component';
import {Filter, FILTER_CONFIGS, FILTER_EXTRACTORS, FilterType, FilterValue, NUMERIC_ID_FILTER_TYPES, SortMode} from './book-filter.config';
import {filterBooksByFilters} from '../filters/SidebarFilter';
import {filterBooksByFilters} from '../filters/sidebar-filter';
import {BookFilterMode} from '../../../../settings/user-management/user.service';
const MAX_FILTER_ITEMS = 100;
@@ -1,169 +0,0 @@
import {combineLatest, Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {BookFilter} from './BookFilter';
import {BookState} from '../../../model/state/book-state.model';
import {fileSizeRanges, matchScoreRanges, pageCountRanges, ratingRanges} from '../book-filter/book-filter.config';
import {Book, ReadStatus} from '../../../model/book.model';
import {BookFilterMode} from '../../../../settings/user-management/user.service';
export function isRatingInRange(rating: number | undefined | null, rangeId: string | number): boolean {
if (rating == null) return false;
const numericId = typeof rangeId === 'string' ? Number(rangeId) : rangeId;
const range = ratingRanges.find(r => r.id === numericId);
if (!range) return false;
return rating >= range.min && rating < range.max;
}
export function isRatingInRange10(rating: number | undefined | null, rangeId: string | number): boolean {
if (rating == null) return false;
const numericId = typeof rangeId === 'string' ? Number(rangeId) : rangeId;
return Math.round(rating) === numericId;
}
export function isFileSizeInRange(fileSizeKb: number | undefined, rangeId: string | number): boolean {
if (fileSizeKb == null) return false;
const numericId = typeof rangeId === 'string' ? Number(rangeId) : rangeId;
const range = fileSizeRanges.find(r => r.id === numericId);
if (!range) return false;
return fileSizeKb >= range.min && fileSizeKb < range.max;
}
export function isPageCountInRange(pageCount: number | undefined, rangeId: string | number): boolean {
if (pageCount == null) return false;
const numericId = typeof rangeId === 'string' ? Number(rangeId) : rangeId;
const range = pageCountRanges.find(r => r.id === numericId);
if (!range) return false;
return pageCount >= range.min && pageCount < range.max;
}
export function isMatchScoreInRange(score: number | undefined | null, rangeId: string | number): boolean {
if (score == null) return false;
const normalizedScore = score > 1 ? score / 100 : score;
const numericId = typeof rangeId === 'string' ? Number(rangeId) : rangeId;
const range = matchScoreRanges.find(r => r.id === numericId);
if (!range) return false;
return normalizedScore >= range.min && normalizedScore < range.max;
}
export function doesBookMatchReadStatus(book: Book, selected: unknown[]): boolean {
const status = book.readStatus ?? ReadStatus.UNSET;
return selected.includes(status);
}
export function doesBookMatchFilter(
book: Book,
filterType: string,
filterValues: unknown[],
mode: BookFilterMode
): boolean {
if (!Array.isArray(filterValues) || filterValues.length === 0) {
return mode === 'or';
}
switch (filterType) {
case 'author':
return mode === 'or'
? filterValues.some(val => book.metadata?.authors?.includes(val as string))
: filterValues.every(val => book.metadata?.authors?.includes(val as string));
case 'category':
return mode === 'or'
? filterValues.some(val => book.metadata?.categories?.includes(val as string))
: filterValues.every(val => book.metadata?.categories?.includes(val as string));
case 'series':
return mode === 'or'
? filterValues.some(val => book.metadata?.seriesName === val)
: filterValues.every(val => book.metadata?.seriesName === val);
case 'bookType':
return filterValues.includes(book.primaryFile?.bookType);
case 'readStatus':
return doesBookMatchReadStatus(book, filterValues);
case 'personalRating':
return filterValues.some(range => isRatingInRange10(book.personalRating, range as string | number));
case 'publisher':
return mode === 'or'
? filterValues.some(val => book.metadata?.publisher === val)
: filterValues.every(val => book.metadata?.publisher === val);
case 'matchScore':
return filterValues.some(range => isMatchScoreInRange(book.metadataMatchScore, range as string | number));
case 'library':
return mode === 'or'
? filterValues.some(val => val == book.libraryId)
: filterValues.every(val => val == book.libraryId);
case 'shelf':
return mode === 'or'
? filterValues.some(val => book.shelves?.some(s => s.id == val))
: filterValues.every(val => book.shelves?.some(s => s.id == val));
case 'shelfStatus':
const shelved = book.shelves && book.shelves.length > 0 ? 'shelved' : 'unshelved';
return filterValues.includes(shelved);
case 'tag':
return mode === 'or'
? filterValues.some(val => book.metadata?.tags?.includes(val as string))
: filterValues.every(val => book.metadata?.tags?.includes(val as string));
case 'publishedDate':
const bookYear = book.metadata?.publishedDate
? new Date(book.metadata.publishedDate).getFullYear()
: null;
return bookYear ? filterValues.some(val => val == bookYear || val == bookYear.toString()) : false;
case 'fileSize':
return filterValues.some(range => isFileSizeInRange(book.fileSizeKb, range as string | number));
case 'amazonRating':
return filterValues.some(range => isRatingInRange(book.metadata?.amazonRating, range as string | number));
case 'goodreadsRating':
return filterValues.some(range => isRatingInRange(book.metadata?.goodreadsRating, range as string | number));
case 'hardcoverRating':
return filterValues.some(range => isRatingInRange(book.metadata?.hardcoverRating, range as string | number));
case 'language':
return filterValues.includes(book.metadata?.language);
case 'pageCount':
return filterValues.some(range => isPageCountInRange(book.metadata?.pageCount!, range as string | number));
case 'mood':
return mode === 'or'
? filterValues.some(val => book.metadata?.moods?.includes(val as string))
: filterValues.every(val => book.metadata?.moods?.includes(val as string));
default:
return false;
}
}
export function filterBooksByFilters(
books: Book[],
activeFilters: Record<string, unknown[]> | null,
mode: BookFilterMode,
excludeFilterType?: string
): Book[] {
if (!activeFilters) return books;
const filterEntries = Object.entries(activeFilters)
.filter(([type]) => type !== excludeFilterType);
if (filterEntries.length === 0) return books;
return books.filter(book => {
const matches = filterEntries.map(([filterType, filterValues]) =>
doesBookMatchFilter(book, filterType, filterValues, mode)
);
return mode === 'or' ? matches.some(m => m) : matches.every(m => m);
});
}
export class SideBarFilter implements BookFilter {
constructor(private selectedFilter$: Observable<unknown>, private selectedFilterMode$: Observable<BookFilterMode>) {
}
filter(bookState: BookState): Observable<BookState> {
return combineLatest([this.selectedFilter$, this.selectedFilterMode$]).pipe(
map(([activeFilters, mode]) => {
if (bookState.books == null) return bookState;
if (!activeFilters) return bookState;
const filteredBooks = filterBooksByFilters(
bookState.books || [],
activeFilters as Record<string, unknown[]>,
mode
);
return {...bookState, books: filteredBooks};
})
);
}
}
@@ -2,7 +2,7 @@ import {combineLatest, Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {BookFilter} from './BookFilter';
import {BookState} from '../../../model/state/book-state.model';
import {AGE_RATING_OPTIONS, fileSizeRanges, matchScoreRanges, pageCountRanges, ratingRanges, RangeConfig} from '../book-filter/book-filter.config';
import {fileSizeRanges, matchScoreRanges, pageCountRanges, ratingRanges} from '../book-filter/book-filter.config';
import {Book, ReadStatus} from '../../../model/book.model';
import {BookFilterMode} from '../../../../settings/user-management/user.service';
@@ -45,15 +45,148 @@ export function isMatchScoreInRange(score: number | undefined | null, rangeId: s
return normalizedScore >= range.min && normalizedScore < range.max;
}
export function doesBookMatchReadStatus(book: Book, selected: string[]): boolean {
export function doesBookMatchReadStatus(book: Book, selected: unknown[]): boolean {
const status = book.readStatus ?? ReadStatus.UNSET;
return selected.includes(status);
}
export function isAgeRatingMatch(ageRating: number | undefined | null, rangeId: string | number): boolean {
if (ageRating == null) return false;
const numericId = typeof rangeId === 'string' ? Number(rangeId) : rangeId;
return ageRating === numericId;
export function doesBookMatchFilter(
book: Book,
filterType: string,
filterValues: unknown[],
mode: BookFilterMode
): boolean {
if (!Array.isArray(filterValues) || filterValues.length === 0) {
return mode === 'or';
}
switch (filterType) {
case 'author':
return mode === 'or'
? filterValues.some(val => book.metadata?.authors?.includes(val as string))
: filterValues.every(val => book.metadata?.authors?.includes(val as string));
case 'category':
return mode === 'or'
? filterValues.some(val => book.metadata?.categories?.includes(val as string))
: filterValues.every(val => book.metadata?.categories?.includes(val as string));
case 'series':
return mode === 'or'
? filterValues.some(val => book.metadata?.seriesName === val)
: filterValues.every(val => book.metadata?.seriesName === val);
case 'bookType':
return filterValues.includes(book.primaryFile?.bookType);
case 'readStatus':
return doesBookMatchReadStatus(book, filterValues);
case 'personalRating':
return filterValues.some(range => isRatingInRange10(book.personalRating, range as string | number));
case 'publisher':
return mode === 'or'
? filterValues.some(val => book.metadata?.publisher === val)
: filterValues.every(val => book.metadata?.publisher === val);
case 'matchScore':
return filterValues.some(range => isMatchScoreInRange(book.metadataMatchScore, range as string | number));
case 'library':
return mode === 'or'
? filterValues.some(val => val == book.libraryId)
: filterValues.every(val => val == book.libraryId);
case 'shelf':
return mode === 'or'
? filterValues.some(val => book.shelves?.some(s => s.id == val))
: filterValues.every(val => book.shelves?.some(s => s.id == val));
case 'shelfStatus':
const shelved = book.shelves && book.shelves.length > 0 ? 'shelved' : 'unshelved';
return filterValues.includes(shelved);
case 'tag':
return mode === 'or'
? filterValues.some(val => book.metadata?.tags?.includes(val as string))
: filterValues.every(val => book.metadata?.tags?.includes(val as string));
case 'publishedDate':
const bookYear = book.metadata?.publishedDate
? new Date(book.metadata.publishedDate).getFullYear()
: null;
return bookYear ? filterValues.some(val => val == bookYear || val == bookYear.toString()) : false;
case 'fileSize':
return filterValues.some(range => isFileSizeInRange(book.fileSizeKb, range as string | number));
case 'amazonRating':
return filterValues.some(range => isRatingInRange(book.metadata?.amazonRating, range as string | number));
case 'goodreadsRating':
return filterValues.some(range => isRatingInRange(book.metadata?.goodreadsRating, range as string | number));
case 'hardcoverRating':
return filterValues.some(range => isRatingInRange(book.metadata?.hardcoverRating, range as string | number));
case 'language':
return filterValues.includes(book.metadata?.language);
case 'pageCount':
return filterValues.some(range => isPageCountInRange(book.metadata?.pageCount!, range as string | number));
case 'mood':
return mode === 'or'
? filterValues.some(val => book.metadata?.moods?.includes(val as string))
: filterValues.every(val => book.metadata?.moods?.includes(val as string));
case 'ageRating':
return filterValues.some(val => {
const numVal = typeof val === 'string' ? Number(val) : val;
return book.metadata?.ageRating === numVal;
});
case 'contentRating':
return filterValues.includes(book.metadata?.contentRating);
case 'comicCharacter':
return mode === 'or'
? filterValues.some(val => book.metadata?.comicMetadata?.characters?.includes(val as string))
: filterValues.every(val => book.metadata?.comicMetadata?.characters?.includes(val as string));
case 'comicTeam':
return mode === 'or'
? filterValues.some(val => book.metadata?.comicMetadata?.teams?.includes(val as string))
: filterValues.every(val => book.metadata?.comicMetadata?.teams?.includes(val as string));
case 'comicLocation':
return mode === 'or'
? filterValues.some(val => book.metadata?.comicMetadata?.locations?.includes(val as string))
: filterValues.every(val => book.metadata?.comicMetadata?.locations?.includes(val as string));
case 'comicCreator': {
const comic = book.metadata?.comicMetadata;
if (!comic) return false;
const allCreators: string[] = [];
const roles: [string[] | undefined, string][] = [
[comic.pencillers, 'penciller'],
[comic.inkers, 'inker'],
[comic.colorists, 'colorist'],
[comic.letterers, 'letterer'],
[comic.coverArtists, 'coverArtist'],
[comic.editors, 'editor']
];
for (const [names, role] of roles) {
if (names) {
for (const name of names) {
allCreators.push(`${name}:${role}`);
}
}
}
return mode === 'or'
? filterValues.some(val => allCreators.includes(val as string))
: filterValues.every(val => allCreators.includes(val as string));
}
default:
return false;
}
}
export function filterBooksByFilters(
books: Book[],
activeFilters: Record<string, unknown[]> | null,
mode: BookFilterMode,
excludeFilterType?: string
): Book[] {
if (!activeFilters) return books;
const filterEntries = Object.entries(activeFilters)
.filter(([type]) => type !== excludeFilterType);
if (filterEntries.length === 0) return books;
return books.filter(book => {
const matches = filterEntries.map(([filterType, filterValues]) =>
doesBookMatchFilter(book, filterType, filterValues, mode)
);
return mode === 'or' ? matches.some(m => m) : matches.every(m => m);
});
}
export class SideBarFilter implements BookFilter {
@@ -66,82 +199,11 @@ export class SideBarFilter implements BookFilter {
map(([activeFilters, mode]) => {
if (bookState.books == null) return bookState;
if (!activeFilters) return bookState;
const filteredBooks = (bookState.books || []).filter(book => {
const matches = Object.entries(activeFilters).map(([filterType, filterValues]) => {
if (!Array.isArray(filterValues) || filterValues.length === 0) {
return mode === 'or';
}
switch (filterType) {
case 'author':
return mode === 'or'
? filterValues.some(val => book.metadata?.authors?.includes(val))
: filterValues.every(val => book.metadata?.authors?.includes(val));
case 'category':
return mode === 'or'
? filterValues.some(val => book.metadata?.categories?.includes(val))
: filterValues.every(val => book.metadata?.categories?.includes(val));
case 'series':
return mode === 'or'
? filterValues.some(val => book.metadata?.seriesName === val)
: filterValues.every(val => book.metadata?.seriesName === val);
case 'bookType':
return filterValues.includes(book.primaryFile?.bookType);
case 'readStatus':
return doesBookMatchReadStatus(book, filterValues);
case 'personalRating':
return filterValues.some(range => isRatingInRange10(book.personalRating, range));
case 'publisher':
return mode === 'or'
? filterValues.some(val => book.metadata?.publisher === val)
: filterValues.every(val => book.metadata?.publisher === val);
case 'matchScore':
return filterValues.some(range => isMatchScoreInRange(book.metadataMatchScore, range));
case 'library':
return mode === 'or'
? filterValues.some(val => val == book.libraryId)
: filterValues.every(val => val == book.libraryId);
case 'shelf':
return mode === 'or'
? filterValues.some(val => book.shelves?.some(s => s.id == val))
: filterValues.every(val => book.shelves?.some(s => s.id == val));
case 'shelfStatus':
const shelved = book.shelves && book.shelves.length > 0 ? 'shelved' : 'unshelved';
return filterValues.includes(shelved);
case 'tag':
return mode === 'or'
? filterValues.some(val => book.metadata?.tags?.includes(val))
: filterValues.every(val => book.metadata?.tags?.includes(val));
case 'publishedDate':
const bookYear = book.metadata?.publishedDate
? new Date(book.metadata.publishedDate).getFullYear()
: null;
return bookYear ? filterValues.some(val => val == bookYear || val == bookYear.toString()) : false;
case 'fileSize':
return filterValues.some(range => isFileSizeInRange(book.fileSizeKb, range));
case 'amazonRating':
return filterValues.some(range => isRatingInRange(book.metadata?.amazonRating, range));
case 'goodreadsRating':
return filterValues.some(range => isRatingInRange(book.metadata?.goodreadsRating, range));
case 'hardcoverRating':
return filterValues.some(range => isRatingInRange(book.metadata?.hardcoverRating, range));
case 'language':
return filterValues.includes(book.metadata?.language);
case 'pageCount':
return filterValues.some(range => isPageCountInRange(book.metadata?.pageCount!, range));
case 'mood':
return mode === 'or'
? filterValues.some(val => book.metadata?.moods?.includes(val))
: filterValues.every(val => book.metadata?.moods?.includes(val));
case 'ageRating':
return filterValues.some(val => isAgeRatingMatch(book.metadata?.ageRating, val));
case 'contentRating':
return filterValues.includes(book.metadata?.contentRating);
default:
return false;
}
});
return mode === 'or' ? matches.some(m => m) : matches.every(m => m);
});
const filteredBooks = filterBooksByFilters(
bookState.books || [],
activeFilters as Record<string, unknown[]>,
mode
);
return {...bookState, books: filteredBooks};
})
);
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="dialogRef.close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="closeDialog()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -50,7 +50,7 @@
[dropdown]="true"
[showClear]="true"
placeholder="Search for a book in the same library..."
styleClass="full-width"
class="full-width"
[disabled]="isAttaching">
<ng-template let-book pTemplate="item">
<div class="book-suggestion">
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="dynamicDialogRef.close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -27,7 +27,7 @@
placeholder="Select Email Provider"
[(ngModel)]="selectedProvider"
appendTo="body"
styleClass="full-width">
class="full-width">
</p-select>
</div>
@@ -40,7 +40,7 @@
[(ngModel)]="selectedRecipient"
[disabled]="!selectedProvider"
appendTo="body"
styleClass="full-width">
class="full-width">
</p-select>
</div>
@@ -19,7 +19,7 @@
[rounded]="true"
severity="secondary"
(onClick)="closeDialog()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -15,7 +15,7 @@
[rounded]="true"
severity="secondary"
(onClick)="closeDialog()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -193,6 +193,7 @@ export interface BookMetadata {
tags?: string[];
provider?: string;
providerBookId?: string;
externalUrl?: string;
thumbnailUrl?: string | null;
reviews?: BookReview[];
titleLocked?: boolean;
@@ -5,12 +5,13 @@ import {FetchMetadataRequest} from '../../metadata/model/request/fetch-metadata-
import {BookMetadata} from '../model/book.model';
import {AuthService} from '../../../shared/service/auth.service';
import {SseClient} from 'ngx-sse-client';
import {HttpHeaders} from '@angular/common/http';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {map} from 'rxjs/operators';
@Injectable({providedIn: 'root'})
export class BookMetadataService {
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/books`;
private http = inject(HttpClient);
private authService = inject(AuthService);
private sseClient = inject(SseClient);
@@ -52,4 +53,8 @@ export class BookMetadataService {
})
);
}
fetchMetadataDetail(provider: string, providerItemId: string): Observable<BookMetadata> {
return this.http.get<BookMetadata>(`${this.url}/metadata/detail/${provider}/${providerItemId}`);
}
}
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="ref.close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -40,7 +40,7 @@
[label]="getPlaceholderLabel(placeholder.name)"
[pTooltip]="getPlaceholderTooltip(placeholder)"
tooltipPosition="top"
styleClass="placeholder-chip"
class="placeholder-chip"
(click)="insertPlaceholder(placeholder.name)">
</p-chip>
}
@@ -71,7 +71,7 @@
@for (preview of previewResults; track preview.fileName) {
<div class="preview-item" [ngClass]="getPreviewClass(preview)">
<div class="preview-filename">
<i class="pi"
<i class="pi"
[ngClass]="getPreviewIconClass(preview)"
[pTooltip]="getErrorTooltip(preview)"
tooltipPosition="top"
@@ -29,7 +29,7 @@
<p-button
label="Create Your Library"
icon="pi pi-plus"
styleClass="p-button-rounded p-button-outlined"
class="p-button-rounded p-button-outlined"
(click)="createNewLibrary()">
</p-button>
</div>
@@ -15,7 +15,7 @@
[rounded]="true"
severity="secondary"
(onClick)="cancel()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -14,7 +14,7 @@
[text]="true"
severity="secondary"
(click)="ref?.close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
}
@@ -161,6 +161,7 @@
<p-button pTooltip="Unlock Cover" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audiobookCover')" severity="warn"></p-button>
}
</div>
`
</div>
}
</div>
@@ -305,7 +306,7 @@
</div>
<div class="field-row">
<div class="field-group full-width">
<div class="field-group half-width">
<label for="moods">Moods</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
@@ -329,9 +330,7 @@
}
</div>
</div>
</div>
<div class="field-row">
<div class="field-group full-width">
<div class="field-group half-width">
<label for="tags">Tags</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
@@ -406,20 +405,45 @@
}
</div>
</div>
<div class="field-group small-field">
<label for="pageCount">Pages</label>
<label>Public Reviews</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>
<input pSize="small" pInputText [disabled]="true" value="No Value"/>
@if (!book.metadata!['reviewsLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('reviews')" severity="success"></p-button>
}
@if (book.metadata!['pageCountLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="warn"></p-button>
@if (book.metadata!['reviewsLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('reviews')" severity="warn"></p-button>
}
</div>
</div>
</div>
<div class="field-row">
<div class="field-group small-field">
<label for="isbn10">ISBN 10</label>
<div class="field-with-lock">
<input pInputText id="isbn10" formControlName="isbn10"/>
@if (!book.metadata!['isbn10Locked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="success"></p-button>
}
@if (book.metadata!['isbn10Locked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="warn"></p-button>
}
</div>
</div>
<div class="field-group small-field">
<label for="isbn13">ISBN 13</label>
<div class="field-with-lock">
<input pInputText id="isbn13" formControlName="isbn13"/>
@if (!book.metadata!['isbn13Locked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="success"></p-button>
}
@if (book.metadata!['isbn13Locked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="warn"></p-button>
}
</div>
</div>
<div class="field-group small-field">
<label for="ageRating">Age Rating</label>
<div class="field-with-lock">
@@ -441,7 +465,6 @@
}
</div>
</div>
<div class="field-group small-field">
<label for="contentRating">Content Rating</label>
<div class="field-with-lock">
@@ -463,309 +486,416 @@
}
</div>
</div>
<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>
}
@if (book.metadata!['pageCountLocked']) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="warn"></p-button>
}
</div>
</div>
</div>
</div>
</div>
<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>
}
@if (book.metadata!['reviewsLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('reviews')" severity="warn"></p-button>
}
<!-- Audiobook Metadata Section -->
@if (isAudiobook(book)) {
<div class="collapsible-section" [class.expanded]="audiobookSectionExpanded">
<div class="collapsible-header" (click)="audiobookSectionExpanded = !audiobookSectionExpanded">
<i class="pi pi-headphones"></i>
<span>Audiobook Details</span>
<i [class]="audiobookSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div>
@if (audiobookSectionExpanded) {
<div class="collapsible-content">
<div class="field-row metadata-ids-row">
@for (field of audiobookMetadataFields; track field) {
<div class="field-group metadata-id-field">
<label>{{ field.label }}</label>
<div class="field-with-lock">
@if (field.type === 'boolean') {
<p-select [formControlName]="field.controlName" [options]="booleanOptions" optionLabel="label" optionValue="value" appendTo="body"></p-select>
} @else {
<input pInputText [formControlName]="field.controlName"/>
}
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
</div>
<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>
}
@if (book.metadata!['isbn10Locked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="warn"></p-button>
}
}
<!-- Comic Book Metadata Section -->
@if (isCBX(book)) {
<div class="collapsible-section" [class.expanded]="comicSectionExpanded">
<div class="collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded">
<i class="pi pi-bolt"></i>
<span>Comic Book Details</span>
<i [class]="comicSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div>
@if (comicSectionExpanded) {
<div class="collapsible-content">
<!-- Text/number/boolean fields in grid -->
<div class="comic-text-grid">
@for (field of comicTextFields; track field) {
<div class="field-group">
<label>{{ field.label }}</label>
<div class="field-with-lock">
@if (field.type === 'boolean') {
<p-select [formControlName]="field.controlName" [options]="booleanOptions" optionLabel="label" optionValue="value" size="small" appendTo="body"></p-select>
} @else {
<input pSize="small" pInputText [formControlName]="field.controlName"/>
}
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
</div>
</div>
}
</div>
<!-- Array fields (creators, characters, teams, locations) -->
<div class="comic-array-grid">
@for (field of comicArrayFields; track field) {
<div class="field-group">
<label>{{ field.label }}</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
<p-autoComplete
[formControlName]="field.controlName"
[multiple]="true"
[dropdown]="false"
[suggestions]="[]"
[forceSelection]="false"
[showClear]="true"
(onKeyUp)="onAutoCompleteKeyUp(field.controlName, $event)"
(onSelect)="onAutoCompleteSelect(field.controlName, $event)">
</p-autoComplete>
</div>
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
</div>
</div>
}
</div>
<!-- Textarea fields (notes) -->
@for (field of comicTextareaFields; track field) {
<div class="field-row comic-array-row">
<div class="field-group full-width">
<label>{{ field.label }}</label>
<div class="field-with-lock description-with-lock">
<textarea pTextarea [formControlName]="field.controlName" rows="4"></textarea>
@if (!metadataForm.get(field.lockedKey)?.value) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
}
@if (metadataForm.get(field.lockedKey)?.value) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
</div>
</div>
</div>
}
</div>
}
</div>
<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>
}
@if (book.metadata!['isbn13Locked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="warn"></p-button>
}
</div>
}
<!-- Provider Metadata Section (collapsible) -->
<div class="collapsible-section" [class.expanded]="providerSectionExpanded">
<div class="collapsible-header" (click)="providerSectionExpanded = !providerSectionExpanded">
<i class="pi pi-database"></i>
<span>Provider Metadata</span>
<i [class]="providerSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div>
@if (isFieldVisible('asin')) {
<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>
@if (providerSectionExpanded) {
<div class="collapsible-content">
<div class="field-row metadata-ids-row">
@if (isFieldVisible('asin')) {
<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>
}
@if (book.metadata!['asinLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['asinLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
@if (isFieldVisible('amazonRating')) {
<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>
}
@if (book.metadata!['amazonRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('amazonRating')) {
<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>
@if (isFieldVisible('amazonReviewCount')) {
<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>
}
@if (book.metadata!['amazonReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['amazonRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonRating')" severity="warn"></p-button>
@if (isFieldVisible('googleId')) {
<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>
}
@if (book.metadata!['googleIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('amazonReviewCount')) {
<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>
@if (isFieldVisible('goodreadsId')) {
<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>
}
@if (book.metadata!['goodreadsIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['amazonReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('amazonReviewCount')" severity="warn"></p-button>
@if (isFieldVisible('goodreadsRating')) {
<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>
}
@if (book.metadata!['goodreadsRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('googleId')) {
<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>
@if (isFieldVisible('goodreadsReviewCount')) {
<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>
}
@if (book.metadata!['goodreadsReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['googleIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('googleId')" severity="warn"></p-button>
@if (isFieldVisible('hardcoverId')) {
<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>
}
@if (book.metadata!['hardcoverIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('goodreadsId')) {
<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>
@if (isFieldVisible('hardcoverBookId')) {
<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>
}
@if (book.metadata!['hardcoverBookIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverBookId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['goodreadsIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsId')" severity="warn"></p-button>
@if (isFieldVisible('hardcoverRating')) {
<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>
}
@if (book.metadata!['hardcoverRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('goodreadsRating')) {
<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>
@if (isFieldVisible('hardcoverReviewCount')) {
<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>
}
@if (book.metadata!['hardcoverReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['goodreadsRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsRating')" severity="warn"></p-button>
@if (isFieldVisible('lubimyczytacId')) {
<div class="field-group metadata-id-field">
<label for="lubimyczytacId">Lubimyczytac 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>
}
@if (book.metadata!['lubimyczytacIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('lubimyczytacId')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('goodreadsReviewCount')) {
<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>
@if (isFieldVisible('lubimyczytacRating')) {
<div class="field-group metadata-id-field">
<label for="lubimyczytacRating">Lubimyczytac ★</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>
}
@if (book.metadata!['lubimyczytacRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('lubimyczytacRating')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['goodreadsReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('goodreadsReviewCount')" severity="warn"></p-button>
@if (isFieldVisible('comicvineId')) {
<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>
}
@if (book.metadata!['comicvineIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('hardcoverId')) {
<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>
@if (isFieldVisible('ranobedbId')) {
<div class="field-group metadata-id-field">
<label for="ranobedbId">Ranobedb ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbId" formControlName="ranobedbId"/>
@if (!book.metadata!['ranobedbIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="success"></p-button>
}
@if (book.metadata!['ranobedbIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['hardcoverIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverId')" severity="warn"></p-button>
@if (isFieldVisible('ranobedbRating')) {
<div class="field-group metadata-id-field">
<label for="ranobedbRating">Ranobedb ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbRating" formControlName="ranobedbRating"/>
@if (!book.metadata!['ranobedbRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="success"></p-button>
}
@if (book.metadata!['ranobedbRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('hardcoverBookId')) {
<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>
@if (isFieldVisible('audibleId')) {
<div class="field-group metadata-id-field">
<label for="audibleId">Audible ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleId" formControlName="audibleId"/>
@if (!book.metadata!['audibleIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audibleId')" severity="success"></p-button>
}
@if (book.metadata!['audibleIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audibleId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (book.metadata!['hardcoverBookIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverBookId')" severity="warn"></p-button>
@if (isFieldVisible('audibleRating')) {
<div class="field-group metadata-id-field">
<label for="audibleRating">Audible ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleRating" formControlName="audibleRating"/>
@if (!book.metadata!['audibleRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audibleRating')" severity="success"></p-button>
}
@if (book.metadata!['audibleRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audibleRating')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
}
@if (isFieldVisible('hardcoverRating')) {
<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>
}
@if (book.metadata!['hardcoverRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverRating')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('hardcoverReviewCount')) {
<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>
}
@if (book.metadata!['hardcoverReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('hardcoverReviewCount')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('lubimyczytacId')) {
<div class="field-group metadata-id-field">
<label for="lubimyczytacId">Lubimyczytac 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>
}
@if (book.metadata!['lubimyczytacIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('lubimyczytacId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('lubimyczytacRating')) {
<div class="field-group metadata-id-field">
<label for="lubimyczytacRating">Lubimyczytac ★</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>
}
@if (book.metadata!['lubimyczytacRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('lubimyczytacRating')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('comicvineId')) {
<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>
}
@if (book.metadata!['comicvineIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('ranobedbId')) {
<div class="field-group metadata-id-field">
<label for="ranobedbId">Ranobedb ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbId" formControlName="ranobedbId"/>
@if (!book.metadata!['ranobedbIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="success"></p-button>
}
@if (book.metadata!['ranobedbIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('ranobedbRating')) {
<div class="field-group metadata-id-field">
<label for="ranobedbRating">Ranobedb ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbRating" formControlName="ranobedbRating"/>
@if (!book.metadata!['ranobedbRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="success"></p-button>
}
@if (book.metadata!['ranobedbRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('audibleId')) {
<div class="field-group metadata-id-field">
<label for="audibleId">Audible ID</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleId" formControlName="audibleId"/>
@if (!book.metadata!['audibleIdLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audibleId')" severity="success"></p-button>
}
@if (book.metadata!['audibleIdLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audibleId')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('audibleRating')) {
<div class="field-group metadata-id-field">
<label for="audibleRating">Audible ★</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleRating" formControlName="audibleRating"/>
@if (!book.metadata!['audibleRatingLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audibleRating')" severity="success"></p-button>
}
@if (book.metadata!['audibleRatingLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audibleRating')" severity="warn"></p-button>
}
</div>
</div>
}
@if (isFieldVisible('audibleReviewCount')) {
<div class="field-group metadata-id-field">
<label for="audibleReviewCount">Audible #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleReviewCount" formControlName="audibleReviewCount"/>
@if (!book.metadata!['audibleReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audibleReviewCount')" severity="success"></p-button>
}
@if (book.metadata!['audibleReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audibleReviewCount')" severity="warn"></p-button>
@if (isFieldVisible('audibleReviewCount')) {
<div class="field-group metadata-id-field">
<label for="audibleReviewCount">Audible #</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleReviewCount" formControlName="audibleReviewCount"/>
@if (!book.metadata!['audibleReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audibleReviewCount')" severity="success"></p-button>
}
@if (book.metadata!['audibleReviewCountLocked']) {
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audibleReviewCount')" severity="warn"></p-button>
}
</div>
</div>
}
</div>
</div>
@@ -239,7 +239,7 @@ label {
.language-field {
@media (min-width: 768px) {
width: 9rem;
width: 11rem;
}
}
@@ -271,21 +271,31 @@ label {
width: 100%;
}
.half-width {
width: 100%;
@media (min-width: 768px) {
flex: 1;
}
}
.series-name-field {
@media (min-width: 768px) {
flex-basis: 75%;
flex: 4.75;
min-width: 0;
}
}
.small-field {
@media (min-width: 768px) {
width: 9rem;
flex: 1;
min-width: 0;
}
}
.metadata-ids-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 1rem;
width: 100%;
@@ -300,6 +310,76 @@ label {
}
}
.collapsible-section {
margin-top: 1rem;
width: 100%;
background: var(--card-background);
border: 1px solid var(--border-color);
border-radius: 0.75rem;
.collapsible-header {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1rem;
min-height: 2.5rem;
background: var(--surface-ground);
border-radius: 0.75rem;
font-size: 0.875rem;
font-weight: 600;
color: var(--text-color);
cursor: pointer;
user-select: none;
transition: background 0.2s ease;
&:hover {
background: var(--surface-hover);
}
i:first-child {
font-size: 0.9rem;
color: var(--primary-color);
}
.section-toggle {
margin-left: auto;
font-size: 0.75rem;
color: var(--text-secondary-color);
}
}
&.expanded .collapsible-header {
border-radius: 0.75rem 0.75rem 0 0;
}
.collapsible-content {
padding: 0.75rem;
border-top: 1px solid var(--border-color);
}
}
.comic-text-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 1rem;
margin-bottom: 1rem;
@media (max-width: 767px) {
grid-template-columns: repeat(2, 1fr);
}
}
.comic-array-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1rem;
margin-bottom: 1rem;
@media (max-width: 767px) {
grid-template-columns: 1fr;
}
}
.description-section {
display: flex;
flex-direction: column;
@@ -335,7 +415,8 @@ label {
input,
p-autocomplete,
p-datepicker {
p-datepicker,
p-select {
width: 100%;
}
}
@@ -6,8 +6,9 @@ import {FormControl, FormGroup, FormsModule, ReactiveFormsModule,} from "@angula
import {Observable, sample} from "rxjs";
import {AsyncPipe} from "@angular/common";
import {MessageService} from "primeng/api";
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper,} from "../../../../book/model/book.model";
import {Book, BookMetadata, ComicMetadata, MetadataClearFlags, MetadataUpdateWrapper,} from "../../../../book/model/book.model";
import {UrlHelperService} from "../../../../../shared/service/url-helper.service";
import {ALL_COMIC_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELDS, COMIC_FORM_TO_MODEL_LOCK, COMIC_TEXT_METADATA_FIELDS, COMIC_ARRAY_METADATA_FIELDS, COMIC_TEXTAREA_METADATA_FIELDS, MetadataFieldConfig} from '../../../../../shared/metadata';
import {FileUpload, FileUploadErrorEvent, FileUploadEvent,} from "primeng/fileupload";
import {HttpResponse} from "@angular/common/http";
import {BookService} from "../../../../book/service/book.service";
@@ -106,6 +107,20 @@ export class MetadataEditorComponent implements OnInit {
contentRatingOptions: {label: string, value: string}[] = [];
ageRatingOptions: {label: string, value: number}[] = [];
booleanOptions: {label: string, value: boolean | null}[] = [
{label: 'Unknown', value: null},
{label: 'Yes', value: true},
{label: 'No', value: false},
];
comicSectionExpanded = true;
audiobookSectionExpanded = true;
providerSectionExpanded = true;
comicTextFields = COMIC_TEXT_METADATA_FIELDS;
comicArrayFields = COMIC_ARRAY_METADATA_FIELDS;
comicTextareaFields = COMIC_TEXTAREA_METADATA_FIELDS;
audiobookMetadataFields = AUDIOBOOK_METADATA_FIELDS;
providerSpecificFields: MetadataProviderSpecificFields = {
asin: true,
@@ -274,6 +289,20 @@ export class MetadataEditorComponent implements OnInit {
{label: '18+', value: 18},
{label: '21+', value: 21}
];
// Add audiobook metadata form controls
for (const field of AUDIOBOOK_METADATA_FIELDS) {
const defaultValue = field.type === 'boolean' ? null : '';
this.metadataForm.addControl(field.controlName, new FormControl(defaultValue));
this.metadataForm.addControl(field.lockedKey, new FormControl(false));
}
// Add comic metadata form controls
for (const field of ALL_COMIC_METADATA_FIELDS) {
const defaultValue = field.type === 'array' ? [] : (field.type === 'number' || field.type === 'boolean') ? null : '';
this.metadataForm.addControl(field.controlName, new FormControl(defaultValue));
this.metadataForm.addControl(field.lockedKey, new FormControl(false));
}
}
ngOnInit(): void {
@@ -434,6 +463,33 @@ export class MetadataEditorComponent implements OnInit {
contentRatingLocked: metadata.contentRatingLocked ?? false,
});
// Patch audiobook metadata
const audiobookPatch: Record<string, unknown> = {};
for (const field of AUDIOBOOK_METADATA_FIELDS) {
const key = field.controlName as keyof BookMetadata;
const lockedKey = field.lockedKey as keyof BookMetadata;
audiobookPatch[field.controlName] = metadata[key] ?? (field.type === 'boolean' ? null : '');
audiobookPatch[field.lockedKey] = metadata[lockedKey] ?? false;
}
this.metadataForm.patchValue(audiobookPatch);
// Patch comic metadata
const comicMeta = metadata.comicMetadata;
const comicPatch: Record<string, unknown> = {};
for (const field of ALL_COMIC_METADATA_FIELDS) {
const value = comicMeta?.[field.fetchedKey as keyof ComicMetadata];
if (field.type === 'array') {
comicPatch[field.controlName] = [...(value as string[] ?? [])].sort();
} else if (field.type === 'boolean' || field.type === 'number') {
comicPatch[field.controlName] = value ?? null;
} else {
comicPatch[field.controlName] = value ?? '';
}
const modelLockKey = COMIC_FORM_TO_MODEL_LOCK[field.lockedKey];
comicPatch[field.lockedKey] = comicMeta?.[modelLockKey as keyof ComicMetadata] ?? false;
}
this.metadataForm.patchValue(comicPatch);
const lockableFields: { key: keyof BookMetadata; control: string }[] = [
{key: "titleLocked", control: "title"},
{key: "subtitleLocked", control: "subtitle"},
@@ -485,6 +541,24 @@ export class MetadataEditorComponent implements OnInit {
isLocked ? formControl.disable() : formControl.enable();
}
}
// Apply audiobook lock states
for (const field of AUDIOBOOK_METADATA_FIELDS) {
const isLocked = this.metadataForm.get(field.lockedKey)?.value === true;
const formControl = this.metadataForm.get(field.controlName);
if (formControl) {
isLocked ? formControl.disable() : formControl.enable();
}
}
// Apply comic lock states
for (const field of ALL_COMIC_METADATA_FIELDS) {
const isLocked = this.metadataForm.get(field.lockedKey)?.value === true;
const formControl = this.metadataForm.get(field.controlName);
if (formControl) {
isLocked ? formControl.disable() : formControl.enable();
}
}
}
onAutoCompleteSelect(fieldName: string, event: AutoCompleteSelectEvent) {
@@ -628,6 +702,12 @@ export class MetadataEditorComponent implements OnInit {
thumbnailUrl: form.get("thumbnailUrl")?.value,
audiobookCover: form.get("audiobookCover")?.value,
// Audiobook metadata
narrator: form.get("narrator")?.value,
abridged: form.get("abridged")?.value,
narratorLocked: form.get("narratorLocked")?.value,
abridgedLocked: form.get("abridgedLocked")?.value,
// Locks
titleLocked: form.get("titleLocked")?.value,
subtitleLocked: form.get("subtitleLocked")?.value,
@@ -677,6 +757,35 @@ export class MetadataEditorComponent implements OnInit {
}),
};
// Build comic metadata from form controls
const comicMetadata: Record<string, unknown> = {};
for (const field of ALL_COMIC_METADATA_FIELDS) {
const value = form.get(field.controlName)?.value;
if (field.type === 'array') {
comicMetadata[field.fetchedKey] = Array.isArray(value) ? value : [];
} else if (field.type === 'number') {
comicMetadata[field.fetchedKey] = value !== '' && value !== null ? Number(value) : null;
} else if (field.type === 'boolean') {
comicMetadata[field.fetchedKey] = value ?? null;
} else {
comicMetadata[field.fetchedKey] = value ?? '';
}
}
// Consolidate comic lock states to model lock keys
const lockGroups: Record<string, boolean> = {};
for (const [formKey, modelKey] of Object.entries(COMIC_FORM_TO_MODEL_LOCK)) {
const value = form.get(formKey)?.value ?? false;
if (value) {
lockGroups[modelKey] = true;
} else if (!(modelKey in lockGroups)) {
lockGroups[modelKey] = false;
}
}
for (const [modelKey, value] of Object.entries(lockGroups)) {
comicMetadata[modelKey] = value;
}
metadata.comicMetadata = comicMetadata as ComicMetadata;
const original = this.originalMetadata;
const wasCleared = (key: keyof BookMetadata): boolean => {
@@ -725,6 +834,8 @@ export class MetadataEditorComponent implements OnInit {
seriesName: wasCleared("seriesName"),
seriesNumber: wasCleared("seriesNumber"),
seriesTotal: wasCleared("seriesTotal"),
narrator: wasCleared("narrator"),
abridged: wasCleared("abridged"),
audiobookCover: wasCleared("audiobookCover"),
cover: false,
ageRating: wasCleared("ageRating"),
@@ -1051,6 +1162,14 @@ export class MetadataEditorComponent implements OnInit {
return this.bookService.supportsDualCovers(book);
}
isCBX(book: Book): boolean {
return book.primaryFile?.bookType === 'CBX';
}
isAudiobook(book: Book): boolean {
return book.primaryFile?.bookType === 'AUDIOBOOK';
}
getUploadAudiobookCoverUrl(): string {
return this.bookService.getUploadAudiobookCoverUrl(this.currentBookId);
}
@@ -1,6 +1,13 @@
@if (book$ | async; as book) {
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="metadata-picker">
<div class="dialog-body">
@if (detailLoading) {
<div class="detail-loading-banner">
<i class="pi pi-spin pi-spinner"></i>
<span>Loading complete metadata...</span>
</div>
}
<!-- Column Headers (Desktop) -->
<div class="column-headers desktop-only">
<div class="column-label current">
@@ -434,51 +441,170 @@
</div>
</section>
<!-- Provider Metadata Section -->
@if (metadataProviderFields.length > 0) {
<!-- Comic Book Details Section -->
@if (shouldShowComicSection()) {
<section class="form-section">
<div class="section-header">
<i class="pi pi-cloud"></i>
<span>Provider Metadata</span>
<div class="section-header collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded">
<i class="pi pi-bolt"></i>
<span>Comic Book Details</span>
@if (!hasAnyFetchedComicData() && !hasAnyCurrentComicData()) {
<span class="section-empty-badge">none present</span>
}
<i [class]="comicSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div>
<div class="section-content">
@for (field of metadataProviderFields; track field) {
<div class="field-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
@if (comicSectionExpanded) {
<div class="section-content">
<!-- Comic text/number/boolean fields -->
@for (field of comicTextFields; track field) {
<div class="field-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
@if (field.type === 'boolean') {
<p-checkbox
formControlName="{{field.controlName}}"
[binary]="true"
class="field-checkbox"
/>
} @else {
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
}
</div>
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
</div>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched">
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-input" readonly/>
<div class="field-side fetched">
@if (field.type === 'boolean') {
<p-checkbox
[ngModel]="getFetchedComicValue(field.fetchedKey)"
[ngModelOptions]="{ standalone: true }"
[binary]="true"
[disabled]="true"
class="field-checkbox"
/>
} @else {
<input pInputText [value]="getFetchedComicValue(field.fetchedKey) ?? ''" class="field-input" readonly/>
}
</div>
</div>
</div>
</div>
}
</div>
}
<!-- Comic array fields (creators, characters, teams, locations) -->
@for (field of comicArrayFields; track field) {
<div class="field-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
<p-autoComplete
class="chips-input"
formControlName="{{field.controlName}}"
[multiple]="true"
[dropdown]="false"
[forceSelection]="false"
[showClear]="true"
[suggestions]="getFiltered(field.controlName)"
(completeMethod)="filterItems($event, field.controlName)"
(onKeyUp)="onAutoCompleteKeyUp(field.controlName, $event)"
(onSelect)="onAutoCompleteSelect(field.controlName, $event)"
/>
</div>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched">
<p-autoComplete
[ngModel]="getFetchedComicValue(field.fetchedKey) ?? []"
[ngModelOptions]="{ standalone: true }"
[disabled]="true"
[multiple]="true"
[typeahead]="false"
[dropdown]="false"
[forceSelection]="false"
class="chips-input readonly"
/>
</div>
</div>
</div>
}
<!-- Comic textarea fields (notes) -->
@for (field of comicTextareaFields; track field) {
<div class="field-row textarea-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
<textarea pTextarea formControlName="{{field.controlName}}" class="field-textarea" rows="3"></textarea>
</div>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched">
<textarea pTextarea [value]="getFetchedComicValue(field.fetchedKey) ?? ''" class="field-textarea" rows="3" readonly></textarea>
</div>
</div>
</div>
}
</div>
}
</section>
}
@@ -547,6 +673,54 @@
</div>
</section>
}
<!-- Provider Metadata Section -->
@if (metadataProviderFields.length > 0) {
<section class="form-section">
<div class="section-header">
<i class="pi pi-cloud"></i>
<span>Provider Metadata</span>
</div>
<div class="section-content">
@for (field of metadataProviderFields; track field) {
<div class="field-row">
<label class="field-label">{{ field.label }}</label>
<div class="field-content">
<div class="field-side current">
<button
type="button"
class="lock-btn"
[class.locked]="metadataForm.get(field.lockedKey)?.value"
(click)="toggleLock(field.controlName)"
>
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
</button>
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
</div>
<button
type="button"
class="transfer-btn"
[class.saved]="isValueSaved(field.controlName)"
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
(mouseenter)="onMouseEnter(field.controlName)"
(mouseleave)="onMouseLeave(field.controlName)"
>
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
</button>
<div class="field-side fetched">
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-input" readonly/>
</div>
</div>
</div>
}
</div>
</section>
}
</div>
@if (!reviewMode) {
@@ -25,6 +25,26 @@
}
// Detail loading banner
.detail-loading-banner {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.625rem 1rem;
background: rgba(34, 197, 94, 0.1);
border: 1px solid rgba(34, 197, 94, 0.3);
border-radius: 8px;
color: var(--p-green-400);
font-size: 0.875rem;
font-weight: 600;
animation: fadeIn 0.3s ease-in;
i {
font-size: 1rem;
}
}
// Body
.dialog-body {
flex: 1;
@@ -128,6 +148,35 @@
font-size: 0.9rem;
color: var(--primary-color);
}
&.collapsible-header {
cursor: pointer;
user-select: none;
transition: color 0.2s ease;
&:hover {
color: var(--text-color);
}
.section-toggle {
margin-left: auto;
font-size: 0.75rem;
color: var(--text-secondary-color);
}
}
.section-empty-badge {
font-size: 0.7rem;
font-weight: 500;
text-transform: none;
letter-spacing: normal;
color: var(--text-secondary-color);
background: var(--surface-ground);
border: 1px solid var(--border-color);
border-radius: 4px;
padding: 0.125rem 0.5rem;
opacity: 0.8;
}
}
.section-content {
@@ -1,5 +1,5 @@
import {Component, DestroyRef, EventEmitter, inject, Input, OnInit, Output} from '@angular/core';
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../../book/model/book.model';
import {Book, BookMetadata, ComicMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../../book/model/book.model';
import {MessageService} from 'primeng/api';
import {Button} from 'primeng/button';
import {FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
@@ -18,7 +18,7 @@ import {Checkbox} from 'primeng/checkbox';
import {LazyLoadImageModule} from 'ng-lazyload-image';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model';
import {ALL_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELDS, getArrayFields, getBookDetailsFields, getBottomFields, getProviderFields, getSeriesFields, getTextareaFields, getTopFields, MetadataFieldConfig, MetadataFormBuilder, MetadataUtilsService} from '../../../../../shared/metadata';
import {ALL_COMIC_METADATA_FIELDS, ALL_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELDS, COMIC_ARRAY_METADATA_FIELDS, COMIC_FORM_TO_MODEL_LOCK, COMIC_TEXT_METADATA_FIELDS, COMIC_TEXTAREA_METADATA_FIELDS, getArrayFields, getBookDetailsFields, getBottomFields, getProviderFields, getSeriesFields, getTextareaFields, getTopFields, MetadataFieldConfig, MetadataFormBuilder, MetadataUtilsService} from '../../../../../shared/metadata';
@Component({
selector: 'app-metadata-picker',
@@ -50,10 +50,15 @@ export class MetadataPickerComponent implements OnInit {
metadataProviderFields: MetadataFieldConfig[] = [];
metadataFieldsBottom: MetadataFieldConfig[] = [];
audiobookMetadataFields: MetadataFieldConfig[] = [];
comicTextFields: MetadataFieldConfig[] = [];
comicArrayFields: MetadataFieldConfig[] = [];
comicTextareaFields: MetadataFieldConfig[] = [];
comicSectionExpanded = false;
@Input() reviewMode!: boolean;
@Input() fetchedMetadata!: BookMetadata;
@Input() book$!: Observable<Book | null>;
@Input() detailLoading = false;
@Output() goBack = new EventEmitter<boolean>();
currentBook: Book | null = null;
@@ -93,6 +98,9 @@ export class MetadataPickerComponent implements OnInit {
this.updateProviderFields();
this.updateBottomFields();
this.audiobookMetadataFields = AUDIOBOOK_METADATA_FIELDS;
this.comicTextFields = COMIC_TEXT_METADATA_FIELDS;
this.comicArrayFields = COMIC_ARRAY_METADATA_FIELDS;
this.comicTextareaFields = COMIC_TEXTAREA_METADATA_FIELDS;
}
private updateProviderFields(): void {
@@ -209,8 +217,26 @@ export class MetadataPickerComponent implements OnInit {
patchData[field.lockedKey] = topLevelLocked ?? false;
}
// Handle comic book metadata fields (nested under comicMetadata)
const comicMeta = metadata.comicMetadata;
for (const field of ALL_COMIC_METADATA_FIELDS) {
const value = comicMeta?.[field.fetchedKey as keyof ComicMetadata];
if (field.type === 'array') {
patchData[field.controlName] = [...(value as string[] ?? [])].sort();
} else if (field.type === 'boolean') {
patchData[field.controlName] = value ?? null;
} else if (field.type === 'number') {
patchData[field.controlName] = value ?? null;
} else {
patchData[field.controlName] = value ?? '';
}
const modelLockKey = COMIC_FORM_TO_MODEL_LOCK[field.lockedKey];
patchData[field.lockedKey] = comicMeta?.[modelLockKey as keyof ComicMetadata] ?? false;
}
this.metadataForm.patchValue(patchData);
this.applyLockStates(metadata);
this.comicSectionExpanded = this.hasAnyFetchedComicData() || this.hasAnyCurrentComicData();
}
private applyLockStates(metadata: BookMetadata): void {
@@ -222,6 +248,12 @@ export class MetadataPickerComponent implements OnInit {
for (const field of AUDIOBOOK_METADATA_FIELDS) {
lockedFields[field.lockedKey] = !!metadata[field.lockedKey as keyof BookMetadata];
}
// Handle comic book metadata lock states (nested under comicMetadata)
const comicMeta = metadata.comicMetadata;
for (const field of ALL_COMIC_METADATA_FIELDS) {
const modelLockKey = COMIC_FORM_TO_MODEL_LOCK[field.lockedKey];
lockedFields[field.lockedKey] = !!comicMeta?.[modelLockKey as keyof ComicMetadata];
}
this.formBuilder.applyLockStates(this.metadataForm, lockedFields);
}
@@ -326,6 +358,35 @@ export class MetadataPickerComponent implements OnInit {
metadata[field.lockedKey] = this.metadataForm.get(field.lockedKey)?.value ?? false;
}
// Build comic metadata from form controls
const comicMetadata: Record<string, unknown> = {};
for (const field of ALL_COMIC_METADATA_FIELDS) {
if (field.type === 'array') {
comicMetadata[field.fetchedKey] = this.getArrayValue(field.controlName);
} else if (field.type === 'number') {
comicMetadata[field.fetchedKey] = this.getNumberValue(field.controlName);
} else if (field.type === 'boolean') {
comicMetadata[field.fetchedKey] = this.getBooleanValue(field.controlName);
} else {
comicMetadata[field.fetchedKey] = this.getStringValue(field.controlName);
}
}
// Consolidate lock states back to model lock keys using the form-to-model mapping.
// If ANY field in a group is locked, the backend group lock is set to true.
const lockGroups: Record<string, boolean> = {};
for (const [formKey, modelKey] of Object.entries(COMIC_FORM_TO_MODEL_LOCK)) {
const value = this.metadataForm.get(formKey)?.value ?? false;
if (value) {
lockGroups[modelKey] = true;
} else if (!(modelKey in lockGroups)) {
lockGroups[modelKey] = false;
}
}
for (const [modelKey, value] of Object.entries(lockGroups)) {
comicMetadata[modelKey] = value;
}
metadata['comicMetadata'] = comicMetadata;
return metadata as BookMetadata;
}
@@ -411,6 +472,27 @@ export class MetadataPickerComponent implements OnInit {
}
}
// Handle comic metadata clear flags
const currComic = current.comicMetadata;
const origComic = original.comicMetadata;
if (origComic) {
for (const field of ALL_COMIC_METADATA_FIELDS) {
const key = field.fetchedKey as keyof ComicMetadata;
const curr = currComic?.[key];
const orig = origComic[key];
if (field.type === 'array') {
flags[`comic_${key}`] = !(curr as string[])?.length && !!(orig as string[])?.length;
} else if (field.type === 'boolean') {
flags[`comic_${key}`] = curr === null && orig !== null;
} else if (field.type === 'number') {
flags[`comic_${key}`] = curr === null && orig !== null;
} else {
flags[`comic_${key}`] = !curr && !!orig;
}
}
}
return flags as MetadataClearFlags;
}
@@ -478,6 +560,21 @@ export class MetadataPickerComponent implements OnInit {
this.copiedFields,
(field) => this.copyFetchedToCurrent(field)
);
// Also copy missing comic fields
if (this.fetchedMetadata?.comicMetadata) {
for (const field of ALL_COMIC_METADATA_FIELDS) {
const isLocked = this.metadataForm.get(field.lockedKey)?.value;
const currentValue = this.metadataForm.get(field.controlName)?.value;
const fetchedValue = this.fetchedMetadata.comicMetadata[field.fetchedKey as keyof ComicMetadata];
const isEmpty = Array.isArray(currentValue)
? currentValue.length === 0
: (currentValue === null || currentValue === undefined || currentValue === '');
const hasFetchedValue = fetchedValue !== null && fetchedValue !== undefined && fetchedValue !== '';
if (!isLocked && isEmpty && hasFetchedValue) {
this.copyFetchedToCurrent(field.controlName);
}
}
}
}
copyAll(): void {
@@ -486,9 +583,40 @@ export class MetadataPickerComponent implements OnInit {
this.metadataForm,
(field) => this.copyFetchedToCurrent(field)
);
// Also copy all comic fields
if (this.fetchedMetadata?.comicMetadata) {
for (const field of ALL_COMIC_METADATA_FIELDS) {
const isLocked = this.metadataForm.get(field.lockedKey)?.value;
const fetchedValue = this.fetchedMetadata.comicMetadata[field.fetchedKey as keyof ComicMetadata];
if (!isLocked && fetchedValue != null && fetchedValue !== '') {
this.copyFetchedToCurrent(field.controlName);
}
}
}
}
copyFetchedToCurrent(field: string): void {
// Handle comic fields (nested under comicMetadata)
const comicConfig = this.getComicFieldConfig(field);
if (comicConfig) {
const isLocked = this.metadataForm.get(comicConfig.lockedKey)?.value;
if (isLocked) {
this.messageService.add({
severity: 'warn',
summary: 'Action Blocked',
detail: `${comicConfig.label} is locked and cannot be updated.`
});
return;
}
const value = this.fetchedMetadata?.comicMetadata?.[comicConfig.fetchedKey as keyof ComicMetadata];
if (value !== null && value !== undefined && value !== '') {
this.metadataForm.get(field)?.setValue(value);
this.copiedFields[field] = true;
this.highlightCopiedInput(field);
}
return;
}
let lockField = field;
if (field === 'thumbnailUrl') {
lockField = 'cover';
@@ -552,6 +680,14 @@ export class MetadataPickerComponent implements OnInit {
}
resetField(field: string): void {
const comicConfig = this.getComicFieldConfig(field);
if (comicConfig) {
const value = this.originalMetadata?.comicMetadata?.[comicConfig.fetchedKey as keyof ComicMetadata];
this.metadataForm.get(field)?.setValue(value ?? (comicConfig.type === 'array' ? [] : comicConfig.type === 'boolean' ? null : ''));
this.copiedFields[field] = false;
this.hoveredFields[field] = false;
return;
}
this.metadataUtils.resetField(field, this.metadataForm, this.originalMetadata, this.copiedFields, this.hoveredFields);
}
@@ -580,4 +716,41 @@ export class MetadataPickerComponent implements OnInit {
supportsDualCovers(book: Book): boolean {
return this.hasEbookFormat(book) && this.hasAudiobookFormat(book);
}
// Comic metadata helpers
hasAnyFetchedComicData(): boolean {
const comic = this.fetchedMetadata?.comicMetadata;
if (!comic) return false;
return ALL_COMIC_METADATA_FIELDS.some(field => {
const value = comic[field.fetchedKey as keyof ComicMetadata];
if (value === null || value === undefined || value === '' || value === false) return false;
if (Array.isArray(value) && value.length === 0) return false;
return true;
});
}
hasAnyCurrentComicData(): boolean {
const comic = this.currentBook?.metadata?.comicMetadata;
if (!comic) return false;
return ALL_COMIC_METADATA_FIELDS.some(field => {
const value = comic[field.fetchedKey as keyof ComicMetadata];
if (value === null || value === undefined || value === '' || value === false) return false;
if (Array.isArray(value) && value.length === 0) return false;
return true;
});
}
shouldShowComicSection(): boolean {
return this.hasAnyFetchedComicData() || this.hasAnyCurrentComicData() ||
this.currentBook?.primaryFile?.bookType === 'CBX' ||
this.fetchedMetadata?.provider?.toLowerCase() === 'comicvine';
}
getFetchedComicValue(fetchedKey: string): unknown {
return this.fetchedMetadata?.comicMetadata?.[fetchedKey as keyof ComicMetadata];
}
private getComicFieldConfig(controlName: string): MetadataFieldConfig | undefined {
return ALL_COMIC_METADATA_FIELDS.find(f => f.controlName === controlName);
}
}
@@ -3,6 +3,7 @@
<app-metadata-picker
[fetchedMetadata]="selectedFetchedMetadata"
[book$]="book$"
[detailLoading]="detailLoading"
(goBack)="onGoBack()">
</app-metadata-picker>
</div>
@@ -44,6 +44,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
@Input() book$!: Observable<Book | null>;
selectedFetchedMetadata$ = new BehaviorSubject<BookMetadata | null>(null);
detailLoading = false;
private formBuilder = inject(FormBuilder);
private bookMetadataService = inject(BookMetadataService);
@@ -267,7 +268,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
if (metadata.comicvineId) return 'comicvine';
if (metadata.ranobedbId) return 'ranobedb';
if (metadata.audibleId) return 'audible';
return null;
return metadata.provider?.toLowerCase() || null;
}
getProviderClass(metadata: BookMetadata): string {
@@ -341,9 +342,64 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
onBookClick(fetchedMetadata: BookMetadata) {
this.selectedFetchedMetadata$.next(fetchedMetadata);
const enrichment = this.getDetailEnrichmentInfo(fetchedMetadata);
if (enrichment) {
this.detailLoading = true;
this.bookMetadataService.fetchMetadataDetail(enrichment.provider, enrichment.id)
.pipe(takeUntil(this.cancelRequest$))
.subscribe({
next: (enriched) => {
const current = this.selectedFetchedMetadata$.value;
const currentId = current && this.getProviderItemId(current, enrichment.provider);
if (currentId === enrichment.id) {
this.selectedFetchedMetadata$.next(enriched);
}
this.detailLoading = false;
},
error: (err) => {
console.error('Error fetching detailed metadata:', err);
this.detailLoading = false;
}
});
}
}
private getDetailEnrichmentInfo(metadata: BookMetadata): { provider: string; id: string } | null {
if (metadata.comicvineId && (!metadata.comicMetadata
|| (!metadata.comicMetadata.pencillers?.length
&& !metadata.comicMetadata.inkers?.length
&& !metadata.comicMetadata.colorists?.length
&& !metadata.comicMetadata.letterers?.length
&& !metadata.comicMetadata.editors?.length
&& !metadata.comicMetadata.characters?.length))) {
return {provider: 'Comicvine', id: metadata.comicvineId};
}
if (metadata.goodreadsId && !metadata.description) {
return {provider: 'GoodReads', id: metadata.goodreadsId};
}
if (metadata.asin && !metadata.description) {
return {provider: 'Amazon', id: metadata.asin};
}
if (metadata.audibleId && !metadata.description) {
return {provider: 'Audible', id: metadata.audibleId};
}
return null;
}
private getProviderItemId(metadata: BookMetadata, provider: string): string | undefined {
switch (provider) {
case 'Comicvine': return metadata.comicvineId;
case 'GoodReads': return metadata.goodreadsId;
case 'Amazon': return metadata.asin;
case 'Audible': return metadata.audibleId;
default: return undefined;
}
}
onGoBack() {
this.detailLoading = false;
this.selectedFetchedMetadata$.next(null);
}
@@ -371,16 +427,17 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
} else if (metadata['lubimyczytacId']) {
return `<a href="https://lubimyczytac.pl/ksiazka/${metadata['lubimyczytacId']}/ksiazka" target="_blank">Lubimyczytac</a>`;
} else if (metadata.comicvineId) {
if (metadata.comicvineId.startsWith('4000')) {
const name = metadata.seriesName ? metadata.seriesName.replace(/ /g, '-').toLowerCase() + "-" + metadata.seriesNumber : '';
return `<a href="https://comicvine.gamespot.com/${name}/${metadata.comicvineId}" target="_blank">Comicvine</a>`;
if (metadata.externalUrl) {
return `<a href="${metadata.externalUrl}" target="_blank">Comicvine</a>`;
}
const name = metadata.seriesName;
return `<a href="https://comicvine.gamespot.com/volume/${metadata.comicvineId}" target="_blank">Comicvine</a>`;
return `<a href="https://comicvine.gamespot.com/4050-${metadata.comicvineId}/" target="_blank">Comicvine</a>`;
} else if (metadata.ranobedbId) {
return `<a href="https://ranobedb.org/book/${metadata.ranobedbId}" target="_blank">RanobeDB</a>`;
} else if (metadata.audibleId) {
return `<a href="https://www.audible.com/pd/${metadata.audibleId}" target="_blank">Audible</a>`;
} else if (metadata.externalUrl) {
const providerName = metadata.provider || 'Link';
return `<a href="${metadata.externalUrl}" target="_blank">${providerName}</a>`;
}
throw new Error("No provider ID found in metadata.");
}
@@ -85,7 +85,7 @@
width="200"
appendTo="body"
[preview]="true"
styleClass="square-cover">
class="square-cover">
</p-image>
</div>
</div>
@@ -254,10 +254,10 @@
</a>
}
@if (book?.metadata?.comicvineId) {
@if (book?.metadata?.comicMetadata?.webLink) {
<a
class="rating-link"
[href]="'https://comicvine.gamespot.com/' + book.metadata!.comicvineId"
[href]="book.metadata!.comicMetadata!.webLink"
target="_blank"
rel="noopener noreferrer"
>
@@ -10,7 +10,7 @@
<p-tag
[value]="getSyncStatusLabel()"
[severity]="getSyncStatusSeverity()"
styleClass="sync-status-tag"
class="sync-status-tag"
/>
</div>
</div>
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="ref.close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="dynamicDialogRef.close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -162,7 +162,7 @@
header="Merge/Split {{ currentMergeType | titlecase }}"
[(visible)]="showMergeDialog"
[modal]="true"
styleClass="user-dialog"
class="user-dialog"
[style]="{width: '50rem'}">
<div class="dialog-form">
<p>You are merging/splitting {{ getSelectedItems(currentMergeType).length }} {{ currentMergeType }}:</p>
@@ -238,7 +238,7 @@
header="Rename/Split {{ currentMergeType | titlecase }}"
[(visible)]="showRenameDialog"
[modal]="true"
styleClass="user-dialog"
class="user-dialog"
[style]="{width: '40rem'}">
<div class="dialog-form">
<p>You are renaming/splitting:</p>
@@ -308,7 +308,7 @@
header="Delete {{ currentMergeType | titlecase }}"
[(visible)]="showDeleteDialog"
[modal]="true"
styleClass="user-dialog"
class="user-dialog"
[style]="{width: '40rem'}">
<div class="dialog-form">
<div class="warning-message">
@@ -36,28 +36,28 @@
<p-select [options]="providersWithClear" [(ngModel)]="bulkP1"
(ngModelChange)="setBulkProvider('p1', $event)"
placeholder="Set all P1" appendTo="body"
styleClass="select-full-width" size="small">
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP2"
(ngModelChange)="setBulkProvider('p2', $event)"
placeholder="Set all P2" appendTo="body"
styleClass="select-full-width" size="small">
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP3"
(ngModelChange)="setBulkProvider('p3', $event)"
placeholder="Set all P3" appendTo="body"
styleClass="select-full-width" size="small">
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP4"
(ngModelChange)="setBulkProvider('p4', $event)"
placeholder="Set all P4" appendTo="body"
styleClass="select-full-width" size="small">
class="select-full-width" size="small">
</p-select>
</td>
</tr>
@@ -75,28 +75,28 @@
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
[disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body"
styleClass="select-full-width" size="small">
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
[disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body"
styleClass="select-full-width" size="small">
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
[disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body"
styleClass="select-full-width" size="small">
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p4"
[disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body"
styleClass="select-full-width" size="small">
class="select-full-width" size="small">
</p-select>
</td>
</tr>
@@ -125,7 +125,7 @@
<div class="option-item">
<p pTooltip="Controls how fetched metadata replaces existing values. 'Replace Missing Only' only fills empty fields, 'Replace All Fields' overwrites existing values." tooltipPosition="top">Replace Mode:</p>
<p-select [options]="replaceModeOptions" [(ngModel)]="replaceMode" optionLabel="label" optionValue="value"
appendTo="body" size="small" styleClass="select-mode">
appendTo="body" size="small" class="select-mode">
</p-select>
</div>
<div class="option-item">
@@ -109,14 +109,21 @@
.options-group {
display: flex;
flex-direction: row;
gap: 2.5rem;
flex-wrap: wrap;
align-items: center;
gap: 1rem 2.5rem;
}
.option-item {
display: flex;
flex-direction: row;
align-items: center;
gap: 1rem;
gap: 0.5rem;
p {
margin: 0;
white-space: nowrap;
}
}
.action-buttons {
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="ref.close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -13,7 +13,7 @@
[text]="true"
severity="secondary"
(click)="dialogRef.close()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -104,7 +104,7 @@
[max]="duration || 100"
[step]="1"
(onChange)="seek($event)"
styleClass="progress-slider"
class="progress-slider"
/>
</div>
</div>
@@ -154,7 +154,7 @@
severity="contrast"
(onClick)="togglePlay()"
[disabled]="audioLoading"
styleClass="play-button"
class="play-button"
size="large"
/>
@@ -214,7 +214,7 @@
[max]="1"
[step]="0.01"
(onChange)="setVolume($event)"
styleClass="volume-slider"
class="volume-slider"
/>
</div>
@@ -252,7 +252,7 @@
[rounded]="true"
[text]="true"
severity="secondary"
[styleClass]="sleepTimerActive ? 'sleep-timer-active' : ''"
[class]="sleepTimerActive ? 'sleep-timer-active' : ''"
(onClick)="sleepTimerMenu.toggle($event)"
size="small"
/>
@@ -64,11 +64,11 @@
</label>
@if (!fontsLoadedInBrowser) {
<div class="font-preview-skeleton">
<p-skeleton width="100%" height="1rem" styleClass="mb-3"></p-skeleton>
<p-skeleton width="100%" height="1rem" styleClass="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" styleClass="mb-3"></p-skeleton>
<p-skeleton width="60%" height="1rem" styleClass="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" styleClass="mb-3"></p-skeleton>
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="60%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="95%" height="0.875rem"></p-skeleton>
</div>
} @else {
@@ -39,11 +39,13 @@ export class LibraryMetadataSettingsComponent implements OnInit {
activePanel: number | null = null;
sidecarExporting: Record<number, boolean> = {};
sidecarImporting: Record<number, boolean> = {};
private cachedDefaultOptions: Record<number, MetadataRefreshOptions> = {};
ngOnInit() {
this.appSettingsService.appSettings$.subscribe(appSettings => {
if (appSettings) {
this.defaultMetadataOptions = appSettings.defaultMetadataRefreshOptions;
this.cachedDefaultOptions = {};
this.initializeLibraryOptions(appSettings);
this.updateLibraryOptionsFromSettings(appSettings);
}
@@ -80,7 +82,13 @@ export class LibraryMetadataSettingsComponent implements OnInit {
}
getLibraryOptions(libraryId: number): MetadataRefreshOptions {
return this.libraryMetadataOptions[libraryId] || {...this.defaultMetadataOptions, libraryId};
if (this.libraryMetadataOptions[libraryId]) {
return this.libraryMetadataOptions[libraryId];
}
if (!this.cachedDefaultOptions[libraryId]) {
this.cachedDefaultOptions[libraryId] = {...this.defaultMetadataOptions, libraryId};
}
return this.cachedDefaultOptions[libraryId];
}
trackByLibrary(index: number, library: Library): number | undefined {
@@ -291,7 +291,7 @@
header="Create OPDS User"
[(visible)]="showCreateUserDialog"
[modal]="true"
styleClass="user-dialog"
class="user-dialog"
[style]="{width: '400px'}">
<div class="dialog-form">
<div class="form-field">
@@ -424,7 +424,7 @@
header="Change Password"
[(visible)]="isPasswordDialogVisible"
[modal]="true"
styleClass="user-dialog"
class="user-dialog"
[style]="{width: '400px'}">
<div class="dialog-form">
<div class="form-field">
@@ -193,7 +193,8 @@ export type VisibleFilterType =
| 'personalRating' | 'publisher' | 'matchScore' | 'library' | 'shelf'
| 'shelfStatus' | 'tag' | 'publishedDate' | 'fileSize' | 'amazonRating'
| 'goodreadsRating' | 'hardcoverRating' | 'language' | 'pageCount' | 'mood'
| 'ageRating' | 'contentRating';
| 'ageRating' | 'contentRating'
| 'comicCharacter' | 'comicTeam' | 'comicLocation' | 'comicCreator';
export const DEFAULT_VISIBLE_FILTERS: VisibleFilterType[] = [
'author', 'category', 'series', 'bookType', 'readStatus',
@@ -223,7 +224,11 @@ export const ALL_FILTER_OPTIONS: { label: string; value: VisibleFilterType }[] =
{label: 'Mood', value: 'mood'},
{label: 'Amazon Rating', value: 'amazonRating'},
{label: 'Goodreads Rating', value: 'goodreadsRating'},
{label: 'Hardcover Rating', value: 'hardcoverRating'}
{label: 'Hardcover Rating', value: 'hardcoverRating'},
{label: 'Comic Character', value: 'comicCharacter'},
{label: 'Comic Team', value: 'comicTeam'},
{label: 'Comic Location', value: 'comicLocation'},
{label: 'Comic Creator', value: 'comicCreator'}
];
export interface UserSettings {
@@ -16,7 +16,7 @@
[rounded]="true"
severity="secondary"
(onClick)="closeDialog()"
styleClass="close-button">
class="close-button">
</p-button>
</div>
@@ -134,7 +134,7 @@
id="confirmNewPassword"
formControlName="confirmNewPassword"
[feedback]="false"
styleClass="field-input"
class="field-input"
[inputStyle]="{'width': '100%'}">
</p-password>
@if (changePasswordForm.get('confirmNewPassword')?.invalid &&
@@ -31,26 +31,58 @@
<label class="setting-label">Visible Filters</label>
</div>
<p class="setting-description">
Select which filters appear in the filter sidebar. Choose between {{ minFilters }} and {{ maxFilters }} filters.
Choose which filters appear in the sidebar and drag to reorder. Between {{ minFilters }} and {{ maxFilters }} filters.
<span class="filter-count">({{ selectionCountText }})</span>
</p>
<div class="setting-options">
<p-multiselect
[options]="allFilterOptions"
[(ngModel)]="selectedVisibleFilters"
(ngModelChange)="onVisibleFiltersChange()"
optionLabel="label"
optionValue="value"
[showClear]="false"
[filter]="true"
filterPlaceHolder="Search filters..."
placeholder="Select filters"
display="chip"
appendTo="body"
[maxSelectedLabels]="5"
selectedItemsLabel="{0} filters selected"
styleClass="visible-filters-select">
</p-multiselect>
<div class="filter-order-editor">
<div
#filterList
class="filter-order-list"
cdkDropList
[cdkDropListData]="selectedVisibleFilters"
(cdkDropListDropped)="onDrop($event)">
@for (f of selectedVisibleFilters; track f; let i = $index) {
<div class="filter-order-row" cdkDrag>
<div class="filter-drag-handle" cdkDragHandle>
<i class="pi pi-bars"></i>
</div>
<span class="filter-rank">{{ i + 1 }}.</span>
<span class="filter-label">{{ getFilterLabel(f) }}</span>
<button
type="button"
class="remove-filter-btn"
(click)="removeFilter(i)"
[disabled]="selectedVisibleFilters.length <= minFilters"
pTooltip="Remove"
tooltipPosition="top">
<i class="pi pi-times"></i>
</button>
</div>
}
</div>
<div class="filter-actions-row">
@if (availableFilters.length > 0 && selectedVisibleFilters.length < maxFilters) {
<p-select
size="small"
[options]="availableFilters"
[(ngModel)]="selectedAddFilter"
optionLabel="label"
optionValue="value"
placeholder="Add filter..."
[style]="{ width: '200px' }"
appendTo="body"
(onChange)="addFilter()">
</p-select>
}
<button
type="button"
class="reset-btn"
(click)="resetToDefaults()"
pTooltip="Reset to defaults"
tooltipPosition="top">
<i class="pi pi-refresh"></i>
</button>
</div>
</div>
</div>
@@ -47,19 +47,150 @@
width: 100%;
}
}
p-multiselect {
min-width: 300px;
max-width: 100%;
@media (max-width: 768px) {
min-width: 100%;
width: 100%;
}
}
}
.filter-count {
font-weight: 500;
color: var(--p-primary-color);
}
// Filter order editor styles
.filter-order-editor {
margin-top: 0.75rem;
}
.filter-order-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
min-height: 40px;
max-height: 320px;
max-width: 350px;
overflow-y: auto;
margin-bottom: 0.75rem;
}
.filter-order-row {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 0.75rem;
background-color: var(--overlay-background);
border: 1px solid var(--border-color);
border-radius: 6px;
cursor: move;
transition: background-color 0.15s ease, box-shadow 0.15s ease;
&:hover {
background-color: var(--ground-background);
}
}
.cdk-drag-preview {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.35rem 0.75rem;
background-color: var(--card-background);
border: 1px solid var(--primary-color);
border-radius: 6px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.25);
}
.cdk-drag-placeholder {
opacity: 0.3;
}
.cdk-drag-animating {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}
.filter-order-list.cdk-drop-list-dragging .filter-order-row:not(.cdk-drag-placeholder) {
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}
.filter-drag-handle {
display: flex;
align-items: center;
justify-content: center;
color: var(--text-secondary-color);
cursor: grab;
&:active {
cursor: grabbing;
}
i {
font-size: 0.85rem;
}
}
.filter-rank {
font-weight: 600;
color: var(--primary-color);
min-width: 1.75rem;
}
.filter-label {
flex: 1;
font-size: 0.875rem;
color: var(--text-color);
}
.remove-filter-btn {
display: flex;
align-items: center;
justify-content: center;
width: 1.75rem;
height: 1.75rem;
padding: 0;
border: none;
border-radius: 4px;
background-color: transparent;
color: var(--p-red-500);
cursor: pointer;
transition: background-color 0.15s ease;
i {
font-size: 0.85rem;
}
&:hover:not(:disabled) {
background-color: var(--ground-background);
}
&:disabled {
opacity: 0.4;
cursor: not-allowed;
}
}
.filter-actions-row {
display: flex;
align-items: center;
gap: 0.5rem;
}
.reset-btn {
display: flex;
align-items: center;
justify-content: center;
width: 1.75rem;
height: 1.75rem;
padding: 0;
border: none;
border-radius: 4px;
background-color: transparent;
color: var(--text-secondary-color);
cursor: pointer;
transition: background-color 0.15s ease, color 0.15s ease;
i {
font-size: 0.85rem;
}
&:hover {
background-color: var(--ground-background);
color: var(--primary-color);
}
}
@@ -1,30 +1,25 @@
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
import {Component, ElementRef, inject, OnDestroy, OnInit, viewChild} from '@angular/core';
import {Select} from 'primeng/select';
import {
ALL_FILTER_OPTIONS,
BookFilterMode,
DEFAULT_VISIBLE_FILTERS,
User,
UserService,
UserSettings,
UserState,
VisibleFilterType
} from '../../user-management/user.service';
import {ALL_FILTER_OPTIONS, BookFilterMode, DEFAULT_VISIBLE_FILTERS, User, UserService, UserSettings, UserState, VisibleFilterType} from '../../user-management/user.service';
import {MessageService} from 'primeng/api';
import {Observable, Subject} from 'rxjs';
import {FormsModule} from '@angular/forms';
import {filter, takeUntil} from 'rxjs/operators';
import {MultiSelect} from 'primeng/multiselect';
import {CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray} from '@angular/cdk/drag-drop';
import {Tooltip} from 'primeng/tooltip';
const MIN_VISIBLE_FILTERS = 5;
const MAX_VISIBLE_FILTERS = 15;
const MAX_VISIBLE_FILTERS = 20;
@Component({
selector: 'app-filter-preferences',
imports: [
Select,
FormsModule,
MultiSelect
CdkDropList,
CdkDrag,
CdkDragHandle,
Tooltip
],
templateUrl: './filter-preferences.component.html',
styleUrl: './filter-preferences.component.scss'
@@ -44,6 +39,8 @@ export class FilterPreferencesComponent implements OnInit, OnDestroy {
selectedFilterMode: BookFilterMode = 'and';
selectedVisibleFilters: VisibleFilterType[] = [...DEFAULT_VISIBLE_FILTERS];
private readonly filterList = viewChild<ElementRef<HTMLElement>>('filterList');
private readonly userService = inject(UserService);
private readonly messageService = inject(MessageService);
private readonly destroy$ = new Subject<void>();
@@ -95,25 +92,43 @@ export class FilterPreferencesComponent implements OnInit, OnDestroy {
this.updatePreference(['filterMode'], this.selectedFilterMode);
}
onVisibleFiltersChange(): void {
if (this.selectedVisibleFilters.length < MIN_VISIBLE_FILTERS) {
this.messageService.add({
severity: 'warn',
summary: 'Minimum Filters Required',
detail: `Please select at least ${MIN_VISIBLE_FILTERS} filters.`,
life: 2000
selectedAddFilter: string | null = null;
get availableFilters(): {label: string; value: string}[] {
const used = new Set(this.selectedVisibleFilters);
return this.allFilterOptions.filter(opt => !used.has(opt.value));
}
getFilterLabel(value: string): string {
return this.allFilterOptions.find(opt => opt.value === value)?.label ?? value;
}
onDrop(event: CdkDragDrop<VisibleFilterType[]>): void {
moveItemInArray(this.selectedVisibleFilters, event.previousIndex, event.currentIndex);
this.updatePreference(['visibleFilters'], this.selectedVisibleFilters);
}
addFilter(): void {
if (this.selectedAddFilter) {
this.selectedVisibleFilters.push(this.selectedAddFilter as VisibleFilterType);
this.selectedAddFilter = null;
this.updatePreference(['visibleFilters'], this.selectedVisibleFilters);
requestAnimationFrame(() => {
const el = this.filterList()?.nativeElement;
if (el) el.scrollTop = el.scrollHeight;
});
return;
}
if (this.selectedVisibleFilters.length > MAX_VISIBLE_FILTERS) {
this.messageService.add({
severity: 'warn',
summary: 'Maximum Filters Exceeded',
detail: `Please select at most ${MAX_VISIBLE_FILTERS} filters.`,
life: 2000
});
return;
}
removeFilter(index: number): void {
if (this.selectedVisibleFilters.length > MIN_VISIBLE_FILTERS) {
this.selectedVisibleFilters.splice(index, 1);
this.updatePreference(['visibleFilters'], this.selectedVisibleFilters);
}
}
resetToDefaults(): void {
this.selectedVisibleFilters = [...DEFAULT_VISIBLE_FILTERS];
this.updatePreference(['visibleFilters'], this.selectedVisibleFilters);
}
@@ -18,7 +18,7 @@
[draggable]="false"
[resizable]="false"
[style]="{width: '600px', maxWidth: '90vw'}"
styleClass="config-dialog"
class="config-dialog"
header="Chart Configuration">
<div class="config-dialog-content">