Add page description, local timezone display, and auto-refresh

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nxm
2026-05-03 21:11:22 +02:00
parent 8914d2cca8
commit cfbe34a22c
+12 -3
View File
@@ -46,7 +46,7 @@ def read_agent_status(name: str) -> dict:
def render_html(services: list, agents: list) -> str: def render_html(services: list, agents: list) -> str:
now = datetime.now().strftime("%Y-%m-%d %H:%M") now_iso = datetime.now(timezone.utc).isoformat()
SERVICE_COLOURS = {"up": "#3fb950", "degraded": "#d29922", "down": "#f85149"} SERVICE_COLOURS = {"up": "#3fb950", "degraded": "#d29922", "down": "#f85149"}
AGENT_COLOURS = {"success": "#3fb950", "failure": "#f85149"} AGENT_COLOURS = {"success": "#3fb950", "failure": "#f85149"}
@@ -67,7 +67,8 @@ def render_html(services: list, agents: list) -> str:
agent_rows = "" agent_rows = ""
for a in agents: for a in agents:
colour = AGENT_COLOURS.get(a["status"], "#8b949e") colour = AGENT_COLOURS.get(a["status"], "#8b949e")
ts = a["timestamp"][:16].replace("T", " ") + " UTC" if a["timestamp"] else "" raw_ts = a["timestamp"]
ts = f'<span data-utc="{raw_ts}"></span>' if raw_ts else ""
agent_rows += f""" agent_rows += f"""
<tr> <tr>
<td><span class="dot" style="background:{colour}"></span>{a['name']}</td> <td><span class="dot" style="background:{colour}"></span>{a['name']}</td>
@@ -81,12 +82,14 @@ def render_html(services: list, agents: list) -> str:
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="refresh" content="900">
<title>Varys — Status</title> <title>Varys — Status</title>
<style> <style>
* {{ box-sizing: border-box; margin: 0; padding: 0; }} * {{ box-sizing: border-box; margin: 0; padding: 0; }}
body {{ font-family: monospace; background: #0d1117; color: #c9d1d9; padding: 2rem; }} body {{ font-family: monospace; background: #0d1117; color: #c9d1d9; padding: 2rem; }}
h1 {{ color: #58a6ff; margin-bottom: 0.25rem; }} h1 {{ color: #58a6ff; margin-bottom: 0.25rem; }}
h2 {{ color: #8b949e; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin: 2rem 0 0.75rem; }} h2 {{ color: #8b949e; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin: 2rem 0 0.75rem; }}
.desc {{ color: #8b949e; font-size: 0.9rem; margin: 0.4rem 0 0.25rem; }}
.meta {{ color: #8b949e; font-size: 0.85rem; margin-bottom: 2rem; }} .meta {{ color: #8b949e; font-size: 0.85rem; margin-bottom: 2rem; }}
.meta a {{ color: #8b949e; }} .meta a {{ color: #8b949e; }}
.dot {{ display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }} .dot {{ display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }}
@@ -101,11 +104,17 @@ def render_html(services: list, agents: list) -> str:
</head> </head>
<body> <body>
<h1>Varys — Status</h1> <h1>Varys — Status</h1>
<p class="meta">Updated {now} &nbsp;·&nbsp; <a href="/">← home</a></p> <p class="desc">Checks HTTP reachability for all services in the NxM stack and monitors agent run status. Refreshes every 15 minutes.</p>
<p class="meta">Updated <span data-utc="{now_iso}"></span> &nbsp;·&nbsp; <a href="/">← home</a></p>
<h2>Services</h2> <h2>Services</h2>
{service_cards} {service_cards}
<h2>Agents</h2> <h2>Agents</h2>
<table><tbody>{agent_rows}</tbody></table> <table><tbody>{agent_rows}</tbody></table>
<script>
document.querySelectorAll('[data-utc]').forEach(el => {{
el.textContent = new Date(el.dataset.utc).toLocaleString(undefined, {{year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit'}});
}});
</script>
</body> </body>
</html>""" </html>"""