mirror of
https://github.com/lumapu/ahoy.git
synced 2025-08-02 16:08:26 +02:00
147 lines
6.3 KiB
HTML
147 lines
6.3 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>System</title>
|
|
<link rel="stylesheet" type="text/css" href="style.css"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<script type="text/javascript" src="api.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="topnav">
|
|
<a href="/" class="title">AhoyDTU</a>
|
|
<a href="javascript:void(0);" class="icon" onclick="topnav()">
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
</a>
|
|
<div id="topnav" class="hide"></div>
|
|
<div id="wifiicon" class="info"></div>
|
|
</div>
|
|
<div id="wrapper">
|
|
<div id="content">
|
|
<pre id="stat"></pre>
|
|
<div id="info" class="col-sm-12 col-md-6 mt-3"></div>
|
|
<div id="radio" class="col-sm-12 col-md-6 mt-3"></div>
|
|
<div id="sun" class="col-sm-12 col-md-6 mt-3"></div>
|
|
<div id="html" class="mt-3 mb-3"></div>
|
|
</div>
|
|
</div>
|
|
<div id="footer">
|
|
<div class="left">
|
|
<a href="https://ahoydtu.de" target="_blank">AhoyDTU © 2023</a>
|
|
<ul>
|
|
<li><a href="https://discord.gg/WzhxEY62mB" target="_blank">Discord</a></li>
|
|
<li><a href="https://github.com/lumapu/ahoy" target="_blank">Github</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="right">
|
|
<ul>
|
|
<li><span id="version"></span></li>
|
|
<li><span id="esp_type"></span></li>
|
|
<li><a href="https://creativecommons.org/licenses/by-nc-sa/3.0/de" target="_blank" >CC BY-NC-SA 3.0</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
function parseGeneric(obj) {
|
|
parseVersion(obj);
|
|
parseESP(obj);
|
|
parseRssi(obj);
|
|
}
|
|
|
|
function genTabRow(key, value) {
|
|
var r = div(["row", "p-1"]);
|
|
r.appendChild(div(["col"], key));
|
|
r.appendChild(div(["col"], value));
|
|
return r;
|
|
}
|
|
|
|
function parseSysInfo(obj) {
|
|
const data = ["sdk", "cpu_freq", "chip_revision",
|
|
"chip_model", "chip_cores", "esp_type", "mac", "wifi_rssi", "ts_uptime",
|
|
"flash_size", "sketch_used", "heap_total", "heap_free", "heap_frag",
|
|
"max_free_blk", "version", "core_version", "reboot_reason"];
|
|
|
|
var main = document.getElementById("info");
|
|
var h = div(["head", "p-2"]);
|
|
var r = div(["row"]);
|
|
r.appendChild(div(["col", "a-c"], "System Information"));
|
|
h.appendChild(r);
|
|
main.appendChild(h);
|
|
|
|
for (const [key, value] of Object.entries(obj)) {
|
|
if(!data.includes(key) || (typeof value == 'undefined')) continue;
|
|
main.appendChild(genTabRow(key, value));
|
|
}
|
|
}
|
|
|
|
function parseRadio(obj, stat) {
|
|
const pa = ["MIN", "LOW", "HIGH", "MAX"];
|
|
const datarate = ["1 MBps", "2 MBps", "250 kbps"];
|
|
|
|
var main = document.getElementById("radio");
|
|
var h = div(["head", "p-2"]);
|
|
var r = div(["row"]);
|
|
r.appendChild(div(["col", "a-c"], "Radio"));
|
|
h.appendChild(r);
|
|
main.appendChild(h);
|
|
|
|
main.appendChild(genTabRow("nrf24l01" + (obj["isPVariant"] ? "+ " : ""), (obj["isconnected"] ? "is connected " : "is not connected ")));
|
|
|
|
if(obj["isconnected"]) {
|
|
main.appendChild(genTabRow("Datarate", datarate[obj["DataRate"]]));
|
|
main.appendChild(genTabRow("Power Level", pa[obj["power_level"]]));
|
|
}
|
|
|
|
main.append(
|
|
genTabRow("TX count", stat["tx_cnt"]),
|
|
genTabRow("RX success", stat["rx_success"]),
|
|
genTabRow("RX fail", stat["rx_fail"]),
|
|
genTabRow("RX no answer", stat["rx_fail_answer"]),
|
|
genTabRow("RX fragments", stat["frame_cnt"]),
|
|
genTabRow("TX retransmits", stat["retransmits"])
|
|
);
|
|
}
|
|
|
|
function parseIndex(obj) {
|
|
if(obj["ts_sunrise"] > 0) {
|
|
var h = div(["head", "p-2"]);
|
|
var r = div(["row"]);
|
|
r.appendChild(div(["col", "a-c"], "Sun"));
|
|
h.appendChild(r);
|
|
|
|
document.getElementById("sun").append (
|
|
h,
|
|
genTabRow("Sunrise", new Date(obj["ts_sunrise"] * 1000).toLocaleString('de-DE')),
|
|
genTabRow("Sunset", new Date(obj["ts_sunset"] * 1000).toLocaleString('de-DE')),
|
|
genTabRow("Communication start", new Date((obj["ts_sunrise"] - obj["ts_offset"]) * 1000).toLocaleString('de-DE')),
|
|
genTabRow("Communication stop", new Date((obj["ts_sunset"] + obj["ts_offset"]) * 1000).toLocaleString('de-DE')),
|
|
genTabRow("Night Communication", ((obj["disNightComm"]) ? "disabled" : "enabled"))
|
|
);
|
|
}
|
|
}
|
|
|
|
function parse(obj) {
|
|
if(null != obj) {
|
|
parseMenu(obj["menu"]);
|
|
parseGeneric(obj["generic"]);
|
|
|
|
if(null != obj["refresh"]) {
|
|
var meta = document.createElement('meta');
|
|
meta.httpEquiv = "refresh"
|
|
meta.content = obj["refresh"] + "; URL=" + obj["refresh_url"];
|
|
document.getElementsByTagName('head')[0].appendChild(meta);
|
|
}
|
|
else {
|
|
parseSysInfo(obj["system"]);
|
|
parseRadio(obj["system"]["radio"], obj["system"]["statistics"]);
|
|
getAjax('/api/index', parseIndex);
|
|
}
|
|
document.getElementById("html").innerHTML = obj["html"];
|
|
}
|
|
}
|
|
|
|
getAjax("/api/html" + window.location.pathname, parse);
|
|
</script>
|
|
</body>
|
|
</html>
|