mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-25 06:46:10 +02:00
* fix CMT configureable pins #1150 * fix default CMT pins for opendtufusion * beautified `system` * changed main loops, fix resets #1125, #1135
160 lines
6.4 KiB
HTML
160 lines
6.4 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>System</title>
|
|
{#HTML_HEADER}
|
|
</head>
|
|
<body>
|
|
{#HTML_NAV}
|
|
<div id="wrapper">
|
|
<div id="content">
|
|
<div id="info" class="col-sm-12 col-md-6 mt-3"></div>
|
|
<div id="html" class="mt-3 mb-3"></div>
|
|
</div>
|
|
</div>
|
|
{#HTML_FOOTER}
|
|
<script type="text/javascript">
|
|
function parseGeneric(obj) {
|
|
parseNav(obj);
|
|
parseESP(obj);
|
|
parseRssi(obj);
|
|
}
|
|
|
|
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"];
|
|
|
|
lines = [];
|
|
for (const [key, value] of Object.entries(obj)) {
|
|
if(!data.includes(key) || (typeof value == 'undefined')) continue;
|
|
lines.push(tr(key.replace('_', ' '), value));
|
|
}
|
|
|
|
document.getElementById("info").append(
|
|
headline("System Information"),
|
|
ml("table", {class: "table"},
|
|
ml("tbody", {}, lines)
|
|
)
|
|
);
|
|
}
|
|
|
|
function badge(success, text, second="error") {
|
|
return ml("span", {class: "badge badge-" + ((success) ? "success" : second)}, text);
|
|
}
|
|
|
|
function headline(text) {
|
|
return ml("div", {class: "head p-2 mt-3"}, ml("div", {class: "row"}, ml("div", {class: "col a-c"}, text)))
|
|
}
|
|
|
|
function tr(val1, val2) {
|
|
if(typeof val2 == "number")
|
|
val2 = String(val2);
|
|
return ml("tr", {}, [
|
|
ml("th", {style: "width: 50%"}, val1),
|
|
ml("td", {}, val2)
|
|
]);
|
|
}
|
|
|
|
function parseRadio(obj) {
|
|
const pa = ["MIN (recommended)", "LOW", "HIGH", "MAX"];
|
|
const dr = ["1 M", "2 M", "250 k"]
|
|
|
|
if(obj.radioNrf.en)
|
|
lines = [
|
|
tr("NRF24L01", badge(obj.radioNrf.isconnected, ((obj.radioNrf.isconnected) ? "" : "not ") + "connected")),
|
|
tr("NRF24 Power Level", pa[obj.radioNrf.power_level]),
|
|
tr("NRF24 Data Rate", dr[obj.radioNrf.dataRate] + "bps")
|
|
];
|
|
else
|
|
lines = [tr("NRF24L01", badge(false, "not enabled"))];
|
|
|
|
/*IF_ESP32*/
|
|
if(obj.radioCmt.en)
|
|
lines.push(tr("CMT2300A", badge(obj.radioCmt.isconnected, ((obj.radioCmt.isconnected) ? "" : "not ") + "connected")));
|
|
else
|
|
lines.push(tr("CMT2300A", badge(false, "not enabled")));
|
|
/*ENDIF_ESP32*/
|
|
|
|
var stat = obj.statistics;
|
|
document.getElementById("info").append(
|
|
headline("Radio"),
|
|
ml("table", {class: "table"},
|
|
ml("tbody", {}, lines)
|
|
),
|
|
|
|
headline("Statistics"),
|
|
ml("table", {class: "table"},
|
|
ml("tbody", {}, [
|
|
tr("TX count", stat.tx_cnt),
|
|
tr("RX success", stat.rx_success),
|
|
tr("RX fail", stat.rx_fail),
|
|
tr("RX no answer", stat.rx_fail_answer),
|
|
tr("RX fragments", stat.frame_cnt),
|
|
tr("TX retransmits", stat.retransmits)
|
|
])
|
|
)
|
|
);
|
|
}
|
|
|
|
function parseMqtt(obj) {
|
|
if(obj.enabled) {
|
|
lines = [
|
|
tr("connected", badge(obj.connected, ((obj.connected) ? "true" : "false"))),
|
|
tr("#TX", obj.tx_cnt),
|
|
tr("#RX", obj.rx_cnt)
|
|
];
|
|
|
|
} else
|
|
lines = tr("enabled", badge(false, "false"));
|
|
|
|
document.getElementById("info").append(
|
|
headline("MqTT"),
|
|
ml("table", {class: "table"},
|
|
ml("tbody", {}, lines)
|
|
)
|
|
);
|
|
}
|
|
|
|
function parseIndex(obj) {
|
|
if(obj.ts_sunrise > 0) {
|
|
document.getElementById("info").append(
|
|
headline("Sun"),
|
|
ml("table", {class: "table"},
|
|
ml("tbody", {}, [
|
|
tr("Sunrise", new Date(obj.ts_sunrise * 1000).toLocaleString('de-DE')),
|
|
tr("Sunset", new Date(obj.ts_sunset * 1000).toLocaleString('de-DE')),
|
|
tr("Communication start", new Date((obj.ts_sunrise - obj.ts_offset) * 1000).toLocaleString('de-DE')),
|
|
tr("Communication stop", new Date((obj.ts_sunset + obj.ts_offset) * 1000).toLocaleString('de-DE')),
|
|
tr("Night behaviour", badge(obj.disNightComm, ((obj.disNightComm) ? "not" : "") + " communicating", "warning"))
|
|
])
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
function parse(obj) {
|
|
if(null != obj) {
|
|
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 {
|
|
parseRadio(obj.system);
|
|
parseMqtt(obj.system.mqtt);
|
|
parseSysInfo(obj["system"]);
|
|
getAjax('/api/index', parseIndex);
|
|
}
|
|
document.getElementById("html").innerHTML = obj["html"];
|
|
}
|
|
}
|
|
|
|
getAjax("/api/html" + window.location.pathname, parse);
|
|
</script>
|
|
</body>
|
|
</html>
|