add basic resource viewing
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
c16046f3fa
commit
81e4832fa2
@ -6,7 +6,6 @@
|
||||
<title>tronnet - client</title>
|
||||
<link rel="icon" href="images/favicon.svg" sizes="any" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="css/style.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/form.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/buttons.css" type="text/css">
|
||||
<script src="scripts/index.js" type="module"></script>
|
||||
<script src="scripts/instance.js" type="module"></script>
|
||||
@ -15,6 +14,7 @@
|
||||
<header>
|
||||
<nav>
|
||||
<a href="index.html" aria-current="true">INSTANCES</a>
|
||||
<a href="resources.html">RESOURCES</a>
|
||||
<a href="login.html">LOGOUT</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
23
resources.html
Normal file
23
resources.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>tronnet - client</title>
|
||||
<link rel="icon" href="images/favicon.svg" sizes="any" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="css/style.css" type="text/css">
|
||||
<script src="scripts/resources.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav>
|
||||
<a href="index.html">INSTANCES</a>
|
||||
<a href="resources.html" aria-current="true">RESOURCES</a>
|
||||
<a href="login.html">LOGOUT</a>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
</main>
|
||||
<footer><p>© tronnet</p></footer>
|
||||
</body>
|
||||
</html>
|
@ -1,4 +1,4 @@
|
||||
import {requestPVE, requestAPI, goToPage, deleteAllCookies} from "./utils.js";
|
||||
import {requestPVE, requestAPI, goToPage} from "./utils.js";
|
||||
import { Dialog } from "./dialog.js";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", init);
|
||||
|
30
scripts/resources.js
Normal file
30
scripts/resources.js
Normal file
@ -0,0 +1,30 @@
|
||||
import {requestPVE, requestAPI} from "./utils.js";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
async function init () {
|
||||
let resources = await requestAPI("/user/resources");
|
||||
document.querySelector("main").innerHTML = buildTable(resources.resources, 1);
|
||||
}
|
||||
|
||||
function buildTable (object, idx) {
|
||||
|
||||
if (object instanceof Object) {
|
||||
let table = "";
|
||||
if (idx === 1) { // topmost table gets some margin and a border
|
||||
table += `<table style="margin-top: 10px; border: 1px solid black;">`;
|
||||
}
|
||||
else {
|
||||
table += `<table>`;
|
||||
}
|
||||
Object.keys(object).forEach((element) => {
|
||||
table += `<tr><td>${element}</td><td>${buildTable(object[element], idx + 1)}</td></tr>`;
|
||||
});
|
||||
table += "</table>"
|
||||
|
||||
return table;
|
||||
}
|
||||
else {
|
||||
return object;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user