makign url upload better

This commit is contained in:
2026-07-14 21:37:26 +02:00
parent b5d688ec0d
commit 1e11426043
2 changed files with 67 additions and 23 deletions

View File

@@ -1497,7 +1497,7 @@
font-size: 0.8rem; font-size: 0.8rem;
opacity: 0; opacity: 0;
transform: translateY(10px); transform: translateY(10px);
transition: opacity 0.28s ease, transform 0.28s ease; transition: opacity 1.5s ease, transform 1.5s ease;
pointer-events: none; pointer-events: none;
} }

View File

@@ -161,10 +161,30 @@ window.escapeHtmlUpload = window.escapeHtmlUpload || ((unsafe) => {
_stopPoll(jobId); _stopPoll(jobId);
_broadcast({ type: 'job_resolved', jobId, notif }); _broadcast({ type: 'job_resolved', jobId, notif });
// Fade row out and remove — no lingering done state const success = notif.type === 'upload_success';
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
if (row) { row.classList.add('uut-job--fading'); setTimeout(() => row.remove(), 300); } if (success) {
setTimeout(() => { _active.delete(jobId); _sync(); }, 350); // Success: fade and remove immediately
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
if (row) { row.classList.add('uut-job--fading'); setTimeout(() => row.remove(), 300); }
setTimeout(() => { _active.delete(jobId); _sync(); }, 350);
} else {
// Failure: update the row to show the error, keep until user closes
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
if (row) {
const errMsg = notif.data?.msg || i18n().url_tracker_failed || 'Upload failed';
const stageEl = row.querySelector('.uut-stage');
if (stageEl) {
stageEl.textContent = errMsg;
stageEl.style.color = '#ff5050';
}
const spinner = row.querySelector('.uut-spinner');
if (spinner) spinner.style.display = 'none';
const barFill = row.querySelector('.uut-bar-fill');
if (barFill) { barFill.style.width = '100%'; barFill.style.background = '#ff5050'; barFill.style.backgroundImage = 'none'; barFill.style.animation = 'none'; }
}
_sync(); // update badge (count stays 0 for resolved jobs)
}
}; };
// ── Public API ──────────────────────────────────────────────────────────── // ── Public API ────────────────────────────────────────────────────────────
@@ -220,9 +240,24 @@ window.escapeHtmlUpload = window.escapeHtmlUpload || ((unsafe) => {
const job = _active.get(data.jobId); const job = _active.get(data.jobId);
if (!job?._remote) break; if (!job?._remote) break;
job.resolved = true; job.resolved = true;
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(data.jobId)}"]`); const n = data.notif || {};
if (row) { row.classList.add('uut-job--fading'); setTimeout(() => row.remove(), 300); } if (n.type === 'upload_success') {
setTimeout(() => { _active.delete(data.jobId); _sync(); }, 350); const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(data.jobId)}"]`);
if (row) { row.classList.add('uut-job--fading'); setTimeout(() => row.remove(), 300); }
setTimeout(() => { _active.delete(data.jobId); _sync(); }, 350);
} else {
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(data.jobId)}"]`);
if (row) {
const errMsg = n.data?.msg || i18n().url_tracker_failed || 'Upload failed';
const stageEl = row.querySelector('.uut-stage');
if (stageEl) { stageEl.textContent = errMsg; stageEl.style.color = '#ff5050'; }
const spinner = row.querySelector('.uut-spinner');
if (spinner) spinner.style.display = 'none';
const barFill = row.querySelector('.uut-bar-fill');
if (barFill) { barFill.style.width = '100%'; barFill.style.background = '#ff5050'; barFill.style.backgroundImage = 'none'; barFill.style.animation = 'none'; }
}
_sync();
}
break; break;
} }
} }
@@ -2393,9 +2428,19 @@ window.initUploadForm = (selector) => {
} }
if (successCount > 0) { if (successCount > 0) {
if (dragModal) dragModal.classList.remove('show'); if (lastData?.pending) {
if (window.resetGlobalScrollState) window.resetGlobalScrollState(); // Background URL upload: close modal gently — delay scroll reset
if (window.hideAllModals) window.hideAllModals(); // so queued pointer/keyboard events don't fire on the underlying page
if (dragModal) dragModal.classList.remove('show');
setTimeout(() => {
if (window.resetGlobalScrollState) window.resetGlobalScrollState();
if (window.hideAllModals) window.hideAllModals();
}, 400);
} else {
if (dragModal) dragModal.classList.remove('show');
if (window.resetGlobalScrollState) window.resetGlobalScrollState();
if (window.hideAllModals) window.hideAllModals();
}
form._f0ckUploader.reset(); form._f0ckUploader.reset();
@@ -2408,19 +2453,14 @@ window.initUploadForm = (selector) => {
if (typeof window.flashMessage === 'function') { if (typeof window.flashMessage === 'function') {
window.flashMessage(window.f0ckI18n?.upload_pending_approval_patient || 'Upload awaits approval', 3000, 'warning'); window.flashMessage(window.f0ckI18n?.upload_pending_approval_patient || 'Upload awaits approval', 3000, 'warning');
} }
} else if (lastData?.pending) { } else if (!lastData?.pending && !dragModal && statusDiv) {
// Background URL upload — tracker widget is already showing; just navigate home
/* no additional message needed */
} else if (!dragModal && statusDiv) {
statusDiv.innerHTML = '✓ ' + (lastData?.msg || 'Upload successful'); statusDiv.innerHTML = '✓ ' + (lastData?.msg || 'Upload successful');
statusDiv.className = 'upload-status success'; statusDiv.className = 'upload-status success';
} }
} }
setTimeout(() => { // URL uploads: always stay on current page — tracker panel shows progress
if (typeof window.loadPageAjax === 'function') window.loadPageAjax('/'); // (no redirect here; the file upload path below handles its own redirect)
else window.location.href = '/';
}, dragModal ? 0 : (lastData?.pending ? 0 : 1000));
} else { } else {
restoreBtn(); restoreBtn();
} }
@@ -2591,10 +2631,14 @@ window.initUploadForm = (selector) => {
} }
} }
setTimeout(() => { // Skip redirect if every item was a background URL job
if (typeof window.loadPageAjax === 'function') window.loadPageAjax('/'); const allPending = lastData?.pending && selectedFiles.every(i => i.type === 'url');
else window.location.href = '/'; if (!allPending) {
}, dragModal ? 0 : 1000); setTimeout(() => {
if (typeof window.loadPageAjax === 'function') window.loadPageAjax('/');
else window.location.href = '/';
}, dragModal ? 0 : 1000);
}
} else { } else {
restoreBtn(); restoreBtn();
if (progressContainer) progressContainer.style.display = 'none'; if (progressContainer) progressContainer.style.display = 'none';