Metadata viewer minor layout tweaks

This commit is contained in:
aditya.chandel
2025-11-30 17:36:19 -07:00
parent ff17b74adb
commit 0c9409b087
4 changed files with 86 additions and 24 deletions
@@ -48,6 +48,7 @@ import {SidebarFilterTogglePrefService} from './filters/sidebar-filter-toggle-pr
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
import {GroupRule} from '../../../magic-shelf/component/magic-shelf-component';
import {TaskHelperService} from '../../../settings/task-management/task-helper.service';
import {FilterLabelHelper} from './filter-label.helper';
export enum EntityType {
LIBRARY = 'Library',
@@ -191,17 +192,18 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
if (filterEntries.length === 1) {
const [filterType, values] = filterEntries[0];
const filterName = this.capitalize(filterType);
const filterName = FilterLabelHelper.getFilterTypeName(filterType);
if (values.length === 1) {
return `${filterName}: ${values[0]}`;
const displayValue = FilterLabelHelper.getFilterDisplayValue(filterType, values[0]);
return `${filterName}: ${displayValue}`;
}
return `${filterName} (${values.length})`;
}
const filterSummary = filterEntries
.map(([type, values]) => `${this.capitalize(type)} (${values.length})`)
.map(([type, values]) => `${FilterLabelHelper.getFilterTypeName(type)} (${values.length})`)
.join(', ');
return filterSummary.length > 50
@@ -209,6 +211,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
: filterSummary;
}
ngOnInit(): void {
this.pageTitle.setPageTitle('')
this.coverScalePreferenceService.scaleChange$.pipe(debounceTime(1000)).subscribe();
@@ -292,7 +295,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.bookFilterComponent.setFilters?.(parsedFilters);
this.bookFilterComponent.onFiltersChanged?.();
}
if (Object.keys(parsedFilters).length > 0) {
this.currentFilterLabel = this.computedFilterLabel;
}
@@ -813,8 +816,4 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
})
);
}
private capitalize(str: string): string {
return str.charAt(0).toUpperCase() + str.slice(1);
}
}
@@ -0,0 +1,63 @@
import {
fileSizeRanges,
matchScoreRanges,
pageCountRanges,
ratingOptions10,
ratingRanges
} from './book-filter/book-filter.component';
export class FilterLabelHelper {
private static readonly FILTER_TYPE_MAP: Record<string, string> = {
author: 'Author',
category: 'Genre',
series: 'Series',
publisher: 'Publisher',
readStatus: 'Read Status',
personalRating: 'Personal Rating',
publishedYear: 'Year Published',
matchScore: 'Metadata Match Score',
language: 'Language',
bookType: 'Book Type',
shelfStatus: 'Shelf Status',
fileSize: 'File Size',
pageCount: 'Page Count',
amazonRating: 'Amazon Rating',
goodreadsRating: 'Goodreads Rating',
hardcoverRating: 'Hardcover Rating',
mood: 'Mood',
tag: 'Tag',
};
static getFilterTypeName(filterType: string): string {
return this.FILTER_TYPE_MAP[filterType] || this.capitalize(filterType);
}
static getFilterDisplayValue(filterType: string, value: string): string {
switch (filterType.toLowerCase()) {
case 'filesize':
const fileSizeRange = fileSizeRanges.find(r => r.id === value);
return fileSizeRange?.label || value;
case 'pagecount':
const pageCountRange = pageCountRanges.find(r => r.id === value);
return pageCountRange?.label || value;
case 'matchscore':
const matchScoreRange = matchScoreRanges.find(r => r.id === value);
return matchScoreRange?.label || value;
case 'personalrating':
const personalRating = ratingOptions10.find(r => r.id === value);
return personalRating?.label || value;
case 'amazonrating':
case 'goodreadsrating':
case 'hardcoverrating':
const ratingRange = ratingRanges.find(r => r.id === value);
return ratingRange?.label || value;
default:
return value;
}
}
private static capitalize(str: string): string {
return str.charAt(0).toUpperCase() + str.slice(1);
}
}