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); });
}
}