ProxmoxAAS-Dashboard/scripts/account.js

28 lines
809 B
JavaScript
Raw Normal View History

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