100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
get data from service and put in template
Vincent51ad3a922d1d
diff --git a/ui/app/main/src/components/pages/page-insights.ts b/ui/app/main/src/components/pages/page-insights.tsindex ab0d22404..1575cb9c7 100644--- a/ui/app/main/src/components/pages/page-insights.ts+++ b/ui/app/main/src/components/pages/page-insights.ts@@ -79,22 +79,6 @@ const style = css`}`;-const viewerConfig: DataViewerConfig = {- panels: {- "chart": {- type: "chart",- hideOnMobile: true,- panelStyles: {- gridColumn: "1 / -1",- gridRowStart: "1"- },- defaults: [{- assetId:"5442Ite2XVp3Ky9X2y647a",- attributes: ["UVIndex"]- }]- }- }-};@customElement("page-insights")class PageInsights extends connect(store)(LitElement) {@@ -103,19 +87,20 @@ class PageInsights extends connect(store)(LitElement) {return style;}- @property()- protected _assetId;-protected render(): TemplateResult | void {++ const assetId: string = "2U48805AfxblLl1P5dCifA";+ const attributeName: string = "location";+return html`<div id="wrapper"><div id="container">- <or-attribute-card .assetId="${this._assetId}"></or-attribute-card>- <or-attribute-card .assetId="${this._assetId}"></or-attribute-card>- <or-attribute-card .assetId="${this._assetId}"></or-attribute-card>- <or-attribute-card .assetId="${this._assetId}"></or-attribute-card>+ <or-attribute-card .assetId="${assetId}" .attributeName="${attributeName}"></or-attribute-card>+ <or-attribute-card .assetId="${assetId}" .attributeName="${attributeName}"></or-attribute-card>+ <or-attribute-card .assetId="${assetId}" .attributeName="${attributeName}"></or-attribute-card>+ <or-attribute-card .assetId="${assetId}" .attributeName="${attributeName}"></or-attribute-card><!--<div class="row">-->- <!-- <or-data-viewer .config="${viewerConfig}"></or-data-viewer>-->+ <!-- <p>temp text</p>--><!--</div>--></div></div>diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.tsindex c8966963a..11299c484 100644--- a/ui/component/or-attribute-card/src/index.ts+++ b/ui/component/or-attribute-card/src/index.ts@@ -3,6 +3,8 @@ import {OrTranslate, translate} from "@openremote/or-translate";import {classMap} from "lit-html/directives/class-map";import i18next from "i18next";+import {Asset, AssetAttribute} from "@openremote/model";+import manager from "@openremote/core";// language=CSSconst style = css`@@ -43,7 +45,7 @@ const style = css``;@customElement("or-attribute-card")-export class OrAssetDetail extends LitElement {+export class OrAttributeCard extends LitElement {static get styles() {return [@@ -51,32 +53,57 @@ export class OrAssetDetail extends LitElement {];}- @property({type: String})+ @property()public assetId?: string;+ @property()+ public attributeName?: string;++ @property()+ private cardTitle: string = "";++ private getData = () => {+ if (this.assetId) {+ this.getAssetById(this.assetId)+ .then((data) => {+ this.cardTitle = data.name || "";+ console.log("set", this.cardTitle);+ }+ );+ }+ };+protected render() {+ console.log("vars ready", this.assetId, this.attributeName);+ this.getData();- if (!this.assetId) {- return html`- <div class="panel">- <div class="panel-content-wrapper">- <div class="panel-title">- <or-translate value="attributeDetail"></or-translate>- </div>- <div class="panel-content">- <p>no attribute found</p>- </div>- </div>- </div>- `;+ if (!this.assetId || !this.attributeName) {+ // return html`+ // <div class="panel">+ // <div class="panel-content-wrapper">+ // <div class="panel-title">+ // ${this.asdf}+ // </div>+ // <div class="panel-content">+ // <p>no attribute found</p>+ // </div>+ // </div>+ // </div>+ // `;}return html`- <div class="panel">+ <div class="panel" id="attribute-card"><div class="panel-content-wrapper"><div class="panel-title">- <or-translate value="attributeDetail"></or-translate>+ this.cardTitle: ${this.cardTitle}+ </div>+ <div class="panel-title">+ ${this.assetId}+ </div>+ <div class="panel-title">+ ${this.attributeName}</div><div class="panel-content"><p>person</p>@@ -86,4 +113,17 @@ export class OrAssetDetail extends LitElement {`;}+ private async getAssetById(id: string): Promise<Asset> {+ const response = await manager.rest.api.AssetResource.queryAssets({+ ids: [id],+ recursive: false+ });++ // if (response.status !== 200 || !response.data) {+ // return;+ // }++ return response.data[0];+ }+}