Implement Bookdrop: Watch folder for file drops and auto-process uploads
This commit is contained in:
committed by
Aditya Chandel
parent
5064706b8f
commit
177528e640
+270
@@ -0,0 +1,270 @@
|
||||
<div class="flex flex-col h-[calc(100vh-6.1rem)] rounded-xl bg-[var(--card-background)] space-y-4">
|
||||
|
||||
<div class="px-6 pt-6 pb-4">
|
||||
<h2 class="text-xl font-semibold pb-1">Review Bookdrop Files</h2>
|
||||
<p class="text-sm text-gray-400">
|
||||
These files were uploaded to the
|
||||
<strong class="text-[var(--primary-color)]">Bookdrop Folder</strong>.
|
||||
Review their fetched metadata, assign a library and subpath, and finalize where they belong in your collection.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@if (loading) {
|
||||
<div class="absolute inset-0 flex items-center justify-center z-50 rounded-xl">
|
||||
<div class="flex flex-col items-center space-y-3">
|
||||
<p-progressSpinner styleClass="w-8 h-8" strokeWidth="4"/>
|
||||
<span class="text-gray-300">
|
||||
Loading Bookdrop files. Please wait...
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="px-6 pb-2">
|
||||
@if (saving) {
|
||||
<div class="absolute inset-0 bg-black bg-opacity-50 flex flex-col items-center justify-center z-50 rounded-xl space-y-3">
|
||||
<p-progressSpinner styleClass="w-8 h-8" strokeWidth="4"/>
|
||||
<div class="bg-gray-900/90 px-4 py-2 rounded-md">
|
||||
<span class="text-sm text-gray-200 text-center">
|
||||
Organizing and moving files to their designated libraries. Please wait...
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (bookdropFileUis.length !== 0) {
|
||||
<div class="flex gap-2 items-center px-1 pb-4 w-full">
|
||||
<label for="uploadPatternInput" class="text-sm text-gray-300 font-medium">File Naming Pattern:</label>
|
||||
<input
|
||||
id="uploadPatternInput"
|
||||
fluid
|
||||
class="min-w-[20rem] max-w-[45.5rem]"
|
||||
pSize="small"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="uploadPattern"
|
||||
placeholder="e.g., {title} - {authors}"
|
||||
/>
|
||||
<i
|
||||
class="pi pi-info-circle text-blue-500 cursor-help"
|
||||
pTooltip="Sets the filename pattern used when moving files from bookdrop folder to the library, using metadata placeholders like {title}, {authors}, etc."
|
||||
tooltipPosition="top"
|
||||
style="font-size: 1rem; margin-left: 0.25rem;"
|
||||
></i>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between items-center gap-4 px-1">
|
||||
<div class="flex gap-4 items-center">
|
||||
<span class="text-sm text-gray-300 font-medium">Library for All Files:</span>
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="libraryOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Select Default Library"
|
||||
class="min-w-[8rem] max-w-[16rem]"
|
||||
[(ngModel)]="defaultLibraryId">
|
||||
</p-select>
|
||||
|
||||
<span class="text-sm text-gray-300 font-medium">Subpath for All Files:</span>
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="selectedLibraryPaths"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Select Default Subpath"
|
||||
class="min-w-[8rem] max-w-[16rem]"
|
||||
[(ngModel)]="defaultPathId">
|
||||
</p-select>
|
||||
|
||||
<p-button
|
||||
size="small"
|
||||
label="Apply to All"
|
||||
icon="pi pi-check"
|
||||
[disabled]="!canApplyDefaults"
|
||||
(click)="applyDefaultsToAll()"
|
||||
pTooltip="Apply selected library and subpath to all files"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-4">
|
||||
<p-button
|
||||
size="small"
|
||||
outlined
|
||||
severity="info"
|
||||
label="Apply (w/ Cover)"
|
||||
icon="pi pi-copy"
|
||||
(click)="copyAll(true)"
|
||||
pTooltip="For all files, replace current metadata with fetched metadata, including cover images"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
size="small"
|
||||
outlined
|
||||
severity="info"
|
||||
label="Apply (no Cover)"
|
||||
icon="pi pi-copy"
|
||||
(click)="copyAll(false)"
|
||||
pTooltip="For all files, replace current metadata with fetched metadata, excluding cover images"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
<p-button
|
||||
size="small"
|
||||
outlined
|
||||
severity="warn"
|
||||
label="Reset"
|
||||
icon="pi pi-refresh"
|
||||
(click)="resetAll()"
|
||||
pTooltip="Reset all metadata changes"
|
||||
tooltipPosition="left">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="flex-1 overflow-y-auto px-6 space-y-2 pb-4">
|
||||
@if (bookdropFileUis.length === 0) {
|
||||
<div class="h-full w-full flex items-center justify-center text-gray-400 italic py-8">
|
||||
No bookdrop files to review.
|
||||
</div>
|
||||
} @else {
|
||||
@for (file of bookdropFileUis; track file) {
|
||||
<div class="flex flex-col">
|
||||
<div class="flex items-center gap-4 custom-border rounded-xl px-4 py-2">
|
||||
|
||||
@if (file.file.fetchedMetadata) {
|
||||
<i
|
||||
class="pi pi-circle-fill"
|
||||
style="color: green; font-size: 0.75rem"
|
||||
pTooltip="Fetched metadata is available."
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
} @else {
|
||||
<i
|
||||
class="pi pi-circle-fill"
|
||||
style="color: darkorange; font-size: 0.75rem"
|
||||
pTooltip="No fetched metadata available."
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
|
||||
@if (file.metadataForm.get('thumbnailUrl')?.value) {
|
||||
<img
|
||||
[src]="file.metadataForm.get('thumbnailUrl')?.value"
|
||||
alt="Cover"
|
||||
title="Original cover"
|
||||
(click)="file.showDetails = !file.showDetails"
|
||||
class="w-6 h-8 flex-shrink-0 rounded-sm object-cover cursor-pointer transition-transform duration-200 hover:scale-105 hover:shadow-md"
|
||||
/>
|
||||
}
|
||||
|
||||
@if (file.file.fetchedMetadata?.thumbnailUrl) {
|
||||
<img
|
||||
[src]="file.file.fetchedMetadata?.thumbnailUrl"
|
||||
alt="Cover"
|
||||
title="Fetched cover"
|
||||
(click)="file.showDetails = !file.showDetails"
|
||||
class="w-6 h-8 flex-shrink-0 rounded-sm object-cover cursor-pointer transition-transform duration-200 hover:scale-105 hover:shadow-md"
|
||||
/>
|
||||
}
|
||||
|
||||
<div class="flex-1 font-medium text-sm truncate" (click)="file.showDetails = !file.showDetails">
|
||||
{{ file.file.fileName }}
|
||||
</div>
|
||||
|
||||
@if (copiedFlags[file.file.id]) {
|
||||
<i
|
||||
class="pi pi-check-circle text-green-500"
|
||||
pTooltip="Fetched metadata has been applied."
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
} @else if (!file.file.fetchedMetadata) {
|
||||
<i
|
||||
class="pi pi-check-circle text-blue-500"
|
||||
pTooltip="No fetched metadata available. Original metadata will used."
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
} @else {
|
||||
<i
|
||||
class="pi pi-exclamation-triangle text-red-500"
|
||||
pTooltip="Fetched metadata hasn’t been applied yet. You can open the metadata picker using the dropdown on the right, or skip and keep the original metadata."
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="libraryOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Select Library"
|
||||
class="min-w-[8rem] max-w-[16rem]"
|
||||
[(ngModel)]="file.selectedLibraryId"
|
||||
(onChange)="onLibraryChange(file)">
|
||||
</p-select>
|
||||
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="file.availablePaths"
|
||||
optionLabel="name"
|
||||
optionValue="id"
|
||||
placeholder="Select Subpath"
|
||||
class="min-w-[8rem] max-w-[16rem]"
|
||||
appendTo="body"
|
||||
[(ngModel)]="file.selectedPathId">
|
||||
</p-select>
|
||||
|
||||
<p-button
|
||||
size="small"
|
||||
[icon]="file.showDetails ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
|
||||
(click)="file.showDetails = !file.showDetails"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
|
||||
@if (file.showDetails) {
|
||||
<app-bookdrop-file-metadata-picker-component
|
||||
class="px-12 py-8 custom-border1"
|
||||
style="transition: opacity 0.3s ease"
|
||||
#metadataPicker
|
||||
[originalMetadata]="file.file.originalMetadata"
|
||||
[fetchedMetadata]="file.file.fetchedMetadata!"
|
||||
[metadataForm]="file.metadataForm"
|
||||
[copiedFields]="file.copiedFields"
|
||||
[savedFields]="file.savedFields"
|
||||
[bookdropFileId]="file.file.id"
|
||||
(metadataCopied)="onMetadataCopied(file.file.id, $event)">
|
||||
</app-bookdrop-file-metadata-picker-component>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<p-divider></p-divider>
|
||||
<div class="pb-4 px-6 gap-4 flex justify-end">
|
||||
@if (bookdropFileUis.length !== 0) {
|
||||
<p-button
|
||||
label="Delete Files"
|
||||
icon="pi pi-times"
|
||||
severity="danger"
|
||||
outlined
|
||||
pTooltip="Permanently delete all Bookdrop files and discard any changes"
|
||||
tooltipPosition="top"
|
||||
(click)="confirmDelete()">
|
||||
</p-button>
|
||||
}
|
||||
|
||||
<p-button
|
||||
[label]="saving ? 'Finalize Imports...' : 'Finalize Imports'"
|
||||
[icon]="saving ? 'pi pi-spin pi-spinner' : 'pi pi-save'"
|
||||
severity="success"
|
||||
outlined
|
||||
pTooltip="This will move all staged files into the selected library and subpath."
|
||||
(click)="confirmFinalize()"
|
||||
[disabled]="!canFinalize || saving">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
Reference in New Issue
Block a user