feat: add button to fetch metadata from book file in metadata editor (#2739)
This commit is contained in:
+23
-1
@@ -161,7 +161,6 @@
|
||||
<p-button [pTooltip]="t('unlockCoverTooltip')" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audiobookCover')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
`
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -967,6 +966,18 @@
|
||||
}
|
||||
|
||||
<div class="actions-right">
|
||||
@if (!book.isPhysical) {
|
||||
<p-button
|
||||
[label]="isFetchingFromFile ? t('fetchingBtn') : t('fetchFromFileBtn')"
|
||||
[icon]="isFetchingFromFile ? 'pi pi-spin pi-spinner' : 'pi pi-file'"
|
||||
[outlined]="true"
|
||||
severity="secondary"
|
||||
(onClick)="fetchFromFile(book.id)"
|
||||
[disabled]="isFetchingFromFile"
|
||||
[pTooltip]="t('fetchFromFileTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
<p-button
|
||||
[label]="isAutoFetching ? t('fetchingBtn') : t('autoFetchBtn')"
|
||||
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
|
||||
@@ -1025,6 +1036,17 @@
|
||||
</div>
|
||||
}
|
||||
<div class="mobile-lock-actions">
|
||||
@if (!book.isPhysical) {
|
||||
<p-button
|
||||
icon="pi pi-file"
|
||||
[outlined]="true"
|
||||
severity="secondary"
|
||||
(onClick)="fetchFromFile(book.id)"
|
||||
[disabled]="isFetchingFromFile"
|
||||
[pTooltip]="t('fetchFromFileBtn')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
<p-button
|
||||
icon="pi pi-bolt"
|
||||
[outlined]="true"
|
||||
|
||||
+26
@@ -90,6 +90,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
|
||||
refreshingBookIds = new Set<number>();
|
||||
isAutoFetching = false;
|
||||
isFetchingFromFile = false;
|
||||
autoSaveEnabled = false;
|
||||
|
||||
originalMetadata!: BookMetadata;
|
||||
@@ -1035,6 +1036,31 @@ export class MetadataEditorComponent implements OnInit {
|
||||
}, 15000);
|
||||
}
|
||||
|
||||
fetchFromFile(bookId: number) {
|
||||
this.isFetchingFromFile = true;
|
||||
this.bookService.getFileMetadata(bookId).pipe(
|
||||
finalize(() => this.isFetchingFromFile = false),
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
).subscribe({
|
||||
next: (metadata) => {
|
||||
this.populateFormFromMetadata(metadata);
|
||||
this.metadataForm.markAsDirty();
|
||||
this.messageService.add({
|
||||
severity: 'info',
|
||||
summary: this.t.translate('metadata.editor.toast.successSummary'),
|
||||
detail: this.t.translate('metadata.editor.toast.fileMetadataLoaded'),
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('metadata.editor.toast.errorSummary'),
|
||||
detail: err?.error?.message || this.t.translate('metadata.editor.toast.fileMetadataFailed'),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onNext() {
|
||||
this.nextBookClicked.emit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user