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
Updated console app to work with Console providers
Michael Rademakerb0af65ef557c
diff --git a/console/generic_app/android/app/build.gradle b/console/generic_app/android/app/build.gradleindex 186e61876..43236342a 100644--- a/console/generic_app/android/app/build.gradle+++ b/console/generic_app/android/app/build.gradle@@ -23,6 +23,7 @@ if (flutterVersionName == null) {apply plugin: 'com.android.application'apply plugin: 'kotlin-android'+apply plugin: 'com.google.gms.google-services'apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"android {@@ -37,8 +38,7 @@ android {}defaultConfig {- // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).- applicationId "io.openremote.generic_app"+ applicationId "io.openremote.app"minSdkVersion 16targetSdkVersion 28versionCode flutterVersionCode.toInteger()diff --git a/console/generic_app/android/app/google-services.json b/console/generic_app/android/app/google-services.jsonnew file mode 100644index 000000000..3eb75c537--- /dev/null+++ b/console/generic_app/android/app/google-services.json@@ -0,0 +1,47 @@+{+ "project_info": {+ "project_number": "667022545910",+ "firebase_url": "https://openremoteapp-a6a60.firebaseio.com",+ "project_id": "openremoteapp-a6a60",+ "storage_bucket": "openremoteapp-a6a60.appspot.com"+ },+ "client": [+ {+ "client_info": {+ "mobilesdk_app_id": "1:667022545910:android:23c352988b6d3d6ea5add7",+ "android_client_info": {+ "package_name": "io.openremote.app"+ }+ },+ "oauth_client": [+ {+ "client_id": "667022545910-g53k1fiocps3sso32hqvotr34fe2libr.apps.googleusercontent.com",+ "client_type": 3+ }+ ],+ "api_key": [+ {+ "current_key": "AIzaSyCXUqMM_P0Vo_pGmebCLgyD8RWeSN71TxU"+ }+ ],+ "services": {+ "appinvite_service": {+ "other_platform_oauth_client": [+ {+ "client_id": "667022545910-g53k1fiocps3sso32hqvotr34fe2libr.apps.googleusercontent.com",+ "client_type": 3+ },+ {+ "client_id": "667022545910-9fee9uvb8iguprjtimmq8uea6cqt2p5i.apps.googleusercontent.com",+ "client_type": 2,+ "ios_info": {+ "bundle_id": "io.openremote.app"+ }+ }+ ]+ }+ }+ }+ ],+ "configuration_version": "1"+}diff --git a/console/generic_app/android/app/src/main/AndroidManifest.xml b/console/generic_app/android/app/src/main/AndroidManifest.xmlindex 05f783ef7..7231a184a 100644--- a/console/generic_app/android/app/src/main/AndroidManifest.xml+++ b/console/generic_app/android/app/src/main/AndroidManifest.xml@@ -13,8 +13,8 @@<applicationandroid:name="io.flutter.app.FlutterApplication"- android:label="generic_app"- android:icon="@mipmap/ic_launcher">+ android:label="OpenRemote"+ android:icon="@mipmap/launcher_icon"><activityandroid:name=".MainActivity"android:launchMode="singleTop"diff --git a/console/generic_app/android/build.gradle b/console/generic_app/android/build.gradleindex 6901e4ac0..9e5ef632c 100644--- a/console/generic_app/android/build.gradle+++ b/console/generic_app/android/build.gradle@@ -8,6 +8,7 @@ buildscript {dependencies {classpath 'com.android.tools.build:gradle:3.5.3'classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"+ classpath 'com.google.gms:google-services:4.2.0'}}diff --git a/console/generic_app/ios/Runner.xcodeproj/project.pbxproj b/console/generic_app/ios/Runner.xcodeproj/project.pbxprojindex 91b737577..9ae11962b 100644--- a/console/generic_app/ios/Runner.xcodeproj/project.pbxproj+++ b/console/generic_app/ios/Runner.xcodeproj/project.pbxproj@@ -9,8 +9,8 @@/* Begin PBXBuildFile section */1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };+ 4CD7187324C9968C00692984 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4CD7187224C9968C00692984 /* GoogleService-Info.plist */; };74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };- 87680EB324B375E6008CC803 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 87680EB224B375E6008CC803 /* GoogleService-Info.plist */; };97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };@@ -36,12 +36,13 @@1CFF1733714D5E6047310E9F /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };22F4AECA8DB2788DCE5E11F8 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };+ 4CD7187224C9968C00692984 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };+ 4CD7187424C996B000692984 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };584E2B9AD7744102DD3DFD0E /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };6BCC9896775CFEDCCE384D35 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };- 87680EB224B375E6008CC803 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; 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 /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };@@ -95,7 +96,7 @@97C146E51CF9000F007C117D = {isa = PBXGroup;children = (- 87680EB224B375E6008CC803 /* GoogleService-Info.plist */,+ 4CD7187224C9968C00692984 /* GoogleService-Info.plist */,9740EEB11CF90186004384FC /* Flutter */,97C146F01CF9000F007C117D /* Runner */,97C146EF1CF9000F007C117D /* Products */,@@ -115,6 +116,7 @@97C146F01CF9000F007C117D /* Runner */ = {isa = PBXGroup;children = (+ 4CD7187424C996B000692984 /* Runner.entitlements */,97C146FA1CF9000F007C117D /* Main.storyboard */,97C146FD1CF9000F007C117D /* Assets.xcassets */,97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,@@ -201,7 +203,7 @@files = (97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,- 87680EB324B375E6008CC803 /* GoogleService-Info.plist in Resources */,+ 4CD7187324C9968C00692984 /* GoogleService-Info.plist in Resources */,97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,);@@ -383,6 +385,7 @@buildSettings = {ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;CLANG_ENABLE_MODULES = YES;+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";DEVELOPMENT_TEAM = 4AC88KZHJZ;ENABLE_BITCODE = NO;@@ -518,6 +521,7 @@buildSettings = {ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;CLANG_ENABLE_MODULES = YES;+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";DEVELOPMENT_TEAM = 4AC88KZHJZ;ENABLE_BITCODE = NO;@@ -546,6 +550,7 @@buildSettings = {ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;CLANG_ENABLE_MODULES = YES;+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";DEVELOPMENT_TEAM = 4AC88KZHJZ;ENABLE_BITCODE = NO;diff --git a/console/generic_app/ios/Runner/Info.plist b/console/generic_app/ios/Runner/Info.plistindex b0b8452f2..100ad723d 100644--- a/console/generic_app/ios/Runner/Info.plist+++ b/console/generic_app/ios/Runner/Info.plist@@ -33,6 +33,7 @@<key>UIBackgroundModes</key><array><string>location</string>+ <string>remote-notification</string></array><key>UILaunchStoryboardName</key><string>LaunchScreen</string>diff --git a/console/generic_app/ios/Runner/Runner.entitlements b/console/generic_app/ios/Runner/Runner.entitlementsnew file mode 100644index 000000000..903def2af--- /dev/null+++ b/console/generic_app/ios/Runner/Runner.entitlements@@ -0,0 +1,8 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>aps-environment</key>+ <string>development</string>+</dict>+</plist>diff --git a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dartindex ba669998a..4fb59a2c6 100644--- a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart+++ b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart@@ -57,7 +57,7 @@ class GeofenceProvider {return GeofenceProvider(await SharedPreferences.getInstance());}- initialize() async {+ Future<Map<String, dynamic>> initialize() async {return {"action": "PROVIDER_INIT","provider": "geofence",@@ -115,7 +115,7 @@ class GeofenceProvider {}}- disable() async {+ Future<Map<String, dynamic>> disable() async {for (String geofenceId in geofences.map((e) => e.id)) {Geofence.removeGeolocation(new Geolocation(id: geofenceId), GeolocationEvent.exit);@@ -186,7 +186,7 @@ class GeofenceProvider {_sharedPreferences.setString(geofencesKey,- json.encode(geofenceDefinitions.map((e) => e.toJson())))+ json.encode(geofenceDefinitions.map((e) => e.toJson()).toList())).then((value) => geofences = geofenceDefinitions);});}diff --git a/console/generic_app/lib/ConsoleProviders/PushProvider.dart b/console/generic_app/lib/ConsoleProviders/PushProvider.dartindex fd3b96bdd..8f8a2244e 100644--- a/console/generic_app/lib/ConsoleProviders/PushProvider.dart+++ b/console/generic_app/lib/ConsoleProviders/PushProvider.dart@@ -21,10 +21,10 @@ class PushProvider {await SharedPreferences.getInstance(), FirebaseMessaging());}- initialize() async {+ Future<Map<String, dynamic>> initialize() async {return {"action": "PROVIDER_INIT",- "provider": "geofence",+ "provider": "push","version": _version,"requiresPermission": true,"hasPermission": await Permission.notification.isGranted,@@ -41,6 +41,15 @@ class PushProvider {await _sharedPreferences.setBool(pushDisabledKey, false);if (await Permission.notification.isGranted) {+ _fcm.getToken().then((token) {+ callback?.call({+ "action": "PROVIDER_ENABLE",+ "provider": "push",+ "hasPermission": true,+ "success": true,+ "data": {"token": token}+ });+ });} else {if (await Permission.notification.isUndetermined) {Permission.notification.request().then((value) {@@ -74,7 +83,7 @@ class PushProvider {}}- disable() async {+ Future<Map<String, dynamic>> disable() async {await _sharedPreferences.setBool(pushDisabledKey, true);return {"action": "PROVIDER_DISABLE",diff --git a/console/generic_app/lib/ConsoleProviders/StorageProvider.dart b/console/generic_app/lib/ConsoleProviders/StorageProvider.dartindex 40bb08e3f..b247114fa 100644--- a/console/generic_app/lib/ConsoleProviders/StorageProvider.dart+++ b/console/generic_app/lib/ConsoleProviders/StorageProvider.dart@@ -12,7 +12,7 @@ class StorageProvider {return StorageProvider._internal(await SharedPreferences.getInstance());}- initialize() {+ Map<String, dynamic> initialize() {return {"action": "PROVIDER_INIT","provider": "storage",@@ -24,7 +24,7 @@ class StorageProvider {};}- enable() {+ Map<String, dynamic> enable() {return {"action": "PROVIDER_ENABLE","provider": "storage",@@ -33,14 +33,14 @@ class StorageProvider {};}- disable() {+ Map<String, dynamic> disable() {return {"action": "PROVIDER_DISABLE","provider": "storage",};}- store(String key, String data) {+ Map<String, dynamic> store(String key, String data) {if (data == null) {_sharedPreferences.remove(key);} else {@@ -48,7 +48,7 @@ class StorageProvider {}}- retrieve(String key) {+ Map<String, dynamic> retrieve(String key) {return {"action": "RETRIEVE","provider": "storage",diff --git a/console/generic_app/lib/config/CurrentConsoleAppConfig.dart b/console/generic_app/lib/config/CurrentConsoleAppConfig.dartindex ac96fd338..8f8581502 100644--- a/console/generic_app/lib/config/CurrentConsoleAppConfig.dart+++ b/console/generic_app/lib/config/CurrentConsoleAppConfig.dart@@ -47,6 +47,9 @@ class CurrentConsoleAppConfig {String get url {return _url;+ //consolePlatform+ //consoleName=realm+ //consoleVersion}bool get menuEnabled {@@ -74,6 +77,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/LinkConfig.dart b/console/generic_app/lib/models/LinkConfig.dartindex bb488b35c..e5a03d2d9 100644--- a/console/generic_app/lib/models/LinkConfig.dart+++ b/console/generic_app/lib/models/LinkConfig.dart@@ -10,10 +10,9 @@ class LinkConfig implements BaseModel {final String displayText;final String pageLink;- final Map<String, String> queryParams;- LinkConfig(this.displayText, this.pageLink, this.queryParams);+ LinkConfig(this.displayText, this.pageLink);static LinkConfig fromJson(Map<String, dynamic> json) => _$LinkConfigFromJson(json);Map<String, dynamic> toJson() => _$LinkConfigToJson(this);-}\ No newline at end of file+}diff --git a/console/generic_app/lib/models/LinkConfig.g.dart b/console/generic_app/lib/models/LinkConfig.g.dartindex 828ea5973..92250e540 100644--- a/console/generic_app/lib/models/LinkConfig.g.dart+++ b/console/generic_app/lib/models/LinkConfig.g.dart@@ -10,9 +10,6 @@ LinkConfig _$LinkConfigFromJson(Map<String, dynamic> json) {return LinkConfig(json['displayText'] as String,json['pageLink'] as String,- (json['queryParams'] as Map<String, dynamic>)?.map(- (k, e) => MapEntry(k, e as String),- ),);}@@ -20,5 +17,4 @@ Map<String, dynamic> _$LinkConfigToJson(LinkConfig instance) =><String, dynamic>{'displayText': instance.displayText,'pageLink': instance.pageLink,- 'queryParams': instance.queryParams,};diff --git a/console/generic_app/lib/ui/ProjectPage.dart b/console/generic_app/lib/ui/ProjectPage.dartindex 0144f87bb..7ac8909dd 100644--- a/console/generic_app/lib/ui/ProjectPage.dart+++ b/console/generic_app/lib/ui/ProjectPage.dart@@ -132,7 +132,7 @@ class _ProjectPageState extends State<ProjectPage> {void _getConsoleAppConfig() {var apiManager =- new ApiManager("https://$_projectName.openremote.io/api/$_realmName");+ 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);diff --git a/console/generic_app/lib/ui/SplashPage.dart b/console/generic_app/lib/ui/SplashPage.dartindex 55ba4ddad..29bf58533 100644--- a/console/generic_app/lib/ui/SplashPage.dart+++ b/console/generic_app/lib/ui/SplashPage.dart@@ -58,7 +58,7 @@ class _SplashPageState extends State<SplashPage> {void _getConsoleAppConfig() {var apiManager =- new ApiManager("https://$_projectName.openremote.io/api/$_realmName");+ new ApiManager("http://192.168.100.9:8080/api/$_realmName");apiManager.get(["app", "config"], ConsoleAppConfig.fromJson).then((value) {print(value);CurrentConsoleAppConfig.instance.updateConfig(value, _projectName);diff --git a/console/generic_app/lib/ui/WebViewPage.dart b/console/generic_app/lib/ui/WebViewPage.dartindex 9ac341848..08c7ab997 100644--- a/console/generic_app/lib/ui/WebViewPage.dart+++ b/console/generic_app/lib/ui/WebViewPage.dart@@ -29,6 +29,7 @@ class _WebViewPageState extends State<WebViewPage> {@overrideWidget build(BuildContext context) {_webView = WebView(+ debuggingEnabled: true,onPageStarted: (url) {print("started: $url");},@@ -75,12 +76,12 @@ class _WebViewPageState extends State<WebViewPage> {_notifyClient(Map<String, dynamic> data) {final String jsonString = json.encode(data);_controller.evaluateJavascript(- "OpenRemoteConsole._handleProviderResponse($jsonString)");+ "OpenRemoteConsole._handleProviderResponse(JSON.stringify($jsonString))");}JavascriptChannel _postMessageJavascriptChannel(BuildContext context) {return JavascriptChannel(- name: 'postMessage',+ name: 'MobileInterface',onMessageReceived: (JavascriptMessage message) {Map<String, dynamic> messageContent = json.decode(message.message);String messageType = messageContent["type"];@@ -158,8 +159,13 @@ class _WebViewPageState extends State<WebViewPage> {}}- _handleStorageProviderMessage(Map<String, dynamic> data) {+ _handleStorageProviderMessage(Map<String, dynamic> data) async {String action = data["action"];++ if (_storageProvider == null) {+ _storageProvider = await StorageProvider.getInstance();+ }+if (action == "PROVIDER_INIT") {_notifyClient(_storageProvider.initialize());} else if (action == "PROVIDER_ENABLE") {diff --git a/console/generic_app/pubspec.lock b/console/generic_app/pubspec.lockindex 7f726b7ad..d50a81639 100644--- a/console/generic_app/pubspec.lock+++ b/console/generic_app/pubspec.lock@@ -188,6 +188,13 @@ packages:url: "https://pub.dartlang.org"source: hostedversion: "0.2.0"+ flutter_launcher_icons:+ dependency: "direct dev"+ description:+ name: flutter_launcher_icons+ url: "https://pub.dartlang.org"+ source: hosted+ version: "0.7.5"flutter_localizations:dependency: "direct main"description: flutterdiff --git a/console/generic_app/pubspec.yaml b/console/generic_app/pubspec.yamlindex 617f28591..d52da98e2 100644--- a/console/generic_app/pubspec.yaml+++ b/console/generic_app/pubspec.yaml@@ -1,5 +1,5 @@name: generic_app-description: A new Flutter project.+description: Generic app of OpenRemote# The following defines the version and build number for your application.# A version number is three numbers separated by dots, like 1.2.43@@ -41,6 +41,12 @@ dev_dependencies:build_runner: 1.8.1json_serializable: 3.3.0+ flutter_launcher_icons: "^0.7.3"++flutter_icons:+ android: "launcher_icon"+ ios: true+ image_path: "assets/images/or_splash.png"# For information on the generic Dart part of this file, see the