Shaped Devices page includes a count of devices and circuits

This commit is contained in:
Herbert Wolverson 2024-07-03 12:43:55 -05:00
parent 8d242ee2e8
commit e4840583a3
2 changed files with 17 additions and 1 deletions

View File

@ -124,12 +124,28 @@ function fillTable() {
target.appendChild(pages);
}
function countCircuits() {
let entries = {};
shapedDevices.forEach((d) => {
if (!entries.hasOwnProperty(d.circuit_id)) {
entries[d.circuit_id] = 1;
}
})
let count = 0;
for (const i in entries) {
count++;
}
return count;
}
function loadDevices() {
$.get("/local-api/devicesAll", (data) => {
//console.log(data);
shapedDevices = data;
displayDevices = data;
fillTable();
$("#count").text(shapedDevices.length + " devices");
$("#countCircuit").text(countCircuits() + " circuits");
})
}

View File

@ -1,6 +1,6 @@
<div class="row">
<div class="col-12">
<h5><i class="fa fa-group"></i> Shaped Devices</h5>
<h5><i class="fa fa-group"></i> Shaped Devices <span class="badge" id="count">?</span> <span class="badge" id="countCircuit">?</span></h5>
</div>
<div class="col-12">
<div id="deviceTable">