rename buttons.css to button.css,
add table styling and prepare for better table generation Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
8b9cbec5fb
commit
f1dc99dedd
@ -7,7 +7,7 @@
|
||||
<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">
|
||||
<link rel="stylesheet" href="css/button.css" type="text/css">
|
||||
<script src="scripts/config.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
21
css/table.css
Normal file
21
css/table.css
Normal file
@ -0,0 +1,21 @@
|
||||
table {
|
||||
padding: 10px;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid var(--content-txt-color);
|
||||
}
|
||||
|
||||
tr {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr:nth-child(even) {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background-color: #aaa;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 5px;
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
<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/buttons.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/button.css" type="text/css">
|
||||
<script src="scripts/index.js" type="module"></script>
|
||||
<script src="scripts/instance.js" type="module"></script>
|
||||
<style>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<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">
|
||||
<link rel="stylesheet" href="css/button.css" type="text/css">
|
||||
<script src="scripts/login.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -6,6 +6,7 @@
|
||||
<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/table.css" type="text/css">
|
||||
<script src="scripts/resources.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
@ -17,6 +18,13 @@
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<table id="resource-table">
|
||||
<thead>
|
||||
<td>Resource Type</td>
|
||||
<td>Avaliable Amount</td>
|
||||
<td>Total Amount</td>
|
||||
</thead>
|
||||
</table>
|
||||
</main>
|
||||
<footer><p>© tronnet</p></footer>
|
||||
</body>
|
||||
|
@ -7,7 +7,7 @@ export class Dialog extends HTMLElement {
|
||||
<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/dialog.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/buttons.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/button.css" type="text/css">
|
||||
<dialog>
|
||||
<p id="prompt"></p>
|
||||
<hr>
|
||||
|
@ -8,7 +8,7 @@ export class Instance extends HTMLElement {
|
||||
|
||||
shadowRoot.innerHTML = `
|
||||
<link rel="stylesheet" href="css/style.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/buttons.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/button.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/instance.css" type="text/css">
|
||||
<div>
|
||||
<img id="node-status" alt="instance node">
|
||||
|
@ -4,27 +4,26 @@ window.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
async function init () {
|
||||
let resources = await requestAPI("/user/resources");
|
||||
document.querySelector("main").innerHTML = buildTable(resources.resources, 1);
|
||||
document.querySelector("main").append(buildResourceTable(resources.resources, "#resource-table"));
|
||||
}
|
||||
|
||||
function buildTable (object, idx) {
|
||||
function buildResourceTable (object, tableid) {
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
let table = document.querySelector(tableid);
|
||||
Object.keys(object).forEach((element) => {
|
||||
table += `<tr><td>${element}</td><td>${buildTable(object[element], idx + 1)}</td></tr>`;
|
||||
let row = table.insertRow();
|
||||
let key = row.insertCell();
|
||||
key.innerText = `${element}`;
|
||||
let val = row.insertCell();
|
||||
val.innerText = `${object[element]}`
|
||||
let total = row.insertCell();;
|
||||
total.innerText = `${object[element]}`
|
||||
});
|
||||
table += "</table>"
|
||||
|
||||
return table;
|
||||
}
|
||||
else {
|
||||
return object;
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user