-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
241 lines (230 loc) · 8.14 KB
/
index.html
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
<!doctype html>
<html>
<head>
<title>Steve's Pi</title>
<meta charset="utf-8" />
<meta
name="description"
content="A peek into Steve's Raspberry Pi and the services it runs"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Steve's Pi" />
<meta
property="og:description"
content="A peek into Steve's Raspberry Pi and the services it runs"
/>
<meta property="og:url" content="https://pi.stevedylan.dev" />
<meta property="og:site_name" content="Steve's Pi" />
<meta property="og:image" content="https://stevedylan.dev/pi.png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<link rel="icon" href="https://stevedylan.dev/favicon.ico" sizes="any" />
<link
rel="icon"
href="https://stevedylan.dev/icon.svg"
type="image/svg+xml"
/>
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<style>
@font-face {
font-family: 'CommitMono';
src: url('https://stevedylan.dev/CommitMono-400-Regular.otf') format('opentype'),
font-weight: normal;
font-style: normal;
}
html {
padding: 0;
margin: 0 1rem 0 1rem;
box-sizing: border-box;
background: #000000;
color: #FFFFFF;
font-family: 'CommitMono', sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
min-height: 90vh;
max-width: 500px;
margin: auto;
font-size: 14px;
}
.stats-container {
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.ipfs-div {
display: flex;
justify-content: flex-start;
align-items: center;
gap: 0.5rem;
}
.source-link {
padding-top: 2rem;
}
.link-container {
display: flex;
justify-content: flex-start;
align-items: center;
gap: 1rem;
}
.truncate {
display: inline-block;
max-width: calc(100% - 30px); /* Adjust based on the width of "ID: " */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: bottom;
}
p {
padding: 0;
margin: 0;
}
a {
color:#FFFFFF;
}
img {
height: 24px;
width: 24px;
}
@media (max-width: 480px) {
.truncate {
max-width: 300px;
}
}
</style>
</head>
<body>
<div class="stats-container">
<h1>Steve's Pi</h1>
<p>
Welcome to a live feed of my Raspberry Pi! It sits on my desk and runs
multiple small services such as
<a href="https://ipfs.io" target="_blank">IPFS</a> and
<a href="https://radicle.xyz" target="_blank">Radicle</a>.
</p>
<div class="ipfs-div">
<img src="https://dweb.mypinata.cloud/ipfs/QmbvEEN8zY657JC6wC2piMygmHcEKhwT5gkNWUs2qcnwKb" alt="ipfs-cube">
<h3>IPFS Node</h3>
</div>
<p>RepoSize: <span id="repoSize">-</span></p>
<p>Objects: <span id="objects">-</span></p>
<p>Bandwidth In: <span id="rateIn">-</span></p>
<p>Bandwidth Out: <span id="rateOut">-</span></p>
<p>Total Data In: <span id="totalIn">-</span></p>
<p>Total Data Out: <span id="totalOut">-</span></p>
<div class="system-info">
<div class="ipfs-div">
<img src="https://dweb.mypinata.cloud/ipfs/QmVtXdzGAQYWYMFGCZR9XV1NFpT941F234Q4oaANTvPeqb" alt="radicle-alien">
<h3>Radicle Node</h3>
</div>
<p>ID: <span class="truncate" id="radId">-</span></p>
<p>Agent: <span id="radAgent">-</span></p>
<p>Status: <span id="radStatus">-</span></p>
<p>Repos: <span id="radRepos">-</span></p>
<p>Seeding Policy: <span id="radPolicy">-</span></p>
</div>
<div class="system-info">
<div class="ipfs-div">
<img src="https://dweb.mypinata.cloud/ipfs/Qmaz5ih9noiMqNnAE5681cCPwGnomopKLUfF2LaSNmuV4P" alt="raspberry-pi-logo" />
<h3>System Information</h3>
</div>
<p>OS: <span id="os">-</span></p>
<p>Kernel: <span id="kernel">-</span></p>
<p>Uptime: <span id="uptime">-</span></p>
<p>CPU Model: <span id="cpuModel">-</span></p>
<p>CPU Usage: <span id="cpuUsage">-</span>%</p>
<p>
Memory: <span id="memoryUsed">-</span>/<span id="memoryTotal">-</span>
</p>
</div>
<div class="link-container">
<a
class="source-link"
href="http://github.com/stevedylandev/pi-widget"
target="_blank"
>Source Code</a
>
<a class="source-link" href="https://stevedylan.dev" target="_blank"
>Homepage</a
>
</div>
</div>
<script>
function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return "0 Bytes";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return (
parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i]
);
}
function formatBitrate(bits) {
if (bits < 1000) {
return bits.toFixed(2) + " bps";
} else if (bits < 1000000) {
return (bits / 1000).toFixed(2) + " Kbps";
} else {
return (bits / 1000000).toFixed(2) + " Mbps";
}
}
const evtSource = new EventSource("/events");
evtSource.onopen = function (event) {
console.log("SSE connection opened");
};
evtSource.onerror = function (event) {
console.error("SSE connection error:", event);
};
evtSource.onmessage = function (event) {
console.log("Received data:", event.data);
try {
const data = JSON.parse(event.data);
// IPFS
document.getElementById("repoSize").textContent = formatBytes(
data.RepoSize,
);
document.getElementById("objects").textContent =
data.NumObjects.toLocaleString();
document.getElementById("rateIn").textContent = formatBitrate(
data.RateIn,
);
document.getElementById("rateOut").textContent = formatBitrate(
data.RateOut,
);
document.getElementById("totalIn").textContent = formatBytes(
data.TotalIn,
);
document.getElementById("totalOut").textContent = formatBytes(
data.TotalOut,
);
// Rad Node
document.getElementById("radId").textContent = data.id;
document.getElementById("radAgent").textContent = data.agent;
document.getElementById("radStatus").textContent = data.state;
document.getElementById("radPolicy").textContent = data.config.seedingPolicy.default;
document.getElementById("radRepos").textContent = data.repos.total.toString()
// System
document.getElementById("os").textContent = data.os;
document.getElementById("kernel").textContent = data.kernel;
document.getElementById("uptime").textContent = data.uptime;
document.getElementById("cpuModel").textContent = data.cpuModel;
document.getElementById("cpuUsage").textContent =
data.cpuUsage.toFixed(2);
document.getElementById("memoryUsed").textContent = formatBytes(
data.memoryUsed,
);
document.getElementById("memoryTotal").textContent = formatBytes(
data.memoryTotal,
);
} catch (error) {
console.error("Error parsing or updating data:", error);
}
};
</script>
</body>
</html>