mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 17:06:25 +01:00
Print free disk space in human readable numbers
Signed-off-by: Mimoja <git@mimoja.de>
This commit is contained in:
@@ -94,7 +94,7 @@ function connect() {
|
||||
processTags(msg.tags);
|
||||
}
|
||||
if (msg.sys) {
|
||||
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes ┇ db size: ' + msg.sys.dbsize + ' bytes ┇ db record count: ' + msg.sys.recordcount + ' ┇ littlefs free: ' + msg.sys.littlefsfree + ' bytes';
|
||||
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes ┇ db size: ' + msg.sys.dbsize + ' bytes ┇ db record count: ' + msg.sys.recordcount + ' ┇ active filesystem free: ' + msg.sys.littlefsfree + ' bytes ' + convertSize(msg.sys.littlefsfree);
|
||||
if (msg.sys.apstate) {
|
||||
$("#apstatecolor").style.color = apstate[msg.sys.apstate].color;
|
||||
$("#apstate").innerHTML = apstate[msg.sys.apstate].state;
|
||||
@@ -127,6 +127,18 @@ function connect() {
|
||||
});
|
||||
}
|
||||
|
||||
// Copied from
|
||||
// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
|
||||
function convertSize(bytes){
|
||||
if (bytes >= 1073741824) { bytes = (bytes / 1073741824).toFixed(2) + " GB"; }
|
||||
else if (bytes >= 1048576) { bytes = (bytes / 1048576).toFixed(2) + " MB"; }
|
||||
else if (bytes >= 1024) { bytes = (bytes / 1024).toFixed(2) + " KB"; }
|
||||
else if (bytes > 1) { bytes = bytes + " bytes"; }
|
||||
else if (bytes == 1) { bytes = bytes + " byte"; }
|
||||
else { bytes = "0 bytes"; }
|
||||
return "(" + bytes + ")";
|
||||
}
|
||||
|
||||
function processTags(tagArray) {
|
||||
for (const element of tagArray) {
|
||||
tagmac = element.mac;
|
||||
|
||||
Reference in New Issue
Block a user