From 488de43d2fdb882e55d28b0070016c0d4f9fea0a Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Wed, 5 Jul 2023 23:29:14 +0000 Subject: [PATCH] add pci devices to account --- scripts/account.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/account.js b/scripts/account.js index 6b2336e..9403d2b 100644 --- a/scripts/account.js +++ b/scripts/account.js @@ -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); +}