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 stuff with getting location. Also added initial URL to ConsoleAppConfig.dart
Michael Rademaker4e9e95a5516f
diff --git a/console/generic_app/ios/Runner.xcodeproj/project.pbxproj b/console/generic_app/ios/Runner.xcodeproj/project.pbxprojindex ab3bbf404..9b8735c80 100644--- a/console/generic_app/ios/Runner.xcodeproj/project.pbxproj+++ b/console/generic_app/ios/Runner.xcodeproj/project.pbxproj@@ -45,7 +45,7 @@7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };- 97C146EE1CF9000F007C117D /* OR App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OR App.app"; sourceTree = BUILT_PRODUCTS_DIR; };+ 97C146EE1CF9000F007C117D /* OpenRemote.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OpenRemote.app; sourceTree = BUILT_PRODUCTS_DIR; };97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };@@ -108,7 +108,7 @@97C146EF1CF9000F007C117D /* Products */ = {isa = PBXGroup;children = (- 97C146EE1CF9000F007C117D /* OR App.app */,+ 97C146EE1CF9000F007C117D /* OpenRemote.app */,);name = Products;sourceTree = "<group>";@@ -159,7 +159,7 @@);name = Runner;productName = Runner;- productReference = 97C146EE1CF9000F007C117D /* OR App.app */;+ productReference = 97C146EE1CF9000F007C117D /* OpenRemote.app */;productType = "com.apple.product-type.application";};/* End PBXNativeTarget section */@@ -402,7 +402,7 @@"$(PROJECT_DIR)/Flutter",);PRODUCT_BUNDLE_IDENTIFIER = io.openremote.app;- PRODUCT_NAME = "OR App";+ PRODUCT_NAME = OpenRemote;SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";SWIFT_VERSION = 5.0;VERSIONING_SYSTEM = "apple-generic";@@ -538,7 +538,7 @@"$(PROJECT_DIR)/Flutter",);PRODUCT_BUNDLE_IDENTIFIER = io.openremote.app;- PRODUCT_NAME = "OR App";+ PRODUCT_NAME = OpenRemote;SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";SWIFT_OPTIMIZATION_LEVEL = "-Onone";SWIFT_VERSION = 5.0;@@ -567,7 +567,7 @@"$(PROJECT_DIR)/Flutter",);PRODUCT_BUNDLE_IDENTIFIER = io.openremote.app;- PRODUCT_NAME = "OR App";+ PRODUCT_NAME = OpenRemote;SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";SWIFT_VERSION = 5.0;VERSIONING_SYSTEM = "apple-generic";diff --git a/console/generic_app/ios/Runner/Info.plist b/console/generic_app/ios/Runner/Info.plistindex 0f1025432..a60097a2c 100644--- a/console/generic_app/ios/Runner/Info.plist+++ b/console/generic_app/ios/Runner/Info.plist@@ -5,7 +5,7 @@<key>CFBundleDevelopmentRegion</key><string>$(DEVELOPMENT_LANGUAGE)</string><key>CFBundleDisplayName</key>- <string></string>+ <string>$(PRODUCT_NAME)</string><key>CFBundleExecutable</key><string>$(EXECUTABLE_NAME)</string><key>CFBundleIdentifier</key>diff --git a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dartindex 1e2b34db3..a6ec39ad1 100644--- a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart+++ b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart@@ -3,6 +3,7 @@ import 'dart:convert';import 'package:flutter/material.dart';import 'package:flutter_geofence/Geolocation.dart';import 'package:flutter_geofence/geofence.dart';+import 'package:location/location.dart';import 'package:generic_app/ConsoleProviders/GeoLocation.dart';import 'package:generic_app/models/GeofenceDefinition.dart';import 'package:generic_app/network/ApiManager.dart';@@ -33,8 +34,10 @@ class GeofenceProvider {GeoLocation _exitedLocation;bool _sendQueued;+ Location _locationManager;+GeofenceProvider._internal(this._baseURL, this._consoleId, this.geofences,- this._sharedPreferences, this._apiManager);+ this._sharedPreferences, this._apiManager, this._locationManager);factory GeofenceProvider(SharedPreferences sharedPreferences) {String geofenceString = sharedPreferences.getString(geofencesKey);@@ -50,7 +53,8 @@ class GeofenceProvider {sharedPreferences.getString(consoleIdKey),geofences,sharedPreferences,- ApiManager(sharedPreferences.getString(baseUrlKey)));+ ApiManager(sharedPreferences.getString(baseUrlKey)),+ new Location());}static Future<GeofenceProvider> getInstance() async {@@ -263,27 +267,26 @@ class GeofenceProvider {_getLocationCallback = callback;if (await Permission.locationAlways.isGranted) {- Geofence.getCurrentLocation().then((coordinate) {- _getLocationCallback({- "action": "GET_LOCATION",- "provider": "geofence",- "data": {- "latitude": coordinate.latitude,- "longitude": coordinate.longitude- }- });+ LocationData locationData = await _locationManager.getLocation();+ _getLocationCallback({+ "action": "GET_LOCATION",+ "provider": "geofence",+ "data": {+ "latitude": locationData.latitude,+ "longitude": locationData.longitude+ }});} else {if (await Permission.locationAlways.isUndetermined) {Permission.locationAlways.request().then((value) {if (value.isGranted) {- Geofence.getCurrentLocation().then((coordinate) {+ _locationManager.getLocation().then((locationData) {_getLocationCallback({"action": "GET_LOCATION","provider": "geofence","data": {- "latitude": coordinate.latitude,- "longitude": coordinate.longitude+ "latitude": locationData.latitude,+ "longitude": locationData.longitude}});});diff --git a/console/generic_app/lib/config/CurrentConsoleAppConfig.dart b/console/generic_app/lib/config/CurrentConsoleAppConfig.dartindex ab7394ef0..f9fad802e 100644--- a/console/generic_app/lib/config/CurrentConsoleAppConfig.dart+++ b/console/generic_app/lib/config/CurrentConsoleAppConfig.dart@@ -12,6 +12,7 @@ class CurrentConsoleAppConfig {updateConfig(ConsoleAppConfig appConfig, String project) {this._realm = appConfig.realm;+ this._initialUrl = appConfig.initialUrl;this._url = appConfig.url;this._menuEnabled = appConfig.menuEnabled;this._menuPosition = appConfig.menuPosition;@@ -22,21 +23,14 @@ class CurrentConsoleAppConfig {}String _realm;-+ String _initialUrl;String _url;-bool _menuEnabled;-String _menuPosition;-String _menuImage;-String _primaryColor;-String _secondaryColor;-List<LinkConfig> _links;-String _project;@@ -44,6 +38,10 @@ class CurrentConsoleAppConfig {return _realm;}+ String get initialUrl {+ return _initialUrl;+ }+String get url {return _url;//consolePlatform@@ -76,6 +74,6 @@ class CurrentConsoleAppConfig {}String get baseUrl {- return "https://$_project.openremote.io/api/$_realm";+ return "http://192.168.100.9:8080/api/$_realm";}}diff --git a/console/generic_app/lib/models/ConsoleAppConfig.dart b/console/generic_app/lib/models/ConsoleAppConfig.dartindex 9b08bbfb6..9ee4f657c 100644--- a/console/generic_app/lib/models/ConsoleAppConfig.dart+++ b/console/generic_app/lib/models/ConsoleAppConfig.dart@@ -10,25 +10,20 @@ part 'ConsoleAppConfig.g.dart';class ConsoleAppConfig implements BaseModel {final int id;- final String realm ;-+ final String realm;+ final String initialUrl;final String url;-final bool menuEnabled;-final String menuPosition;-final String menuImage;-final String primaryColor;-final String secondaryColor;-final List<LinkConfig> links;ConsoleAppConfig({this.id,this.realm,+ this.initialUrl,this.url,this.menuEnabled,this.menuPosition,@@ -40,4 +35,4 @@ class ConsoleAppConfig implements BaseModel {static ConsoleAppConfig fromJson(Map<String, dynamic> json) => _$ConsoleAppConfigFromJson(json);Map<String, dynamic> toJson() => _$ConsoleAppConfigToJson(this);-}\ No newline at end of file+}diff --git a/console/generic_app/lib/models/ConsoleAppConfig.g.dart b/console/generic_app/lib/models/ConsoleAppConfig.g.dartindex 422c7a764..64912da41 100644--- a/console/generic_app/lib/models/ConsoleAppConfig.g.dart+++ b/console/generic_app/lib/models/ConsoleAppConfig.g.dart@@ -10,6 +10,7 @@ ConsoleAppConfig _$ConsoleAppConfigFromJson(Map<String, dynamic> json) {return ConsoleAppConfig(id: json['id'] as int,realm: json['realm'] as String,+ initialUrl: json['initialUrl'] as String,url: json['url'] as String,menuEnabled: json['menuEnabled'] as bool,menuPosition: json['menuPosition'] as String,@@ -27,6 +28,7 @@ Map<String, dynamic> _$ConsoleAppConfigToJson(ConsoleAppConfig instance) =><String, dynamic>{'id': instance.id,'realm': instance.realm,+ 'initialUrl': instance.initialUrl,'url': instance.url,'menuEnabled': instance.menuEnabled,'menuPosition': instance.menuPosition,diff --git a/console/generic_app/lib/ui/ProjectPage.dart b/console/generic_app/lib/ui/ProjectPage.dartindex 25d0ff9be..06c652b66 100644--- a/console/generic_app/lib/ui/ProjectPage.dart+++ b/console/generic_app/lib/ui/ProjectPage.dart@@ -131,7 +131,7 @@ class _ProjectPageState extends State<ProjectPage> {}void _getConsoleAppConfig() {- var apiManager = new ApiManager("https://$_projectName.openremote.io/api/$_realmName");+ var apiManager = new ApiManager("http://192.168.100.9:8080/api/$_realmName");apiManager.get(["app", "config"], ConsoleAppConfig.fromJson).then((value) {_sharedPreferences.setString("project", _projectName);_sharedPreferences.setString("realm", _realmName);@@ -140,7 +140,7 @@ class _ProjectPageState extends State<ProjectPage> {context,MaterialPageRoute(builder: (context) => WebViewPage(- initialUrl: CurrentConsoleAppConfig.instance.url,+ initialUrl: CurrentConsoleAppConfig.instance.initialUrl,)));}).catchError((onError) {print(onError);diff --git a/console/generic_app/lib/ui/SplashPage.dart b/console/generic_app/lib/ui/SplashPage.dartindex 68eba70d6..e230c2d2c 100644--- a/console/generic_app/lib/ui/SplashPage.dart+++ b/console/generic_app/lib/ui/SplashPage.dart@@ -35,6 +35,8 @@ class _SplashPageState extends State<SplashPage> {]);quickActions.initialize((String shortcutType) async {if (shortcutType == 'starting_page') {+ _sharedPreferences = await SharedPreferences.getInstance();+ await _sharedPreferences.clear();ORApp.navigatorKey.currentState.pushReplacement(MaterialPageRoute(builder: (context) => ProjectPage()));}});@@ -54,7 +56,7 @@ class _SplashPageState extends State<SplashPage> {context,MaterialPageRoute(builder: (context) => WebViewPage(- initialUrl: CurrentConsoleAppConfig.instance.url)));+ initialUrl: CurrentConsoleAppConfig.instance.initialUrl)));} else {Navigator.pushReplacement(context,MaterialPageRoute(builder: (context) => ProjectPage()));@@ -91,7 +93,7 @@ class _SplashPageState extends State<SplashPage> {Future<bool> _getConsoleAppConfig() async {var apiManager =- new ApiManager("https://$_projectName.openremote.io/api/$_realmName");+ new ApiManager("http://192.168.100.9:8080/api/$_realmName");return apiManager.get(["app", "config"], ConsoleAppConfig.fromJson).then((value) {CurrentConsoleAppConfig.instance.updateConfig(value, _projectName);diff --git a/console/generic_app/lib/ui/WebViewPage.dart b/console/generic_app/lib/ui/WebViewPage.dartindex 9c4f02197..a17942982 100644--- a/console/generic_app/lib/ui/WebViewPage.dart+++ b/console/generic_app/lib/ui/WebViewPage.dart@@ -205,6 +205,13 @@ class _WebViewPageState extends State<WebViewPage> {decoration: BoxDecoration(shape: BoxShape.circle,color: CurrentConsoleAppConfig.instance.primaryColor,+ boxShadow: [+ BoxShadow(+ color: Colors.grey.withOpacity(0.5),+ spreadRadius: 2,+ blurRadius: 2,+ ),+ ]),child: Icon(Icons.menu),),diff --git a/console/generic_app/pubspec.lock b/console/generic_app/pubspec.lockindex 1318986d8..34618e16e 100644--- a/console/generic_app/pubspec.lock+++ b/console/generic_app/pubspec.lock@@ -294,6 +294,27 @@ packages:url: "https://pub.dartlang.org"source: hostedversion: "3.3.0"+ location:+ dependency: "direct main"+ description:+ name: location+ url: "https://pub.dartlang.org"+ source: hosted+ version: "3.0.2"+ location_platform_interface:+ dependency: transitive+ description:+ name: location_platform_interface+ url: "https://pub.dartlang.org"+ source: hosted+ version: "1.0.0"+ location_web:+ dependency: transitive+ description:+ name: location_web+ url: "https://pub.dartlang.org"+ source: hosted+ version: "1.0.0"logging:dependency: transitivedescription:diff --git a/console/generic_app/pubspec.yaml b/console/generic_app/pubspec.yamlindex 02e593a40..31b88d7b1 100644--- a/console/generic_app/pubspec.yaml+++ b/console/generic_app/pubspec.yaml@@ -11,7 +11,7 @@ description: Generic app of OpenRemote# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.# Read more about iOS versioning at# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html-version: 1.0.0+9+version: 1.0.0+10environment:sdk: ">=2.2.0 <3.0.0"@@ -30,6 +30,7 @@ dependencies:json_annotation: ^3.0.1flutter_geofence: ^0.2.0+ location: ^3.0.0webview_flutter: ^0.3.22+1shared_preferences: ^0.5.7+3permission_handler: ^5.0.1+1diff --git a/ui/app/main/package.json b/ui/app/main/package.jsonindex 98572481d..0b27f12e3 100644--- a/ui/app/main/package.json+++ b/ui/app/main/package.json@@ -10,7 +10,7 @@"modelBuild": "node ../../model-build.js","modelWatch": "node ../../model-watch.js","build": "npx tsc -b && npx cross-env NODE_OPTIONS=--max_old_space_size=4096 webpack --mode production",- "serve": "npx cross-env NODE_OPTIONS=--max_old_space_size=4096 webpack-dev-server --mode development",+ "serve": "npx cross-env NODE_OPTIONS=--max_old_space_size=4096 webpack-dev-server --host 0.0.0.0 --port 8000 --mode development","watch": "npx tsc -b -w","test": "echo \"Error: no test specified\" && exit 1"},