add pci devices to account

This commit is contained in:
Arthur Lu 2023-07-05 23:29:14 +00:00
parent 3b23a9043c
commit 8a37615721

View File

@ -42,6 +42,15 @@ function buildResourceTable (resources, tableid) {
Object.keys(resources.resources).forEach((element) => {
if (resources.resources[element].display) {
if (resources.resources[element].type === "list") {
const row = tbody.insertRow();
const key = row.insertCell();
key.innerHTML = `${element}`;
const used = row.insertCell();
parseList(used, resources.used[element]);
const avail = row.insertCell();
parseList(avail, resources.avail[element]);
const total = row.insertCell();
parseList(total, resources.max[element]);
}
else {
const row = tbody.insertRow();
@ -78,3 +87,14 @@ function parseNumber (value, unitData) {
return `${value} ${unit}`;
}
}
function parseList (cell, list) {
const listElem = document.createElement("ul");
listElem.style = "list-style-type: none; padding: 0; margin: 0;";
for (const item of list) {
const itemElem = document.createElement("li");
itemElem.innerText = item;
listElem.append(itemElem);
}
cell.append(listElem);
}