/
index.html
237 lines (198 loc) · 9.7 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Topology Explorer - Panel Index</title>
<script language="javascript" type="text/javascript">
var wsUri = "ws://" + location.host + "/ws";
function init() {
setUpWebSocket();
}
function setUpWebSocket() {
websocket = new WebSocket(wsUri);
websocket.onopen = function (evt) { onOpen(evt) };
websocket.onclose = function (evt) { onClose(evt) };
websocket.onmessage = function (evt) { onMessage(evt) };
websocket.onerror = function (evt) { onError(evt) };
}
function onOpen(evt) {
logToScreen("CONNECTED");
doSend("SendIndex");
}
function onClose(evt) {
logToScreen("DISCONNECTED");
}
function onMessage(evt) {
const obj = JSON.parse(evt.data);
if (obj.hasOwnProperty("ConnectedSignal") && obj["ConnectedSignal"]) {
document.location = "/panel";
}
if (obj.hasOwnProperty("Time")) {
document.getElementById("Time").innerHTML = obj["Time"]
}
if (obj["ZeroconfEntries"] != null) {
output = '<table border="0" id="PanelEntries">';
output += `<tr class="header">
<td>Model</td>
<td>Serial</td>
<td>IP address</td>
<td>Port</td>
<td>Protocol</td>
<td>Description</td>
<td>skaarOS</td>
<td>Ping</td>
<td></td>
<td></td>
<td></td>
</tr>`;
for (var i = 0; i < obj["ZeroconfEntries"].length; i++) {
console.log(obj["ZeroconfEntries"][i]["RawPanelDetails"])
output += '<tr' + (obj["ZeroconfEntries"][i]["IsNew"] ? ' class="justAdded"' : '') + '>';
output += '<td>' + obj["ZeroconfEntries"][i]["Model"] + '</td>';
output += '<td>' + obj["ZeroconfEntries"][i]["Serial"] + '</td>';
output += '<td><a href="http://' + obj["ZeroconfEntries"][i]["IPaddr"] + '" target="_blank">' + obj["ZeroconfEntries"][i]["IPaddr"] + '</a></td>';
output += '<td>' + (obj["ZeroconfEntries"][i]["Port"] != -1 ? obj["ZeroconfEntries"][i]["Port"] : '') + '</td>';
output += '<td>' + obj["ZeroconfEntries"][i]["Protocol"] + '</td>';
output += '<td>' + obj["ZeroconfEntries"][i]["Name"] + '</td>';
output += '<td>' + obj["ZeroconfEntries"][i]["SkaarOS"] + '</td>';
output += '<td>' + (obj["ZeroconfEntries"][i]["PingTime"] > -1 ? obj["ZeroconfEntries"][i]["PingTime"] + 'ms' : '') + '</td>';
output += '<td>' + (obj["ZeroconfEntries"][i]["Port"] != -1 ? '<input type="button" value="Connect" onclick="connectTo(\'' + obj["ZeroconfEntries"][i]["IPaddr"] + ':' + obj["ZeroconfEntries"][i]["Port"] + '\');">' : '') + '</td>';
output += '<td>' + (obj["ZeroconfEntries"][i]["RawPanelDetails"] != null && obj["ZeroconfEntries"][i]["RawPanelDetails"]["PanelTopologySVG"] ? obj["ZeroconfEntries"][i]["RawPanelDetails"]["PanelTopologySVG"] + '<br/><span style="font-size: 10px;">HWC count: ' + obj["ZeroconfEntries"][i]["RawPanelDetails"]["TotalHWCs"] : "") + '</span></td>';
output += '<td>' + (obj["ZeroconfEntries"][i]["RawPanelDetails"] != null ? renderRWPderivedInfoTable(obj["ZeroconfEntries"][i]["RawPanelDetails"]) : "") + '</td>';
output += '</tr>';
}
output += '</table>';
document.getElementById("PanelEntriesDiv").innerHTML = output
}
//websocket.close();
logToScreen('<span style="color: blue;">RESPONSE: ' + evt.data + '</span><br/>');
}
function renderRWPderivedInfoTable(rwDetails) {
if (rwDetails["ErrorMsg"] != "") {
return '<span style="color:red">' + rwDetails["ErrorMsg"] + '</span>';
}
output = '';
if (rwDetails["Msg"] != "") {
output += rwDetails["Msg"];
}
output += '<table border="0" class="rpDetails' + (rwDetails["Platform"] == "ibeam" ? " platformBluePill" : " platformOther") + '">';
output += `<tr>
<td class="header" style="font-size: 10px;">Model/Serial/Ver:</td>
<td style="font-size: 10px;` + (rwDetails["SerialModelError"] ? ` color:red;` : ``) + `">` + rwDetails["Model"] + ` / ` + rwDetails["Serial"] + ` / ` + rwDetails["SoftwareVersion"] + `</td>
</tr>`;
output += `<tr>
<td class="header" style="font-size: 10px;">Platform / BP Ready:</td>
<td style="font-size: 10px;">` + (rwDetails["Platform"] ? rwDetails["Platform"] : "-") + ` / ` + (rwDetails["BluePillReady"] ? rwDetails["BluePillReady"] : "-") + `</td>
</tr>`;
output += `<tr>
<td class="header" style="font-size: 10px;">Friendly Name:</td>
<td style="font-size: 10px;">` + rwDetails["FriendlyName"] + `</td>
</tr>`;
output += `<tr>
<td class="header" style="font-size: 10px;">Max Clients / Lock To IPs:</td>
<td style="font-size: 10px;">` + (rwDetails["MaxClients"] ? rwDetails["MaxClients"] : "-") + ` / ` + (rwDetails["LockedToIPs"] ? rwDetails["LockedToIPs"] : "-") + `</td>
</tr>`;
output += `<tr>
<td class="header" style="font-size: 10px;">Current Connections:</td>
<td style="font-size: 10px;">` + (rwDetails["Connections"] ? rwDetails["Connections"] : "-") + `</td>
</tr>`;
output += `<tr>
<td class="header" style="font-size: 10px;">Boots/Session/Uptime/Sleep:</td>
<td style="font-size: 10px;">` + (rwDetails["BootsCount"] ? rwDetails["BootsCount"] : "-") + ` / ` + (rwDetails["SessionUptime"] ? rwDetails["SessionUptime"] : "-") + ` / ` + (rwDetails["TotalUptime"] ? rwDetails["TotalUptime"] : "-") + ` / ` + (rwDetails["ScreenSaveOnTime"] ? rwDetails["ScreenSaveOnTime"] : "-") + `</td>
</tr>`;
output += `<tr>
<td class="header" style="font-size: 10px;">Stats retrieval time:</td>
<td style="font-size: 10px;` + (rwDetails["DeltaTime"] >= 20000 ? ` color:red;` : ``) + `">` + (rwDetails["DeltaTime"] ? rwDetails["DeltaTime"] + 'ms' : '') + `</td>
</tr>`;
output += '</table>';
if (rwDetails["BinaryConnection"]) {
output += '<span style="background-color: black; color: white; padding: 3px 3px 3px 3px; font-size: 9px; border-radius:4px;">BINARY</span>';
} else {
output += '<span style="background-color: #666666; color: white; padding: 3px 3px 3px 3px; font-size: 9px; border-radius:4px;">ASCII</span>';
}
return output;
}
function onError(evt) {
logToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
}
function connectTo(ipAndPort) {
doSend(`{"ConnectTo": "` + ipAndPort + `"}`);
}
function doSend(message) {
logToScreen("SENT: " + message);
websocket.send(message);
}
function logToScreen(message) {
return // Don't log.
}
window.addEventListener("load", init, false);
</script>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
}
table.rpDetails td.header {
font-weight: bold;
}
table#PanelEntries {
margin-left: auto;
margin-right: auto;
}
table#PanelEntries td {
padding-left: 5px;
padding-right: 5px;
font-size: 12px;
}
.platformOther {
background-color: #838383
}
.platformBluePill {
background-color: #3e89eb
}
table#PanelEntries tr {
background-color: #dddddd;
}
table#PanelEntries tr.justAdded {
background-color: #c4e5c4;
}
table#PanelEntries tr.header td {
background-color: #cccccc;
font-weight: bold;
}
div.container {
background-color: #eeeeee;
border-radius: 10px;
border: 1px solid #666666;
padding: 20px 20px 20px 20px;
}
input[type=button] {
background: #cccccc;
width: auto;
cursor: pointer;
padding: 4px 4px 4px 4px;
border-radius: 6px;
border: 2px solid #cccccc;
}
p.tip {
font-size: 10px;
font-style: italic;
}
a {
color: black;
}
</style>
</head>
<body>
<div
style="background-color: #00449c; border-radius: 5px; padding-left: 10px; padding-right: 10px; padding-top: 3px; padding-bottom: 3px;">
<a href="/"><img src="logoheader.png" height="30" /></a>
<img src="kasperwashere.png" height="30" style="float:right;" />
</div>
<h2>Panels on Network:</h2>
<p>Updated: <span id="Time"></span></p>
<div class="container" id="PanelEntriesDiv">
</div>
<p class="tip">SKAARHOJ devices found on the network.</p>
</body>
</html>