100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Fixed getting realm from url when using a hash in url. Added Geofence rules for demo environment.
Michael Rademaker2e4c29bde988
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.javaindex 1097312d5..7d69c619a 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@@ -25,6 +25,7 @@ import org.openremote.manager.setup.AbstractManagerSetup;import org.openremote.model.rules.AssetRuleset;import org.openremote.model.rules.Ruleset;import org.openremote.model.rules.TenantRuleset;+import org.openremote.model.value.Values;import java.io.InputStream;import java.nio.charset.StandardCharsets;@@ -42,6 +43,7 @@ public class RulesDemoSetup extends AbstractManagerSetup {public Long apartmentActionsRulesetId;public Long tenantBuildingRulesetId;+ public Long tenantSmartCityRulesetId;@Overridepublic void onStart() throws Exception {@@ -116,5 +118,14 @@ public class RulesDemoSetup extends AbstractManagerSetup {);rulesetStorageService.merge(ruleset);}++ // SmartCity geofences+ try (InputStream inputStream = RulesDemoSetup.class.getResourceAsStream("/demo/rules/DemoGeofences.json")) {+ String rules = IOUtils.toString(inputStream, StandardCharsets.UTF_8);+ Ruleset ruleset = new TenantRuleset(+ keycloakDemoSetup.tenantCity.getRealm(), "Demo Geofences", Ruleset.Lang.JSON, rules+ ).setAccessPublicRead(true).addMeta("showOnMap", Values.create(true)).addMeta("showOnList", Values.create(true));+ tenantSmartCityRulesetId = rulesetStorageService.merge(ruleset).getId();+ }}}diff --git a/manager/src/main/resources/demo/rules/DemoGeofences.json b/manager/src/main/resources/demo/rules/DemoGeofences.jsonnew file mode 100644index 000000000..5dd2a290a--- /dev/null+++ b/manager/src/main/resources/demo/rules/DemoGeofences.json@@ -0,0 +1,238 @@+{+ "rules": [+ {+ "name": "De Kuip",+ "when": {+ "items": [+ {+ "datetime": {+ "predicateType": "datetime",+ "value": "2020-07-01T00:00:00+02:00",+ "rangeValue": "2020-09-01T00:00:00+02:00",+ "operator": "BETWEEN"+ },+ "assets": {+ "types": [+ {+ "predicateType": "string",+ "match": "EXACT",+ "value": "urn:openremote:asset:console"+ }+ ],+ "attributes": {+ "items": [+ {+ "name": {+ "predicateType": "string",+ "match": "EXACT",+ "value": "location"+ },+ "value": {+ "predicateType": "radial",+ "radius": 100,+ "lat": 51.8938569,+ "lng": 4.5219983+ }+ }+ ]+ }+ }+ }+ ]+ },+ "then": [+ {+ "action": "notification",+ "target": {+ "useAssetsFromWhen": true+ },+ "notification": {+ "name": "De Kuip",+ "message": {+ "type": "push",+ "title": "De Kuip",+ "body": "De thuis van Feyenoord",+ "action": {+ "url": "https://www.feyenoord.nl"+ },+ "buttons": [+ {+ "title": "Open in app",+ "action": {+ "url": "https://www.feyenoord.nl"+ }+ },+ {+ "title": "Open in browser",+ "action": {+ "url": "https://www.feyenoord.nl",+ "openInBrowser": true+ }+ }+ ]+ }+ }+ }+ ],+ "reset": {+ "timer": "1m"+ }+ },+ {+ "name": "Euromast",+ "when": {+ "items": [+ {+ "datetime": {+ "predicateType": "datetime",+ "value": "2020-07-01T00:00:00+02:00",+ "rangeValue": "2020-09-01T00:00:00+02:00",+ "operator": "BETWEEN"+ },+ "assets": {+ "types": [+ {+ "predicateType": "string",+ "match": "EXACT",+ "value": "urn:openremote:asset:console"+ }+ ],+ "attributes": {+ "items": [+ {+ "name": {+ "predicateType": "string",+ "match": "EXACT",+ "value": "location"+ },+ "value": {+ "predicateType": "radial",+ "radius": 100,+ "lat": 51.9069373,+ "lng": 4.4633775+ }+ }+ ]+ }+ }+ }+ ]+ },+ "then": [+ {+ "action": "notification",+ "target": {+ "useAssetsFromWhen": true+ },+ "notification": {+ "name": "Euromast",+ "message": {+ "type": "push",+ "title": "Euromast",+ "body": "Euromast, sinds 1960",+ "action": {+ "url": "https://euromast.nl"+ },+ "buttons": [+ {+ "title": "Open in app",+ "action": {+ "url": "https://euromast.nl"+ }+ },+ {+ "title": "Open in browser",+ "action": {+ "url": "https://euromast.nl",+ "openInBrowser": true+ }+ }+ ]+ }+ }+ }+ ],+ "reset": {+ "timer": "1m"+ }+ },+ {+ "name": "Markthal",+ "when": {+ "items": [+ {+ "datetime": {+ "predicateType": "datetime",+ "value": "2020-07-01T00:00:00+02:00",+ "rangeValue": "2020-09-01T00:00:00+02:00",+ "operator": "BETWEEN"+ },+ "assets": {+ "types": [+ {+ "predicateType": "string",+ "match": "EXACT",+ "value": "urn:openremote:asset:console"+ }+ ],+ "attributes": {+ "items": [+ {+ "name": {+ "predicateType": "string",+ "match": "EXACT",+ "value": "location"+ },+ "value": {+ "predicateType": "radial",+ "radius": 100,+ "lat": 51.9202494,+ "lng": 4.4851372+ }+ }+ ]+ }+ }+ }+ ]+ },+ "then": [+ {+ "action": "notification",+ "target": {+ "useAssetsFromWhen": true+ },+ "notification": {+ "name": "Markthal",+ "message": {+ "type": "push",+ "title": "Markthal",+ "body": "Happy Food Shopping",+ "action": {+ "url": "https://www.markthal.nl"+ },+ "buttons": [+ {+ "title": "Open in app",+ "action": {+ "url": "https://www.markthal.nl"+ }+ },+ {+ "title": "Open in browser",+ "action": {+ "url": "https://www.markthal.nl",+ "openInBrowser": true+ }+ }+ ]+ }+ }+ }+ ],+ "reset": {+ "timer": "1m"+ }+ }+ ]+}\ No newline at end of filediff --git a/ui/app/or-app/src/index.ts b/ui/app/or-app/src/index.tsindex 55a073b9e..ba7f6a03d 100644--- a/ui/app/or-app/src/index.ts+++ b/ui/app/or-app/src/index.ts@@ -191,7 +191,15 @@ export function headerItemAccount<S extends AppStateKeyed, A extends AnyAction>(}export function getRealmQueryParameter(): string {- return Util.getQueryParameter(location.search, "realm");+ if(location.search && location.search !== "") {+ return Util.getQueryParameter(location.search, "realm");+ }+ if(location.hash) {+ let index = location.hash.indexOf("?");+ if(index > -1) {+ return Util.getQueryParameter(location.hash.substring(index + 1), "realm");+ }+ }}const DEFAULT_MANAGER_CONFIG: ManagerConfig = {diff --git a/ui/component/core/src/console.ts b/ui/component/core/src/console.tsindex cd1b5a16f..b7258a919 100644--- a/ui/component/core/src/console.ts+++ b/ui/component/core/src/console.ts@@ -175,7 +175,7 @@ export class Console {this._initialiseInProgress = false;if (this._pendingProviderEnables.length === 0) {- this.sendRegistration();+ await this.sendRegistration();this._callCompletedCallback();} else if (this._autoEnable) {await this.enableProviders();