Skip to content

armgit / core

Public Imported from GitHub
0

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

UI updates: minor

Rich Turner6fd89fa21ed7
diff --git a/ui/component/core/src/asset-mixin.ts b/ui/component/core/src/asset-mixin.ts
index 4147b772d..4d9ac9f2a 100644
--- a/ui/component/core/src/asset-mixin.ts
+++ b/ui/component/core/src/asset-mixin.ts
@@ -126,7 +126,7 @@ export const subscribe = (eventProviderFactory: EventProviderFactory) => <T exte
}
public _onAttributeEvent(event: AttributeEvent) {
- if (!this._connectRequested || !this._assetSubscriptionId) {
+ if (!this._connectRequested || !this._attributeSubscriptionId) {
return;
}
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 64d3333ac..efc224e8c 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -482,13 +482,8 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
if (this.asset && this.asset.attributes && this.asset.attributes.hasOwnProperty(attrName)) {
if (event.attributeState!.deleted) {
delete this.asset.attributes[attrName];
- } else {
- const attr = this.asset.attributes[attrName]! as Attribute;
- attr.valueTimestamp = event.timestamp;
- attr.value = event.attributeState!.value;
- this.asset.attributes[attrName] = {...attr};
+ this.asset = {...this.asset}
}
- this.asset = {...this.asset}
}
}
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
index 6b85ea907..6f488ccc9 100644
--- a/ui/component/or-attribute-input/src/index.ts
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -77,7 +77,10 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
public disabled: boolean = false;
@property({type: Boolean})
- public preventWrite: boolean = false;
+ public disableSubscribe: boolean = false;
+
+ @property({type: Boolean})
+ public disableWrite: boolean = false;
@property({type: Boolean})
public dense: boolean = false;
@@ -249,8 +252,8 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
public updated(_changedProperties: PropertyValues): void {
super.updated(_changedProperties);
- if (_changedProperties.has("attribute") || _changedProperties.has("attributeRef")) {
- if (this.attribute || this.attributeRef) {
+ if (_changedProperties.has("attribute") || _changedProperties.has("attributeRef") || _changedProperties.has("disabledSubscribe")) {
+ if ((this.attribute || this.attributeRef) && !this.disableSubscribe) {
this._loading = true;
super.attributeRefs = this.attribute ? [{entityId: this.attribute!.assetId!, attributeName: this.attribute!.name!}] : [this.attributeRef!];
} else {
@@ -289,6 +292,8 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
const oldValue = this.attribute ? this.attribute.value : undefined;
if (this.attribute) {
this.attribute.value = event.attributeState!.value;
+ this.attribute.valueTimestamp = event.timestamp;
+ this._loading = false;
super.requestUpdate();
}
this.dispatchEvent(new OrInputChangedEvent(event.attributeState!.value, oldValue));
@@ -300,7 +305,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
newValue = this._valueInboundConverter(newValue);
}
- if (!this.preventWrite && !this.disabled && !this.readonly) {
+ if (!this.disableWrite && !this.disabled && !this.readonly) {
let attributeRef = this.attributeRef;