ProxmoxAAS-Dashboard/scripts/account.js
Arthur Lu 31042464a4 change resource page to account page,
improve table styling

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
2023-04-05 22:48:36 +00:00

26 lines
719 B
JavaScript

import {requestPVE, requestAPI} from "./utils.js";
window.addEventListener("DOMContentLoaded", init);
async function init () {
let resources = await requestAPI("/user/resources");
buildResourceTable(resources.resources, "#resource-table");
}
function buildResourceTable (object, tableid) {
if (object instanceof Object) {
let table = document.querySelector(tableid);
let tbody = table.querySelector("tbody");
Object.keys(object).forEach((element) => {
let row = tbody.insertRow();
let key = row.insertCell();
key.innerText = `${element}`;
let val = row.insertCell();
val.innerText = `${object[element]}`
let total = row.insertCell();;
total.innerText = `${object[element]}`
});
}
}