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
UI updates: Fix for adding attributes to an asset in the asset editor (Fixes #311)
Rich Turner6f559bdab5ee
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.tsindex ef4ad6e69..7f55c2165 100644--- a/ui/component/core/src/index.ts+++ b/ui/component/core/src/index.ts@@ -266,7 +266,7 @@ export class AssetModelUtil {return match ? match.assetDescriptor : undefined;}- public static getAttributeDescriptor(attributeName?: string, assetTypeOrDescriptor?: string | AssetDescriptor | AssetTypeInfo): AttributeDescriptor | undefined {+ public static getAttributeDescriptor(attributeName: string, assetTypeOrDescriptor: string | AssetDescriptor | AssetTypeInfo): AttributeDescriptor | undefined {if (!attributeName) {return;}diff --git a/ui/component/or-asset-viewer/src/or-add-attribute-panel.ts b/ui/component/or-asset-viewer/src/or-add-attribute-panel.tsindex 7e2952e5c..732a8e0ab 100644--- a/ui/component/or-asset-viewer/src/or-add-attribute-panel.ts+++ b/ui/component/or-asset-viewer/src/or-add-attribute-panel.ts@@ -97,7 +97,7 @@ export class OrAddAttributePanel extends LitElement {} else {nameInput!.classList.add("hidden");typeInput!.classList.add("hidden");- const descriptor = AssetModelUtil.getAttributeDescriptor(name)!;+ const descriptor = AssetModelUtil.getAttributeDescriptor(name, this.asset.type!)!;this.attribute = {};this.attribute.name = descriptor.name;this.attribute.type = descriptor.type;diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.tsindex f671d3121..25bea10eb 100644--- a/ui/component/or-attribute-card/src/index.ts+++ b/ui/component/or-attribute-card/src/index.ts@@ -777,7 +777,7 @@ export class OrAttributeCard extends LitElement {const attr = this.asset.attributes![this.attributeName!];const roundedVal = +value.toFixed(this.mainValueDecimals); // + operator prevents str return- const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(this.attributeName!, this.asset!.type);+ const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(this.attributeName!, this.asset!.type!);const units = Util.resolveUnits(Util.getAttributeUnits(attr, attributeDescriptor, this.asset!.type));this.setMainValueSize(roundedVal.toString());diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.tsindex f821ab4a0..c34051401 100644--- a/ui/component/or-chart/src/index.ts+++ b/ui/component/or-chart/src/index.ts@@ -485,7 +485,7 @@ export class OrChart extends translate(i18next)(LitElement) {<div id="attribute-list">${this.assetAttributes && this.assetAttributes.map((attr, index) => {- const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(attr.name!);+ const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(attr.name!, this.assets[index]!.type!);const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assets[index]!.type, attr.name, attr);const label = Util.getAttributeLabel(attr, descriptors[0], this.assets[index]!.type, true);const bgColor = Util.getMetaValue('color', attr, undefined) ? Util.getMetaValue('color', attr, undefined) : "";diff --git a/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts b/ui/component/or-rules/src/flow-viewer/components/internal-picker.tsindex 143abd394..6326136ba 100644--- a/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts+++ b/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts@@ -120,7 +120,7 @@ export class InternalPicker extends translate(i18next)(LitElement) {this.attributeNames = [];Object.values(this.selectedAsset.attributes).forEach((attribute) => {if (attribute.meta && (attribute.meta.hasOwnProperty(WellknownMetaItems.RULESTATE) ? attribute.meta[WellknownMetaItems.RULESTATE] : attribute.meta.hasOwnProperty(WellknownMetaItems.AGENTLINK))) {- const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(attribute.name, this.selectedAsset.type!);+ const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(attribute.name!, this.selectedAsset.type!);const label = Util.getAttributeLabel(attribute, attributeDescriptor, this.selectedAsset.type!, true);this.attributeNames.push({name: attribute.name!,