document.addEventListener("DOMContentLoaded", function () { function color(heat) { if (heat < 30) return "#2ecc71"; if (heat < 60) return "#f1c40f"; if (heat < 80) return "#e67e22"; return "#e74c3c"; } document.getElementById("load").addEventListener("click", function () { cockpit.spawn( ["python3", "/usr/share/cockpit/fester/backend/nodes.py"], { superuser: "require" } ) .then(data => { const parsed = JSON.parse(data); let html = `

Master

${JSON.stringify(parsed.master, null, 2)}

Nodes

`; parsed.nodes.forEach(n => { html += `
${n.name}
state: ${n.state}
heat: ${n.heat}
`; }); document.getElementById("nodes").innerHTML = html; }) .catch(err => { document.getElementById("nodes").textContent = err.toString(); }); }); });