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.
This commit is contained in:
parent
6a9e20da19
commit
48bf0cf050
@ -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); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user