diff --git a/apps/dashboard/assets/js/renderers/immich.js b/apps/dashboard/assets/js/renderers/immich.js new file mode 100644 index 0000000..d4120b1 --- /dev/null +++ b/apps/dashboard/assets/js/renderers/immich.js @@ -0,0 +1,28 @@ +export function renderImmich(state) { + const d = state.immich || {}; + const online = d.source_status === "online"; + + const pill = document.getElementById("immich-pill"); + if (pill) { + pill.textContent = online ? "ONLINE" : "OFFLINE"; + pill.className = "status-pill " + (online ? "pill-online" : "pill-offline"); + } + + const set = (id, val) => { const el = document.getElementById(id); if (el) el.textContent = val; }; + + if (online) { + set("immich-photos", fmtNum(d.photos ?? 0)); + set("immich-videos", fmtNum(d.videos ?? 0)); + set("immich-storage", `${(d.storage_gb ?? 0).toFixed(1)} GB`); + } else { + set("immich-photos", "—"); + set("immich-videos", "—"); + set("immich-storage", "—"); + } +} + +function fmtNum(n) { + if (n >= 1_000_000) return (n / 1_000_000).toFixed(1) + "M"; + if (n >= 1_000) return (n / 1_000).toFixed(1) + "K"; + return String(n); +}