From da4d03d314513677bef5a207530da2edb3c1f4e7 Mon Sep 17 00:00:00 2001 From: Arthur Verdon Date: Tue, 8 Dec 2020 09:16:10 +0100 Subject: [PATCH 1/7] begin migrating to latest version of ang/ionic --- packages/mobile-app/package.json | 34 +++++++++-------- .../mobile-app/src/app/app-routing.module.ts | 38 +++++++++++++------ .../set-global-position.page.ts | 30 ++++++++++++++- .../take-picture/take-picture.page.ts | 2 +- 4 files changed, 73 insertions(+), 31 deletions(-) diff --git a/packages/mobile-app/package.json b/packages/mobile-app/package.json index 7f9eaae..bf36708 100644 --- a/packages/mobile-app/package.json +++ b/packages/mobile-app/package.json @@ -24,20 +24,21 @@ "@angular/platform-browser": "~8.1.2", "@angular/platform-browser-dynamic": "~8.1.2", "@angular/router": "~8.1.2", - "@capacitor/android": "^1.4.0", - "@capacitor/core": "^1.5.2", - "@fortawesome/fontawesome-free": "^5.13.0", - "@ionic-native/core": "^5.0.0", - "@ionic-native/splash-screen": "^5.0.0", - "@ionic-native/status-bar": "^5.0.0", - "@ionic/angular": "^4.7.1", - "@ionic/storage": "^2.2.0", + "@capacitor/android": "^2.4.4", + "@capacitor/core": "^1.5.3", + "@fortawesome/fontawesome-free": "^5.15.1", + "@ionic-native/core": "^5.30.0", + "@ionic-native/splash-screen": "^5.30.0", + "@ionic-native/status-bar": "^5.30.0", + "@ionic/angular": "^5.5.1", + "@ionic/storage": "^2.3.1", "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "^4.0.0", - "cordova-android": "8.1.0", - "core-js": "^2.5.4", + "cordova-android": "^9.0.0", + "core-js": "^2.6.12", + "leaflet": "^1.7.1", "rxjs": "~6.5.1", - "tslib": "^1.9.0", + "tslib": "^1.14.1", "zone.js": "~0.9.1" }, "devDependencies": { @@ -49,11 +50,12 @@ "@angular/compiler": "~8.1.2", "@angular/compiler-cli": "~8.1.2", "@angular/language-service": "~8.1.2", - "@capacitor/cli": "^1.5.2", - "@ionic/angular-toolkit": "~2.0.0", - "@ionic/cli": "^6.10.1", + "@capacitor/cli": "^1.5.3", + "@ionic/angular-toolkit": "^3.0.0", + "@ionic/cli": "^6.12.2", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", + "@types/leaflet": "^1.5.19", "@types/node": "~8.9.4", "codelyzer": "^5.0.0", "cordova-plugin-device": "^2.0.2", @@ -64,12 +66,12 @@ "cordova-plugin-whitelist": "^1.3.3", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", - "karma": "~4.1.0", + "karma": "^5.2.3", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", - "protractor": "~5.4.0", + "protractor": "^7.0.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.4.3" diff --git a/packages/mobile-app/src/app/app-routing.module.ts b/packages/mobile-app/src/app/app-routing.module.ts index a80569c..03e3603 100644 --- a/packages/mobile-app/src/app/app-routing.module.ts +++ b/packages/mobile-app/src/app/app-routing.module.ts @@ -30,7 +30,11 @@ export class IsSignedInGuard implements CanActivate { const routes: Routes = [ { path: '', redirectTo: 'login', pathMatch: 'full' }, - { path: 'login', loadChildren: './login/login.module#LoginPageModule' }, + { + path: 'login', + loadChildren: () => + import('./login/login.module').then((m) => m.LoginPageModule), + }, { path: 'home', loadChildren: () => @@ -42,28 +46,38 @@ const routes: Routes = [ children: [ { path: 'select-obstacle', - loadChildren: - './contribution/select-obstacle/select-obstacle.module#SelectObstaclePageModule', + loadChildren: () => + import('./contribution/select-obstacle/select-obstacle.module').then( + (m) => m.SelectObstaclePageModule + ), }, { path: 'take-picture/:obstacle', - loadChildren: - './contribution/take-picture/take-picture.module#TakePicturePageModule', + loadChildren: () => + import('./contribution/take-picture/take-picture.module').then( + (m) => m.TakePicturePageModule + ), }, { - path: 'set-global-position', - loadChildren: - './contribution/set-global-position/set-global-position.module#SetGlobalPositionPageModule', + path: 'set-position', + loadChildren: () => + import( + './contribution/set-global-position/set-global-position.module' + ).then((m) => m.SetGlobalPositionPageModule), }, { path: 'obstacle-summary', - loadChildren: - './contribution/obstacle-summary/obstacle-summary.module#ObstacleSummaryPageModule', + loadChildren: () => + import( + './contribution/obstacle-summary/obstacle-summary.module' + ).then((m) => m.ObstacleSummaryPageModule), }, { path: 'feedback', - loadChildren: - './contribution/feedback/feedback.module#FeedbackPageModule', + loadChildren: () => + import('./contribution/feedback/feedback.module').then( + (m) => m.FeedbackPageModule + ), }, ], }, diff --git a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.ts b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.ts index 466dc1a..249ffc3 100644 --- a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.ts +++ b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.ts @@ -1,4 +1,6 @@ import { Component, OnInit } from '@angular/core'; +import { Capacitor, Plugins } from '@capacitor/core'; +import { Location } from '../../models/location.model'; @Component({ selector: 'app-set-global-position', @@ -6,10 +8,34 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./set-global-position.page.scss'], }) export class SetGlobalPositionPage implements OnInit { + private location = new Location(); - constructor() { } + constructor() {} - ngOnInit() { + async ngOnInit() {} + + async ionViewWillEnter() { + await this.autoLocate(); } + /** + * Will locate the user with high accuracy + */ + private async autoLocate() { + if (!Capacitor.isPluginAvailable('Geolocation')) { + console.error('error GPS'); + return; + } + + // For more information about the options: + // https://github.com/apache/cordova-plugin-geolocation#geolocationoptions + const position = await Plugins.Geolocation.getCurrentPosition({ + maximumAge: 1000, + timeout: 5000, + enableHighAccuracy: true, + }); + + this.location.lat = position.coords.latitude; + this.location.lng = position.coords.longitude; + } } diff --git a/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.ts b/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.ts index 55ce777..dadcefc 100644 --- a/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.ts +++ b/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.ts @@ -20,7 +20,7 @@ export class TakePicturePage implements OnInit { onImagePicked(imageData: string) { this.param.image = imageData; this.param.obstacle = this.obstacle; - this.router.navigate(['/contribution/obstacle-summary']); + this.router.navigate(['/contribution/set-position']); } onCancelImagePIcked() { From d243b247d05d28db424e0a398e2762a6d7b457ac Mon Sep 17 00:00:00 2001 From: Arthur Verdon Date: Tue, 8 Dec 2020 09:17:59 +0100 Subject: [PATCH 2/7] update to latest angular 8 --- packages/mobile-app/package.json | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/mobile-app/package.json b/packages/mobile-app/package.json index bf36708..0caa650 100644 --- a/packages/mobile-app/package.json +++ b/packages/mobile-app/package.json @@ -17,13 +17,13 @@ "private": true, "dependencies": { "@angular/animations": "8.2.14", - "@angular/common": "~8.1.2", - "@angular/compiler": "~8.1.2", - "@angular/core": "~8.1.2", - "@angular/forms": "~8.1.2", - "@angular/platform-browser": "~8.1.2", - "@angular/platform-browser-dynamic": "~8.1.2", - "@angular/router": "~8.1.2", + "@angular/common": "~8.2.14", + "@angular/compiler": "~8.2.14", + "@angular/core": "~8.2.14", + "@angular/forms": "~8.2.14", + "@angular/platform-browser": "~8.2.14", + "@angular/platform-browser-dynamic": "~8.2.14", + "@angular/router": "~8.2.14", "@capacitor/android": "^2.4.4", "@capacitor/core": "^1.5.3", "@fortawesome/fontawesome-free": "^5.15.1", @@ -37,7 +37,7 @@ "cordova-android": "^9.0.0", "core-js": "^2.6.12", "leaflet": "^1.7.1", - "rxjs": "~6.5.1", + "rxjs": "~6.6.3", "tslib": "^1.14.1", "zone.js": "~0.9.1" }, @@ -46,10 +46,9 @@ "@angular-devkit/build-angular": "^0.803.24", "@angular-devkit/core": "~8.1.2", "@angular-devkit/schematics": "~8.1.2", - "@angular/cli": "~8.1.2", - "@angular/compiler": "~8.1.2", - "@angular/compiler-cli": "~8.1.2", - "@angular/language-service": "~8.1.2", + "@angular/cli": "~8.3.29", + "@angular/compiler-cli": "~8.2.14", + "@angular/language-service": "~8.2.14", "@capacitor/cli": "^1.5.3", "@ionic/angular-toolkit": "^3.0.0", "@ionic/cli": "^6.12.2", @@ -74,7 +73,7 @@ "protractor": "^7.0.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", - "typescript": "~3.4.3" + "typescript": "~3.5.3" }, "description": "An Ionic project", "cordova": { From 5dc6ea6cee52cae014a30e96ac176b431d34bfc8 Mon Sep 17 00:00:00 2001 From: Arthur Verdon Date: Tue, 8 Dec 2020 10:01:03 +0100 Subject: [PATCH 3/7] Complete upgrade to latest lib --- .../{browserslist => .browserslistrc} | 0 packages/mobile-app/android/app/build.gradle | 10 +-- .../android/app/src/main/AndroidManifest.xml | 2 +- .../app/src/main/assets/capacitor.config.json | 6 +- .../app/src/main/res/layout/activity_main.xml | 4 +- packages/mobile-app/android/build.gradle | 2 +- packages/mobile-app/android/gradle.properties | 2 + .../gradle/wrapper/gradle-wrapper.properties | 4 +- packages/mobile-app/angular.json | 26 +++++-- packages/mobile-app/capacitor.config.json | 6 +- packages/mobile-app/e2e/tsconfig.json | 2 +- packages/mobile-app/package.json | 58 +++++++-------- .../mobile-app/src/app/app-routing.module.ts | 2 +- .../mobile-app/src/app/app.component.spec.ts | 4 +- .../feedback/feedback.page.spec.ts | 4 +- .../obstacle-summary.page.html | 2 +- .../obstacle-summary.page.spec.ts | 4 +- .../obstacle-summary/obstacle-summary.page.ts | 2 +- .../select-obstacle.page.spec.ts | 4 +- .../set-global-position.page.spec.ts | 4 +- .../take-picture/take-picture.page.html | 2 +- .../take-picture/take-picture.page.spec.ts | 4 +- .../camera/camera.component.spec.ts | 4 +- .../location/location.component.spec.ts | 4 +- .../map-modal/map-modal.component.spec.ts | 4 +- .../mobile-app/src/app/home/home.page.spec.ts | 4 +- .../src/app/login/login.page.spec.ts | 4 +- packages/mobile-app/tsconfig.app.json | 9 ++- packages/mobile-app/tsconfig.json | 2 +- packages/mobile-app/tslint.json | 73 ++++++++++++++++++- 30 files changed, 174 insertions(+), 84 deletions(-) rename packages/mobile-app/{browserslist => .browserslistrc} (100%) diff --git a/packages/mobile-app/browserslist b/packages/mobile-app/.browserslistrc similarity index 100% rename from packages/mobile-app/browserslist rename to packages/mobile-app/.browserslistrc diff --git a/packages/mobile-app/android/app/build.gradle b/packages/mobile-app/android/app/build.gradle index 5b0b33a..5266756 100644 --- a/packages/mobile-app/android/app/build.gradle +++ b/packages/mobile-app/android/app/build.gradle @@ -8,7 +8,7 @@ android { targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { release { @@ -29,11 +29,11 @@ repositories { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'androidx.appcompat:appcompat:1.0.0' implementation project(':capacitor-android') testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' implementation project(':capacitor-cordova-android-plugins') } @@ -46,4 +46,4 @@ try { } } catch(Exception e) { logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work") -} \ No newline at end of file +} diff --git a/packages/mobile-app/android/app/src/main/AndroidManifest.xml b/packages/mobile-app/android/app/src/main/AndroidManifest.xml index 5c8bd3c..b6f097b 100644 --- a/packages/mobile-app/android/app/src/main/AndroidManifest.xml +++ b/packages/mobile-app/android/app/src/main/AndroidManifest.xml @@ -34,7 +34,7 @@ diff --git a/packages/mobile-app/android/app/src/main/assets/capacitor.config.json b/packages/mobile-app/android/app/src/main/assets/capacitor.config.json index bf313f5..7aa691d 100644 --- a/packages/mobile-app/android/app/src/main/assets/capacitor.config.json +++ b/packages/mobile-app/android/app/src/main/assets/capacitor.config.json @@ -3,5 +3,9 @@ "appName": "modos Explorer", "bundledWebRuntime": false, "npmClient": "npm", - "webDir": "www" + "webDir": "www", + "server": { + "url": "http://192.168.0.10:8100", + "cleartext": true + } } diff --git a/packages/mobile-app/android/app/src/main/res/layout/activity_main.xml b/packages/mobile-app/android/app/src/main/res/layout/activity_main.xml index 03c6eed..b5ad138 100644 --- a/packages/mobile-app/android/app/src/main/res/layout/activity_main.xml +++ b/packages/mobile-app/android/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - - + diff --git a/packages/mobile-app/android/build.gradle b/packages/mobile-app/android/build.gradle index 937411e..eb3487d 100644 --- a/packages/mobile-app/android/build.gradle +++ b/packages/mobile-app/android/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.2' + classpath 'com.android.tools.build:gradle:4.0.0' classpath 'com.google.gms:google-services:4.2.0' // NOTE: Do not place your application dependencies here; they belong diff --git a/packages/mobile-app/android/gradle.properties b/packages/mobile-app/android/gradle.properties index aac7c9b..9e6fce1 100644 --- a/packages/mobile-app/android/gradle.properties +++ b/packages/mobile-app/android/gradle.properties @@ -9,6 +9,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. diff --git a/packages/mobile-app/android/gradle/wrapper/gradle-wrapper.properties b/packages/mobile-app/android/gradle/wrapper/gradle-wrapper.properties index bf8d6ba..9f45452 100644 --- a/packages/mobile-app/android/gradle/wrapper/gradle-wrapper.properties +++ b/packages/mobile-app/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jan 30 13:14:22 CST 2018 +#Tue Dec 08 09:53:16 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/packages/mobile-app/angular.json b/packages/mobile-app/angular.json index 8d92fd8..a85732a 100644 --- a/packages/mobile-app/angular.json +++ b/packages/mobile-app/angular.json @@ -33,16 +33,20 @@ ], "styles": [ { - "input": "src/theme/variables.scss" + "input": "src/theme/variables.scss", + "inject": true }, { - "input": "src/global.scss" + "input": "src/global.scss", + "inject": true }, { - "input": "node_modules/@fortawesome/fontawesome-free/css/all.css" + "input": "node_modules/@fortawesome/fontawesome-free/css/all.css", + "inject": true } ], - "scripts": [] + "scripts": [], + "aot": true }, "configurations": { "production": { @@ -55,9 +59,7 @@ "optimization": true, "outputHashing": "all", "sourceMap": false, - "extractCss": true, "namedChunks": false, - "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, @@ -66,11 +68,21 @@ "type": "initial", "maximumWarning": "2mb", "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" } ] }, "ci": { - "progress": false + "progress": false, + "budgets": [ + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" + } + ] } } }, diff --git a/packages/mobile-app/capacitor.config.json b/packages/mobile-app/capacitor.config.json index bf313f5..7aa691d 100644 --- a/packages/mobile-app/capacitor.config.json +++ b/packages/mobile-app/capacitor.config.json @@ -3,5 +3,9 @@ "appName": "modos Explorer", "bundledWebRuntime": false, "npmClient": "npm", - "webDir": "www" + "webDir": "www", + "server": { + "url": "http://192.168.0.10:8100", + "cleartext": true + } } diff --git a/packages/mobile-app/e2e/tsconfig.json b/packages/mobile-app/e2e/tsconfig.json index 77d311e..d696d43 100644 --- a/packages/mobile-app/e2e/tsconfig.json +++ b/packages/mobile-app/e2e/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../out-tsc/app", "module": "commonjs", - "target": "es5", + "target": "es2018", "types": [ "jasmine", "jasminewd2", diff --git a/packages/mobile-app/package.json b/packages/mobile-app/package.json index 0caa650..5e98e80 100644 --- a/packages/mobile-app/package.json +++ b/packages/mobile-app/package.json @@ -16,14 +16,14 @@ }, "private": true, "dependencies": { - "@angular/animations": "8.2.14", - "@angular/common": "~8.2.14", - "@angular/compiler": "~8.2.14", - "@angular/core": "~8.2.14", - "@angular/forms": "~8.2.14", - "@angular/platform-browser": "~8.2.14", - "@angular/platform-browser-dynamic": "~8.2.14", - "@angular/router": "~8.2.14", + "@angular/animations": "11.0.3", + "@angular/common": "~11.0.3", + "@angular/compiler": "~11.0.3", + "@angular/core": "~11.0.3", + "@angular/forms": "~11.0.3", + "@angular/platform-browser": "~11.0.3", + "@angular/platform-browser-dynamic": "~11.0.3", + "@angular/router": "~11.0.3", "@capacitor/android": "^2.4.4", "@capacitor/core": "^1.5.3", "@fortawesome/fontawesome-free": "^5.15.1", @@ -38,42 +38,42 @@ "core-js": "^2.6.12", "leaflet": "^1.7.1", "rxjs": "~6.6.3", - "tslib": "^1.14.1", - "zone.js": "~0.9.1" + "tslib": "^2.0.0", + "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/architect": "~0.801.2", - "@angular-devkit/build-angular": "^0.803.24", - "@angular-devkit/core": "~8.1.2", - "@angular-devkit/schematics": "~8.1.2", - "@angular/cli": "~8.3.29", - "@angular/compiler-cli": "~8.2.14", - "@angular/language-service": "~8.2.14", + "@angular-devkit/build-angular": "~0.1100.3", + "@angular-devkit/core": "~11.0.3", + "@angular-devkit/schematics": "~11.0.3", + "@angular/cli": "~11.0.3", + "@angular/compiler-cli": "~11.0.3", + "@angular/language-service": "~11.0.3", "@capacitor/cli": "^1.5.3", "@ionic/angular-toolkit": "^3.0.0", "@ionic/cli": "^6.12.2", - "@types/jasmine": "~3.3.8", + "@types/jasmine": "~3.6.0", "@types/jasminewd2": "~2.0.3", "@types/leaflet": "^1.5.19", - "@types/node": "~8.9.4", - "codelyzer": "^5.0.0", + "@types/node": "^12.11.1", + "codelyzer": "^6.0.0", "cordova-plugin-device": "^2.0.2", "cordova-plugin-ionic-keyboard": "^2.2.0", "cordova-plugin-ionic-webview": "^4.1.3", "cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-statusbar": "^2.4.2", "cordova-plugin-whitelist": "^1.3.3", - "jasmine-core": "~3.4.0", - "jasmine-spec-reporter": "~4.2.1", - "karma": "^5.2.3", - "karma-chrome-launcher": "~2.2.0", - "karma-coverage-istanbul-reporter": "~2.0.1", - "karma-jasmine": "~2.0.1", - "karma-jasmine-html-reporter": "^1.4.0", - "protractor": "^7.0.0", + "jasmine-core": "~3.6.0", + "jasmine-spec-reporter": "~5.0.0", + "karma": "~5.0.0", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage-istanbul-reporter": "~3.0.2", + "karma-jasmine": "~4.0.0", + "karma-jasmine-html-reporter": "^1.5.0", + "protractor": "~7.0.0", "ts-node": "~7.0.0", - "tslint": "~5.15.0", - "typescript": "~3.5.3" + "tslint": "~6.1.0", + "typescript": "~4.0.5" }, "description": "An Ionic project", "cordova": { diff --git a/packages/mobile-app/src/app/app-routing.module.ts b/packages/mobile-app/src/app/app-routing.module.ts index 03e3603..93866c4 100644 --- a/packages/mobile-app/src/app/app-routing.module.ts +++ b/packages/mobile-app/src/app/app-routing.module.ts @@ -85,7 +85,7 @@ const routes: Routes = [ @NgModule({ imports: [ - RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }), + RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules, relativeLinkResolution: 'legacy' }), ], exports: [RouterModule], }) diff --git a/packages/mobile-app/src/app/app.component.spec.ts b/packages/mobile-app/src/app/app.component.spec.ts index 2bd6389..63fc4e1 100644 --- a/packages/mobile-app/src/app/app.component.spec.ts +++ b/packages/mobile-app/src/app/app.component.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { TestBed, async } from '@angular/core/testing'; +import { TestBed, waitForAsync } from '@angular/core/testing'; import { Platform } from '@ionic/angular'; import { SplashScreen } from '@ionic-native/splash-screen/ngx'; @@ -11,7 +11,7 @@ describe('AppComponent', () => { let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); platformReadySpy = Promise.resolve(); diff --git a/packages/mobile-app/src/app/contribution/feedback/feedback.page.spec.ts b/packages/mobile-app/src/app/contribution/feedback/feedback.page.spec.ts index 3ccc423..1a0ec7c 100644 --- a/packages/mobile-app/src/app/contribution/feedback/feedback.page.spec.ts +++ b/packages/mobile-app/src/app/contribution/feedback/feedback.page.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { FeedbackPage } from './feedback.page'; @@ -7,7 +7,7 @@ describe('FeedbackPage', () => { let component: FeedbackPage; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ FeedbackPage ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.html b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.html index 9da19cf..88c2b02 100644 --- a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.html +++ b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.html @@ -2,7 +2,7 @@ Récapitulatif - annuler + annuler diff --git a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.spec.ts b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.spec.ts index db49b38..f8816f5 100644 --- a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.spec.ts +++ b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { ObstacleSummaryPage } from './obstacle-summary.page'; @@ -7,7 +7,7 @@ describe('ObstacleSummaryPage', () => { let component: ObstacleSummaryPage; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ ObstacleSummaryPage ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts index aba2974..55e9f7f 100644 --- a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts +++ b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts @@ -39,7 +39,7 @@ export class ObstacleSummaryPage implements OnInit { public statusCode: StatusCode; constructor( - private param: NavParamsService, + public param: NavParamsService, private router: Router, private observation: ObservationsService, private alertCtrl: AlertController, diff --git a/packages/mobile-app/src/app/contribution/select-obstacle/select-obstacle.page.spec.ts b/packages/mobile-app/src/app/contribution/select-obstacle/select-obstacle.page.spec.ts index cc6d58f..f61f633 100644 --- a/packages/mobile-app/src/app/contribution/select-obstacle/select-obstacle.page.spec.ts +++ b/packages/mobile-app/src/app/contribution/select-obstacle/select-obstacle.page.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { SelectObstaclePage } from './select-obstacle.page'; @@ -7,7 +7,7 @@ describe('SelectObstaclePage', () => { let component: SelectObstaclePage; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ SelectObstaclePage ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.spec.ts b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.spec.ts index 3f6d254..f257353 100644 --- a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.spec.ts +++ b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { SetGlobalPositionPage } from './set-global-position.page'; @@ -7,7 +7,7 @@ describe('SetGlobalPositionPage', () => { let component: SetGlobalPositionPage; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ SetGlobalPositionPage ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.html b/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.html index 912613b..ebec8e7 100644 --- a/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.html +++ b/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.html @@ -1,4 +1,4 @@ diff --git a/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.spec.ts b/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.spec.ts index 0def03c..2815546 100644 --- a/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.spec.ts +++ b/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { TakePicturePage } from './take-picture.page'; @@ -7,7 +7,7 @@ describe('TakePicturePage', () => { let component: TakePicturePage; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ TakePicturePage ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/src/app/custom-components/camera/camera.component.spec.ts b/packages/mobile-app/src/app/custom-components/camera/camera.component.spec.ts index 17f8bef..fae4553 100644 --- a/packages/mobile-app/src/app/custom-components/camera/camera.component.spec.ts +++ b/packages/mobile-app/src/app/custom-components/camera/camera.component.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { CameraComponent } from './camera.component'; @@ -7,7 +7,7 @@ describe('CameraComponent', () => { let component: CameraComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ CameraComponent ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/src/app/custom-components/location/location.component.spec.ts b/packages/mobile-app/src/app/custom-components/location/location.component.spec.ts index 26caad1..6dad1c4 100644 --- a/packages/mobile-app/src/app/custom-components/location/location.component.spec.ts +++ b/packages/mobile-app/src/app/custom-components/location/location.component.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { LocationComponent } from './location.component'; @@ -7,7 +7,7 @@ describe('LocationComponent', () => { let component: LocationComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ LocationComponent ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/src/app/custom-components/map-modal/map-modal.component.spec.ts b/packages/mobile-app/src/app/custom-components/map-modal/map-modal.component.spec.ts index c8b0bdc..5a8a2d5 100644 --- a/packages/mobile-app/src/app/custom-components/map-modal/map-modal.component.spec.ts +++ b/packages/mobile-app/src/app/custom-components/map-modal/map-modal.component.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { MapModalComponent } from './map-modal.component'; @@ -7,7 +7,7 @@ describe('MapModalComponent', () => { let component: MapModalComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ MapModalComponent ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/src/app/home/home.page.spec.ts b/packages/mobile-app/src/app/home/home.page.spec.ts index 68caa9a..d628561 100644 --- a/packages/mobile-app/src/app/home/home.page.spec.ts +++ b/packages/mobile-app/src/app/home/home.page.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { IonicModule } from '@ionic/angular'; import { HomePage } from './home.page'; @@ -7,7 +7,7 @@ describe('HomePage', () => { let component: HomePage; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ HomePage ], imports: [IonicModule.forRoot()] diff --git a/packages/mobile-app/src/app/login/login.page.spec.ts b/packages/mobile-app/src/app/login/login.page.spec.ts index e6ff074..c2859c9 100644 --- a/packages/mobile-app/src/app/login/login.page.spec.ts +++ b/packages/mobile-app/src/app/login/login.page.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { LoginPage } from './login.page'; @@ -7,7 +7,7 @@ describe('LoginPage', () => { let component: LoginPage; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ LoginPage ], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/packages/mobile-app/tsconfig.app.json b/packages/mobile-app/tsconfig.app.json index 31f8397..f712455 100644 --- a/packages/mobile-app/tsconfig.app.json +++ b/packages/mobile-app/tsconfig.app.json @@ -5,10 +5,11 @@ "types": [] }, "include": [ - "src/**/*.ts" + "src/**/*.d.ts" ], - "exclude": [ - "src/test.ts", - "src/**/*.spec.ts" + "files": [ + "src/main.ts", + "src/zone-flags.ts", + "src/polyfills.ts" ] } diff --git a/packages/mobile-app/tsconfig.json b/packages/mobile-app/tsconfig.json index 0af3f32..c531647 100644 --- a/packages/mobile-app/tsconfig.json +++ b/packages/mobile-app/tsconfig.json @@ -5,7 +5,7 @@ "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, - "module": "esnext", + "module": "es2020", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, diff --git a/packages/mobile-app/tslint.json b/packages/mobile-app/tslint.json index 172a40e..4ba30f6 100644 --- a/packages/mobile-app/tslint.json +++ b/packages/mobile-app/tslint.json @@ -4,8 +4,15 @@ "codelyzer" ], "rules": { + "align": { + "options": [ + "parameters", + "statements" + ] + }, "array-type": false, "arrow-parens": false, + "arrow-return-shorthand": true, "deprecation": { "severity": "warn" }, @@ -13,13 +20,21 @@ true, "rxjs/Rx" ], + "curly": true, "interface-name": false, "max-classes-per-file": false, "max-line-length": [ true, 140 ], + "eofline": true, "member-access": false, + "import-spacing": true, + "indent": { + "options": [ + "spaces" + ] + }, "member-ordering": [ true, { @@ -48,7 +63,6 @@ "no-non-null-assertion": true, "no-redundant-jsdoc": true, "no-switch-case-fall-through": true, - "no-use-before-declare": true, "no-var-requires": false, "object-literal-key-quotes": [ true, @@ -69,8 +83,44 @@ "use-lifecycle-interface": true, "use-pipe-transform-interface": true, "one-variable-per-declaration": false, - "component-class-suffix": [true, "Page", "Component"], + "component-class-suffix": [ + true, + "Page", + "Component" + ], + "semicolon": { + "options": [ + "always" + ] + }, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, "directive-class-suffix": true, + "typedef-whitespace": { + "options": [ + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } + ] + }, "directive-selector": [ true, "attribute", @@ -83,6 +133,23 @@ "app", "page", "kebab-case" - ] + ], + "variable-name": { + "options": [ + "ban-keywords", + "check-format", + "allow-pascal-case" + ] + }, + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast" + ] + } } } From f2a531a16045bb1eb9782bea379417b5ccf6a686 Mon Sep 17 00:00:00 2001 From: Arthur Verdon Date: Tue, 8 Dec 2020 11:48:23 +0100 Subject: [PATCH 4/7] add leaflet and validate position page --- .../obstacle-summary/obstacle-summary.page.ts | 62 +-------- .../set-global-position.page.html | 30 +++-- .../set-global-position.page.ts | 122 +++++++++++++++++- .../src/app/services/nav-params.service.ts | 11 +- packages/mobile-app/src/global.scss | 3 + 5 files changed, 158 insertions(+), 70 deletions(-) diff --git a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts index 55e9f7f..323183d 100644 --- a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts +++ b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts @@ -49,16 +49,12 @@ export class ObstacleSummaryPage implements OnInit { ngOnInit() {} async ionViewWillEnter() { - this.isSaveBtnDisabled = true; - try { - await this.autoLocate(); - this.isSaveBtnDisabled = false; - if (this.param.obstacle === 'other') { - this.isCommentsMandatory = true; - this.isSaveBtnDisabled = true; - } - } catch (err) { - this.showErrorLocalisationAlert(); + console.log(this.param.location); + + this.isSaveBtnDisabled = false; + if (this.param.obstacle === 'other') { + this.isCommentsMandatory = true; + this.isSaveBtnDisabled = true; } } @@ -72,7 +68,7 @@ export class ObstacleSummaryPage implements OnInit { this.image.imageData = this.param.image; this.newObservation.description = this.description; this.newObservation.image = this.image; - this.newObservation.location = this.location; + this.newObservation.location = this.param.location; this.isSaveBtnDisabled = true; @@ -146,50 +142,6 @@ export class ObstacleSummaryPage implements OnInit { this.showCancelWarning(); } - /** - * Will locate the user with high accuracy - */ - private async autoLocate() { - if (!Capacitor.isPluginAvailable('Geolocation')) { - this.showErrorLocalisationAlert(); - return; - } - - // For more information about the options: - // https://github.com/apache/cordova-plugin-geolocation#geolocationoptions - const position = await Plugins.Geolocation.getCurrentPosition({ - maximumAge: 1000, - timeout: 5000, - enableHighAccuracy: true, - }); - - this.location.lat = position.coords.latitude; - this.location.lng = position.coords.longitude; - } - - private showErrorLocalisationAlert() { - this.alertCtrl - .create({ - header: `Impossible d'obtenir la localisation`, - message: `Sans localisation, il est impossible d'effectuer une observation.`, - buttons: [ - { - text: `Retour à l'accueil`, - handler: () => this.router.navigate(['/home']), - }, - ], - backdropDismiss: false, - }) - .then((alertEl) => { - alertEl.present(); - alertEl - .onDidDismiss() - .then(() => this.router.navigate(['/home'])) - .catch((err) => {}); - }) - .catch((err) => {}); - } - private async showCancelWarning() { const alert = await this.alertCtrl.create({ header: `Annuler`, diff --git a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.html b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.html index 884201d..cba191c 100644 --- a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.html +++ b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.html @@ -8,19 +8,29 @@ - - + + + +
-
- - - - - - - + + + + + + + + + + + + diff --git a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.ts b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.ts index 249ffc3..b00921a 100644 --- a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.ts +++ b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.ts @@ -1,6 +1,20 @@ import { Component, OnInit } from '@angular/core'; import { Capacitor, Plugins } from '@capacitor/core'; import { Location } from '../../models/location.model'; +import { Map, tileLayer, marker } from 'leaflet'; +import { AlertController, LoadingController } from '@ionic/angular'; + +// resolve bug with leaflet not loading the icon +import 'leaflet/dist/images/marker-shadow.png'; +import 'leaflet/dist/images/marker-icon-2x.png'; +import { Router } from '@angular/router'; +import { NavParamsService } from 'src/app/services/nav-params.service'; + +const DEFAULT_MAP_ZOOM = 16; + +// following position is ~Yverdon-Les-Bains +const DEFAULT_LAT = 46.7785; +const DEFAULT_LNG = 6.6412; @Component({ selector: 'app-set-global-position', @@ -8,14 +22,49 @@ import { Location } from '../../models/location.model'; styleUrls: ['./set-global-position.page.scss'], }) export class SetGlobalPositionPage implements OnInit { - private location = new Location(); + public map: Map; + public markerPosition: any; + public location = new Location(); - constructor() {} + constructor( + public loadingController: LoadingController, + private alertCtrl: AlertController, + private param: NavParamsService, + private router: Router + ) {} async ngOnInit() {} async ionViewWillEnter() { - await this.autoLocate(); + // init map and base coordinate + this.location.lat = DEFAULT_LAT; + this.location.lng = DEFAULT_LNG; + this.loadLeafletMap(); + + await this.refreshMapPosition(); + } + + private showErrorLocalisationAlert() { + this.alertCtrl + .create({ + header: `Impossible d'obtenir la localisation`, + message: `Sans localisation, il est impossible d'effectuer une observation.`, + buttons: [ + { + text: `Retour à l'accueil`, + handler: () => this.router.navigate(['/home']), + }, + ], + backdropDismiss: false, + }) + .then((alertEl) => { + alertEl.present(); + alertEl + .onDidDismiss() + .then(() => this.router.navigate(['/home'])) + .catch((err) => {}); + }) + .catch((err) => {}); } /** @@ -23,7 +72,7 @@ export class SetGlobalPositionPage implements OnInit { */ private async autoLocate() { if (!Capacitor.isPluginAvailable('Geolocation')) { - console.error('error GPS'); + this.showErrorLocalisationAlert(); return; } @@ -38,4 +87,69 @@ export class SetGlobalPositionPage implements OnInit { this.location.lat = position.coords.latitude; this.location.lng = position.coords.longitude; } + + /** + * Initialize a Leaflet map in the div with ID 'map' + */ + private loadLeafletMap() { + this.map = new Map('map').setView( + [this.location.lat, this.location.lng], + DEFAULT_MAP_ZOOM + ); + tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: + 'Map data © OpenStreetMap contributors,CC-BY-SA', + }).addTo(this.map); + } + + /** + * Refresh the position of the person on the map + */ + private refreshMarkerPos() { + if (this.markerPosition) { + this.map.removeLayer(this.markerPosition); + } + + this.markerPosition = marker([this.location.lat, this.location.lng]).addTo( + this.map + ); + } + + /** + * Refresh the map position and the marker of the person + */ + private async refreshMapPosition() { + const loading = await this.loadingController.create({ + message: 'Chargement des coordonnées GPS', + }); + await loading.present(); + + try { + await this.autoLocate(); + this.refreshMarkerPos(); + this.map.setView( + [this.location.lat, this.location.lng], + DEFAULT_MAP_ZOOM + ); + } catch (err) { + alert(err); + } + + await loading.dismiss(); + } + + /** + * + */ + public async getLocalisation() { + await this.refreshMapPosition(); + } + + /** + * goToSummary + */ + public goToSummary() { + this.param.location = this.location; + this.router.navigate(['/contribution/obstacle-summary']); + } } diff --git a/packages/mobile-app/src/app/services/nav-params.service.ts b/packages/mobile-app/src/app/services/nav-params.service.ts index cb39830..500f2b1 100644 --- a/packages/mobile-app/src/app/services/nav-params.service.ts +++ b/packages/mobile-app/src/app/services/nav-params.service.ts @@ -1,12 +1,14 @@ import { Injectable } from '@angular/core'; import { Image } from '../models/image.model'; +import { Location } from '../models/location.model'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class NavParamsService { private _obstacle: string; private _image: string; + private _location: Location; set obstacle(o: string) { this._obstacle = o; @@ -21,4 +23,11 @@ export class NavParamsService { get image(): string { return this._image; } + + set location(i: Location) { + this._location = i; + } + get location(): Location { + return this._location; + } } diff --git a/packages/mobile-app/src/global.scss b/packages/mobile-app/src/global.scss index 19302e8..a1e4595 100644 --- a/packages/mobile-app/src/global.scss +++ b/packages/mobile-app/src/global.scss @@ -28,6 +28,9 @@ @import "~@ionic/angular/css/text-transformation.css"; @import "~@ionic/angular/css/flex-utils.css"; +/* Leaflet */ +@import "~leaflet/dist/leaflet.css"; + /* Fonts */ @import url("https://fonts.googleapis.com/css?family=Roboto&display=swap"); From 14db2a9d16a7e651e49fb0f83a56acf6e50fc388 Mon Sep 17 00:00:00 2001 From: Arthur Verdon Date: Tue, 8 Dec 2020 11:56:20 +0100 Subject: [PATCH 5/7] remove useless test file --- .../app/src/main/assets/capacitor.config.json | 6 +-- packages/mobile-app/capacitor.config.json | 6 +-- packages/mobile-app/package.json | 1 + .../mobile-app/src/app/app.component.spec.ts | 47 ------------------- .../feedback/feedback.page.spec.ts | 27 ----------- .../obstacle-summary.page.spec.ts | 27 ----------- .../obstacle-summary/obstacle-summary.page.ts | 2 - .../select-obstacle.page.spec.ts | 27 ----------- .../set-global-position.page.spec.ts | 27 ----------- .../take-picture/take-picture.page.spec.ts | 27 ----------- .../camera/camera.component.spec.ts | 27 ----------- .../location/location.component.spec.ts | 27 ----------- .../map-modal/map-modal.component.spec.ts | 27 ----------- .../mobile-app/src/app/home/home.page.spec.ts | 24 ---------- .../src/app/login/login.page.spec.ts | 27 ----------- 15 files changed, 3 insertions(+), 326 deletions(-) delete mode 100644 packages/mobile-app/src/app/app.component.spec.ts delete mode 100644 packages/mobile-app/src/app/contribution/feedback/feedback.page.spec.ts delete mode 100644 packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.spec.ts delete mode 100644 packages/mobile-app/src/app/contribution/select-obstacle/select-obstacle.page.spec.ts delete mode 100644 packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.spec.ts delete mode 100644 packages/mobile-app/src/app/contribution/take-picture/take-picture.page.spec.ts delete mode 100644 packages/mobile-app/src/app/custom-components/camera/camera.component.spec.ts delete mode 100644 packages/mobile-app/src/app/custom-components/location/location.component.spec.ts delete mode 100644 packages/mobile-app/src/app/custom-components/map-modal/map-modal.component.spec.ts delete mode 100644 packages/mobile-app/src/app/home/home.page.spec.ts delete mode 100644 packages/mobile-app/src/app/login/login.page.spec.ts diff --git a/packages/mobile-app/android/app/src/main/assets/capacitor.config.json b/packages/mobile-app/android/app/src/main/assets/capacitor.config.json index 7aa691d..bf313f5 100644 --- a/packages/mobile-app/android/app/src/main/assets/capacitor.config.json +++ b/packages/mobile-app/android/app/src/main/assets/capacitor.config.json @@ -3,9 +3,5 @@ "appName": "modos Explorer", "bundledWebRuntime": false, "npmClient": "npm", - "webDir": "www", - "server": { - "url": "http://192.168.0.10:8100", - "cleartext": true - } + "webDir": "www" } diff --git a/packages/mobile-app/capacitor.config.json b/packages/mobile-app/capacitor.config.json index 7aa691d..bf313f5 100644 --- a/packages/mobile-app/capacitor.config.json +++ b/packages/mobile-app/capacitor.config.json @@ -3,9 +3,5 @@ "appName": "modos Explorer", "bundledWebRuntime": false, "npmClient": "npm", - "webDir": "www", - "server": { - "url": "http://192.168.0.10:8100", - "cleartext": true - } + "webDir": "www" } diff --git a/packages/mobile-app/package.json b/packages/mobile-app/package.json index 5e98e80..8f77fde 100644 --- a/packages/mobile-app/package.json +++ b/packages/mobile-app/package.json @@ -8,6 +8,7 @@ "start": "ng serve", "build": "ng build", "build:android": "npx cap copy && npx cap update && npx cap open android", + "deploy:android": "npm run build && npm run build:android", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", diff --git a/packages/mobile-app/src/app/app.component.spec.ts b/packages/mobile-app/src/app/app.component.spec.ts deleted file mode 100644 index 63fc4e1..0000000 --- a/packages/mobile-app/src/app/app.component.spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { TestBed, waitForAsync } from '@angular/core/testing'; - -import { Platform } from '@ionic/angular'; -import { SplashScreen } from '@ionic-native/splash-screen/ngx'; -import { StatusBar } from '@ionic-native/status-bar/ngx'; - -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - - let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; - - beforeEach(waitForAsync(() => { - statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); - splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); - platformReadySpy = Promise.resolve(); - platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); - - TestBed.configureTestingModule({ - declarations: [AppComponent], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - providers: [ - { provide: StatusBar, useValue: statusBarSpy }, - { provide: SplashScreen, useValue: splashScreenSpy }, - { provide: Platform, useValue: platformSpy }, - ], - }).compileComponents(); - })); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app).toBeTruthy(); - }); - - it('should initialize the app', async () => { - TestBed.createComponent(AppComponent); - expect(platformSpy.ready).toHaveBeenCalled(); - await platformReadySpy; - expect(statusBarSpy.styleDefault).toHaveBeenCalled(); - expect(splashScreenSpy.hide).toHaveBeenCalled(); - }); - - // TODO: add more tests! - -}); diff --git a/packages/mobile-app/src/app/contribution/feedback/feedback.page.spec.ts b/packages/mobile-app/src/app/contribution/feedback/feedback.page.spec.ts deleted file mode 100644 index 1a0ec7c..0000000 --- a/packages/mobile-app/src/app/contribution/feedback/feedback.page.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { FeedbackPage } from './feedback.page'; - -describe('FeedbackPage', () => { - let component: FeedbackPage; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ FeedbackPage ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FeedbackPage); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.spec.ts b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.spec.ts deleted file mode 100644 index f8816f5..0000000 --- a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { ObstacleSummaryPage } from './obstacle-summary.page'; - -describe('ObstacleSummaryPage', () => { - let component: ObstacleSummaryPage; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ ObstacleSummaryPage ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ObstacleSummaryPage); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts index 323183d..2badd21 100644 --- a/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts +++ b/packages/mobile-app/src/app/contribution/obstacle-summary/obstacle-summary.page.ts @@ -49,8 +49,6 @@ export class ObstacleSummaryPage implements OnInit { ngOnInit() {} async ionViewWillEnter() { - console.log(this.param.location); - this.isSaveBtnDisabled = false; if (this.param.obstacle === 'other') { this.isCommentsMandatory = true; diff --git a/packages/mobile-app/src/app/contribution/select-obstacle/select-obstacle.page.spec.ts b/packages/mobile-app/src/app/contribution/select-obstacle/select-obstacle.page.spec.ts deleted file mode 100644 index f61f633..0000000 --- a/packages/mobile-app/src/app/contribution/select-obstacle/select-obstacle.page.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { SelectObstaclePage } from './select-obstacle.page'; - -describe('SelectObstaclePage', () => { - let component: SelectObstaclePage; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ SelectObstaclePage ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(SelectObstaclePage); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.spec.ts b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.spec.ts deleted file mode 100644 index f257353..0000000 --- a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { SetGlobalPositionPage } from './set-global-position.page'; - -describe('SetGlobalPositionPage', () => { - let component: SetGlobalPositionPage; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ SetGlobalPositionPage ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(SetGlobalPositionPage); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.spec.ts b/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.spec.ts deleted file mode 100644 index 2815546..0000000 --- a/packages/mobile-app/src/app/contribution/take-picture/take-picture.page.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { TakePicturePage } from './take-picture.page'; - -describe('TakePicturePage', () => { - let component: TakePicturePage; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ TakePicturePage ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(TakePicturePage); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/custom-components/camera/camera.component.spec.ts b/packages/mobile-app/src/app/custom-components/camera/camera.component.spec.ts deleted file mode 100644 index fae4553..0000000 --- a/packages/mobile-app/src/app/custom-components/camera/camera.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { CameraComponent } from './camera.component'; - -describe('CameraComponent', () => { - let component: CameraComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ CameraComponent ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CameraComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/custom-components/location/location.component.spec.ts b/packages/mobile-app/src/app/custom-components/location/location.component.spec.ts deleted file mode 100644 index 6dad1c4..0000000 --- a/packages/mobile-app/src/app/custom-components/location/location.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { LocationComponent } from './location.component'; - -describe('LocationComponent', () => { - let component: LocationComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ LocationComponent ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(LocationComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/custom-components/map-modal/map-modal.component.spec.ts b/packages/mobile-app/src/app/custom-components/map-modal/map-modal.component.spec.ts deleted file mode 100644 index 5a8a2d5..0000000 --- a/packages/mobile-app/src/app/custom-components/map-modal/map-modal.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { MapModalComponent } from './map-modal.component'; - -describe('MapModalComponent', () => { - let component: MapModalComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ MapModalComponent ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MapModalComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/home/home.page.spec.ts b/packages/mobile-app/src/app/home/home.page.spec.ts deleted file mode 100644 index d628561..0000000 --- a/packages/mobile-app/src/app/home/home.page.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; -import { IonicModule } from '@ionic/angular'; - -import { HomePage } from './home.page'; - -describe('HomePage', () => { - let component: HomePage; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ HomePage ], - imports: [IonicModule.forRoot()] - }).compileComponents(); - - fixture = TestBed.createComponent(HomePage); - component = fixture.componentInstance; - fixture.detectChanges(); - })); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/packages/mobile-app/src/app/login/login.page.spec.ts b/packages/mobile-app/src/app/login/login.page.spec.ts deleted file mode 100644 index c2859c9..0000000 --- a/packages/mobile-app/src/app/login/login.page.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { LoginPage } from './login.page'; - -describe('LoginPage', () => { - let component: LoginPage; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ LoginPage ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(LoginPage); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); From ab24fd64577c110724f7648ee8ace15eaf3d7924 Mon Sep 17 00:00:00 2001 From: Arthur Verdon Date: Thu, 10 Dec 2020 09:34:56 +0100 Subject: [PATCH 6/7] added a satellite layer --- .../app/src/main/assets/capacitor.config.json | 6 +++- packages/mobile-app/capacitor.config.json | 6 +++- .../set-global-position.page.html | 6 +--- .../set-global-position.page.ts | 34 +++++++++++++++---- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/packages/mobile-app/android/app/src/main/assets/capacitor.config.json b/packages/mobile-app/android/app/src/main/assets/capacitor.config.json index bf313f5..7aa691d 100644 --- a/packages/mobile-app/android/app/src/main/assets/capacitor.config.json +++ b/packages/mobile-app/android/app/src/main/assets/capacitor.config.json @@ -3,5 +3,9 @@ "appName": "modos Explorer", "bundledWebRuntime": false, "npmClient": "npm", - "webDir": "www" + "webDir": "www", + "server": { + "url": "http://192.168.0.10:8100", + "cleartext": true + } } diff --git a/packages/mobile-app/capacitor.config.json b/packages/mobile-app/capacitor.config.json index bf313f5..7aa691d 100644 --- a/packages/mobile-app/capacitor.config.json +++ b/packages/mobile-app/capacitor.config.json @@ -3,5 +3,9 @@ "appName": "modos Explorer", "bundledWebRuntime": false, "npmClient": "npm", - "webDir": "www" + "webDir": "www", + "server": { + "url": "http://192.168.0.10:8100", + "cleartext": true + } } diff --git a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.html b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.html index cba191c..dbc9ec1 100644 --- a/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.html +++ b/packages/mobile-app/src/app/contribution/set-global-position/set-global-position.page.html @@ -9,11 +9,7 @@ - +
OpenStreetMap contributors,CC-BY-SA', + } + ); + const ESRI_IMAGERY_LAYER = tileLayer( + 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', + { + attribution: + 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community', + } + ); + this.map = new Map('map').setView( [this.location.lat, this.location.lng], DEFAULT_MAP_ZOOM ); - tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: - 'Map data © OpenStreetMap contributors,CC-BY-SA', - }).addTo(this.map); + + ESRI_IMAGERY_LAYER.addTo(this.map); + + new Control.Layers( + { + Plan: OPENSTREETMAP_LAYER, + Satellite: ESRI_IMAGERY_LAYER, + }, + {}, + { collapsed: false } + ).addTo(this.map); } /** From cd87dcae79ff2c781612dfbfdba5ef85fc955803 Mon Sep 17 00:00:00 2001 From: Arthur Verdon Date: Thu, 10 Dec 2020 09:40:01 +0100 Subject: [PATCH 7/7] deploy v0.1.3 --- .../android/app/src/main/assets/capacitor.config.json | 6 +----- packages/mobile-app/capacitor.config.json | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/mobile-app/android/app/src/main/assets/capacitor.config.json b/packages/mobile-app/android/app/src/main/assets/capacitor.config.json index 7aa691d..bf313f5 100644 --- a/packages/mobile-app/android/app/src/main/assets/capacitor.config.json +++ b/packages/mobile-app/android/app/src/main/assets/capacitor.config.json @@ -3,9 +3,5 @@ "appName": "modos Explorer", "bundledWebRuntime": false, "npmClient": "npm", - "webDir": "www", - "server": { - "url": "http://192.168.0.10:8100", - "cleartext": true - } + "webDir": "www" } diff --git a/packages/mobile-app/capacitor.config.json b/packages/mobile-app/capacitor.config.json index 7aa691d..bf313f5 100644 --- a/packages/mobile-app/capacitor.config.json +++ b/packages/mobile-app/capacitor.config.json @@ -3,9 +3,5 @@ "appName": "modos Explorer", "bundledWebRuntime": false, "npmClient": "npm", - "webDir": "www", - "server": { - "url": "http://192.168.0.10:8100", - "cleartext": true - } + "webDir": "www" }