Added thermal sensor support in web app.

This commit is contained in:
Ylian Saint-Hilaire 2021-01-28 01:02:29 -08:00
parent 5d3e48df69
commit 7279b26d67
3 changed files with 35 additions and 4 deletions

View File

@ -3094,3 +3094,15 @@ a {
#p19headers > span.on {
font-weight: bold;
}
.thermalSensor {
float: left;
padding: 5px;
background-color: gold;
margin-right: 6px;
border-radius: 4px;
}
.night .thermalSensor {
color: #000;
}

View File

@ -4902,6 +4902,13 @@
"default.handlebars->31->201"
]
},
{
"en": "Alpine Linux x86 64 Bit (MUSL)",
"xloc": [
"default-mobile.handlebars->11->39",
"default.handlebars->31->46"
]
},
{
"en": "Alt",
"fr": "Alt",
@ -40197,7 +40204,6 @@
"xloc": [
"default-mobile.handlebars->11->219",
"default-mobile.handlebars->11->37",
"default-mobile.handlebars->11->39",
"default-mobile.handlebars->11->40",
"default-mobile.handlebars->11->41",
"default-mobile.handlebars->11->42",
@ -40222,7 +40228,6 @@
"default.handlebars->31->2128",
"default.handlebars->31->44",
"default.handlebars->31->452",
"default.handlebars->31->46",
"default.handlebars->31->47",
"default.handlebars->31->48",
"default.handlebars->31->49",

View File

@ -878,6 +878,7 @@
<div style="margin-bottom:10px;margin-left:16px;height:240px;width:calc(100% - 16px);position:relative">
<canvas id=deviceDetailsStats style="position:absolute;top:0;left:0;right:0;bottom:0"></canvas>
</div>
<div id="extraGraphValues" style="display:none;margin-left:30px;margin-bottom:15px"></div>
</td>
</tr>
</table>
@ -2188,7 +2189,7 @@
if (typeof message.cpu.total == 'number') { cpu = message.cpu.total; }
if (typeof message.memory.percentConsumed == 'number') { memory = message.memory.percentConsumed; }
deviceDetailsStatsData.push([now, cpu, memory]);
deviceDetailsStatsDraw();
deviceDetailsStatsDraw(message);
} else if (message.type == 'console') { p15consoleReceive(nodes[index], message.value, message.source); } // This is a console message.
else if (message.type == 'notify') { // This is a notification message.
var n = getstore('notifications', 0);
@ -8929,6 +8930,7 @@
{ label: 'Memory', backgroundColor: 'rgba(255, 99, 132, .5)', borderColor: 'rgb(255, 99, 132)', data: [], fill: true }
] },
options: {
events: ['click'],
animation: false,
responsive: true,
maintainAspectRatio: false,
@ -8957,13 +8959,15 @@
if (deviceDetailsStatsTimer != null) { clearInterval(deviceDetailsStatsTimer); deviceDetailsStatsTimer = null; }
deviceDetailsStatsData = [];
deviceDetailsStatsDraw();
QV('extraGraphValues', false);
QH('extraGraphValues', '');
}
function deviceDetailsStatsTimerFunc() {
if (currentNode != null) { meshserver.send({ action: 'msg', type: 'cpuinfo', nodeid: currentNode._id }); }
}
function deviceDetailsStatsDraw() {
function deviceDetailsStatsDraw(message) {
var now = Date.now() / 1000, oldLimit = (now - 100);
while ((deviceDetailsStatsData.length > 0) && (deviceDetailsStatsData[0][0] < (oldLimit - 5))) { deviceDetailsStatsData.shift(); }
@ -8977,6 +8981,16 @@
deviceDetailsConfig.data.datasets[0].data = cpu;
deviceDetailsConfig.data.datasets[1].data = memory;
if (window.deviceDetailsStatsChart) { window.deviceDetailsStatsChart.update(); }
// Display any additional live values
if (message != null) {
if (Array.isArray(message.thermals) && (message.thermals.length > 0)) {
var x = '&nbsp;';
for (var i in message.thermals) { x += '<div class=thermalSensor>' + parseFloat(message.thermals[i]).toFixed(2) + '&deg;C / ' + parseFloat((message.thermals[i] * 1.8) + 32).toFixed(2) + '&deg;F' + '</div>'; }
QV('extraGraphValues', true);
QH('extraGraphValues', x);
}
}
}
var DeviceDetailsHardware = null;