29 lines
890 B
JavaScript
29 lines
890 B
JavaScript
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);
|
|
}
|