Refine bookdrop results and related websocket events

This commit is contained in:
aditya.chandel
2025-08-16 10:18:33 -06:00
committed by Aditya Chandel
parent c75c4dce5b
commit a092d629c9
26 changed files with 288 additions and 120 deletions
@@ -13,7 +13,7 @@
<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"/>
<p-progressSpinner class="w-8 h-8" strokeWidth="4"/>
<span class="text-gray-300">Loading Bookdrop files. Please wait...</span>
</div>
</div>
@@ -23,7 +23,7 @@
<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"/>
<p-progressSpinner class="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...
@@ -246,7 +246,6 @@
}
</div>
<!-- Center container: paginator, flex-grow and centered -->
<div class="flex-grow flex justify-center">
<p-paginator
[rows]="pageSize"
@@ -258,7 +257,6 @@
</p-paginator>
</div>
<!-- Right container: fixed width, right aligned -->
<div class="flex gap-4 items-center min-w-[200px] justify-end">
<p-button
[label]="'Delete ' + selectedCount + ' File' + (selectedCount !== 1 ? 's' : '')"
@@ -116,7 +116,7 @@ export class BookdropFileReviewComponent implements OnInit {
const selected = this.libraries.find((lib) => lib?.id && String(lib.id) === value)
if (selected && selected.paths.length ===1) {
if (selected && selected.paths.length === 1) {
this.defaultPathId = String(selected.paths[0].id)
}
}
@@ -458,7 +458,7 @@ export class BookdropFileReviewComponent implements OnInit {
modal: true,
closable: true,
closeOnEscape: true,
data: {results: result.results},
data: {result: result},
});
const finalizedIds = new Set(files.map(f => f.fileId));
@@ -42,6 +42,10 @@ export interface BookdropFileResult {
}
export interface BookdropFinalizeResult {
totalFiles: number;
successfullyImported: number;
failed: number;
processedAt: string;
results: BookdropFileResult[];
}
@@ -1,26 +1,53 @@
<ul class="space-y-3">
@for (result of results; track result) {
<li
class="flex items-start gap-3 p-3 rounded-xl border shadow-sm transition-colors"
[ngClass]="{
'bg-green-800/10 border-green-500/40 text-green-100': result.success,
'bg-red-800/10 border-red-500/40 text-red-100': !result.success
}"
>
<i
class="pi text-xl mt-1"
[ngClass]="{
'pi-check-circle text-green-500': result.success,
'pi-times-circle text-red-500': !result.success
}"
></i>
<div class="flex flex-col">
<span class="font-medium text-sm text-white">
{{ result.fileName }}
</span>
<span class="text-sm text-gray-400">{{ result.message }}</span>
<div class="max-w-3xl mx-auto">
<div class="mb-8">
<div class="p-6 bg-zinc-800/50 rounded-xl border border-zinc-500">
<div class="grid grid-cols-3 gap-6 mb-6">
<div class="text-center p-4 bg-zinc-700/30 rounded-lg">
<div class="text-3xl font-bold text-blue-400 mb-1">{{ result.totalFiles }}</div>
<div class="text-sm text-gray-400 font-medium">Total Files</div>
</div>
<div class="text-center p-4 bg-zinc-700/30 rounded-lg">
<div class="text-3xl font-bold text-green-400 mb-1">{{ result.successfullyImported }}</div>
<div class="text-sm text-gray-400 font-medium">Successfully Imported</div>
</div>
<div class="text-center p-4 bg-zinc-700/30 rounded-lg">
<div class="text-3xl font-bold text-red-400 mb-1">{{ result.failed }}</div>
<div class="text-sm text-gray-400 font-medium">Failed</div>
</div>
</div>
</li>
}
</ul>
<div class="text-center pt-4 border-t border-zinc-600">
<div class="text-sm text-gray-300 mb-1">Processed at</div>
<div class="text-base text-white font-mono">{{ result.processedAt | date:'medium' }}</div>
</div>
</div>
</div>
<div class="max-h-[35rem] overflow-y-scroll">
<ul class="space-y-3 px-4">
@for (r of result.results; track r) {
<li
class="flex items-start gap-3 p-3 rounded-xl border shadow-sm transition-colors"
[ngClass]="{
'bg-green-800/10 border-green-500/40 text-green-100': r.success,
'bg-red-800/10 border-red-500/40 text-red-100': !r.success
}"
>
<i
class="pi text-xl mt-1"
[ngClass]="{
'pi-check-circle text-green-500': r.success,
'pi-times-circle text-red-500': !r.success
}"
></i>
<div class="flex flex-col">
<span class="font-medium text-sm text-white">
{{ r.fileName }}
</span>
<span class="text-sm text-gray-400">{{ r.message }}</span>
</div>
</li>
}
</ul>
</div>
</div>
@@ -1,22 +1,23 @@
import {Component, OnDestroy} from '@angular/core';
import {NgClass} from '@angular/common';
import {BookdropFileResult} from '../bookdrop-file-task.service';
import {DatePipe, NgClass} from '@angular/common';
import {BookdropFinalizeResult} from '../bookdrop-file-task.service';
import {DynamicDialogConfig, DynamicDialogRef} from "primeng/dynamicdialog";
@Component({
selector: 'app-bookdrop-finalize-result-dialog-component',
imports: [
NgClass
NgClass,
DatePipe
],
templateUrl: './bookdrop-finalize-result-dialog-component.html',
styleUrl: './bookdrop-finalize-result-dialog-component.scss'
})
export class BookdropFinalizeResultDialogComponent implements OnDestroy {
results: BookdropFileResult[] = [];
result: BookdropFinalizeResult;
constructor(public ref: DynamicDialogRef, public config: DynamicDialogConfig) {
this.results = config.data.results;
this.result = config.data.result;
}
ngOnDestroy(): void {
@@ -20,10 +20,10 @@
@if (permissions.admin || permissions.canManipulateLibrary) {
<div>
<h1 class="no-library-header">
Welcome to BookLore! 📚<br>
Welcome to BookLore!<br>
Let's create your first library
</h1>
<p class="text-gray-300 text-lg mb-8 max-w-md mx-auto leading-relaxed">
<p class="text-gray-300 mb-8 mx-auto leading-relaxed">
A library is where all your books live. Start building your digital collection today!
</p>
<p-button
@@ -47,7 +47,7 @@
}
.dashboard .no-library-header {
font-size: 2rem;
font-size: 1.75rem;
font-weight: 700;
margin-bottom: 2rem;
background: linear-gradient(135deg, #ffffff, #e2e8f0, var(--p-primary-500));