diff --git a/Mohem/package.json b/Mohem/package.json index 0c42ecb6..a43cfecc 100644 --- a/Mohem/package.json +++ b/Mohem/package.json @@ -26,7 +26,6 @@ "@ionic-native/app-rate": "^5.5.1", "@ionic-native/background-geolocation": "^5.4.0", "@ionic-native/badge": "^5.4.0", - "@ionic-native/barcode-scanner": "^5.4.0", "@ionic-native/ble": "^5.4.0", "@ionic-native/call-number": "^5.4.0", "@ionic-native/camera": "^5.4.0", @@ -35,13 +34,11 @@ "@ionic-native/diagnostic": "^5.4.0", "@ionic-native/fingerprint-aio": "^5.4.0", "@ionic-native/globalization": "^5.4.0", - "@ionic-native/health": "^5.4.0", "@ionic-native/in-app-browser": "^5.5.1", "@ionic-native/keyboard": "^5.4.0", "@ionic-native/launch-navigator": "^5.4.0", "@ionic-native/local-notifications": "^5.4.0", "@ionic-native/native-storage": "^5.4.0", - "@ionic-native/push": "^5.4.0", "@ionic-native/sms": "^5.8.0", "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/sqlite": "^5.5.1", @@ -54,7 +51,6 @@ "call-number": "^1.0.1", "chart.js": "^2.8.0", "cordova-android": "7.1.4", - "cordova-android-support-gradle-release": "2.1.0", "cordova-browser": "5.0.4", "cordova-ios": "4.5.5", "cordova-opentok-android-permissions": "1.0.1", @@ -71,12 +67,10 @@ "cordova-plugin-dialogs": "2.0.1", "cordova-plugin-fingerprint-aio": "^1.7.0", "cordova-plugin-globalization": "^1.11.0", - "cordova-plugin-health": "1.1.3", "cordova-plugin-inappbrowser": "3.0.0", "cordova-plugin-ionic-keyboard": "^2.1.3", "cordova-plugin-ionic-webview": "^3.1.2", "cordova-plugin-local-notification": "^0.9.0-beta.2", - "cordova-plugin-mauron85-background-geolocation": "3.0.0-alpha.50", "cordova-plugin-nativestorage": "^2.3.2", "cordova-plugin-sms-receive": "^1.0.2", "cordova-plugin-splashscreen": "^5.0.2", @@ -85,14 +79,11 @@ "cordova-plugin-whitelist": "^1.3.3", "cordova-sms-plugin": "1.0.0", "cordova-sqlite-storage": "^3.2.0", - "cordova-support-google-services": "^1.1.0", "cordova.plugins.diagnostic": "^4.0.12", "core-js": "^2.5.4", "date-fns": "^1.30.1", "mx.ferreyra.callnumber": "0.0.2", - "phonegap-plugin-barcodescanner": "^8.0.1", "phonegap-plugin-multidex": "^1.0.0", - "phonegap-plugin-push": "2.2.3", "primeicons": "^1.0.0", "primeng": "^7.1.2", "run": "1.4.0", @@ -136,18 +127,6 @@ "cordova-plugin-ionic-webview": { "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" }, - "cordova-plugin-mauron85-background-geolocation": { - "GOOGLE_PLAY_SERVICES_VERSION": "16.0.0", - "ANDROID_SUPPORT_LIBRARY_VERSION": "26+", - "ICON": "@mipmap/icon", - "SMALL_ICON": "@mipmap/icon", - "ACCOUNT_NAME": "@string/app_name", - "ACCOUNT_LABEL": "@string/app_name", - "ACCOUNT_TYPE": "$PACKAGE_NAME.account", - "CONTENT_AUTHORITY": "$PACKAGE_NAME", - "ALWAYS_USAGE_DESCRIPTION": "This app always requires location tracking", - "MOTION_USAGE_DESCRIPTION": "This app requires motion detection" - }, "cordova-sqlite-storage": {}, "cordova-plugin-nativestorage": {}, "cordova-plugin-ble-central": {}, @@ -165,28 +144,11 @@ "cordova.plugins.diagnostic": { "ANDROID_SUPPORT_VERSION": "28.+" }, - "phonegap-plugin-barcodescanner": { - "ANDROID_SUPPORT_V4_VERSION": "27.+" - }, "cordova-plugin-camera": {}, "cordova-plugin-ionic-keyboard": {}, - "cordova-android-support-gradle-release": { - "ANDROID_SUPPORT_VERSION": "27.+" - }, "cordova-opentok-android-permissions": {}, - "cordova-plugin-health": { - "HEALTH_READ_PERMISSION": "App needs read access to read heart rate", - "HEALTH_WRITE_PERMISSION": "App needs write access for heart rate", - "GMS_VERSION": "16.0.1" - }, "cordova-plugin-appavailability": {}, "call-number": {}, - "cordova-support-google-services": {}, - "phonegap-plugin-push": { - "GOOGLE_PLAY_SERVICES_VERSION": "16.0.0", - "FCM_VERSION": "15.0.0", - "ANDROID_SUPPORT_V13_VERSION": "27.+" - }, "cordova-plugin-apprate": {}, "cordova-plugin-inappbrowser": {}, "cordova-sms-plugin": {} @@ -197,4 +159,4 @@ "android" ] } -} +} \ No newline at end of file diff --git a/Mohem/src/app/authentication/login/login.component.ts b/Mohem/src/app/authentication/login/login.component.ts index c5da9e6f..6c9ee3bf 100644 --- a/Mohem/src/app/authentication/login/login.component.ts +++ b/Mohem/src/app/authentication/login/login.component.ts @@ -1,397 +1,400 @@ -import { Component, OnInit, ViewChild, ChangeDetectorRef, NgZone, OnDestroy } from '@angular/core'; -import { CommonService } from 'src/app/hmg-common/services/common/common.service'; -import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; -import { Router } from '@angular/router'; -import { AlertController } from '@ionic/angular'; -import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; -import { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request'; -import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response'; -import { CheckActivationCodeResponse } from 'src/app/hmg-common/services/authentication/models/check-activation-code.response'; -import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.service'; -import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user'; -import { PATIENT_TYPE } from 'src/app/hmg-common/services/models/patient.type'; -import { FingerprintAIO } from '@ionic-native/fingerprint-aio/ngx'; -import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request'; -import { GetLoginInfoResponse } from 'src/app/hmg-common/services/authentication/models/get-login-info.response'; -import { Device } from '@ionic-native/device/ngx'; -import { SplashScreen } from '@ionic-native/splash-screen/ngx'; -import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; -import { LoginModel } from '../models/LoginModel'; -import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request'; +import { + Component, + OnInit, + ViewChild, + ChangeDetectorRef, + NgZone, + OnDestroy +} from "@angular/core"; +import { CommonService } from "src/app/hmg-common/services/common/common.service"; +import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; +import { Router } from "@angular/router"; +import { AlertController } from "@ionic/angular"; +import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; +import { CheckUserAuthenticationRequest } from "src/app/hmg-common/services/authentication/models/check-user-auth.request"; +import { CheckUserAuthenticationResponse } from "src/app/hmg-common/services/authentication/models/check-user-auth.response"; +import { CheckActivationCodeResponse } from "src/app/hmg-common/services/authentication/models/check-activation-code.response"; +import { SmsReaderService } from "src/app/hmg-common/services/sms/sms-reader.service"; +import { AuthenticatedUser } from "src/app/hmg-common/services/authentication/models/authenticated-user"; +import { PATIENT_TYPE } from "src/app/hmg-common/services/models/patient.type"; +import { FingerprintAIO } from "@ionic-native/fingerprint-aio/ngx"; +import { GetLoginInfoRequest } from "src/app/hmg-common/services/authentication/models/get-login-info.request"; +import { GetLoginInfoResponse } from "src/app/hmg-common/services/authentication/models/get-login-info.response"; +import { Device } from "@ionic-native/device/ngx"; +import { SplashScreen } from "@ionic-native/splash-screen/ngx"; +import { SharedDataService } from "src/app/hmg-common/services/shared-data-service/shared-data.service"; +import { LoginModel } from "../models/LoginModel"; +import { LoginRequest } from "src/app/hmg-common/services/authentication/models/login.request"; @Component({ - selector: 'login', - templateUrl: './login.component.html', - styleUrls: ['./login.component.scss'] + selector: "login", + templateUrl: "./login.component.html", + styleUrls: ["./login.component.scss"] }) - export class LoginComponent implements OnInit, OnDestroy { - appLang:number=1; - isExpired:boolean =false; - isSupportAr:boolean=false; - isAppleStore:boolean=false; - memberLogin: any = {}; - private password: string; - private language: string; - private username : string; - private currentLang : any =1; - private patientOutSA: boolean; - private loginTokenID: string; - private isMobileFingerPrint: boolean; - private FingerPrintPatientIdentificationID: string; - private loginData = new LoginModel(); - constructor( - public cs: CommonService, - public authService: AuthenticationService, - public router: Router, - public alertController: AlertController, - public ts: TranslatorService, - public smsService: SmsReaderService, - private faio: FingerprintAIO, - public ngZone: NgZone, - public device: Device, - public splash: SplashScreen, - public sharedData: SharedDataService - ) { - } - - ngOnInit() { - - } - - ngOnDestroy(): void { - this.backClicked(); - } - public changeLanguage(){ - this.ts.switchLanguage(); - if(TranslatorService.CURRENT_LANGUAGE == TranslatorService.EN) - { - this.language = "US"; - } - else{ - this.language = "AR"; - } - this.currentLang = TranslatorService.getCurrentLanguageCode(); - - } - // private checkIfLoggedInBefore() { - // this.cs.startLoading(); - // // check if user logged in before - // this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => { - // if (user) { - // this.startBiometricLogin(user); - // } else { - // this.hideSplashScreen(true); - // } - // }); - // } - private forgetPasswordPage(){ - this.cs.openUserForgot(); + appLang: number = 1; + isExpired: boolean = false; + isSupportAr: boolean = false; + isAppleStore: boolean = false; + memberLogin: any = {}; + private password: string; + private language: string; + private username: string; + private currentLang: any = 1; + private patientOutSA: boolean; + private loginTokenID: string; + private isMobileFingerPrint: boolean; + private FingerPrintPatientIdentificationID: string; + private loginData = new LoginModel(); + constructor( + public cs: CommonService, + public authService: AuthenticationService, + public router: Router, + public alertController: AlertController, + public ts: TranslatorService, + public smsService: SmsReaderService, + private faio: FingerprintAIO, + public ngZone: NgZone, + public device: Device, + public splash: SplashScreen, + public sharedData: SharedDataService + ) {} + + ngOnInit() {} + + ngOnDestroy(): void { + this.backClicked(); + } + public changeLanguage() { + this.ts.switchLanguage(); + if (TranslatorService.CURRENT_LANGUAGE == TranslatorService.EN) { + this.language = "US"; + } else { + this.language = "AR"; } - private hideSplashScreen(stopLoading = false) { - // this.splash.hide(); - if (stopLoading) { - this.cs.stopLoading(); - } - } - // private startBiometricLogin(user: AuthenticatedUser) { - // this.faio.isAvailable().then((options) => { - // this.hideSplashScreen(true); - // if (user.biometricEnabled) { - // // ask if login with face or finger - // this.cs.presentConfirmDialog( - // this.ts.trPK('login', options), - // () => this.presentBiometricDialog(user), - // () => { } - // ); - // } else { - // // ask to enable biometric - // this.getPermissionToActivateBiometric(user); - // } - // }, () => { - // this.hideSplashScreen(true); - // }); - // } - - private getPermissionToActivateBiometric(user: AuthenticatedUser) { - this.cs.presentConfirmDialog( - this.ts.trPK('login', 'enable-biometric'), - () => { - user['biometricEnabled'] = true; - this.authService.updateLoggedInUser(user).subscribe((success: boolean) => { - this.presentBiometricDialog(user); - }); - }, - () => { } - ); + this.currentLang = TranslatorService.getCurrentLanguageCode(); + } + // private checkIfLoggedInBefore() { + // this.cs.startLoading(); + // // check if user logged in before + // this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => { + // if (user) { + // this.startBiometricLogin(user); + // } else { + // this.hideSplashScreen(true); + // } + // }); + // } + private forgetPasswordPage() { + this.cs.openUserForgot(); + } + private hideSplashScreen(stopLoading = false) { + // this.splash.hide(); + if (stopLoading) { + this.cs.stopLoading(); } - /* + } + // private startBiometricLogin(user: AuthenticatedUser) { + // this.faio.isAvailable().then((options) => { + // this.hideSplashScreen(true); + // if (user.biometricEnabled) { + // // ask if login with face or finger + // this.cs.presentConfirmDialog( + // this.ts.trPK('login', options), + // () => this.presentBiometricDialog(user), + // () => { } + // ); + // } else { + // // ask to enable biometric + // this.getPermissionToActivateBiometric(user); + // } + // }, () => { + // this.hideSplashScreen(true); + // }); + // } + + private getPermissionToActivateBiometric(user: AuthenticatedUser) { + this.cs.presentConfirmDialog( + this.ts.trPK("login", "enable-biometric"), + () => { + user["biometricEnabled"] = true; + this.authService + .updateLoggedInUser(user) + .subscribe((success: boolean) => { + this.presentBiometricDialog(user); + }); + }, + () => {} + ); + } + /* activate biometric login for this user */ - private getMobileInfo(user: AuthenticatedUser) { - this.authService.getLoginInfo(new GetLoginInfoRequest(user), () => { - - }, this.ts.trPK('general', 'ok')).subscribe((result: GetLoginInfoResponse) => { - if (this.cs.validResponse(result)) { - if (!result.SMSLoginRequired) { - this.loginTokenID = result.LogInTokenID; - this.patientOutSA = result.PatientOutSA; - this.initializeForAuthentictedUser(user); - // sms for register the biometric - if (result.isSMSSent) { - this.startListeneingForSMS(this.ts.trPK('general', 'enter-sms-enable-biometric')); - } else { - this.checkActivationCode(); - } - } + private getMobileInfo(user: AuthenticatedUser) { + this.authService + .getLoginInfo( + new GetLoginInfoRequest(user), + () => {}, + this.ts.trPK("general", "ok") + ) + .subscribe((result: GetLoginInfoResponse) => { + if (this.cs.validResponse(result)) { + if (!result.SMSLoginRequired) { + this.loginTokenID = result.LogInTokenID; + this.patientOutSA = result.PatientOutSA; + this.initializeForAuthentictedUser(user); + // sms for register the biometric + if (result.isSMSSent) { + this.startListeneingForSMS( + this.ts.trPK("general", "enter-sms-enable-biometric") + ); + } else { + this.checkActivationCode(); } - }); - } - - private initializeForAuthentictedUser(user: AuthenticatedUser) { - this.ngZone.run(() => { - //this.isMobileFingerPrint = true; - //this.FingerPrintPatientIdentificationID = user.IdentificationNo; - //this.mobileNumber = user.MobileNumber; - //this.zipCode = CountryCode.localCode(user.ZipCode); - - }); - } - - private presentBiometricDialog(user) { - this.faio.show({ - clientId: 'Fingerprint Authetnciation', - clientSecret: 'Ate343_9347lajF', // Only necessary for Android - disableBackup: true, // Only for Android(optional) - localizedFallbackTitle: this.ts.trPK('login', 'use-pin'), // Only for iOS - localizedReason: this.ts.trPK('login', 'auth-please') // Only for iOS - }).then((result: any) => { - // this.checkActivationCode(); - this.getMobileInfo(user); - - }).catch((error: any) => console.log(error)); - } - - public onLogin() { - this.checkUserAuthentication(); - } - - - - - - - // public loginWithMyAccount() { - // // this.loginWithTamer(); - // this.loginWithTamer(); - // } - - /* + } + } + }); + } + + private initializeForAuthentictedUser(user: AuthenticatedUser) { + this.ngZone.run(() => { + //this.isMobileFingerPrint = true; + //this.FingerPrintPatientIdentificationID = user.IdentificationNo; + //this.mobileNumber = user.MobileNumber; + //this.zipCode = CountryCode.localCode(user.ZipCode); + }); + } + + private presentBiometricDialog(user) { + this.faio + .show({ + clientId: "Fingerprint Authetnciation", + clientSecret: "Ate343_9347lajF", // Only necessary for Android + disableBackup: true, // Only for Android(optional) + localizedFallbackTitle: this.ts.trPK("login", "use-pin"), // Only for iOS + localizedReason: this.ts.trPK("login", "auth-please") // Only for iOS + }) + .then((result: any) => { + // this.checkActivationCode(); + this.getMobileInfo(user); + }) + .catch((error: any) => console.log(error)); + } + + public onLogin() { + this.checkUserAuthentication(); + } + + // public loginWithMyAccount() { + // // this.loginWithTamer(); + // this.loginWithTamer(); + // } + + /* TODO to be removed later */ - // public loginWithEnas() { - // alert('you are doing slient login width enas account '); - // const user = new AuthenticatedUser(); - // user.PatientID = 862616; - - // user.PatientTypeID = PATIENT_TYPE.PERMANENT; - // user.PatientOutSA = false; - // user.TokenID = '@dm!n'; - // user.ProjectID = 0; - // user.NationalityID = '2300948375'; - // user.MobileNo = user.MobileNumber = '554355126'; - // user.ZipCode = '+966'; - // user.Address = 'riyadh'; - // user.FirstName = 'MOHAMED'; - // user.MiddleName = 'yaghi'; - // user.LastName = 'mohammed'; - // user.Age = 30; - // user.agreed = true; - // const birthDate = new Date(); - // birthDate.setFullYear(birthDate.getFullYear() - 29); - // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); - // user.Email = 'Mohamed.Afifi@cloudsolution-sa.com'; - // user.PatientName = 'enas yaghi'; - // this.authService.updateLoggedInUser(user).subscribe(done => { - // this.authService.startIdleMonitoring(); - // this.cs.openHome(); - // }); - // } - - // public loginWithVaccineUser() { - // alert('you are doing slient login width vaccine account '); - // const user = new AuthenticatedUser(); - // user.PatientID = 862616; // user with vaccines in dev - - // user.PatientTypeID = PATIENT_TYPE.PERMANENT; - // user.PatientOutSA = false; - // user.TokenID = '@dm!n'; - // user.NationalityID = '2300948375'; - // user.MobileNo = user.MobileNumber = '554355126'; - // user.ProjectID = 0; - // user.ZipCode = '+966'; - // user.Address = 'riyadh'; - // user.FirstName = 'MOHAMED'; - // user.MiddleName = 'yaghi'; - // user.LastName = 'mohammed'; - // user.Age = 30; - // user.agreed = true; - // const birthDate = new Date(); - // birthDate.setFullYear(birthDate.getFullYear() - 29); - // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); - // user.Email = 'minna.barry@cloudsolution-sa.com'; - // user.PatientName = 'enas yaghi'; - // this.authService.updateLoggedInUser(user).subscribe(done => { - // this.authService.startIdleMonitoring(); - // this.cs.openHome(); - // }); - // } - - - // public loginWithEyeMeasureUser() { - // alert('you are doing slient login width eye measurements user account '); - // const user = new AuthenticatedUser(); - // user.PatientID = 873010; - - // user.PatientTypeID = PATIENT_TYPE.PERMANENT; - // user.PatientOutSA = false; - // user.TokenID = '@dm!n'; - // user.NationalityID = '2302581828'; - // user.ProjectID = 0; - // user.MobileNo = user.MobileNumber = '555333541'; - // user.ZipCode = '+966'; - // user.Address = 'riyadh'; - // user.FirstName = 'eye'; - // user.MiddleName = 'user'; - // user.LastName = 'measurment'; - // user.Age = 30; - // user.agreed = true; - // const birthDate = new Date(); - // birthDate.setFullYear(birthDate.getFullYear() - 29); - // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); - // user.Email = 'sultan.khan@hmg.local'; - // user.PatientName = 'eye user'; - // this.authService.updateLoggedInUser(user).subscribe(done => { - // this.authService.startIdleMonitoring(); - // this.cs.openHome(); - // }); - // } - - /* + // public loginWithEnas() { + // alert('you are doing slient login width enas account '); + // const user = new AuthenticatedUser(); + // user.PatientID = 862616; + + // user.PatientTypeID = PATIENT_TYPE.PERMANENT; + // user.PatientOutSA = false; + // user.TokenID = '@dm!n'; + // user.ProjectID = 0; + // user.NationalityID = '2300948375'; + // user.MobileNo = user.MobileNumber = '554355126'; + // user.ZipCode = '+966'; + // user.Address = 'riyadh'; + // user.FirstName = 'MOHAMED'; + // user.MiddleName = 'yaghi'; + // user.LastName = 'mohammed'; + // user.Age = 30; + // user.agreed = true; + // const birthDate = new Date(); + // birthDate.setFullYear(birthDate.getFullYear() - 29); + // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); + // user.Email = 'Mohamed.Afifi@cloudsolution-sa.com'; + // user.PatientName = 'enas yaghi'; + // this.authService.updateLoggedInUser(user).subscribe(done => { + // this.authService.startIdleMonitoring(); + // this.cs.openHome(); + // }); + // } + + // public loginWithVaccineUser() { + // alert('you are doing slient login width vaccine account '); + // const user = new AuthenticatedUser(); + // user.PatientID = 862616; // user with vaccines in dev + + // user.PatientTypeID = PATIENT_TYPE.PERMANENT; + // user.PatientOutSA = false; + // user.TokenID = '@dm!n'; + // user.NationalityID = '2300948375'; + // user.MobileNo = user.MobileNumber = '554355126'; + // user.ProjectID = 0; + // user.ZipCode = '+966'; + // user.Address = 'riyadh'; + // user.FirstName = 'MOHAMED'; + // user.MiddleName = 'yaghi'; + // user.LastName = 'mohammed'; + // user.Age = 30; + // user.agreed = true; + // const birthDate = new Date(); + // birthDate.setFullYear(birthDate.getFullYear() - 29); + // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); + // user.Email = 'minna.barry@cloudsolution-sa.com'; + // user.PatientName = 'enas yaghi'; + // this.authService.updateLoggedInUser(user).subscribe(done => { + // this.authService.startIdleMonitoring(); + // this.cs.openHome(); + // }); + // } + + // public loginWithEyeMeasureUser() { + // alert('you are doing slient login width eye measurements user account '); + // const user = new AuthenticatedUser(); + // user.PatientID = 873010; + + // user.PatientTypeID = PATIENT_TYPE.PERMANENT; + // user.PatientOutSA = false; + // user.TokenID = '@dm!n'; + // user.NationalityID = '2302581828'; + // user.ProjectID = 0; + // user.MobileNo = user.MobileNumber = '555333541'; + // user.ZipCode = '+966'; + // user.Address = 'riyadh'; + // user.FirstName = 'eye'; + // user.MiddleName = 'user'; + // user.LastName = 'measurment'; + // user.Age = 30; + // user.agreed = true; + // const birthDate = new Date(); + // birthDate.setFullYear(birthDate.getFullYear() - 29); + // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); + // user.Email = 'sultan.khan@hmg.local'; + // user.PatientName = 'eye user'; + // this.authService.updateLoggedInUser(user).subscribe(done => { + // this.authService.startIdleMonitoring(); + // this.cs.openHome(); + // }); + // } + + /* TODO login with mr rwaid */ - // public loginWithRwaid() { - // alert('you are doing slient login width mr: rwaid account'); - - // const user = new AuthenticatedUser(); - // // tamer with eye measurments 1231755 - // user.PatientID = 1018977; - // user.PatientTypeID = PATIENT_TYPE.PERMANENT; - // user.ProjectID = 0; - // user.PatientOutSA = false; - // user.TokenID = '@dm!n'; - // user.NationalityID = '1001242559'; - // user.MobileNo = user.MobileNumber = '545156035'; - // user.ZipCode = '+966'; - // user.Address = 'riyadh'; - // user.FirstName = 'rwaid'; - // user.MiddleName = 'el mallah'; - // user.LastName = 'mohammed'; - // user.Age = 30; - // user.agreed = true; - // const birthDate = new Date(); - // birthDate.setFullYear(birthDate.getFullYear() - 29); - // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); - // user.Email = 'mohamed.afifi@cloudsolution-sa.com'; - // user.PatientName = 'rwaid al mallah'; - // this.authService.updateLoggedInUser(user).subscribe(done => { - // this.authService.startIdleMonitoring(); - // this.cs.openHome(); - // }); - - // } - - // public loginWithTamer() { - // alert('you are doing slient login width tamer account'); - - // const user = new AuthenticatedUser(); - // user.PatientID = 1231755; - // user.PatientTypeID = PATIENT_TYPE.PERMANENT; - // user.ProjectID = 0; - // user.PatientOutSA = false; - // user.TokenID = '@dm!n'; - // user.NationalityID = '1001242559'; - // user.MobileNo = user.MobileNumber = '537503378'; - // user.ZipCode = '+966'; - // user.Address = 'riyadh'; - // user.FirstName = 'tamer'; - // user.MiddleName = 'faneshah'; - // user.LastName = 'faneshah'; - // user.Age = 30; - // user.agreed = true; - // const birthDate = new Date(); - // birthDate.setFullYear(birthDate.getFullYear() - 29); - // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); - // user.Email = 'mohamed.afifi@cloudsolution-sa.com'; - // user.PatientName = 'tamer fneshah'; - // this.authService.updateLoggedInUser(user).subscribe(done => { - // this.authService.startIdleMonitoring(); - // this.cs.openHome(); + // public loginWithRwaid() { + // alert('you are doing slient login width mr: rwaid account'); + + // const user = new AuthenticatedUser(); + // // tamer with eye measurments 1231755 + // user.PatientID = 1018977; + // user.PatientTypeID = PATIENT_TYPE.PERMANENT; + // user.ProjectID = 0; + // user.PatientOutSA = false; + // user.TokenID = '@dm!n'; + // user.NationalityID = '1001242559'; + // user.MobileNo = user.MobileNumber = '545156035'; + // user.ZipCode = '+966'; + // user.Address = 'riyadh'; + // user.FirstName = 'rwaid'; + // user.MiddleName = 'el mallah'; + // user.LastName = 'mohammed'; + // user.Age = 30; + // user.agreed = true; + // const birthDate = new Date(); + // birthDate.setFullYear(birthDate.getFullYear() - 29); + // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); + // user.Email = 'mohamed.afifi@cloudsolution-sa.com'; + // user.PatientName = 'rwaid al mallah'; + // this.authService.updateLoggedInUser(user).subscribe(done => { + // this.authService.startIdleMonitoring(); + // this.cs.openHome(); + // }); + + // } + + // public loginWithTamer() { + // alert('you are doing slient login width tamer account'); + + // const user = new AuthenticatedUser(); + // user.PatientID = 1231755; + // user.PatientTypeID = PATIENT_TYPE.PERMANENT; + // user.ProjectID = 0; + // user.PatientOutSA = false; + // user.TokenID = '@dm!n'; + // user.NationalityID = '1001242559'; + // user.MobileNo = user.MobileNumber = '537503378'; + // user.ZipCode = '+966'; + // user.Address = 'riyadh'; + // user.FirstName = 'tamer'; + // user.MiddleName = 'faneshah'; + // user.LastName = 'faneshah'; + // user.Age = 30; + // user.agreed = true; + // const birthDate = new Date(); + // birthDate.setFullYear(birthDate.getFullYear() - 29); + // user.DateofBirth = this.cs.convertISODateToJsonDate(this.cs.getDateISO(birthDate)); + // user.Email = 'mohamed.afifi@cloudsolution-sa.com'; + // user.PatientName = 'tamer fneshah'; + // this.authService.updateLoggedInUser(user).subscribe(done => { + // this.authService.startIdleMonitoring(); + // this.cs.openHome(); + // }); + + // } + + private startListeneingForSMS(title?: string) { + this.startReceivingSMS(); + //this.presentSMSPasswordDialog(title); + } + + private checkUserAuthentication() { + const request = new LoginRequest(); + request.P_USER_NAME = this.username; + request.P_LANGUAGE = this.language; + request.P_PASSWORD = this.password; + console.log(request); + this.authService + .login(request, () => {}, this.ts.trPK("general", "ok")) + .subscribe((result: CheckUserAuthenticationResponse) => { + if (this.cs.validResponse(result)) { + this.loginData.LogInTokenID = result.LogInTokenID; + this.loginData.MobileNumber = result.MemberLoginList.P_MOBILE_NUMBER; + this.sharedData.setSharedData(this.loginData, "logindata"); + this.cs.openSMSPage(); + } + }); + } + + public backClicked() { + this.smsService.stopSMSMonitoring(); + } + + private startReceivingSMS() { + // this.smsModal.presentModal(); + // this.smsService.startSMSMonitoring((code) => { + // this.smsModal.dismiss; + // this.global_code = code; + // SMSService.code = this.global_code; + // this.checkActivationCode(code); + // this.cs.dismissSMSDialog().subscribe(cleared => { + // this.checkActivationCode(code); // }); - - // } - - - - private startListeneingForSMS(title?: string) { - this.startReceivingSMS(); - //this.presentSMSPasswordDialog(title); - } - - private checkUserAuthentication() { - const request = new LoginRequest(); - request.P_USER_NAME = this.username; - request.P_LANGUAGE = this.language; - request.P_PASSWORD = this.password; - console.log(request); - this.authService.login( - request, - () => { - }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { - if (this.cs.validResponse(result)) { - this.loginData.LogInTokenID = result.LogInTokenID; - this.sharedData.setSharedData(this.loginData, "logindata"); - this.cs.openSMSPage(); - } - }); - } - - public backClicked() { - this.smsService.stopSMSMonitoring(); - } - - private startReceivingSMS() { - - // this.smsModal.presentModal(); - // this.smsService.startSMSMonitoring((code) => { - // this.smsModal.dismiss; - // this.global_code = code; - // SMSService.code = this.global_code; - // this.checkActivationCode(code); - // this.cs.dismissSMSDialog().subscribe(cleared => { - // this.checkActivationCode(code); - // }); - // }); - } - public presentSMSPasswordDialog(title?: string) { - this.cs.presentSMSPasswordDialog( - (code: string) => { - this.checkActivationCode(code); - }, null, title); - } - - private checkActivationCode(readedCode?) { - /*const request = new CheckActivationCodeRequest(); + // }); + } + public presentSMSPasswordDialog(title?: string) { + this.cs.presentSMSPasswordDialog( + (code: string) => { + this.checkActivationCode(code); + }, + null, + title + ); + } + + private checkActivationCode(readedCode?) { + /*const request = new CheckActivationCodeRequest(); request.IsMobileFingerPrint = this.isMobileFingerPrint; request.FingerPrintPatientIdentificationID = this.FingerPrintPatientIdentificationID; request.LogInTokenID = this.loginTokenID; @@ -401,73 +404,62 @@ export class LoginComponent implements OnInit, OnDestroy { request.PatientMobileNumber = this.mobileNumber; request.ZipCode = this.zipCode; request.isRegister = false;*/ - - // request.SearchType = this.loginType; - // if (this.loginType === LoginComponent.IDENTIFCIATION_LOGIN_TYPE) { - // request.PatientIdentificationID = this.id; - // request.PatientID = 0; - // } else { - // request.PatientID = Number(this.id); - // request.PatientIdentificationID = ''; - // } - // this.authService.checkActivationCode( - // request, - // () => { - // //this.presentSMSPasswordDialog(); - // this.smsModal.presentModal(); - // }, this.ts.trPK('general', 'retry')).subscribe((result: CheckActivationCodeResponse) => { - // if (this.cs.validResponse(result)) { - // if (this.cs.hasData(result.List)) { - // this.smsService.stopSMSMonitoring(); - // this.checkIfUserAgreedBefore(result); - // } - // } - // }); - - } - - - private checkIfUserAgreedBefore(result: CheckActivationCodeResponse) { - - this.authService.setAuthenticatedUser(result).subscribe(() => { - // if (this.authService.isAgreedBefore()) { - // this.cs.openHome(); - // } else { - // // this.cs.openAgreement(); - // } - }); - } - - private checkUserAgreement() { - - } - - public signOut() { - // this.cs.presentConfirmDialog(this.ts.trPK('login', 'sign-out'), - // () => { - // this.authService.clearUser().subscribe(success => { - // this.id = null; - // if (this.countryCode) { - // this.internationlMobile.setMobileNumber(this.countryCode.code, null); - // } - - // }); - // }); - - - } - - public openForgotID() { - this.cs.openUserForgot(); - } - - public onDismiss() - { - // this.global_code = SMSService.code; - //this.checkActivationCode(this.global_code); - } - public onCancelled() - { - console.log("Modal pop up cancelled"); - } + // request.SearchType = this.loginType; + // if (this.loginType === LoginComponent.IDENTIFCIATION_LOGIN_TYPE) { + // request.PatientIdentificationID = this.id; + // request.PatientID = 0; + // } else { + // request.PatientID = Number(this.id); + // request.PatientIdentificationID = ''; + // } + // this.authService.checkActivationCode( + // request, + // () => { + // //this.presentSMSPasswordDialog(); + // this.smsModal.presentModal(); + // }, this.ts.trPK('general', 'retry')).subscribe((result: CheckActivationCodeResponse) => { + // if (this.cs.validResponse(result)) { + // if (this.cs.hasData(result.List)) { + // this.smsService.stopSMSMonitoring(); + // this.checkIfUserAgreedBefore(result); + // } + // } + // }); + } + + private checkIfUserAgreedBefore(result: CheckActivationCodeResponse) { + this.authService.setAuthenticatedUser(result).subscribe(() => { + // if (this.authService.isAgreedBefore()) { + // this.cs.openHome(); + // } else { + // // this.cs.openAgreement(); + // } + }); + } + + private checkUserAgreement() {} + + public signOut() { + // this.cs.presentConfirmDialog(this.ts.trPK('login', 'sign-out'), + // () => { + // this.authService.clearUser().subscribe(success => { + // this.id = null; + // if (this.countryCode) { + // this.internationlMobile.setMobileNumber(this.countryCode.code, null); + // } + // }); + // }); + } + + public openForgotID() { + this.cs.openUserForgot(); + } + + public onDismiss() { + // this.global_code = SMSService.code; + //this.checkActivationCode(this.global_code); + } + public onCancelled() { + console.log("Modal pop up cancelled"); + } } diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.ts b/Mohem/src/app/authentication/sms-page/sms-page.page.ts index f879b8e2..51d127af 100644 --- a/Mohem/src/app/authentication/sms-page/sms-page.page.ts +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.ts @@ -1,14 +1,14 @@ -import { Component, OnInit } from '@angular/core'; -import { ElementRef } from '@angular/core'; -import { NavController } from '@ionic/angular'; -import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; -import { CommonService } from 'src/app/hmg-common/services/common/common.service'; -import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; -import { SMSCheckRequest } from 'src/app/hmg-common/services/authentication/models/smscheck.request'; -import { LoginModel } from '../models/LoginModel'; -import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; -import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.response'; -import { Password } from '../models/password'; +import { Component, OnInit } from "@angular/core"; +import { ElementRef } from "@angular/core"; +import { NavController } from "@ionic/angular"; +import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; +import { CommonService } from "src/app/hmg-common/services/common/common.service"; +import { SharedDataService } from "src/app/hmg-common/services/shared-data-service/shared-data.service"; +import { SMSCheckRequest } from "src/app/hmg-common/services/authentication/models/smscheck.request"; +import { LoginModel } from "../models/LoginModel"; +import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; +import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response"; +import { Password } from "../models/password"; @Component({ selector: "app-sms-page", @@ -16,7 +16,7 @@ import { Password } from '../models/password'; styleUrls: ["./sms-page.page.scss"] }) export class SmsPagePage implements OnInit { - public static LOGIN_DATA = 'LOGIN_DATA'; + public static LOGIN_DATA = "LOGIN_DATA"; Channel: number = 0; activationCode: string; P_SESSION_ID: number; @@ -46,8 +46,8 @@ export class SmsPagePage implements OnInit { this.count = 0; this.initTimer(); this.startTimer(); - this.isForgetPwd = this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false; - + this.isForgetPwd = + this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false; } initTimer() { @@ -124,7 +124,7 @@ export class SmsPagePage implements OnInit { //this.navCtrl.pop(); goBack this.common.JustAlertDialog(this.translate.trPK("general", "ok"), msg); } - }; + } public checkSMS() { const data = this.sharedData.getSharedData("logindata", false); @@ -132,9 +132,7 @@ export class SmsPagePage implements OnInit { (request.LogInTokenID = data.LogInTokenID), (request.activationCode = this.activationCode); - //request.P_USER_NAME=this.userName, - //request.MobileNumber=this.member.MemberLoginList.P_MOBILE_NUMBER - + request.MobileNumber = data.MobileNumber; this.authService .checkSMS(request, () => {}, this.translate.trPK("general", "ok")) .subscribe((result: SMSCheckResponse) => { @@ -142,36 +140,33 @@ export class SmsPagePage implements OnInit { if (this.common.validResponse(result)) { //this.sharedData.setSharedData(this.loginData, SmsPagePage.LOGIN_DATA); this.authService.setAuthenticatedUser(result).subscribe(() => { - this.common.openHome(); - }) + this.common.openHome(); + }); } }); } - public checkForgetPwdSMS() - { + public checkForgetPwdSMS() { const data = this.sharedData.getSharedData("logindata", false); const request = new SMSCheckRequest(); - request.LogInTokenID= data.LogInTokenID, - request.activationCode =this.activationCode; + (request.LogInTokenID = data.LogInTokenID), + (request.activationCode = this.activationCode); //request.P_USER_NAME=this.userName, //request.MobileNumber=this.member.MemberLoginList.P_MOBILE_NUMBER console.log(data.LogInTokenID); - this.authService.checkForgetSMS( - request, - () => { - }, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => { + this.authService + .checkForgetSMS(request, () => {}, this.translate.trPK("general", "ok")) + .subscribe((result: SMSCheckResponse) => { console.log(result); - if (this.common.validResponse(result)) { - console.log(result); + if (this.common.validResponse(result)) { + console.log(result); - //this.loginData.LogInTokenID = result.LogInTokenID; - //this.sharedData.setSharedData(this.loginData, "logindata"); - this.common.openForgotPassword(); - } + //this.loginData.LogInTokenID = result.LogInTokenID; + //this.sharedData.setSharedData(this.loginData, "logindata"); + this.common.openForgotPassword(); + } }); } - } diff --git a/Mohem/src/app/hmg-common/hmg-common.module.ts b/Mohem/src/app/hmg-common/hmg-common.module.ts index 43ff4d57..154867ad 100644 --- a/Mohem/src/app/hmg-common/hmg-common.module.ts +++ b/Mohem/src/app/hmg-common/hmg-common.module.ts @@ -46,7 +46,7 @@ import { UserLocalNotificationService } from './services/user-local-notification import { LocalNotifications } from '@ionic-native/local-notifications/ngx'; import { EmailComponent } from './ui/email/email.component'; import { Badge } from '@ionic-native/badge/ngx'; -import { Push } from '@ionic-native/push/ngx'; +// import { Push } from '@ionic-native/push/ngx'; import { PushService } from './services/push/push.service'; import { LifeCycleService } from './services/life-cycle/life-cycle.service'; import { HmgBrowserService } from './services/hmg-browser/hmg-browser.service'; @@ -69,7 +69,6 @@ import { Keyboard } from '@ionic-native/keyboard/ngx'; import { KeyboardService } from './services/keyboard/keyboard.service'; import { DevicePermissionsService } from './services/device-permissions/device-permissions.service'; import { SegmentsComponent } from './ui/segments/segments.component'; -import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx'; import { AccordionComponent } from './ui/accordion/accordion.component'; import { AccordionTabComponent } from './ui/accordion/accordion-tab/accordion-tab.component'; import { TwoOptionSelectComponent } from './ui/two-option-select/two-option-select.component'; @@ -218,7 +217,6 @@ import { MenuService } from './services/menu/menuservice.service'; UserLocalNotificationService, LocalNotifications, Badge, - Push, LifeCycleService, HmgBrowserService, GuidService, @@ -228,7 +226,6 @@ import { MenuService } from './services/menu/menuservice.service'; KeyboardService, Diagnostic, DevicePermissionsService, - BarcodeScanner, LazyLoadingService, HMGPreloadingStrategy, HMGPreloadingStrategyLoading, diff --git a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts index 69c0d4b7..f3ddea32 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -113,7 +113,7 @@ export class AuthenticationService { request.LanguageID = TranslatorService.getCurrentLanguageCode(); //request.IPAdress = '10.10.10.10'; //request.SessionID = "any thing"; // ??? required for not authorized login funny - request.MobileType = "android"; + request.MobileType = ""; //request.isDentalAllowedBackend = false; return request; } diff --git a/Mohem/src/app/hmg-common/services/push/push.service.ts b/Mohem/src/app/hmg-common/services/push/push.service.ts index f87de61d..48be6ccb 100644 --- a/Mohem/src/app/hmg-common/services/push/push.service.ts +++ b/Mohem/src/app/hmg-common/services/push/push.service.ts @@ -1,5 +1,5 @@ import { Injectable, NgZone } from '@angular/core'; -import { Push, PushObject, PushOptions } from '@ionic-native/push/ngx'; +// import { Push, PushObject, PushOptions } from '@ionic-native/push/ngx'; import { CommonService } from '../common/common.service'; import { TranslatorService } from '../translator/translator.service'; import { NotificationModel } from './models/notification.model'; @@ -26,7 +26,7 @@ export class PushService { public static CHANNEL_ID = '815750722565'; constructor( - public push: Push, + // public push: Push, public cs: CommonService, public ts: TranslatorService, public sharedService: SharedDataService, @@ -43,58 +43,58 @@ export class PushService { this.processStartReceiving(); } private processStartReceiving() { - if (this.cs.isCordova()) { - this.stopNotifications(() => { - this.push.hasPermission() - .then((res: any) => { - if (res.isEnabled) { - this.createChannel(); - } else { - this.cs.presentAlert(this.ts.trPK('push', 'no-permiss')); - } - }); - }); - } + // if (this.cs.isCordova()) { + // this.stopNotifications(() => { + // this.push.hasPermission() + // .then((res: any) => { + // if (res.isEnabled) { + // this.createChannel(); + // } else { + // this.cs.presentAlert(this.ts.trPK('push', 'no-permiss')); + // } + // }); + // }); + // } } private createChannel() { // Create a channel (Android O and above). You'll need to provide the id, description and importance properties. - this.push.createChannel({ - id: PushService.CHANNEL_ID, - description: 'HMG push notifications', - importance: 3 - }).then(() => { - this.initialize(); - }); + // this.push.createChannel({ + // id: PushService.CHANNEL_ID, + // description: 'HMG push notifications', + // importance: 3 + // }).then(() => { + // this.initialize(); + // }); } private initialize() { - const options: PushOptions = { - android: { - senderID: PushService.CHANNEL_ID, - sound: true, - forceShow: true - }, - ios: { - alert: true, - badge: true, - sound: true - }, - windows: {}, - browser: { - pushServiceURL: 'http://push.api.phonegap.com/v1/push' - } - }; - const pushObject: PushObject = this.push.init(options); - pushObject.on('notification').subscribe((notification: any) => { - this.processNotification(notification); - }); + // const options: PushOptions = { + // android: { + // senderID: PushService.CHANNEL_ID, + // sound: true, + // forceShow: true + // }, + // ios: { + // alert: true, + // badge: true, + // sound: true + // }, + // windows: {}, + // browser: { + // pushServiceURL: 'http://push.api.phonegap.com/v1/push' + // } + // }; + // const pushObject: PushObject = this.push.init(options); + // pushObject.on('notification').subscribe((notification: any) => { + // this.processNotification(notification); + // }); - pushObject.on('registration').subscribe((data: any) => { - this.registerInBackend(data); - }); + // pushObject.on('registration').subscribe((data: any) => { + // this.registerInBackend(data); + // }); - pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error)); + // pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error)); } @@ -149,11 +149,11 @@ export class PushService { } public stopNotifications(done: any) { // Delete a channel (Android O and above) - if (this.cs.isCordova()) { - this.push.deleteChannel(PushService.CHANNEL_ID).then(() => { - done(); - }); - } + // if (this.cs.isCordova()) { + // this.push.deleteChannel(PushService.CHANNEL_ID).then(() => { + // done(); + // }); + // } } private registerInBackend(data: any) { diff --git a/Mohem/src/app/home/home.page.scss b/Mohem/src/app/home/home.page.scss index 709bf833..018f5f17 100644 --- a/Mohem/src/app/home/home.page.scss +++ b/Mohem/src/app/home/home.page.scss @@ -63,7 +63,7 @@ font-size: 14px; min-height: 20px; // white-space: normal; - display: -webkit-box; + text-align: center; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; diff --git a/Mohem/src/assets/localization/i18n.json b/Mohem/src/assets/localization/i18n.json index 4f926ef5..de7f67ff 100644 --- a/Mohem/src/assets/localization/i18n.json +++ b/Mohem/src/assets/localization/i18n.json @@ -684,5 +684,36 @@ "en": "User has no permissions", "ar": "المستخدم ليس لدية صلاحيات" } +}, +"home": { + "dashboard":{ + "en":"My Dashboard", + "ar":"" + }, + "hello": { + "en":"Hello", + "ar":"" + }, + "logout": { + "en":"Logout", + "ar":"" + }, + "worklist":{ + "en":"Work List", + "ar":"" + }, + "possitionAlert":{ + "en":"The app could not access your location. Make sure that the location service is enabled from your device settings", + "ar":"" + }, + "swipeAlertSuccess":{ + "en":"Your swipe done successfully", + "ar":"" + }, + + "swipeAlertFailed":{ + "en":"your swipe Failed, please try again...", + "ar":"" + } } } \ No newline at end of file