From 48bf0cf050ca006cbe8404e2e0b0e13e539b3738 Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Sun, 3 May 2026 12:27:24 +0200 Subject: [PATCH] UI: Nextcloud gumb \u2014 optimistic feedback. Takoj ob kliku gumb postane oran\u017een "\u23f3 Po\u0161iljam...", disabled, cursor:wait. Po uspe\u0161nem upload-u refreshJobs() zamenja v zelen \u2713 Nextcloud. Pri napaki vrne original state. --- templates/index.html | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/templates/index.html b/templates/index.html index f251cb7..1cb1d75 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1236,18 +1236,30 @@ }); async function uploadToNextcloud(id, title) { + // Optimistic UI: takoj zamrzni vse Nextcloud gumbe za ta job in pokazi "Posiljam..." + const btns = document.querySelectorAll(`button[data-action="nextcloud"][data-id="${id}"]`); + const orig = []; + btns.forEach(b => { + orig.push({ btn: b, html: b.innerHTML, disabled: b.disabled, style: b.getAttribute("style") || "" }); + b.disabled = true; + b.innerHTML = '⏳ Pošiljam...'; + b.setAttribute("style", "border-color:#f59e0b; color:#f59e0b; opacity:0.85; cursor:wait;"); + }); try { const r = await fetch(`/api/jobs/${id}/upload-nextcloud`, { method: "POST" }); if (!r.ok) { const err = await r.json().catch(() => ({})); alert("❌ Napaka: " + (err.detail || r.status)); + // Vrni original state pri napaki + orig.forEach(o => { o.btn.disabled = o.disabled; o.btn.innerHTML = o.html; o.btn.setAttribute("style", o.style); }); return; } - const data = await r.json(); - // Status will update via SSE / refresh - refreshJobs(); + await r.json(); + // refreshJobs() bo zamenjal gumb v zelen ✓ + await refreshJobs(); } catch (e) { alert("❌ Napaka: " + e.message); + orig.forEach(o => { o.btn.disabled = o.disabled; o.btn.innerHTML = o.html; o.btn.setAttribute("style", o.style); }); } }