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
extra logic for panel types
Vincentfa9c084bbe9b
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.tsindex 9fa4a0b15..50256534f 100644--- a/ui/component/or-asset-viewer/src/index.ts+++ b/ui/component/or-asset-viewer/src/index.ts@@ -30,7 +30,7 @@ import i18next from "i18next";import {styleMap} from "lit-html/directives/style-map";import {classMap} from "lit-html/directives/class-map";-export type PanelType = "property" | "location" | "attribute" | "history" | "chart" | "group";+export type PanelType = "property" | "location" | "attribute" | "history" | "chart" | "info" | "group";export interface PanelConfig {type?: PanelType;@@ -104,9 +104,9 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElempanelStyles: {}},"info": {- type: "attribute",+ type: "info",hideOnMobile: true,- include: ["userNotes", "brand"],+ include: ["userNotes", "manufacturer", "model"],panelStyles: {},fieldStyles: {@@ -308,12 +308,10 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElempublic static getPanel(name: string, asset: Asset, attributes: AssetAttribute[], viewerConfig: AssetViewerConfig, panelConfig: PanelConfig, shadowRoot: ShadowRoot | null) {const content = OrAssetViewer.getPanelContent(name, asset, attributes, viewerConfig, panelConfig, shadowRoot);-if (!content) {return;}-return html`<div class=${classMap({"panel": true, mobileHidden: panelConfig.hideOnMobile === true})} id="${name}-panel" style="${panelConfig && panelConfig.panelStyles ? styleMap(panelConfig.panelStyles) : ""}"><div class="panel-content-wrapper">@@ -442,25 +440,21 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem}} else if (panelConfig && panelConfig.type === "chart") {- let storeDataPointAttrs = attrs.filter((attr) => Util.getFirstMetaItem(attr, MetaItemType.STORE_DATA_POINTS.urn!))- let defaultAttrs = storeDataPointAttrs.filter((attr) => (defaultAttributes && defaultAttributes.indexOf(attr.name!) >= 0));- let assetAttributes;-- if(defaultAttrs.length > 0){- assetAttributes = defaultAttrs;- } else if(storeDataPointAttrs.length > 0) {- assetAttributes = storeDataPointAttrs;- assetAttributes.length = 1;- }- const assetList:Asset[] = [];- if(assetAttributes) {- assetAttributes.forEach(attr => assetList.push(asset));++ if (asset.type === "urn:openremote:asset:group") {+ return;}+content = html`- <or-chart id="chart" .config="${viewerConfig.chartConfig}" .activeAsset="${asset}" .assets="${assetList ? assetList : [asset]}" .assetAttributes="${assetAttributes}"></or-chart>+ <or-chart id="chart" .config="${viewerConfig.chartConfig}" activeAssetId="${asset.id}" .activeAsset="${asset}" ></or-chart>`;} else if (panelConfig && panelConfig.type === "location") {++ if (asset.type === "urn:openremote:asset:group") {+ return;+ }+const attribute = attrs.find((attr) => attr.name === AttributeType.LOCATION.attributeName);if (attribute) {// Special handling for location panel which shows an attribute selector and a map showing the location of the attribute@@ -536,12 +530,30 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem["Name","Version","Temperature","Vault","Latest cleansing (mins ago)"]]'></or-table>`;+ } else if (panelConfig && panelConfig.type === "info") {++ if (asset.type !== "urn:openremote:asset:group") {+ return;+ }++ content = html`+ info+ `;+ } else if (panelConfig && panelConfig.type === "attribute") {++ if (asset.type !== "urn:openremote:asset:group") {+ return;+ }} else {+ if(attrs.length === 0) {+ return undefined;+ }+content = html`${attrs.sort((attr1, attr2) => attr1.name! < attr2.name! ? -1 : attr1.name! > attr2.name! ? 1 : 0).map((attr) => {- let style = styles ? styles[attr.name!] : undefined;- return this.getField(attr.name!, false, style, OrAssetViewer.getAttributeTemplate(asset, attr, viewerConfig, panelConfig));- })}+ let style = styles ? styles[attr.name!] : undefined;+ return this.getField(attr.name!, false, style, OrAssetViewer.getAttributeTemplate(asset, attr, viewerConfig, panelConfig));+ })}`;}@@ -601,7 +613,6 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElemreturn result;}}-return html`<or-attribute-input dense .assetType="${asset!.type}" .attribute="${attribute}" .label="${i18next.t(attribute.name!)}"></or-attribute-input>`;@@ -611,7 +622,6 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElemif (!content) {return ``;}-return html`<div id="field-${name}" style="${styles ? styleMap(styles) : ""}" class="field ${isProperty ? "field-property" : "field-attribute"}">${content}