-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
381 lines (325 loc) · 12.4 KB
/
index.html
File metadata and controls
381 lines (325 loc) · 12.4 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
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WOLPU3H Dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
<style>
:root {
--primary: #38bdf8;
--bg: #0f172a;
--card: rgba(30, 41, 59, 0.7);
--text: #f8fafc;
--text-dim: #94a3b8;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--bg);
color: var(--text);
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
padding: 20px;
}
.container {
width: 100%;
max-width: 600px;
}
header {
text-align: center;
margin-bottom: 40px;
}
h1 {
font-size: 2.5rem;
margin: 0;
background: linear-gradient(to right, #38bdf8, #818cf8);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.card {
background: var(--card);
backdrop-filter: blur(12px);
border-radius: 20px;
padding: 24px;
border: 1px solid rgba(255, 255, 255, 0.1);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
margin-bottom: 20px;
}
.group {
margin-bottom: 16px;
}
label {
display: block;
font-size: 0.8rem;
color: var(--text-dim);
margin-bottom: 6px;
}
input {
width: 100%;
padding: 12px;
background: #0f172a;
border: 1px solid #334155;
border-radius: 10px;
color: white;
box-sizing: border-box;
}
.btn {
width: 100%;
padding: 14px;
border-radius: 10px;
border: none;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: transform 0.1s, opacity 0.2s;
}
.btn-primary {
background: #0284c7;
color: white;
}
.btn-ghost {
background: transparent;
border: 1px solid #334155;
color: var(--text-dim);
margin-top: 10px;
}
.btn:active {
transform: scale(0.98);
}
.status-list {
list-style: none;
padding: 0;
margin: 0;
}
.status-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
cursor: pointer;
transition: all 0.2s;
}
.status-item:hover {
background: rgba(255, 255, 255, 0.05);
padding-left: 10px;
padding-right: 10px;
margin-left: -10px;
margin-right: -10px;
border-radius: 8px;
}
.badge {
padding: 4px 8px;
border-radius: 6px;
font-size: 0.7rem;
font-weight: bold;
text-transform: uppercase;
}
.badge-pending {
background: #f59e0b22;
color: #fbbf24;
}
.badge-done {
background: #10b98122;
color: #34d399;
}
.badge-online {
background: #10b98122;
color: #34d399;
}
.badge-offline {
background: #ef444422;
color: #f87171;
}
.hidden {
display: none;
}
#config-panel {
transition: all 0.3s;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>WOLPU3H</h1>
<p style="color: var(--text-dim)">Remote Wake-on-LAN Manager</p>
</header>
<!-- Main Section (Dashboard) -->
<div id="main-panel" class="hidden">
<div class="card"
style="background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(30, 41, 59, 0.7))">
<h2 style="margin-top: 0; font-size: 1.2rem;">Wake up PC</h2>
<div class="group">
<label>Target MAC Address</label>
<input type="text" id="target-mac" placeholder="AA:BB:CC:DD:EE:FF">
</div>
<div class="group">
<label>Device ID (Optional)</label>
<input type="text" id="device-id" placeholder="wolpu3h_01">
</div>
<button class="btn btn-primary" id="btn-wake" onclick="triggerWOL()">Send Magic Packet</button>
</div>
<div class="card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
<h3 style="margin: 0; font-size: 1rem;">Active Devices</h3>
<button class="btn btn-ghost" style="width: auto; padding: 5px 10px; font-size: 0.8rem;"
onclick="fetchDevices()">Refresh</button>
</div>
<ul id="device-list" class="status-list">
<!-- Data will be loaded here -->
</ul>
</div>
<div class="card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
<h3 style="margin: 0; font-size: 1rem;">Recent Requests</h3>
<button class="btn btn-ghost" style="width: auto; padding: 5px 10px; font-size: 0.8rem;"
onclick="fetchRequests()">Refresh</button>
</div>
<ul id="request-list" class="status-list">
<!-- Data will be loaded here -->
</ul>
</div>
</div>
<!-- Configuration Section -->
<div id="config-panel" class="card">
<div class="group">
<label>Supabase URL</label>
<input type="text" id="sb-url" placeholder="https://xyz.supabase.co">
</div>
<div class="group">
<label>Anon Key</label>
<input type="password" id="sb-key" placeholder="eyJhbGci...">
</div>
<button class="btn btn-primary" onclick="saveConfig()">Save Configuration</button>
</div>
<button id="btn-settings" class="btn btn-ghost hidden" onclick="toggleConfig()">Settings</button>
</div>
<script>
let sb = null;
function init() {
const url = localStorage.getItem('sb-url');
const key = localStorage.getItem('sb-key');
const targetMac = localStorage.getItem('target-mac');
const deviceId = localStorage.getItem('device-id');
if (url && key) {
document.getElementById('sb-url').value = url;
document.getElementById('sb-key').value = key;
setupSupabase(url, key);
}
if (targetMac) document.getElementById('target-mac').value = targetMac;
if (deviceId) document.getElementById('device-id').value = deviceId;
}
function setupSupabase(url, key) {
sb = supabase.createClient(url, key);
document.getElementById('config-panel').classList.add('hidden');
document.getElementById('main-panel').classList.remove('hidden');
document.getElementById('btn-settings').classList.remove('hidden');
fetchRequests();
fetchDevices();
setInterval(fetchDevices, 60000); // Auto refresh every minute
}
function saveConfig() {
const url = document.getElementById('sb-url').value.trim();
const key = document.getElementById('sb-key').value.trim();
localStorage.setItem('sb-url', url);
localStorage.setItem('sb-key', key);
setupSupabase(url, key);
}
function toggleConfig() {
document.getElementById('config-panel').classList.toggle('hidden');
}
async function triggerWOL() {
const mac = document.getElementById('target-mac').value.trim();
const did = document.getElementById('device-id').value.trim();
const btn = document.getElementById('btn-wake');
if (!mac) return alert('MAC address is required');
// Remember these values for next time
localStorage.setItem('target-mac', mac);
localStorage.setItem('device-id', did);
btn.disabled = true;
btn.innerText = 'Sending...';
// Send null if device_id is empty so it matches 'is.null' query
const { error } = await sb
.from('wol_requests')
.insert([{ target_mac: mac, device_id: did || null, status: 'pending' }]);
if (error) {
alert('Error: ' + error.message);
} else {
fetchRequests();
}
btn.disabled = false;
btn.innerText = 'Send Magic Packet';
}
async function fetchRequests() {
if (!sb) return;
const { data, error } = await sb
.from('wol_requests')
.select('*')
.order('created_at', { ascending: false })
.limit(10);
if (error) return console.error(error);
const list = document.getElementById('request-list');
list.innerHTML = data.map(req => `
<li class="status-item" onclick="fillForm('${req.target_mac}', '${req.device_id || ''}')" title="Click to fill form">
<div>
<div style="font-size: 0.9rem;">${req.target_mac}</div>
<div style="font-size: 0.7rem; color: var(--text-dim)">
${req.device_id ? `[${req.device_id}] ` : ''}${new Date(req.created_at).toLocaleString()}
</div>
</div>
<span class="badge badge-${req.status}">${req.status}</span>
</li>
`).join('');
}
async function fetchDevices() {
if (!sb) return;
const { data, error } = await sb
.from('device_status')
.select('*')
.order('last_seen', { ascending: false });
if (error) return console.error(error);
const list = document.getElementById('device-list');
list.innerHTML = data.map(dev => {
const lastSeen = new Date(dev.last_seen);
const statusLabel = dev.is_online ? 'online' : 'offline';
return `
<li class="status-item" style="cursor: default;">
<div>
<div style="font-size: 0.9rem; font-weight: bold;">${dev.device_id}</div>
<div style="font-size: 0.7rem; color: var(--text-dim)">
IP: ${dev.ip_address} | FW: ${dev.firmware_version} <br/>
Last Seen: ${lastSeen.toLocaleString()}
</div>
</div>
<span class="badge badge-${statusLabel}">${statusLabel}</span>
</li>
`}).join('');
}
function fillForm(mac, deviceId) {
document.getElementById('target-mac').value = mac;
const didInput = document.getElementById('device-id');
// Check for 'null' string because template literals might convert null to "null"
if (deviceId && deviceId !== 'null' && deviceId !== 'undefined') {
didInput.value = deviceId;
} else {
didInput.value = '';
}
// Visual feedback
const inputs = [document.getElementById('target-mac'), didInput];
inputs.forEach(input => {
input.style.borderColor = '#38bdf8';
input.style.boxShadow = '0 0 0 2px rgba(56, 189, 248, 0.2)';
setTimeout(() => {
input.style.borderColor = '#334155';
input.style.boxShadow = 'none';
}, 400);
});
}
init();
</script>
</body>
</html>