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: bug fix fixes #482 and #487

Rich Turner82c3f26d0806
diff --git a/ui/app/manager/src/pages/page-map.ts b/ui/app/manager/src/pages/page-map.ts
index b164ced40..7ded01eb7 100644
--- a/ui/app/manager/src/pages/page-map.ts
+++ b/ui/app/manager/src/pages/page-map.ts
@@ -115,8 +115,8 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
or-map-asset-card {
height: 166px;
position: absolute;
- bottom: 0px;
- right: 0px;
+ bottom: 0;
+ right: 0;
width: calc(100vw - 10px);
margin: 5px;
z-index: 99;
@@ -132,7 +132,7 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
or-map-asset-card {
position: absolute;
top: 20px;
- right: 20px;
+ right: 50px;
width: 320px;
margin: 0;
height: 400px; /* fallback for IE */
diff --git a/ui/component/core/src/event.ts b/ui/component/core/src/event.ts
index 3114c2c01..41ea0f533 100644
--- a/ui/component/core/src/event.ts
+++ b/ui/component/core/src/event.ts
@@ -290,7 +290,22 @@ abstract class EventProviderImpl implements EventProvider {
});
}
- this._assetEventCallbackMap.set(subscriptionId, callback);
+ const eventFilter = (e: AssetEvent) => {
+ const assetId = e.asset!.id!;
+
+ if (assetIds) {
+ if (assetIds.find((id => assetId === id))) {
+ callback(e);
+ }
+ } else {
+ const realm = e.asset!.realm!;
+ if (realm === manager.displayRealm) {
+ callback(e);
+ }
+ }
+ };
+
+ this._assetEventCallbackMap.set(subscriptionId, eventFilter);
return this._assetEventPromise.then(() => {
@@ -343,7 +358,7 @@ abstract class EventProviderImpl implements EventProvider {
const attributes = isAttributeRef ? ids as AttributeRef[] : undefined;
const subscriptionId = "AttributeEvent" + EventProviderImpl._subscriptionCounter++;
- // If not already done then create a single global subscription for asset events and filter for each callback
+ // If not already done then create a single global subscription for attribute events and filter for each callback
if (!this._attributeEventPromise) {
const subscription: EventSubscription<AttributeEvent> = {
@@ -356,15 +371,23 @@ abstract class EventProviderImpl implements EventProvider {
// Build a filter to only respond to the callback for the requested attributes
const eventFilter = (e: AttributeEvent) => {
+ const eventRef = e.attributeState!.ref!;
+
if (isAttributeRef) {
(ids as AttributeRef[]).forEach((ref: AttributeRef) => {
- const eventRef = e.attributeState!.ref!;
if (eventRef.id === ref.id && eventRef.name === ref.name) {
callback(e);
}
});
+ } else if (assetIds) {
+ if (assetIds.find((id => eventRef.id === id))) {
+ callback(e);
+ }
} else {
- callback(e);
+ const realm = e.realm!;
+ if (realm === manager.displayRealm) {
+ callback(e);
+ }
}
};
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index cf69cce7c..3af75fc10 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -1325,16 +1325,11 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
if (event.eventType === "attribute") {
const attributeEvent = event as AttributeEvent;
- if (attributeEvent.attributeState!.ref!.id !== this.assetId) {
- return;
- }
const attrName = attributeEvent.attributeState!.ref!.name!;
- if (this.asset && this.asset.attributes && this.asset.attributes.hasOwnProperty(attrName)) {
- if (attributeEvent.attributeState!.deleted) {
- delete this.asset.attributes[attrName];
- this.asset = {...this.asset};
- }
+ if (attributeEvent.attributeState!.deleted && this.asset && this.asset.attributes) {
+ delete this.asset.attributes[attrName];
+ this.asset = {...this.asset};
}
}
}