client: create TableView scaffolding for updating the UI
This commit is contained in:
parent
36a96a84fd
commit
405df9acfc
2 changed files with 37 additions and 1 deletions
|
@ -1,11 +1,20 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
import SystemQueryClient from './js/SystemQueryClient.mjs';
|
import SystemQueryClient from './js/SystemQueryClient.mjs';
|
||||||
import make_router from './js/routes_client.mjs';
|
import make_router from './js/routes_client.mjs';
|
||||||
|
|
||||||
|
import TableView from './js/TableView.mjs';
|
||||||
|
|
||||||
window.addEventListener("load", async (_event) => {
|
window.addEventListener("load", async (_event) => {
|
||||||
|
const el_version = document.querySelector(".version");
|
||||||
|
const el_table = document.querySelector("main");
|
||||||
|
|
||||||
globalThis.sysquery = new SystemQueryClient();
|
globalThis.sysquery = new SystemQueryClient();
|
||||||
globalThis.sysquery_router = make_router();
|
globalThis.sysquery_router = make_router();
|
||||||
|
globalThis.sysui = {
|
||||||
|
tableview: new TableView(el_table)
|
||||||
|
}
|
||||||
|
|
||||||
const el_version = document.querySelector(".version");
|
|
||||||
|
|
||||||
|
|
||||||
const status = await globalThis.sysquery.status();
|
const status = await globalThis.sysquery.status();
|
||||||
|
|
27
src/static/js/TableView.mjs
Normal file
27
src/static/js/TableView.mjs
Normal 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;
|
Loading…
Reference in a new issue