Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

fill table with dynamic data, add styles and fix indenting

Vincentf6d8b97e51c7
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 2fa27e2d1..d684f9b8a 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -521,9 +521,16 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
}
} else if (panelConfig && panelConfig.type === "group") {
- console.log(panelConfig);
content = html`
- <or-table></or-table>
+ <or-table
+ headers='["Name","Version","Temperature","Vault","Latest cleansing (mins ago)"]'
+ rows='[
+ ["Name","Version","Temperature","Vault","Latest cleansing (mins ago)"],
+ ["Name","Version","Temperature","Vault","Latest cleansing (mins ago)"],
+ ["Name","Version","Temperature","Vault","Latest cleansing (mins ago)"],
+ ["Name","Version","Temperature","Vault","Latest cleansing (mins ago)"],
+ ["Name","Version","Temperature","Vault","Latest cleansing (mins ago)"]]'
+ ></or-table>
`;
} else {
content = html`
diff --git a/ui/component/or-table/src/index.ts b/ui/component/or-table/src/index.ts
index b7276c54e..02865b220 100644
--- a/ui/component/or-table/src/index.ts
+++ b/ui/component/or-table/src/index.ts
@@ -1,25 +1,25 @@
import {css, customElement, html, LitElement, property, PropertyValues, TemplateResult, unsafeCSS, query} from "lit-element";
import {classMap} from "lit-html/directives/class-map";
import {ifDefined} from "lit-html/directives/if-defined";
-import {MDCDataTable } from "@material/data-table";
+import {MDCDataTable} from "@material/data-table";
import {DefaultColor1, DefaultColor4, DefaultColor8} from "@openremote/core";
+const dataTableStyle = require("!!raw-loader!@material/data-table/dist/mdc.data-table.css");
+
// language=CSS
const style = css`
-
+
:host([hidden]) {
display: none;
}
-
- #wrapper {
- display: flex;
- align-items: center;
- }
-
- #component {
- max-width: 100%;
+
+ .mdc-data-table__header-cell {
+ font-weight: 700;
+ color: #aaa;
+ font-size: 12px;
}
+
`;
@customElement("or-table")
@@ -27,13 +27,37 @@ export class OrTable extends LitElement {
static get styles() {
return [
+ css`${unsafeCSS(dataTableStyle)}`,
style
];
}
+ @property({type: Array})
+ public headers!: string[];
+
+ @property({type: Array})
+ public rows!: [string[]];
+
protected render() {
- return html`<span>tabel</span>`;
+ return html`
+ <div class="mdc-data-table">
+ <table class="mdc-data-table__table" aria-label="Dessert calories">
+ <thead>
+ <tr class="mdc-data-table__header-row">
+ ${this.headers.map(item => html`<th class="mdc-data-table__header-cell" role="columnheader" scope="col">${item}</th>`)}
+ </tr>
+ </thead>
+ <tbody class="mdc-data-table__content">
+ ${this.rows.map(item => html`
+ <tr class="mdc-data-table__row">
+ ${item.map(cell => html`<td class="mdc-data-table__cell">${cell}</td>`)}
+ </tr>
+ `)}
+ </tbody>
+ </table>
+ </div>
+ `;
}
}