From a24ba21ba8db268e8d6ea5437c1eb5fccf338ffe Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 10 Mar 2022 23:09:22 +0000 Subject: [PATCH] Add tabledefs & ui item indexes --- src/static/js/tabledefs/index.mjs | 9 +++++++++ src/static/js/ui/GlobalUI.mjs | 2 +- src/static/js/ui/TableView.mjs | 16 +++++++--------- src/static/js/ui/ui_item_index.mjs | 7 +++++++ 4 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 src/static/js/tabledefs/index.mjs create mode 100644 src/static/js/ui/ui_item_index.mjs diff --git a/src/static/js/tabledefs/index.mjs b/src/static/js/tabledefs/index.mjs new file mode 100644 index 0000000..f3f5e5f --- /dev/null +++ b/src/static/js/tabledefs/index.mjs @@ -0,0 +1,9 @@ +"use strict"; + +import cpu from './cpu.mjs'; +import cpu_live from './cpu_live.mjs'; + +export default { + cpu, + cpu_live +} diff --git a/src/static/js/ui/GlobalUI.mjs b/src/static/js/ui/GlobalUI.mjs index 1c8225b..2ea10f7 100644 --- a/src/static/js/ui/GlobalUI.mjs +++ b/src/static/js/ui/GlobalUI.mjs @@ -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() { diff --git a/src/static/js/ui/TableView.mjs b/src/static/js/ui/TableView.mjs index f2c21fc..e9e82fd 100644 --- a/src/static/js/ui/TableView.mjs +++ b/src/static/js/ui/TableView.mjs @@ -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); diff --git a/src/static/js/ui/ui_item_index.mjs b/src/static/js/ui/ui_item_index.mjs new file mode 100644 index 0000000..18ba7d0 --- /dev/null +++ b/src/static/js/ui/ui_item_index.mjs @@ -0,0 +1,7 @@ +"use strict"; + +import UITable from './UITable.mjs'; + +export default { + table: UITable +};