Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit, moved over from raw-panel-utils
- Loading branch information
Kasper Skårhøj
committed
Jul 30, 2022
1 parent
4809f3b
commit b62c197
Showing
7 changed files
with
1,124 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.