From 41b181d9fb278f773132694ebbef421d59602838 Mon Sep 17 00:00:00 2001 From: logicog Date: Tue, 19 Aug 2025 09:27:24 +0200 Subject: [PATCH] Add port statistics page --- html/stat.html | 22 ++++++++++++++++++++++ html/stat.js | 26 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 html/stat.html create mode 100644 html/stat.js diff --git a/html/stat.html b/html/stat.html new file mode 100644 index 0000000..17bd1b7 --- /dev/null +++ b/html/stat.html @@ -0,0 +1,22 @@ + + + + + + + FreeSwitchOS Port Statistics + + + +
+
+

Port Statistics

+ + + +
Port link TX Good TX Bad RX Good RX Bad
+
+ + diff --git a/html/stat.js b/html/stat.js new file mode 100644 index 0000000..18c5e6f --- /dev/null +++ b/html/stat.js @@ -0,0 +1,26 @@ +function fillStats() { + var tbl = document.getElementById('statstable'); + if (tbl.rows.length > 1) { + for (let i = 0; i < 6; i++) { + console.log("Table Update row: " + i + " state " + pState[i] + " is " + linkS[pState[i] +1]); + tbl.rows[i+1].cells[1].innerHTML = `${linkS[pState[i]+1]}`; + tbl.rows[i+1].cells[2].innerHTML = `${txG[i]} Byte`; + tbl.rows[i+1].cells[3].innerHTML = `${txB[i]} Byte`; + tbl.rows[i+1].cells[4].innerHTML = `${rxG[i]} Byte`; + tbl.rows[i+1].cells[5].innerHTML = `${rxB[i]} Byte`; + } + } else { + for (let i = 0; i < 6; i++) { + console.log("Table row: " + i); + const tr = tbl.insertRow(); + let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i+1}`)); + td = tr.insertCell(); td.appendChild(document.createTextNode(`${linkS[pState[i]+1]}`)); + td = tr.insertCell(); td.appendChild(document.createTextNode(`${txG[i]} Byte`)); + td = tr.insertCell();td.appendChild(document.createTextNode(`${txB[i]} Byte`)); + td = tr.insertCell();td.appendChild(document.createTextNode(`${rxG[i]} Byte`)); + td = tr.insertCell();td.appendChild(document.createTextNode(`${rxB[i]} Byte`)); + } + } +} + +const stat = setInterval(fillStats, 500);