mirror of https://github.com/lumapu/ahoy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
5.6 KiB
142 lines
5.6 KiB
<!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 headline(text) {
|
|
return ml("div", {class: "head p-2 mt-3"}, ml("div", {class: "row"}, ml("div", {class: "col a-c"}, text)))
|
|
}
|
|
|
|
function parseRadio(obj) {
|
|
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 Data Rate", dr[obj.radioNrf.dataRate] + "bps"),
|
|
tr("DTU Radio ID", obj.radioNrf.sn)
|
|
];
|
|
} else
|
|
lines = [tr("NRF24L01", badge(false, "not enabled"))];
|
|
|
|
document.getElementById("info").append(
|
|
headline("Radio NRF"),
|
|
ml("table", {class: "table"},
|
|
ml("tbody", {}, lines)
|
|
)
|
|
);
|
|
|
|
/*IF_ESP32*/
|
|
if(obj.radioCmt.en) {
|
|
cmt = [
|
|
tr("CMT2300A", badge(obj.radioCmt.isconnected, ((obj.radioCmt.isconnected) ? "" : "not ") + "connected")),
|
|
tr("DTU Radio ID", obj.radioCmt.sn)
|
|
];
|
|
} else
|
|
cmt = [tr("CMT2300A", badge(false, "not enabled"))];
|
|
|
|
document.getElementById("info").append(
|
|
headline("Radio CMT"),
|
|
ml("table", {class: "table"},
|
|
ml("tbody", {}, cmt)
|
|
)
|
|
);
|
|
/*ENDIF_ESP32*/
|
|
}
|
|
|
|
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_offsSr) * 1000).toLocaleString('de-DE')),
|
|
tr("Communication stop", new Date((obj.ts_sunset + obj.ts_offsSs) * 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 if(null != obj.system) {
|
|
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>
|
|
|