client: create TableView scaffolding for updating the UI

This commit is contained in:
Starbeamrainbowlabs 2022-02-26 21:58:51 +00:00
parent 36a96a84fd
commit 405df9acfc
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 37 additions and 1 deletions

View File

@ -1,11 +1,20 @@
"use strict";
import SystemQueryClient from './js/SystemQueryClient.mjs';
import make_router from './js/routes_client.mjs';
import TableView from './js/TableView.mjs';
window.addEventListener("load", async (_event) => {
const el_version = document.querySelector(".version");
const el_table = document.querySelector("main");
globalThis.sysquery = new SystemQueryClient();
globalThis.sysquery_router = make_router();
globalThis.sysui = {
tableview: new TableView(el_table)
}
const el_version = document.querySelector(".version");
const status = await globalThis.sysquery.status();

View File

@ -0,0 +1,27 @@
"use strict";
class TableView {
constructor(el) {
if(this.el === null || typeof this.el === "undefined") throw new Error(`Expected HTML element as the first argument, but got null or undefined.`);
this.el = el;
this.el_parts = new Map();
}
clear() {
this.el.replaceChildren();
this.el_parts.clear();
}
async switch_table(table_name) {
this.clear();
for await (let tabledef of await globalThis.sysquery.table(table_name)) {
this.append_table(tabledef.peer, tabledef.table);
}
}
append_table(peer, table) {
}
}
export default TableView;