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