Nextcloud upload za FOLX SLOVENIJA reels
User wants reels saved directly to Nextcloud /folxspeed/REELS/FOLX SLOVENIJA/
NEW backend endpoint: POST /api/jobs/{id}/upload-nextcloud
- WebDAV PUT preko stdlib urllib (no new deps)
- Uses NEXTCLOUD_URL/USER/PASS/REELS_PATH env vars
- Updates job status: uploading → uploaded / error
- Stores nextcloud_url + nextcloud_error in job
Frontend already had button (☁ Nextcloud) and handler — just needed
backend endpoint. UI states:
- ☁ Nextcloud (blue) — not yet uploaded
- ☁ ✓ Nextcloud (green) — uploaded successfully
- ☁ ✕ Poskusi znova (red) — upload failed (hover for error)
Env vars added in Coolify:
- NEXTCLOUD_URL=https://nextcloud.folx.tv
- NEXTCLOUD_USER=admin
- NEXTCLOUD_PASS=<app token>
- NEXTCLOUD_REELS_PATH=folxspeed/REELS/FOLX SLOVENIJA
This commit is contained in:
@@ -925,6 +925,17 @@
|
||||
actions.push(`<button class="small" data-action="download" data-id="${job.id}">⬇ Download</button>`);
|
||||
actions.push(`<button class="small ghost" data-action="preview" data-id="${job.id}">▶ Preview</button>`);
|
||||
actions.push(`<button class="small ghost" data-action="edit" data-id="${job.id}">✏️ Edit</button>`);
|
||||
// Nextcloud upload — različni stanja:
|
||||
const nc = job.nextcloud_status;
|
||||
if (nc === "uploaded") {
|
||||
actions.push(`<button class="small ghost" data-action="nextcloud" data-id="${job.id}" title="Že naloženo — klikni da naložiš ponovno" style="border-color:#4ade80; color:#4ade80;">☁ ✓ Nextcloud</button>`);
|
||||
} else if (nc === "uploading") {
|
||||
actions.push(`<button class="small ghost" disabled title="Nalagam...">☁ ⏳ Nalagam...</button>`);
|
||||
} else if (nc === "failed") {
|
||||
actions.push(`<button class="small ghost" data-action="nextcloud" data-id="${job.id}" title="Napaka: ${escapeHtml(job.nextcloud_error || '')}" style="border-color:#ef4444; color:#ef4444;">☁ ✕ Poskusi znova</button>`);
|
||||
} else {
|
||||
actions.push(`<button class="small ghost" data-action="nextcloud" data-id="${job.id}" title="Naloži v Nextcloud /folxspeed/REELS/" style="border-color:#3b82f6; color:#3b82f6;">☁ Nextcloud</button>`);
|
||||
}
|
||||
}
|
||||
actions.push(`<button class="small ghost" data-action="delete" data-id="${job.id}">✕</button>`);
|
||||
|
||||
@@ -975,11 +986,29 @@
|
||||
previewJob(id, title);
|
||||
} else if (action === "edit") {
|
||||
openEditModal(id, title);
|
||||
} else if (action === "nextcloud") {
|
||||
uploadToNextcloud(id, title);
|
||||
} else if (action === "delete") {
|
||||
deleteJob(id);
|
||||
}
|
||||
});
|
||||
|
||||
async function uploadToNextcloud(id, title) {
|
||||
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));
|
||||
return;
|
||||
}
|
||||
const data = await r.json();
|
||||
// Status will update via SSE / refresh
|
||||
refreshJobs();
|
||||
} catch (e) {
|
||||
alert("❌ Napaka: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteJob(id) {
|
||||
if (!confirm("Izbrišem ta job?")) return;
|
||||
await fetch(`/api/jobs/${id}`, { method: "DELETE" });
|
||||
|
||||
Reference in New Issue
Block a user