Skip to content

armgit / core

Public Imported from GitHub
0

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

Fixed issues with onboarding pages not showing permission on right moment

Michael Rademaker9b73f9fa7439
diff --git a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart
index 022e55f3a..1e2b34db3 100644
--- a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart
+++ b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart
@@ -66,7 +66,8 @@ class GeofenceProvider {
"hasPermission": await Permission.locationAlways.isGranted,
"success": true,
"enabled": false,
- "disabled": _sharedPreferences.containsKey(geoDisabledKey)
+ "disabled": _sharedPreferences.containsKey(geoDisabledKey) &&
+ _sharedPreferences.getBool(geoDisabledKey)
};
}
@@ -262,14 +263,15 @@ class GeofenceProvider {
_getLocationCallback = callback;
if (await Permission.locationAlways.isGranted) {
- Coordinate coordinate = await Geofence.getCurrentLocation();
- _getLocationCallback({
- "action": "GET_LOCATION",
- "provider": "geofence",
- "data": {
- "latitude": coordinate.latitude,
- "longitude": coordinate.longitude
- }
+ Geofence.getCurrentLocation().then((coordinate) {
+ _getLocationCallback({
+ "action": "GET_LOCATION",
+ "provider": "geofence",
+ "data": {
+ "latitude": coordinate.latitude,
+ "longitude": coordinate.longitude
+ }
+ });
});
} else {
if (await Permission.locationAlways.isUndetermined) {
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 f426747d4..6e9d68a24 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
@@ -841,19 +841,20 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
lightOP6Asset = assetStorageService.merge(lightOP6Asset);
persistenceService.doTransaction(entityManager ->
- entityManager.merge(new ConsoleAppConfig(
- realmCityTenant,
- "https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage",
- true,
- ConsoleAppConfig.MenuPosition.BOTTOM_LEFT,
- null,
- "#FAFAFA",
- "#AFAFAF",
- Values.createArray().addAll(
- Values.createObject()
- .put("displayText", "Map")
- .put("pageLink", "https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage")
- )))
+ entityManager.merge(new ConsoleAppConfig(
+ realmCityTenant,
+ "https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage",
+ "https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage&consoleAutoEnable=true#!geofences",
+ true,
+ ConsoleAppConfig.MenuPosition.BOTTOM_LEFT,
+ null,
+ "#FAFAFA",
+ "#AFAFAF",
+ Values.createArray().addAll(
+ Values.createObject()
+ .put("displayText", "Map")
+ .put("pageLink", "https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage&consoleAutoEnable=true#!geofences")
+ )))
);
}
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java
index 9622ae0e0..6e2ad921e 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerTestSetup.java
@@ -747,6 +747,7 @@ public class ManagerTestSetup extends AbstractManagerSetup {
entityManager.merge(new ConsoleAppConfig(
realmCityTenant,
"https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage",
+ "https://demo.openremote.io/main/?realm=smartcity&consoleProviders=geofence push storage",
true,
ConsoleAppConfig.MenuPosition.BOTTOM_LEFT,
null,
@@ -755,10 +756,7 @@ public class ManagerTestSetup extends AbstractManagerSetup {
Values.createArray().addAll(
Values.createObject()
.put("displayText","Map")
- .put("pageLink","https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage"),
- Values.createObject()
- .put("displayText","List")
- .put("pageLink","https://demo.openremote.io/mobile/#!geofences?realm=smartcity&consoleProviders=geofence push storage&view=list")
+ .put("pageLink","https://demo.openremote.io/main/#!geofences?realm=smartcity&consoleProviders=geofence push storage")
)
));
});
diff --git a/manager/src/main/resources/org/openremote/manager/setup/database/V20191202_01__Schema.sql b/manager/src/main/resources/org/openremote/manager/setup/database/V20191202_01__Schema.sql
index 3d57caef0..5c408dfc9 100644
--- a/manager/src/main/resources/org/openremote/manager/setup/database/V20191202_01__Schema.sql
+++ b/manager/src/main/resources/org/openremote/manager/setup/database/V20191202_01__Schema.sql
@@ -144,6 +144,7 @@ create table GATEWAY_CONNECTION (
create table CONSOLE_APP_CONFIG (
ID int8 not null,
REALM varchar(255) not null,
+ INITIAL_URL varchar(255) not null,
URL varchar(255) not null,
MENU_ENABLED varchar(255) not null default false,
MENU_POSITION varchar(255) not null default 'BOTTOM_LEFT',
diff --git a/model/src/main/java/org/openremote/model/apps/ConsoleAppConfig.java b/model/src/main/java/org/openremote/model/apps/ConsoleAppConfig.java
index bbe419184..747f37dd3 100644
--- a/model/src/main/java/org/openremote/model/apps/ConsoleAppConfig.java
+++ b/model/src/main/java/org/openremote/model/apps/ConsoleAppConfig.java
@@ -21,8 +21,9 @@ public class ConsoleAppConfig {
public ConsoleAppConfig() {
}
- public ConsoleAppConfig(String realm, String url, Boolean menuEnabled, MenuPosition menuPosition, String menuImage, String primaryColor, String secondaryColor, ArrayValue links) {
+ public ConsoleAppConfig(String realm, String initialUrl, String url, Boolean menuEnabled, MenuPosition menuPosition, String menuImage, String primaryColor, String secondaryColor, ArrayValue links) {
this.realm = realm;
+ this.initialUrl = initialUrl;
this.url = url;
this.menuEnabled = menuEnabled;
this.menuPosition = menuPosition;
@@ -40,6 +41,9 @@ public class ConsoleAppConfig {
@Column(name = "REALM", nullable = false)
protected String realm;
+ @Column(name = "INITIAL_URL", nullable = false)
+ protected String initialUrl;
+
@Column(name = "URL", nullable = false)
protected String url;
diff --git a/ui/app/mobile/src/index.ts b/ui/app/mobile/src/index.ts
index 60ce28cd2..cd0c87821 100644
--- a/ui/app/mobile/src/index.ts
+++ b/ui/app/mobile/src/index.ts
@@ -30,7 +30,13 @@ const onboardingConfig:OnboardingConfig = {
title: "Your opinion matters",
type: "default",
description: "With this app we will involve you in developments within the city. We keep you up to date on current projects and will ask for your opinion.",
- image: require("../images/logo-mobile.png")
+ image: require("../images/logo-mobile.png"),
+ enableProviders: [
+ {
+ name:"push",
+ action:"PROVIDER_ENABLE"
+ }
+ ],
},
{
title: "At the right time and place",
@@ -39,7 +45,7 @@ const onboardingConfig:OnboardingConfig = {
enableProviders: [
{
name:"geofence",
- action:"GEOFENCE_REFRESH"
+ action:"PROVIDER_ENABLE"
}
],
image: require("../images/logo-mobile.png")
@@ -56,7 +62,7 @@ const onboardingConfig:OnboardingConfig = {
const splashConfig:SplashConfig = {
redirect: "#!onboarding/",
- interval: 5000,
+ interval: 3000,
logoMobile: require("../images/logo-mobile.png")
}
@@ -78,7 +84,7 @@ const managerConfig: ManagerConfig = {
auth: Auth.NONE,
autoLogin: false,
realm: getRealmQueryParameter(),
- consoleAutoEnable: true,
+ consoleAutoEnable: false,
loadTranslations: ["app", "or"]
};
diff --git a/ui/app/or-app/src/pages/page-mobile-geofences.ts b/ui/app/or-app/src/pages/page-mobile-geofences.ts
index 14467f3ba..8d45a0d2a 100644
--- a/ui/app/or-app/src/pages/page-mobile-geofences.ts
+++ b/ui/app/or-app/src/pages/page-mobile-geofences.ts
@@ -289,10 +289,12 @@ class PageMobileGeofences<S extends AppStateKeyed> extends Page<S> {
}
protected getLocation() {
+ console.info("getLocation pressed");
const map = this.shadowRoot.querySelector('.or-map');
const vectorMap = map as OrMap;
manager.console.sendProviderMessage({provider: 'geofence', action: "GET_LOCATION"}, true).then(response => {
+ console.log(JSON.stringify(response));
if (response.data) {
vectorMap.flyTo({lng: response.data.longitude, lat: response.data.latitude});
}
diff --git a/ui/app/or-app/src/pages/page-mobile-onboarding.ts b/ui/app/or-app/src/pages/page-mobile-onboarding.ts
index c3fccc3ea..cce3bf71b 100644
--- a/ui/app/or-app/src/pages/page-mobile-onboarding.ts
+++ b/ui/app/or-app/src/pages/page-mobile-onboarding.ts
@@ -92,7 +92,7 @@ class PageMobileOnboarding<S extends AppStateKeyed> extends Page<S> {
public connectedCallback() {
super.connectedCallback();
if (localStorage.getItem("completedOnboarding") !== null) {
- window.location.href = this.config.redirect;
+ window.location.href = manager.consoleAppConfig ? manager.consoleAppConfig.url : this.config.redirect;
}
}
@@ -133,21 +133,23 @@ class PageMobileOnboarding<S extends AppStateKeyed> extends Page<S> {
`;
}
- private async enableProviders() {
- if(this.config.pages[this.pageIndex-1].enableProviders) {
- this.config.pages[this.pageIndex-1].enableProviders.map(provider => {
- manager.console.sendProviderMessage({provider: provider.name, action: provider.action}, true)
- })
+ private enableProviders(): Promise<any> {
+ if(this.config.pages[this.pageIndex].enableProviders) {
+ return Promise.all(this.config.pages[this.pageIndex].enableProviders.map(provider => {
+ return manager.console.sendProviderMessage({provider: provider.name, action: provider.action, consoleId: manager.console.registration.id}, true);
+ }));
}
+ return Promise.resolve();
}
-
+
private nextPage(index) {
- if(this.config.pages.length-1 === index) {
- window.location.href = this.config.redirect;
- window.localStorage.setItem("completedOnboarding", "1");
- } else {
- this.pageIndex = this.pageIndex+1
- }
- this.enableProviders();
+ this.enableProviders().then(() => {
+ if (this.config.pages.length - 1 === index) {
+ window.location.href = manager.consoleAppConfig ? manager.consoleAppConfig.url : this.config.redirect;
+ window.localStorage.setItem("completedOnboarding", "1");
+ } else {
+ this.pageIndex = this.pageIndex + 1
+ }
+ });
}
}
diff --git a/ui/component/core/src/console.ts b/ui/component/core/src/console.ts
index b7258a919..329dcbce4 100644
--- a/ui/component/core/src/console.ts
+++ b/ui/component/core/src/console.ts
@@ -526,4 +526,4 @@ export class Console {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.ts
index 16363f1e5..d6b045e0f 100644
--- a/ui/component/core/src/index.ts
+++ b/ui/component/core/src/index.ts
@@ -14,7 +14,8 @@ import {
MetaItemDescriptor,
User,
Role,
- Attribute
+ Attribute,
+ ConsoleAppConfig
} from "@openremote/model";
import * as Util from "./util";
import orIconSet from "./or-icon-set";
@@ -453,6 +454,10 @@ export class Manager implements EventProviderFactory {
return this._console;
}
+ get consoleAppConfig() {
+ return this._consoleAppConfig;
+ }
+
get events() {
return this._events;
}
@@ -569,6 +574,7 @@ export class Manager implements EventProviderFactory {
private _managerVersion: string = "";
private _listeners: EventCallback[] = [];
private _console!: Console;
+ private _consoleAppConfig?: ConsoleAppConfig;
private _events?: EventProvider;
private _displayRealm?: string = "";
@@ -621,6 +627,7 @@ export class Manager implements EventProviderFactory {
if (success) {
success = await this.doDescriptorsInit();
+ await this.getConsoleAppConfig();
}
// TODO: Reinstate this once websocket supports anonymous connections
@@ -851,6 +858,13 @@ export class Manager implements EventProviderFactory {
}
}
+ protected async getConsoleAppConfig(): Promise<void> {
+ const consoleAppConfigResponse = await this.rest.api.ConsoleAppResource.getAppConfig();
+ if(consoleAppConfigResponse.status === 200) {
+ this._consoleAppConfig = consoleAppConfigResponse.data;
+ }
+ }
+
public logout(redirectUrl?: string) {
if (this._keycloak) {
if (this.console.isMobile) {