Skip to content

armgit / core

Public Imported from GitHub
0

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

Various minor UI as described in #43

Rich Turner3184c93fba9a
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetEditActivity.java b/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetEditActivity.java
index 7d2357831..cfb450f75 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetEditActivity.java
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetEditActivity.java
@@ -60,6 +60,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import static org.openremote.manager.client.http.RequestExceptionHandler.handleRequestException;
+import static org.openremote.model.asset.AssetAttribute.attributesFromJson;
import static org.openremote.model.attribute.Attribute.ATTRIBUTE_NAME_VALIDATOR;
import static org.openremote.model.attribute.Attribute.isAttributeNameEqualTo;
import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo;
@@ -84,6 +85,7 @@ public class AssetEditActivity
protected List<ProtocolDescriptor> protocolDescriptors = new ArrayList<>();
protected List<MetaItemDescriptor> metaItemDescriptors = new ArrayList<>(Arrays.asList(AssetMeta.values()));
double[] selectedCoordinates;
+ protected List<AssetAttribute> initialAssetAttributes;
@Inject
public AssetEditActivity(Environment environment,
@@ -149,9 +151,11 @@ public class AssetEditActivity
asset.setName("My New Asset");
asset.setRealmId(currentTenant.getId());
asset.setTenantDisplayName(currentTenant.getDisplayName());
- asset.setType("urn:mydomain:customtype");
+ asset.setType(AssetType.THING);
}
+ initialAssetAttributes = attributesFromJson(asset.getAttributes(), assetId).collect(Collectors.toList());
+
clearViewMessages();
writeAssetToView();
writeAttributeTypesToView(() -> {
@@ -479,7 +483,10 @@ public class AssetEditActivity
// new ProtocolLinksEditor(environment, this.view.getStyle(), view, attribute, protocolDescriptor, false)
// );
- if (protocolDescriptor.isDeviceDiscovery() || protocolDescriptor.isDeviceImport()) {
+ // Only add the import extension if the attribute existed when edit first started
+ boolean existingAttribute = initialAssetAttributes.stream().anyMatch(initialAttribute -> initialAttribute.getName().equals(attribute.getName()));
+
+ if (existingAttribute && (protocolDescriptor.isDeviceDiscovery() || protocolDescriptor.isDeviceImport())) {
extensions.add(
new ProtocolDiscoveryView(
environment,
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetTreeNode.java b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetTreeNode.java
index 22bd0ba90..8c1d18d08 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetTreeNode.java
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetTreeNode.java
@@ -42,7 +42,9 @@ public class AssetTreeNode extends BrowserTreeNode {
@Override
public boolean isLeaf() {
- return Asset.isAssetTypeEqualTo(asset, AssetType.THING);
+ return false;
+ // RT: Removed as mentioned in #43
+ //return Asset.isAssetTypeEqualTo(asset, AssetType.THING);
}
@Override
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java b/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java
index 60efdbce1..678bf6f1a 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java
@@ -49,7 +49,12 @@ public class AttributeEvent extends SharedEvent {
* consequence. Protocols can also create events for internal processing,
* to update any assets' state.
*/
- INTERNAL,
+ INTERNAL, // This needs to be more fine grained
+
+ /**
+ *
+ */
+ ATTRIBUTE_LINKING_SERVICE,
/**
* The event is a value change on a sensor, created by a protocol.