Files
byre/web/index.html
T

43 lines
1.3 KiB
HTML
Raw Normal View History

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>byre</title>
<style>
body { font: 14px/1.4 -apple-system, system-ui, sans-serif; margin: 2rem; color: #222; }
h1 { margin: 0 0 1rem; }
section { margin-bottom: 1.5rem; }
pre { background: #f4f4f4; padding: .5rem; overflow-x: auto; }
#events div { font-family: ui-monospace, monospace; font-size: 12px; }
</style>
</head>
<body>
<h1>byre</h1>
<section><h2>Me</h2><pre id="me"></pre></section>
<section><h2>Projects</h2><pre id="projects"></pre></section>
<section><h2>Events</h2><div id="events"></div></section>
<script>
async function load(id, path) {
const res = await fetch(path);
document.getElementById(id).textContent = JSON.stringify(await res.json(), null, 2);
}
load("me", "/api/me");
load("projects", "/api/projects");
const events = document.getElementById("events");
const source = new EventSource("/api/events");
source.onmessage = (msg) => {
const ev = JSON.parse(msg.data);
const line = document.createElement("div");
line.textContent = `${ev.seq} ${ev.created_at} ${ev.actor} ${ev.kind} ${JSON.stringify(ev.payload)}`;
events.prepend(line);
if (ev.kind.startsWith("project.")) {
load("projects", "/api/projects");
}
};
</script>
</body>
</html>