client: TableView: move to UI subdir
This commit is contained in:
parent
5bbe91c3e9
commit
6a834eea22
2 changed files with 20 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
||||||
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';
|
import TableView from './js/ui/TableView.mjs';
|
||||||
|
|
||||||
window.addEventListener("load", async (_event) => {
|
window.addEventListener("load", async (_event) => {
|
||||||
const el_version = document.querySelector(".version");
|
const el_version = document.querySelector(".version");
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
import Emel from 'emel';
|
||||||
|
import fa_emel from './forkawesome_emel.mjs';
|
||||||
|
|
||||||
class TableView {
|
class TableView {
|
||||||
constructor(el) {
|
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.`);
|
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 = el;
|
||||||
this.el_parts = new Map();
|
this.el_parts = new Map();
|
||||||
|
this.emel = new Emel().emel;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
@ -12,7 +16,22 @@ class TableView {
|
||||||
this.el_parts.clear();
|
this.el_parts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init(tabledef) {
|
||||||
|
this.clear();
|
||||||
|
const parts = this.emel(`h2>(${fa_emel(tabledef.icon)}+{?})^div[class=data-display]`, {
|
||||||
|
placeholders: [
|
||||||
|
tabledef.name
|
||||||
|
]
|
||||||
|
});
|
||||||
|
for(let def of tabledef.items) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
this.el.replaceChildren(parts);
|
||||||
|
}
|
||||||
|
|
||||||
async switch_table(table_name) {
|
async switch_table(table_name) {
|
||||||
|
table_name = table_name.replace(/[^a-z0-9-_]/g, "");
|
||||||
this.clear();
|
this.clear();
|
||||||
for await (let tabledef of await globalThis.sysquery.table(table_name)) {
|
for await (let tabledef of await globalThis.sysquery.table(table_name)) {
|
||||||
this.append_table(tabledef.peer, tabledef.table);
|
this.append_table(tabledef.peer, tabledef.table);
|
Loading…
Reference in a new issue