File size: 11,692 Bytes
b841799
 
 
 
 
 
 
 
 
0b8407c
 
05e743b
 
7eeb2f9
 
5e2284c
 
 
 
05e743b
5e2284c
 
 
 
 
0b8407c
 
 
 
05e743b
 
b841799
 
0b8407c
7eeb2f9
05e743b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b8407c
7eeb2f9
05e743b
 
 
 
 
 
 
 
 
 
8cfd412
0b8407c
 
b841799
0b8407c
 
05e743b
 
b841799
 
0b8407c
 
05e743b
54dc52b
 
05e743b
0b8407c
 
 
 
b841799
 
05e743b
 
b841799
 
05e743b
 
b841799
05e743b
 
b841799
 
05e743b
 
 
 
 
 
b841799
0b8407c
05e743b
 
 
 
 
 
0b8407c
 
05e743b
 
0b8407c
 
05e743b
 
 
 
0b8407c
 
05e743b
 
0b8407c
 
 
05e743b
 
0b8407c
 
05e743b
 
0b8407c
 
 
8cfd412
05e743b
 
8cfd412
05e743b
 
 
0b8407c
 
05e743b
 
0b8407c
05e743b
b841799
 
05e743b
 
 
b841799
 
05e743b
0b8407c
05e743b
8cfd412
05e743b
0b8407c
b841799
 
0b8407c
05e743b
b841799
05e743b
 
b841799
 
7eeb2f9
05e743b
 
 
 
b841799
 
 
 
5e2284c
 
 
0b8407c
b841799
0b8407c
 
 
 
 
54dc52b
b841799
 
 
 
0b8407c
b841799
 
 
 
 
0b8407c
b841799
 
 
 
0b8407c
b841799
 
 
 
 
0b8407c
b841799
 
 
 
 
 
 
0b8407c
 
 
 
 
 
 
 
b841799
 
 
0b8407c
b841799
 
 
 
54dc52b
 
0b8407c
 
 
54dc52b
0b8407c
54dc52b
0b8407c
54dc52b
0b8407c
 
 
54dc52b
 
 
 
 
0b8407c
 
54dc52b
0b8407c
54dc52b
 
 
0b8407c
 
 
54dc52b
0b8407c
 
 
54dc52b
0b8407c
 
 
54dc52b
0b8407c
 
 
 
 
54dc52b
0b8407c
 
 
b841799
 
 
 
 
54dc52b
b841799
54dc52b
0b8407c
 
b841799
 
 
 
 
 
 
 
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Server Dashboard — Hedd</title>
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      font-family: -apple-system, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
      min-height: 100vh;
      color: #fff;
      overflow-x: hidden;
    }

    /* Background photo with dark overlay */
    .bg-photo {
      position: fixed; inset: 0; z-index: -2;
      background: url('https://images.unsplash.com/photo-1519681393784-d120267933ba?w=1920&q=80') center/cover no-repeat;
    }
    .bg-overlay {
      position: fixed; inset: 0; z-index: -1;
      background:
        radial-gradient(ellipse at 30% 20%, rgba(88, 60, 209, 0.15) 0%, transparent 50%),
        linear-gradient(180deg, rgba(10,10,26,0.55) 0%, rgba(10,10,26,0.8) 100%);
    }

    .container {
      position: relative; z-index: 1;
      max-width: 960px; margin: 0 auto;
      padding: 2rem 1.25rem 3rem;
    }

    .glass {
      position: relative;
      background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0.06) 40%,
        rgba(255, 255, 255, 0.04) 60%,
        rgba(255, 255, 255, 0.08) 100%
      );
      backdrop-filter: blur(40px) saturate(180%);
      -webkit-backdrop-filter: blur(40px) saturate(180%);
      border: 1px solid rgba(255, 255, 255, 0.18);
      border-radius: 20px;
      box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05);
      overflow: hidden;
    }
    .glass::before {
      content: '';
      position: absolute; inset: 0;
      border-radius: 20px;
      background: linear-gradient(
        135deg,
        rgba(255,255,255,0.08) 0%,
        transparent 50%,
        rgba(255,255,255,0.03) 100%
      );
      pointer-events: none;
    }

    .header {
      text-align: center;
      margin-bottom: 2rem;
      padding: 1.5rem 1rem;
      border-radius: 24px;
    }
    .header h1 {
      font-size: 2rem;
      font-weight: 700;
      background: linear-gradient(135deg, #a78bfa, #60a5fa, #34d399);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
      background-clip: text;
      margin-bottom: 0.3rem;
    }
    .header-sub {
      display: flex; align-items: center; justify-content: center; gap: 0.5rem;
      flex-wrap: wrap;
    }
    .status-dot {
      width: 8px; height: 8px; background: #34d399; border-radius: 50%;
      animation: pulse 2s infinite;
    }
    @keyframes pulse {
      0%,100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
      50% { box-shadow: 0 0 0 8px rgba(52,211,153,0); }
    }
    .status-text, .refresh-info { font-size: 0.8rem; color: rgba(255,255,255,0.5); }
    .refresh-info { margin-left: 0.5rem; font-variant-numeric: tabular-nums; }

    .stats {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 1rem; margin-bottom: 2rem;
    }
    .stat-card {
      position: relative; padding: 1.3rem 1.2rem;
      transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
    }
    .stat-card:hover {
      transform: translateY(-2px);
      border-color: rgba(255, 255, 255, 0.3);
      box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05);
    }
    .stat-label {
      font-size: 0.65rem; color: rgba(255,255,255,0.4);
      text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.3rem;
    }
    .stat-value {
      font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums;
      background: linear-gradient(135deg, #fff 30%, rgba(255,255,255,0.7));
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
      background-clip: text;
    }
    .stat-sub {
      font-size: 0.7rem; color: rgba(255,255,255,0.35);
      margin-top: 0.35rem; line-height: 1.4; font-variant-numeric: tabular-nums;
    }

    .progress-bar {
      height: 4px; background: rgba(255,255,255,0.08);
      border-radius: 2px; margin-top: 0.6rem; overflow: hidden;
    }
    .progress-fill {
      height: 100%; border-radius: 2px; transition: width 0.8s ease;
      position: relative;
    }
    .progress-fill::after {
      content: ''; position: absolute;
      top: 0; right: 0; width: 20px; height: 100%;
      background: rgba(255,255,255,0.4);
      filter: blur(4px); border-radius: 2px;
    }
    .fill-green  { background: linear-gradient(90deg, #34d399, #059669); }
    .fill-yellow { background: linear-gradient(90deg, #fbbf24, #d97706); }
    .fill-red    { background: linear-gradient(90deg, #f87171, #dc2626); }

    .section-title {
      font-size: 0.85rem; color: rgba(255,255,255,0.5);
      margin-bottom: 0.6rem; padding-left: 0.2rem;
    }
    .info-list { position: relative; overflow: hidden; }
    .info-row {
      display: flex; justify-content: space-between; align-items: center;
      padding: 0.7rem 1.2rem;
      border-bottom: 1px solid rgba(255,255,255,0.06);
      font-size: 0.85rem;
    }
    .info-row:last-child { border-bottom: none; }
    .info-key { color: rgba(255,255,255,0.45); }
    .info-val {
      color: rgba(255,255,255,0.85); font-weight: 500;
      text-align: right; font-family: 'SF Mono', 'Fira Code', monospace;
      font-size: 0.78rem;
    }

    .footer {
      text-align: center; margin-top: 3rem;
      color: rgba(255,255,255,0.2); font-size: 0.7rem;
    }
    .footer a { color: rgba(167,139,250,0.6); text-decoration: none; }
    .footer a:hover { color: rgba(167,139,250,0.9); }

    @media (max-width: 600px) {
      .container { padding: 1.5rem 0.75rem 2rem; }
      .stats { grid-template-columns: 1fr 1fr; }
      .info-row { flex-direction: column; align-items: flex-start; gap: 0.15rem; padding: 0.6rem 1rem; }
      .header h1 { font-size: 1.5rem; }
      .stat-value { font-size: 1.6rem; }
    }
  </style>
</head>
<body>
  <!-- Background photo -->
  <div class="bg-photo"></div>
  <div class="bg-overlay"></div>

  <div class="container">
    <div class="header glass">
      <h1>⚡ Server Dashboard</h1>
      <div class="header-sub">
        <span class="status-dot"></span>
        <span class="status-text" id="hostnameLabel">Loading...</span>
        <span class="refresh-info" id="lastUpdate">...</span>
      </div>
    </div>

    <div class="stats">
      <div class="stat-card glass">
        <div class="stat-label">CPU Usage</div>
        <div class="stat-value" id="cpuValue">--%</div>
        <div class="stat-sub" id="cpuSub">Loading...</div>
        <div class="progress-bar"><div class="progress-fill fill-green" id="cpuBar" style="width:0%"></div></div>
      </div>
      <div class="stat-card glass">
        <div class="stat-label">Uptime</div>
        <div class="stat-value" id="uptimeValue">--</div>
        <div class="stat-sub" id="uptimeSub">Loading...</div>
      </div>
      <div class="stat-card glass">
        <div class="stat-label">RAM Usage</div>
        <div class="stat-value" id="memValue">-- GB</div>
        <div class="stat-sub" id="memSub">Loading...</div>
        <div class="progress-bar"><div class="progress-fill fill-green" id="memBar" style="width:0%"></div></div>
      </div>
      <div class="stat-card glass">
        <div class="stat-label">Disk Usage</div>
        <div class="stat-value" id="diskValue">-- GB</div>
        <div class="stat-sub" id="diskSub">Loading...</div>
        <div class="progress-bar"><div class="progress-fill fill-green" id="diskBar" style="width:0%"></div></div>
      </div>
    </div>

    <div class="section-title">📋 Server Info</div>
    <div class="info-list glass">
      <div class="info-row"><span class="info-key">Hostname</span><span class="info-val" id="infoHostname">...</span></div>
      <div class="info-row"><span class="info-key">OS</span><span class="info-val" id="infoOS">...</span></div>
      <div class="info-row"><span class="info-key">Kernel</span><span class="info-val" id="infoKernel">...</span></div>
      <div class="info-row"><span class="info-key">Processes</span><span class="info-val" id="infoProcs">...</span></div>
      <div class="info-row"><span class="info-key">Node.js</span><span class="info-val" id="infoNode">...</span></div>
      <div class="info-row"><span class="info-key">Last Update</span><span class="info-val" id="infoTime">...</span></div>
    </div>

    <div class="footer">
      Powered by <a href="https://github.com/openclaw/openclaw" target="_blank">OpenClaw</a> · Dashboard by Hedd
    </div>
  </div>

  <script>
    function getBarColor(p) { return p < 60 ? 'fill-green' : p < 80 ? 'fill-yellow' : 'fill-red'; }

    function update(d) {
      const hn = (d.hostname || '').split('-').slice(0, 3).join('-') || 'N/A';
      document.getElementById('hostnameLabel').textContent = hn;

      const c = d.cpu || {};
      document.getElementById('cpuValue').textContent = c.usage !== undefined ? c.usage + '%' : 'N/A';
      const la = Array.isArray(c.loadAvg) ? c.loadAvg.join(' ') : '';
      document.getElementById('cpuSub').textContent =
        c.cpuCount + ' cores' +
        (c.loadPercent ? ' · Load ' + c.loadPercent + '%' : '') +
        (la ? ' · avg(' + la + ')' : '');
      const cpuB = document.getElementById('cpuBar');
      const cpuPct = typeof c.usage === 'number' ? c.usage : 0;
      cpuB.style.width = cpuPct + '%';
      cpuB.className = 'progress-fill ' + getBarColor(cpuPct);

      document.getElementById('uptimeValue').textContent = d.uptime || '--';
      document.getElementById('uptimeSub').textContent = (d.kernel || '').split('(')[0].trim();

      const m = d.mem || {};
      document.getElementById('memValue').textContent = m.used + ' GB';
      document.getElementById('memSub').textContent = m.available + ' GB avail / ' + m.total + ' GB';
      const memB = document.getElementById('memBar');
      const mPct = typeof m.percent === 'number' ? m.percent : 0;
      memB.style.width = mPct + '%';
      memB.className = 'progress-fill ' + getBarColor(mPct);

      const dk = d.disk || {};
      document.getElementById('diskValue').textContent = dk.used + ' GB';
      document.getElementById('diskSub').textContent = dk.free + ' GB free / ' + dk.total + ' GB';
      const diskB = document.getElementById('diskBar');
      const dPct = typeof dk.percent === 'number' ? dk.percent : 0;
      diskB.style.width = dPct + '%';
      diskB.className = 'progress-fill ' + getBarColor(dPct);

      document.getElementById('infoHostname').textContent = d.hostname || '—';
      document.getElementById('infoOS').textContent = d.os || '—';
      document.getElementById('infoKernel').textContent = (d.kernel || '').split(' (')[0] || '—';
      document.getElementById('infoProcs').textContent = d.processes || '—';
      document.getElementById('infoNode').textContent = d.node || '—';

      const t = new Date(d.timestamp || Date.now()).toLocaleString('id-ID', { timeZone: 'Asia/Jakarta' });
      document.getElementById('infoTime').textContent = t + ' WIB';
      document.getElementById('lastUpdate').textContent = 'Updated ' + t;
    }

    async function fetchStats() {
      try {
        const res = await fetch('/api/stats');
        if (!res.ok) throw new Error('HTTP ' + res.status);
        const data = await res.json();
        update(data);
      } catch (e) {
        document.getElementById('lastUpdate').textContent = 'Connection lost';
      }
    }

    fetchStats();
    setInterval(fetchStats, 5000);
  </script>
</body>
</html>