-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
249 lines (218 loc) · 11.6 KB
/
dashboard.html
File metadata and controls
249 lines (218 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>00zeven ops</title>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@400;500;600&display=swap" rel="stylesheet">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #060810; color: #c8ccd4; font-family: 'Space Grotesk', sans-serif; padding: 24px; max-width: 1200px; margin: 0 auto; }
.mono { font-family: 'JetBrains Mono', monospace; }
a { color: #c9a227; text-decoration: none; }
a:hover { text-decoration: underline; }
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; flex-wrap: wrap; gap: 16px; }
header h1 { font-size: 24px; color: #eceef1; font-weight: 700; }
header h1 span { color: #8b5cf6; }
.status { font-family: 'JetBrains Mono', monospace; font-size: 12px; padding: 4px 12px; border-radius: 12px; }
.status-live { background: #22c55e22; color: #22c55e; }
.status-stale { background: #f5920022; color: #f59200; }
.status-error { background: #ef444422; color: #ef4444; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric { background: #0c0f17; border: 1px solid #181e2a; border-radius: 12px; padding: 16px 20px; }
.metric-value { font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 700; color: #eceef1; }
.metric-label { font-size: 11px; color: #6b7385; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.08em; }
.section-label { font-size: 11px; color: #6b7385; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 12px; margin-top: 24px; font-family: 'JetBrains Mono', monospace; }
.panel { background: #0c0f17; border: 1px solid #181e2a; border-radius: 12px; margin-bottom: 16px; overflow: hidden; }
.panel-header { padding: 14px 20px; border-bottom: 1px solid #181e2a; display: flex; justify-content: space-between; align-items: center; }
.panel-title { font-size: 13px; font-weight: 600; color: #eceef1; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 8px 20px; font-size: 10px; color: #6b7385; text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid #181e2a; font-family: 'JetBrains Mono', monospace; }
td { padding: 10px 20px; font-size: 13px; border-bottom: 1px solid #0e1219; }
tr:hover { background: #0e1219; }
.badge { font-family: 'JetBrains Mono', monospace; font-size: 10px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.badge-agent { background: #8b5cf622; color: #8b5cf6; }
.badge-gov { background: #4a9e9322; color: #4a9e93; }
.badge-life { background: #c9a22722; color: #c9a227; }
.badge-ok { background: #22c55e22; color: #22c55e; }
.badge-warn { background: #f5920022; color: #f59200; }
.badge-err { background: #ef444422; color: #ef4444; }
.hash { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #6b7385; }
.time { font-size: 11px; color: #6b7385; }
.miner-card { background: #0c0f17; border: 1px solid #181e2a; border-radius: 12px; padding: 16px 20px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.miner-name { font-family: 'JetBrains Mono', monospace; font-size: 14px; color: #eceef1; font-weight: 600; }
.miner-stat { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #6b7385; }
.miner-stat b { color: #eceef1; font-weight: 600; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }
.empty { padding: 32px; text-align: center; color: #3e4556; font-size: 12px; font-family: 'JetBrains Mono', monospace; }
footer { text-align: center; padding: 24px; color: #3e4556; font-size: 11px; margin-top: 32px; border-top: 1px solid #181e2a; }
</style>
</head>
<body>
<header>
<h1>00<span>zeven</span> ops</h1>
<div style="display: flex; align-items: center; gap: 12px;">
<span class="time" id="last-refresh">-</span>
<span class="status status-live" id="status">connecting...</span>
</div>
</header>
<!-- Agent metrics -->
<div class="grid" id="metrics">
<div class="metric"><div class="metric-value" id="m-actions">-</div><div class="metric-label">Agent actions</div></div>
<div class="metric"><div class="metric-value" id="m-miners">-</div><div class="metric-label">Miners</div></div>
<div class="metric"><div class="metric-value" id="m-hashrate">-</div><div class="metric-label">Hashrate</div></div>
<div class="metric"><div class="metric-value" id="m-leaves">-</div><div class="metric-label">Total events</div></div>
<div class="metric"><div class="metric-value" id="m-anchors">-</div><div class="metric-label">Anchors</div></div>
<div class="metric"><div class="metric-value" id="m-unanchored">-</div><div class="metric-label">Unanchored</div></div>
</div>
<!-- Miners -->
<div class="section-label">Fleet</div>
<div id="miners-panel">
<div class="empty">Polling Foreman...</div>
</div>
<!-- Two column: Agent actions + Protocol events -->
<div class="two-col">
<div>
<div class="section-label">Agent actions</div>
<div class="panel">
<div class="panel-header">
<span class="panel-title">00zeven-alpha</span>
<span class="badge badge-agent" id="agent-status">-</span>
</div>
<table>
<thead><tr><th>Action</th><th>Leaf</th><th>Time</th></tr></thead>
<tbody id="agent-body"><tr><td colspan="3" class="empty">Loading...</td></tr></tbody>
</table>
</div>
</div>
<div>
<div class="section-label">Recent attestations</div>
<div class="panel">
<div class="panel-header">
<span class="panel-title">All event types</span>
<span class="badge badge-life" id="event-count">-</span>
</div>
<table>
<thead><tr><th>Type</th><th>Leaf</th><th>Time</th></tr></thead>
<tbody id="events-body"><tr><td colspan="3" class="empty">Loading...</td></tr></tbody>
</table>
</div>
</div>
</div>
<!-- Anchors -->
<div class="section-label">Anchor history</div>
<div class="panel">
<table>
<thead><tr><th>Height</th><th>Root</th><th>Leaves</th><th>Txid</th></tr></thead>
<tbody id="anchors-body"><tr><td colspan="4" class="empty">Loading...</td></tr></tbody>
</table>
</div>
<footer>
<a href="https://00zeven.cash">00zeven</a> |
<a href="https://nordicshield.cash">Nordic Shield</a> |
<a href="https://explorer.frontiercompute.io">Explorer</a> |
<a href="https://github.com/Frontier-Compute/zap1">Protocol</a> |
<a href="https://sepolia.etherscan.io/address/0x3fD65055A8dC772C848E7F227CE458803005C87F">Etherscan</a>
</footer>
<script>
const API = 'https://pay.frontiercompute.io';
const AGENT_ID = '00zeven-alpha';
function badge(type) {
if (type.startsWith('AGENT')) return `<span class="badge badge-agent">${type}</span>`;
if (type.startsWith('GOVERNANCE')) return `<span class="badge badge-gov">${type}</span>`;
return `<span class="badge badge-life">${type}</span>`;
}
function sh(h) { return `<span class="hash">${h.slice(0, 14)}...</span>`; }
function rel(ts) {
const s = Math.floor((Date.now() - new Date(ts)) / 1000);
if (s < 60) return s + 's';
if (s < 3600) return Math.floor(s / 60) + 'm';
if (s < 86400) return Math.floor(s / 3600) + 'h';
return Math.floor(s / 86400) + 'd';
}
function minerStatus(m) {
if (m.status === 'online' || m.status === 'active') return '<span class="badge badge-ok">online</span>';
if (m.status === 'offline') return '<span class="badge badge-err">offline</span>';
return `<span class="badge badge-warn">${m.status}</span>`;
}
async function refresh() {
try {
const [agent, stats, events, anchors, anchorStatus] = await Promise.all([
fetch(`${API}/agent/${AGENT_ID}`).then(r => r.json()),
fetch(`${API}/stats`).then(r => r.json()),
fetch(`${API}/events?limit=12`).then(r => r.json()),
fetch(`${API}/anchor/history`).then(r => r.json()),
fetch(`${API}/anchor/status`).then(r => r.json()),
]);
// Metrics
document.getElementById('m-actions').textContent = agent.actions;
document.getElementById('m-leaves').textContent = stats.total_leaves;
document.getElementById('m-anchors').textContent = stats.total_anchors;
document.getElementById('m-unanchored').textContent = anchorStatus.unanchored_leaves;
// Miners
const miners = agent.miners || [];
document.getElementById('m-miners').textContent = miners.length || '-';
if (miners.length) {
const totalHash = miners.reduce((s, m) => s + (m.hashrate || 0), 0);
document.getElementById('m-hashrate').textContent = totalHash > 1000 ? (totalHash / 1000).toFixed(1) + ' MH/s' : totalHash.toFixed(0) + ' KH/s';
document.getElementById('miners-panel').innerHTML = miners.map(m =>
`<div class="miner-card">
<div>
<div class="miner-name">${m.name}</div>
<div class="miner-stat">${minerStatus(m)} ${m.last_seen ? rel(m.last_seen) + ' ago' : ''}</div>
</div>
<div style="display: flex; gap: 24px;">
<div class="miner-stat"><b>${m.hashrate ? m.hashrate.toFixed(0) : '-'}</b> ${m.hashrate_unit || 'KH/s'}</div>
${m.temp ? `<div class="miner-stat"><b>${m.temp.toFixed(0)}</b>°C</div>` : ''}
${m.fan_speed ? `<div class="miner-stat"><b>${m.fan_speed}</b> RPM</div>` : ''}
${m.pool ? `<div class="miner-stat">${m.pool.split('/')[2] || m.pool}</div>` : ''}
</div>
</div>`
).join('');
} else {
document.getElementById('m-hashrate').textContent = '-';
document.getElementById('miners-panel').innerHTML = '<div class="empty">No miner data from Foreman</div>';
}
// Agent actions
document.getElementById('agent-status').textContent = agent.registered ? `${agent.total_events} events` : 'unregistered';
const agentActions = agent.events.filter(e => e.event_type === 'AGENT_ACTION').slice(-10).reverse();
document.getElementById('agent-body').innerHTML = agentActions.length
? agentActions.map(e =>
`<tr>
<td><span class="mono" style="font-size: 12px; color: #8b5cf6;">${e.serial_number || 'action'}</span></td>
<td><a href="${API}/verify/${e.leaf_hash}">${sh(e.leaf_hash)}</a></td>
<td><span class="time">${rel(e.created_at)}</span></td>
</tr>`).join('')
: '<tr><td colspan="3" class="empty">No actions yet</td></tr>';
// All events
document.getElementById('event-count').textContent = stats.total_leaves + ' leaves';
document.getElementById('events-body').innerHTML = events.events.slice(0, 10).map(e =>
`<tr>
<td>${badge(e.event_type)}</td>
<td><a href="${API}/verify/${e.leaf_hash}">${sh(e.leaf_hash)}</a></td>
<td><span class="time">${rel(e.created_at)}</span></td>
</tr>`
).join('');
// Anchors
document.getElementById('anchors-body').innerHTML = anchors.anchors.slice().reverse().map(a =>
`<tr>
<td><span class="mono" style="color: #c9a227;">${a.height || 'pending'}</span></td>
<td>${sh(a.root)}</td>
<td>${a.leaf_count}</td>
<td>${a.txid ? `<a href="https://zcashblockexplorer.com/transactions/${a.txid}" target="_blank">${sh(a.txid)}</a>` : '-'}</td>
</tr>`
).join('');
document.getElementById('status').textContent = 'live';
document.getElementById('status').className = 'status status-live';
document.getElementById('last-refresh').textContent = new Date().toLocaleTimeString();
} catch (err) {
document.getElementById('status').textContent = 'error';
document.getElementById('status').className = 'status status-error';
}
}
refresh();
setInterval(refresh, 30000);
</script>
</body>
</html>