From 2fcc4b8075628e10edef992db81335f0df2c6614 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 3 May 2026 12:48:31 +0000 Subject: [PATCH] Dashboard: TV station filter tabs nad jobs-list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Tabi: Vse / FOLX SLOVENIJA / FOLX DE / ONE DE / ZWEI MUSIC / ADRIA / (brez postaje) - Števec na vsakem tabu = število NEPOTRJENIH jobov (!hidden_after_upload) za to postajo - Klik na tab = filter samo tisti station, samo nepotrjeni - 'Vse' = vsi nepotrjeni (kot do zdaj) - '(brez postaje)' tab se skrije, če ni jobov brez postaje - Persist v localStorage (reels_jobs_station_filter) - Iskanje IGNORIRA station filter (vrne tudi naložene + vse postaje) - Empty state sporočilo prilagojeno glede na izbran filter --- templates/index.html | 103 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 98 insertions(+), 5 deletions(-) diff --git a/templates/index.html b/templates/index.html index 1cb1d75..2fece35 100644 --- a/templates/index.html +++ b/templates/index.html @@ -420,6 +420,30 @@ + +
+ + + + + + + +
Še ni obdelav
@@ -1074,17 +1098,30 @@ const list = $("#jobs-list"); const showUploaded = $("#show-uploaded") && $("#show-uploaded").checked; const searchQuery = ($("#jobs-search") && $("#jobs-search").value) || ""; - // Filtriraj: če iskanje aktivno → ignore hidden_after_upload (iskanje vidi vse) + const stationFilter = (window._stationFilter !== undefined ? window._stationFilter : ""); + + // 1) Posodobi števce ob tabih — samo ne-potrjeni (!hidden_after_upload) joby + updateStationCounts(data.jobs); + + // 2) Filtriraj za prikaz const visible = data.jobs.filter(j => { + // Iskanje IGNORIRA hidden filter (vrne tudi naložene), TUDI station filter if (searchQuery.trim()) return jobMatchesSearch(j, searchQuery); - return showUploaded || !j.hidden_after_upload; + // Sicer: skrij potrjene (razen če je showUploaded) + if (!showUploaded && j.hidden_after_upload) return false; + // Station filter: prazen string = "Vse", drugače uskladi + if (stationFilter === "") return true; + if (stationFilter === "__none__") return !j.tv_station; + return (j.tv_station || "") === stationFilter; }); if (!visible.length) { list.innerHTML = searchQuery.trim() ? `
Ni zadetkov za "${escapeHtml(searchQuery)}"
` - : (showUploaded - ? '
Še ni obdelav
' - : '
Vse obdelano in naloženo. Klikni "Pokaži tudi že naložene" če želiš popraviti.
'); + : (stationFilter + ? `
Ni nepotrjenih reelov za ${escapeHtml(stationFilter === "__none__" ? "(brez postaje)" : stationFilter)}.
` + : (showUploaded + ? '
Še ni obdelav
' + : '
Vse obdelano in naloženo. Klikni "Pokaži tudi že naložene" če želiš popraviti.
')); return; } list.innerHTML = ""; @@ -1096,6 +1133,30 @@ } }); } + + // Posodobi števce ob station-filter tabih. + // Šteje samo še-ne-potrjene jobe (!hidden_after_upload). + function updateStationCounts(jobs) { + const tabs = $("#station-filter-tabs"); + if (!tabs) return; + const pending = jobs.filter(j => !j.hidden_after_upload); + const counts = {}; + pending.forEach(j => { + const k = j.tv_station || "__none__"; + counts[k] = (counts[k] || 0) + 1; + }); + // Vse + const allEl = tabs.querySelector("[data-cnt-all]"); + if (allEl) allEl.textContent = pending.length; + // Posamezne postaje + tabs.querySelectorAll("[data-cnt]").forEach(el => { + const key = el.dataset.cnt; + el.textContent = counts[key] || 0; + }); + // Skrij/show "(brez postaje)" tab — samo če imamo kakšen brez postaje + const noneTab = tabs.querySelector('[data-station="__none__"]'); + if (noneTab) noneTab.style.display = (counts["__none__"] || 0) > 0 ? "" : "none"; + } // Toggle pokaži/skrij že naložene + iskalnik document.addEventListener("DOMContentLoaded", () => { @@ -1109,6 +1170,38 @@ searchTimer = setTimeout(refreshJobs, 150); }); } + // Station filter tabs + const stationTabs = $$(".station-filter-tab"); + // Restore from localStorage + try { + const saved = localStorage.getItem("reels_jobs_station_filter"); + if (saved !== null) window._stationFilter = saved; + } catch (e) {} + // Apply visual active state + stationTabs.forEach(t => { + const isActive = (t.dataset.station || "") === (window._stationFilter || ""); + t.classList.toggle("active", isActive); + t.style.borderColor = isActive ? "var(--accent)" : "#444"; + t.style.background = isActive ? "var(--accent)" : "transparent"; + t.style.color = isActive ? "#fff" : (t.dataset.station === "__none__" ? "#888" : "#ccc"); + }); + // Click handler + stationTabs.forEach(tab => { + tab.addEventListener("click", () => { + const station = tab.dataset.station || ""; + window._stationFilter = station; + try { localStorage.setItem("reels_jobs_station_filter", station); } catch(e) {} + // Vizualno označi + stationTabs.forEach(t => { + const active = t === tab; + t.classList.toggle("active", active); + t.style.borderColor = active ? "var(--accent)" : "#444"; + t.style.background = active ? "var(--accent)" : "transparent"; + t.style.color = active ? "#fff" : (t.dataset.station === "__none__" ? "#888" : "#ccc"); + }); + refreshJobs(); + }); + }); }); function updateJobInList(job) {