Skip to content

armgit / core

Public Imported from GitHub
0

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

Updated the demo setup with new realms and with the new npm ui packages

Michael Rademaker31986964cc59
diff --git a/deployment/build.gradle b/deployment/build.gradle
index 0414012e3..8df8b0a9e 100644
--- a/deployment/build.gradle
+++ b/deployment/build.gradle
@@ -7,7 +7,7 @@ task clean() {
task installDist(type: Copy) {
dependsOn(rootProject.getTasksByName('installDist', true).findAll {it.project != project && ((parent == rootProject) || (isCustomProject() && it.project.parent != rootProject))})
from(projectDir) {
- exclude "build.gradle", "Dockerfile", "build"
+ exclude "build.gradle", "Dockerfile", "build", "**/*.mbtiles"
}
into project(":deployment").buildDir
}
\ No newline at end of file
diff --git a/deployment/map/mapsettings.json b/deployment/map/mapsettings.json
index 9ec8624fe..ccce473c7 100644
--- a/deployment/map/mapsettings.json
+++ b/deployment/map/mapsettings.json
@@ -7,7 +7,7 @@
"maxZoom": 19,
"boxZoom": false
},
- "tenantA": {
+ "building": {
"center": [5.4774, 51.4370],
"bounds": [5.343, 51.378, 5.591, 51.509],
"zoom": 13,
diff --git a/docker-compose-swarm.yml b/docker-compose-swarm.yml
index 3f15f728d..f8b5757df 100644
--- a/docker-compose-swarm.yml
+++ b/docker-compose-swarm.yml
@@ -90,7 +90,7 @@ services:
# PROXY_HOST_REDIRECT_1_NAME: www.my-console-master.tld
# PROXY_HOST_REDIRECT_1_TARGET: /console/master
# PROXY_HOST_REDIRECT_2_NAME: www.my-console-tenant-a.tld
- # PROXY_HOST_REDIRECT_2_TARGET: /console/tenantA
+ # PROXY_HOST_REDIRECT_2_TARGET: /console/building
# PROXY_HOST_REDIRECT_3_NAME: ...
# Customize proxy log, defaults to 'notice', requests are logged at 'info'.
diff --git a/docker-compose.yml b/docker-compose.yml
index f20bfca3d..342eeede8 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -71,6 +71,8 @@ services:
- proxy-data:/deployment
# Override the haproxy.cfg with custom file
# -${MY_PROXY_CONFIG_FILE}:/etc/haproxy/haproxy.cfg
+ environment:
+ DOMAINNAME: demo.openremote.io
# This configuration uses the manager's deployment-specific data such as map tiles,
# console application static resources (HTML, JS, CSS), extensions, and other
@@ -84,6 +86,10 @@ services:
condition: service_healthy
volumes:
- deployment-data:/deployment
+ - /deployment.local/manager:/deployment.local
+ environment:
+ MAP_TILES_PATH: '/deployment.local/map/mapdata.mbtiles'
+ IDENTITY_NETWORK_HOST: demo.openremote.io
keycloak:
extends:
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakDemoSetup.java
index 56d89d86d..8b333e341 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakDemoSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/KeycloakDemoSetup.java
@@ -39,10 +39,10 @@ import java.util.logging.Logger;
* <ul>
* <li><code>admin</code> - The superuser in the "master" realm with all access</li>
* <li><code>testuser1</code> - (Password: testuser1) A user in the "master" realm with read/write access to assets and rules</li>
- * <li><code>testuser2</code> - (Password: testuser2) A user in the "tenantA" realm with only read access to assets</li>
- * <li><code>testuser3</code> - (Password: testuser3) A user in the "tenantA" realm with read/write access to a restricted set of assets and their rules</li>
- * <li><code>building</code> - (Password: building) A user in the "tenantA" realm with read/write access to the building apartment 1 assets and their rules</li>
- * <li><code>testuser4</code> - (Password: testuser4) A user in the "tenantB" realm with read/write access to a restricted set of assets and their rules</li>
+ * <li><code>testuser2</code> - (Password: testuser2) A user in the "building" realm with only read access to assets</li>
+ * <li><code>testuser3</code> - (Password: testuser3) A user in the "building" realm with read/write access to a restricted set of assets and their rules</li>
+ * <li><code>building</code> - (Password: building) A user in the "building" realm with read/write access to the building apartment 1 assets and their rules</li>
+ * <li><code>testuser4</code> - (Password: testuser4) A user in the "smartcity" realm with read/write access to a restricted set of assets and their rules</li>
*
* </ul>
*/
@@ -56,8 +56,8 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
public String testuser4Id;
public String buildingUserId;
public Tenant masterTenant;
- public Tenant tenantA;
- public Tenant tenantB;
+ public Tenant tenantBuilding;
+ public Tenant tenantCity;
public KeycloakDemoSetup(Container container) {
super(container);
@@ -70,19 +70,19 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
// Tenants
masterTenant = identityService.getIdentityProvider().getTenant(Constants.MASTER_REALM);
- tenantA = new Tenant();
- tenantA.setRealm("tenantA");
- tenantA.setDisplayName("Tenant A");
- tenantA.setEnabled(true);
- keycloakProvider.createTenant(new ClientRequestInfo(null, accessToken), tenantA, emailConfig);
- tenantA = keycloakProvider.getTenant(tenantA.getRealm());
-
- tenantB = new Tenant();
- tenantB.setRealm("tenantB");
- tenantB.setDisplayName("Tenant B");
- tenantB.setEnabled(true);
- keycloakProvider.createTenant(new ClientRequestInfo(null, accessToken), tenantB, emailConfig);
- tenantB = keycloakProvider.getTenant(tenantB.getRealm());
+ tenantBuilding = new Tenant();
+ tenantBuilding.setRealm("building");
+ tenantBuilding.setDisplayName("Building");
+ tenantBuilding.setEnabled(true);
+ keycloakProvider.createTenant(new ClientRequestInfo(null, accessToken), tenantBuilding, emailConfig);
+ tenantBuilding = keycloakProvider.getTenant(tenantBuilding.getRealm());
+ Updated the demo setup with new realms and with the new npm ui packages
+ tenantCity = new Tenant();
+ tenantCity.setRealm("smartcity");
+ tenantCity.setDisplayName("Smart City");
+ tenantCity.setEnabled(true);
+ keycloakProvider.createTenant(new ClientRequestInfo(null, accessToken), tenantCity, emailConfig);
+ tenantCity = keycloakProvider.getTenant(tenantCity.getRealm());
// Users
String masterClientObjectId = getClientObjectId(masterClientsResource);
@@ -111,10 +111,10 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
));
LOG.info("Added demo user '" + testuser1.getUsername() + "' with password '" + testuser1Credentials.getValue() + "'");
- UsersResource tenantAUsersResource = keycloakProvider.getRealms(accessToken).realm("tenantA").users();
- ClientsResource tenantAClientsResource = keycloakProvider.getRealms(accessToken).realm("tenantA").clients();
- String tenantAClientObjectId = getClientObjectId(tenantAClientsResource);
- RolesResource tenantARolesResource = tenantAClientsResource.get(tenantAClientObjectId).roles();
+ UsersResource tenantBuildingUsersResource = keycloakProvider.getRealms(accessToken).realm("building").users();
+ ClientsResource tenantBuildingClientsResource = keycloakProvider.getRealms(accessToken).realm("building").clients();
+ String tenantBuildingClientObjectId = getClientObjectId(tenantBuildingClientsResource);
+ RolesResource tenantBuildingRolesResource = tenantBuildingClientsResource.get(tenantBuildingClientObjectId).roles();
UserRepresentation testuser2 = new UserRepresentation();
testuser2.setUsername("testuser2");
@@ -122,18 +122,18 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
testuser2.setLastName("DemoLast");
testuser2.setEmail("[email protected]");
testuser2.setEnabled(true);
- tenantAUsersResource.create(testuser2);
- testuser2 = tenantAUsersResource.search("testuser2", null, null, null, null, null).get(0);
+ tenantBuildingUsersResource.create(testuser2);
+ testuser2 = tenantBuildingUsersResource.search("testuser2", null, null, null, null, null).get(0);
this.testuser2Id = testuser2.getId();
CredentialRepresentation testuser2Credentials = new CredentialRepresentation();
testuser2Credentials.setType("password");
testuser2Credentials.setValue("testuser2");
testuser2Credentials.setTemporary(false);
- tenantAUsersResource.get(testuser2.getId()).resetPassword(testuser2Credentials);
- tenantAUsersResource.get(testuser2.getId()).roles().clientLevel(tenantAClientObjectId).add(Arrays.asList(
- tenantARolesResource.get(ClientRole.WRITE_USER.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.READ_MAP.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.READ_ASSETS.getValue()).toRepresentation()
+ tenantBuildingUsersResource.get(testuser2.getId()).resetPassword(testuser2Credentials);
+ tenantBuildingUsersResource.get(testuser2.getId()).roles().clientLevel(tenantBuildingClientObjectId).add(Arrays.asList(
+ tenantBuildingRolesResource.get(ClientRole.WRITE_USER.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.READ_MAP.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.READ_ASSETS.getValue()).toRepresentation()
));
LOG.info("Added demo user '" + testuser2.getUsername() + "' with password '" + testuser2Credentials.getValue() + "'");
@@ -143,21 +143,21 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
testuser3.setLastName("DemoLast");
testuser3.setEmail("[email protected]");
testuser3.setEnabled(true);
- tenantAUsersResource.create(testuser3);
- testuser3 = tenantAUsersResource.search("testuser3", null, null, null, null, null).get(0);
+ tenantBuildingUsersResource.create(testuser3);
+ testuser3 = tenantBuildingUsersResource.search("testuser3", null, null, null, null, null).get(0);
this.testuser3Id = testuser3.getId();
CredentialRepresentation testuser3Credentials = new CredentialRepresentation();
testuser3Credentials.setType("password");
testuser3Credentials.setValue("testuser3");
testuser3Credentials.setTemporary(false);
- tenantAUsersResource.get(testuser3.getId()).resetPassword(testuser3Credentials);
- tenantAUsersResource.get(testuser3.getId()).roles().clientLevel(tenantAClientObjectId).add(Arrays.asList(
- tenantARolesResource.get(ClientRole.WRITE_USER.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.READ_MAP.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.READ_ASSETS.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.WRITE_RULES.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.WRITE_ASSETS.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.READ_RULES.getValue()).toRepresentation()
+ tenantBuildingUsersResource.get(testuser3.getId()).resetPassword(testuser3Credentials);
+ tenantBuildingUsersResource.get(testuser3.getId()).roles().clientLevel(tenantBuildingClientObjectId).add(Arrays.asList(
+ tenantBuildingRolesResource.get(ClientRole.WRITE_USER.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.READ_MAP.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.READ_ASSETS.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.WRITE_RULES.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.WRITE_ASSETS.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.READ_RULES.getValue()).toRepresentation()
));
LOG.info("Added demo user '" + testuser3.getUsername() + "' with password '" + testuser3Credentials.getValue() + "'");
@@ -167,28 +167,28 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
buildingUser.setLastName("User");
buildingUser.setEmail("[email protected]");
buildingUser.setEnabled(true);
- tenantAUsersResource.create(buildingUser);
- buildingUser = tenantAUsersResource.search("building", null, null, null, null, null).get(0);
+ tenantBuildingUsersResource.create(buildingUser);
+ buildingUser = tenantBuildingUsersResource.search("building", null, null, null, null, null).get(0);
this.buildingUserId = buildingUser.getId();
CredentialRepresentation buildingUserCredentials = new CredentialRepresentation();
buildingUserCredentials.setType("password");
buildingUserCredentials.setValue("building");
buildingUserCredentials.setTemporary(false);
- tenantAUsersResource.get(buildingUser.getId()).resetPassword(buildingUserCredentials);
- tenantAUsersResource.get(buildingUser.getId()).roles().clientLevel(tenantAClientObjectId).add(Arrays.asList(
- tenantARolesResource.get(ClientRole.WRITE_USER.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.READ_MAP.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.READ_ASSETS.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.WRITE_RULES.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.WRITE_ASSETS.getValue()).toRepresentation(),
- tenantARolesResource.get(ClientRole.READ_RULES.getValue()).toRepresentation()
+ tenantBuildingUsersResource.get(buildingUser.getId()).resetPassword(buildingUserCredentials);
+ tenantBuildingUsersResource.get(buildingUser.getId()).roles().clientLevel(tenantBuildingClientObjectId).add(Arrays.asList(
+ tenantBuildingRolesResource.get(ClientRole.WRITE_USER.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.READ_MAP.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.READ_ASSETS.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.WRITE_RULES.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.WRITE_ASSETS.getValue()).toRepresentation(),
+ tenantBuildingRolesResource.get(ClientRole.READ_RULES.getValue()).toRepresentation()
));
LOG.info("Added demo user '" + buildingUser.getUsername() + "' with password '" + buildingUserCredentials.getValue() + "'");
- UsersResource tenantBUsersResource = keycloakProvider.getRealms(accessToken).realm("tenantB").users();
- ClientsResource tenantBClientsResource = keycloakProvider.getRealms(accessToken).realm("tenantB").clients();
- String tenantBClientObjectId = getClientObjectId(tenantBClientsResource);
- RolesResource tenantBRolesResource = tenantBClientsResource.get(tenantBClientObjectId).roles();
+ UsersResource tenantCityUsersResource = keycloakProvider.getRealms(accessToken).realm("city").users();
+ ClientsResource tenantCityClientsResource = keycloakProvider.getRealms(accessToken).realm("city").clients();
+ String tenantCityClientObjectId = getClientObjectId(tenantCityClientsResource);
+ RolesResource tenantCityRolesResource = tenantCityClientsResource.get(tenantCityClientObjectId).roles();
UserRepresentation testuser4 = new UserRepresentation();
testuser4.setUsername("testuser4");
@@ -196,19 +196,19 @@ public class KeycloakDemoSetup extends AbstractKeycloakSetup {
testuser4.setLastName("DemoLast");
testuser4.setEmail("[email protected]");
testuser4.setEnabled(true);
- tenantBUsersResource.create(testuser4);
- testuser4 = tenantBUsersResource.search("testuser4", null, null, null, null, null).get(0);
+ tenantCityUsersResource.create(testuser4);
+ testuser4 = tenantCityUsersResource.search("testuser4", null, null, null, null, null).get(0);
this.testuser4Id = testuser4.getId();
CredentialRepresentation testuser4Credentials = new CredentialRepresentation();
testuser4Credentials.setType("password");
testuser4Credentials.setValue("testuser4");
testuser4Credentials.setTemporary(false);
- tenantBUsersResource.get(testuser4.getId()).resetPassword(testuser4Credentials);
- tenantBUsersResource.get(testuser4.getId()).roles().clientLevel(tenantBClientObjectId).add(Arrays.asList(
- tenantBRolesResource.get(ClientRole.WRITE_USER.getValue()).toRepresentation(),
- tenantBRolesResource.get(ClientRole.READ_MAP.getValue()).toRepresentation(),
- tenantBRolesResource.get(ClientRole.READ_ASSETS.getValue()).toRepresentation(),
- tenantBRolesResource.get(ClientRole.READ_RULES.getValue()).toRepresentation()
+ tenantCityUsersResource.get(testuser4.getId()).resetPassword(testuser4Credentials);
+ tenantCityUsersResource.get(testuser4.getId()).roles().clientLevel(tenantCityClientObjectId).add(Arrays.asList(
+ tenantCityRolesResource.get(ClientRole.WRITE_USER.getValue()).toRepresentation(),
+ tenantCityRolesResource.get(ClientRole.READ_MAP.getValue()).toRepresentation(),
+ tenantCityRolesResource.get(ClientRole.READ_ASSETS.getValue()).toRepresentation(),
+ tenantCityRolesResource.get(ClientRole.READ_RULES.getValue()).toRepresentation()
));
LOG.info("Added demo user '" + testuser4.getUsername() + "' with password '" + testuser4Credentials.getValue() + "'");
}
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
index 6d6f2bc87..9e2646306 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
@@ -38,6 +38,7 @@ import org.openremote.model.simulator.element.SwitchSimulatorElement;
import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Values;
+import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@@ -90,8 +91,8 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
public String apartment2BathroomId;
public String apartment3LivingroomId;
public String masterRealm;
- public String realmATenant;
- public String realmBTenant;
+ public String realmBuildingTenant;
+ public String realmCityTenant;
public String smartCityServiceAgentId;
@@ -106,11 +107,11 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
KeycloakDemoSetup keycloakDemoSetup = setupService.getTaskOfType(KeycloakDemoSetup.class);
Tenant masterTenant = keycloakDemoSetup.masterTenant;
- Tenant realmATenant = keycloakDemoSetup.tenantA;
- Tenant realmBTenant = keycloakDemoSetup.tenantB;
+ Tenant tenantBuilding = keycloakDemoSetup.tenantBuilding;
+ Tenant tenantCity = keycloakDemoSetup.tenantCity;
masterRealm = masterTenant.getRealm();
- this.realmATenant = realmATenant.getRealm();
- this.realmBTenant = realmBTenant.getRealm();
+ this.realmBuildingTenant = tenantBuilding.getRealm();
+ this.realmCityTenant = tenantCity.getRealm();
// ################################ Demo assets for 'master' realm ###################################
@@ -378,12 +379,12 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
AttributeEvent.Source.SENSOR);
});
- // ################################ Demo assets for 'tenantA' realm ###################################
+ // ################################ Demo assets for 'building' realm ###################################
ObjectValue locationValueA = SMART_BUILDING_LOCATION.toValue();
Asset smartBuilding = new Asset();
- smartBuilding.setRealm(this.realmATenant);
+ smartBuilding.setRealm(this.realmBuildingTenant);
smartBuilding.setName("Smart Building");
smartBuilding.setType(BUILDING);
smartBuilding.addAttributes(
@@ -734,41 +735,41 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
// ################################ Link demo users and assets ###################################
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.testuser3Id,
apartment1Id));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.testuser3Id,
apartment1LivingroomId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.testuser3Id,
apartment1KitchenId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.testuser3Id,
apartment1Bedroom1Id));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.testuser3Id,
apartment1BathroomId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.testuser3Id,
apartment1HallwayId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.buildingUserId,
apartment1Id));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.buildingUserId,
apartment1LivingroomId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.buildingUserId,
apartment1KitchenId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.buildingUserId,
apartment1Bedroom1Id));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.buildingUserId,
apartment1BathroomId));
- assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantA.getRealm(),
+ assetStorageService.storeUserAsset(new UserAsset(keycloakDemoSetup.tenantBuilding.getRealm(),
keycloakDemoSetup.buildingUserId,
apartment1HallwayId));
@@ -782,12 +783,12 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
testuser3Config.setRestricted(true);
buildingUserConfig = identityService.mergeUserConfiguration(buildingUserConfig);
- // ################################ Realm B ###################################
+ // ################################ Realm smartcity ###################################
ObjectValue locationValueB = SMART_CITY_LOCATION.toValue();
Asset smartCity = new Asset();
- smartCity.setRealm(this.realmBTenant);
+ smartCity.setRealm(this.realmCityTenant);
smartCity.setName("Smart City");
smartCity.setType(BUILDING);
smartCity.addAttributes(
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
index c06a17cc7..cf59f6469 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/RulesDemoSetup.java
@@ -27,7 +27,7 @@ import org.openremote.model.rules.Ruleset;
import org.openremote.model.rules.TenantRuleset;
import java.io.InputStream;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.logging.Logger;
public class RulesDemoSetup extends AbstractManagerSetup {
@@ -39,7 +39,7 @@ public class RulesDemoSetup extends AbstractManagerSetup {
}
public Long apartmentActionsRulesetId;
- public Long tenantARulesetId;
+ public Long tenantBuildingRulesetId;
@Override
public void onStart() throws Exception {
@@ -53,35 +53,35 @@ public class RulesDemoSetup extends AbstractManagerSetup {
// Apartment 1
try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidencePresenceDetection.groovy")) {
- String rules = IOUtils.toString(inputStream, Charset.forName("utf-8"));
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
Ruleset ruleset = new AssetRuleset(
managerDemoSetup.apartment1Id, "Demo Residence - Presence Detection with motion and CO2 sensors", Ruleset.Lang.GROOVY, rules
);
apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
}
try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceVacationMode.groovy")) {
- String rules = IOUtils.toString(inputStream, Charset.forName("utf-8"));
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
Ruleset ruleset = new AssetRuleset(
managerDemoSetup.apartment1Id, "Demo Residence - Vacation Mode", Ruleset.Lang.GROOVY, rules
);
apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
}
try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceAutoVentilation.groovy")) {
- String rules = IOUtils.toString(inputStream, Charset.forName("utf-8"));
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
Ruleset ruleset = new AssetRuleset(
managerDemoSetup.apartment1Id, "Demo Residence - Auto Ventilation", Ruleset.Lang.GROOVY, rules
);
apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
}
try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceNotifyAlarmTrigger.groovy")) {
- String rules = IOUtils.toString(inputStream, Charset.forName("utf-8"));
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
Ruleset ruleset = new AssetRuleset(
managerDemoSetup.apartment1Id, "Demo Residence - Notify Alarm Trigger", Ruleset.Lang.GROOVY, rules
);
apartmentActionsRulesetId = rulesetStorageService.merge(ruleset).getId();
}
try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceSmartSwitch.groovy")) {
- String rules = IOUtils.toString(inputStream, Charset.forName("utf-8"));
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
Ruleset ruleset = new AssetRuleset(
managerDemoSetup.apartment1Id, "Demo Residence - Smart Start Switch", Ruleset.Lang.GROOVY, rules
);
@@ -90,7 +90,7 @@ public class RulesDemoSetup extends AbstractManagerSetup {
// Apartment 2
try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoResidenceAllLightsOff.js")) {
- String rules = IOUtils.toString(inputStream, Charset.forName("utf-8"));
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
Ruleset ruleset = new AssetRuleset(
managerDemoSetup.apartment2Id, "Demo Residence - All Lights Off", Ruleset.Lang.JAVASCRIPT, rules
);
@@ -98,11 +98,11 @@ public class RulesDemoSetup extends AbstractManagerSetup {
}
try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoConsoleLocation.groovy")) {
- String rules = IOUtils.toString(inputStream, Charset.forName("utf-8"));
+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
Ruleset ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantA.getRealm(), "Demo Console Location", Ruleset.Lang.GROOVY, rules
+ keycloakDemoSetup.tenantBuilding.getRealm(), "Demo Console Location", Ruleset.Lang.GROOVY, rules
).setAccessPublicRead(true);
- tenantARulesetId = rulesetStorageService.merge(ruleset).getId();
+ tenantBuildingRulesetId = rulesetStorageService.merge(ruleset).getId();
}
}
}
diff --git a/model/src/main/java/org/openremote/model/asset/Asset.java b/model/src/main/java/org/openremote/model/asset/Asset.java
index 0caa29bdd..7100ba639 100644
--- a/model/src/main/java/org/openremote/model/asset/Asset.java
+++ b/model/src/main/java/org/openremote/model/asset/Asset.java
@@ -96,8 +96,8 @@ import static org.openremote.model.attribute.AttributeType.LOCATION;
* "name": "Smart Building",
* "type": "urn:openremote:asset:building",
* "accessPublicRead": false,
- * "realm": "tenantA",
- * "realmDisplayName": "Tenant A",
+ * "realm": "building",
+ * "realmDisplayName": "Building",
* "path": [
* "0oI7Gf_kTh6WyRJFUTr8Lg"
* ],
@@ -119,8 +119,8 @@ import static org.openremote.model.attribute.AttributeType.LOCATION;
* "parentName": "Smart Building",
* "parentType": "urn:openremote:asset:building",
* "realm": "c38a3fdf-9d74-4dac-940c-50d3dce1d248",
- * "tenantRealm": "tenantA",
- * "tenantDisplayName": "Tenant A",
+ * "tenantRealm": "building",
+ * "tenantDisplayName": "Building",
* "path": [
* "B0x8ZOqZQHGjq_l0RxAJBA",
* "0oI7Gf_kTh6WyRJFUTr8Lg"
@@ -143,8 +143,8 @@ import static org.openremote.model.attribute.AttributeType.LOCATION;
* "parentName": "Apartment 1",
* "parentType": "urn:openremote:asset:residence",
* "realm": "c38a3fdf-9d74-4dac-940c-50d3dce1d248",
- * "tenantRealm": "tenantA",
- * "tenantDisplayName": "Tenant A",
+ * "tenantRealm": "building",
+ * "tenantDisplayName": "Building",
* "path": [
* "bzlRiJmSSMCl8HIUt9-lMg",
* "B0x8ZOqZQHGjq_l0RxAJBA",
@@ -168,8 +168,8 @@ import static org.openremote.model.attribute.AttributeType.LOCATION;
* "parentName": "Living Room",
* "parentType": "urn:openremote:asset:room",
* "realm": "c38a3fdf-9d74-4dac-940c-50d3dce1d248",
- * "tenantRealm": "tenantA",
- * "tenantDisplayName": "Tenant A",
+ * "tenantRealm": "building",
+ * "tenantDisplayName": "Building",
* "path": [
* "W7GV_lFeQVyHLlgHgE3dEQ",
* "bzlRiJmSSMCl8HIUt9-lMg",
diff --git a/profile/deploy.yml b/profile/deploy.yml
index e7129e963..8bd652899 100644
--- a/profile/deploy.yml
+++ b/profile/deploy.yml
@@ -49,7 +49,7 @@ services:
# PROXY_HOST_REDIRECT_1_NAME: www.my-console-master.tld
# PROXY_HOST_REDIRECT_1_TARGET: /console/master
# PROXY_HOST_REDIRECT_2_NAME: www.my-console-tenant-a.tld
- # PROXY_HOST_REDIRECT_2_TARGET: /console/tenantA
+ # PROXY_HOST_REDIRECT_2_TARGET: /console/building
# PROXY_HOST_REDIRECT_3_NAME: ...
# Customize proxy log, defaults to 'notice', requests are logged at 'info'.
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy
index 9cc6a55cb..47080d846 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetBrowserPresenterTest.groovy
@@ -164,11 +164,11 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContaine
assert rowData[0].icon == "group"
assert rowData[0].id == keycloakDemoSetup.masterTenant.realm
assert rowData[1] instanceof TenantTreeNode
- assert rowData[1].label == "Tenant A"
- assert rowData[1].id == keycloakDemoSetup.tenantA.realm
+ assert rowData[1].label == "Building"
+ assert rowData[1].id == keycloakDemoSetup.tenantBuilding.realm
assert rowData[2] instanceof TenantTreeNode
- assert rowData[2].label == "Tenant B"
- assert rowData[2].id == keycloakDemoSetup.tenantB.realm
+ assert rowData[2].label == "City"
+ assert rowData[2].id == keycloakDemoSetup.tenantCity.realm
}
1 * treeDisplay.setRowCount(3, true)
@@ -400,7 +400,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContaine
collectedSharedEvents.clear()
clientEventService.subscribe(
AssetTreeModifiedEvent.class,
- new TenantFilter(keycloakDemoSetup.tenantA.realm)
+ new TenantFilter(keycloakDemoSetup.tenantBuilding.realm)
)
then: "the server should return a failure"
@@ -427,7 +427,7 @@ class AssetBrowserPresenterTest extends Specification implements ManagerContaine
def keycloakDemoSetup = container.getService(SetupService.class).getTaskOfType(KeycloakDemoSetup.class)
and: "an authenticated user"
- def realm = keycloakDemoSetup.tenantA.realm
+ def realm = keycloakDemoSetup.tenantBuilding.realm
def accessToken = {
authenticate(
container,
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
index 42873f0f0..4e12dd5aa 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
@@ -94,7 +94,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the root assets of the given realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantA.realm))
+ .tenant(new TenantPredicate(keycloakDemoSetup.tenantBuilding.realm))
.parents(new ParentPredicate(true))
)
@@ -157,13 +157,13 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
testAsset.parentId == managerDemoSetup.groundFloorId
when: "an asset is moved to a foreign realm and made a root asset"
- testAsset.setRealm(keycloakDemoSetup.tenantA.realm)
+ testAsset.setRealm(keycloakDemoSetup.tenantBuilding.realm)
testAsset.setParentId(null)
assetResource.update(null, testAsset.id, testAsset)
testAsset = assetResource.get(null, testAsset.getId())
then: "the asset should be updated"
- testAsset.realm == keycloakDemoSetup.tenantA.realm
+ testAsset.realm == keycloakDemoSetup.tenantBuilding.realm
testAsset.parentId == null
when: "an asset is updated with a new parent in a foreign realm"
@@ -172,7 +172,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
testAsset = assetResource.get(null, testAsset.getId())
then: "the asset should be updated"
- testAsset.realm == keycloakDemoSetup.tenantA.realm
+ testAsset.realm == keycloakDemoSetup.tenantBuilding.realm
testAsset.parentId == managerDemoSetup.smartBuildingId
when: "an asset is deleted in the authenticated realm"
@@ -298,7 +298,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the root assets of the given realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantA.realm))
+ .tenant(new TenantPredicate(keycloakDemoSetup.tenantBuilding.realm))
.parents(new ParentPredicate(true))
)
@@ -349,7 +349,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
testAsset.parentId == managerDemoSetup.groundFloorId
when: "an asset is moved to a foreign realm and made a root asset"
- testAsset.setRealm(keycloakDemoSetup.tenantA.realm)
+ testAsset.setRealm(keycloakDemoSetup.tenantBuilding.realm)
testAsset.setParentId(null)
assetResource.update(null, testAsset.id, testAsset)
@@ -411,14 +411,14 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
and: "an authenticated test user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
).token
and: "the asset resource"
- def assetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm, accessToken).proxy(AssetResource.class)
+ def assetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
/* ############################################## READ ####################################### */
@@ -451,12 +451,12 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
then: "result should match"
assets.length == 1
assets[0].id == managerDemoSetup.smartBuildingId
- assets[0].realm == keycloakDemoSetup.tenantA.realm
+ assets[0].realm == keycloakDemoSetup.tenantBuilding.realm
when: "the root assets of the given realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantB.realm))
+ .tenant(new TenantPredicate(keycloakDemoSetup.tenantCity.realm))
.parents(new ParentPredicate(true))
)
@@ -505,7 +505,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
ex.response.status == 403
when: "an asset is created in the authenticated realm"
- testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.tenantA.realm)
+ testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.tenantBuilding.realm)
assetResource.create(null, testAsset)
then: "access should be forbidden"
@@ -555,14 +555,14 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
and: "an authenticated test user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
).token
and: "the asset resource"
- def assetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm, accessToken).proxy(AssetResource.class)
+ def assetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
/* ############################################## READ ####################################### */
@@ -575,7 +575,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
apartment1.id == managerDemoSetup.apartment1Id
apartment1.name == "Apartment 1"
apartment1.createdOn.getTime() < System.currentTimeMillis()
- apartment1.realm == keycloakDemoSetup.tenantA.realm
+ apartment1.realm == keycloakDemoSetup.tenantBuilding.realm
apartment1.type == AssetType.RESIDENCE.type
apartment1.parentId == managerDemoSetup.smartBuildingId
apartment1.path == null
@@ -623,7 +623,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
when: "the root assets of the given realm are retrieved"
assets = assetResource.queryAssets(null,
new AssetQuery()
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantB.realm))
+ .tenant(new TenantPredicate(keycloakDemoSetup.tenantCity.realm))
.parents(new ParentPredicate(true))
)
@@ -738,7 +738,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
assert testAsset.getName() == "Living Room"
when: "an asset is created in the authenticated realm"
- testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.tenantA.realm)
+ testAsset = new Asset("Test Room", AssetType.ROOM, null, keycloakDemoSetup.tenantBuilding.realm)
assetResource.create(null, testAsset)
then: "access should be forbidden"
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
index 8ba81c8c1..fa30d908f 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
@@ -220,7 +220,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
asset.parentId == managerDemoSetup.smartBuildingId
asset.parentName == null
asset.parentType == null
- asset.realm == keycloakDemoSetup.tenantA.realm
+ asset.realm == keycloakDemoSetup.tenantBuilding.realm
asset.path.length == 2
asset.path[0] == managerDemoSetup.apartment1Id
asset.path[1] == managerDemoSetup.smartBuildingId
@@ -326,7 +326,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
assets.get(0).parentId == managerDemoSetup.smartBuildingId
assets.get(0).parentName == "Smart Building"
assets.get(0).parentType == AssetType.BUILDING.type
- assets.get(0).realm == keycloakDemoSetup.tenantA.realm
+ assets.get(0).realm == keycloakDemoSetup.tenantBuilding.realm
assets.get(0).path == null
assets.get(0).attributesList.size() == 0
assets.get(1).id == managerDemoSetup.apartment2Id
@@ -337,7 +337,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(selectExcludePathAndAttributes())
.parents(new ParentPredicate(managerDemoSetup.smartBuildingId))
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantA.realm))
+ .tenant(new TenantPredicate(keycloakDemoSetup.tenantBuilding.realm))
)
then: "result should match"
@@ -351,7 +351,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
new AssetQuery()
.select(selectExcludePathAndAttributes())
.parents(new ParentPredicate(managerDemoSetup.smartBuildingId))
- .tenant(new TenantPredicate(keycloakDemoSetup.tenantA.realm))
+ .tenant(new TenantPredicate(keycloakDemoSetup.tenantBuilding.realm))
.orderBy(new OrderBy(NAME, true))
)
@@ -633,7 +633,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
asset.parentId != null
asset.parentName == "Apartment 1"
asset.parentType == AssetType.RESIDENCE.getType()
- asset.realm == keycloakDemoSetup.tenantA.realm
+ asset.realm == keycloakDemoSetup.tenantBuilding.realm
asset.path != null
asset.getAttributesList().size() == 3
asset.getAttribute("co2Level").isPresent()
@@ -660,7 +660,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
asset.parentId != null
asset.parentName == "Apartment 1"
asset.parentType == AssetType.RESIDENCE.getType()
- asset.realm == keycloakDemoSetup.tenantA.realm
+ asset.realm == keycloakDemoSetup.tenantBuilding.realm
asset.path != null
asset.getAttributesList().size() == 1
asset.getAttribute("co2Level").isPresent()
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
index 96d498066..2c73d2f7f 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetUserLinkingTest.groovy
@@ -48,12 +48,12 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
identityService.getIdentityProvider().isRestrictedUser(keycloakDemoSetup.testuser3Id)
when: "all user assets are retrieved of a realm"
- def userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantA.realm, null, null)
+ def userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, null, null)
then: "result should match"
userAssets.length == 12
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser3Id &&
it.id.assetId == managerDemoSetup.apartment1Id &&
it.assetName == "Apartment 1" &&
@@ -61,7 +61,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser3Id &&
it.id.assetId == managerDemoSetup.apartment1LivingroomId &&
it.assetName == "Living Room" &&
@@ -69,7 +69,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser3Id &&
it.id.assetId == managerDemoSetup.apartment1KitchenId &&
it.assetName == "Kitchen" &&
@@ -77,7 +77,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser3Id &&
it.id.assetId == managerDemoSetup.apartment1HallwayId &&
it.assetName == "Hallway" &&
@@ -85,7 +85,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser3Id &&
it.id.assetId == managerDemoSetup.apartment1Bedroom1Id &&
it.assetName == "Bedroom" &&
@@ -93,7 +93,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
it.userFullName == "testuser3 (DemoA3 DemoLast)"
}
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser3Id &&
it.id.assetId == managerDemoSetup.apartment1BathroomId &&
it.assetName == "Bathroom" &&
@@ -102,13 +102,13 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
}
when: "all user assets are retrieved of a realm and user"
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantA.realm, keycloakDemoSetup.testuser3Id, null)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser3Id, null)
then: "result should match"
userAssets.length == 6
when: "the realm and user don't match"
- assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantB.realm, keycloakDemoSetup.testuser3Id, null)
+ assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantCity.realm, keycloakDemoSetup.testuser3Id, null)
then: "an error response should be returned"
WebApplicationException ex = thrown()
@@ -122,12 +122,12 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
ex.response.status == 404
when: "all user assets are retrieved of a realm and user"
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantA.realm, null, managerDemoSetup.apartment1Id)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, null, managerDemoSetup.apartment1Id)
then: "result should match"
userAssets.length == 2
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser3Id &&
it.id.assetId == managerDemoSetup.apartment1Id &&
it.assetName == "Apartment 1" &&
@@ -136,12 +136,12 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
}
when: "all user assets are retrieved of a realm and user and asset"
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantA.realm, keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1Id)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser3Id, managerDemoSetup.apartment1Id)
then: "result should match"
userAssets.length == 1
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser3Id &&
it.id.assetId == managerDemoSetup.apartment1Id &&
it.assetName == "Apartment 1" &&
@@ -150,7 +150,7 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
}
when: "all user assets are retrieved of a realm and user and asset"
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantA.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment1Id)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment1Id)
then: "result should match"
userAssets.length == 0
@@ -158,14 +158,14 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
/* ############################################## WRITE ####################################### */
when: "an asset is linked to a user"
- UserAsset userAsset = new UserAsset(keycloakDemoSetup.tenantA.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment2Id)
+ UserAsset userAsset = new UserAsset(keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment2Id)
assetResource.createUserAsset(null, userAsset)
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantA.realm, keycloakDemoSetup.testuser2Id, null)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, null)
then: "result should match"
userAssets.length == 1
userAssets.any {
- it.id.realm == keycloakDemoSetup.tenantA.realm &&
+ it.id.realm == keycloakDemoSetup.tenantBuilding.realm &&
it.id.userId == keycloakDemoSetup.testuser2Id &&
it.id.assetId == managerDemoSetup.apartment2Id &&
it.assetName == "Apartment 2" &&
@@ -175,8 +175,8 @@ class AssetUserLinkingTest extends Specification implements ManagerContainerTrai
}
when: "an asset link is deleted"
- assetResource.deleteUserAsset(null, keycloakDemoSetup.tenantA.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment2Id)
- userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantA.realm, keycloakDemoSetup.testuser2Id, null)
+ assetResource.deleteUserAsset(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, managerDemoSetup.apartment2Id)
+ userAssets = assetResource.getUserAssetLinks(null, keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser2Id, null)
then: "result should match"
userAssets.length == 0
diff --git a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
index b4f7b4b91..ade0bfaad 100644
--- a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
@@ -97,36 +97,36 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
and: "the demo location predicate console rules are loaded"
Ruleset ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantA.realm,
- "Demo Tenant A - Console Location",
+ keycloakDemoSetup.tenantBuilding.realm,
+ "Demo Tenant Building - Console Location",
Ruleset.Lang.GROOVY,
getClass().getResource("/demo/rules/DemoConsoleLocation.groovy").text)
rulesetStorageService.merge(ruleset)
expect: "the rule engine to become available and be running"
conditions.eventually {
- def tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
- assert tenantAEngine != null
- assert tenantAEngine.isRunning()
- assert tenantAEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
+ def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ assert tenantBuildingEngine != null
+ assert tenantBuildingEngine.isRunning()
+ assert tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
}
and: "an authenticated user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
).token
and: "authenticated and anonymous console, rules and asset resources"
- def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm, accessToken).proxy(ConsoleResource.class)
- def authenticatedRulesResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm, accessToken).proxy(RulesResource.class)
- def authenticatedAssetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm, accessToken).proxy(AssetResource.class)
- def anonymousConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm).proxy(ConsoleResource.class)
- def anonymousRulesResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm).proxy(RulesResource.class)
- def anonymousAssetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm).proxy(AssetResource.class)
+ def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(ConsoleResource.class)
+ def authenticatedRulesResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
+ def authenticatedAssetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(AssetResource.class)
+ def anonymousConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm).proxy(ConsoleResource.class)
+ def anonymousRulesResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm).proxy(RulesResource.class)
+ def anonymousAssetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm).proxy(AssetResource.class)
when: "a console registers with an authenticated user"
def consoleRegistration = new ConsoleRegistration(null,
@@ -184,7 +184,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
}.orElse(null) == "23123213ad2313b0897efd"
and: "the console should have been linked to the authenticated user"
- def userAssets = assetStorageService.findUserAssets(keycloakDemoSetup.tenantA.realm, keycloakDemoSetup.testuser3Id, consoleId)
+ def userAssets = assetStorageService.findUserAssets(keycloakDemoSetup.tenantBuilding.realm, keycloakDemoSetup.testuser3Id, consoleId)
assert userAssets.size() == 1
assert userAssets.get(0).assetName == "Test Console"
@@ -411,10 +411,10 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert asset != null
assert asset.getAttribute(LOCATION.attributeName).flatMap { it.valueTimestamp }.orElse(Long.MIN_VALUE) > timestamp
assert notificationIds.size() == 1
- def tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
- assert tenantAEngine != null
- assert tenantAEngine.isRunning()
- assert !tenantAEngine.facts.getOptional("welcomeHome_${testUser3Console2.id}").isPresent()
+ def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ assert tenantBuildingEngine != null
+ assert tenantBuildingEngine.isRunning()
+ assert !tenantBuildingEngine.facts.getOptional("welcomeHome_${testUser3Console2.id}").isPresent()
}
when: "a console's location is updated to be at the Smart Building again"
diff --git a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
index 3f0ebc341..0605100da 100644
--- a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
@@ -78,7 +78,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
def consoleResource = (ConsoleResourceImpl)container.getService(WebService.class).getApiSingletons().find {it instanceof ConsoleResourceImpl}
and: "an authenticated test user"
- def realm = keycloakDemoSetup.tenantA.realm
+ def realm = keycloakDemoSetup.tenantBuilding.realm
def testuser1AccessToken = authenticate(
container,
MASTER_REALM,
@@ -125,7 +125,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
def testuser2NotificationResource = getClientApiTarget(serverUri(serverPort), realm, testuser2AccessToken).proxy(NotificationResource.class)
def testuser3NotificationResource = getClientApiTarget(serverUri(serverPort), realm, testuser3AccessToken).proxy(NotificationResource.class)
def adminNotificationResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, adminAccessToken).proxy(NotificationResource.class)
- def anonymousNotificationResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm).proxy(NotificationResource.class)
+ def anonymousNotificationResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm).proxy(NotificationResource.class)
def testuser1ConsoleResource = getClientApiTarget(serverUri(serverPort), MASTER_REALM, testuser1AccessToken).proxy(ConsoleResource.class)
def testuser2ConsoleResource = getClientApiTarget(serverUri(serverPort), realm, testuser2AccessToken).proxy(ConsoleResource.class)
def testuser3ConsoleResource = getClientApiTarget(serverUri(serverPort), realm, testuser3AccessToken).proxy(ConsoleResource.class)
@@ -175,7 +175,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
anonymousConsole.id != null
when: "the admin user sends a push notification to an entire realm"
- notification.targets = new Notification.Targets(Notification.TargetType.TENANT, keycloakDemoSetup.tenantA.realm)
+ notification.targets = new Notification.Targets(Notification.TargetType.TENANT, keycloakDemoSetup.tenantBuilding.realm)
adminNotificationResource.sendNotification(null, notification)
then: "all consoles in that realm should have been sent a notification"
@@ -225,7 +225,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
ex = thrown()
ex.response.status == 403
- when: "the admin user sends a push notification to the console assets in tenantA realm"
+ when: "the admin user sends a push notification to the console assets in building realm"
notification.targets = new Notification.Targets(Notification.TargetType.ASSET,
testuser2Console.id,
testuser3Console1.id,
@@ -295,7 +295,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
// Check notification resource
// -----------------------------------------------
- when: "the admin user requests the notifications for Tenant A consoles"
+ when: "the admin user requests the notifications for Building consoles"
def notifications = []
notifications.addAll(adminNotificationResource.getNotifications(null, null, null, null, null, null, null, testuser2Console.id))
notifications.addAll(adminNotificationResource.getNotifications(null, null, null, null, null, null, null, testuser3Console1.id))
@@ -312,7 +312,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
n.acknowledgedOn == null
} == 19
- when: "the admin user marks a Tenant A console notification as delivered and requests the notifications for Tenant A consoles"
+ when: "the admin user marks a Building console notification as delivered and requests the notifications for Building consoles"
adminNotificationResource.notificationDelivered(null, testuser2Console.id, notifications.find {n -> n.targetId == testuser2Console.id}.id)
notifications = []
notifications.addAll(adminNotificationResource.getNotifications(null, null, null, null, null, null, null, testuser2Console.id))
@@ -324,7 +324,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
assert notifications.size() == 19
assert notifications.count {n -> n.deliveredOn != null} == 1
- when: "the admin user marks a Tenant A console notification as delivered and requests the notifications for Tenant A consoles"
+ when: "the admin user marks a Building console notification as delivered and requests the notifications for Building consoles"
adminNotificationResource.notificationAcknowledged(null, testuser2Console.id, notifications.find {n -> n.targetId == testuser2Console.id && n.deliveredOn != null}.id, Values.create("dismissed"))
notifications = []
notifications.addAll(adminNotificationResource.getNotifications(null, null, null, null, null, null, null, testuser2Console.id))
@@ -577,8 +577,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
def notification = new Notification(
"Test",
new EmailNotificationMessage().setSubject("Test").setText("Hello world!"),
- new Notification.Targets(Notification.TargetType.TENANT, managerDemoSetup.realmATenant), null, null)
- notificationService.sendNotification(notification, Notification.Source.TENANT_RULESET, managerDemoSetup.realmATenant)
+ new Notification.Targets(Notification.TargetType.TENANT, managerDemoSetup.realmBuildingTenant), null, null)
+ notificationService.sendNotification(notification, Notification.Source.TENANT_RULESET, managerDemoSetup.realmBuildingTenant)
then: "the email should have been sent to all tenant users"
conditions.eventually {
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
index e7ae35083..6b62d619a 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesDeploymentTest.groovy
@@ -74,71 +74,71 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
assert rulesService.globalEngine.deployments.values().any({ it.name == "Some more global rules" && it.status == DEPLOYED})
}
- when: "a new tenant rule definition is added to Tenant A"
+ when: "a new tenant rule definition is added to Building"
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantA.realm,
- "Some more tenantA tenant rules",
+ keycloakDemoSetup.tenantBuilding.realm,
+ "Some more building tenant rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy").text)
rulesetStorageService.merge(ruleset)
- then: "Tenant A rules engine should load this definition and restart successfully"
+ then: "Building rules engine should load this definition and restart successfully"
conditions.eventually {
- def tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
- assert tenantAEngine != null
- assert tenantAEngine.isRunning()
- assert tenantAEngine.deployments.size() == 2
- assert tenantAEngine.deployments.values().any({ it.name == "Some tenantA tenant demo rules" && it.status == DEPLOYED})
- assert tenantAEngine.deployments.values().any({ it.name == "Some more tenantA tenant rules" && it.status == DEPLOYED})
+ def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ assert tenantBuildingEngine != null
+ assert tenantBuildingEngine.isRunning()
+ assert tenantBuildingEngine.deployments.size() == 2
+ assert tenantBuildingEngine.deployments.values().any({ it.name == "Some building tenant demo rules" && it.status == DEPLOYED})
+ assert tenantBuildingEngine.deployments.values().any({ it.name == "Some more building tenant rules" && it.status == DEPLOYED})
}
- when: "a new tenant rule definition is added to Tenant B"
+ when: "a new tenant rule definition is added to City"
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantB.realm,
- "Some more tenantB tenant rules",
+ keycloakDemoSetup.tenantCity.realm,
+ "Some more smartcity tenant rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates2.groovy").text)
rulesetStorageService.merge(ruleset)
- then: "a tenant rules engine should be created for Tenant B and load this definition and start successfully"
+ then: "a tenant rules engine should be created for City and load this definition and start successfully"
conditions.eventually {
- def tenantBEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantB.realm)
+ def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
assert rulesService.tenantEngines.size() == 3
- assert tenantBEngine != null
- assert tenantBEngine.isRunning()
- assert tenantBEngine.deployments.size() == 1
- assert tenantBEngine.deployments.values().any({ it.name == "Some more tenantB tenant rules" && it.status == DEPLOYED})
+ assert tenantCity != null
+ assert tenantCity.isRunning()
+ assert tenantCity.deployments.size() == 1
+ assert tenantCity.deployments.values().any({ it.name == "Some more smartcity tenant rules" && it.status == DEPLOYED})
}
when: "the disabled rule definition for Tenant B is enabled"
- ruleset = rulesetStorageService.find(TenantRuleset.class, rulesImport.tenantBRulesetId)
+ ruleset = rulesetStorageService.find(TenantRuleset.class, rulesImport.tenantCityRulesetId)
ruleset.setEnabled(true)
rulesetStorageService.merge(ruleset)
- then: "Tenant B rule engine should load this definition and restart successfully"
+ then: "City rule engine should load this definition and restart successfully"
conditions.eventually {
- def tenantBEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantB.realm)
+ def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
assert rulesService.tenantEngines.size() == 3
- assert tenantBEngine != null
- assert tenantBEngine.isRunning()
- assert tenantBEngine.deployments.size() == 2
- assert tenantBEngine.deployments.values().any({ it.name == "Some more tenantB tenant rules" && it.status == DEPLOYED})
- assert tenantBEngine.deployments.values().any({ it.name == "Some tenantB tenant demo rules" && it.status == DEPLOYED})
+ assert tenantCity != null
+ assert tenantCity.isRunning()
+ assert tenantCity.deployments.size() == 2
+ assert tenantCity.deployments.values().any({ it.name == "Some more smartcity tenant rules" && it.status == DEPLOYED})
+ assert tenantCity.deployments.values().any({ it.name == "Some smartcity tenant demo rules" && it.status == DEPLOYED})
}
- when: "the enabled rule definition for Tenant B is disabled"
+ when: "the enabled rule definition for City is disabled"
// TODO: Stop instances of rule definitions being passed around as rules engine nulls the rules property
- ruleset = rulesetStorageService.find(TenantRuleset.class, rulesImport.tenantBRulesetId)
+ ruleset = rulesetStorageService.find(TenantRuleset.class, rulesImport.tenantCityRulesetId)
ruleset.setEnabled(false)
rulesetStorageService.merge(ruleset)
- then: "Tenant B rule engine should remove it again"
+ then: "City rule engine should remove it again"
conditions.eventually {
- def tenantBEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantB.realm)
- assert tenantBEngine != null
- assert tenantBEngine.isRunning()
- assert tenantBEngine.deployments.size() == 1
- assert tenantBEngine.deployments.values().any({ it.name == "Some more tenantB tenant rules" && it.status == DEPLOYED})
+ def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
+ assert tenantCity != null
+ assert tenantCity.isRunning()
+ assert tenantCity.deployments.size() == 1
+ assert tenantCity.deployments.values().any({ it.name == "Some more smartcity tenant rules" && it.status == DEPLOYED})
}
when: "the asset rule definition for apartment 2 is deleted"
@@ -185,17 +185,17 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
}
when: "a tenant is disabled"
- def tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
+ def tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
def apartment3Engine = rulesService.assetEngines.get(managerDemoSetup.apartment3Id)
- def tenantATenant = keycloakDemoSetup.tenantA
- tenantATenant.setEnabled(false)
- identityService.getIdentityProvider().updateTenant(new ClientRequestInfo(null, accessToken), tenantATenant.getRealm(), tenantATenant)
+ def tenantBuildingTenant = keycloakDemoSetup.tenantBuilding
+ tenantBuildingTenant.setEnabled(false)
+ identityService.getIdentityProvider().updateTenant(new ClientRequestInfo(null, accessToken), tenantBuildingTenant.getRealm(), tenantBuildingTenant)
then: "the tenants rule engine should stop and all asset rule engines in this realm should also stop"
conditions.eventually {
- assert !tenantAEngine.isRunning()
- assert tenantAEngine.deployments.size() == 2
- assert rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm) == null
+ assert !tenantBuildingEngine.isRunning()
+ assert tenantBuildingEngine.deployments.size() == 2
+ assert rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm) == null
assert !apartment3Engine.isRunning()
assert apartment3Engine.deployments.size() == 1
assert rulesService.assetEngines.get(managerDemoSetup.apartment3Id) == null
@@ -206,35 +206,35 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
assert rulesService.tenantEngines.size() == 2
assert rulesService.assetEngines.size() == 1
def masterEngine = rulesService.tenantEngines.get(keycloakDemoSetup.masterTenant.realm)
- def tenantBEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantB.realm)
+ def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
assert masterEngine != null
assert masterEngine.isRunning()
- assert tenantBEngine != null
- assert tenantBEngine.isRunning()
+ assert tenantCity != null
+ assert tenantCity.isRunning()
}
when: "the disabled tenant is re-enabled"
- tenantATenant.setEnabled(true)
- identityService.getIdentityProvider().updateTenant(new ClientRequestInfo(null, accessToken), tenantATenant.getRealm(), tenantATenant)
+ tenantBuildingTenant.setEnabled(true)
+ identityService.getIdentityProvider().updateTenant(new ClientRequestInfo(null, accessToken), tenantBuildingTenant.getRealm(), tenantBuildingTenant)
then: "the tenants rule engine should start and all asset rule engines from this realm should also start"
conditions.eventually {
- tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
apartment3Engine = rulesService.assetEngines.get(managerDemoSetup.apartment3Id)
assert rulesService.tenantEngines.size() == 3
assert rulesService.assetEngines.size() == 2
- assert tenantAEngine != null
- assert tenantAEngine.isRunning()
- assert tenantAEngine.deployments.size() == 2
- assert tenantAEngine.deployments.values().any({ it.name == "Some tenantA tenant demo rules" && it.status == DEPLOYED})
- assert tenantAEngine.deployments.values().any({ it.name == "Some more tenantA tenant rules" && it.status == DEPLOYED})
+ assert tenantBuildingEngine != null
+ assert tenantBuildingEngine.isRunning()
+ assert tenantBuildingEngine.deployments.size() == 2
+ assert tenantBuildingEngine.deployments.values().any({ it.name == "Some building tenant demo rules" && it.status == DEPLOYED})
+ assert tenantBuildingEngine.deployments.values().any({ it.name == "Some more building tenant rules" && it.status == DEPLOYED})
assert apartment3Engine.deployments.size() == 1
assert apartment3Engine.deployments.values().any({ it.name == "Some apartment 3 demo rules" && it.status == DEPLOYED})
}
- when: "a new tenant rule definition is added to Tenant A"
+ when: "a new tenant rule definition is added to Building"
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
"Throw Failure Exception",
GROOVY,
getClass().getResource("/org/openremote/test/failure/RulesFailureActionThrowsException.groovy").text)
@@ -243,17 +243,17 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "the tenants A rule engine should run with one deployment as error"
conditions.eventually {
- tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
- assert tenantAEngine != null
- assert tenantAEngine.isRunning()
- assert tenantAEngine.deployments.size() == 3
- assert tenantAEngine.deployments[ruleset.id].status == EXECUTION_ERROR
- assert !tenantAEngine.isError()
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ assert tenantBuildingEngine != null
+ assert tenantBuildingEngine.isRunning()
+ assert tenantBuildingEngine.deployments.size() == 3
+ assert tenantBuildingEngine.deployments[ruleset.id].status == EXECUTION_ERROR
+ assert !tenantBuildingEngine.isError()
}
- when: "a new tenant rule definition is added to Tenant A"
+ when: "a new tenant rule definition is added to Building"
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
"Looping error",
GROOVY,
getClass().getResource("/org/openremote/test/failure/RulesFailureLoop.groovy").text)
@@ -262,26 +262,26 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
then: "the tenants A rule engine should have an error"
conditions.eventually {
- tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
- assert tenantAEngine != null
- assert !tenantAEngine.isRunning()
- assert tenantAEngine.deployments.size() == 4
- assert tenantAEngine.deployments[ruleset.id].status == LOOP_ERROR
- assert tenantAEngine.deployments[ruleset.id].error instanceof RulesLoopException
- assert tenantAEngine.deployments[ruleset.id].error.message == "Possible rules loop detected, exceeded max trigger count of " + RulesFacts.MAX_RULES_TRIGGERED_PER_EXECUTION + " for rule: Condition loops"
- assert tenantAEngine.isError()
- assert tenantAEngine.getError() instanceof RuntimeException
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ assert tenantBuildingEngine != null
+ assert !tenantBuildingEngine.isRunning()
+ assert tenantBuildingEngine.deployments.size() == 4
+ assert tenantBuildingEngine.deployments[ruleset.id].status == LOOP_ERROR
+ assert tenantBuildingEngine.deployments[ruleset.id].error instanceof RulesLoopException
+ assert tenantBuildingEngine.deployments[ruleset.id].error.message == "Possible rules loop detected, exceeded max trigger count of " + RulesFacts.MAX_RULES_TRIGGERED_PER_EXECUTION + " for rule: Condition loops"
+ assert tenantBuildingEngine.isError()
+ assert tenantBuildingEngine.getError() instanceof RuntimeException
}
//TODO: Reinstate the tenant delete test once tenant delete mechanism is finalised
// when: "a tenant is deleted"
-// identityService.deleteTenant(accessToken, tenantATenant.getRealm())
+// identityService.deleteTenant(accessToken, tenantBuildingTenant.getRealm())
//
// then: "the tenants rule engine should stop and all asset rule engines in this realm should also stop"
// conditions.eventually {
-// assert tenantAEngine.isRunning() == false
-// assert tenantAEngine.allRulesets.length == 0
-// assert rulesService.tenantEngines.get(keycloakDemoSetup.tenantATenant.id) == null
+// assert tenantBuildingEngine.isRunning() == false
+// assert tenantBuildingEngine.allRulesets.length == 0
+// assert rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuildingTenant.id) == null
// assert smartHomeEngine.isRunning() == false
// assert smartHomeEngine.allRulesets.length == 0
// assert rulesService.assetEngines.get(managerDemoSetup.smartBuildingId) == null
@@ -295,11 +295,11 @@ class BasicRulesDeploymentTest extends Specification implements ManagerContainer
// assert rulesService.tenantEngines.size() == 2
// assert rulesService.assetEngines.size() == 0
// def masterEngine = rulesService.tenantEngines.get(Constants.MASTER_REALM)
-// def tenantBEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBTenant.id)
+// def tenantCity = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBTenant.id)
// assert masterEngine != null
// assert masterEngine.isRunning()
-// assert tenantBEngine != null
-// assert tenantBEngine.isRunning()
+// assert tenantCity != null
+// assert tenantCity.isRunning()
// }
cleanup: "the server should be stopped"
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesImport.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesImport.groovy
index d4cebb018..0d82a4e74 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesImport.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesImport.groovy
@@ -19,15 +19,15 @@ class BasicRulesImport {
final Long globalRulesetId
final Long globalRuleset2Id
final Long masterRulesetId
- final Long tenantARulesetId
- final Long tenantBRulesetId
+ final Long tenantBuildingRulesetId
+ final Long tenantCityRulesetId
final Long apartment1RulesetId
final Long apartment2RulesetId
final Long apartment3RulesetId
RulesEngine globalEngine
RulesEngine masterEngine
- RulesEngine tenantAEngine
+ RulesEngine tenantBuildingEngine
RulesEngine apartment1Engine
RulesEngine apartment2Engine
RulesEngine apartment3Engine
@@ -55,19 +55,19 @@ class BasicRulesImport {
masterRulesetId = rulesetStorageService.merge(ruleset).id
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantA.realm,
- "Some tenantA tenant demo rules",
+ keycloakDemoSetup.tenantBuilding.realm,
+ "Some building tenant demo rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text)
- tenantARulesetId = rulesetStorageService.merge(ruleset).id
+ tenantBuildingRulesetId = rulesetStorageService.merge(ruleset).id
ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantB.realm,
- "Some tenantB tenant demo rules",
+ keycloakDemoSetup.tenantCity.realm,
+ "Some smartcity tenant demo rules",
GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicMatchAllAssetStates.groovy").text)
ruleset.setEnabled(false)
- tenantBRulesetId = rulesetStorageService.merge(ruleset).id
+ tenantCityRulesetId = rulesetStorageService.merge(ruleset).id
ruleset = new AssetRuleset(
managerDemoSetup.apartment1Id,
@@ -112,15 +112,15 @@ class BasicRulesImport {
assert masterEngine.deployments.size() == 1
assert masterEngine.deployments.values().iterator().next().name == "Some master tenant demo rules"
assert masterEngine.deployments.values().iterator().next().status == DEPLOYED
- tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
- assert tenantAEngine != null
- tenantAEngine.disableTemporaryFactExpiration = true
- assert tenantAEngine.isRunning()
- assert tenantAEngine.deployments.size() == 1
- assert tenantAEngine.deployments.values().iterator().next().name == "Some tenantA tenant demo rules"
- assert tenantAEngine.deployments.values().iterator().next().status == DEPLOYED
- def tenantBEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantB.realm)
- assert tenantBEngine == null
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ assert tenantBuildingEngine != null
+ tenantBuildingEngine.disableTemporaryFactExpiration = true
+ assert tenantBuildingEngine.isRunning()
+ assert tenantBuildingEngine.deployments.size() == 1
+ assert tenantBuildingEngine.deployments.values().iterator().next().name == "Some building tenant demo rules"
+ assert tenantBuildingEngine.deployments.values().iterator().next().status == DEPLOYED
+ def tenantCityEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantCity.realm)
+ assert tenantCityEngine == null
assert rulesService.assetEngines.size() == 3
apartment1Engine = rulesService.assetEngines.get(managerDemoSetup.apartment1Id)
@@ -145,7 +145,7 @@ class BasicRulesImport {
void resetRulesFired(RulesEngine... engine) {
// Remove all named facts (those are the only ones inserted by basic test rules)
- Collection<RulesEngine> engines = [globalEngine, masterEngine, tenantAEngine, apartment2Engine, apartment3Engine]
+ Collection<RulesEngine> engines = [globalEngine, masterEngine, tenantBuildingEngine, apartment2Engine, apartment3Engine]
engines.addAll(engine)
engines.forEach({ e ->
e.facts.namedFacts.keySet().forEach({ factName ->
@@ -155,7 +155,7 @@ class BasicRulesImport {
}
void assertNoRulesFired(RulesEngine... engine) {
- Collection<RulesEngine> engines = [globalEngine, masterEngine, tenantAEngine, apartment2Engine, apartment3Engine]
+ Collection<RulesEngine> engines = [globalEngine, masterEngine, tenantBuildingEngine, apartment2Engine, apartment3Engine]
engines.addAll(engine)
engines.forEach({ e ->
assert e.facts.namedFacts.size() == 0
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
index e6d17cae2..59c296beb 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
@@ -56,7 +56,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL
assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL
assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE
- assert rulesImport.tenantAEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2
assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3
}
@@ -86,8 +86,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
assert smartHomeEngine.assetStates.size() == DEMO_RULE_STATES_SMART_BUILDING
assertRulesFired(rulesImport.globalEngine, 1)
assertRulesFired(rulesImport.globalEngine, ["All"])
- assertRulesFired(rulesImport.tenantAEngine, 1)
- assertRulesFired(rulesImport.tenantAEngine, ["All"])
+ assertRulesFired(rulesImport.tenantBuildingEngine, 1)
+ assertRulesFired(rulesImport.tenantBuildingEngine, ["All"])
assertRulesFired(rulesImport.apartment2Engine, 1)
assertRulesFired(rulesImport.apartment2Engine, ["All"])
assertRulesFired(rulesImport.apartment3Engine, 0)
@@ -106,8 +106,8 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
conditions.eventually {
assertRulesFired(rulesImport.globalEngine, 1)
assertRulesFired(rulesImport.globalEngine, ["All"])
- assertRulesFired(rulesImport.tenantAEngine, 1)
- assertRulesFired(rulesImport.tenantAEngine, ["All"])
+ assertRulesFired(rulesImport.tenantBuildingEngine, 1)
+ assertRulesFired(rulesImport.tenantBuildingEngine, ["All"])
assertRulesFired(rulesImport.apartment2Engine, 1)
assertRulesFired(rulesImport.apartment2Engine, ["All"])
assertRulesFired(rulesImport.apartment3Engine, 0)
@@ -145,7 +145,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
rulesImport.resetRulesFired()
def apartment2 = assetStorageService.find(managerDemoSetup.apartment2Id)
def asset = new Asset("Kitchen", AssetType.ROOM, apartment2)
- asset.setRealm(keycloakDemoSetup.tenantA.getRealm())
+ asset.setRealm(keycloakDemoSetup.tenantBuilding.getRealm())
def attributes = [
new AssetAttribute("testString", AttributeValueType.STRING, Values.create("test"))
.setMeta(
@@ -160,7 +160,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
conditions.eventually {
assert rulesImport.globalEngine.lastFireTimestamp > 0
assert rulesImport.masterEngine.lastFireTimestamp > 0
- assert rulesImport.tenantAEngine.lastFireTimestamp > 0
+ assert rulesImport.tenantBuildingEngine.lastFireTimestamp > 0
assert rulesImport.apartment2Engine.lastFireTimestamp > 0
assert rulesImport.apartment3Engine.lastFireTimestamp > 0
}
@@ -170,15 +170,15 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 1
assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 1
assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE
- assert rulesImport.tenantAEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A + 1
+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A + 1
assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2 + 1
assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3
assertRulesFired(rulesImport.globalEngine, 1)
assertRulesFired(rulesImport.globalEngine, ["All"])
assertRulesFired(rulesImport.masterEngine, 1)
assertRulesFired(rulesImport.masterEngine, ["All"])
- assertRulesFired(rulesImport.tenantAEngine, 1)
- assertRulesFired(rulesImport.tenantAEngine, ["All"])
+ assertRulesFired(rulesImport.tenantBuildingEngine, 1)
+ assertRulesFired(rulesImport.tenantBuildingEngine, ["All"])
assertRulesFired(rulesImport.apartment2Engine, 1)
assertRulesFired(rulesImport.apartment2Engine, ["All"])
assertRulesFired(rulesImport.apartment3Engine, 0)
@@ -187,7 +187,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
when: "an attribute event is pushed into the system for an attribute with no RULE_STATE meta"
def globalLastFireTimestamp = rulesImport.globalEngine.lastFireTimestamp
def masterLastFireTimestamp = rulesImport.masterEngine.lastFireTimestamp
- def tenantALastFireTimestamp = rulesImport.tenantAEngine.lastFireTimestamp
+ def tenantALastFireTimestamp = rulesImport.tenantBuildingEngine.lastFireTimestamp
def apartment2LastFireTimestamp = rulesImport.apartment2Engine.lastFireTimestamp
def apartment3LastFireTimestamp = rulesImport.apartment3Engine.lastFireTimestamp
def apartment2LivingRoomWindowOpenChange = new AttributeEvent(
@@ -205,7 +205,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
conditions.eventually {
assert rulesImport.globalEngine.lastFireTimestamp == globalLastFireTimestamp
assert rulesImport.masterEngine.lastFireTimestamp == masterLastFireTimestamp
- assert rulesImport.tenantAEngine.lastFireTimestamp == tenantALastFireTimestamp
+ assert rulesImport.tenantBuildingEngine.lastFireTimestamp == tenantALastFireTimestamp
assert rulesImport.apartment2Engine.lastFireTimestamp == apartment2LastFireTimestamp
assert rulesImport.apartment3Engine.lastFireTimestamp == apartment3LastFireTimestamp
}
@@ -213,7 +213,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
when: "the Kitchen room asset is modified to add a new attribute but RULE_STATE = true meta is not changed"
globalLastFireTimestamp = rulesImport.globalEngine.lastFireTimestamp
masterLastFireTimestamp = rulesImport.masterEngine.lastFireTimestamp
- tenantALastFireTimestamp = rulesImport.tenantAEngine.lastFireTimestamp
+ tenantALastFireTimestamp = rulesImport.tenantBuildingEngine.lastFireTimestamp
apartment2LastFireTimestamp = rulesImport.apartment2Engine.lastFireTimestamp
apartment3LastFireTimestamp = rulesImport.apartment3Engine.lastFireTimestamp
attributes = [
@@ -230,7 +230,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
conditions.eventually {
assert rulesImport.globalEngine.lastFireTimestamp > globalLastFireTimestamp
assert rulesImport.masterEngine.lastFireTimestamp == masterLastFireTimestamp
- assert rulesImport.tenantAEngine.lastFireTimestamp > tenantALastFireTimestamp
+ assert rulesImport.tenantBuildingEngine.lastFireTimestamp > tenantALastFireTimestamp
assert rulesImport.apartment2Engine.lastFireTimestamp > apartment2LastFireTimestamp
assert rulesImport.apartment3Engine.lastFireTimestamp == apartment3LastFireTimestamp
}
@@ -240,12 +240,12 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 1
assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 1
assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE
- assert rulesImport.tenantAEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A + 1
+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A + 1
assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2 + 1
assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3
assertRulesFired(rulesImport.globalEngine, 1)
assertRulesFired(rulesImport.masterEngine, 1)
- assertRulesFired(rulesImport.tenantAEngine, 1)
+ assertRulesFired(rulesImport.tenantBuildingEngine, 1)
assertRulesFired(rulesImport.apartment2Engine, 1)
assertRulesFired(rulesImport.apartment3Engine, 0)
}
@@ -267,13 +267,13 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL
assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL
assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE
- assert rulesImport.tenantAEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2
assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3
assertRulesFired(rulesImport.globalEngine, 1)
assertRulesFired(rulesImport.globalEngine, ["All"])
- assertRulesFired(rulesImport.tenantAEngine, 1)
- assertRulesFired(rulesImport.tenantAEngine, ["All"])
+ assertRulesFired(rulesImport.tenantBuildingEngine, 1)
+ assertRulesFired(rulesImport.tenantBuildingEngine, ["All"])
assertRulesFired(rulesImport.apartment2Engine, 1)
assertRulesFired(rulesImport.apartment2Engine, ["All"])
assertRulesFired(rulesImport.apartment3Engine, 0)
@@ -299,13 +299,13 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 2
assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL + 2
assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE
- assert rulesImport.tenantAEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A + 2
+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A + 2
assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2 + 2
assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3
assertRulesFired(rulesImport.globalEngine, 1)
assertRulesFired(rulesImport.globalEngine, ["All"])
- assertRulesFired(rulesImport.tenantAEngine, 1)
- assertRulesFired(rulesImport.tenantAEngine, ["All"])
+ assertRulesFired(rulesImport.tenantBuildingEngine, 1)
+ assertRulesFired(rulesImport.tenantBuildingEngine, ["All"])
assertRulesFired(rulesImport.apartment2Engine, 1)
assertRulesFired(rulesImport.apartment2Engine, ["All"])
assertRulesFired(rulesImport.apartment3Engine, 0)
@@ -320,13 +320,13 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
assert rulesService.assetStates.size() == DEMO_RULE_STATES_GLOBAL
assert rulesImport.globalEngine.assetStates.size() == DEMO_RULE_STATES_GLOBAL
assert rulesImport.masterEngine.assetStates.size() == DEMO_RULE_STATES_SMART_OFFICE
- assert rulesImport.tenantAEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
+ assert rulesImport.tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
assert rulesImport.apartment2Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_2
assert rulesImport.apartment3Engine.assetStates.size() == DEMO_RULE_STATES_APARTMENT_3
assertRulesFired(rulesImport.globalEngine, 1)
assertRulesFired(rulesImport.globalEngine, ["All"])
- assertRulesFired(rulesImport.tenantAEngine, 1)
- assertRulesFired(rulesImport.tenantAEngine, ["All"])
+ assertRulesFired(rulesImport.tenantBuildingEngine, 1)
+ assertRulesFired(rulesImport.tenantBuildingEngine, ["All"])
assertRulesFired(rulesImport.apartment2Engine, 1)
assertRulesFired(rulesImport.apartment2Engine, ["All"])
assertRulesFired(rulesImport.apartment3Engine, 0)
@@ -358,22 +358,22 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
rulesImport.assertEnginesReady(rulesService, keycloakDemoSetup, managerDemoSetup)
}
- when: "a broken RHS rule is loaded into the tenantA engine"
+ when: "a broken RHS rule is loaded into the building engine"
def ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
"Some broken test rules",
Ruleset.Lang.GROOVY,
getClass().getResource("/org/openremote/test/rules/BasicBrokenRules.groovy").text)
rulesetStorageService.merge(ruleset)
- then: "the tenantA engine should not run and the rule engine status should indicate the issue"
+ then: "the building engine should not run and the rule engine status should indicate the issue"
conditions.eventually {
- assert rulesImport.tenantAEngine.deployments.size() == 2
- assert !rulesImport.tenantAEngine.running
- assert rulesImport.tenantAEngine.deployments.values().any({
- it.name == "Some tenantA tenant demo rules" && it.status == READY
+ assert rulesImport.tenantBuildingEngine.deployments.size() == 2
+ assert !rulesImport.tenantBuildingEngine.running
+ assert rulesImport.tenantBuildingEngine.deployments.values().any({
+ it.name == "Some building tenant demo rules" && it.status == READY
})
- assert rulesImport.tenantAEngine.deployments.values().any({
+ assert rulesImport.tenantBuildingEngine.deployments.values().any({
it.name == "Some broken test rules" && it.status == COMPILATION_ERROR && it.error instanceof RuntimeException
})
}
@@ -381,7 +381,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
when: "an attribute event occurs"
def globalLastFireTimestamp = rulesImport.globalEngine.lastFireTimestamp
def masterLastFireTimestamp = rulesImport.masterEngine.lastFireTimestamp
- def tenantALastFireTimestamp = rulesImport.tenantAEngine.lastFireTimestamp
+ def tenantALastFireTimestamp = rulesImport.tenantBuildingEngine.lastFireTimestamp
def apartment2LastFireTimestamp = rulesImport.apartment2Engine.lastFireTimestamp
def apartment3LastFireTimestamp = rulesImport.apartment3Engine.lastFireTimestamp
def apartment2LivingRoomPresenceDetectedChange = new AttributeEvent(
@@ -393,7 +393,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
conditions.eventually {
assert rulesImport.globalEngine.lastFireTimestamp > globalLastFireTimestamp
assert rulesImport.masterEngine.lastFireTimestamp > masterLastFireTimestamp
- assert rulesImport.tenantAEngine.lastFireTimestamp == tenantALastFireTimestamp
+ assert rulesImport.tenantBuildingEngine.lastFireTimestamp == tenantALastFireTimestamp
assert rulesImport.apartment2Engine.lastFireTimestamp > apartment2LastFireTimestamp
assert rulesImport.apartment3Engine.lastFireTimestamp > apartment3LastFireTimestamp
}
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
index 572765e5b..564fd4697 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesetResourceTest.groovy
@@ -73,11 +73,11 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ruleDefinitions[0].lang == GROOVY
when: "some tenant rules in a non-authenticated realm are retrieved"
- ruleDefinitions = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantA.realm, null, false)
+ ruleDefinitions = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)
then: "result should match"
ruleDefinitions.length == 1
- ruleDefinitions[0].name == "Some tenantA tenant demo rules"
+ ruleDefinitions[0].name == "Some building tenant demo rules"
ruleDefinitions[0].enabled
when: "some asset rules are retrieved"
@@ -200,9 +200,9 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "a tenant ruleset is created in a non-authenticated realm"
- tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantA.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
- rulesetId = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantA.realm, null, false)[1].id
+ rulesetId = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)[1].id
tenantRuleset = rulesetResource.getTenantRuleset(null, rulesetId)
lastModified = tenantRuleset.lastModified
@@ -213,7 +213,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
lastModified.time < System.currentTimeMillis()
tenantRuleset.name == "Test tenant definition"
tenantRuleset.rules == "SomeRulesCode"
- tenantRuleset.realm == keycloakDemoSetup.tenantA.realm
+ tenantRuleset.realm == keycloakDemoSetup.tenantBuilding.realm
when: "an asset ruleset is created in the authenticated realm"
def assetRuleset = new AssetRuleset(managerDemoSetup.smartOfficeId, "Test asset definition", GROOVY, "SomeRulesCode")
@@ -345,7 +345,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ruleDefinitions[0].name == "Some master tenant demo rules"
when: "some tenant rules in a non-authenticated realm are retrieved"
- rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantA.realm, null, false)
+ rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)
then: "access should be forbidden"
ex = thrown()
@@ -446,7 +446,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "a tenant ruleset is created in a non-authenticated realm"
- tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantA.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -544,14 +544,14 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
and: "an authenticated test user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser2",
"testuser2"
).token
and: "the ruleset resource"
- def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm, accessToken).proxy(RulesResource.class)
+ def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
expect: "the rules engines to be ready"
new PollingConditions(initialDelay: 3, timeout: 20, delay: 1).eventually {
@@ -575,7 +575,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "some tenant rules in the authenticated realm are retrieved by user without rules read role"
- def rulesets = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantA.realm, null, false)
+ def rulesets = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)
then: "no rulesets should be returned"
rulesets.length == 0
@@ -611,7 +611,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in the authenticated realm"
- def tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantA.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ def tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -633,7 +633,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in a non-authenticated realm"
- tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantB.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantCity.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -641,7 +641,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in the authenticated realm"
- def assetRuleset = new AssetRuleset(keycloakDemoSetup.tenantA.realm, "Test asset definition", GROOVY, "SomeRulesCode")
+ def assetRuleset = new AssetRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
then: "access should be forbidden"
@@ -663,7 +663,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in a non-authenticated realm"
- assetRuleset = new AssetRuleset(keycloakDemoSetup.tenantB.realm, "Test asset definition", GROOVY, "SomeRulesCode")
+ assetRuleset = new AssetRuleset(keycloakDemoSetup.tenantCity.realm, "Test asset definition", GROOVY, "SomeRulesCode")
rulesetResource.createAssetRuleset(null, assetRuleset)
then: "access should be forbidden"
@@ -690,14 +690,14 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
and: "an authenticated test user"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
).token
and: "the ruleset resource"
- def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm, accessToken).proxy(RulesResource.class)
+ def rulesetResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(RulesResource.class)
expect: "the rules engines to be ready"
new PollingConditions(initialDelay: 3, timeout: 20, delay: 1).eventually {
@@ -721,7 +721,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "some tenant rules in the authenticated realm are retrieved by the restricted user"
- def rulesets = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantA.realm, null, false)
+ def rulesets = rulesetResource.getTenantRulesets(null, keycloakDemoSetup.tenantBuilding.realm, null, false)
then: "no rulesets should be returned"
rulesets.length == 0
@@ -764,7 +764,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 403
when: "a tenant ruleset is created in the authenticated realm"
- def tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantA.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ def tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantBuilding.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
@@ -787,7 +787,7 @@ class BasicRulesetResourceTest extends Specification implements ManagerContainer
ex.response.status == 404
when: "a tenant ruleset is created in a non-authenticated realm"
- tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantB.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
+ tenantRuleset = new TenantRuleset(keycloakDemoSetup.tenantCity.realm, "Test tenant definition", GROOVY, "SomeRulesCode")
rulesetResource.createTenantRuleset(null, tenantRuleset)
then: "access should be forbidden"
diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
index 224d0a9b7..8ac91203c 100644
--- a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
@@ -79,11 +79,11 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
def timerService = container.getService(TimerService.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetProcessingService = container.getService(AssetProcessingService.class)
- RulesEngine tenantAEngine
+ RulesEngine tenantBuildingEngine
and: "some rules"
Ruleset ruleset = new TenantRuleset(
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
"Demo Apartment - All Lights Off",
Ruleset.Lang.JSON,
getClass().getResource("/org/openremote/test/rules/BasicJsonRules.json").text)
@@ -91,10 +91,10 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
expect: "the rule engines to become available and be running with asset states inserted"
conditions.eventually {
- tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
- assert tenantAEngine != null
- assert tenantAEngine.isRunning()
- assert tenantAEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
+ tenantBuildingEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantBuilding.realm)
+ assert tenantBuildingEngine != null
+ assert tenantBuildingEngine.isRunning()
+ assert tenantBuildingEngine.assetStates.size() == DEMO_RULE_STATES_CUSTOMER_A
}
and: "the room lights in an apartment to be on"
@@ -110,14 +110,14 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
when: "a user authenticates"
def accessToken = authenticate(
container,
- keycloakDemoSetup.tenantA.realm,
+ keycloakDemoSetup.tenantBuilding.realm,
KEYCLOAK_CLIENT_ID,
"testuser3",
"testuser3"
).token
and: "a console is registered by that user"
- def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantA.realm, accessToken).proxy(ConsoleResource.class)
+ def authenticatedConsoleResource = getClientApiTarget(serverUri(serverPort), keycloakDemoSetup.tenantBuilding.realm, accessToken).proxy(ConsoleResource.class)
def consoleRegistration = new ConsoleRegistration(null,
"Test Console",
"1.0",
@@ -169,7 +169,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "the console location asset state should be in the rule engine"
conditions.eventually {
- assert tenantAEngine.assetStates.find {
+ assert tenantBuildingEngine.assetStates.find {
it.id == consoleRegistration.id && it.value.flatMap { GeoJSONPoint.fromValue(it) }.map {
it.x == ManagerDemoSetup.SMART_BUILDING_LOCATION.x && it.y == ManagerDemoSetup.SMART_BUILDING_LOCATION.y ? it : null
}.isPresent()
@@ -201,12 +201,12 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
}
when: "the console device moves back inside the home geofence (as defined in the rule)"
- def lastFireTimestamp = tenantAEngine.lastFireTimestamp
+ def lastFireTimestamp = tenantBuildingEngine.lastFireTimestamp
assetProcessingService.sendAttributeEvent(new AttributeEvent(consoleRegistration.id, LOCATION.attributeName, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue()), AttributeEvent.Source.CLIENT)
and: "the engine fires at least one more time"
conditions.eventually {
- assert tenantAEngine.lastFireTimestamp > lastFireTimestamp
+ assert tenantBuildingEngine.lastFireTimestamp > lastFireTimestamp
}
and: "the console device moves outside the home geofence again (as defined in the rule)"
@@ -284,8 +284,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "the ruleset should be redeployed and paused until 1st occurrence"
conditions.eventually {
- assert tenantAEngine.deployments.find{it.key == ruleset.id}.value.version == version+1
- assert tenantAEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.PAUSED
+ assert tenantBuildingEngine.deployments.find{it.key == ruleset.id}.value.version == version+1
+ assert tenantBuildingEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.PAUSED
}
when: "the same AttributeEvent is sent"
@@ -307,7 +307,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "eventually the ruleset should be unpaused (1st occurrence)"
conditions.eventually {
- assert tenantAEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.DEPLOYED
+ assert tenantBuildingEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.DEPLOYED
}
when: "the same AttributeEvent is sent"
@@ -332,7 +332,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "the ruleset should become paused again (until next occurrence)"
conditions.eventually {
- assert tenantAEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.PAUSED
+ assert tenantBuildingEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.PAUSED
}
when: "the same AttributeEvent is sent"
@@ -354,7 +354,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "eventually the ruleset should be unpaused (next occurrence)"
conditions.eventually {
- assert tenantAEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.DEPLOYED
+ assert tenantBuildingEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.DEPLOYED
}
when: "the un-pause elapses"
@@ -362,7 +362,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "the ruleset should become paused again (until last occurrence)"
conditions.eventually {
- assert tenantAEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.PAUSED
+ assert tenantBuildingEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.PAUSED
}
when: "the pause elapses"
@@ -370,7 +370,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "eventually the ruleset should be unpaused (last occurrence)"
conditions.eventually {
- assert tenantAEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.DEPLOYED
+ assert tenantBuildingEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.DEPLOYED
}
when: "the un-pause elapses"
@@ -378,7 +378,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
then: "the ruleset should expire"
conditions.eventually {
- assert tenantAEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.EXPIRED
+ assert tenantBuildingEngine.deployments.find{it.key == ruleset.id}.value.status == RulesetStatus.EXPIRED
}
cleanup: "stop the container"
diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy
index 5a42ea546..687018b78 100644
--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy
@@ -100,7 +100,7 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
assert !livingRoomAsset.getAttribute("presenceDetected").orElse(null).valueAsBoolean.orElse(null)
and: "an authenticated test user"
- def realm = "tenantA"
+ def realm = "building"
def accessToken = authenticate(
container,
realm,
diff --git a/ui/app/main/.babelrc b/ui/app/main/.babelrc
new file mode 100644
index 000000000..8aa924d7c
--- /dev/null
+++ b/ui/app/main/.babelrc
@@ -0,0 +1,3 @@
+{
+ "presets": ["@babel/preset-env"]
+}
\ No newline at end of file
diff --git a/ui/app/main/.gitignore b/ui/app/main/.gitignore
new file mode 100644
index 000000000..632fd9253
--- /dev/null
+++ b/ui/app/main/.gitignore
@@ -0,0 +1,11 @@
+build/
+node_modules/
+test/integration/screenshots-current/
+_site/
+.DS_Store
+src/**/*.d.ts
+src/**/*.js
+src/**/*.js.map
+openremote/**/*.d.ts
+openremote/**/*.js
+openremote/**/*.js.map
\ No newline at end of file
diff --git a/ui/app/main/.htaccess b/ui/app/main/.htaccess
new file mode 100644
index 000000000..168af4142
--- /dev/null
+++ b/ui/app/main/.htaccess
@@ -0,0 +1,8 @@
+<ifModule mod_rewrite.c>
+ Options +FollowSymLinks
+ IndexIgnore */*
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteRule (.*) index.html
+</ifModule>
\ No newline at end of file
diff --git a/ui/app/main/.travis.yml b/ui/app/main/.travis.yml
new file mode 100644
index 000000000..95411b36e
--- /dev/null
+++ b/ui/app/main/.travis.yml
@@ -0,0 +1,23 @@
+language: node_js
+matrix:
+ include:
+ - node_js: '9'
+ os: osx
+ script: npm run test:integration
+ - node_js: '9'
+ sudo: required
+ os: linux
+ dist: trusty
+ addons:
+ chrome: stable
+ firefox: latest
+ before_script:
+ - export DISPLAY=:99.0
+ - sh -e /etc/init.d/xvfb start
+ script:
+ - npm run test:unit
+ - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test:sauce; fi
+env:
+ global:
+ - secure: C+/z9HB1amzxgntbpkNhjcWeYFt6uagVAp2TuceInyzCpwD8A9mOG+X3pfBX8A0OJnKchSduXbcUzcg8Rw2ZVR/RZajkzWUnInFNeFm4WMgHZFQxc+pHq9o5UyCw+Q237+S5IdC+WI0lfAGh3+5OeGvS+JoC3jUarYb6UlCybgfkqA+Zo0wy6Xyjisb3vYKPnmmF+Ki5fkzwLqpkcqQI3zZQZimTZHNwGOJO6ib2uEEjaCVhvG1XKDlF8M+07arE97hKOJEEKIHHPOaPtABw634OfwbiS5lPHlb626VD+ry08P1FH7mg3XM+XdUS7T+o3Lb2RScjA5jetF27s2E9mK467zIw60kC5e8eDx8/uJWlx/c3jT4nQQ+epjTp7M5lbOQBYiQttGureaWHSVVvUJKTrSN8CxceV7Zmia1N9dtC3o2CEDZyrbJ5+2tR8POkUZkz5XHNhHg0/U/vq0dm3LjhOGfyKCqD4o1qS2ytdzPVu2fwHdD63NxU1pKPeYNcO3aKASTgUJpPWA4j/JQWWNF/HTUU6NMO3ihKxX+ZeenX/wtvSrurNIFhIqf81hr0iRYVH+pMOZ7shfr65w6GgllQjO2gFz8IZyc0t9I5CJnOVyhHfgdVj4XgeTHaxDalYE/eB/ny1unxbG/c+6v06pHWJ9HNXFd5VXPTmtNu1m8=
+ - secure: MIqRhLuXEh4qKMvVnbqs2jAtwsGgnl8qLYRNGKeG5eUf3aJT86FJefcccddVAipNun10fnkSkNd2rpNb/G8Htxvyg9lYiOeCDOvxsaDtYwxvz1WGk2u5kRUjkfyb2LVzUV0MCUSiR+o/9qUXy5TVcwrzAN/4Jin8diMPVkuektP5xhyVm1BAMufn+IcX56xtkT123Egz1Y0N47TKB4rEqhVUazYvMy2Vq2Xs2NIpVT2v8+91UzRLCeESIKKPFfZvdgVHovqKiKmsXLMsGTsAKT6FjimSmKvknC4iR7B3CiQQwoo0GIJjd/QKy35S3wMUoZEy+WpN8hBuKoJLg2GtaVmsV1MEAyKBFtMRPQwUTSPSxz5RQzVYKby9TsOKulFbsfk1jRzAlJSc4USSXO7/HH/vcTF0NZJhqvZAo8mX43UqQSmOEo6vobEASM8I5lysQnuqjrDTowg8Wou7a0yhIaKiGBhf5Yy61mSqURNBXCpRHR75SDr2/9qtqU8hfH6PqCuLHtQ0eEhNzfcjo8fPRcAx2QWPmmnOpDAZcxFvVGlkiM5aOFlRiPbGLFADkzm1uDh7GYfSChoLoEhM/MJMxl0OeLIcKpsgXUjrQv2KdJCVtbu610jMlH98J5GsfoA7SkKUn8DYujkuhaHBqYKLjZ7tCVLXsoMZqJcQf7W5Q3g=
diff --git a/ui/app/smart-building/babel.config.js b/ui/app/main/babel.config.js
similarity index 100%
rename from ui/app/smart-building/babel.config.js
rename to ui/app/main/babel.config.js
diff --git a/ui/app/main/build.gradle b/ui/app/main/build.gradle
new file mode 100644
index 000000000..010a45540
--- /dev/null
+++ b/ui/app/main/build.gradle
@@ -0,0 +1,7 @@
+buildDir = "dist"
+
+task installDist(type: Copy) {
+ dependsOn npmClean, npmBuild
+ from project.buildDir
+ into "${project(':deployment').buildDir}/manager/app/${projectDir.name}"
+}
\ No newline at end of file
diff --git a/ui/app/main/images/Icon-128.png b/ui/app/main/images/Icon-128.png
new file mode 100755
index 000000000..c2020e03c
Binary files /dev/null and b/ui/app/main/images/Icon-128.png differ
diff --git a/ui/app/main/images/Icon-144.png b/ui/app/main/images/Icon-144.png
new file mode 100755
index 000000000..65839d849
Binary files /dev/null and b/ui/app/main/images/Icon-144.png differ
diff --git a/ui/app/main/images/Icon-196.png b/ui/app/main/images/Icon-196.png
new file mode 100755
index 000000000..ff9be3c08
Binary files /dev/null and b/ui/app/main/images/Icon-196.png differ
diff --git a/ui/app/main/images/Icon-256.png b/ui/app/main/images/Icon-256.png
new file mode 100755
index 000000000..6b2cc235f
Binary files /dev/null and b/ui/app/main/images/Icon-256.png differ
diff --git a/ui/app/main/images/Icon-48.png b/ui/app/main/images/Icon-48.png
new file mode 100755
index 000000000..8849e954a
Binary files /dev/null and b/ui/app/main/images/Icon-48.png differ
diff --git a/ui/app/main/images/Icon-512.png b/ui/app/main/images/Icon-512.png
new file mode 100755
index 000000000..75456d23c
Binary files /dev/null and b/ui/app/main/images/Icon-512.png differ
diff --git a/ui/app/main/images/Icon-72.png b/ui/app/main/images/Icon-72.png
new file mode 100755
index 000000000..e12fb4d49
Binary files /dev/null and b/ui/app/main/images/Icon-72.png differ
diff --git a/ui/app/main/images/favicon.ico b/ui/app/main/images/favicon.ico
new file mode 100644
index 000000000..b9aed223e
Binary files /dev/null and b/ui/app/main/images/favicon.ico differ
diff --git a/ui/app/main/images/logo-mobile.png b/ui/app/main/images/logo-mobile.png
new file mode 100644
index 000000000..15ace0048
Binary files /dev/null and b/ui/app/main/images/logo-mobile.png differ
diff --git a/ui/app/main/images/logo.png b/ui/app/main/images/logo.png
new file mode 100644
index 000000000..bbcbd480f
Binary files /dev/null and b/ui/app/main/images/logo.png differ
diff --git a/ui/app/main/images/openremote-logo.png b/ui/app/main/images/openremote-logo.png
new file mode 100644
index 000000000..17a75c022
Binary files /dev/null and b/ui/app/main/images/openremote-logo.png differ
diff --git a/ui/app/smart-building/index.html b/ui/app/main/index.html
similarity index 58%
rename from ui/app/smart-building/index.html
rename to ui/app/main/index.html
index d1e329731..373277506 100644
--- a/ui/app/smart-building/index.html
+++ b/ui/app/main/index.html
@@ -3,36 +3,32 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
+ <title>Demo</title>
+ <meta name="application-name" content="Demo">
+ <meta name="apple-mobile-web-app-title" content="Demo">
- <title>OpenRemote Smart Building Demo</title>
+ <meta name="msapplication-TileImage" content="images/Icon-144.png">
+ <meta name="msapplication-TileColor" content="#222120">
+ <meta name="msapplication-tap-highlight" content="no">
<link rel="icon" href="images/favicon.ico">
-
- <!-- See https://goo.gl/OOhYW5 -->
- <!--<link rel="manifest" href="manifest.json">-->
-
- <!-- See https://goo.gl/qRE0vM -->
- <meta name="theme-color" content="#3f51b5">
+ <meta name="theme-color" content="#222120">
<!-- Add to homescreen for Chrome on Android. Fallback for manifest.json -->
<meta name="mobile-web-app-capable" content="yes">
- <meta name="application-name" content="Smart Building Demo">
<!-- Add to homescreen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="default">
- <meta name="apple-mobile-web-app-title" content="Smart Building Demo">
<!-- Homescreen icons -->
- <link rel="apple-touch-icon" href="images/manifest/icon-48x48.png">
- <link rel="apple-touch-icon" sizes="72x72" href="images/manifest/icon-72x72.png">
- <link rel="apple-touch-icon" sizes="96x96" href="images/manifest/icon-96x96.png">
- <link rel="apple-touch-icon" sizes="144x144" href="images/manifest/icon-144x144.png">
- <link rel="apple-touch-icon" sizes="192x192" href="images/manifest/icon-192x192.png">
+ <link rel="apple-touch-icon" href="images/Icon-48.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="images/Icon-72.png">
+ <link rel="apple-touch-icon" sizes="144x144" href="images/Icon-144.png">
+ <link rel="apple-touch-icon" sizes="192x192" href="images/Icon-196.png">
<!-- Tile icon for Windows 8 (144x144 + tile color) -->
- <meta name="msapplication-TileImage" content="images/manifest/icon-144x144.png">
- <meta name="msapplication-TileColor" content="#3f51b5">
+ <meta name="msapplication-TileImage" content="images/Icon-144.png">
+ <meta name="msapplication-TileColor" content="#222120">
<meta name="msapplication-tap-highlight" content="no">
<!-- Default twitter cards -->
@@ -40,11 +36,8 @@
<meta name="twitter:site" content="@username">
<meta property="og:type" content="website">
<meta property="og:site_name" content="my-app">
- <meta property="og:image" content="images/manifest/icon-144x144.png" />
+ <meta property="og:image" content="images/Icon-144.png" />
- <!-- Performance tip: hint to the browser to start the handshake for the fonts site -->
- <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--
Feature detect Custom Elements support. If the browser DOES support Custom
Elements then we need to load the custom-elements-es5-adapter because
@@ -55,25 +48,26 @@
<script src="./modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
<!--! DO NOT REMOVE THIS COMMENT, WE NEED ITS CLOSING MARKER -->
- <style type="text/css">
- html, body {
- margin: 0;
- min-height: 100vh;
- overflow: hidden;
+ <style>
+ html {
+ height: 100%;
}
-
body {
- background: var(--theme-mediumgrey);
- font-family: 'Open Sans', 'Roboto', Helvetica, Arial, Lucida, sans-serif;
+ margin: 0;
+ font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
+ line-height: 1.5;
+ height: 100%;
+ -webkit-font-smoothing: antialiased;
+ overflow: hidden;
}
</style>
+
+
</head>
<body>
-<smart-building-app>
- <!-- You can override the logo
- <img slot="logo" height="20" src="mylogo.png"/>
- -->
-</smart-building-app>
+<div class="vertical-section-container centered">
+ <my-app apptitle="Demo"></my-app>
+</div>
<!--
Use the webcomponents-loader script which will feature detect which Web
diff --git a/ui/app/main/locales/nl/app.json b/ui/app/main/locales/nl/app.json
new file mode 100644
index 000000000..7c058ae71
--- /dev/null
+++ b/ui/app/main/locales/nl/app.json
@@ -0,0 +1,23 @@
+{
+ "Space": "Plaatsen",
+ "occupied": "Bezet",
+ "buffer": "Buffer",
+ "capacity": "Totale plaatsen",
+ "occupancy": "Bezette plaatsen",
+ "Sound": "Geluidsniveau",
+ "alarm": "Alarm",
+ "zone1": "Scenario 1",
+ "zone2": "Scenario 2",
+ "zone3": "Scenario 3",
+ "zone4": "Scenario 4",
+ "maintMode": "Onderhoudsmodus",
+ "On": "Aan",
+ "Off": "Uit",
+ "streamId": "ID",
+ "alarmEvent": "Laatste alarm",
+ "latestEvent": "Laatste event",
+ "gunshotEvent": "Laatste gunshot",
+ "intensityEvent": "Laatste lawaai",
+ "aggressionEvent": "Laatste agressie",
+ "breakingglassEvent": "Laatste brekend glas"
+}
\ No newline at end of file
diff --git a/ui/app/smart-building/package.json b/ui/app/main/package.json
similarity index 67%
rename from ui/app/smart-building/package.json
rename to ui/app/main/package.json
index 99cad570c..7382a6c6c 100644
--- a/ui/app/smart-building/package.json
+++ b/ui/app/main/package.json
@@ -1,10 +1,10 @@
{
- "description": "Smart Building Demo",
- "homepage": "http://openremote.io/",
- "name": "smart-building",
- "version": "3.0.0",
- "author": "OpenRemote Inc. <[email protected]>",
+ "name": "demo",
+ "version": "1.0.0",
+ "description": "Demo App",
+ "author": "OpenRemote",
"license": "AGPL-3.0-or-later",
+ "private": true,
"scripts": {
"clean": "npx shx rm -rf dist",
"modelBuild": "node ../../model-build.js",
@@ -15,27 +15,24 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
- "@fortawesome/fontawesome-svg-core": "^1.2.12",
- "@fortawesome/free-regular-svg-icons": "^5.6.3",
- "@fortawesome/free-solid-svg-icons": "^5.6.3",
"@openremote/core": "^1.1.0",
- "@openremote/or-bottom-navigation": "^1.1.0",
+ "@openremote/or-asset-tree": "^1.1.0",
+ "@openremote/or-asset-viewer": "^1.1.0",
"@openremote/or-header": "^1.1.0",
- "@polymer/app-layout": "^3.0.0",
- "@polymer/iron-demo-helpers": "^3.0.0-pre.19",
- "@polymer/polymer": "^3.0.0",
- "@webcomponents/html-imports": "^1.2.0",
- "bootstrap": "4.3.1",
- "i18next": "^15.0.9",
- "i18next-xhr-backend": "^2.0.1",
- "lit-element": "^2.0.1",
- "mapbox-gl": "^0.50.0",
+ "@openremote/or-map": "^1.1.0",
+ "@openremote/or-rules-editor": "^1.1.0",
+ "@openremote/or-smart-notify": "^1.1.0",
+ "@openremote/or-timeline": "^1.1.0",
+ "@openremote/rest": "^1.1.0",
+ "@types/navigo": "^7.0.1",
+ "@webcomponents/webcomponentsjs": "^2.2.10",
+ "lit-element": "^2.2.1",
"moment": "^2.24.0",
- "moment-es6": "^1.0.0",
+ "navigo": "^7.1.2",
"pwa-helpers": "^0.9.0",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
- "reselect": "^3.0.1"
+ "reselect": "^4.0.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
diff --git a/ui/app/main/src/actions/app.ts b/ui/app/main/src/actions/app.ts
new file mode 100644
index 000000000..7dd690a41
--- /dev/null
+++ b/ui/app/main/src/actions/app.ts
@@ -0,0 +1,91 @@
+import {Action, ActionCreator} from "redux";
+import {ThunkAction} from "redux-thunk";
+import {RootState} from "../store";
+
+export const UPDATE_PAGE = "UPDATE_PAGE";
+export const UPDATE_RULE = "UPDATE_RULE";
+export const RESOLVE_APP = "RESOLVE_APP";
+export const UPDATE_DRAWER = "UPDATE_DRAWER";
+export const SET_SCROLL_TOP = "SET_SCROLL_TOP";
+export const SET_ACTIVE_ASSET = "SET_ACTIVE_ASSET";
+
+
+export interface AppActionUpdatePage extends Action<typeof UPDATE_PAGE> {
+ page: string;
+}
+
+export interface AppActionSetActiveAsset extends Action<typeof SET_ACTIVE_ASSET> {
+ assetId: string;
+}
+
+export interface AppActionSetScrollTop extends Action<typeof SET_SCROLL_TOP> {
+ top: number;
+}
+
+export interface AppActionUpdateRule extends Action<typeof UPDATE_RULE> {
+ id: string;
+}
+
+export interface AppActionResolveApp extends Action<typeof RESOLVE_APP> {
+ resolved: boolean;
+}
+
+export interface AppActionUpdateDrawer extends Action<typeof UPDATE_DRAWER> {
+ opened: boolean;
+}
+
+export type AppAction =
+ AppActionUpdatePage
+ | AppActionSetActiveAsset
+ | AppActionSetScrollTop
+ | AppActionUpdateRule
+ | AppActionUpdateDrawer
+ | AppActionResolveApp;
+
+type ThunkResult = ThunkAction<void, RootState, undefined, AppAction>;
+
+export const setScrollTop: ActionCreator<ThunkResult> = (top: number) => (dispatch) => {
+ dispatch({
+ type: SET_SCROLL_TOP,
+ top
+ });
+};
+
+export const setActiveAsset: ActionCreator<ThunkResult> = (assetId: string) => (dispatch) => {
+ dispatch({
+ type: SET_ACTIVE_ASSET,
+ assetId
+ });
+};
+
+export const updatePage: ActionCreator<ThunkResult> = (page: string) => (dispatch) => {
+ dispatch({
+ type: UPDATE_PAGE,
+ page
+ });
+
+ // Close the drawer - in case the *path* change came from a link in the drawer.
+ dispatch(updateDrawer(false));
+};
+
+
+export const updateRule: ActionCreator<ThunkResult> = (id: string) => (dispatch) => {
+ dispatch({
+ type: UPDATE_RULE,
+ id
+ });
+};
+
+export const resolveApp: ActionCreator<ThunkResult> = (resolved: boolean) => (dispatch) => {
+ dispatch({
+ type: RESOLVE_APP,
+ resolved
+ });
+};
+
+export const updateDrawer: ActionCreator<ThunkResult> = (opened: boolean) => (dispatch) => {
+ dispatch({
+ type: UPDATE_DRAWER,
+ opened
+ });
+};
diff --git a/ui/app/main/src/actions/map.ts b/ui/app/main/src/actions/map.ts
new file mode 100644
index 000000000..24e28522f
--- /dev/null
+++ b/ui/app/main/src/actions/map.ts
@@ -0,0 +1,118 @@
+import {Action, ActionCreator} from "redux";
+import {ThunkAction} from "redux-thunk";
+import {RootState} from "../store";
+import manager from "@openremote/core";
+import {AssetEvent, AttributeEvent} from "@openremote/model";
+
+export const ASSET_EVENT_RECEIVED = "ASSET_EVENT_RECEIVED";
+export const ATTRIBUTE_EVENT_RECEIVED = "ATTRIBUTE_EVENT_RECEIVED";
+export const UPDATE_ASSET_SUBSCRIPTION_ID = "UPDATE_ASSET_SUBSCRIPTION_ID";
+export const UPDATE_ATTRIBUTE_SUBSCRIPTION_ID = "UPDATE_ATTRIBUTE_SUBSCRIPTION_ID";
+export const SET_CURRENT_ASSET_ID = "SET_CURRENT_ASSET_ID";
+
+export interface MapActionAssetEventReceived extends Action<typeof ASSET_EVENT_RECEIVED> {
+ event: AssetEvent;
+}
+
+export interface MapActionAttributeEventReceived extends Action<typeof ATTRIBUTE_EVENT_RECEIVED> {
+ event: AttributeEvent;
+}
+
+export interface MapActionUpdateAssetSubscriptionId extends Action<typeof UPDATE_ASSET_SUBSCRIPTION_ID> {
+ id: string;
+}
+
+export interface MapActionUpdateAttributeSubscriptionId extends Action<typeof UPDATE_ATTRIBUTE_SUBSCRIPTION_ID> {
+ id: string;
+}
+
+export interface MapActionSetCurrentAssetId extends Action<typeof SET_CURRENT_ASSET_ID> {
+ id: string;
+}
+
+export type MapAction = MapActionAssetEventReceived | MapActionAttributeEventReceived | MapActionUpdateAssetSubscriptionId | MapActionUpdateAttributeSubscriptionId | MapActionSetCurrentAssetId;
+
+type ThunkResult = ThunkAction<void, RootState, undefined, MapAction>;
+
+export const subscribeAssets: ActionCreator<ThunkResult> = () => async (dispatch) => {
+
+ try {
+ const result = await manager.rest.api.AssetResource.queryAssets({
+ select: {
+ excludeAttributes: true,
+ excludeRealm: true,
+ excludeParentInfo: true,
+ excludePath: true
+ }
+ });
+
+ if (result.data) {
+ const ids = result.data.map(
+ asset => asset.id
+ );
+
+ let subscriptionId = await manager.events.subscribeAssetEvents(ids, true, (event) => {
+ dispatch(assetEventReceived(event));
+ });
+ dispatch(updateAssetSubscriptionId(subscriptionId));
+
+ subscriptionId = await manager.events.subscribeAttributeEvents(ids, false, (event) => {
+ dispatch(attributeEventReceived(event));
+ });
+ dispatch(updateAttributeSubscriptionId(subscriptionId));
+ }
+
+ } catch (e) {
+ console.error("Failed to subscribe to assets", e)
+ }
+};
+
+export const assetEventReceived = (event: AssetEvent): MapActionAssetEventReceived => {
+ return {
+ type: ASSET_EVENT_RECEIVED,
+ event: event
+ }
+};
+
+export const unsubscribeAssets: ActionCreator<ThunkResult> = () => (dispatch, getState) => {
+ if (getState().map.assetSubscriptionId) {
+ manager.events.unsubscribe(getState().map.assetSubscriptionId);
+ dispatch(
+ updateAssetSubscriptionId(null)
+ );
+ }
+ if (getState().map.attributeSubscriptionId) {
+ manager.events.unsubscribe(getState().map.attributeSubscriptionId);
+ dispatch(
+ updateAttributeSubscriptionId(null)
+ );
+ }
+};
+
+export const attributeEventReceived = (event: AttributeEvent): MapActionAttributeEventReceived => {
+ return {
+ type: ATTRIBUTE_EVENT_RECEIVED,
+ event: event
+ }
+};
+
+export const updateAssetSubscriptionId = (id: string): MapActionUpdateAssetSubscriptionId => {
+ return {
+ type: UPDATE_ASSET_SUBSCRIPTION_ID,
+ id: id
+ }
+};
+
+export const updateAttributeSubscriptionId = (id: string): MapActionUpdateAttributeSubscriptionId => {
+ return {
+ type: UPDATE_ATTRIBUTE_SUBSCRIPTION_ID,
+ id: id
+ }
+};
+
+export const setCurrentAssetId = (id: string): MapActionSetCurrentAssetId => {
+ return {
+ type: SET_CURRENT_ASSET_ID,
+ id: id
+ }
+};
diff --git a/ui/app/main/src/components/my-app.ts b/ui/app/main/src/components/my-app.ts
new file mode 100644
index 000000000..f70f5a3b6
--- /dev/null
+++ b/ui/app/main/src/components/my-app.ts
@@ -0,0 +1,125 @@
+import {css, customElement, html, LitElement, property, PropertyValues, unsafeCSS, TemplateResult} from "lit-element";
+import {updateMetadata} from "pwa-helpers/metadata";
+import "@openremote/or-header";
+import "@openremote/or-icon";
+import "@openremote/or-translate";
+import manager, {DefaultColor2, DefaultColor3, DefaultHeaderHeight} from "@openremote/core";
+import {router} from "../index";
+import {RootState, store} from "../store";
+import "../components/pages/page-map";
+import "../components/pages/page-assets";
+import "../components/pages/page-rules";
+import "../components/or-language/src";
+import i18next from "i18next";
+import {connect} from "pwa-helpers/connect-mixin";
+
+// Declare require method which we'll use for importing webpack resources (using ES6 imports will confuse typescript parser)
+declare function require(name: string): any;
+
+const logoImage = require("../../images/openremote-logo.png");
+const logoMobileImage = require("../../images/logo-mobile.png");
+
+@customElement("my-app")
+class MyApp extends connect(store)(LitElement) {
+
+ @property({type: String})
+ public appTitle = "";
+
+ @property({type: Boolean, attribute: false})
+ protected resolved = false;
+
+ @property({type: String, attribute: false})
+ protected page = "";
+
+ static get styles() {
+ return css`
+ :host {
+ --or-app-color2: ${unsafeCSS(DefaultColor2)};
+ --or-app-color3: #22211f;
+ --or-app-color4: #3F89BF;
+ color: ${unsafeCSS(DefaultColor3)};
+ fill: ${unsafeCSS(DefaultColor3)};
+ font-size: 14px;
+ }
+
+ .main-content {
+ display: flex;
+ padding-top: ${unsafeCSS(DefaultHeaderHeight)};
+ height: 100vh;
+ box-sizing: border-box;
+ background-color: var(--or-app-color2);
+ }
+
+ .page {
+ display: flex;
+ flex: 1;
+ position: relative;
+ }
+
+ .desktop-hidden {
+ display: none !important;
+ }
+
+ @media only screen and (max-width: 780px){
+ .desktop-hidden {
+ display: inline-block !important;
+ }
+ }
+
+ /* HEADER STYLES */
+ or-header a > or-icon {
+ margin-right: 10px;
+ }
+ `;
+ }
+
+ protected render(): TemplateResult | void {
+
+ if (!this.resolved) {
+ return html``;
+ }
+
+ return html`
+ <or-header logo="${logoImage}" logoMobile="${logoMobileImage}">
+ <a slot="desktop-left" ?selected="${this.page === "map"}" @click="${() => router.navigate("map")}"><or-icon icon="map"></or-icon><or-translate value="map"></or-translate></a>
+ <a slot="desktop-left" ?selected="${this.page === "assets"}" @click="${() => router.navigate("assets")}"><or-icon icon="sitemap"></or-icon><or-translate value="asset_plural"></or-translate></a>
+ <a slot="desktop-left" ?selected="${this.page === "rules"}" @click="${() => router.navigate("rules")}"><or-icon icon="cogs"></or-icon><or-translate value="rules"></or-translate></a>
+ <a slot="desktop-right"><or-language></or-language></a>
+ <a slot="desktop-right" @click="${() => this.logout()}"><or-translate value="logout"></or-translate></a>
+ <a slot="mobile-top" ?selected="${this.page === "map"}" @click="${() => router.navigate("map")}"><or-icon icon="map"></or-icon><or-translate value="map"></or-translate></a>
+ <a slot="mobile-top" ?selected="${this.page === "assets"}" @click="${() => router.navigate("assets")}"><or-icon icon="sitemap"></or-icon><or-translate value="asset_plural"></or-translate></a>
+ <a slot="mobile-top" ?selected="${this.page === "rules"}" @click="${() => router.navigate("rules")}"><or-icon icon="cogs"></or-icon><or-translate value="rules"></or-translate></a>
+
+ <a slot="mobile-top" @click="${() => this.logout()}"><or-icon icon="logout"></or-icon><or-translate value="logout"></or-translate></a>
+ </or-header>
+
+ <!-- Main content -->
+ <main role="main" class="main-content d-none">
+ ${this.page === "map" ? html`<page-map class="page"></page-map>` : ``}
+ ${this.page === "assets" ? html`<page-assets class="page"></page-assets>` : ``}
+ ${this.page === "rules" ? html`<page-rules class="page"></page-rules>` : ``}
+ </main>
+ `;
+ }
+
+ public logout() {
+ manager.logout();
+ }
+
+ public stateChanged(state: RootState) {
+ this.page = state.app!.page;
+ this.resolved = state.app.resolved;
+ }
+
+ protected updated(changedProps: PropertyValues) {
+ super.updated(changedProps);
+
+ if (changedProps.has("page")) {
+ const pageTitle = i18next.isInitialized ? i18next.t(this.appTitle) + " - " + i18next.t(this.page) : this.appTitle + " - " + this.page;
+ updateMetadata({
+ title: pageTitle,
+ description: pageTitle
+ });
+ }
+ }
+}
diff --git a/ui/app/main/src/components/or-asset-summary-card.ts b/ui/app/main/src/components/or-asset-summary-card.ts
new file mode 100644
index 000000000..6d4bd59e9
--- /dev/null
+++ b/ui/app/main/src/components/or-asset-summary-card.ts
@@ -0,0 +1,256 @@
+import {
+ css,
+ CSSResult,
+ CSSResultArray,
+ customElement,
+ html,
+ LitElement,
+ property,
+ PropertyValues,
+ TemplateResult,
+ unsafeCSS
+} from "lit-element";
+import {Asset, AssetEvent, AssetEventCause, AttributeEvent, AttributeType, AttributeValueType} from "@openremote/model";
+import manager, {
+ AssetModelUtil,
+ DefaultColor1,
+ DefaultColor3,
+ DefaultColor4,
+ DefaultColor5,
+ DefaultHeaderHeight,
+ subscribe,
+ Util
+} from "@openremote/core";
+import "@openremote/or-icon";
+import {router} from "../index";
+import "./or-attribute-field/src";
+import {orAttributeTemplateProvider} from "./or-attribute-field/src";
+
+orAttributeTemplateProvider.setTemplate((attribute) => {
+ let template;
+ switch (attribute.type) {
+
+ case AttributeValueType.BOOLEAN.name:
+ template = html`<or-translate value="${attribute.value}"></or-translate>`;
+ break;
+ case AttributeValueType.SWITCH_TOGGLE.name:
+ template = html`<or-translate value="${attribute.value ? "On" : "Off"}"></or-translate>`;
+ break;
+ case AttributeValueType.NUMBER.name:
+ case AttributeValueType.SOUND_DB.name:
+ template = attribute.value ? new Intl.NumberFormat().format(attribute.value) : "-";
+ break;
+ case AttributeValueType.STRING.name:
+ template = html`<or-translate value="${attribute.value}"></or-translate>`;
+ break;
+ case AttributeValueType.OBJECT.name:
+ case AttributeValueType.ARRAY.name:
+ if(attribute.name === "status") {
+ template = html`<or-translate value="${attribute.value.result}"></or-translate>`;
+ }
+ else if(attribute.value && attribute.value.content.time) {
+ template = new Intl.DateTimeFormat('default', {
+ year: 'numeric',
+ month: 'numeric',
+ day: 'numeric',
+ hour: 'numeric',
+ minute: 'numeric'
+ }).format(new Date(attribute.value.content.time));
+ }
+ break;
+ default:
+ template = attribute.value ? attribute.value : "-";
+ break;
+ }
+ return template;
+});
+
+@customElement("or-asset-summary-card")
+export class OrAssetSummaryCard extends subscribe(manager)(LitElement) {
+
+ @property({type: String, reflect: true, attribute: true})
+ public assetId?: string;
+
+ @property({type: Object, attribute: true})
+ public asset?: Asset;
+
+ @property({type: Boolean, attribute: true})
+ public useAssetColor: boolean = true;
+
+ static get styles(): CSSResultArray | CSSResult {
+ return css`
+ :host {
+ --internal-or-asset-summary-card-header-color: var(--or-asset-summary-card-header-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
+ --internal-or-asset-summary-card-header-text-color: var(--or-asset-summary-card-header-text-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
+ --internal-or-asset-summary-card-header-height: var(--or-asset-summary-card-header-height, calc(${unsafeCSS(DefaultHeaderHeight)} - 10px));
+ --internal-or-asset-summary-card-background-color: var(--or-asset-summary-card-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
+ --internal-or-asset-summary-card-background-text-color: var(--or-asset-summary-card-background-text-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));
+ --internal-or-asset-summary-card-separator-color: var(--or-asset-summary-card-separator-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));
+
+ display: block;
+ }
+
+ #card-container {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ background-color: var(--internal-or-asset-summary-card-background-color);
+ -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
+ -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
+ box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
+ }
+
+ #header {
+ height: var(--internal-or-asset-summary-card-header-height);
+ background-color: var(--internal-or-asset-summary-card-header-color);
+ line-height: var(--internal-or-asset-summary-card-header-height);
+ border-bottom: 1px solid ${unsafeCSS(DefaultColor5)};
+ text-align: center;
+ color: var(--internal-or-asset-summary-card-header-text-color);
+ --or-icon-fill: var(--internal-or-asset-summary-card-header-text-color);
+ --or-icon-width: 20px;
+ --or-icon-height: 20px;
+ z-index: 99999;
+ }
+
+ #header > or-icon {
+ margin-right: 5px;
+ }
+
+ #title {
+ font-weight: 500;
+ }
+
+ #attribute-list {
+ flex: 1;
+ color: var(--internal-or-asset-summary-card-background-text-color);
+ padding: 10px 20px;
+ overflow: auto;
+ font-size: 14px;
+ }
+
+ ul {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ }
+
+ li {
+ display: flex;
+ line-height: 30px;
+ height: 32px;
+ }
+
+ .attribute-name {
+ flex: 1;
+ }
+
+ .attribute-value {
+ overflow: hidden;
+ padding-left: 20px;
+ text-align: right;
+ }
+
+ #footer {
+ height: var(--internal-or-asset-summary-card-header-height);
+ border-top: 1px solid var(--internal-or-asset-summary-card-separator-color);
+ text-align: right;
+ }
+
+ #footer > span {
+ line-height: var(--internal-or-asset-summary-card-header-height);
+ font-weight: 500;
+ font-size: 14px;
+ margin-right: 20px;
+ cursor: pointer;
+ }
+
+ @media only screen and (min-width: 415px){
+ #card-container {
+ height: 400px; /* fallback for IE */
+ height: max-content;
+ max-height: calc(100vh - 150px);
+ min-height: 134px;
+ }
+ }
+ `;
+ }
+
+ protected shouldUpdate(_changedProperties: PropertyValues): boolean {
+
+ if (_changedProperties.has("assetId")) {
+ this.title = undefined;
+ this.assetIds = this.assetId && this.assetId.length > 0 ? [this.assetId] : undefined;
+
+ if (Object.keys(_changedProperties).length === 1) {
+ return false;
+ }
+ }
+
+ return super.shouldUpdate(_changedProperties);
+ }
+
+ public onAttributeEvent(event: AttributeEvent) {
+
+ if (this.asset) {
+ this.asset = Util.updateAsset(this.asset, event);
+ this.requestUpdate();
+ }
+ }
+
+ public onAssetEvent(event: AssetEvent) {
+ switch (event.cause) {
+ case AssetEventCause.READ:
+ case AssetEventCause.CREATE:
+ case AssetEventCause.UPDATE:
+ this.asset = event.asset;
+ break;
+ case AssetEventCause.DELETE:
+ this.asset = null;
+ break;
+ }
+ }
+
+ protected render(): TemplateResult | undefined {
+
+ if (!this.asset) {
+ return html``;
+ }
+
+ const icon = this.getIcon();
+ const color = this.getColor();
+ const styleStr = color ? "--internal-or-asset-summary-card-header-color: #" + color + ";" : "";
+ return html`
+ <div id="card-container" style="${styleStr}">
+ <div id="header">
+ ${icon ? html`<or-icon icon="${icon}"></or-icon>` : ``}
+ <span id="title">${this.asset.name}</span>
+ </div>
+ <div id="attribute-list">
+ <ul>
+ ${Util.getAssetAttributes(this.asset).filter((attr) => attr.name !== AttributeType.LOCATION.attributeName).map((attr) => {
+ return html`<li><or-translate class="attribute-name" value="${attr.name}"></or-translate><span class="attribute-value"><or-attribute-field .attribute="${attr}"></or-attribute-field></span></li>`;
+ })}
+ </ul>
+ </div>
+ <div id="footer">
+ <span @click="${() => router.navigate('assets/'+this.asset.id)}">Asset details</span>
+ </div>
+ </div>
+ `;
+ }
+
+ protected getIcon(): string | undefined {
+ if (this.asset) {
+ const descriptor = AssetModelUtil.getAssetDescriptor(this.asset.type);
+ return descriptor.icon;
+ }
+ }
+
+ protected getColor(): string | undefined {
+ if (this.asset) {
+ const descriptor = AssetModelUtil.getAssetDescriptor(this.asset.type);
+ return descriptor.color;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ui/app/main/src/components/or-attribute-field/src/index.ts b/ui/app/main/src/components/or-attribute-field/src/index.ts
new file mode 100644
index 000000000..312547aaf
--- /dev/null
+++ b/ui/app/main/src/components/or-attribute-field/src/index.ts
@@ -0,0 +1,63 @@
+import {css, customElement, html, LitElement, property} from "lit-element";
+import {i18next, translate} from "@openremote/or-translate";
+import {
+ AssetAttribute,
+ AttributeRef,
+ AttributeValueType,
+ AttributeEvent,
+} from "@openremote/model";
+import manager, {subscribe} from "@openremote/core";
+import "@openremote/or-input";
+
+class ORAttributeTemplateProvider {
+ _template = null;
+
+ getTemplate(object) {
+ if(this._template){
+ const template = this._template(object);
+ if (template) {
+ return template;
+ }
+ }
+ }
+
+ setTemplate(callback) {
+ this._template = callback;
+ }
+}
+
+export let orAttributeTemplateProvider = new ORAttributeTemplateProvider();
+
+orAttributeTemplateProvider.setTemplate((attribute) => {
+ let template;
+ switch (attribute.type) {
+ default:
+ template = attribute.value;
+ break;
+ }
+ return template;
+});
+
+@customElement("or-attribute-field")
+export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitElement)) {
+
+ static get styles() {
+ return css`
+ :host {
+ display: inline-block;
+ }
+
+ `;
+ }
+
+ @property({type: Object, reflect: false})
+ public attribute?: AssetAttribute;
+
+ constructor() {
+ super();
+ }
+
+ public render() {
+ return html`${orAttributeTemplateProvider.getTemplate(this.attribute)}`;
+ }
+}
diff --git a/ui/app/main/src/components/or-language/src/index.ts b/ui/app/main/src/components/or-language/src/index.ts
new file mode 100644
index 000000000..405f75ad8
--- /dev/null
+++ b/ui/app/main/src/components/or-language/src/index.ts
@@ -0,0 +1,43 @@
+import {customElement, html, LitElement, property} from "lit-element";
+import "@openremote/or-icon";
+import manager from "@openremote/core";
+import {style} from "./style";
+
+@customElement("or-language")
+export class OrLanguage extends LitElement {
+
+
+ @property({type: Boolean})
+ isVisible?: boolean = false;
+
+ static styles = style;
+
+ protected render() {
+ return html`
+ <or-icon icon="web" @click="${this.toggleMenu}"></or-icon>
+ <div class="background-close ${this.isVisible ? "active" : ""}" @click="${this.closeMenu}"></div>
+ ${this.isVisible ? html`
+ <div class="dropdown-menu">
+ <span @click="${() => this.changeLanguage("en")}"><or-translate value="English"></or-translate></span>
+ <span @click="${() => this.changeLanguage("nl")}"><or-translate value="Dutch"></or-translate></span>
+ <span @click="${() => this.changeLanguage("fr")}"><or-translate value="French"></or-translate></span>
+ <span @click="${() => this.changeLanguage("de")}"><or-translate value="German"></or-translate></span>
+ <span @click="${() => this.changeLanguage("es")}"><or-translate value="Spanish"></or-translate></span>
+ </div>
+ ` : ``}
+ `;
+ }
+
+ changeLanguage(language) {
+ manager.language = language;
+ this.isVisible = false;
+ }
+
+ closeMenu() {
+ this.isVisible = false;
+ }
+
+ toggleMenu() {
+ this.isVisible = !this.isVisible;
+ }
+}
diff --git a/ui/app/main/src/components/or-language/src/style.ts b/ui/app/main/src/components/or-language/src/style.ts
new file mode 100644
index 000000000..28c8e330b
--- /dev/null
+++ b/ui/app/main/src/components/or-language/src/style.ts
@@ -0,0 +1,37 @@
+import {css} from "lit-element";
+
+// language=CSS
+export const style = css`
+ :host {
+ position: relative;
+ }
+
+ .dropdown-menu {
+ position: absolute;
+ top: 100%;
+ box-shadow: rgba(0, 0, 0, 0.3) 0 5px 5px -2px;
+ width: 120px;
+ background-color: white;
+ right: 0;
+ }
+
+ span {
+ display: block;
+ height: 40px;
+ line-height: 40px;
+ }
+
+ .background-close {
+ display: none;
+ position: fixed;
+ width: 100vw;
+ height: 100vh;
+ top: 0;
+ left: 0;
+ z-index: 0;
+ }
+
+ .background-close.active {
+ display: block;
+ }
+`;
\ No newline at end of file
diff --git a/ui/app/main/src/components/pages/page-assets.ts b/ui/app/main/src/components/pages/page-assets.ts
new file mode 100644
index 000000000..8b9b6c950
--- /dev/null
+++ b/ui/app/main/src/components/pages/page-assets.ts
@@ -0,0 +1,161 @@
+import {customElement, html, LitElement, property, TemplateResult, css, unsafeCSS} from "lit-element";
+import {store} from "../../store";
+import {connect} from "pwa-helpers/connect-mixin";
+import "@openremote/or-asset-tree";
+import "@openremote/or-asset-viewer";
+import {ViewerConfig} from "@openremote/or-asset-viewer";
+import {OrAssetTreeSelectionChangedEvent} from "@openremote/or-asset-tree";
+import {DefaultBoxShadow} from "@openremote/core";
+import moment from "moment";
+import {router} from "../../index";
+
+// language=CSS
+const style = css`
+
+ or-asset-tree {
+ align-items: stretch;
+ z-index: 1;
+ }
+
+ .hideMobile {
+ display: none;
+ }
+
+ or-asset-viewer {
+ align-items: stretch;
+ z-index: 0;
+ }
+
+ @media only screen and (min-width: 768px){
+ or-asset-tree {
+ width: 300px;
+ min-width: 300px;
+ box-shadow: ${unsafeCSS(DefaultBoxShadow)}
+ }
+
+ .hideMobile {
+ display: flex;
+ }
+
+ or-asset-viewer,
+ or-asset-viewer.hideMobile {
+ display: initial;
+ }
+
+
+
+ }
+`;
+
+const viewerConfig: ViewerConfig = {
+ historyConfig: {
+ table: {
+ attributeNames: {
+ "gunshotEvent": {
+ columns: [
+ {
+ header: "area",
+ type: "prop",
+ path: "$.content.area",
+ styles: {
+ width: "20%"
+ }
+ },
+ {
+ header: "location",
+ type: "prop",
+ path: "$.content.triggers[0].position.coordinates",
+ styles: {
+ width: "30%"
+ },
+ contentProvider: (datapoint, value, config) => {
+ if (Array.isArray(value)) {
+ return "[" + Number(value[0]).toLocaleString(undefined, {minimumFractionDigits: 5, maximumFractionDigits: 5}) + ", " + Number(value[1]).toLocaleString(undefined, {minimumFractionDigits: 5, maximumFractionDigits: 5}) + "]"
+ }
+ }
+ },
+ {
+ header: "intensity",
+ type: "prop",
+ path: "$.content.triggers[0].intensity",
+ styles: {
+ width: "25%"
+ },
+ contentProvider: (datapoint, value, config) => {
+ return Number(value).toLocaleString(undefined, {maximumFractionDigits: 0})
+ }
+ },
+ {
+ header: "timestamp",
+ type: "prop",
+ path: "$.content.time",
+ styles: {
+ width: "25%"
+ },
+ contentProvider: (datapoint, value, config) => {
+ if (value) {
+ return moment(value).format("L HH:mm:ss");
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ default: {
+ panels: {
+ "attributes": {
+ exclude: ["location"]
+ }
+ }
+ },
+ assetTypes: {
+ "urn:openremote:asset:cdpstrijp:topic": {
+ panels: {
+ "attributes": {
+ exclude: ["location", "status"]
+ }
+ }
+ }
+ }
+};
+
+@customElement("page-assets")
+class PageAssets extends connect(store)(LitElement) {
+
+ static get styles() {
+ return style;
+ }
+
+ @property()
+ protected _assetId;
+
+ constructor() {
+ super();
+ this.addEventListener(OrAssetTreeSelectionChangedEvent.NAME, (evt) => this._onTreeSelectionChanged(evt));
+ }
+
+ protected render(): TemplateResult | void {
+ const selectedIds = [this._assetId];
+ return html`
+ <or-asset-tree class="${this._assetId ? "hideMobile" : ""}" .selectedIds="${selectedIds}"></or-asset-tree>
+ <or-asset-viewer class="${!this._assetId ? "hideMobile" : ""}" .config="${viewerConfig}" .assetId="${this._assetId}"></or-asset-viewer>
+ `;
+ }
+
+ stateChanged(state) {
+ if(state.app.activeAsset && this._assetId !== state.app.activeAsset) {
+ this._assetId = state.app.activeAsset
+ } else if (!state.app.activeAsset) {
+ this._assetId = null;
+ }
+ }
+
+ protected _onTreeSelectionChanged(event: OrAssetTreeSelectionChangedEvent) {
+ const nodes = event.detail;
+ if(nodes[0]){
+ router.navigate('assets/'+nodes[0].asset.id);
+ }
+ }
+}
diff --git a/ui/app/main/src/components/pages/page-map.ts b/ui/app/main/src/components/pages/page-map.ts
new file mode 100644
index 000000000..1f981d01a
--- /dev/null
+++ b/ui/app/main/src/components/pages/page-map.ts
@@ -0,0 +1,102 @@
+import {css, customElement, html, LitElement, property, query} from "lit-element";
+import {connect} from "pwa-helpers/connect-mixin";
+import "@openremote/or-map";
+import {OrMap, OrMapClickedEvent, OrMapMarkerAsset, OrMapMarkerClickedEvent} from "@openremote/or-map";
+import {RootState, store} from "../../store";
+import {setCurrentAssetId, subscribeAssets, unsubscribeAssets} from "../../actions/map";
+import map from "../../reducers/map";
+import {createSelector} from "reselect";
+import {Asset} from "@openremote/model";
+import "../or-asset-summary-card";
+import {MapStyle} from "./style";
+import {router} from "../../index";
+store.addReducers({
+ map
+});
+
+@customElement("page-map")
+class PageMap extends connect(store)(LitElement) {
+
+ static get styles() {
+ return MapStyle;
+ }
+
+ @query("#map")
+ protected _map?: OrMap;
+
+ @property()
+ protected _assets: Asset[] = [];
+
+ @property()
+ protected _currentAsset?: Asset;
+
+ protected _assetSelector = (state: RootState) => state.map.assets;
+ protected _currentAssetSelector = (state: RootState) => state.app.activeAsset;
+
+ protected _getMapAssets = createSelector(
+ [this._assetSelector],
+ (assets) => {
+ return assets;
+ });
+
+ protected _getCurrentAsset = createSelector(
+ [this._assetSelector, this._currentAssetSelector],
+ (assets, currentId) => {
+ if (!currentId) {
+ return null;
+ }
+ return assets.find((asset) => asset.id === currentId);
+ });
+
+ protected render() {
+
+ return html`
+
+ ${this._currentAsset ? html `<or-asset-summary-card .asset="${this._currentAsset}"> </or-asset-summary-card>` : ``}
+
+ <or-map id="map" class="or-map">
+ ${
+ this._assets.map((asset) => {
+ return html`
+ <or-map-marker-asset ?active="${this._currentAsset && this._currentAsset.id === asset.id}" .asset="${asset}"></or-map-marker-asset>
+ `;
+ })
+ }
+ </or-map>
+ `;
+ }
+
+ public connectedCallback() {
+ super.connectedCallback();
+ this.addEventListener(OrMapMarkerClickedEvent.NAME, this.onMapMarkerClick);
+ this.addEventListener(OrMapClickedEvent.NAME, this.onMapClick);
+ store.dispatch(subscribeAssets());
+ }
+
+ public disconnectedCallback() {
+ super.disconnectedCallback();
+ this.removeEventListener(OrMapMarkerClickedEvent.NAME, this.onMapMarkerClick);
+ this.removeEventListener(OrMapClickedEvent.NAME, this.onMapClick);
+ store.dispatch(unsubscribeAssets());
+ }
+
+ stateChanged(state: RootState) {
+ this._assets = this._getMapAssets(state);
+ this._currentAsset = this._getCurrentAsset(state);
+ }
+
+ protected onMapMarkerClick(e: OrMapMarkerClickedEvent) {
+ const asset = (e.detail.marker as OrMapMarkerAsset).asset;
+ store.dispatch(setCurrentAssetId(asset.id));
+
+ router.navigate('map/'+asset.id);
+ }
+
+ protected onMapClick(e: OrMapClickedEvent) {
+ router.navigate('map');
+ }
+
+ protected getCurrentAsset() {
+ this._getCurrentAsset(store.getState());
+ }
+}
diff --git a/ui/app/main/src/components/pages/page-rules.ts b/ui/app/main/src/components/pages/page-rules.ts
new file mode 100644
index 000000000..6c328a4d2
--- /dev/null
+++ b/ui/app/main/src/components/pages/page-rules.ts
@@ -0,0 +1,27 @@
+import {html, LitElement, property, css, query, customElement, PropertyValues} from "lit-element";
+import {store} from "../../store";
+import {connect} from "pwa-helpers/connect-mixin";
+import "@openremote/or-rules-editor";
+
+@customElement("page-rules")
+class PageRules extends connect(store)(LitElement) {
+
+ static get styles() {
+ return css`
+ :host {
+
+ }
+
+ or-rules-editor {
+ width: 100%;
+ height: 100%;
+ }
+ `;
+ }
+
+ protected render() {
+ return html`
+ <or-rules-editor></or-rules-editor>
+ `;
+ }
+}
diff --git a/ui/app/main/src/components/pages/style.ts b/ui/app/main/src/components/pages/style.ts
new file mode 100644
index 000000000..dda826bac
--- /dev/null
+++ b/ui/app/main/src/components/pages/style.ts
@@ -0,0 +1,33 @@
+import {css, CSSResult} from "lit-element";
+
+// language=CSS
+export const MapStyle: CSSResult = css`
+ or-asset-summary-card {
+ height: 166px;
+ position: absolute;
+ bottom: 0px;
+ right: 0px;
+ width: calc(100vw - 10px);
+ margin: 5px;
+ z-index: 99;
+ }
+
+ or-map {
+ display: block;
+ height: 100%;
+ width: 100%;
+ }
+
+ @media only screen and (min-width: 415px){
+ or-asset-summary-card {
+ position: absolute;
+ top: 20px;
+ right: 20px;
+ width: 320px;
+ margin: 0;
+ height: 400px; /* fallback for IE */
+ height: max-content;
+ max-height: calc(100vh - 150px);
+ }
+ }
+`;
\ No newline at end of file
diff --git a/ui/app/main/src/index.ts b/ui/app/main/src/index.ts
new file mode 100644
index 000000000..887327c25
--- /dev/null
+++ b/ui/app/main/src/index.ts
@@ -0,0 +1,63 @@
+import Navigo from "navigo";
+import manager, {Auth} from "@openremote/core";
+import {store} from "./store";
+import "./components/my-app";
+import {resolveApp, updatePage, updateRule, setActiveAsset} from "./actions/app";
+
+// Declare MANAGER_URL
+declare var MANAGER_URL: string;
+
+// Configure routing
+export const router = new Navigo(null, true, "#!");
+
+router.on({
+ "map": (params, query) => {
+ store.dispatch(setActiveAsset(null));
+ store.dispatch(updatePage("map"));
+ },
+ "map/:id": (params, query) => {
+ store.dispatch(setActiveAsset(params.id));
+ store.dispatch(updatePage("map"));
+ },
+ "assets": (params, query) => {
+ store.dispatch(setActiveAsset(null));
+ store.dispatch(updatePage("assets"));
+ },
+ "assets/:id": (params, query) => {
+ store.dispatch(setActiveAsset(params.id));
+ store.dispatch(updatePage("assets", params.id));
+ },
+ "rules": (params, query) => {
+ store.dispatch(updatePage("rules"));
+ },
+ "rules/:id": (params, query) => {
+ store.dispatch(updateRule(params.id));
+ store.dispatch(updatePage("rules"));
+ },
+ "*": (params, query) => {
+ store.dispatch(updatePage("map"));
+ }
+});
+
+function getUrlParameter(name) {
+ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+ const regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
+ const results = regex.exec(location.search);
+ return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
+}
+
+const realmFromPath = getUrlParameter("realm");
+
+manager.init({
+ managerUrl: MANAGER_URL,
+ auth: Auth.KEYCLOAK,
+ autoLogin: true,
+ realm: realmFromPath,
+ consoleAutoEnable: true,
+ loadTranslations: ["app", "or"]
+}).then(() => {
+ if (manager.authenticated) {
+ router.resolve();
+ store.dispatch(resolveApp(true));
+ }
+});
\ No newline at end of file
diff --git a/ui/app/main/src/reducers/app.ts b/ui/app/main/src/reducers/app.ts
new file mode 100644
index 000000000..6ceece8da
--- /dev/null
+++ b/ui/app/main/src/reducers/app.ts
@@ -0,0 +1,60 @@
+import { Reducer } from "redux";
+import {
+ UPDATE_PAGE,
+ SET_SCROLL_TOP,
+ UPDATE_DRAWER,
+ RESOLVE_APP,
+ AppAction, SET_ACTIVE_ASSET
+} from "../actions/app";
+
+export interface AppState {
+ page: string;
+ activeAsset: string;
+ offline: boolean;
+ resolved: boolean,
+ drawerOpened: boolean;
+ scrollTop: number;
+}
+
+const INITIAL_STATE: AppState = {
+ page: "",
+ activeAsset: undefined,
+ offline: false,
+ resolved: false,
+ drawerOpened: false,
+ scrollTop: 0,
+};
+
+const app: Reducer<AppState, AppAction> = (state = INITIAL_STATE, action) => {
+ switch (action.type) {
+ case UPDATE_PAGE:
+ return {
+ ...state,
+ page: action.page
+ };
+ case RESOLVE_APP:
+ return {
+ ...state,
+ resolved: action.resolved
+ };
+ case UPDATE_DRAWER:
+ return {
+ ...state,
+ drawerOpened: action.opened
+ };
+ case SET_SCROLL_TOP:
+ return {
+ ...state,
+ scrollTop: action.top
+ };
+ case SET_ACTIVE_ASSET:
+ return {
+ ...state,
+ activeAsset: action.assetId
+ };
+ default:
+ return state;
+ }
+};
+
+export default app;
diff --git a/ui/app/main/src/reducers/map.ts b/ui/app/main/src/reducers/map.ts
new file mode 100644
index 000000000..49113055a
--- /dev/null
+++ b/ui/app/main/src/reducers/map.ts
@@ -0,0 +1,64 @@
+import {Reducer} from "redux";
+import {MapAction, ASSET_EVENT_RECEIVED, SET_CURRENT_ASSET_ID, ATTRIBUTE_EVENT_RECEIVED} from "../actions/map";
+import {Asset, AssetEventCause} from "@openremote/model";
+import {Util} from "@openremote/core";
+
+export interface MapState {
+ assets: Asset[];
+ currentAssetId: string;
+ assetSubscriptionId: string;
+ attributeSubscriptionId: string;
+}
+
+const INITIAL_STATE: MapState = {
+ assets: [],
+ currentAssetId: undefined,
+ assetSubscriptionId: undefined,
+ attributeSubscriptionId: undefined
+};
+
+const reducer: Reducer<MapState, MapAction> = (state = INITIAL_STATE, action) => {
+ switch (action.type) {
+
+ case ASSET_EVENT_RECEIVED: {
+ let assets = state.assets.filter((asst) => asst.id !== action.event.asset.id);
+ if (action.event.cause !== AssetEventCause.DELETE) {
+ assets.push(action.event.asset);
+ }
+ return {
+ ...state,
+ assets: assets
+ };
+ }
+ case ATTRIBUTE_EVENT_RECEIVED: {
+ let assets = state.assets;
+ const assetId = action.event.attributeState.attributeRef.entityId;
+ const index = assets.findIndex((asst) => asst.id === assetId);
+ let asset = index >= 0 ? assets[index] : null;
+
+ if (!asset) {
+ return state;
+ }
+
+ asset = Util.updateAsset(asset, action.event);
+
+ return {
+ ...state,
+ assets: [
+ ...assets.slice(0, index),
+ asset,
+ ...assets.slice(index + 1)
+ ]
+ };
+ }
+ case SET_CURRENT_ASSET_ID:
+ return {
+ ...state,
+ currentAssetId: action.id
+ };
+ default:
+ return state;
+ }
+};
+
+export default reducer;
diff --git a/ui/app/smart-building/src/store.ts b/ui/app/main/src/store.ts
similarity index 60%
rename from ui/app/smart-building/src/store.ts
rename to ui/app/main/src/store.ts
index a4cb0f6c2..934299bff 100644
--- a/ui/app/smart-building/src/store.ts
+++ b/ui/app/main/src/store.ts
@@ -1,38 +1,41 @@
+import {MapAction} from "./actions/map";
+
declare global {
- interface Window {
- process?: Object;
- __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose;
- }
+ interface Window {
+ process?: Object;
+ __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose;
+ }
}
import {
- createStore,
- compose,
- applyMiddleware,
- combineReducers,
- Reducer,
- StoreEnhancer
+ createStore,
+ compose,
+ applyMiddleware,
+ combineReducers,
+ Reducer,
+ StoreEnhancer
} from "redux";
-
import thunk, { ThunkMiddleware } from "redux-thunk";
-import { lazyReducerEnhancer } from "pwa-helpers/lazy-reducer-enhancer.js";
+import { lazyReducerEnhancer } from "pwa-helpers/lazy-reducer-enhancer";
import app, { AppState } from "./reducers/app";
import { AppAction } from "./actions/app";
+import {MapState} from "./reducers/map";
// Overall state extends static states and partials lazy states.
export interface RootState {
- app?: AppState;
+ app?: AppState;
+ map?: MapState;
}
-export type RootAction = AppAction;
+export type RootAction = AppAction | MapAction;
// Sets up a Chrome extension for time travel debugging.
// See https://github.com/zalmoxisus/redux-devtools-extension for more information.
const devCompose: <Ext0, Ext1, StateExt0, StateExt1>(
- f1: StoreEnhancer<Ext0, StateExt0>, f2: StoreEnhancer<Ext1, StateExt1>
+ f1: StoreEnhancer<Ext0, StateExt0>, f2: StoreEnhancer<Ext1, StateExt1>
) => StoreEnhancer<Ext0 & Ext1, StateExt0 & StateExt1> =
- window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
+ window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
// Initializes the Redux store with a lazyReducerEnhancer (so that you can
// lazily add reducers after the store has been created) and redux-thunk (so
@@ -40,13 +43,14 @@ const devCompose: <Ext0, Ext1, StateExt0, StateExt1>(
// section of the wiki for more details:
// https://github.com/Polymer/pwa-starter-kit/wiki/4.-Redux-and-state-management
export const store = createStore(
- state => state as Reducer<RootState, RootAction>,
- devCompose(
- lazyReducerEnhancer(combineReducers),
- applyMiddleware(thunk as ThunkMiddleware<RootState, RootAction>))
+ (state) => state as Reducer<RootState, RootAction>,
+ devCompose(
+ lazyReducerEnhancer(combineReducers),
+ applyMiddleware(thunk as ThunkMiddleware<RootState, RootAction>))
);
// Initially loaded reducers.
store.addReducers({
- app
+ app
});
+
diff --git a/ui/app/main/tsconfig.json b/ui/app/main/tsconfig.json
new file mode 100644
index 000000000..984465ff9
--- /dev/null
+++ b/ui/app/main/tsconfig.json
@@ -0,0 +1,22 @@
+{
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "tsBuildInfoFile": "./.tsbuildinfo",
+ "strict": false
+ },
+ "include": [
+ "./src",
+ "../../component/or-map/@types"
+ ],
+ "references": [
+ { "path": "../../component/core" },
+ { "path": "../../component/rest" },
+ { "path": "../../component/or-header" },
+ { "path": "../../component/or-rules-editor" },
+ { "path": "../../component/or-input" },
+ { "path": "../../component/or-map" },
+ { "path": "../../component/or-asset-tree" },
+ { "path": "../../component/or-attribute-input" },
+ { "path": "../../component/or-asset-viewer" }
+ ]
+}
\ No newline at end of file
diff --git a/ui/app/smart-building/webpack.config.js b/ui/app/main/webpack.config.js
similarity index 64%
rename from ui/app/smart-building/webpack.config.js
rename to ui/app/main/webpack.config.js
index c451d2279..bf743b1df 100644
--- a/ui/app/smart-building/webpack.config.js
+++ b/ui/app/main/webpack.config.js
@@ -1,33 +1,79 @@
-var production = process.env.NODE_ENV === "production";
var webpack = require("webpack");
var path = require("path");
-var managerUrl = production ? undefined : "http://localhost:8080";
var CopyWebpackPlugin = require("copy-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");
-module.exports = {
- mode: 'development',
+var config = {
entry: {
- 'bundle': './src/components/smart-building-app.js'
+ 'bundle': './src/index.js'
},
output: {
- path: __dirname + "/dist",
- filename: "[name].[hash].js",
- publicPath: ""
+ path: __dirname + "/dist",
+ publicPath: "",
+ filename: "[name].[hash].js"
},
- devtool: 'inline-source-map',
- devServer: {
- port: 9000,
- contentBase: './dist',
- publicPath: "/" + __dirname.split(path.sep).slice(-1)[0] + "/"
- },
- plugins: [
+ module: {
+ rules: [
+ {
+ test: /\.css$/,
+ use: [
+ { loader: "css-loader" }
+ ]
+ },
+ {
+ test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
+ loader: 'url-loader',
+ options: {
+ outputPath: "images/",
+ limit: 10000,
+ },
+ }
+ ]
+ }
+};
+
+module.exports = (env, argv) => {
+
+ const production = argv.mode === "production";
+ const managerUrl = production ? undefined : "http://localhost:8080";
+ const IS_DEV_SERVER = process.argv.find(arg => arg.includes('webpack-dev-server'));
+ const OUTPUT_PATH = IS_DEV_SERVER ? 'src' : 'dist';
+
+ // Only use babel for production otherwise source maps don't work
+ if (production) {
+ config.module.rules.push(
+ {
+ test: /\.js$/,
+ include: function(modulePath) {
+ return /(@webcomponents[\/|\\]shadycss|lit-css|styled-lit-element|lit-element|lit-html|@polymer|@lit|pwa-helpers)/.test(modulePath) || !/node_modules/.test(modulePath);
+ },
+ use: [
+ {
+ loader: 'babel-loader'
+ }
+ ]
+ },
+ );
+ } else {
+ config.module.rules.push(
+ {
+ test: /\.js$/,
+ use: ["source-map-loader"],
+ enforce: "pre",
+ exclude: [
+ /node_modules/
+ ]
+ },
+ );
+ }
+
+ config.plugins = [
// Conditional compilation variables
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(production),
MANAGER_URL: JSON.stringify(managerUrl),
"process.env": {
- BABEL_ENV: JSON.stringify(process.env.NODE_ENV)
+ BABEL_ENV: JSON.stringify(argv.mode)
}
}),
new HtmlWebpackPlugin({
@@ -48,44 +94,28 @@ module.exports = {
{
from: "./locales",
to: "locales"
- }
- ])
- ],
- module: {
- rules: [
- {
- test: /\.js$/,
- use: ["source-map-loader"],
- enforce: "pre",
- exclude: [
- /node_modules/
- ]
- },
- {
- test: /\.js$/,
- include: function(modulePath) {
- return /(@webcomponents[\/|\\]shadycss|lit-css|styled-lit-element|lit-element|lit-html|@polymer|@lit|pwa-helpers)/.test(modulePath) || !/node_modules/.test(modulePath);
- },
- use: [
- {
- loader: 'babel-loader'
- }
- ]
},
{
- test: /\.css$/,
- use: [
- { loader: "css-loader" }
- ]
- },
- {
- test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
- loader: 'url-loader',
- options: {
- outputPath: "images/",
- limit: 10000,
- },
+ from: ".htaccess",
+ to: ".htaccess",
+ toType: 'file'
}
- ]
+ ])
+ ];
+
+ config.devtool = production ? false :"inline-source-map",
+ config.devServer = {
+ historyApiFallback: {
+ index: "/" + __dirname.split(path.sep).slice(-1)[0] + "/",
+ },
+ port: 9000,
+ publicPath: "/" + __dirname.split(path.sep).slice(-1)[0] + "/",
+ contentBase: OUTPUT_PATH,
+ disableHostCheck: true
+ };
+ config.watchOptions = {
+ ignored: ['**/*.ts', 'node_modules']
}
-};
+
+ return config;
+};
\ No newline at end of file
diff --git a/ui/app/smart-building-v1/build.gradle b/ui/app/smart-building-v1/build.gradle
deleted file mode 100644
index 9900b0d73..000000000
--- a/ui/app/smart-building-v1/build.gradle
+++ /dev/null
@@ -1,11 +0,0 @@
-task build {
- dependsOn tasks.getByPath(":yarnInstall")
-}
-
-task installDist(type: Copy) {
- dependsOn build
- from(projectDir) {
- exclude "gwt", "build.gradle", "package.json", "yarn.lock", ".bowerrc"
- }
- into "${project(':deployment').buildDir}/manager/app/${projectDir.name}"
-}
\ No newline at end of file
diff --git a/ui/app/smart-building-v1/index.html b/ui/app/smart-building-v1/index.html
deleted file mode 100644
index b673da527..000000000
--- a/ui/app/smart-building-v1/index.html
+++ /dev/null
@@ -1,55 +0,0 @@
-<!doctype html>
-<html>
-<head>
- <title>OpenRemote SmartHome Example</title>
-
- <!-- Some sensible meta tags -->
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1, user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="mobile-web-app-capable" content="yes">
-
- <!-- The language of the SmartHome app -->
- <meta name="or-language" content="en">
-
- <!-- ############## Required: Load WebComponents polyfill and components ############### -->
- <script src="/static/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
-
- <!-- Load the SmartHome app -->
- <link rel="import" href="./smart-home/smart-home-app.html">
-
- <style type="text/css">
- /* Recommended: Avoid flickering during loading/styling by hiding children of or-app */
- or-app > * {
- visibility: hidden;
- }
-
- /* Styles for the SmartHome app */
- html, body {
- margin: 0;
- min-height: 100vh;
- overflow: hidden;
- }
-
- body {
- background: var(--theme-white);
- font-family: 'Open Sans', 'Roboto', Helvetica, Arial, Lucida, sans-serif;
- }
- </style>
-
-</head>
-
-<body>
-
-<or-app login tenant-realm="tenantA" console-auto-enable="true">
-
- <smart-home-app>
- <!-- You can override the logo
- <img slot="logo" height="20" src="mylogo.png"/>
- -->
- </smart-home-app>
-
-</or-app>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/ui/app/smart-building-v1/package.json b/ui/app/smart-building-v1/package.json
deleted file mode 100644
index 66bcc2803..000000000
--- a/ui/app/smart-building-v1/package.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "name": "customerA",
- "version": "3.0.0",
- "homepage": "http://openremote.com/",
- "author": "OpenRemote Inc. <[email protected]>",
- "description": "OpenRemote SmartHome Example App",
- "main": "index.html",
- "license": "AGPL-3.0-or-later"
-}
diff --git a/ui/app/smart-building-v1/smart-home/img/co2.png b/ui/app/smart-building-v1/smart-home/img/co2.png
deleted file mode 100644
index 20f89dd60..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/co2.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/eye.png b/ui/app/smart-building-v1/smart-home/img/eye.png
deleted file mode 100644
index 228c524f4..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/eye.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/eye_large.png b/ui/app/smart-building-v1/smart-home/img/eye_large.png
deleted file mode 100644
index 9269aacd6..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/eye_large.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/eye_large_active.png b/ui/app/smart-building-v1/smart-home/img/eye_large_active.png
deleted file mode 100644
index e7596d0d5..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/eye_large_active.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/home_large_energy.png b/ui/app/smart-building-v1/smart-home/img/home_large_energy.png
deleted file mode 100644
index 1d522e134..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/home_large_energy.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/home_on.png b/ui/app/smart-building-v1/smart-home/img/home_on.png
deleted file mode 100644
index 955131fcd..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/home_on.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/humidity.png b/ui/app/smart-building-v1/smart-home/img/humidity.png
deleted file mode 100644
index f0304e259..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/humidity.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/lightbulb.png b/ui/app/smart-building-v1/smart-home/img/lightbulb.png
deleted file mode 100644
index 7016167dc..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/lightbulb.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/star.png b/ui/app/smart-building-v1/smart-home/img/star.png
deleted file mode 100644
index 374592cd5..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/star.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/temperature.png b/ui/app/smart-building-v1/smart-home/img/temperature.png
deleted file mode 100644
index 7abb2b09a..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/temperature.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/img/ventilation.png b/ui/app/smart-building-v1/smart-home/img/ventilation.png
deleted file mode 100644
index 68f4b4539..000000000
Binary files a/ui/app/smart-building-v1/smart-home/img/ventilation.png and /dev/null differ
diff --git a/ui/app/smart-building-v1/smart-home/locales.json b/ui/app/smart-building-v1/smart-home/locales.json
deleted file mode 100644
index 4072f9eb9..000000000
--- a/ui/app/smart-building-v1/smart-home/locales.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "en": {
- "scenes": "Scenes",
- "control": "Bediening",
- "climate": "Climate",
- "energy": "Energy",
- "security": "Alarm",
- "settings": "Settings",
- "messages": "Received messages",
- "contact": "Send message",
- "language": "Select language"
- },
- "nl": {
- "scenes": "Scenes",
- "control": "Bediening",
- "climate": "Klimaat",
- "energy": "Energie",
- "security": "Alarm",
- "settings": "Instellingen",
- "messages": "Ontvangen berichten",
- "contact": "Melding maken",
- "language": "Taal kiezen",
- "Morning": "Ochtend",
- "Day": "Dag",
- "Evening": "Avond",
- "Night": "Nacht",
- "Automatically switch scenes": "Automatisch scenes wisselen",
- "Lighting":"Verlichting",
- "Living room stand": "Woonkamer staande",
- "Living room ceiling": "Woonkamer plafond",
- "Appliances": "Apparaten",
- "Washing machine": "Wasmachine",
- "Dishwasher": "Vaatwasser",
- "Temperature": "Temperatuur",
- "Kitchen": "Keuken",
- "Living Room": "Woonkamer",
- "Hallway": "Gang",
- "Bedroom": "Slaapkamer",
- "Bathroom": "Badkamer",
- "Ventilation": "Ventilatie",
- "Ventilation Mode": "Ventilation Mode",
- "Speed": "Snelheid",
- "Auto": "Auto",
- "Low": "Laag",
- "Medium": "Medium",
- "High": "Hoog",
- "Carbon Dioxide": "Kooldioxide",
- "Humidity": "Luchtvochtigheid",
- "Electricity": "Elektriciteit",
- "Current usage": "Huidig verbruik",
- "Solar and battery": "Zon and batterij",
- "Mains": "Netstroom",
- "Solar energy": "zonne-energie",
- "Mains and solar energy usage": "Gebruik zonne-energie en netstroom",
- "Warm water": "Warm water",
- "Total": "Totaal",
- "Tap water": "Tapwater",
- "Heating": "Verwarming",
- "Tap water and heating usage": "Gebruik tapwater en verwarming",
- "From": "Van",
- "To": "Tot",
- "Date": "Datum",
- "Activity": "Activiteit",
- "No activity": "Geen activiteit",
- "On": "Aan",
- "Off": "Uit",
- "Log out": "Uitloggen",
- "Weekly schedule": "Weekschema",
- "Vacation": "Vakantie",
- "On vacation until": "op Vakantie tot",
- "Scene configuration": "Scene configuratie",
- "Temperature settings": "Temperatuur",
- "Setpoint": "Setpoint",
- "Alarm settings": "Alarm instellingen",
- "Enabled": "Actief",
- "Select": "Kiezen",
- "Monday": "Maandag",
- "Tuesday": "Dinsdag",
- "Wednesday": "Woensdag",
- "Thursday": "Donderdag",
- "Friday": "Vrijdag",
- "Saturday": "Zaterdag",
- "Sunday": "Zondag"
- }
-}
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-app.html b/ui/app/smart-building-v1/smart-home/smart-home-app.html
deleted file mode 100644
index 2ed7adc1c..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-app.html
+++ /dev/null
@@ -1,197 +0,0 @@
-<!-- The OpenRemote web components -->
-<link rel="import" href="/static/src/or-app/or-app.html">
-
-<!-- You can add other dependencies in package.json and then load them here -->
-
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-<link rel="import" href="smart-home-header.html">
-<link rel="import" href="smart-home-body.html">
-<link rel="import" href="smart-home-scenes.html">
-<link rel="import" href="smart-home-control.html">
-<link rel="import" href="smart-home-energy.html">
-<link rel="import" href="smart-home-security.html">
-<link rel="import" href="smart-home-climate.html">
-<link rel="import" href="smart-home-settings.html">
-<link rel="import" href="smart-home-footer.html">
-
-<dom-module id="smart-home-app">
- <template>
- <style include="smart-home-style">
- :host {
- min-height: 100vh;
- }
- </style>
-
- <app-location use-hash-as-path route="{{appLocation}}"></app-location>
-
- <smart-home-header active-nav="[[view]]">
-
- <template is="dom-if" if="[[!isActiveView(view, 'settings')]]">
- <slot slot="leftItem"
- name="logo">
- <span style="color: var(--theme-white); font-size: 1.1em;">{{localize(view)}}</span>
- </slot>
- <a slot="rightItem"
- href="#settings"><span class$="[[icon('ellipsis-v')]]"></span></a>
- </template>
-
- <template is="dom-if" if="[[isActiveView(view, 'settings')]]">
- <a slot="leftItem"
- href="#scenes"><span class$="[[icon('arrow-left')]]"></span>[[localize('Settings')]]
- </a>
- <div slot="rightItem"
- on-click="logout"><span class$="[[icon('sign-out-alt')]]"></span>[[localize('Log out')]]
- </div>
- </template>
-
- </smart-home-header>
-
- <smart-home-body>
-
- <smart-home-scenes hidden$="[[!isActiveView(view, 'scenes')]]"
- residence="[[residence]]"></smart-home-scenes>
-
- <smart-home-control hidden$="[[!isActiveView(view, 'control')]]"
- residence="[[residence]]"
- rooms="[[rooms]]"></smart-home-control>
-
- <smart-home-energy hidden$="[[!isActiveView(view, 'energy')]]"
- residence="[[residence]]"
- rooms="[[rooms]]"></smart-home-energy>
-
- <smart-home-security hidden$="[[!isActiveView(view, 'security')]]"
- residence="[[residence]]"
- rooms="[[rooms]]"></smart-home-security>
-
- <smart-home-climate hidden$="[[!isActiveView(view, 'climate')]]"
- residence="[[residence]]"
- rooms="[[rooms]]"></smart-home-climate>
-
- <smart-home-settings hidden$="[[!isActiveView(view, 'settings')]]"
- residence="[[residence]]"></smart-home-settings>
-
- <smart-home-messages hidden$="[[!isActiveView(view, 'messsages')]]"
- residence="[[residence]]"></smart-home-messages>
-
- <smart-home-contact hidden$="[[!isActiveView(view, 'contact')]]"
- residence="[[residence]]"></smart-home-contact>
-
- <smart-home-language hidden$="[[!isActiveView(view, 'language')]]"
- residence="[[residence]]"></smart-home-language>
-
- </smart-home-body>
-
- <smart-home-footer active-nav="[[view]]" hide-nav$="[[hideFooter(view)]]" />
- </template>
-
- <script>
- class SmartHomeApp extends SmartHomeComponent {
- static get is() {
- return "smart-home-app";
- }
-
- static get properties() {
- return {
- /**
- * The default start page.
- */
- defaultView: {
- type: String,
- value: "scenes"
- },
- /**
- * The residence asset of the current user.
- */
- residence: {
- type: Object
- },
- /**
- * The room assets of the current user.
- */
- rooms: {
- type: Array,
- value: []
- }
- }
- }
-
- ready() {
- super.ready();
-
- this.shadowRoot.host.classList.add("flex", "layout", "vertical");
-
- console.log("Ready, initialising application state");
- this.requests().sendAndReturn(
- (requestParams) => {
- let query = {
- select: {include: "ALL"},
- userId: this.getUserId()
- }
- openremote.REST.AssetResource.queryAssets(requestParams, query);
- },
- 200,
- (response) => {
- if (!response) {
- this.setError("error", "No assets assigned to user.");
- return;
- }
- response.forEach(asset => {
- // Take the first residence asset
- if (asset.type === "urn:openremote:asset:residence" && !this.residence) {
- this.set("residence", asset);
- }
- // And any room assets
- if (asset.type === "urn:openremote:asset:room") {
- this.push("rooms", asset);
- this.notifyPath("rooms");
- }
- })
- if (!this.residence) {
- this.setError("No residence asset found for user.");
- }
-
- // Subscribe to attribute events on residence and all rooms
- this.addAttributeEventListener(e => {
- this.onServiceAttributeEvent(e.detail);
- });
- let subscribedAssetIds = [this.residence.id];
- this.rooms.forEach(room => {
- subscribedAssetIds.push(room.id);
- })
- this.subscribeAttributeEvents(subscribedAssetIds);
- }
- );
- }
-
- hideFooter(view) {
- return super.isActiveView(view, 'settings') || super.isActiveView(view, 'messages') || super.isActiveView(view, 'contact') || super.isActiveView(view, 'language');
- }
-
- onServiceAttributeEvent(e) {
- // Use attribute event to update residence or room asset attribute value/valueTimestamp
- if (!e.attributeState)
- return
- let assetId = e.attributeState.attributeRef.entityId;
- let attributeName = e.attributeState.attributeRef.attributeName;
-
- // Update residence
- if (assetId === this.residence.id && attributeName in this.residence.attributes) {
- this.set("residence.attributes." + attributeName + ".value", e.attributeState.value);
- this.set("residence.attributes." + attributeName + ".valueTimestamp", e.timestamp);
- }
-
- // Update rooms
- this.rooms.forEach(room => {
- if (assetId === room.id && attributeName in room.attributes) {
- this.set("rooms." + this.rooms.indexOf(room) + ".attributes." + attributeName + ".value", e.attributeState.value);
- this.set("rooms." + this.rooms.indexOf(room) + ".attributes." + attributeName + ".valueTimestamp", e.timestamp);
- }
- });
- }
- }
-
- defineAppElement(SmartHomeApp, SmartHomeApp.is, "SmartHomeApp");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-body.html b/ui/app/smart-building-v1/smart-home/smart-home-body.html
deleted file mode 100644
index f15f7329c..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-body.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-
-<dom-module id="smart-home-body">
- <template>
- <style include="smart-home-style">
- </style>
-
- <slot></slot>
-
- </template>
-
- <script>
- class SmartHomeBody extends SmartHomeComponent {
- static get is() {
- return "smart-home-body";
- }
-
- ready() {
- super.ready();
- this.shadowRoot.host.classList.add("flex", "scroll", "layout", "vertical");
- }
- }
-
- defineAppElement(SmartHomeBody, SmartHomeBody.is, "SmartHomeBody");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-climate.html b/ui/app/smart-building-v1/smart-home/smart-home-climate.html
deleted file mode 100644
index c5a228257..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-climate.html
+++ /dev/null
@@ -1,293 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-<link rel="import" href="smart-home-section.html">
-<link rel="import" href="smart-home-temperature-select.html">
-
-<dom-module id="smart-home-climate">
- <template>
- <style include="smart-home-style">
-
- .roomLabel {
- padding: 0 10px;
- }
-
- .roomItem,
- .ventilationItem {
- margin: 10px 0;
- }
-
- .ventilationLabel {
- margin: 0 10px;
- }
-
- .attributeValue {
- margin-left: 20px;
- font-size: 1.2em;
- line-height: 1;
- white-space: nowrap;
- }
- </style>
-
- <div id="page-container">
-
- <template is="dom-if" if="[[roomsTemperature]]">
- <div class="layout horizontal center heading">
- <span>[[localize('Temperature')]]</span>
- </div>
-
- <div class="section">
- <template is="dom-repeat" items="[[roomsTemperature]]">
- <div class="layout horizontal center roomItem">
- <div class="layout vertical center-center">
- <img height="30" src="smart-home/img/temperature.png"/>
- </div>
- <div class="flex layout horizontal center roomLabel">
- [[localize(item.roomName)]]
- </div>
- <template is="dom-if" if="[[item.roomHasTargetTemperature]]">
- <div class="targetTemperature">
- <smart-home-temperature-select
- temperature="[[item.targetTemperature]]"
- on-change="onTargetTemperatureChange"
- temperature-format="[[item.targetTemperatureFormat]]"></smart-home-temperature-select>
- </div>
- </template>
- <template is="dom-if" if="[[item.roomHasCurrentTemperature]]">
- <div class="attributeValue">
- [[formatAttributeValue(item.currentTemperatureFormat, item.currentTemperature)]]
- </div>
- </template>
- </div>
- </template>
- </div>
- </template>
-
- <div class="layout horizontal center heading">
- <span>[[localize('Ventilation')]]</span>
- </div>
-
- <div class="section">
- <div class="layout horizontal center ventilationItem">
- <div class="layout vertical center-center">
- <img height="30" src="smart-home/img/ventilation.png"/>
- </div>
- <div class="flex layout horizontal ventilationLabel">
- [[localize('Ventilation')]]
- </div>
- <div class="ventilationMode">
- <div class="or-Select">
- <select value="{{ventilationMode::change}}"
- title="[[localize('Ventilation Mode')]]">
- <option value="AUTO">[[localize('Auto')]]</option>
- <option value="LOW">[[localize('Low')]]</option>
- <option value="MEDIUM">[[localize('Medium')]]</option>
- <option value="HIGH">[[localize('High')]]</option>
- </select>
- </div>
- </div>
- </div>
- </div>
-
-
- <template is="dom-if" if="[[roomsCO2]]">
- <div class="layout horizontal center heading">
- <span>CO<sub>2</sub></span>
- </div>
-
- <div class="section">
- <template is="dom-repeat" items="[[roomsCO2]]">
- <div class="layout horizontal center roomItem">
- <div class="layout vertical center-center">
- <img height="30" src="smart-home/img/co2.png"/>
- </div>
- <div class="flex layout horizontal center roomLabel">
- [[localize(item.roomName)]]
- </div>
- <div class="attributeValue">
- [[formatAttributeValue(item.co2LevelFormat, item.co2Level)]]
- </div>
- </div>
- </template>
- </div>
- </template>
-
- <template is="dom-if" if="[[roomsHumidity]]">
- <div class="layout horizontal center heading">
- <span>[[localize('Humidity')]]</span>
- </div>
-
- <div class="section">
- <template is="dom-repeat" items="[[roomsHumidity]]">
- <div class="layout horizontal center roomItem">
- <div class="layout vertical center-center">
- <img height="30" src="smart-home/img/humidity.png"/>
- </div>
- <div class="flex layout horizontal center roomLabel">
- [[localize(item.roomName)]]
- </div>
- <div class="attributeValue">
- [[formatAttributeValue(item.humidityFormat, item.humidity)]]
- </div>
- </div>
- </template>
- </div>
- </template>
- </div>
- </template>
-
- <script>
- class SmartHomeClimate extends SmartHomeComponent {
- static get is() {
- return "smart-home-climate";
- }
-
- static get properties() {
- return {
- roomsTemperature: {
- type: Array,
- computed: "computeRoomsTemperature(rooms.*)"
- },
- roomsCO2: {
- type: Array,
- computed: "computeRoomsCO2(rooms.*)"
- },
- roomsHumidity: {
- type: Array,
- computed: "computeRoomsHumidity(rooms.*)"
- },
- ventilationMode: {
- type: String,
- observer: "onVentilationModeChange"
- }
- }
- }
-
- static get observers() {
- return [
- "onResidenceChange(residence.*)"
- ]
- }
-
- computeRoomsTemperature() {
- let roomsTemperature = [];
- if (!this.rooms)
- return roomsTemperature;
- this.rooms.forEach(room => {
- if ("currentTemperature" in room.attributes || "targetTemperature" in room.attributes) {
- roomsTemperature.push({
- roomId: room.id,
- roomName: room.name,
- roomHasCurrentTemperature: "currentTemperature" in room.attributes,
- currentTemperature: room.attributes.currentTemperature
- ? room.attributes.currentTemperature.value
- : null,
- currentTemperatureFormat: room.attributes.currentTemperature
- ? room.attributes.currentTemperature.meta.filter(m => m.name === "urn:openremote:asset:meta:format").map(m => m.value)[0]
- : null,
- roomHasTargetTemperature: "targetTemperature" in room.attributes,
- targetTemperature: room.attributes.targetTemperature
- ? parseInt(room.attributes.targetTemperature.value) // TODO Currently we cut off decimal (19.5 -> 19)
- : null,
- targetTemperatureFormat: room.attributes.targetTemperature
- ? room.attributes.targetTemperature.meta.filter(m => m.name === "urn:openremote:asset:meta:format").map(m => m.value)[0]
- : null,
- });
- }
- })
- return roomsTemperature;
- }
-
- computeRoomsCO2() {
- let roomsCO2 = [];
- if (!this.rooms)
- return roomsCO2;
- this.rooms.forEach(room => {
- if ("co2Level" in room.attributes) {
- roomsCO2.push({
- roomId: room.id,
- roomName: room.name,
- co2Level: room.attributes.co2Level.value,
- co2LevelFormat: room.attributes.co2Level.meta.filter(m => m.name === "urn:openremote:asset:meta:format").map(m => m.value)[0],
- });
- }
- })
- return roomsCO2;
- }
-
- computeRoomsHumidity() {
- let roomsHumidity = [];
- if (!this.rooms)
- return roomsHumidity;
- this.rooms.forEach(room => {
- if ("humidity" in room.attributes) {
- roomsHumidity.push({
- roomId: room.id,
- roomName: room.name,
- humidity: room.attributes.humidity.value,
- humidityFormat: room.attributes.humidity.meta.filter(m => m.name === "urn:openremote:asset:meta:format").map(m => m.value)[0],
- });
- }
- })
- return roomsHumidity;
- }
-
- onResidenceChange() {
- let ventilationMode;
- if ("ventilationAuto" in this.residence.attributes && this.residence.attributes.ventilationAuto.value) {
- ventilationMode = "AUTO";
- } else if ("ventilationLevel" in this.residence.attributes) {
- if (!this.residence.attributes.ventilationLevel.value) {
- ventilationMode = "LOW";
- } else if (this.residence.attributes.ventilationLevel.value <= 64) {
- ventilationMode = "LOW";
- } else if (this.residence.attributes.ventilationLevel.value <= 128) {
- ventilationMode = "MEDIUM";
- } else if (this.residence.attributes.ventilationLevel.value <= 255) {
- ventilationMode = "HIGH";
- }
- }
- this.set("ventilationMode", ventilationMode);
- }
-
- onTargetTemperatureChange(e) {
- this.sendAttributeEvent(
- e.model.item.roomId, "targetTemperature", parseFloat(e.detail)
- );
- }
-
- onVentilationModeChange() {
- if (this.ventilationMode === "AUTO") {
- if (!this.residence.attributes.ventilationAuto.value) {
- this.sendAttributeEvent(
- this.residence.id, "ventilationAuto", true
- );
- }
- return;
- }
- let ventilationLevel = null;
- if (this.ventilationMode === "LOW") {
- ventilationLevel = 64;
- } else if (this.ventilationMode === "MEDIUM") {
- ventilationLevel = 128;
- } else if (this.ventilationMode === "HIGH") {
- ventilationLevel = 255;
- }
-
- if (this.residence.attributes.ventilationAuto.value) {
- this.sendAttributeEvent(
- this.residence.id, "ventilationAuto", false
- );
- }
-
- if (this.residence.attributes.ventilationLevel.value !== ventilationLevel) {
- this.sendAttributeEvent(
- this.residence.id, "ventilationLevel", ventilationLevel
- );
- }
- }
- }
-
- defineAppElement(SmartHomeClimate, SmartHomeClimate.is, "SmartHomeClimate");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-component.html b/ui/app/smart-building-v1/smart-home/smart-home-component.html
deleted file mode 100644
index 7f7c7e769..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-component.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<dom-module id="smart-home-component">
- <script>
- class SmartHomeComponent extends OpenRemoteComponent {
-
- static get properties() {
- return {
- localesResource: {
- type: String,
- value: "locales.json"
- }
- }
- }
- }
- </script>
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-control.html b/ui/app/smart-building-v1/smart-home/smart-home-control.html
deleted file mode 100644
index 1c788c1e5..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-control.html
+++ /dev/null
@@ -1,280 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-<link rel="import" href="smart-home-section.html">
-<link rel="import" href="smart-home-temperature-select.html">
-
-<dom-module id="smart-home-control">
- <template>
- <style include="smart-home-style">
-
- .smartSwitchItem {
- margin: 10px 0;
- }
-
- .smartSwitchLabel {
- padding: 0 10px;
- }
-
- .smartSwitchMode {
- }
-
- .smartSwitchTomorrow {
- padding-left: 5px;
- font-size: 0.7em;
- }
-
- .smartSwitchTimeInput {
- margin-left: 5px;
- }
-
- </style>
-
- <div id="page-container">
- <div class="layout horizontal center heading">
- <span>[[localize('Lighting')]]</span>
- </div>
-
- <div class="section">
- <template is="dom-repeat" items="[[lights]]">
- <template is="dom-if" if="[[isLightType(item, 'BOOLEAN')]]">
- <div class="layout horizontal center smartSwitchItem">
- <div><img height="30" src="smart-home/img/lightbulb.png"/></div>
- <div class="flex layout horizontal smartSwitchLabel">
- [[item.label]]
- </div>
- <template is="dom-if" if="[[isLightType(item, 'BOOLEAN')]]">
- <div class="layout horizontal smartSwitchMode">
- <or-checkbox checked="[[item.value]]"
- on-change="onLightChange"></or-checkbox>
- </div>
- </template>
- <template is="dom-if" if="[[isLightType(item, 'NUMBER')]]">
- <div class="layout horizontal center">
- <span>SLIDER</span>
- </div>
- </template>
- </div>
- </template>
- </template>
- </div>
-
- <div class="layout horizontal center heading">
- <span>[[localize('Appliances')]]</span>
- </div>
-
- <div class="section">
- <template is="dom-repeat" items="[[smartSwitches]]">
- <div class="layout horizontal center smartSwitchItem">
- <div><img height="30" src="smart-home/img/home_on.png"/></div>
- <div class="flex layout horizontal smartSwitchLabel">
- [[item.label]]
- </div>
- <div class="layout horizontal smartSwitchMode">
- <div class="or-Select">
- <select value="{{item.mode::change}}"
- on-change="onSmartSwitchModeChange"
- title="[[localize('Mode')]]">
- <option value="NOW_ON">[[localize('Now on')]]</option>
- <option value="ON_AT">[[localize('On at')]]</option>
- <option value="READY_AT">[[localize('Ready at')]]</option>
- </select>
- </div>
- </div>
- <template is="dom-if" if="[[item.hourMinuteVisible]]">
- <div class="layout horizontal center">
- <template is="dom-if" if="[[item.hourMinuteTomorrow]]">
- <div class="smartSwitchTomorrow">([[localize('tomorrow')]])</div>
- </template>
- <input class="or-Input or-InputTime smartSwitchTimeInput"
- title="[[localize('Begin/end of cycle')]]"
- type="time"
- step="60"
- required
- value="{{item.hourMinute::input}}"
- on-input="onSmartSwitchHourMinuteChange"/>
- </div>
- </template>
- </div>
- </template>
- </div>
- </div>
- </template>
-
- <script>
- class SmartHomeControl extends SmartHomeComponent {
- static get is() {
- return "smart-home-control";
- }
-
- static get properties() {
- return {
- smartSwitches: {
- type: Array,
- computed: "computeSmartSwitches(rooms.*)"
- },
- lights: {
- type: Array,
- computed: "computeLights(rooms.*)"
- },
- smartSwitchHourMinuteChangeDebouncer: {
- type: Object,
- value: {}
- }
- }
- }
-
- computeLights() {
- let lights = [];
- if (!this.rooms)
- return lights;
- this.rooms.forEach(room => {
- Object.keys(room.attributes).forEach(attr => {
- if (attr.startsWith("lights")) {
- lights.push(
- {
- roomId: room.id,
- name: attr,
- label: this.getLightsLabel(room.name, room.attributes[attr]),
- type: room.attributes[attr].type,
- value: room.attributes[attr].value
- }
- )
- }
- })
- })
- return lights;
- }
-
- getLightsLabel(roomName, attribute) {
- let name = roomName;
-
- if (attribute && attribute.meta) {
- for (let i = 0; i < attribute.meta.length; i++) {
- let metaItem = attribute.meta[i];
- if (metaItem.name === "urn:openremote:asset:meta:label") {
- name = metaItem.value;
- }
- }
- }
-
- return this.localize(name);
- }
-
- isLightType(item, type) {
- return item.type === type;
- }
-
- onLightChange(e) {
- let light = e.model.item;
- let value = e.detail;
- this.sendAttributeEvent(
- light.roomId, light.name, value
- );
- }
-
- computeSmartSwitches() {
- let smartSwitches = [];
- if (!this.rooms)
- return smartSwitches;
- this.rooms.forEach(room => {
- if ("smartSwitchModeA" in room.attributes && "smartSwitchBeginEndA" in room.attributes) {
- smartSwitches.push(
- this.computeSmartSwitch(room.id, this.localize("Switch A"), "A", room.attributes.smartSwitchModeA.value, room.attributes.smartSwitchBeginEndA.value)
- );
- }
- if ("smartSwitchModeB" in room.attributes && "smartSwitchBeginEndB" in room.attributes) {
- smartSwitches.push(
- this.computeSmartSwitch(room.id, this.localize("Switch B"), "B", room.attributes.smartSwitchModeB.value, room.attributes.smartSwitchBeginEndB.value)
- );
- }
- if ("smartSwitchModeC" in room.attributes && "smartSwitchBeginEndC" in room.attributes) {
- smartSwitches.push(
- this.computeSmartSwitch(room.id, this.localize("Switch C"), "C", room.attributes.smartSwitchModeC.value, room.attributes.smartSwitchBeginEndC.value)
- );
- }
- })
- return smartSwitches;
- }
-
- computeSmartSwitch(roomId, label, attributeSuffix, mode, beginEnd) {
- return {
- roomId: roomId,
- label: label,
- suffix: attributeSuffix,
- mode: mode ? mode : "NOW_ON", // Default to NOW_ON when mode is empty
- hourMinute: beginEnd ? moment(beginEnd).format("HH:mm") : null,
- hourMinuteVisible: mode && (mode === "ON_AT" || mode === "READY_AT"),
- hourMinuteTomorrow: beginEnd ? moment(beginEnd).isAfter(moment(), "day") : false,
- }
- }
-
- onSmartSwitchModeChange(e) {
- let smartSwitch = e.model.item;
- let smartSwitchMode = e.target.value; // model.item.mode is not updated yet when this event listener runs
- let beginEndTimestamp = this.computeSmartSwitchBeginEndTimestamp(smartSwitchMode, smartSwitch.hourMinute);
-
- this.sendAttributeEvent(
- smartSwitch.roomId, "smartSwitchMode" + smartSwitch.suffix, smartSwitchMode
- );
- this.sendAttributeEvent(
- smartSwitch.roomId, "smartSwitchBeginEnd" + smartSwitch.suffix, beginEndTimestamp
- );
- }
-
- onSmartSwitchHourMinuteChange(e) {
- let smartSwitch = e.model.item;
- let hourMinute = e.target.value; // model.item.hourMinute is not updated yet when this event listener runs
- let beginEndTimestamp = this.computeSmartSwitchBeginEndTimestamp(smartSwitch.mode, hourMinute);
-
- // Delay/debounce sending the change to service, the user is probably still editing
- // the hour/minute (cursor keys, spinner button)
- this.smartSwitchHourMinuteChangeDebouncer[smartSwitch] = Polymer.Debouncer.debounce(
- this.smartSwitchHourMinuteChangeDebouncer[smartSwitch],
- Polymer.Async.timeOut.after(3000),
- () => {
- // If entered time is empty, switch to now on
- if (!hourMinute) {
- this.sendAttributeEvent(
- smartSwitch.roomId, "smartSwitchMode" + smartSwitch.suffix, "NOW_ON"
- );
- return;
- }
- this.sendAttributeEvent(
- smartSwitch.roomId, "smartSwitchBeginEnd" + smartSwitch.suffix, beginEndTimestamp
- );
- });
- }
-
- computeSmartSwitchBeginEndTimestamp(mode, hourMinute) {
- // Get the moment of the user-supplied hour/minute or current time +2m
- let hourMinuteMoment = hourMinute ? moment(hourMinute, "HH:mm") : moment().add(2, "minutes");
-
- // Try to correct hour/minute depending on selected mode
- if (!mode || mode === "NOW_ON") {
-
- // No mode or now on, empty begin/end timestamp
- hourMinuteMoment = null;
-
- } else if (mode === "ON_AT") {
-
- // If it's not one minute in the future (time it takes to process event on server), add one day
- if (hourMinuteMoment.isBefore(moment().add(1, "minutes"))) {
- hourMinuteMoment = hourMinuteMoment.add(1, "days");
- }
-
- } else if (mode === "READY_AT") {
-
- // If cycle can't finish in the next (2.5h cycle duration, +1m for event processing), add one day
- if (hourMinuteMoment.isBefore(moment().add(151, "minutes"))) {
- hourMinuteMoment = hourMinuteMoment.add(1, "days");
- }
- }
-
- return hourMinuteMoment ? hourMinuteMoment.valueOf() : null;
- }
- }
-
- defineAppElement(SmartHomeControl, SmartHomeControl.is, "SmartHomeControl");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-energy.html b/ui/app/smart-building-v1/smart-home/smart-home-energy.html
deleted file mode 100644
index fce42ac5f..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-energy.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-<link rel="import" href="smart-home-section.html">
-
-<dom-module id="smart-home-energy">
- <template>
- <style include="smart-home-style">
-
-
- </style>
-
- <!-- TODO This section is not functional, not bound to any assets
- <smart-home-section>
- <div class="layout horizontal center">
- <div class="flex" style="position: relative; padding-left: 10px;">
- <div style="position: absolute;">
- <div style="position: relative; left: 40px; top: 65px;">12%</div>
- <div style="position: relative; top: 65px; left: 41px; font-size: x-small;">[[localize('Green')]]</div>
- </div>
- <img width="110" height="110" src="smart-home/img/home_large_energy.png"/>
- </div>
- <div class="layout vertical" style="font-size: smaller; margin-right: 5px;">
-
- <div class="layout horizontal" style="margin: 5px 0;">
- <div class="flex" style="padding-right: 20px;">[[localize('Usage today')]]</div>
- <div>418W</div>
- </div>
-
- <div class="layout horizontal" style="margin: 5px 0; color: var(--theme-mediumgrey)">
- <div class="flex">[[localize('Zone & Battery')]]</div>
- <div>9%</div>
- </div>
-
- <div style="margin-bottom:5px;width:87%;height:10px; background-color: var(--theme-lightgreen);"></div>
- <div class="" style="width:17%;height:10px; background-color: var(--theme-mediumgrey)"></div>
-
- <div class="layout horizontal" style="margin: 5px 0; color: var(--theme-mediumgrey)">
- <div class="flex">[[localize('Grid')]]</div>
- <div>91%</div>
- </div>
- </div>
- </div>
- </smart-home-section>
- -->
-
- </template>
-
- <script>
- class SmartHomeEnergy extends SmartHomeComponent {
- static get is() {
- return "smart-home-energy";
- }
-
- static get properties() {
- return {
-
- }
- }
-
-
-
- }
-
- defineAppElement(SmartHomeEnergy, SmartHomeEnergy.is, "SmartHomeEnergy");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-footer.html b/ui/app/smart-building-v1/smart-home/smart-home-footer.html
deleted file mode 100644
index f23a4cc42..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-footer.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-
-<dom-module id="smart-home-footer">
- <template>
- <style include="smart-home-style">
-
- .footer {
- font-size: 25px;
- box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
- }
-
- .headerItem ::slotted(*) {
- color: var(--theme-white);
- text-decoration: none;
- font-size: 20px;
- cursor: pointer;
- }
-
- .nav {
- background-color: var(--theme-white);
- }
-
- .navItem {
- color: var(--theme-mediumgrey);
- text-align: center;
- padding: 10px;
- cursor: pointer;
- text-decoration: none;
- border-top: 3px solid transparent;
- border-bottom: 3px solid transparent;
- }
-
- .navItem.active {
- color: var(--theme-black);
- font-weight: 600;
- }
-
- </style>
-
- <template is="dom-if" if="[[!hideNav]]">
- <div class="footer layout horizontal nav">
- <a href="#scenes" class$="[[getNavItemClass(activeNav, 'scenes')]]"><span class$="[[icon('th-large')]]"></span></a>
- <a href="#control" class$="[[getNavItemClass(activeNav, 'control')]]"><span class$="[[icon('lightbulb')]]"></span></a>
- <a href="#climate" class$="[[getNavItemClass(activeNav, 'climate')]]"><span class$="[[icon('thermometer-half')]]"></span></a>
- <a href="#energy" class$="[[getNavItemClass(activeNav, 'energy')]]"><span class$="[[icon('burn')]]"></span></a>
- <a href="#security" class$="[[getNavItemClass(activeNav, 'security')]]"><span class$="[[icon('shield-alt')]]"></span></a>
- </div>
- </template>
-
- </template>
-
- <script>
- class SmartHomeFooter extends SmartHomeComponent {
- static get is() {
- return "smart-home-footer";
- }
-
- static get properties() {
- return {
- hideNav: {
- type: Boolean,
- value: false
- },
- activeNav: {
- type: String
- },
- }
- }
-
- ready() {
- super.ready();
- this.shadowRoot.host.classList.add("flex-none", "layout", "vertical");
- }
-
- getNavItemClass(active, item) {
- return active === item
- ? "flex layout horizontal center-center navItem active"
- : "flex layout horizontal center-center navItem";
- }
- }
-
- defineAppElement(SmartHomeFooter, SmartHomeFooter.is, "SmartHomeFooter");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-header.html b/ui/app/smart-building-v1/smart-home/smart-home-header.html
deleted file mode 100644
index 3306696c6..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-header.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-
-<dom-module id="smart-home-header">
- <template>
- <style include="smart-home-style">
-
- .header {
- background-color: var(--theme-darkgrey);
- padding: 7px 15px;
- min-height: 34px;
- }
-
- .headerItem ::slotted(*) {
- color: var(--theme-white);
- text-decoration: none;
- font-size: 20px;
- cursor: pointer;
- }
-
- .nav {
- background-color: var(--theme-white);
- }
-
- .navItem {
- color: var(--theme-mediumgrey);
- text-align: center;
- padding: 10px;
- cursor: pointer;
- text-decoration: none;
- border-top: 3px solid transparent;
- border-bottom: 3px solid transparent;
- }
-
- .navItem.active {
- color: var(--theme-black);
- border-bottom: 3px solid var(--theme-lightgreen);
- font-weight: 600;
- }
-
- </style>
-
- <div class="flex-none layout horizontal center header">
- <div class="flex layout horizontal center">
-
- <div class="flex layout horizontal headerItem">
- <slot name="leftItem"></slot>
- </div>
-
- <div class="layout horizontal headerItem">
- <slot name="rightItem"></slot>
- </div>
-
- </div>
- </div>
-
- </template>
-
- <script>
- class SmartHomeHeader extends SmartHomeComponent {
- static get is() {
- return "smart-home-header";
- }
-
- static get properties() {
- return {
- activeNav: {
- type: String
- },
- }
- }
-
- ready() {
- super.ready();
- this.shadowRoot.host.classList.add("flex-none", "layout", "vertical");
- }
-
- getNavItemClass(active, item) {
- return active === item
- ? "flex layout horizontal center-center navItem active"
- : "flex layout horizontal center-center navItem";
- }
- }
-
- defineAppElement(SmartHomeHeader, SmartHomeHeader.is, "SmartHomeHeader");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-scenes.html b/ui/app/smart-building-v1/smart-home/smart-home-scenes.html
deleted file mode 100644
index a73a859f6..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-scenes.html
+++ /dev/null
@@ -1,247 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-<link rel="import" href="smart-home-section.html">
-
-<dom-module id="smart-home-scenes">
- <template>
- <style include="smart-home-style">
-
- .scene-container {
- max-width: 400px;
- margin: 0 auto;
- }
-
- .scene-container > div {
- position: relative;
- padding-bottom: 50%;
- width: 50%;
- }
-
- .sceneItem {
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- margin: 10px;
- border-radius: 0.2em;
- cursor: pointer;
- padding: 5%;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- box-sizing: border-box;
- -moz-box-sizing: border-box;
- -webkit-box-sizing: border-box;
- background-color: var(--theme-darkgrey);
- color: var(--theme-white);
- }
-
- .scene-item-content-container {
- position: relative;
- width: 100%;
- height: 100%;
- }
-
- .scene-temp-container {
- position: absolute;
- right: 0;
- top: 0;
- }
-
- .scene-name-and-time-container {
- position: absolute;
- left: 0;
- bottom: 0;
- }
-
- .scene-content-container > div {
- margin: 5px;
- }
-
- .scene-name {
- font-weight: 600;
- }
-
- .scene-time, .scene-temp {
- font-size: small;
- }
-
- .scene-temp {
- font-weight: 600;
- }
-
- .scene-alarm {
- visibility: hidden;
- font-size: larger;
- }
-
- .scene-alarm.enabled {
- visibility: inherit;
- }
-
- .scene-temp, .scene-alarm {
- text-align: center;
- }
-
- .or-Icon {
- margin: 0;
- }
-
- .sceneItem.selected {
- background-color: var(--theme-lightgreen);
- color: var(--theme-darkgrey);
- }
-
- .sceneItem.active {
- background-color: var(--theme-lightgreen);
- color: var(--theme-black);
- }
-
- </style>
-
- <div class="layout horizontal center-center" style="margin: 20px;">
- <!-- Means enabling/disabling automatic scene switching based on schedule -->
- <div class="flex layout horizontal smartLabel">[[localize('Automatically switch scenes')]]</div>
- <div class="layout horizontal">
- <or-checkbox checked="[[residence.attributes.sceneTimerEnabled.value]]"
- on-change="onSmartToggleChange"></or-checkbox>
- </div>
- </div>
-
- <div class="layout horizontal center-center scene-container">
- <div>
- <div id="MORNING"
- class$="layout horizontal center-center sceneItem [[getItemClass(residence.attributes.lastExecutedScene.value, 'MORNING')]]"
- on-click="switchScene">
- <div class="scene-item-content-container">
- <div class="scene-temp-container scene-content-container">
- <div class="scene-temp">[[residence.attributes.morningSceneTargetTemperature.value]]&deg;</div>
- <div class$="scene-alarm [[getAlarmClass(residence.attributes.morningSceneAlarmEnabled.value)]]"><span class$="[[icon('shield-alt')]]"></span></div>
- </div>
- <div class="scene-name-and-time-container scene-content-container">
- <div class="scene-name">[[localize('Morning')]]</div>
- <div class="scene-time">[[getSceneTime(residence.attributes, 'morning')]]</div>
- </div>
- </div>
- </div>
- </div>
- <div>
- <div id="DAY"
- class$="layout horizontal center-center sceneItem [[getItemClass(residence.attributes.lastExecutedScene.value, 'DAY')]]"
- on-click="switchScene">
- <div class="scene-item-content-container">
- <div class="scene-temp-container scene-content-container">
- <div class="scene-temp">[[residence.attributes.daySceneTargetTemperature.value]]&deg;</div>
- <div class$="scene-alarm [[getAlarmClass(residence.attributes.daySceneAlarmEnabled.value)]]"><span class$="[[icon('shield-alt')]]"></span></div>
- </div>
- <div class="scene-name-and-time-container scene-content-container">
- <div class="scene-name">[[localize('Day')]]</div>
- <div class="scene-time">[[getSceneTime(residence.attributes, 'day')]]</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="layout horizontal center-center scene-container">
- <div>
- <div id="EVENING"
- class$="layout horizontal center-center sceneItem [[getItemClass(residence.attributes.lastExecutedScene.value, 'EVENING')]]"
- on-click="switchScene">
- <div class="scene-item-content-container">
- <div class="scene-temp-container scene-content-container">
- <div class="scene-temp">[[residence.attributes.eveningSceneTargetTemperature.value]]&deg;</div>
- <div class$="scene-alarm [[getAlarmClass(residence.attributes.eveningSceneAlarmEnabled.value)]]"><span class$="[[icon('shield-alt')]]"></span></div>
- </div>
- <div class="scene-name-and-time-container scene-content-container">
- <div class="scene-name">{{localize('Evening')}}</div>
- <div class="scene-time">[[getSceneTime(residence.attributes, 'evening')]]</div>
- </div>
- </div>
- </div>
- </div>
- <div>
- <div id="NIGHT"
- class$="layout horizontal center-center sceneItem [[getItemClass(residence.attributes.lastExecutedScene.value, 'NIGHT')]]"
- on-click="switchScene">
- <div class="scene-item-content-container">
- <div class="scene-temp-container scene-content-container">
- <div class="scene-temp">[[residence.attributes.nightSceneTargetTemperature.value]]&deg;</div>
- <div class$="scene-alarm [[getAlarmClass(residence.attributes.nightSceneAlarmEnabled.value)]]"><span class$="[[icon('shield-alt')]]"></span></div>
- </div>
- <div class="scene-name-and-time-container scene-content-container">
- <div class="scene-name">{{localize('Night')}}</div>
- <div class="scene-time">[[getSceneTime(residence.attributes, 'night')]]</div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- </template>
-
- <script>
- class SmartHomeScenes extends SmartHomeComponent {
- static get is() {
- return "smart-home-scenes";
- }
-
- getItemClass(lastExecutedScene, item) {
- return lastExecutedScene === item ? "active" : "";
- }
-
- getAlarmClass(enabled) {
- return enabled ? "enabled" : "";
- }
-
- getSceneTime(attributes, scene) {
- if (!attributes) {
- return;
- }
-
- let now = moment();
- let today = now.format("dddd");
- let nextScene = "";
- let nextSceneDay = today;
-
- switch (scene) {
- case "morning":
- nextScene = "day";
- break;
- case "day":
- nextScene = "evening";
- break;
- case "evening":
- nextScene = "night";
- break;
- case "night":
- nextScene = "morning";
- nextSceneDay = now.add(1, "days").format("dddd");
- break;
- }
-
- let start = attributes[scene + "SceneTime" + today.toUpperCase()].value;
- let end = attributes[nextScene + "SceneTime" + nextSceneDay.toUpperCase()].value;
- return moment(start, "HH:mm:ss").format("HH:mm") + " - " + moment(end, "HH:mm:ss").format("HH:mm");
- }
-
- switchScene(e) {
- let sceneItem = e.currentTarget;
- sceneItem.classList.add("selected");
- this.sendAttributeEvent(
- this.residence.id, sceneItem.id.toLowerCase() + "Scene", "REQUEST_START"
- );
- }
-
- onSmartToggleChange(e) {
- this.sendAttributeEvent(
- this.residence.id, e.detail ? "enableSceneTimer" : "disableSceneTimer", "REQUEST_START"
- );
- }
- }
-
- defineAppElement(SmartHomeScenes, SmartHomeScenes.is, "SmartHomeScenes");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-section.html b/ui/app/smart-building-v1/smart-home/smart-home-section.html
deleted file mode 100644
index fc20cffd0..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-section.html
+++ /dev/null
@@ -1,93 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-
-<dom-module id="smart-home-section">
- <template>
- <style include="smart-home-style">
- :host {
- background-color: var(--theme-white);
- border-radius: 10px;
- margin: 10px;
- -webkit-box-shadow: 4px 4px 15px 0px rgba(0, 0, 0, 0.2);
- -moz-box-shadow: 4px 4px 15px 0px rgba(0, 0, 0, 0.2);
- box-shadow: 4px 4px 15px 0px rgba(0, 0, 0, 0.2);
- }
-
- .title {
- padding: 10px;
- font-weight: 600;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- cursor: pointer;
- color: var(--theme-darkgrey);
- -webkit-tap-highlight-color: transparent;
- -webkit-touch-callout: none;
- }
-
- .content {
- padding: 10px;
- }
-
- .content[collapsed] {
- display: none;
- }
-
- .expandCollapseIcon {
- text-align: right;
- color: var(--theme-darkgrey);
- }
- </style>
-
- <template is="dom-if" if="[[title]]">
- <div class="layout horizontal" hidden$="[[!title]]">
- <div class="flex layout horizontal center title"
- on-click="onTitleClicked">
- <span class="flex or-Icon">&nbsp;</span>
- <span class="">[[title]]</span>
- <span class$="flex [[icon('caret-down')]] expandCollapseIcon" hidden$="[[!collapsed]]"></span>
- <span class$="flex [[icon('caret-up')]] expandCollapseIcon" hidden$="[[collapsed]]"></span>
- </div>
- </div>
- </template>
-
- <div class="layout vertical content" collapsed$="[[collapsed]]">
- <slot></slot>
- </div>
-
- </template>
-
- <script>
- class SmartHomeSection extends SmartHomeComponent {
- static get is() {
- return "smart-home-section";
- }
-
- static get properties() {
- return {
- title: {
- type: String,
- reflectToAttribute:true
- },
- collapsed: {
- type: Boolean,
- value: false
- }
- }
- }
-
- ready() {
- super.ready();
- this.shadowRoot.host.classList.add("flex-none", "layout", "vertical");
- }
-
- onTitleClicked() {
- this.set("collapsed", !this.collapsed);
- }
- }
-
- defineAppElement(SmartHomeSection, SmartHomeSection.is, "SmartHomeSection");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-security.html b/ui/app/smart-building-v1/smart-home/smart-home-security.html
deleted file mode 100644
index 082476009..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-security.html
+++ /dev/null
@@ -1,121 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-<link rel="import" href="smart-home-section.html">
-<link rel="import" href="/static/src/or-checkbox/or-checkbox.html">
-
-<dom-module id="smart-home-security">
- <template>
- <style include="smart-home-style">
-
- .alarm {
- margin: 10px 0;
- }
-
- .residencePresenceStatus {
- padding: 10px 20px;
- }
-
- .roomLabel {
- padding: 0 10px;
- }
-
- .presenceStatus {
- color: var(--theme-mediumgrey);
- }
-
- .roomPresenceStatusItem {
- margin: 10px 0;
- }
-
- </style>
-
- <div id="page-container">
-
- <div class="section">
- <div class="layout horizontal center alarm">
- <template is="dom-if" if="[[residence.attributes.presenceDetected.value]]">
- <img height="60" src="smart-home/img/eye_large_active.png"/>
- </template>
- <template is="dom-if" if="[[!residence.attributes.presenceDetected.value]]">
- <img height="60" src="smart-home/img/eye_large.png"/>
- </template>
- <div class="flex layout vertical residencePresenceStatus">
- <div>[[localize('Alarm')]]</div>
- <div class="presenceStatus">
- [[computePresenceStatus(residence.attributes.presenceDetected.value)]]
- </div>
- </div>
- <div class="layout horizontal">
- <or-checkbox checked="[[residence.attributes.alarmEnabled.value]]"
- on-change="onAlarmEnabledChange"></or-checkbox>
- </div>
- </div>
- </div>
-
- <div class="section">
- <div class="layout vertical">
- <template is="dom-repeat" items="[[roomsPresenceStatus]]">
- <div class="layout horizontal center roomPresenceStatusItem">
- <div class="layout vertical center-center">
- <img height="30" src="smart-home/img/eye.png"/>
- </div>
- <div class="flex layout horizontal roomLabel">
- [[localize(item.roomName)]]
- </div>
- <div class="presenceStatus">
- [[computePresenceStatus(item.presenceDetected)]]
- </div>
- </div>
- </template>
- </div>
- </div>
- </div>
-
- </template>
-
- <script>
- class SmartHomeSecurity extends SmartHomeComponent {
- static get is() {
- return "smart-home-security";
- }
-
- static get properties() {
- return {
- roomsPresenceStatus: {
- type: Array,
- computed: "computeRoomsPresenceStatus(rooms.*)"
- }
- }
- }
-
- onAlarmEnabledChange(e) {
- this.sendAttributeEvent(
- this.residence.id, "alarmEnabled", e.detail
- );
- }
-
- computePresenceStatus(presenceDetected) {
- return presenceDetected === true ? this.localize("Activity") : this.localize("No activity");
- }
-
- computeRoomsPresenceStatus(rooms) {
- let roomsPresenceStatus = [];
- if (!this.rooms)
- return roomsPresenceStatus;
- this.rooms.forEach(room => {
- if ("presenceDetected" in room.attributes) {
- roomsPresenceStatus.push({
- roomId: room.id,
- roomName: room.name,
- presenceDetected: room.attributes.presenceDetected.value
- });
- }
- })
- return roomsPresenceStatus;
- }
- }
-
- defineAppElement(SmartHomeSecurity, SmartHomeSecurity.is, "SmartHomeSecurity");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-settings.html b/ui/app/smart-building-v1/smart-home/smart-home-settings.html
deleted file mode 100644
index 4bf0fa999..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-settings.html
+++ /dev/null
@@ -1,273 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-<link rel="import" href="smart-home-section.html">
-<link rel="import" href="smart-home-temperature-select.html">
-<link rel="import" href="/static/src/or-checkbox/or-checkbox.html">
-
-<dom-module id="smart-home-settings">
- <template>
- <style include="smart-home-style">
- smart-home-section {
- margin: 10px 0 20px 0;
- }
-
- .infoLabel {
- font-size: smaller;
- font-style: italic;
- color: var(--theme-white);
- margin: 20px;
- }
-
- .row .field {
- font-size: smaller;
- margin: 0.6em 0;
- }
-
- .row .first.field {
- max-width: 5.5em;
- min-width: 5.5em;
- }
-
- .first.row {
- background-color: var(--theme-lightergrey);
- color: var(--theme-black);
- }
-
- .first.row .first.field {
- font-weight: 600;
- margin: 0;
- padding: 0.6em 0;
- background-color: var(--theme-white);
- }
-
- .row .field .or-InputTime {
- max-width: 3em;
- text-align: center;
- padding: 0 0.2em;
- }
-
- </style>
-
- <div id="page-container">
- <div class="layout horizontal center heading">
- <span>[[localize('Weekly schedule')]]</span>
- </div>
-
- <smart-home-section class="section">
- <div class="layout horizontal">
- <div class="layout horizontal first row">
- <div class="first field">[[localize('Scene')]]</div>
- </div>
- <template is="dom-repeat" items="{{scenes}}" as="scene">
- <div class="flex layout horizontal center-center first row">
- <div class="field">[[localize(scene.label)]]</div>
- </div>
- </template>
- </div>
- <template is="dom-repeat" items="{{weekdays}}" as="weekday">
- <div class="layout horizontal">
- <div class="layout horizontal center row">
- <div class="first field">[[localize(weekday)]]</div>
- </div>
- <template is="dom-repeat" items="{{scenes}}" as="scene">
- <div class="flex layout horizontal center-center row">
- <div class="field">
- <input class="or-Input or-InputTime"
- title="[[localize('Scene start time')]]"
- type="time"
- step="60"
- required
- value="[[getSceneTime(residence.attributes, weekday, scene.name)]]"
- on-input="onSceneTimeChange"/>
- </div>
- </div>
- </template>
- </div>
- </template>
- </smart-home-section>
-
- <div class="layout horizontal center heading">
- <span>[[localize('Vacation')]]</span>
- </div>
- <div class="section">
- <div class="layout horizontal center" style="margin-bottom: 10px;">
- <div class="flex">[[localize('On vacation until')]]</div>
- <input class="or-Input or-InputDate"
- title="[[localize('End of vacation')]]"
- type="date"
- empty$="[[vacationUntilEmpty]]"
- value="[[vacationUntil]]"
- on-input="onVacationUntilChange"/>
- </div>
- </div>
-
- <div class="layout horizontal center heading">
- <span>[[localize('Scene configuration')]]</span>
- </div>
-
- <div class="section">
-
- <div class="layout horizontal" style="margin-top: 20px;">
- <div class="layout horizontal first row">
- <div class="first field">[[localize('Climate')]]</div>
- </div>
- <template is="dom-repeat" items="{{scenes}}" as="scene">
- <div class="flex layout horizontal center-center first row">
- <div class="field">[[localize(scene.label)]]</div>
- </div>
- </template>
- </div>
- <div class="layout horizontal">
- <div class="layout horizontal center row">
- <div class="first field">[[localize('Temperature')]]</div>
- </div>
- <template is="dom-repeat" items="{{scenes}}" as="scene">
- <div class="flex layout horizontal center-center row">
- <div class="field">
- <smart-home-temperature-select
- temperature="[[getSceneTemperature(residence.attributes, scene.name)]]"
- on-change="onSceneTemperatureChange"
- temperature-format="%0f° C"></smart-home-temperature-select>
- </div>
- </div>
- </template>
- </div>
- </div>
-
- <div class="section">
- <div class="layout horizontal">
- <div class="layout horizontal first row">
- <div class="first field">[[localize('Alarm')]]</div>
- </div>
- <template is="dom-repeat" items="{{scenes}}" as="scene">
- <div class="flex layout horizontal center-center first row">
- <div class="field">[[localize(scene.label)]]</div>
- </div>
- </template>
- </div>
- <div class="layout horizontal">
- <div class="layout horizontal center row">
- <div class="first field">[[localize('Enabled')]]</div>
- </div>
- <template is="dom-repeat" items="{{scenes}}" as="scene">
- <div class="flex layout horizontal center-center row">
- <div class="field">
- <or-checkbox checked="[[getAlarmEnabled(residence.attributes, scene.name)]]"
- on-change="onAlarmEnabledChange"></or-checkbox>
- </div>
- </div>
- </template>
- </div>
-
- </div>
- </div>
-
- </template>
-
- <script>
- class SmartHomeSettings extends SmartHomeComponent {
- static get is() {
- return "smart-home-settings";
- }
-
- static get properties() {
- return {
- vacationUntilEmpty: {
- type: Boolean,
- computed: "computeVacationUntilEmpty(residence.attributes)"
- },
- vacationUntil: {
- type: String,
- computed: "computeVacationUntil(residence.attributes)"
- },
- scenes: {
- type: Array,
- value: [
- {name: "morning", label: "Morning"},
- {name: "day", label: "Day"},
- {name: "evening", label: "Evening"},
- {name: "night", label: "Night"},
- ]
- },
- weekdays: {
- type: Array,
- value: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
- },
- }
- }
-
- static get observers() {
- return [
- "onResidenceChange(residence.*)"
- ]
- }
-
- onResidenceChange() {
- // When anything on residence changes, notify everyone that attributes (might have) changed
- this.notifyPath("residence.attributes")
- }
-
-
- computeVacationUntilEmpty(attributes) {
- return !attributes || !attributes.vacationUntil || !attributes.vacationUntil.value;
- }
-
- computeVacationUntil(attributes) {
- return attributes && attributes.vacationUntil && attributes.vacationUntil.value
- ? moment(attributes.vacationUntil.value).format("YYYY-MM-DD")
- : moment().add(7, "days").format("YYYY-MM-DD"); // Show 1 week in future if no vacation until set
- }
-
- onVacationUntilChange(e) {
- let vacationUntilMoment = moment(e.target.value, "YYYY-MM-DD");
- this.sendAttributeEvent(
- this.residence.id,
- "vacationUntil",
- // Vacation until must be in future or clear
- vacationUntilMoment.isAfter(moment()) ? vacationUntilMoment.valueOf() : undefined
- );
- }
-
- getSceneTime(attributes, weekday, scene) {
- let weekdayUpperCase = weekday.toUpperCase();
- return attributes && attributes[scene + "SceneTime" + weekdayUpperCase]
- ? moment(attributes[scene + "SceneTime" + weekdayUpperCase].value, "HH:mm:ss").format("HH:mm")
- : undefined;
- }
-
- onSceneTimeChange(e) {
- let weekdayUpperCase = e.model.weekday.toUpperCase();
- let scene = e.model.scene.name;
- let value = moment(e.target.value, "HH:mm").format("HH:mm:ss");
- this.sendAttributeEvent(this.residence.id, scene + "SceneTime" + weekdayUpperCase, value);
- }
-
- getAlarmEnabled(attributes, scene) {
- return attributes && attributes[scene + "SceneAlarmEnabled"]
- ? attributes[scene + "SceneAlarmEnabled"].value
- : undefined;
- }
-
- onAlarmEnabledChange(e) {
- let scene = e.model.scene.name;
- let enabled = e.detail;
- this.sendAttributeEvent(this.residence.id, scene + "SceneAlarmEnabled", enabled);
- }
-
- getSceneTemperature(attributes, scene) {
- return attributes && attributes[scene + "SceneTargetTemperature"]
- ? parseInt(attributes[scene + "SceneTargetTemperature"].value) // TODO Cut off decimal
- : undefined;
- }
-
- onSceneTemperatureChange(e) {
- let scene = e.model.scene.name;
- let temperature = e.detail;
- this.sendAttributeEvent(this.residence.id, scene + "SceneTargetTemperature", temperature);
- }
- }
-
- defineAppElement(SmartHomeSettings, SmartHomeSettings.is, "SmartHomeSettings");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-smart.html b/ui/app/smart-building-v1/smart-home/smart-home-smart.html
deleted file mode 100644
index 269601eda..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-smart.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-<link rel="import" href="smart-home-section.html">
-<link rel="import" href="/static/src/or-checkbox/or-checkbox.html">
-
-<dom-module id="smart-home-smart">
- <template>
- <style include="smart-home-style">
- .smartLabel {
- margin: 0 10px;
- }
- </style>
-
- <smart-home-section>
- <div class="layout horizontal center">
- <img height="30" src="smart-home/img/star.png"/>
- <!-- "All Smart" currently means enabling/disabling automatic scene switching based on schedule -->
- <div class="flex layout horizontal smartLabel">[[localize('All Smart')]]</div>
- <div class="layout horizontal">
- <or-checkbox checked="[[residence.attributes.sceneTimerEnabled.value]]"
- on-change="onSmartToggleChange"></or-checkbox>
- </div>
- </div>
- </smart-home-section>
-
- </template>
-
- <script>
- class SmartHomeSmart extends SmartHomeComponent {
- static get is() {
- return "smart-home-smart";
- }
-
- ready() {
- super.ready();
- this.shadowRoot.host.classList.add("flex-none");
- }
-
- onSmartToggleChange(e) {
- this.sendAttributeEvent(
- this.residence.id, e.detail ? "enableSceneTimer" : "disableSceneTimer", "REQUEST_START"
- );
- }
- }
-
- defineAppElement(SmartHomeSmart, SmartHomeSmart.is, "SmartHomeSmart");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-style.html b/ui/app/smart-building-v1/smart-home/smart-home-style.html
deleted file mode 100644
index 1499e46e8..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-style.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<dom-module id="smart-home-style">
- <template>
- <style include="or-style">
-
- #page-container {
- padding: 10px 15px 0 15px;
- }
-
- .section {
- padding-bottom: 10px;
- }
-
- .heading {
- color: var(--theme-darkgrey);
- font-weight: 600;
- margin: 20px -2px 10px -2px;
- }
-
- .heading > span {
- padding: 0 2px 4px 2px;
- border-bottom: 3px solid;
- border-color: var(--theme-lightgreen);
- }
- </style>
- </template>
-</dom-module>
\ No newline at end of file
diff --git a/ui/app/smart-building-v1/smart-home/smart-home-temperature-select.html b/ui/app/smart-building-v1/smart-home/smart-home-temperature-select.html
deleted file mode 100644
index 65334173e..000000000
--- a/ui/app/smart-building-v1/smart-home/smart-home-temperature-select.html
+++ /dev/null
@@ -1,68 +0,0 @@
-<link rel="import" href="smart-home-component.html">
-<link rel="import" href="smart-home-style.html">
-
-<dom-module id="smart-home-temperature-select">
- <template>
- <style include="smart-home-style">
- </style>
-
- <div class="or-Select">
- <select value="[[temperature]]"
- on-change="onTemperatureChange"
- title="[[localize('Temperature')]]">
- <template is="dom-repeat" items="[[availableTemperatures]]" as="t">
- <option value="[[t]]" selected$="[[isSelected(temperature, t)]]">
- [[formatAttributeValue(temperatureFormat, t)]]
- </option>
- </template>
- </select>
- </div>
- </template>
-
- <script>
- class SmartHomeTemperatureSelect extends SmartHomeComponent {
- static get is() {
- return "smart-home-temperature-select";
- }
-
- static get properties() {
- return {
- temperatureFormat: {
- type: String
- },
- temperature: {
- type: Number,
- },
- availableTemperatures: {
- type: Array,
- value: () => {
- let temperatures = [];
- // Support temperatures from 11 to 31 degrees
- for(let t = 11; t <= 31; t++) {
- temperatures.push(t);
- }
- return temperatures
- }
- }
- }
- }
-
- ready() {
- super.ready();
- this.shadowRoot.host.classList.add("flex-none");
- }
-
- isSelected(temperature, t) {
- return temperature === t;
- }
-
- onTemperatureChange(e) {
- this.set("temperature", parseInt(e.target.value));
- this.dispatchEvent(new CustomEvent("change", {detail: this.temperature}));
- }
- }
-
- defineAppElement(SmartHomeTemperatureSelect, SmartHomeTemperatureSelect.is, "SmartHomeTemperatureSelect");
- </script>
-
-</dom-module>
diff --git a/ui/app/smart-building/.gitignore b/ui/app/smart-building/.gitignore
deleted file mode 100644
index 6ebead74e..000000000
--- a/ui/app/smart-building/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-node_modules
-src/**/*.d.ts
-src/**/*.js
-src/**/*.js.map
diff --git a/ui/app/smart-building/@types/@polymer/app-localize-behavior/app-localize-behavior.js.d.ts b/ui/app/smart-building/@types/@polymer/app-localize-behavior/app-localize-behavior.js.d.ts
deleted file mode 100644
index 543488bca..000000000
--- a/ui/app/smart-building/@types/@polymer/app-localize-behavior/app-localize-behavior.js.d.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-declare module "@polymer/app-localize-behavior/app-localize-behavior.js" {
- class AppLocalizeBehavior {
-
- /**
- * The language used for translation.
- */
- language: string | null | undefined;
-
- /**
- * The dictionary of localized messages, for each of the languages that
- * are going to be used. See http://formatjs.io/guides/message-syntax/ for
- * more information on the message syntax.
- *
- * For example, a valid dictionary would be:
- * this.resources = {
- * 'en': { 'greeting': 'Hello!' }, 'fr' : { 'greeting': 'Bonjour!' }
- * }
- */
- resources: object | null | undefined;
-
- /**
- * Optional dictionary of user defined formats, as explained here:
- * http://formatjs.io/guides/message-syntax/#custom-formats
- *
- * For example, a valid dictionary of formats would be:
- * this.formats = {
- * number: { USD: { style: 'currency', currency: 'USD' } }
- * }
- */
- formats: object | null | undefined;
-
- /**
- * If true, will use the provided key when
- * the translation does not exist for that key.
- */
- useKeyIfMissing: boolean | null | undefined;
-
- /**
- * Translates a string to the current `language`. Any parameters to the
- * string should be passed in order, as follows:
- * `localize(stringKey, param1Name, param1Value, param2Name, param2Value)`
- */
- readonly localize: Function | null | undefined;
-
- /**
- * If true, will bubble up the event to the parents
- */
- bubbleEvent: boolean | null | undefined;
-
- loadResources(path: any, language: any, merge: any): any;
- }
-}
diff --git a/ui/app/smart-building/build.gradle b/ui/app/smart-building/build.gradle
deleted file mode 100644
index 5f6e722ee..000000000
--- a/ui/app/smart-building/build.gradle
+++ /dev/null
@@ -1,14 +0,0 @@
-//buildDir = "dist"
-//npmBuild.dependsOn(resolveTask(":ui:component:core:build"))
-//
-//task build {
-// dependsOn npmBuild
-//}
-//
-//task installDist(type: Copy) {
-// dependsOn build
-// from(buildDir) {
-// exclude "gwt", "build.gradle", "package.json", "yarn.lock", ".bowerrc"
-// }
-// into "${resolveProject(':deployment').buildDir}/manager/app/${projectDir.name}"
-//}
diff --git a/ui/app/smart-building/images/co2.png b/ui/app/smart-building/images/co2.png
deleted file mode 100644
index 20f89dd60..000000000
Binary files a/ui/app/smart-building/images/co2.png and /dev/null differ
diff --git a/ui/app/smart-building/images/eye.png b/ui/app/smart-building/images/eye.png
deleted file mode 100644
index 228c524f4..000000000
Binary files a/ui/app/smart-building/images/eye.png and /dev/null differ
diff --git a/ui/app/smart-building/images/eye_large.png b/ui/app/smart-building/images/eye_large.png
deleted file mode 100644
index 9269aacd6..000000000
Binary files a/ui/app/smart-building/images/eye_large.png and /dev/null differ
diff --git a/ui/app/smart-building/images/eye_large_active.png b/ui/app/smart-building/images/eye_large_active.png
deleted file mode 100644
index e7596d0d5..000000000
Binary files a/ui/app/smart-building/images/eye_large_active.png and /dev/null differ
diff --git a/ui/app/smart-building/images/home_large_energy.png b/ui/app/smart-building/images/home_large_energy.png
deleted file mode 100644
index 1d522e134..000000000
Binary files a/ui/app/smart-building/images/home_large_energy.png and /dev/null differ
diff --git a/ui/app/smart-building/images/home_on.png b/ui/app/smart-building/images/home_on.png
deleted file mode 100644
index 955131fcd..000000000
Binary files a/ui/app/smart-building/images/home_on.png and /dev/null differ
diff --git a/ui/app/smart-building/images/humidity.png b/ui/app/smart-building/images/humidity.png
deleted file mode 100644
index f0304e259..000000000
Binary files a/ui/app/smart-building/images/humidity.png and /dev/null differ
diff --git a/ui/app/smart-building/images/star.png b/ui/app/smart-building/images/star.png
deleted file mode 100644
index 374592cd5..000000000
Binary files a/ui/app/smart-building/images/star.png and /dev/null differ
diff --git a/ui/app/smart-building/images/temperature.png b/ui/app/smart-building/images/temperature.png
deleted file mode 100644
index 7abb2b09a..000000000
Binary files a/ui/app/smart-building/images/temperature.png and /dev/null differ
diff --git a/ui/app/smart-building/images/ventilation.png b/ui/app/smart-building/images/ventilation.png
deleted file mode 100644
index 68f4b4539..000000000
Binary files a/ui/app/smart-building/images/ventilation.png and /dev/null differ
diff --git a/ui/app/smart-building/locales/nl.json b/ui/app/smart-building/locales/nl.json
deleted file mode 100644
index e61ce142d..000000000
--- a/ui/app/smart-building/locales/nl.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "weeklySchedule": "Weekschema",
- "Energy": "Start",
- "Security": "Veilig",
- "Climate": "Klimaat",
- "receivedMessages": "Ontvangen berichten",
- "sendMessage": "Melding maken",
- "All Smart": "Alles Slim",
- "At Home": "Thuis",
- "Away": "Weg",
- "Evening": "Avond",
- "Night": "Nacht",
- "Switch A": "Afwas",
- "Switch B": "Was",
- "Switch C": "Droger",
- "Now on": "Nu aan",
- "On at": "Aan om",
- "Ready at": "Klaar om",
- "tomorrow": "morgen",
- "Mode": "Mode",
- "Begin/end of cycle": "Begin/end of cycle",
- "Green": "Groen",
- "Usage today": "Huidig verbruik",
- "Zone & Battery": "Zon & Batterij",
- "Grid": "Netwerk",
- "Alarm": "Alarm",
- "Presence detected": "Activiteit",
- "No presence": "Geen Activiteit",
- "Kitchen": "Keuken",
- "Living Room": "Woonkamer",
- "Hallway": "Gang",
- "Bedroom": "Slaapkamer",
- "Bedroom 2": "Slaapkamer 2",
- "Bathroom": "Badkamer",
- "Ventilation": "Ventilatie",
- "Ventilation Mode": "Ventilation Mode",
- "Auto": "Auto",
- "Low": "Laag",
- "Medium": "Medium",
- "High": "Hoog",
- "Vacation": "Vakantie",
- "On vacation until": "Op vakantie tot"
-}
diff --git a/ui/app/smart-building/src/actions/app.ts b/ui/app/smart-building/src/actions/app.ts
deleted file mode 100644
index 7d4e6258d..000000000
--- a/ui/app/smart-building/src/actions/app.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import { Action, ActionCreator } from "redux";
-import { ThunkAction } from "redux-thunk";
-import { RootState } from "../store";
-export const UPDATE_PAGE = "UPDATE_PAGE";
-export const UPDATE_OFFLINE = "UPDATE_OFFLINE";
-export const UPDATE_DRAWER_STATE = "UPDATE_DRAWER_STATE";
-export const OPEN_SNACKBAR = "OPEN_SNACKBAR";
-export const CLOSE_SNACKBAR = "CLOSE_SNACKBAR";
-
-export interface AppActionUpdatePage extends Action<"UPDATE_PAGE"> {page: string};
-export interface AppActionUpdateOffline extends Action<"UPDATE_OFFLINE"> {offline: boolean};
-export interface AppActionUpdateDrawerState extends Action<"UPDATE_DRAWER_STATE"> {opened: boolean};
-export interface AppActionOpenSnackbar extends Action<"OPEN_SNACKBAR"> {};
-export interface AppActionCloseSnackbar extends Action<"CLOSE_SNACKBAR"> {};
-export type AppAction = AppActionUpdatePage | AppActionUpdateOffline | AppActionUpdateDrawerState | AppActionOpenSnackbar | AppActionCloseSnackbar;
-
-type ThunkResult = ThunkAction<void, RootState, undefined, AppAction>;
-
-export const navigate: ActionCreator<ThunkResult> = (path: string) => (dispatch) => {
- // Extract the page name from path.
- const page = path === "/" ? "view1" : path.slice(1);
-
- // Any other info you might want to extract from the path (like page type),
- // you can do here
- dispatch(loadPage(page));
-
- // Close the drawer - in case the *path* change came from a link in the drawer.
- dispatch(updateDrawerState(false));
-};
-
-const loadPage: ActionCreator<ThunkResult> = (page: string) => (dispatch) => {
- switch(page) {
- default:
- page = "scenes";
- import("../components/page-scenes");
- }
-
- dispatch(updatePage(page));
-};
-
-const updatePage: ActionCreator<AppActionUpdatePage> = (page: string) => {
- return {
- type: UPDATE_PAGE,
- page
- };
-};
-
-let snackbarTimer: number;
-
-export const showSnackbar: ActionCreator<ThunkResult> = () => (dispatch) => {
- dispatch({
- type: OPEN_SNACKBAR
- });
- window.clearTimeout(snackbarTimer);
- snackbarTimer = window.setTimeout(() =>
- dispatch({ type: CLOSE_SNACKBAR }), 3000);
-};
-
-export const updateOffline: ActionCreator<ThunkResult> = (offline: boolean) => (dispatch, getState) => {
- // Show the snackbar only if offline status changes.
- if (offline !== getState().app!.offline) {
- dispatch(showSnackbar());
- }
- dispatch({
- type: UPDATE_OFFLINE,
- offline
- });
-};
-
-export const updateDrawerState: ActionCreator<AppActionUpdateDrawerState> = (opened: boolean) => {
- return {
- type: UPDATE_DRAWER_STATE,
- opened
- };
-};
diff --git a/ui/app/smart-building/src/components/page-element.ts b/ui/app/smart-building/src/components/page-element.ts
deleted file mode 100644
index 0c7c028fb..000000000
--- a/ui/app/smart-building/src/components/page-element.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import {LitElement, property} from "lit-element";
-
-export abstract class PageElement extends LitElement {
- @property({type: Boolean})
- active = false;
-
- // Only render this page if it's actually visible.
- protected shouldUpdate() {
- return this.active;
- }
-}
diff --git a/ui/app/smart-building/src/components/page-scenes.ts b/ui/app/smart-building/src/components/page-scenes.ts
deleted file mode 100644
index cbffa0cc7..000000000
--- a/ui/app/smart-building/src/components/page-scenes.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import {css, html, LitElement, property, PropertyValues} from "lit-element";
-import {connect} from "pwa-helpers/connect-mixin";
-import {store} from "../store";
-import {PageElement} from "./page-element";
-import { localize } from "../localize-mixin";
-import { i18next } from "../i18next";
-
-class PageScenes extends connect(store)(localize(i18next)(PageElement)) {
-
-}
-
-window.customElements.define("page-scenes", PageScenes);
diff --git a/ui/app/smart-building/src/components/smart-building-app.ts b/ui/app/smart-building/src/components/smart-building-app.ts
deleted file mode 100644
index 60294d1d9..000000000
--- a/ui/app/smart-building/src/components/smart-building-app.ts
+++ /dev/null
@@ -1,269 +0,0 @@
-import {css, html, LitElement, property, PropertyValues} from "lit-element";
-import {connect} from "pwa-helpers/connect-mixin";
-import {setPassiveTouchGestures} from "@polymer/polymer/lib/utils/settings";
-import {installMediaQueryWatcher} from "pwa-helpers/media-query";
-import {installRouter} from "pwa-helpers/router";
-import {updateMetadata} from "pwa-helpers/metadata";
-import {icon} from "@fortawesome/fontawesome-svg-core";
-import {faMap, faSignOutAlt, faTable} from "@fortawesome/free-solid-svg-icons";
-import "@openremote/or-header";
-import "@openremote/or-bottom-navigation";
-
-import { localize } from "../localize-mixin";
-import { i18next } from "../i18next";
-
-// This element is connected to the Redux store.
-import {store} from "../store";
-
-// These are the actions needed by this element.
-import {navigate, updateDrawerState, updateOffline} from "../actions/app";
-
-
-// Declare MANAGER_URL
-declare var MANAGER_URL: string;
-
-class SmartBuildingApp extends connect(store)(localize(i18next)(LitElement)) {
-
- @property({type: String})
- appTitle = '';
-
- @property({type: String})
- _page = "scenes";
-
- constructor() {
- super();
- // To force all event listeners for gestures to be passive.
- // See https://www.polymer-project.org/3.0/docs/devguide/settings#setting-passive-touch-gestures
- setPassiveTouchGestures(true);
- }
-
- protected invalidate() {
- this.requestUpdate();
- }
-
- protected render() {
- return html`
- <or-header>
- <div slot="desktop-left">
- <a ?selected="${this._page === 'scenes'}" href="#scenes">${i18next.t('scenes')}</a>
- <a ?selected="${this._page === 'messages'}" href="#scenes">${i18next.t('receivedMessages')}</a>
- <a ?selected="${this._page === 'contact'}" href="#scenes">${i18next.t('sendMessage')}</a>
- <a ?selected="${this._page === 'languages'}" href="#scenes">${i18next.t('selectLanguage')}</a>
- </div>
- <div slot="desktop-right">
- <a @click="${this.logout}">${icon(faSignOutAlt).node.item(0)} ${i18next.t('logOut')}</a>
- </div>
- <div slot="mobile-top">
- <a ?selected="${this._page === 'scenes'}" href="#scenes">${i18next.t('scenes')}</a>
- <a ?selected="${this._page === 'messages'}" href="#scenes">${i18next.t('receivedMessages')}</a>
- <a ?selected="${this._page === 'contact'}" href="#scenes">${i18next.t('sendMessage')}</a>
- <a ?selected="${this._page === 'languages'}" href="#scenes">${i18next.t('selectLanguage')}</a>
- <a @click="${this.logout}">${icon(faSignOutAlt).node.item(0)} ${i18next.t('logOut')}</a>
- </div>
- </or-header>
-
- <!-- Main content -->
- <main role="main" class="main-content">
- <page-scenes class="page" ?active="${this._page === "scenes"}"></page-scenes>
- <page-messages class="page" ?active="${this._page === "messages"}"></page-messages>
- <page-contact class="page" ?active="${this._page === "contact"}"></page-contact>
- <page-languages class="page" ?active="${this._page === "languages"}"></page-languages>
- </main>
-
- <or-bottom-navigation>
- <or-navigation-item icon="tv" text="TV"></or-navigation-item>
- <span class="mdc-bottom-navigation__list-item">
- <span class="material-icons mdc-bottom-navigation__list-item__icon">tv</span>
- <span class="mdc-bottom-navigation__list-item__text">TV</span>
- </span>
- <span class="mdc-bottom-navigation__list-item">
- <span class="material-icons mdc-bottom-navigation__list-item__icon">music_note</span>
- <span class="mdc-bottom-navigation__list-item__text">Music</span>
- </span>
- <span class="mdc-bottom-navigation__list-item">
- <span class="material-icons mdc-bottom-navigation__list-item__icon">book</span>
- <span class="mdc-bottom-navigation__list-item__text">Books</span>
- </span>
- <span class="mdc-bottom-navigation__list-item">
- <span class="material-icons mdc-bottom-navigation__list-item__icon">
- <svg style="width:24px;height:24px" viewBox="0 0 24 24">
- <path fill="#000000" d="M20,11H4V8H20M20,15H13V13H20M20,19H13V17H20M11,19H4V13H11M20.33,4.67L18.67,3L17,4.67L15.33,3L13.67,4.67L12,3L10.33,4.67L8.67,3L7,4.67L5.33,3L3.67,4.67L2,3V19A2,2 0 0,0 4,21H20A2,2 0 0,0 22,19V3L20.33,4.67Z" />
- </svg>
- </span>
- <span class="mdc-bottom-navigation__list-item__text">Newstand</span>
- </span>
- </or-bottom-navigation>
- `;
- }
-
- protected firstUpdated() {
- installRouter((location) => store.dispatch(navigate(decodeURIComponent(location.pathname))));
- installMediaQueryWatcher(`(min-width: 460px)`,
- () => store.dispatch(updateDrawerState(false)));
- }
-
- protected updated(changedProps: PropertyValues) {
- if (changedProps.has("_page")) {
- const pageTitle = this.appTitle + " - " + this._page;
- updateMetadata({
- title: pageTitle,
- description: pageTitle
- // This object also takes an image property, that points to an img src.
- });
- }
- }
-
- protected logout() {
-
- }
-
- static styles = css`
- :host {
- --app-header-background-color: #bcbcbc;
- }
- `;
- //static styles = OrHeaderStyle;
- // static styles = css`
- // :host {
- // display: block;
- //
- // --app-drawer-width: 256px;
- //
- // --app-primary-color: #E91E63;
- // --app-secondary-color: #293237;
- // --app-dark-text-color: var(--app-secondary-color);
- // --app-light-text-color: white;
- // --app-section-even-color: #f7f7f7;
- // --app-section-odd-color: white;
- //
- // --app-header-background-color: white;
- // --app-header-text-color: var(--app-dark-text-color);
- // --app-header-selected-color: var(--app-primary-color);
- //
- // --app-drawer-background-color: var(--app-secondary-color);
- // --app-drawer-text-color: var(--app-light-text-color);
- // --app-drawer-selected-color: #78909C;
- // }
- //
- // app-header {
- // position: fixed;
- // top: 0;
- // left: 0;
- // width: 100%;
- // text-align: center;
- // background-color: var(--app-header-background-color);
- // color: var(--app-header-text-color);
- // border-bottom: 1px solid #eee;
- // }
- //
- // .toolbar-top {
- // background-color: var(--app-header-background-color);
- // }
- //
- // [main-title] {
- // font-family: "Pacifico";
- // text-transform: lowercase;
- // font-size: 30px;
- // /* In the narrow layout, the toolbar is offset by the width of the
- // drawer button, and the text looks not centered. Add a padding to
- // match that button */
- // padding-right: 44px;
- // }
- //
- // .toolbar-list {
- // display: none;
- // }
- //
- // .toolbar-list > a {
- // display: inline-block;
- // color: var(--app-header-text-color);
- // text-decoration: none;
- // line-height: 30px;
- // padding: 4px 24px;
- // }
- //
- // .toolbar-list > a[selected] {
- // color: var(--app-header-selected-color);
- // border-bottom: 4px solid var(--app-header-selected-color);
- // }
- //
- // .menu-btn {
- // background: none;
- // border: none;
- // fill: var(--app-header-text-color);
- // cursor: pointer;
- // height: 44px;
- // width: 44px;
- // }
- //
- // .drawer-list {
- // box-sizing: border-box;
- // width: 100%;
- // height: 100%;
- // padding: 24px;
- // background: var(--app-drawer-background-color);
- // position: relative;
- // }
- //
- // .drawer-list > a {
- // display: block;
- // text-decoration: none;
- // color: var(--app-drawer-text-color);
- // line-height: 40px;
- // padding: 0 24px;
- // }
- //
- // .drawer-list > a[selected] {
- // color: var(--app-drawer-selected-color);
- // }
- //
- // /* Workaround for IE11 displaying <main> as inline */
- // main {
- // display: block;
- // }
- //
- // .main-content {
- // padding-top: 64px;
- // min-height: 100vh;
- // }
- //
- // .page {
- // display: none;
- // }
- //
- // .page[active] {
- // display: block;
- // }
- //
- // footer {
- // padding: 24px;
- // background: var(--app-drawer-background-color);
- // color: var(--app-drawer-text-color);
- // text-align: center;
- // }
- //
- // /* Wide layout: when the viewport width is bigger than 460px, layout
- // changes to a wide layout */
- // @media (min-width: 460px) {
- // .toolbar-list {
- // display: block;
- // }
- //
- // .menu-btn {
- // display: none;
- // }
- //
- // .main-content {
- // padding-top: 107px;
- // }
- //
- // /* The drawer button isn't shown in the wide layout, so we don't
- // need to offset the title */
- // [main-title] {
- // padding-right: 0px;
- // }
- // }
- // `;
-}
-
-window.customElements.define("smart-building-app", SmartBuildingApp);
diff --git a/ui/app/smart-building/src/reducers/app.ts b/ui/app/smart-building/src/reducers/app.ts
deleted file mode 100644
index 5fad50f4d..000000000
--- a/ui/app/smart-building/src/reducers/app.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { Reducer } from "redux";
-import {
- UPDATE_PAGE,
- UPDATE_OFFLINE,
- OPEN_SNACKBAR,
- CLOSE_SNACKBAR,
- UPDATE_DRAWER_STATE
-} from "../actions/app";
-import { RootAction } from "../store";
-
-export interface AppState {
- page: string;
- offline: boolean;
- drawerOpened: boolean;
- snackbarOpened: boolean;
-}
-
-const INITIAL_STATE: AppState = {
- page: "",
- offline: false,
- drawerOpened: false,
- snackbarOpened: false,
-};
-
-const app: Reducer<AppState, RootAction> = (state = INITIAL_STATE, action) => {
- switch (action.type) {
- case UPDATE_PAGE:
- return {
- ...state,
- page: action.page
- };
- case UPDATE_OFFLINE:
- return {
- ...state,
- offline: action.offline
- };
- case UPDATE_DRAWER_STATE:
- return {
- ...state,
- drawerOpened: action.opened
- };
- case OPEN_SNACKBAR:
- return {
- ...state,
- snackbarOpened: true
- };
- case CLOSE_SNACKBAR:
- return {
- ...state,
- snackbarOpened: false
- };
- default:
- return state;
- }
-};
-
-export default app;
diff --git a/ui/app/smart-building/tsconfig.json b/ui/app/smart-building/tsconfig.json
deleted file mode 100644
index 283d08f57..000000000
--- a/ui/app/smart-building/tsconfig.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "extends": "../../tsconfig",
- "compilerOptions": {
- "strict": false
- },
- "include": [
- "./src",
- "./@types"
- ],
- "references": [
- { "path": "../../component/core" },
- { "path": "../../component/or-bottom-navigation" },
- { "path": "../../component/rest" },
- { "path": "../../component/or-header" }
- ]
-}
diff --git a/ui/component/core/README.md b/ui/component/core/README.md
index a2563be82..dab5df4f4 100644
--- a/ui/component/core/README.md
+++ b/ui/component/core/README.md
@@ -41,7 +41,7 @@ openremote.init({
keycloakUrl: "http://localhost:8080/auth",
auth: Auth.KEYCLOAK,
autoLogin: false,
- realm: "tenantA",
+ realm: "building",
configureTranslationsOptions: (options) => {
options.lng = "nl"; // Change initial language to dutch rather than english
}
diff --git a/ui/component/index.html b/ui/component/index.html
index e7c3a761f..d8dccfd2b 100644
--- a/ui/component/index.html
+++ b/ui/component/index.html
@@ -21,7 +21,7 @@
auth: "KEYCLOAK",
autoLogin: true,
loadIcons: true,
- realm: "cdp-strijp",
+ realm: "demo",
configureTranslationsOptions: (options) => {
options.lng = "nl"; // Change initial language to dutch
}
@@ -37,5 +37,5 @@
<or-icon icon="access-point"></or-icon>
<or-map style="width: 500px; height: 500px"></or-map>
-<or-asset-tree style="width: 500px; height: 800px;" realm="cdp-strijp"></or-asset-tree>
+<or-asset-tree style="width: 500px; height: 800px;" realm="demo"></or-asset-tree>
</html>
diff --git a/ui/component/or-bottom-navigation/package.json b/ui/component/or-bottom-navigation/package.json
index 593e2216c..e4d9f318d 100644
--- a/ui/component/or-bottom-navigation/package.json
+++ b/ui/component/or-bottom-navigation/package.json
@@ -10,6 +10,9 @@
},
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
+ "dependencies": {
+ "@polymer/polymer": "^3.3.1"
+ },
"devDependencies": {
"tslint": ">=5.11.0",
"typescript": ">=3.4.5",
diff --git a/ui/component/or-map/package.json b/ui/component/or-map/package.json
index f8ad65d09..99f790bb4 100644
--- a/ui/component/or-map/package.json
+++ b/ui/component/or-map/package.json
@@ -17,7 +17,8 @@
"@openremote/rest": "^1.1.0",
"mapbox-gl": "1.2.1",
"mapbox.js": "^3.2.0",
- "lit-element": "^2.1.0"
+ "lit-element": "^2.1.0",
+ "@polymer/polymer": "^3.3.1"
},
"devDependencies": {
"@types/mapbox-gl": "^0.54.2",
diff --git a/ui/demo/demo-core/src/index.ts b/ui/demo/demo-core/src/index.ts
index 2d5277dee..c7dbc9d83 100644
--- a/ui/demo/demo-core/src/index.ts
+++ b/ui/demo/demo-core/src/index.ts
@@ -98,7 +98,7 @@ manager.init({
keycloakUrl: "http://localhost:8080/auth",
auth: Auth.KEYCLOAK,
autoLogin: false,
- realm: "tenantA",
+ realm: "building",
configureTranslationsOptions: (options) => {
options.lng = "nl"; // Change initial language to dutch
}
diff --git a/ui/demo/demo-or-map/src/index.ts b/ui/demo/demo-or-map/src/index.ts
index 8be291e86..ebfc460a4 100644
--- a/ui/demo/demo-or-map/src/index.ts
+++ b/ui/demo/demo-or-map/src/index.ts
@@ -11,7 +11,7 @@ manager.init({
autoLogin: true,
keycloakUrl: "http://localhost:8080/auth",
managerUrl: "http://localhost:8080",
- realm: "tenantA"
+ realm: "building"
})
.then(getApartment1Asset)
.then((apartment1) => {
diff --git a/ui/demo/demo-or-thermostat/src/index.ts b/ui/demo/demo-or-thermostat/src/index.ts
index cc85f98b4..67ffc9c7e 100644
--- a/ui/demo/demo-or-thermostat/src/index.ts
+++ b/ui/demo/demo-or-thermostat/src/index.ts
@@ -68,5 +68,5 @@ manager.init({
autoLogin: true,
keycloakUrl: "https://localhost/auth",
managerUrl: "https://localhost",
- realm: "tenantA"
+ realm: "building"
});
diff --git a/ui/demo/demo-rest/src/index.ts b/ui/demo/demo-rest/src/index.ts
index 7149b5d9c..c06f47435 100644
--- a/ui/demo/demo-rest/src/index.ts
+++ b/ui/demo/demo-rest/src/index.ts
@@ -36,5 +36,5 @@ manager.init({
keycloakUrl: "http://localhost:8080/auth",
auth: Auth.KEYCLOAK,
autoLogin: true,
- realm: "tenantA"
+ realm: "building"
}).then(renderUi);
\ No newline at end of file