Add support for moods and tags in book metadata (#1262)
This commit is contained in:
+57
@@ -176,6 +176,63 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1 md:basis-[50%]">
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
<label class="text-sm" for="moods">Moods</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<div class="w-full">
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
formControlName="moods"
|
||||
[multiple]="true"
|
||||
[dropdown]="false"
|
||||
[suggestions]="filteredMoods"
|
||||
[forceSelection]="false"
|
||||
[showClear]="true"
|
||||
(completeMethod)="filterMoods($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('moods', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('moods', $event)">
|
||||
</p-autoComplete>
|
||||
</div>
|
||||
@if (!book.metadata!['moodsLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('moods')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['moodsLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('moods')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1 md:basis-[50%]">
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
<label class="text-sm" for="tags">Tags</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<div class="w-full">
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
formControlName="tags"
|
||||
[multiple]="true"
|
||||
[dropdown]="false"
|
||||
[suggestions]="filteredTags"
|
||||
[forceSelection]="false"
|
||||
[showClear]="true"
|
||||
(completeMethod)="filterTags($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('tags', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('tags', $event)">
|
||||
</p-autoComplete>
|
||||
</div>
|
||||
@if (!book.metadata!['tagsLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('tags')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['tagsLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('tags')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="flex flex-col gap-1 md:basis-[75%]">
|
||||
<label class="text-sm" for="seriesName">Series Name</label>
|
||||
|
||||
+44
-83
@@ -1,42 +1,19 @@
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
OnInit,
|
||||
Output,
|
||||
} from "@angular/core";
|
||||
import {Component, DestroyRef, EventEmitter, inject, Input, OnInit, Output,} from "@angular/core";
|
||||
import {InputText} from "primeng/inputtext";
|
||||
import {Button} from "primeng/button";
|
||||
import {Divider} from "primeng/divider";
|
||||
import {
|
||||
FormControl,
|
||||
FormGroup,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
} from "@angular/forms";
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule,} from "@angular/forms";
|
||||
import {Observable} 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, MetadataClearFlags, MetadataUpdateWrapper,} from "../../../book/model/book.model";
|
||||
import {UrlHelperService} from "../../../utilities/service/url-helper.service";
|
||||
import {
|
||||
FileUpload,
|
||||
FileUploadErrorEvent,
|
||||
FileUploadEvent,
|
||||
} from "primeng/fileupload";
|
||||
import {FileUpload, FileUploadErrorEvent, FileUploadEvent,} from "primeng/fileupload";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {BookService} from "../../../book/service/book.service";
|
||||
import {ProgressSpinner} from "primeng/progressspinner";
|
||||
import {Tooltip} from "primeng/tooltip";
|
||||
import {filter, take} from "rxjs/operators";
|
||||
import {MetadataRestoreDialogComponent} from "../../../book/components/book-browser/metadata-restore-dialog-component/metadata-restore-dialog-component";
|
||||
import {DialogService} from "primeng/dynamicdialog";
|
||||
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
||||
import {MetadataRefreshRequest} from "../../model/request/metadata-refresh-request.model";
|
||||
@@ -99,8 +76,12 @@ export class MetadataEditorComponent implements OnInit {
|
||||
|
||||
allAuthors!: string[];
|
||||
allCategories!: string[];
|
||||
allMoods!: string[];
|
||||
allTags!: string[];
|
||||
filteredCategories: string[] = [];
|
||||
filteredAuthors: string[] = [];
|
||||
filteredMoods: string[] = [];
|
||||
filteredTags: string[] = [];
|
||||
|
||||
filterCategories(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
@@ -116,12 +97,28 @@ export class MetadataEditorComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
filterMoods(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredMoods = this.allMoods.filter((mood) =>
|
||||
mood.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
filterTags(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredTags = this.allTags.filter((tag) =>
|
||||
tag.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.metadataForm = new FormGroup({
|
||||
title: new FormControl(""),
|
||||
subtitle: new FormControl(""),
|
||||
authors: new FormControl(""),
|
||||
categories: new FormControl(""),
|
||||
moods: new FormControl(""),
|
||||
tags: new FormControl(""),
|
||||
publisher: new FormControl(""),
|
||||
publishedDate: new FormControl(""),
|
||||
isbn10: new FormControl(""),
|
||||
@@ -150,6 +147,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
subtitleLocked: new FormControl(false),
|
||||
authorsLocked: new FormControl(false),
|
||||
categoriesLocked: new FormControl(false),
|
||||
moodsLocked: new FormControl(false),
|
||||
tagsLocked: new FormControl(false),
|
||||
publisherLocked: new FormControl(false),
|
||||
publishedDateLocked: new FormControl(false),
|
||||
isbn10Locked: new FormControl(false),
|
||||
@@ -197,16 +196,22 @@ export class MetadataEditorComponent implements OnInit {
|
||||
.subscribe((bookState) => {
|
||||
const authors = new Set<string>();
|
||||
const categories = new Set<string>();
|
||||
const moods = new Set<string>();
|
||||
const tags = new Set<string>();
|
||||
|
||||
(bookState.books ?? []).forEach((book) => {
|
||||
book.metadata?.authors?.forEach((author) => authors.add(author));
|
||||
book.metadata?.categories?.forEach((category) =>
|
||||
categories.add(category)
|
||||
);
|
||||
book.metadata?.moods?.forEach((mood) => moods.add(mood));
|
||||
book.metadata?.tags?.forEach((tag) => tags.add(tag));
|
||||
});
|
||||
|
||||
this.allAuthors = Array.from(authors);
|
||||
this.allCategories = Array.from(categories);
|
||||
this.allMoods = Array.from(moods);
|
||||
this.allTags = Array.from(tags);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -216,6 +221,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
subtitle: metadata.subtitle ?? null,
|
||||
authors: [...(metadata.authors ?? [])].sort(),
|
||||
categories: [...(metadata.categories ?? [])].sort(),
|
||||
moods: [...(metadata.moods ?? [])].sort(),
|
||||
tags: [...(metadata.tags ?? [])].sort(),
|
||||
publisher: metadata.publisher ?? null,
|
||||
publishedDate: metadata.publishedDate ?? null,
|
||||
isbn10: metadata.isbn10 ?? null,
|
||||
@@ -244,6 +251,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
subtitleLocked: metadata.subtitleLocked ?? false,
|
||||
authorsLocked: metadata.authorsLocked ?? false,
|
||||
categoriesLocked: metadata.categoriesLocked ?? false,
|
||||
moodsLocked: metadata.moodsLocked ?? false,
|
||||
tagsLocked: metadata.tagsLocked ?? false,
|
||||
publisherLocked: metadata.publisherLocked ?? false,
|
||||
publishedDateLocked: metadata.publishedDateLocked ?? false,
|
||||
isbn10Locked: metadata.isbn10Locked ?? false,
|
||||
@@ -274,6 +283,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
{key: "subtitleLocked", control: "subtitle"},
|
||||
{key: "authorsLocked", control: "authors"},
|
||||
{key: "categoriesLocked", control: "categories"},
|
||||
{key: "moodsLocked", control: "moods"},
|
||||
{key: "tagsLocked", control: "tags"},
|
||||
{key: "publisherLocked", control: "publisher"},
|
||||
{key: "publishedDateLocked", control: "publishedDate"},
|
||||
{key: "languageLocked", control: "language"},
|
||||
@@ -410,6 +421,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
subtitle: form.get("subtitle")?.value,
|
||||
authors: form.get("authors")?.value ?? [],
|
||||
categories: form.get("categories")?.value ?? [],
|
||||
moods: form.get("moods")?.value ?? [],
|
||||
tags: form.get("tags")?.value ?? [],
|
||||
publisher: form.get("publisher")?.value,
|
||||
publishedDate: form.get("publishedDate")?.value,
|
||||
isbn10: form.get("isbn10")?.value,
|
||||
@@ -441,6 +454,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
subtitleLocked: form.get("subtitleLocked")?.value,
|
||||
authorsLocked: form.get("authorsLocked")?.value,
|
||||
categoriesLocked: form.get("categoriesLocked")?.value,
|
||||
moodsLocked: form.get("moodsLocked")?.value,
|
||||
tagsLocked: form.get("tagsLocked")?.value,
|
||||
publisherLocked: form.get("publisherLocked")?.value,
|
||||
publishedDateLocked: form.get("publishedDateLocked")?.value,
|
||||
isbn10Locked: form.get("isbn10Locked")?.value,
|
||||
@@ -487,6 +502,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
subtitle: wasCleared("subtitle"),
|
||||
authors: wasCleared("authors"),
|
||||
categories: wasCleared("categories"),
|
||||
moods: wasCleared("moods"),
|
||||
tags: wasCleared("tags"),
|
||||
publisher: wasCleared("publisher"),
|
||||
publishedDate: wasCleared("publishedDate"),
|
||||
isbn10: wasCleared("isbn10"),
|
||||
@@ -602,62 +619,6 @@ export class MetadataEditorComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
// restoreCbxMetadata() {
|
||||
// this.isLoading = true;
|
||||
// this.bookService.getComicInfoMetadata(this.currentBookId).subscribe();
|
||||
// setTimeout(() => {
|
||||
// this.isLoading = false;
|
||||
// // this.refreshingBookIds.delete(bookId);
|
||||
// }, 10000);
|
||||
// }
|
||||
restoreCbxMetadata() {
|
||||
this.isLoading = true;
|
||||
console.log("LOADING CBX METADATA FOR BOOK ID:", this.currentBookId);
|
||||
this.bookService.getComicInfoMetadata(this.currentBookId).subscribe({
|
||||
next: (metadata) => {
|
||||
console.log("Retrieved ComicInfo.xml metadata:", metadata);
|
||||
|
||||
if (metadata) {
|
||||
this.originalMetadata = structuredClone(metadata);
|
||||
this.populateFormFromMetadata(metadata);
|
||||
this.messageService.add({
|
||||
severity: "success",
|
||||
summary: "Restored",
|
||||
detail: "Metadata loaded from ComicInfo.xml",
|
||||
});
|
||||
} else {
|
||||
this.messageService.add({
|
||||
severity: "warn",
|
||||
summary: "No Data",
|
||||
detail: "ComicInfo.xml not found or empty.",
|
||||
});
|
||||
}
|
||||
this.isLoading = false;
|
||||
},
|
||||
error: (err) => {
|
||||
console.error("Error loading ComicInfo.xml metadata:", err);
|
||||
console.error(err.message);
|
||||
this.isLoading = false;
|
||||
this.messageService.add({
|
||||
severity: "error",
|
||||
summary: "Error",
|
||||
detail: err?.error?.message || "Failed to load ComicInfo.xml",
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
restoreMetadata() {
|
||||
this.dialogService.open(MetadataRestoreDialogComponent, {
|
||||
header: "Restore Metadata from Backup",
|
||||
modal: true,
|
||||
closable: true,
|
||||
data: {
|
||||
bookId: [this.currentBookId],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
autoFetch(bookId: number) {
|
||||
this.refreshingBookIds.add(bookId);
|
||||
this.isAutoFetching = true;
|
||||
|
||||
+38
-2
@@ -49,7 +49,9 @@ export class MetadataPickerComponent implements OnInit {
|
||||
|
||||
metadataChips = [
|
||||
{label: 'Authors', controlName: 'authors', lockedKey: 'authorsLocked', fetchedKey: 'authors'},
|
||||
{label: 'Categories', controlName: 'categories', lockedKey: 'categoriesLocked', fetchedKey: 'categories'}
|
||||
{label: 'Categories', controlName: 'categories', lockedKey: 'categoriesLocked', fetchedKey: 'categories'},
|
||||
{label: 'Moods', controlName: 'moods', lockedKey: 'moodsLocked', fetchedKey: 'moods'},
|
||||
{label: 'Tags', controlName: 'tags', lockedKey: 'tagsLocked', fetchedKey: 'tags'},
|
||||
];
|
||||
|
||||
metadataDescription = [
|
||||
@@ -84,11 +86,19 @@ export class MetadataPickerComponent implements OnInit {
|
||||
|
||||
allAuthors!: string[];
|
||||
allCategories!: string[];
|
||||
allMoods!: string[];
|
||||
allTags!: string[];
|
||||
filteredCategories: string[] = [];
|
||||
filteredAuthors: string[] = [];
|
||||
filteredMoods: string[] = [];
|
||||
filteredTags: string[] = [];
|
||||
|
||||
getFiltered(controlName: string): string[] {
|
||||
return controlName === 'authors' ? this.filteredAuthors : this.filteredCategories;
|
||||
if (controlName === 'authors') return this.filteredAuthors;
|
||||
if (controlName === 'categories') return this.filteredCategories;
|
||||
if (controlName === 'moods') return this.filteredMoods;
|
||||
if (controlName === 'tags') return this.filteredTags;
|
||||
return [];
|
||||
}
|
||||
|
||||
filterItems(event: { query: string }, controlName: string) {
|
||||
@@ -97,6 +107,10 @@ export class MetadataPickerComponent implements OnInit {
|
||||
this.filteredAuthors = this.allAuthors.filter(a => a.toLowerCase().includes(query));
|
||||
} else if (controlName === 'categories') {
|
||||
this.filteredCategories = this.allCategories.filter(c => c.toLowerCase().includes(query));
|
||||
} else if (controlName === 'moods') {
|
||||
this.filteredMoods = this.allMoods.filter(m => m.toLowerCase().includes(query));
|
||||
} else if (controlName === 'tags') {
|
||||
this.filteredTags = this.allTags.filter(t => t.toLowerCase().includes(query));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +132,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
subtitle: new FormControl(''),
|
||||
authors: new FormControl(''),
|
||||
categories: new FormControl(''),
|
||||
moods: new FormControl(''),
|
||||
tags: new FormControl(''),
|
||||
publisher: new FormControl(''),
|
||||
publishedDate: new FormControl(''),
|
||||
isbn10: new FormControl(''),
|
||||
@@ -145,6 +161,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
subtitleLocked: new FormControl(false),
|
||||
authorsLocked: new FormControl(false),
|
||||
categoriesLocked: new FormControl(false),
|
||||
moodsLocked: new FormControl(false),
|
||||
tagsLocked: new FormControl(false),
|
||||
publisherLocked: new FormControl(false),
|
||||
publishedDateLocked: new FormControl(false),
|
||||
isbn10Locked: new FormControl(false),
|
||||
@@ -181,14 +199,20 @@ export class MetadataPickerComponent implements OnInit {
|
||||
.subscribe(bookState => {
|
||||
const authors = new Set<string>();
|
||||
const categories = new Set<string>();
|
||||
const moods = new Set<string>();
|
||||
const tags = new Set<string>();
|
||||
|
||||
(bookState.books ?? []).forEach(book => {
|
||||
book.metadata?.authors?.forEach(author => authors.add(author));
|
||||
book.metadata?.categories?.forEach(category => categories.add(category));
|
||||
book.metadata?.moods?.forEach(mood => moods.add(mood));
|
||||
book.metadata?.tags?.forEach(tag => tags.add(tag));
|
||||
});
|
||||
|
||||
this.allAuthors = Array.from(authors);
|
||||
this.allCategories = Array.from(categories);
|
||||
this.allMoods = Array.from(moods);
|
||||
this.allTags = Array.from(tags);
|
||||
});
|
||||
|
||||
this.book$
|
||||
@@ -214,6 +238,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
subtitle: metadata.subtitle || null,
|
||||
authors: [...(metadata.authors ?? [])].sort(),
|
||||
categories: [...(metadata.categories ?? [])].sort(),
|
||||
moods: [...(metadata.moods ?? [])].sort(),
|
||||
tags: [...(metadata.tags ?? [])].sort(),
|
||||
publisher: metadata.publisher || null,
|
||||
publishedDate: metadata.publishedDate || null,
|
||||
isbn10: metadata.isbn10 || null,
|
||||
@@ -241,6 +267,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
subtitleLocked: metadata.subtitleLocked || false,
|
||||
authorsLocked: metadata.authorsLocked || false,
|
||||
categoriesLocked: metadata.categoriesLocked || false,
|
||||
moodsLocked: metadata.moodsLocked || false,
|
||||
tagsLocked: metadata.tagsLocked || false,
|
||||
publisherLocked: metadata.publisherLocked || false,
|
||||
publishedDateLocked: metadata.publishedDateLocked || false,
|
||||
isbn10Locked: metadata.isbn10Locked || false,
|
||||
@@ -277,6 +305,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
if (metadata.subtitleLocked) this.metadataForm.get('subtitle')?.disable({emitEvent: false});
|
||||
if (metadata.authorsLocked) this.metadataForm.get('authors')?.disable({emitEvent: false});
|
||||
if (metadata.categoriesLocked) this.metadataForm.get('categories')?.disable({emitEvent: false});
|
||||
if (metadata.moodsLocked) this.metadataForm.get('moods')?.disable({emitEvent: false});
|
||||
if (metadata.tagsLocked) this.metadataForm.get('tags')?.disable({emitEvent: false});
|
||||
if (metadata.publisherLocked) this.metadataForm.get('publisher')?.disable({emitEvent: false});
|
||||
if (metadata.publishedDateLocked) this.metadataForm.get('publishedDate')?.disable({emitEvent: false});
|
||||
if (metadata.languageLocked) this.metadataForm.get('language')?.disable({emitEvent: false});
|
||||
@@ -353,6 +383,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
subtitle: this.metadataForm.get('subtitle')?.value || this.copiedFields['subtitle'] ? this.getValueOrCopied('subtitle') : '',
|
||||
authors: this.metadataForm.get('authors')?.value || this.copiedFields['authors'] ? this.getArrayFromFormField('authors', this.fetchedMetadata.authors) : [],
|
||||
categories: this.metadataForm.get('categories')?.value || this.copiedFields['categories'] ? this.getArrayFromFormField('categories', this.fetchedMetadata.categories) : [],
|
||||
moods: this.metadataForm.get('moods')?.value || this.copiedFields['moods'] ? this.getArrayFromFormField('moods', this.fetchedMetadata.moods) : [],
|
||||
tags: this.metadataForm.get('tags')?.value || this.copiedFields['tags'] ? this.getArrayFromFormField('tags', this.fetchedMetadata.tags) : [],
|
||||
publisher: this.metadataForm.get('publisher')?.value || this.copiedFields['publisher'] ? this.getValueOrCopied('publisher') : '',
|
||||
publishedDate: this.metadataForm.get('publishedDate')?.value || this.copiedFields['publishedDate'] ? this.getValueOrCopied('publishedDate') : '',
|
||||
isbn10: this.metadataForm.get('isbn10')?.value || this.copiedFields['isbn10'] ? this.getValueOrCopied('isbn10') : '',
|
||||
@@ -381,6 +413,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
subtitleLocked: this.metadataForm.get('subtitleLocked')?.value,
|
||||
authorsLocked: this.metadataForm.get('authorsLocked')?.value,
|
||||
categoriesLocked: this.metadataForm.get('categoriesLocked')?.value,
|
||||
moodsLocked: this.metadataForm.get('moodsLocked')?.value,
|
||||
tagsLocked: this.metadataForm.get('tagsLocked')?.value,
|
||||
publisherLocked: this.metadataForm.get('publisherLocked')?.value,
|
||||
publishedDateLocked: this.metadataForm.get('publishedDateLocked')?.value,
|
||||
isbn10Locked: this.metadataForm.get('isbn10Locked')?.value,
|
||||
@@ -422,6 +456,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
subtitle: !current.subtitle && !!original.subtitle,
|
||||
authors: current.authors?.length === 0 && original.authors?.length! > 0,
|
||||
categories: current.categories?.length === 0 && original.categories?.length! > 0,
|
||||
moods: current.moods?.length === 0 && original.moods?.length! > 0,
|
||||
tags: current.tags?.length === 0 && original.tags?.length! > 0,
|
||||
publisher: !current.publisher && !!original.publisher,
|
||||
publishedDate: !current.publishedDate && !!original.publishedDate,
|
||||
isbn10: !current.isbn10 && !!original.isbn10,
|
||||
|
||||
+61
-34
@@ -216,18 +216,52 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@if (book?.metadata?.categories?.length) {
|
||||
<div class="overflow-x-auto scrollbar-hide max-w-7xl pt-2 md:pt-0">
|
||||
<div class="flex gap-2 w-max max-w-[1150px]">
|
||||
@for (category of book.metadata!.categories; track category) {
|
||||
<a (click)="goToCategory(category)" class="shrink-0 no-underline cursor-pointer">
|
||||
<p-tag [value]="category"></p-tag>
|
||||
</a>
|
||||
}
|
||||
<div class="flex flex-col space-y-2">
|
||||
@if (book?.metadata?.categories?.length) {
|
||||
<div class="flex items-center gap-1">
|
||||
<p class="font-bold text-sm w-[50px]">Genres:</p>
|
||||
<div class="overflow-x-auto scrollbar-hide max-w-7xl">
|
||||
<div class="flex gap-2 w-max max-w-[1150px]">
|
||||
@for (category of book.metadata!.categories; track category) {
|
||||
<a (click)="goToCategory(category)" class="shrink-0 no-underline cursor-pointer">
|
||||
<app-tag color="rose" size="xs">{{ category }}</app-tag>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@if (book?.metadata?.moods?.length) {
|
||||
<div class="flex items-center gap-1">
|
||||
<p class="font-bold text-sm w-[50px]">Moods:</p>
|
||||
<div class="overflow-x-auto scrollbar-hide max-w-7xl">
|
||||
<div class="flex gap-2 w-max max-w-[1150px]">
|
||||
@for (mood of book.metadata!.moods; track mood) {
|
||||
<a (click)="goToMood(mood)" class="shrink-0 no-underline cursor-pointer">
|
||||
<app-tag color="indigo" size="xs">{{ mood }}</app-tag>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (book?.metadata?.tags?.length) {
|
||||
<div class="flex items-center gap-1">
|
||||
<p class="font-bold text-sm w-[50px]">Tags:</p>
|
||||
<div class="overflow-x-auto scrollbar-hide max-w-7xl">
|
||||
<div class="flex gap-2 w-max max-w-[1150px]">
|
||||
@for (tag of book.metadata!.tags; track tag) {
|
||||
<a (click)="goToTag(tag)" class="shrink-0 no-underline cursor-pointer">
|
||||
<app-tag color="cyan" size="xs">{{ tag }}</app-tag>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="px-1 md:px-0">
|
||||
<div class="grid md:grid-cols-4 gap-y-2.5 text-sm pt-2 md:pt-4 pb-2 text-gray-300 md:min-w-[60rem] md:max-w-[100rem]">
|
||||
@@ -251,20 +285,16 @@
|
||||
<p><strong>Language:</strong> {{ book?.metadata!.language || '-' }}</p>
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">File Type:</span>
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-lg text-xs font-bold text-gray-200"
|
||||
[ngClass]="getFileTypeColorClass(getFileExtension(book?.filePath))">
|
||||
{{ getFileExtension(book?.filePath) || '-' }}
|
||||
</span>
|
||||
<app-tag size="3xs" variant="pill" [color]="getFileTypeColor(getFileExtension(book?.filePath))">
|
||||
{{ (getFileExtension(book?.filePath) | uppercase) || '-' }}
|
||||
</app-tag>
|
||||
</p>
|
||||
<p class="whitespace-nowrap flex items-center">
|
||||
<span class="font-bold mr-2">BookLore Progress:</span>
|
||||
<span class="inline-flex items-center">
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
|
||||
[ngClass]="getProgressColorClass(getProgressPercent(book))">
|
||||
<app-tag size="3xs" variant="pill" [color]="getProgressColor(getProgressPercent(book))">
|
||||
{{ getProgressPercent(book) !== null ? getProgressPercent(book) + '%' : 'N/A' }}
|
||||
</span>
|
||||
</app-tag>
|
||||
@if (getProgressPercent(book) !== null) {
|
||||
<p-button
|
||||
pTooltip="Reset progress"
|
||||
@@ -282,11 +312,9 @@
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">Metadata Match:</span>
|
||||
@if (book?.metadataMatchScore != null) {
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-lg text-xs font-bold text-gray-200 border"
|
||||
[ngClass]="getMatchScoreColorClass(book?.metadataMatchScore!)">
|
||||
<app-tag size="3xs" variant="pill" [color]="getMatchScoreColor(book?.metadataMatchScore!)">
|
||||
{{ (book?.metadataMatchScore!) | number:'1.0-0' }}%
|
||||
</span>
|
||||
</app-tag>
|
||||
} @else {
|
||||
<span>-</span>
|
||||
}
|
||||
@@ -305,23 +333,22 @@
|
||||
</p>
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">Read Status:</span>
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white cursor-pointer"
|
||||
[ngClass]="getStatusSeverityClass(selectedReadStatus)"
|
||||
(click)="menu.toggle($event)">
|
||||
<app-tag size="3xs" variant="pill" [color]="getStatusColor(selectedReadStatus)">
|
||||
{{ getStatusLabel(selectedReadStatus) }}
|
||||
</span>
|
||||
</app-tag>
|
||||
<i
|
||||
class="pi pi-pencil cursor-pointer text-[cornflowerblue] hover:text-[darkturquoise] transition-colors"
|
||||
(click)="menu.toggle($event)">
|
||||
</i>
|
||||
<p-menu #menu [popup]="true" [model]="readStatusMenuItems"></p-menu>
|
||||
</p>
|
||||
@if (book?.koreaderProgress && book.koreaderProgress?.percentage != null) {
|
||||
<p class="whitespace-nowrap flex items-center">
|
||||
<span class="font-bold mr-2">KOReader Progress:</span>
|
||||
<span class="inline-flex items-center">
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
|
||||
[ngClass]="getKoProgressColorClass(getKOReaderPercentage(book))">
|
||||
{{ getKOReaderPercentage(book) + '%' }}
|
||||
</span>
|
||||
<app-tag size="3xs" variant="pill" [color]="getKoProgressColor(getKOReaderPercentage(book))">
|
||||
{{ getKOReaderPercentage(book) + '%' }}
|
||||
</app-tag>
|
||||
@if (getKOReaderPercentage(book) !== null) {
|
||||
<p-button
|
||||
pTooltip="Reset progress"
|
||||
|
||||
+47
-38
@@ -1,11 +1,10 @@
|
||||
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, DecimalPipe, NgClass} from '@angular/common';
|
||||
import {AsyncPipe, DecimalPipe, NgClass, UpperCasePipe} from '@angular/common';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Rating, RatingRateEvent} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Book, BookMetadata, BookRecommendation, FileInfo, ReadStatus} from '../../../book/model/book.model';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
@@ -38,13 +37,14 @@ import {TieredMenu} from 'primeng/tieredmenu';
|
||||
import {AdditionalFileUploaderComponent} from '../../../book/components/additional-file-uploader/additional-file-uploader.component';
|
||||
import {Image} from 'primeng/image';
|
||||
import {BookDialogHelperService} from '../../../book/components/book-browser/BookDialogHelperService';
|
||||
import {TagColor, TagComponent} from '../../../shared/components/tag/tag.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-viewer.component.html',
|
||||
styleUrl: './metadata-viewer.component.scss',
|
||||
imports: [Button, AsyncPipe, Rating, FormsModule, Tag, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, InfiniteScrollDirective, BookCardLiteComponent, DatePicker, Tab, TabList, TabPanel, TabPanels, Tabs, BookReviewsComponent, BookNotesComponent, ProgressSpinner, TieredMenu, Image]
|
||||
imports: [Button, AsyncPipe, Rating, FormsModule, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, InfiniteScrollDirective, BookCardLiteComponent, DatePicker, Tab, TabList, TabPanel, TabPanels, Tabs, BookReviewsComponent, BookNotesComponent, ProgressSpinner, TieredMenu, Image, TagComponent, UpperCasePipe]
|
||||
})
|
||||
export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
@Input() book$!: Observable<Book | null>;
|
||||
@@ -551,6 +551,14 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
this.handleMetadataClick('category', category);
|
||||
}
|
||||
|
||||
goToMood(mood: string): void {
|
||||
this.handleMetadataClick('mood', mood);
|
||||
}
|
||||
|
||||
goToTag(tag: string): void {
|
||||
this.handleMetadataClick('tag', tag);
|
||||
}
|
||||
|
||||
goToSeries(seriesName: string): void {
|
||||
const encodedSeriesName = encodeURIComponent(seriesName);
|
||||
this.router.navigate(['/series', encodedSeriesName]);
|
||||
@@ -636,21 +644,21 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
getFileTypeColorClass(fileType: string | null | undefined): string {
|
||||
if (!fileType) return 'bg-gray-600 text-white';
|
||||
getFileTypeColor(fileType: string | null | undefined): TagColor {
|
||||
if (!fileType) return 'gray';
|
||||
switch (fileType.toLowerCase()) {
|
||||
case 'pdf':
|
||||
return 'bg-pink-700 text-white';
|
||||
return 'pink';
|
||||
case 'epub':
|
||||
return 'bg-indigo-600 text-white';
|
||||
return 'indigo';
|
||||
case 'cbz':
|
||||
return 'bg-teal-600 text-white';
|
||||
return 'teal';
|
||||
case 'cbr':
|
||||
return 'bg-purple-700 text-white';
|
||||
return 'purple';
|
||||
case 'cb7':
|
||||
return 'bg-blue-700 text-white';
|
||||
return 'blue';
|
||||
default:
|
||||
return 'bg-gray-600 text-white';
|
||||
return 'gray';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,50 +680,51 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchScoreColorClass(score: number): string {
|
||||
if (score >= 0.95) return 'bg-green-800 border-green-900';
|
||||
if (score >= 0.90) return 'bg-green-700 border-green-800';
|
||||
if (score >= 0.80) return 'bg-green-600 border-green-700';
|
||||
if (score >= 0.70) return 'bg-yellow-600 border-yellow-700';
|
||||
if (score >= 0.60) return 'bg-yellow-500 border-yellow-600';
|
||||
if (score >= 0.50) return 'bg-yellow-400 border-yellow-500';
|
||||
if (score >= 0.40) return 'bg-red-400 border-red-500';
|
||||
if (score >= 0.30) return 'bg-red-500 border-red-600';
|
||||
return 'bg-red-600 border-red-700';
|
||||
|
||||
getMatchScoreColor(score: number): TagColor {
|
||||
if (score >= 0.95) return 'emerald';
|
||||
if (score >= 0.90) return 'green';
|
||||
if (score >= 0.80) return 'lime';
|
||||
if (score >= 0.70) return 'yellow';
|
||||
if (score >= 0.60) return 'amber';
|
||||
if (score >= 0.50) return 'orange';
|
||||
if (score >= 0.40) return 'red';
|
||||
if (score >= 0.30) return 'rose';
|
||||
return 'pink';
|
||||
}
|
||||
|
||||
getStatusSeverityClass(status: string): string {
|
||||
const normalized = status?.toUpperCase();
|
||||
getStatusColor(status: string | null | undefined): TagColor {
|
||||
const normalized = status?.toUpperCase() ?? '';
|
||||
switch (normalized) {
|
||||
case 'UNREAD':
|
||||
return 'bg-gray-500';
|
||||
return 'gray';
|
||||
case 'PAUSED':
|
||||
return 'bg-zinc-600';
|
||||
return 'zinc';
|
||||
case 'READING':
|
||||
return 'bg-blue-600';
|
||||
return 'blue';
|
||||
case 'RE_READING':
|
||||
return 'bg-indigo-600';
|
||||
return 'indigo';
|
||||
case 'READ':
|
||||
return 'bg-green-600';
|
||||
return 'green';
|
||||
case 'PARTIALLY_READ':
|
||||
return 'bg-yellow-600';
|
||||
return 'yellow';
|
||||
case 'ABANDONED':
|
||||
return 'bg-red-600';
|
||||
return 'red';
|
||||
case 'WONT_READ':
|
||||
return 'bg-pink-700';
|
||||
return 'pink';
|
||||
default:
|
||||
return 'bg-gray-600';
|
||||
return 'gray';
|
||||
}
|
||||
}
|
||||
|
||||
getProgressColorClass(progress: number | null | undefined): string {
|
||||
if (progress == null) return 'bg-gray-600';
|
||||
return 'bg-blue-500';
|
||||
getProgressColor(progress: number | null | undefined): TagColor {
|
||||
if (progress == null) return 'gray';
|
||||
return 'blue';
|
||||
}
|
||||
|
||||
getKoProgressColorClass(progress: number | null | undefined): string {
|
||||
if (progress == null) return 'bg-gray-600';
|
||||
return 'bg-amber-500';
|
||||
getKoProgressColor(progress: number | null | undefined): TagColor {
|
||||
if (progress == null) return 'gray';
|
||||
return 'amber';
|
||||
}
|
||||
|
||||
getKOReaderPercentage(book: Book): number | null {
|
||||
|
||||
Reference in New Issue
Block a user