Add tabledefs & ui item indexes
This commit is contained in:
parent
30b20f8e18
commit
a24ba21ba8
4 changed files with 24 additions and 10 deletions
9
src/static/js/tabledefs/index.mjs
Normal file
9
src/static/js/tabledefs/index.mjs
Normal file
|
@ -0,0 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
import cpu from './cpu.mjs';
|
||||
import cpu_live from './cpu_live.mjs';
|
||||
|
||||
export default {
|
||||
cpu,
|
||||
cpu_live
|
||||
}
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
import Emel from 'emel';
|
||||
|
||||
import tabledefs from '../tabledefs/index.mjs';
|
||||
import forkawesome_emel from './forkawesome_emel.mjs';
|
||||
|
||||
import tabledefs from './tabledefs/index.mjs';
|
||||
|
||||
class GlobalUI {
|
||||
constructor() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import Emel from 'emel';
|
||||
import fa_emel from './forkawesome_emel.mjs';
|
||||
|
||||
import UITable from './UITable.mjs';
|
||||
import ui_item_index from './ui_item_index.mjs';
|
||||
|
||||
class TableView {
|
||||
constructor(el) {
|
||||
|
@ -32,15 +32,13 @@ class TableView {
|
|||
el.classList.add("data-item");
|
||||
el_dataitems.appendChild(el);
|
||||
|
||||
let item_manager = null;
|
||||
switch(def.type) {
|
||||
case "table":
|
||||
item_manager = new UITable(el, def);
|
||||
break;
|
||||
default:
|
||||
console.warn(`Unknown item definition type '${def.type}', ignoring. This is probably a bug.`);
|
||||
if(typeof ui_item_index[def.type] !== "undefined") {
|
||||
let item_manager = new ui_item_index[def.type](el, def);
|
||||
this.el_parts.set(def.name, item_manager);
|
||||
}
|
||||
else {
|
||||
console.warn(`Unknown item definition type '${def.type}', ignoring. This is probably a bug.`);
|
||||
}
|
||||
this.el_parts.set(def.name, item_manager);
|
||||
}
|
||||
|
||||
this.el.replaceChildren(parts);
|
||||
|
|
7
src/static/js/ui/ui_item_index.mjs
Normal file
7
src/static/js/ui/ui_item_index.mjs
Normal file
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
import UITable from './UITable.mjs';
|
||||
|
||||
export default {
|
||||
table: UITable
|
||||
};
|
Loading…
Reference in a new issue