Audiobook enhancement (#2611)
* Audiobook enhancement * Fix choppy virtual scroller with mixed audiobook/ebook cards by using uniform heights * Fix audiobook cover regeneration for combined books and improve error messages * Fix cover extraction when attaching audiobook files during rescan * Set audiobookCoverUpdatedOn for cache busting when generating cover * Add support for regenerating covers from specific book files * Fix Continue Reading/Listening scrollers to filter by actual progress instead of primary file type * Show ebook cover and open ebook reader in Continue Reading scroller for combined books * Prevent read status from being downgraded when saving audiobook progress * Fix BookCoverServiceTest to match updated regenerateCover method signature --------- Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
+196
-66
@@ -8,73 +8,161 @@
|
||||
}
|
||||
<div class="form-content">
|
||||
<div class="main-section">
|
||||
<div class="cover-section">
|
||||
<p-image
|
||||
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
alt="Cover Image"
|
||||
width="250"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
@if (isUploading) {
|
||||
<p-progressSpinner class="upload-spinner"></p-progressSpinner>
|
||||
<div class="covers-section" [class.dual-covers]="supportsDualCovers(book)">
|
||||
<!-- Ebook Cover Section -->
|
||||
@if (hasEbookFormat(book)) {
|
||||
<div class="cover-section">
|
||||
@if (supportsDualCovers(book)) {
|
||||
<div class="cover-type-label ebook">
|
||||
<i class="pi pi-book"></i> Ebook Cover
|
||||
</div>
|
||||
}
|
||||
<p-image
|
||||
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
alt="Cover Image"
|
||||
width="200"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
@if (isUploading) {
|
||||
<p-progressSpinner class="upload-spinner"></p-progressSpinner>
|
||||
}
|
||||
<div class="cover-actions">
|
||||
@if (!book.isPhysical) {
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
(onClick)="regenerateCover(book.id)"
|
||||
pTooltip="Regenerate cover (From File)"
|
||||
tooltipPosition="top"
|
||||
[outlined]="true"
|
||||
severity="warn"
|
||||
size="small"
|
||||
[disabled]="book.metadata!['coverLocked']">
|
||||
</p-button>
|
||||
}
|
||||
<p-button
|
||||
icon="pi pi-palette"
|
||||
(onClick)="generateCustomCover(book.id)"
|
||||
pTooltip="Generate Custom Cover"
|
||||
tooltipPosition="top"
|
||||
[outlined]="true"
|
||||
severity="help"
|
||||
size="small"
|
||||
[loading]="isGeneratingCover"
|
||||
[disabled]="book.metadata!['coverLocked'] || isGeneratingCover">
|
||||
</p-button>
|
||||
<p-button
|
||||
[disabled]="book.metadata!['coverLocked']"
|
||||
outlined
|
||||
size="small"
|
||||
icon="pi pi-search"
|
||||
(onClick)="openCoverSearch()"
|
||||
pTooltip="Search for cover"
|
||||
tooltipPosition="top"
|
||||
severity="info">
|
||||
</p-button>
|
||||
<p-fileupload
|
||||
[chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'"
|
||||
pTooltip="Upload cover"
|
||||
tooltipPosition="top"
|
||||
[disabled]="book.metadata!['coverLocked']"
|
||||
name="file"
|
||||
[url]="getUploadCoverUrl()"
|
||||
mode="basic"
|
||||
chooseIcon="pi pi-upload"
|
||||
accept="image/jpeg,image/png"
|
||||
maxFileSize="5000000"
|
||||
(onUpload)="onUpload($event)"
|
||||
(onError)="onUploadError($event)"
|
||||
[auto]="true"
|
||||
(onBeforeUpload)="onBeforeSend()">
|
||||
</p-fileupload>
|
||||
@if (!book.metadata!['coverLocked']) {
|
||||
<p-button pTooltip="Lock Cover" tooltipPosition="top" size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['coverLocked']) {
|
||||
<p-button pTooltip="Unlock Cover" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Audiobook Cover Section -->
|
||||
@if (hasAudiobookFormat(book)) {
|
||||
<div class="cover-section audiobook-cover-section">
|
||||
<div class="cover-type-label audiobook">
|
||||
<i class="pi pi-headphones"></i> Audiobook Cover
|
||||
</div>
|
||||
<p-image
|
||||
[src]="urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)"
|
||||
alt="Audiobook Cover"
|
||||
width="200"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
class="square-cover">
|
||||
</p-image>
|
||||
@if (isUploading) {
|
||||
<p-progressSpinner class="upload-spinner"></p-progressSpinner>
|
||||
}
|
||||
<div class="cover-actions">
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
(onClick)="regenerateAudiobookCover(book.id)"
|
||||
pTooltip="Regenerate cover (From File)"
|
||||
tooltipPosition="top"
|
||||
[outlined]="true"
|
||||
severity="warn"
|
||||
size="small"
|
||||
[disabled]="book.metadata!['audiobookCoverLocked']">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-palette"
|
||||
(onClick)="generateCustomAudiobookCover(book.id)"
|
||||
pTooltip="Generate Custom Cover"
|
||||
tooltipPosition="top"
|
||||
[outlined]="true"
|
||||
severity="help"
|
||||
size="small"
|
||||
[loading]="isGeneratingAudiobookCover"
|
||||
[disabled]="book.metadata!['audiobookCoverLocked'] || isGeneratingAudiobookCover">
|
||||
</p-button>
|
||||
<p-button
|
||||
[disabled]="book.metadata!['audiobookCoverLocked']"
|
||||
outlined
|
||||
size="small"
|
||||
icon="pi pi-search"
|
||||
(onClick)="openAudiobookCoverSearch()"
|
||||
pTooltip="Search for audiobook cover"
|
||||
tooltipPosition="top"
|
||||
severity="info">
|
||||
</p-button>
|
||||
<p-fileupload
|
||||
[chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'"
|
||||
pTooltip="Upload audiobook cover"
|
||||
tooltipPosition="top"
|
||||
[disabled]="book.metadata!['audiobookCoverLocked']"
|
||||
name="file"
|
||||
[url]="getUploadAudiobookCoverUrl()"
|
||||
mode="basic"
|
||||
chooseIcon="pi pi-upload"
|
||||
accept="image/jpeg,image/png"
|
||||
maxFileSize="5000000"
|
||||
(onUpload)="onAudiobookCoverUpload($event)"
|
||||
(onError)="onUploadError($event)"
|
||||
[auto]="true"
|
||||
(onBeforeUpload)="onBeforeSend()">
|
||||
</p-fileupload>
|
||||
@if (!book.metadata!['audiobookCoverLocked']) {
|
||||
<p-button pTooltip="Lock Cover" tooltipPosition="top" size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audiobookCover')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['audiobookCoverLocked']) {
|
||||
<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 class="cover-actions">
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
(onClick)="regenerateCover(book.id)"
|
||||
pTooltip="Regenerate cover (From File)"
|
||||
tooltipPosition="top"
|
||||
[outlined]="true"
|
||||
severity="warn"
|
||||
size="small"
|
||||
[disabled]="book.metadata!['coverLocked']">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-palette"
|
||||
(onClick)="generateCustomCover(book.id)"
|
||||
pTooltip="Generate Custom Cover"
|
||||
tooltipPosition="top"
|
||||
[outlined]="true"
|
||||
severity="help"
|
||||
size="small"
|
||||
[loading]="isGeneratingCover"
|
||||
[disabled]="book.metadata!['coverLocked'] || isGeneratingCover">
|
||||
</p-button>
|
||||
<p-button
|
||||
[disabled]="book.metadata!['coverLocked']"
|
||||
outlined
|
||||
size="small"
|
||||
icon="pi pi-search"
|
||||
(onClick)="openCoverSearch()"
|
||||
pTooltip="Search for cover"
|
||||
tooltipPosition="top"
|
||||
severity="info">
|
||||
</p-button>
|
||||
<p-fileupload
|
||||
[chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'"
|
||||
pTooltip="Upload cover"
|
||||
tooltipPosition="top"
|
||||
[disabled]="book.metadata!['coverLocked']"
|
||||
name="file"
|
||||
[url]="getUploadCoverUrl()"
|
||||
mode="basic"
|
||||
chooseIcon="pi pi-upload"
|
||||
accept="image/jpeg,image/png"
|
||||
maxFileSize="5000000"
|
||||
(onUpload)="onUpload($event)"
|
||||
(onError)="onUploadError($event)"
|
||||
[auto]="true"
|
||||
(onBeforeUpload)="onBeforeSend()">
|
||||
</p-fileupload>
|
||||
@if (!book.metadata!['coverLocked']) {
|
||||
<p-button pTooltip="Lock Cover" tooltipPosition="top" size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['coverLocked']) {
|
||||
<p-button pTooltip="Unlock Cover" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields-section">
|
||||
|
||||
@@ -596,6 +684,48 @@
|
||||
</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>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="description-section">
|
||||
|
||||
+52
-7
@@ -6,10 +6,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep p-image {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
::ng-deep .cover-item p-image {
|
||||
width: 150px;
|
||||
}
|
||||
@@ -120,15 +116,64 @@ label {
|
||||
}
|
||||
}
|
||||
|
||||
.covers-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
flex-shrink: 0;
|
||||
margin: 0 auto;
|
||||
|
||||
&.dual-covers {
|
||||
flex-direction: row;
|
||||
gap: 1rem;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cover-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0;
|
||||
gap: 0.5rem;
|
||||
position: relative;
|
||||
width: 250px;
|
||||
flex-shrink: 0;
|
||||
margin: 0 auto;
|
||||
|
||||
&.audiobook-cover-section {
|
||||
::ng-deep .square-cover img {
|
||||
aspect-ratio: 1;
|
||||
object-fit: cover;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cover-type-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: 0.5rem;
|
||||
margin-bottom: 0.25rem;
|
||||
|
||||
i {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
&.ebook {
|
||||
color: var(--primary-color);
|
||||
background: color-mix(in srgb, var(--primary-color) 15%, transparent);
|
||||
}
|
||||
|
||||
&.audiobook {
|
||||
color: var(--purple-500);
|
||||
background: color-mix(in srgb, var(--purple-500) 15%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
.upload-spinner {
|
||||
|
||||
+170
-3
@@ -80,6 +80,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
isLoading = false;
|
||||
isSaving = false;
|
||||
isGeneratingCover = false;
|
||||
isGeneratingAudiobookCover = false;
|
||||
|
||||
refreshingBookIds = new Set<number>();
|
||||
isAutoFetching = false;
|
||||
@@ -118,6 +119,9 @@ export class MetadataEditorComponent implements OnInit {
|
||||
lubimyczytacRating: true,
|
||||
ranobedbId: true,
|
||||
ranobedbRating: true,
|
||||
audibleId: true,
|
||||
audibleRating: true,
|
||||
audibleReviewCount: true,
|
||||
};
|
||||
|
||||
navigationState$ = this.bookNavigationService.getNavigationState();
|
||||
@@ -195,10 +199,14 @@ export class MetadataEditorComponent implements OnInit {
|
||||
ranobedbId: new FormControl(""),
|
||||
ranobedbRating: new FormControl(""),
|
||||
googleId: new FormControl(""),
|
||||
audibleId: new FormControl(""),
|
||||
audibleRating: new FormControl(""),
|
||||
audibleReviewCount: new FormControl(""),
|
||||
seriesName: new FormControl(""),
|
||||
seriesNumber: new FormControl(""),
|
||||
seriesTotal: new FormControl(""),
|
||||
thumbnailUrl: new FormControl(""),
|
||||
audiobookCover: new FormControl(""),
|
||||
|
||||
titleLocked: new FormControl(false),
|
||||
subtitleLocked: new FormControl(false),
|
||||
@@ -229,10 +237,14 @@ export class MetadataEditorComponent implements OnInit {
|
||||
ranobedbIdLocked: new FormControl(""),
|
||||
ranobedbRatingLocked: new FormControl(false),
|
||||
googleIdLocked: new FormControl(false),
|
||||
audibleIdLocked: new FormControl(false),
|
||||
audibleRatingLocked: new FormControl(false),
|
||||
audibleReviewCountLocked: new FormControl(false),
|
||||
seriesNameLocked: new FormControl(false),
|
||||
seriesNumberLocked: new FormControl(false),
|
||||
seriesTotalLocked: new FormControl(false),
|
||||
coverLocked: new FormControl(false),
|
||||
audiobookCoverLocked: new FormControl(false),
|
||||
reviewsLocked: new FormControl(false),
|
||||
});
|
||||
}
|
||||
@@ -345,6 +357,9 @@ export class MetadataEditorComponent implements OnInit {
|
||||
ranobedbId: metadata.ranobedbId ?? null,
|
||||
ranobedbRating: metadata.ranobedbRating ?? null,
|
||||
googleId: metadata.googleId ?? null,
|
||||
audibleId: metadata.audibleId ?? null,
|
||||
audibleRating: metadata.audibleRating ?? null,
|
||||
audibleReviewCount: metadata.audibleReviewCount ?? null,
|
||||
seriesName: metadata.seriesName ?? null,
|
||||
seriesNumber: metadata.seriesNumber ?? null,
|
||||
seriesTotal: metadata.seriesTotal ?? null,
|
||||
@@ -377,10 +392,14 @@ export class MetadataEditorComponent implements OnInit {
|
||||
ranobedbIdLocked: metadata.ranobedbIdLocked ?? false,
|
||||
ranobedbRatingLocked: metadata.ranobedbRatingLocked ?? false,
|
||||
googleIdLocked: metadata.googleIdLocked ?? false,
|
||||
audibleIdLocked: metadata.audibleIdLocked ?? false,
|
||||
audibleRatingLocked: metadata.audibleRatingLocked ?? false,
|
||||
audibleReviewCountLocked: metadata.audibleReviewCountLocked ?? false,
|
||||
seriesNameLocked: metadata.seriesNameLocked ?? false,
|
||||
seriesNumberLocked: metadata.seriesNumberLocked ?? false,
|
||||
seriesTotalLocked: metadata.seriesTotalLocked ?? false,
|
||||
coverLocked: metadata.coverLocked ?? false,
|
||||
audiobookCoverLocked: metadata.audiobookCoverLocked ?? false,
|
||||
reviewsLocked: metadata.reviewsLocked ?? false,
|
||||
});
|
||||
|
||||
@@ -413,12 +432,16 @@ export class MetadataEditorComponent implements OnInit {
|
||||
{key: "ranobedbIdLocked", control: "ranobedbId"},
|
||||
{key: "ranobedbRatingLocked", control: "ranobedbRating"},
|
||||
{key: "googleIdLocked", control: "googleId"},
|
||||
{key: "audibleIdLocked", control: "audibleId"},
|
||||
{key: "audibleRatingLocked", control: "audibleRating"},
|
||||
{key: "audibleReviewCountLocked", control: "audibleReviewCount"},
|
||||
{key: "pageCountLocked", control: "pageCount"},
|
||||
{key: "descriptionLocked", control: "description"},
|
||||
{key: "seriesNameLocked", control: "seriesName"},
|
||||
{key: "seriesNumberLocked", control: "seriesNumber"},
|
||||
{key: "seriesTotalLocked", control: "seriesTotal"},
|
||||
{key: "coverLocked", control: "thumbnailUrl"},
|
||||
{key: "audiobookCoverLocked", control: "audiobookCover"},
|
||||
{key: "reviewsLocked", control: "reviews"},
|
||||
];
|
||||
|
||||
@@ -496,6 +519,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
const isLocked = this.metadataForm.get(field + "Locked")?.value;
|
||||
const updatedLockedState = !isLocked;
|
||||
this.metadataForm.get(field + "Locked")?.setValue(updatedLockedState);
|
||||
|
||||
if (updatedLockedState) {
|
||||
this.metadataForm.get(field)?.disable();
|
||||
} else {
|
||||
@@ -561,11 +585,15 @@ export class MetadataEditorComponent implements OnInit {
|
||||
ranobedbId: form.get("ranobedbId")?.value,
|
||||
ranobedbRating: form.get("ranobedbRating")?.value,
|
||||
googleId: form.get("googleId")?.value,
|
||||
audibleId: form.get("audibleId")?.value,
|
||||
audibleRating: form.get("audibleRating")?.value,
|
||||
audibleReviewCount: form.get("audibleReviewCount")?.value,
|
||||
language: form.get("language")?.value,
|
||||
seriesName: form.get("seriesName")?.value,
|
||||
seriesNumber: form.get("seriesNumber")?.value,
|
||||
seriesTotal: form.get("seriesTotal")?.value,
|
||||
thumbnailUrl: form.get("thumbnailUrl")?.value,
|
||||
audiobookCover: form.get("audiobookCover")?.value,
|
||||
|
||||
// Locks
|
||||
titleLocked: form.get("titleLocked")?.value,
|
||||
@@ -597,10 +625,14 @@ export class MetadataEditorComponent implements OnInit {
|
||||
ranobedbIdLocked: form.get("ranobedbIdLocked")?.value,
|
||||
ranobedbRatingLocked: form.get("ranobedbRatingLocked")?.value,
|
||||
googleIdLocked: form.get("googleIdLocked")?.value,
|
||||
audibleIdLocked: form.get("audibleIdLocked")?.value,
|
||||
audibleRatingLocked: form.get("audibleRatingLocked")?.value,
|
||||
audibleReviewCountLocked: form.get("audibleReviewCountLocked")?.value,
|
||||
seriesNameLocked: form.get("seriesNameLocked")?.value,
|
||||
seriesNumberLocked: form.get("seriesNumberLocked")?.value,
|
||||
seriesTotalLocked: form.get("seriesTotalLocked")?.value,
|
||||
coverLocked: form.get("coverLocked")?.value,
|
||||
audiobookCoverLocked: form.get("audiobookCoverLocked")?.value,
|
||||
reviewsLocked: form.get("reviewsLocked")?.value,
|
||||
|
||||
...(shouldLockAllFields !== undefined && {
|
||||
@@ -650,9 +682,13 @@ export class MetadataEditorComponent implements OnInit {
|
||||
ranobedbId: wasCleared("ranobedbId"),
|
||||
ranobedbRating: wasCleared("ranobedbRating"),
|
||||
googleId: wasCleared("googleId"),
|
||||
audibleId: wasCleared("audibleId"),
|
||||
audibleRating: wasCleared("audibleRating"),
|
||||
audibleReviewCount: wasCleared("audibleReviewCount"),
|
||||
seriesName: wasCleared("seriesName"),
|
||||
seriesNumber: wasCleared("seriesNumber"),
|
||||
seriesTotal: wasCleared("seriesTotal"),
|
||||
audiobookCover: wasCleared("audiobookCover"),
|
||||
cover: false,
|
||||
};
|
||||
|
||||
@@ -742,6 +778,13 @@ export class MetadataEditorComponent implements OnInit {
|
||||
},
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
this.messageService.add({
|
||||
severity: "error",
|
||||
summary: "Error",
|
||||
detail: err?.error?.message || "Failed to regenerate cover",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -779,6 +822,71 @@ export class MetadataEditorComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
regenerateAudiobookCover(bookId: number) {
|
||||
this.bookService.regenerateAudiobookCover(bookId).subscribe({
|
||||
next: () => {
|
||||
this.bookService.getBookByIdFromAPI(bookId, false).subscribe({
|
||||
next: (updatedBook) => {
|
||||
this.bookService.handleBookUpdate(updatedBook);
|
||||
this.messageService.add({
|
||||
severity: "success",
|
||||
summary: "Success",
|
||||
detail: "Audiobook cover regenerated successfully.",
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: "warning",
|
||||
summary: "Partial Success",
|
||||
detail: "Cover regenerated but failed to refresh display. Please refresh the page.",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
this.messageService.add({
|
||||
severity: "error",
|
||||
summary: "Error",
|
||||
detail: err?.error?.message || "Failed to regenerate audiobook cover",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
generateCustomAudiobookCover(bookId: number) {
|
||||
this.isGeneratingAudiobookCover = true;
|
||||
this.bookService.generateCustomAudiobookCover(bookId)
|
||||
.pipe(finalize(() => this.isGeneratingAudiobookCover = false))
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.bookService.getBookByIdFromAPI(bookId, false).subscribe({
|
||||
next: (updatedBook) => {
|
||||
this.bookService.handleBookUpdate(updatedBook);
|
||||
this.messageService.add({
|
||||
severity: "success",
|
||||
summary: "Success",
|
||||
detail: "Custom audiobook cover generated successfully.",
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: "warning",
|
||||
summary: "Partial Success",
|
||||
detail: "Cover generated but failed to refresh display. Please refresh the page.",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
this.messageService.add({
|
||||
severity: "error",
|
||||
summary: "Error",
|
||||
detail: "Failed to generate custom audiobook cover",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
autoFetch(bookId: number) {
|
||||
this.refreshingBookIds.add(bookId);
|
||||
this.isAutoFetching = true;
|
||||
@@ -818,11 +926,14 @@ export class MetadataEditorComponent implements OnInit {
|
||||
}
|
||||
|
||||
openCoverSearch() {
|
||||
const ref = this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId);
|
||||
const ref = this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'ebook');
|
||||
ref?.onClose.subscribe((result) => {
|
||||
if (result) {
|
||||
this.metadataForm.get("thumbnailUrl")?.setValue(result);
|
||||
this.onSave();
|
||||
this.bookService.getBookByIdFromAPI(this.currentBookId, false).subscribe({
|
||||
next: (updatedBook) => {
|
||||
this.bookService.handleBookUpdate(updatedBook);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -882,4 +993,60 @@ export class MetadataEditorComponent implements OnInit {
|
||||
onFieldChange(): void {
|
||||
this.metadataForm.markAsDirty();
|
||||
}
|
||||
|
||||
// Cover type detection methods
|
||||
hasEbookFormat(book: Book): boolean {
|
||||
if (book.isPhysical) {
|
||||
return true;
|
||||
}
|
||||
const allFiles = [book.primaryFile, ...(book.alternativeFormats || [])].filter(f => f?.bookType);
|
||||
return allFiles.some(f => f!.bookType !== 'AUDIOBOOK');
|
||||
}
|
||||
|
||||
hasAudiobookFormat(book: Book): boolean {
|
||||
const allFiles = [book.primaryFile, ...(book.alternativeFormats || [])].filter(f => f?.bookType);
|
||||
return allFiles.some(f => f!.bookType === 'AUDIOBOOK');
|
||||
}
|
||||
|
||||
supportsDualCovers(book: Book): boolean {
|
||||
return this.bookService.supportsDualCovers(book);
|
||||
}
|
||||
|
||||
getUploadAudiobookCoverUrl(): string {
|
||||
return this.bookService.getUploadAudiobookCoverUrl(this.currentBookId);
|
||||
}
|
||||
|
||||
openAudiobookCoverSearch() {
|
||||
const ref = this.bookDialogHelperService.openCoverSearchDialog(this.currentBookId, 'audiobook');
|
||||
ref?.onClose.subscribe((result) => {
|
||||
if (result) {
|
||||
this.bookService.getBookByIdFromAPI(this.currentBookId, false).subscribe({
|
||||
next: (updatedBook) => {
|
||||
this.bookService.handleBookUpdate(updatedBook);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onAudiobookCoverUpload(event: FileUploadEvent): void {
|
||||
const response: HttpResponse<unknown> =
|
||||
event.originalEvent as HttpResponse<unknown>;
|
||||
if (response && response.status === 200) {
|
||||
this.isUploading = false;
|
||||
this.bookService.getBookByIdFromAPI(this.currentBookId, false).subscribe({
|
||||
next: (updatedBook) => {
|
||||
this.bookService.handleBookUpdate(updatedBook);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
this.isUploading = false;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Upload Failed',
|
||||
detail: 'An error occurred while uploading the audiobook cover',
|
||||
life: 3000,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+294
-55
@@ -40,62 +40,143 @@
|
||||
<span>Cover Image</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
<div class="field-row cover-field-row">
|
||||
<label class="field-label">Cover</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current cover-side">
|
||||
<span class="cover-label mobile-only">Current</span>
|
||||
<div class="cover-wrapper">
|
||||
<p-image
|
||||
class="cover-image"
|
||||
[src]="metadataForm.get('thumbnailUrl')?.value"
|
||||
alt="Current cover"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="lock-badge"
|
||||
[class.locked]="metadataForm.get('coverLocked')?.value"
|
||||
(click)="toggleLock('thumbnailUrl')"
|
||||
[pTooltip]="metadataForm.get('coverLocked')?.value ? 'Unlock cover' : 'Lock cover'"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<i [class]="metadataForm.get('coverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
<div class="section-content" [class.dual-covers-section]="currentBook && supportsDualCovers(currentBook)">
|
||||
<!-- Ebook Cover Row -->
|
||||
@if (!currentBook || hasEbookFormat(currentBook)) {
|
||||
<div class="field-row cover-field-row">
|
||||
<label class="field-label">
|
||||
@if (currentBook && supportsDualCovers(currentBook)) {
|
||||
<i class="pi pi-book cover-type-icon"></i> Ebook
|
||||
} @else {
|
||||
Cover
|
||||
}
|
||||
</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current cover-side">
|
||||
<span class="cover-label mobile-only">Current</span>
|
||||
<div class="cover-wrapper">
|
||||
<p-image
|
||||
class="cover-image"
|
||||
[src]="metadataForm.get('thumbnailUrl')?.value"
|
||||
alt="Current cover"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="lock-badge"
|
||||
[class.locked]="metadataForm.get('coverLocked')?.value"
|
||||
(click)="toggleLock('thumbnailUrl')"
|
||||
[pTooltip]="metadataForm.get('coverLocked')?.value ? 'Unlock cover' : 'Lock cover'"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<i [class]="metadataForm.get('coverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved('thumbnailUrl')"
|
||||
[class.copied]="isValueCopied('thumbnailUrl') && !hoveredFields['thumbnailUrl']"
|
||||
[class.reset]="isValueCopied('thumbnailUrl') && hoveredFields['thumbnailUrl']"
|
||||
(click)="hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? resetField('thumbnailUrl') : copyFetchedToCurrent('thumbnailUrl')"
|
||||
(mouseenter)="onMouseEnter('thumbnailUrl')"
|
||||
(mouseleave)="onMouseLeave('thumbnailUrl')"
|
||||
>
|
||||
<i [class]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : (hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved('thumbnailUrl')"
|
||||
[class.copied]="isValueCopied('thumbnailUrl') && !hoveredFields['thumbnailUrl']"
|
||||
[class.reset]="isValueCopied('thumbnailUrl') && hoveredFields['thumbnailUrl']"
|
||||
(click)="hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? resetField('thumbnailUrl') : copyFetchedToCurrent('thumbnailUrl')"
|
||||
(mouseenter)="onMouseEnter('thumbnailUrl')"
|
||||
(mouseleave)="onMouseLeave('thumbnailUrl')"
|
||||
>
|
||||
<i [class]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : (hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched cover-side">
|
||||
<span class="cover-label mobile-only">Fetched</span>
|
||||
<div class="cover-wrapper">
|
||||
<p-image
|
||||
class="cover-image"
|
||||
[src]="fetchedMetadata.thumbnailUrl!"
|
||||
alt="Fetched cover"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
<div class="field-side fetched cover-side">
|
||||
<span class="cover-label mobile-only">Fetched</span>
|
||||
<div class="cover-wrapper">
|
||||
<p-image
|
||||
class="cover-image"
|
||||
[src]="fetchedMetadata.thumbnailUrl!"
|
||||
alt="Fetched cover"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Audiobook Cover Row -->
|
||||
@if (currentBook && hasAudiobookFormat(currentBook)) {
|
||||
<div class="field-row cover-field-row audiobook-cover-row">
|
||||
<label class="field-label">
|
||||
<i class="pi pi-headphones cover-type-icon"></i> Audiobook
|
||||
</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current cover-side">
|
||||
<span class="cover-label mobile-only">Current</span>
|
||||
<div class="cover-wrapper">
|
||||
<p-image
|
||||
class="cover-image square-cover"
|
||||
[src]="metadataForm.get('audiobookThumbnailUrl')?.value"
|
||||
alt="Current audiobook cover"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="lock-badge"
|
||||
[class.locked]="metadataForm.get('audiobookCoverLocked')?.value"
|
||||
(click)="toggleLock('audiobookThumbnailUrl')"
|
||||
[pTooltip]="metadataForm.get('audiobookCoverLocked')?.value ? 'Unlock cover' : 'Lock cover'"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<i [class]="metadataForm.get('audiobookCoverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (isAudibleProvider()) {
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved('audiobookThumbnailUrl')"
|
||||
[class.copied]="isValueCopied('audiobookThumbnailUrl') && !hoveredFields['audiobookThumbnailUrl']"
|
||||
[class.reset]="isValueCopied('audiobookThumbnailUrl') && hoveredFields['audiobookThumbnailUrl']"
|
||||
(click)="hoveredFields['audiobookThumbnailUrl'] && isValueCopied('audiobookThumbnailUrl') ? resetField('audiobookThumbnailUrl') : copyFetchedToCurrent('audiobookThumbnailUrl')"
|
||||
(mouseenter)="onMouseEnter('audiobookThumbnailUrl')"
|
||||
(mouseleave)="onMouseLeave('audiobookThumbnailUrl')"
|
||||
>
|
||||
<i [class]="isValueSaved('audiobookThumbnailUrl') ? 'pi pi-check' : (hoveredFields['audiobookThumbnailUrl'] && isValueCopied('audiobookThumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
} @else {
|
||||
<div class="transfer-btn-placeholder"></div>
|
||||
}
|
||||
|
||||
<div class="field-side fetched cover-side">
|
||||
<span class="cover-label mobile-only">Fetched</span>
|
||||
<div class="cover-wrapper">
|
||||
@if (isAudibleProvider()) {
|
||||
<p-image
|
||||
class="cover-image square-cover"
|
||||
[src]="fetchedMetadata.thumbnailUrl!"
|
||||
alt="Fetched audiobook cover"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
} @else {
|
||||
<div class="no-cover-placeholder">
|
||||
<i class="pi pi-image"></i>
|
||||
<span>N/A</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -261,16 +342,108 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Additional Details Section -->
|
||||
@if (metadataFieldsBottom.length > 0) {
|
||||
<!-- Series Information Section -->
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-book"></i>
|
||||
<span>Series Information</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataSeriesFields; 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>
|
||||
|
||||
<!-- Book Details Section -->
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-id-card"></i>
|
||||
<span>Book Details</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataBookDetailsFields; 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>
|
||||
|
||||
<!-- Provider Metadata Section -->
|
||||
@if (metadataProviderFields.length > 0) {
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-list"></i>
|
||||
<span>Additional Details</span>
|
||||
<i class="pi pi-cloud"></i>
|
||||
<span>Provider Metadata</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataFieldsBottom; track field) {
|
||||
@for (field of metadataProviderFields; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
@@ -308,6 +481,72 @@
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
|
||||
<!-- Audiobook Details Section -->
|
||||
@if (currentBook && hasAudiobookFormat(currentBook)) {
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-headphones"></i>
|
||||
<span>Audiobook Details</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of audiobookMetadataFields; 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="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">
|
||||
@if (field.type === 'boolean') {
|
||||
<p-checkbox
|
||||
[ngModel]="getFetchedAudiobookValue(field.fetchedKey)"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[binary]="true"
|
||||
[disabled]="true"
|
||||
class="field-checkbox"
|
||||
/>
|
||||
} @else {
|
||||
<input pInputText [value]="getFetchedAudiobookValue(field.fetchedKey) ?? ''" class="field-input" readonly/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (!reviewMode) {
|
||||
|
||||
+66
-8
@@ -144,21 +144,20 @@
|
||||
}
|
||||
|
||||
.cover-image {
|
||||
width: 100px;
|
||||
height: 150px;
|
||||
width: 120px;
|
||||
height: auto;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
|
||||
@media (min-width: 768px) {
|
||||
width: 120px;
|
||||
height: 180px;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
::ng-deep img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +198,65 @@
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
|
||||
// Cover type icon in label
|
||||
.cover-type-icon {
|
||||
font-size: 0.8rem;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
|
||||
// Square cover for audiobooks
|
||||
.square-cover {
|
||||
aspect-ratio: 1;
|
||||
|
||||
::ng-deep img {
|
||||
object-fit: cover;
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Audiobook cover row
|
||||
.audiobook-cover-row {
|
||||
background: rgba(var(--p-primary-500-rgb), 0.03);
|
||||
}
|
||||
|
||||
// Transfer button placeholder (same width as button)
|
||||
.transfer-btn-placeholder {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// No cover placeholder
|
||||
.no-cover-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background: var(--surface-ground);
|
||||
border: 1px dashed var(--border-color);
|
||||
border-radius: 6px;
|
||||
color: var(--text-secondary-color);
|
||||
|
||||
@media (min-width: 768px) {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 1.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Field Rows
|
||||
.field-row {
|
||||
@@ -221,7 +279,7 @@
|
||||
|
||||
// Cover field row specific styles
|
||||
.cover-field-row {
|
||||
padding: 1.25rem 1rem;
|
||||
padding: 1rem;
|
||||
|
||||
.field-label {
|
||||
text-align: center;
|
||||
@@ -255,7 +313,7 @@
|
||||
|
||||
// Position covers towards the arrow on desktop only
|
||||
@media (min-width: 768px) {
|
||||
padding: 1.5rem 1rem;
|
||||
padding: 1rem;
|
||||
|
||||
.field-side.current {
|
||||
justify-content: flex-end;
|
||||
|
||||
+154
-25
@@ -5,19 +5,20 @@ import {Button} from 'primeng/button';
|
||||
import {FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {Observable} from 'rxjs';
|
||||
import {forkJoin, Observable} from 'rxjs';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
||||
import {BookService} from '../../../../book/service/book.service';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
import {filter, map, take} from 'rxjs/operators';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {AutoComplete, AutoCompleteSelectEvent} from 'primeng/autocomplete';
|
||||
import {Image} from 'primeng/image';
|
||||
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, getArrayFields, getBottomFields, getTextareaFields, getTopFields, MetadataFieldConfig, MetadataFormBuilder, MetadataUtilsService} from '../../../../../shared/metadata';
|
||||
import {ALL_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELDS, getArrayFields, getBookDetailsFields, getBottomFields, getProviderFields, getSeriesFields, getTextareaFields, getTopFields, MetadataFieldConfig, MetadataFormBuilder, MetadataUtilsService} from '../../../../../shared/metadata';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-picker',
|
||||
@@ -34,7 +35,8 @@ import {ALL_METADATA_FIELDS, getArrayFields, getBottomFields, getTextareaFields,
|
||||
Textarea,
|
||||
AutoComplete,
|
||||
Image,
|
||||
LazyLoadImageModule
|
||||
LazyLoadImageModule,
|
||||
Checkbox
|
||||
]
|
||||
})
|
||||
export class MetadataPickerComponent implements OnInit {
|
||||
@@ -43,13 +45,19 @@ export class MetadataPickerComponent implements OnInit {
|
||||
metadataFieldsTop: MetadataFieldConfig[] = [];
|
||||
metadataChips: MetadataFieldConfig[] = [];
|
||||
metadataDescription: MetadataFieldConfig[] = [];
|
||||
metadataSeriesFields: MetadataFieldConfig[] = [];
|
||||
metadataBookDetailsFields: MetadataFieldConfig[] = [];
|
||||
metadataProviderFields: MetadataFieldConfig[] = [];
|
||||
metadataFieldsBottom: MetadataFieldConfig[] = [];
|
||||
audiobookMetadataFields: MetadataFieldConfig[] = [];
|
||||
|
||||
@Input() reviewMode!: boolean;
|
||||
@Input() fetchedMetadata!: BookMetadata;
|
||||
@Input() book$!: Observable<Book | null>;
|
||||
@Output() goBack = new EventEmitter<boolean>();
|
||||
|
||||
currentBook: Book | null = null;
|
||||
|
||||
private allItems: Record<string, string[]> = {};
|
||||
filteredItems: Record<string, string[]> = {};
|
||||
|
||||
@@ -80,7 +88,15 @@ export class MetadataPickerComponent implements OnInit {
|
||||
this.metadataFieldsTop = getTopFields();
|
||||
this.metadataChips = getArrayFields();
|
||||
this.metadataDescription = getTextareaFields();
|
||||
this.metadataSeriesFields = getSeriesFields();
|
||||
this.metadataBookDetailsFields = getBookDetailsFields();
|
||||
this.updateProviderFields();
|
||||
this.updateBottomFields();
|
||||
this.audiobookMetadataFields = AUDIOBOOK_METADATA_FIELDS;
|
||||
}
|
||||
|
||||
private updateProviderFields(): void {
|
||||
this.metadataProviderFields = getProviderFields(this.enabledProviderFields);
|
||||
}
|
||||
|
||||
private updateBottomFields(): void {
|
||||
@@ -106,6 +122,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
.subscribe(settings => {
|
||||
if (settings?.metadataProviderSpecificFields) {
|
||||
this.enabledProviderFields = settings.metadataProviderSpecificFields;
|
||||
this.updateProviderFields();
|
||||
this.updateBottomFields();
|
||||
}
|
||||
});
|
||||
@@ -138,9 +155,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
this.book$
|
||||
.pipe(
|
||||
filter((book): book is Book => !!book && !!book.metadata),
|
||||
map(book => book.metadata),
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
).subscribe((metadata) => {
|
||||
).subscribe((book) => {
|
||||
if (this.reviewMode) {
|
||||
this.metadataForm.reset();
|
||||
this.copiedFields = {};
|
||||
@@ -148,16 +164,16 @@ export class MetadataPickerComponent implements OnInit {
|
||||
this.hoveredFields = {};
|
||||
}
|
||||
|
||||
if (metadata) {
|
||||
this.originalMetadata = metadata;
|
||||
this.originalMetadata.thumbnailUrl = this.urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||
this.currentBookId = metadata.bookId;
|
||||
this.patchMetadataToForm(metadata);
|
||||
}
|
||||
this.currentBook = book;
|
||||
const metadata = book.metadata!;
|
||||
this.originalMetadata = metadata;
|
||||
this.originalMetadata.thumbnailUrl = this.urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||
this.currentBookId = metadata.bookId;
|
||||
this.patchMetadataToForm(metadata, book);
|
||||
});
|
||||
}
|
||||
|
||||
private patchMetadataToForm(metadata: BookMetadata): void {
|
||||
private patchMetadataToForm(metadata: BookMetadata, book: Book): void {
|
||||
const patchData: Record<string, unknown> = {};
|
||||
|
||||
for (const field of ALL_METADATA_FIELDS) {
|
||||
@@ -173,10 +189,26 @@ export class MetadataPickerComponent implements OnInit {
|
||||
patchData[field.lockedKey] = metadata[lockedKey] ?? false;
|
||||
}
|
||||
|
||||
// Handle special fields
|
||||
// Handle special fields - ebook cover
|
||||
patchData['thumbnailUrl'] = this.urlHelper.getCoverUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||
patchData['coverLocked'] = metadata.coverLocked ?? false;
|
||||
|
||||
// Handle audiobook cover
|
||||
patchData['audiobookThumbnailUrl'] = this.urlHelper.getAudiobookCoverUrl(metadata.bookId, metadata.audiobookCoverUpdatedOn);
|
||||
patchData['audiobookCoverLocked'] = metadata.audiobookCoverLocked ?? false;
|
||||
|
||||
// Handle audiobook-specific metadata fields
|
||||
// narrator/abridged are now at top-level of BookMetadata, but we also check nested for backward compatibility
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
const key = field.controlName as keyof BookMetadata;
|
||||
const lockedKey = field.lockedKey as keyof BookMetadata;
|
||||
// Prefer top-level fields, fallback to nested audiobookMetadata
|
||||
const topLevelValue = metadata[key];
|
||||
const topLevelLocked = metadata[lockedKey];
|
||||
patchData[field.controlName] = topLevelValue ?? (field.type === 'boolean' ? null : '');
|
||||
patchData[field.lockedKey] = topLevelLocked ?? false;
|
||||
}
|
||||
|
||||
this.metadataForm.patchValue(patchData);
|
||||
this.applyLockStates(metadata);
|
||||
}
|
||||
@@ -186,6 +218,10 @@ export class MetadataPickerComponent implements OnInit {
|
||||
for (const field of ALL_METADATA_FIELDS) {
|
||||
lockedFields[field.lockedKey] = !!metadata[field.lockedKey as keyof BookMetadata];
|
||||
}
|
||||
// Also handle audiobook metadata lock states (now at top-level of BookMetadata)
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
lockedFields[field.lockedKey] = !!metadata[field.lockedKey as keyof BookMetadata];
|
||||
}
|
||||
this.formBuilder.applyLockStates(this.metadataForm, lockedFields);
|
||||
}
|
||||
|
||||
@@ -214,7 +250,20 @@ export class MetadataPickerComponent implements OnInit {
|
||||
onSave(): void {
|
||||
this.isSaving = true;
|
||||
const updatedBookMetadata = this.buildMetadataWrapper(undefined);
|
||||
this.bookService.updateBookMetadata(this.currentBookId, updatedBookMetadata, false).subscribe({
|
||||
|
||||
const requests: Observable<unknown>[] = [
|
||||
this.bookService.updateBookMetadata(this.currentBookId, updatedBookMetadata, false)
|
||||
];
|
||||
|
||||
// Handle audiobook cover upload when fetched from Audible provider
|
||||
if (this.isAudibleProvider() && this.copiedFields['audiobookThumbnailUrl']) {
|
||||
const audiobookCoverUrl = this.fetchedMetadata.thumbnailUrl;
|
||||
if (audiobookCoverUrl) {
|
||||
requests.push(this.bookService.uploadAudiobookCoverFromUrl(this.currentBookId, audiobookCoverUrl));
|
||||
}
|
||||
}
|
||||
|
||||
forkJoin(requests).subscribe({
|
||||
next: () => {
|
||||
this.isSaving = false;
|
||||
for (const field of Object.keys(this.copiedFields)) {
|
||||
@@ -254,6 +303,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
metadata[field.controlName] = this.getArrayValue(field.controlName);
|
||||
} else if (field.type === 'number') {
|
||||
metadata[field.controlName] = this.getNumberValue(field.controlName);
|
||||
} else if (field.type === 'boolean') {
|
||||
metadata[field.controlName] = this.getBooleanValue(field.controlName);
|
||||
} else {
|
||||
metadata[field.controlName] = this.getStringValue(field.controlName);
|
||||
}
|
||||
@@ -263,6 +314,17 @@ export class MetadataPickerComponent implements OnInit {
|
||||
|
||||
metadata['thumbnailUrl'] = this.getThumbnail();
|
||||
metadata['coverLocked'] = this.metadataForm.get('coverLocked')?.value;
|
||||
metadata['audiobookCoverLocked'] = this.metadataForm.get('audiobookCoverLocked')?.value;
|
||||
|
||||
// Set audiobook content metadata (narrator/abridged) at top level
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
if (field.type === 'boolean') {
|
||||
metadata[field.controlName] = this.getBooleanValue(field.controlName);
|
||||
} else {
|
||||
metadata[field.controlName] = this.getStringValue(field.controlName);
|
||||
}
|
||||
metadata[field.lockedKey] = this.metadataForm.get(field.lockedKey)?.value ?? false;
|
||||
}
|
||||
|
||||
return metadata as BookMetadata;
|
||||
}
|
||||
@@ -304,6 +366,17 @@ export class MetadataPickerComponent implements OnInit {
|
||||
return Array.isArray(fieldValue) ? fieldValue as string[] : [];
|
||||
}
|
||||
|
||||
private getBooleanValue(field: string): boolean | null {
|
||||
const formValue = this.metadataForm.get(field)?.value;
|
||||
if (formValue === null || formValue === undefined) {
|
||||
if (this.copiedFields[field]) {
|
||||
return (this.fetchedMetadata[field as keyof BookMetadata] as boolean | null) ?? null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return !!formValue;
|
||||
}
|
||||
|
||||
private inferClearFlags(current: BookMetadata, original: BookMetadata): MetadataClearFlags {
|
||||
const flags: Record<string, boolean> = {};
|
||||
|
||||
@@ -316,16 +389,36 @@ export class MetadataPickerComponent implements OnInit {
|
||||
flags[key] = !(curr as string[])?.length && !!(orig as string[])?.length;
|
||||
} else if (field.type === 'number') {
|
||||
flags[key] = curr === null && orig !== null;
|
||||
} else if (field.type === 'boolean') {
|
||||
flags[key] = curr === null && orig !== null;
|
||||
} else {
|
||||
flags[key] = !curr && !!orig;
|
||||
}
|
||||
}
|
||||
|
||||
flags['cover'] = !current.thumbnailUrl && !!original.thumbnailUrl;
|
||||
|
||||
// Handle audiobook metadata clear flags (now at top-level of BookMetadata)
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
const key = field.controlName as keyof BookMetadata;
|
||||
const curr = current[key];
|
||||
const orig = original[key];
|
||||
|
||||
if (field.type === 'boolean') {
|
||||
flags[key] = curr === null && orig !== null;
|
||||
} else {
|
||||
flags[key] = !curr && !!orig;
|
||||
}
|
||||
}
|
||||
|
||||
return flags as MetadataClearFlags;
|
||||
}
|
||||
|
||||
getThumbnail(): string | null {
|
||||
// For Audible provider, cover is handled separately via uploadAudiobookCoverFromUrl
|
||||
if (this.isAudibleProvider()) {
|
||||
return null;
|
||||
}
|
||||
const thumbnailUrl = this.metadataForm.get('thumbnailUrl')?.value;
|
||||
if (thumbnailUrl?.includes('api/v1')) {
|
||||
return null;
|
||||
@@ -360,16 +453,20 @@ export class MetadataPickerComponent implements OnInit {
|
||||
}
|
||||
|
||||
toggleLock(field: string): void {
|
||||
const controlName = field;
|
||||
let lockField = field;
|
||||
if (field === 'thumbnailUrl') {
|
||||
field = 'cover';
|
||||
lockField = 'cover';
|
||||
} else if (field === 'audiobookThumbnailUrl') {
|
||||
lockField = 'audiobookCover';
|
||||
}
|
||||
const isLocked = this.metadataForm.get(field + 'Locked')?.value;
|
||||
const isLocked = this.metadataForm.get(lockField + 'Locked')?.value;
|
||||
const updatedLockedState = !isLocked;
|
||||
this.metadataForm.get(field + 'Locked')?.setValue(updatedLockedState);
|
||||
this.metadataForm.get(lockField + 'Locked')?.setValue(updatedLockedState);
|
||||
if (updatedLockedState) {
|
||||
this.metadataForm.get(field)?.disable();
|
||||
this.metadataForm.get(controlName)?.disable();
|
||||
} else {
|
||||
this.metadataForm.get(field)?.enable();
|
||||
this.metadataForm.get(controlName)?.enable();
|
||||
}
|
||||
this.updateMetadata(undefined);
|
||||
}
|
||||
@@ -392,20 +489,26 @@ export class MetadataPickerComponent implements OnInit {
|
||||
}
|
||||
|
||||
copyFetchedToCurrent(field: string): void {
|
||||
let lockField = field;
|
||||
if (field === 'thumbnailUrl') {
|
||||
field = 'cover';
|
||||
lockField = 'cover';
|
||||
} else if (field === 'audiobookThumbnailUrl') {
|
||||
lockField = 'audiobookCover';
|
||||
}
|
||||
const isLocked = this.metadataForm.get(`${field}Locked`)?.value;
|
||||
const isLocked = this.metadataForm.get(`${lockField}Locked`)?.value;
|
||||
if (isLocked) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Action Blocked',
|
||||
detail: `${field} is locked and cannot be updated.`
|
||||
detail: `${lockField} is locked and cannot be updated.`
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (field === 'cover') {
|
||||
field = 'thumbnailUrl';
|
||||
// For audiobook cover from Audible, use the thumbnailUrl from fetched metadata
|
||||
if (field === 'audiobookThumbnailUrl') {
|
||||
this.metadataForm.get('audiobookThumbnailUrl')?.setValue(this.fetchedMetadata.thumbnailUrl);
|
||||
this.highlightCopiedInput(field);
|
||||
return;
|
||||
}
|
||||
if (this.metadataUtils.copyFieldToForm(field, this.fetchedMetadata, this.metadataForm, this.copiedFields)) {
|
||||
this.highlightCopiedInput(field);
|
||||
@@ -451,4 +554,30 @@ export class MetadataPickerComponent implements OnInit {
|
||||
resetField(field: string): void {
|
||||
this.metadataUtils.resetField(field, this.metadataForm, this.originalMetadata, this.copiedFields, this.hoveredFields);
|
||||
}
|
||||
|
||||
isAudibleProvider(): boolean {
|
||||
return this.fetchedMetadata?.provider?.toLowerCase() === 'audible';
|
||||
}
|
||||
|
||||
getFetchedAudiobookValue(key: string): unknown {
|
||||
return this.fetchedMetadata?.[key as keyof BookMetadata];
|
||||
}
|
||||
|
||||
// Cover type detection methods
|
||||
hasEbookFormat(book: Book): boolean {
|
||||
if (book.isPhysical) {
|
||||
return true;
|
||||
}
|
||||
const allFiles = [book.primaryFile, ...(book.alternativeFormats || [])].filter(f => f?.bookType);
|
||||
return allFiles.some(f => f!.bookType !== 'AUDIOBOOK');
|
||||
}
|
||||
|
||||
hasAudiobookFormat(book: Book): boolean {
|
||||
const allFiles = [book.primaryFile, ...(book.alternativeFormats || [])].filter(f => f?.bookType);
|
||||
return allFiles.some(f => f!.bookType === 'AUDIOBOOK');
|
||||
}
|
||||
|
||||
supportsDualCovers(book: Book): boolean {
|
||||
return this.hasEbookFormat(book) && this.hasAudiobookFormat(book);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -266,6 +266,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
if (metadata['lubimyczytacId']) return 'lubimyczytac';
|
||||
if (metadata.comicvineId) return 'comicvine';
|
||||
if (metadata.ranobedbId) return 'ranobedb';
|
||||
if (metadata.audibleId) return 'audible';
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -378,13 +379,15 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
return `<a href="https://comicvine.gamespot.com/volume/${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>`;
|
||||
}
|
||||
throw new Error("No provider ID found in metadata.");
|
||||
}
|
||||
|
||||
trackByMetadata(index: number, metadata: BookMetadata): string {
|
||||
return metadata.googleId || metadata.goodreadsId || metadata.asin ||
|
||||
metadata.hardcoverId || metadata.comicvineId || index.toString();
|
||||
metadata.hardcoverId || metadata.comicvineId || metadata.audibleId || index.toString();
|
||||
}
|
||||
|
||||
onProviderClick(event: MouseEvent) {
|
||||
|
||||
+38
@@ -8,6 +8,11 @@
|
||||
<p-tab value="similar">
|
||||
<i class="pi pi-bookmark"></i> Similar Books
|
||||
</p-tab>
|
||||
@if (supportsDualCovers()) {
|
||||
<p-tab value="covers">
|
||||
<i class="pi pi-images"></i> Covers
|
||||
</p-tab>
|
||||
}
|
||||
<p-tab value="files">
|
||||
<i class="pi pi-folder-open"></i> Files
|
||||
</p-tab>
|
||||
@@ -54,6 +59,39 @@
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="covers">
|
||||
<ng-template #content>
|
||||
<div class="covers-tab-content">
|
||||
<div class="covers-grid">
|
||||
<div class="cover-item">
|
||||
<div class="cover-label">
|
||||
<i class="pi pi-book"></i> Ebook Cover
|
||||
</div>
|
||||
<p-image
|
||||
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
alt="Ebook Cover"
|
||||
width="200"
|
||||
appendTo="body"
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
</div>
|
||||
<div class="cover-item">
|
||||
<div class="cover-label audiobook">
|
||||
<i class="pi pi-headphones"></i> Audiobook Cover
|
||||
</div>
|
||||
<p-image
|
||||
[src]="urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)"
|
||||
alt="Audiobook Cover"
|
||||
width="200"
|
||||
appendTo="body"
|
||||
[preview]="true"
|
||||
styleClass="square-cover">
|
||||
</p-image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="notes">
|
||||
<ng-template #content>
|
||||
<app-book-notes-component [bookId]="book.id"></app-book-notes-component>
|
||||
|
||||
+50
@@ -214,3 +214,53 @@
|
||||
margin: 0;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
// Covers tab styles
|
||||
.covers-tab-content {
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.covers-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 2rem;
|
||||
justify-content: center;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.cover-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
|
||||
::ng-deep .square-cover img {
|
||||
aspect-ratio: 1;
|
||||
object-fit: cover;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.cover-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--primary-color);
|
||||
padding: 0.25rem 0.75rem;
|
||||
background: color-mix(in srgb, var(--primary-color) 15%, transparent);
|
||||
border-radius: 0.5rem;
|
||||
|
||||
i {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
&.audiobook {
|
||||
color: var(--purple-500);
|
||||
background: color-mix(in srgb, var(--purple-500) 15%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-2
@@ -1,4 +1,4 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {Component, EventEmitter, inject, Input, Output} from '@angular/core';
|
||||
import {UpperCasePipe} from '@angular/common';
|
||||
import {Book, BookRecommendation, BookType, FileInfo} from '../../../../../book/model/book.model';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
@@ -9,6 +9,9 @@ import {BookNotesComponent} from '../../../../../book/components/book-notes/book
|
||||
import {BookReadingSessionsComponent} from '../../book-reading-sessions/book-reading-sessions.component';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {Image} from 'primeng/image';
|
||||
import {UrlHelperService} from '../../../../../../shared/service/url-helper.service';
|
||||
import {BookService} from '../../../../../book/service/book.service';
|
||||
|
||||
export interface ReadEvent {
|
||||
bookId: number;
|
||||
@@ -59,7 +62,8 @@ export interface DeleteSupplementaryFileEvent {
|
||||
BookReadingSessionsComponent,
|
||||
Button,
|
||||
Tooltip,
|
||||
UpperCasePipe
|
||||
UpperCasePipe,
|
||||
Image
|
||||
],
|
||||
templateUrl: './metadata-tabs.component.html',
|
||||
styleUrl: './metadata-tabs.component.scss'
|
||||
@@ -69,6 +73,9 @@ export class MetadataTabsComponent {
|
||||
@Input() bookInSeries: Book[] = [];
|
||||
@Input() recommendedBooks: BookRecommendation[] = [];
|
||||
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private bookService = inject(BookService);
|
||||
|
||||
@Output() readBook = new EventEmitter<ReadEvent>();
|
||||
@Output() downloadBook = new EventEmitter<DownloadEvent>();
|
||||
@Output() downloadFile = new EventEmitter<DownloadAdditionalFileEvent>();
|
||||
@@ -161,4 +168,8 @@ export class MetadataTabsComponent {
|
||||
isPhysicalBook(): boolean {
|
||||
return !this.book?.primaryFile && (!this.book?.alternativeFormats || this.book.alternativeFormats.length === 0);
|
||||
}
|
||||
|
||||
supportsDualCovers(): boolean {
|
||||
return this.bookService.supportsDualCovers(this.book);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-4
@@ -6,7 +6,7 @@
|
||||
<div class="cover-wrapper">
|
||||
|
||||
<p-image
|
||||
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
[src]="getBookCoverUrl(book)"
|
||||
alt="Image"
|
||||
width="250"
|
||||
appendTo="body"
|
||||
@@ -96,12 +96,12 @@
|
||||
|
||||
<div class="title-group">
|
||||
@if (book?.metadata?.seriesName) {
|
||||
<p class="series-link" (click)="goToSeries(book?.metadata?.seriesName!)">
|
||||
<div class="series-link" (click)="goToSeries(book?.metadata?.seriesName!)">
|
||||
{{ book?.metadata?.seriesName }}
|
||||
@if (book?.metadata?.seriesNumber) {
|
||||
#{{ book?.metadata?.seriesNumber }}
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="title-wrapper">
|
||||
@@ -154,7 +154,7 @@
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
@if (book?.metadata?.amazonRating || book?.metadata?.goodreadsRating || book?.metadata?.hardcoverRating || book?.metadata?.lubimyczytacRating || book?.metadata?.ranobedbRating || book?.metadata?.googleId) {
|
||||
@if (book?.metadata?.amazonRating || book?.metadata?.goodreadsRating || book?.metadata?.hardcoverRating || book?.metadata?.lubimyczytacRating || book?.metadata?.ranobedbRating || book?.metadata?.audibleRating || book?.metadata?.googleId) {
|
||||
<div class="gradient-divider"></div>
|
||||
}
|
||||
|
||||
@@ -229,6 +229,20 @@
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (book?.metadata?.audibleRating) {
|
||||
<a
|
||||
class="rating-link"
|
||||
[href]="'https://www.audible.com/pd/' + (book.metadata?.audibleId ?? '')"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
[pTooltip]="getRatingTooltip(book, 'audible')"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<img src="https://www.audible.com/favicon.ico" alt="Audible" class="rating-favicon"/>
|
||||
<span class="rating-value">{{ getRatingPercent(book.metadata!.audibleRating) }}%</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (book?.metadata?.googleId) {
|
||||
<a
|
||||
class="rating-link"
|
||||
|
||||
+12
-1
@@ -1078,7 +1078,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
return p != null ? Math.round(p * 10) / 10 : null;
|
||||
}
|
||||
|
||||
getRatingTooltip(book: Book, source: 'amazon' | 'goodreads' | 'hardcover' | 'lubimyczytac' | 'ranobedb'): string {
|
||||
getRatingTooltip(book: Book, source: 'amazon' | 'goodreads' | 'hardcover' | 'lubimyczytac' | 'ranobedb' | 'audible'): string {
|
||||
const meta = book?.metadata;
|
||||
if (!meta) return '';
|
||||
|
||||
@@ -1103,6 +1103,10 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
return meta.ranobedbRating != null
|
||||
? `★ ${meta.ranobedbRating}`
|
||||
: '';
|
||||
case 'audible':
|
||||
return meta.audibleRating != null
|
||||
? `★ ${meta.audibleRating} | ${meta.audibleReviewCount?.toLocaleString() ?? '0'} reviews`
|
||||
: '';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
@@ -1231,4 +1235,11 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
isPhysicalBook(book: Book): boolean {
|
||||
return !this.hasAnyFiles(book);
|
||||
}
|
||||
|
||||
getBookCoverUrl(book: Book): string {
|
||||
const isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK';
|
||||
return isAudiobook
|
||||
? this.urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)
|
||||
: this.urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<div class="cover-search-container">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-image header-icon"></i>
|
||||
<i class="pi {{ coverType === 'audiobook' ? 'pi-headphones' : 'pi-image' }} header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Search Cover Images</h2>
|
||||
<h2 class="panel-title">Search {{ coverType === 'audiobook' ? 'Audiobook' : 'Ebook' }} Cover</h2>
|
||||
<p class="panel-description">Find and select a cover for your book</p>
|
||||
</div>
|
||||
<p-button
|
||||
|
||||
+32
-21
@@ -31,7 +31,7 @@ export class CoverSearchComponent implements OnInit {
|
||||
coverImages: CoverImage[] = [];
|
||||
loading = false;
|
||||
hasSearched = false;
|
||||
isAudiobook = false;
|
||||
coverType: 'ebook' | 'audiobook' = 'ebook';
|
||||
|
||||
private fb = inject(FormBuilder);
|
||||
private bookCoverService = inject(BookCoverService);
|
||||
@@ -51,8 +51,16 @@ export class CoverSearchComponent implements OnInit {
|
||||
this.bookId = this.dynamicDialogConfig.data.bookId;
|
||||
const book = this.bookService.getBookByIdFromState(this.bookId);
|
||||
|
||||
// Use explicitly provided coverType, or auto-detect based on primary file
|
||||
if (this.dynamicDialogConfig.data.coverType) {
|
||||
this.coverType = this.dynamicDialogConfig.data.coverType;
|
||||
} else if (book?.primaryFile?.bookType === 'AUDIOBOOK') {
|
||||
this.coverType = 'audiobook';
|
||||
} else {
|
||||
this.coverType = 'ebook';
|
||||
}
|
||||
|
||||
if (book) {
|
||||
this.isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK';
|
||||
this.searchForm.patchValue({
|
||||
title: book.metadata?.title || '',
|
||||
author: book.metadata?.authors && book.metadata?.authors.length > 0 ? book.metadata?.authors[0] : ''
|
||||
@@ -70,7 +78,7 @@ export class CoverSearchComponent implements OnInit {
|
||||
const request: CoverFetchRequest = {
|
||||
title: this.searchForm.value.title,
|
||||
author: this.searchForm.value.author,
|
||||
squareCover: this.isAudiobook
|
||||
coverType: this.coverType
|
||||
};
|
||||
|
||||
this.bookCoverService.fetchBookCovers(request)
|
||||
@@ -95,24 +103,27 @@ export class CoverSearchComponent implements OnInit {
|
||||
}
|
||||
|
||||
selectAndSave(image: CoverImage) {
|
||||
this.bookService.uploadCoverFromUrl(this.bookId, image.url)
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Cover Updated',
|
||||
detail: 'Cover image updated successfully.'
|
||||
});
|
||||
this.dynamicDialogRef.close();
|
||||
},
|
||||
error: err => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Cover Update Failed',
|
||||
detail: err?.message || 'Failed to update cover image.'
|
||||
});
|
||||
}
|
||||
});
|
||||
const uploadObservable = this.coverType === 'audiobook'
|
||||
? this.bookService.uploadAudiobookCoverFromUrl(this.bookId, image.url)
|
||||
: this.bookService.uploadCoverFromUrl(this.bookId, image.url);
|
||||
|
||||
uploadObservable.subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Cover Updated',
|
||||
detail: `${this.coverType === 'audiobook' ? 'Audiobook' : 'Ebook'} cover image updated successfully.`
|
||||
});
|
||||
this.dynamicDialogRef.close(true);
|
||||
},
|
||||
error: err => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Cover Update Failed',
|
||||
detail: err?.message || 'Failed to update cover image.'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onClear() {
|
||||
|
||||
+11
-3
@@ -35,7 +35,8 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'hardcoverId', 'hardcoverRating', 'hardcoverReviewCount', 'moods', 'tags',
|
||||
'comicvineId',
|
||||
'lubimyczytacId', 'lubimyczytacRating',
|
||||
'ranobedbId', 'ranobedbRating'
|
||||
'ranobedbId', 'ranobedbRating',
|
||||
'audibleId', 'audibleRating', 'audibleReviewCount'
|
||||
];
|
||||
|
||||
providerSpecificFields: (keyof FieldOptions)[] = [
|
||||
@@ -46,6 +47,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'comicvineId',
|
||||
'lubimyczytacId', 'lubimyczytacRating',
|
||||
'ranobedbId', 'ranobedbRating',
|
||||
'audibleId', 'audibleRating', 'audibleReviewCount',
|
||||
];
|
||||
|
||||
nonProviderSpecificFields: (keyof FieldOptions)[] = [
|
||||
@@ -54,8 +56,8 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'language', 'categories', 'cover', 'pageCount',
|
||||
];
|
||||
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb'];
|
||||
providersWithClear: string[] = ['Clear All', 'Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb'];
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb', 'Audible'];
|
||||
providersWithClear: string[] = ['Clear All', 'Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb', 'Audible'];
|
||||
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
@@ -102,6 +104,9 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
// Ranobedb
|
||||
'ranobedbId', 'ranobedbRating',
|
||||
|
||||
// Audible
|
||||
'audibleId', 'audibleRating', 'audibleReviewCount',
|
||||
|
||||
// Generic provider-specific
|
||||
'moods', 'tags'
|
||||
];
|
||||
@@ -274,6 +279,9 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'lubimyczytacRating': 'Lubimyczytac Rating',
|
||||
'ranobedbId': 'Ranobedb ID',
|
||||
'ranobedbRating': 'Ranobedb Rating',
|
||||
'audibleId': 'Audible ID',
|
||||
'audibleRating': 'Audible Rating',
|
||||
'audibleReviewCount': 'Audible Review Count',
|
||||
'moods': 'Moods (Hardcover)',
|
||||
'tags': 'Tags (Hardcover)'
|
||||
};
|
||||
|
||||
+9
-1
@@ -45,6 +45,10 @@ export class MetadataProviderFieldSelectorComponent implements OnInit {
|
||||
{
|
||||
label: 'Ranobedb',
|
||||
fields: ['ranobedbId', 'ranobedbRating']
|
||||
},
|
||||
{
|
||||
label: 'Audible',
|
||||
fields: ['audibleId', 'audibleRating', 'audibleReviewCount']
|
||||
}
|
||||
];
|
||||
|
||||
@@ -65,6 +69,9 @@ export class MetadataProviderFieldSelectorComponent implements OnInit {
|
||||
'lubimyczytacRating': 'Lubimyczytac Rating',
|
||||
'ranobedbId': 'Ranobedb ID',
|
||||
'ranobedbRating': 'Ranobedb Rating',
|
||||
'audibleId': 'Audible ID',
|
||||
'audibleRating': 'Audible Rating',
|
||||
'audibleReviewCount': 'Audible Review Count',
|
||||
};
|
||||
|
||||
private readonly allFieldNames: (keyof MetadataProviderSpecificFields)[] = [
|
||||
@@ -74,7 +81,8 @@ export class MetadataProviderFieldSelectorComponent implements OnInit {
|
||||
'hardcoverId', 'hardcoverBookId', 'hardcoverRating', 'hardcoverReviewCount',
|
||||
'comicvineId',
|
||||
'lubimyczytacId', 'lubimyczytacRating',
|
||||
'ranobedbId', 'ranobedbRating'
|
||||
'ranobedbId', 'ranobedbRating',
|
||||
'audibleId', 'audibleRating', 'audibleReviewCount'
|
||||
];
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
@@ -53,6 +53,9 @@ export interface FieldOptions {
|
||||
lubimyczytacRating: FieldProvider;
|
||||
ranobedbId: FieldProvider;
|
||||
ranobedbRating: FieldProvider;
|
||||
audibleId: FieldProvider;
|
||||
audibleRating: FieldProvider;
|
||||
audibleReviewCount: FieldProvider;
|
||||
moods: FieldProvider;
|
||||
tags: FieldProvider;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user