Skip to content

armgit / core

Public Imported from GitHub
0

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

make the asset card on map page more robust to missing information in manager_config

Vincent10cb5b948f56
diff --git a/ui/component/or-map/src/or-map-asset-card.ts b/ui/component/or-map/src/or-map-asset-card.ts
index e9cb02aba..d475239c9 100644
--- a/ui/component/or-map/src/or-map-asset-card.ts
+++ b/ui/component/or-map/src/or-map-asset-card.ts
@@ -165,10 +165,12 @@ export class OrMapAssetCard extends subscribe(manager)(LitElement) {
${attrs.map((attr) => {
if (!this.asset || !this.asset.type) { return }
const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.asset.type, attr.name, attr);
- const label = Util.getAttributeLabel(attr, descriptors[0], this.asset.type, true);
- const value = Util.getAttributeValueAsString(attr, descriptors[0], this.asset.type, false, "-");
- const classes = {highlighted: (this.markerconfig![this.asset.type][0] && attr.name === this.markerconfig![this.asset.type][0].attributeName)};
- return html`<li class="${classMap(classes)}"><span class="attribute-name">${label}</span><span class="attribute-value">${value}</span></li>`;
+ if (descriptors && descriptors.length) {
+ const label = Util.getAttributeLabel(attr, descriptors[0], this.asset.type, true);
+ const value = Util.getAttributeValueAsString(attr, descriptors[0], this.asset.type, false, "-");
+ const classes = {highlighted: (this.markerconfig![this.asset.type] && attr.name === this.markerconfig![this.asset.type][0].attributeName)};
+ return html`<li class="${classMap(classes)}"><span class="attribute-name">${label}</span><span class="attribute-value">${value}</span></li>`;
+ }
})}
</ul>
</div>