diff --git a/Mohem/install-plugins.bat b/Mohem/install-plugins.bat index 20088fa5..1c6245c8 100644 --- a/Mohem/install-plugins.bat +++ b/Mohem/install-plugins.bat @@ -149,6 +149,10 @@ call npm install @ionic-native/file-path call ionic cordova plugin add com-badrit-base64 call npm install @ionic-native/base64 +@echo install OneSignal plugin +call ionic cordova plugin add onesignal-cordova-plugin +call npm install @ionic-native/onesignal + @echo reinitializing git repository @echo git init @echo git remote add origin https://enas_yaghi@hmg.git.cloudforge.com/patientappionic.git diff --git a/Mohem/package-lock.json b/Mohem/package-lock.json index da87b01d..3ef154ef 100644 --- a/Mohem/package-lock.json +++ b/Mohem/package-lock.json @@ -1096,6 +1096,21 @@ } } }, + "@ionic-native/onesignal": { + "version": "5.17.0", + "resolved": "https://registry.npmjs.org/@ionic-native/onesignal/-/onesignal-5.17.0.tgz", + "integrity": "sha512-PQfEki/34yGM4i+548Rt40RV8A4T0srRSk3GVEDZzoHiPMxnbxbLmsxiEjYG74K1AXBzT6tZmnlSiGumJtky6A==", + "requires": { + "@types/cordova": "^0.0.34" + }, + "dependencies": { + "@types/cordova": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/cordova/-/cordova-0.0.34.tgz", + "integrity": "sha1-6nrd907Ow9dimCegw54smt3HPQQ=" + } + } + }, "@ionic-native/open-native-settings": { "version": "5.14.0", "resolved": "https://registry.npmjs.org/@ionic-native/open-native-settings/-/open-native-settings-5.14.0.tgz", @@ -9809,6 +9824,11 @@ "wrappy": "1" } }, + "onesignal-cordova-plugin": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/onesignal-cordova-plugin/-/onesignal-cordova-plugin-2.7.0.tgz", + "integrity": "sha512-ZkvF9uus+WdX+9Nh2p0OlZ6gUJHqKI88IQz78wW1Dat0kPmQvi8bYFi+MI8LYTkg2IFza6W0IbVVkEw7ye58cw==" + }, "onetime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", diff --git a/Mohem/package.json b/Mohem/package.json index ff17267e..b0949ab0 100755 --- a/Mohem/package.json +++ b/Mohem/package.json @@ -46,6 +46,7 @@ "@ionic-native/launch-navigator": "^5.16.0", "@ionic-native/local-notifications": "^5.16.0", "@ionic-native/native-storage": "^5.16.0", + "@ionic-native/onesignal": "^5.17.0", "@ionic-native/open-native-settings": "^5.14.0", "@ionic-native/push": "^5.16.0", "@ionic-native/splash-screen": "^5.0.0", @@ -102,6 +103,7 @@ "mx.ferreyra.callnumber": "0.0.2", "ng2-file-upload": "^1.3.0", "ng2-pdf-viewer": "^5.3.2", + "onesignal-cordova-plugin": "^2.7.0", "phonegap-plugin-barcodescanner": "8.1.0", "phonegap-plugin-multidex": "^1.0.0", "phonegap-plugin-push": "^2.3.0", @@ -200,7 +202,8 @@ "GMS_VERSION": "16.0.1" }, "cordova-plugin-appavailability": {}, - "cordova-plugin-apprate": {} + "cordova-plugin-apprate": {}, + "onesignal-cordova-plugin": {} }, "platforms": [ "browser", diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index b1132673..364b64a6 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -7,7 +7,7 @@ import { AuthenticatedUser } from "./hmg-common/services/authentication/models/a import { TabsBarComponent } from "./hmg-common/ui/tabs-bar/tabs-bar.component"; import { KeyboardService } from "./hmg-common/services/keyboard/keyboard.service"; import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response"; - +import { PushService } from '../../src/app/hmg-common/services/push/push.service'; import { LazyLoadingService } from "./hmg-common/services/lazy-loading/lazy-loading.service"; import { DomSanitizer } from '@angular/platform-browser'; @@ -38,6 +38,7 @@ export class AppComponent implements OnInit, AfterViewInit { private menu: MenuController, private authService: AuthenticationService, private sanitizer: DomSanitizer, + public pushService: PushService, ) { this.events.subscribe("img-change", displayImg => { @@ -50,6 +51,7 @@ export class AppComponent implements OnInit, AfterViewInit { } ngOnInit() { this.initializeApp(); + } ngAfterViewInit() {} initializeApp() { @@ -63,9 +65,15 @@ export class AppComponent implements OnInit, AfterViewInit { this.watchLanguageChangeEvents(); this.subscribeEvents(); this.keyboardService.watchKeyboard(); + this.startReceivingPushService(); }); }); } + + private startReceivingPushService() { + this.pushService.startReceiving(); + +} subscribeEvents() { this.events.subscribe("setMenu", () => { const user = this.authService diff --git a/Mohem/src/app/app.module.ts b/Mohem/src/app/app.module.ts index 6b711832..499bf89d 100644 --- a/Mohem/src/app/app.module.ts +++ b/Mohem/src/app/app.module.ts @@ -5,6 +5,7 @@ import { HmgCommonModule } from './hmg-common/hmg-common.module'; import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx'; +import { OneSignal } from '@ionic-native/onesignal/ngx'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; @@ -36,6 +37,7 @@ import { Base64 } from "@ionic-native/base64/ngx"; File, FilePath, Base64, + OneSignal, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } ], bootstrap: [AppComponent] diff --git a/Mohem/src/app/authentication/authentication.module.ts b/Mohem/src/app/authentication/authentication.module.ts index 143e3a67..520c6c77 100644 --- a/Mohem/src/app/authentication/authentication.module.ts +++ b/Mohem/src/app/authentication/authentication.module.ts @@ -20,7 +20,7 @@ import { SmsPageModule } from 'src/app/hmg-common/ui/sms/sms.module'; import { SmsPageComponent } from './sms-page/sms-page.page'; import { CheckUserComponent } from './check-user/check-user.component'; import { ChangePasswordComponent } from './change-password/change-password.component'; - +import {ConfirmLoginComponent} from '../authentication/confirm-login/confirm-login.component' const routes: Routes = [ @@ -47,6 +47,10 @@ const routes: Routes = [ { path: 'changepassowrd', component: ChangePasswordComponent + }, + { + path: 'confirmLogin', + component: ConfirmLoginComponent } ] } @@ -72,7 +76,8 @@ const routes: Routes = [ ForgotComponent, SmsPageComponent, CheckUserComponent, - ChangePasswordComponent + ChangePasswordComponent, + ConfirmLoginComponent ], providers:[ FingerprintAIO, diff --git a/Mohem/src/app/authentication/confirm-login/confirm-login.component.html b/Mohem/src/app/authentication/confirm-login/confirm-login.component.html new file mode 100644 index 00000000..794c4955 --- /dev/null +++ b/Mohem/src/app/authentication/confirm-login/confirm-login.component.html @@ -0,0 +1,50 @@ + + + + + + {{'login,verify-login' | translate}} + + + + + + + + + + + + + + + + +

{{ts.trPK('login','verify-login-with')}}

+ +

{{ts.trPK('login','verify-fingerprint')}}

+ + +
+
+ + + + + + + + + + + + +
+ +
\ No newline at end of file diff --git a/Mohem/src/app/authentication/confirm-login/confirm-login.component.scss b/Mohem/src/app/authentication/confirm-login/confirm-login.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/Mohem/src/app/authentication/confirm-login/confirm-login.component.spec.ts b/Mohem/src/app/authentication/confirm-login/confirm-login.component.spec.ts new file mode 100644 index 00000000..a332e7d1 --- /dev/null +++ b/Mohem/src/app/authentication/confirm-login/confirm-login.component.spec.ts @@ -0,0 +1,27 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ConfirmLoginComponent } from './confirm-login.component'; + +describe('ConfirmLoginComponent', () => { + let component: ConfirmLoginComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ConfirmLoginComponent ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ConfirmLoginComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts new file mode 100644 index 00000000..3eb241b9 --- /dev/null +++ b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts @@ -0,0 +1,379 @@ +import { Component, OnInit } from '@angular/core'; +import {ButtonSettings} from "src/app/hmg-common/ui/button/models/button-settingsl"; +import {TranslatorService} from "src/app/hmg-common/services/translator/translator.service"; +import { CommonService } from 'src/app/hmg-common/services/common/common.service'; +import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request'; +import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; +import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; +import { SendActivationByType } from '../models/sendActivationByType'; +import { FingerprintAIO } from '@ionic-native/fingerprint-aio/ngx'; +import { GetLoginInfoRequest } from "../../hmg-common/services/authentication/models/get-login-info.request"; +import { GetLoginInfoResponse } from "../../hmg-common/services/authentication/models/get-login-info.response"; +import { SMSCheckRequest } from "src/app/hmg-common/services/authentication/models/smscheck.request"; +import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response"; +import { PushService } from 'src/app/hmg-common/services/push/push.service'; + + +@Component({ + selector: 'app-confirm-login', + templateUrl: './confirm-login.component.html', + styleUrls: ['./confirm-login.component.scss'], +}) +export class ConfirmLoginComponent implements OnInit { + public logo = "assets/imgs/CS.png"; + public buttons:any=[]; + isFaceorFinger: any; + onlySMSBox: any = true; + loginData:any; + selectedOption: any; + lastLogin: any; + loginTokenID:any + deviceToken:any; + + constructor( + public ts: TranslatorService, + public cs: CommonService, + public authService: AuthenticationService, + public sharedData: SharedDataService, + private faio: FingerprintAIO, + public pushService: PushService, + + + ) { + this.loginData= this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); + console.log(this.loginData); + this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); + console.log("deviceToken :"+this.deviceToken); + //if device token undefind + if(this.deviceToken == undefined){ + this.deviceToken = localStorage.getItem("deviceToken"); + + } + this.lastLogin = this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false); + + } + + ngOnInit() { + //**checkIfAvailable FAIO **// + this.checkIfAvailable(); + //**getSharedData of IMEI_USER_DATA and REGISTER_DATA_FOR_LOGIIN to set defult value **// + + // this.setDefault(); + + + this.button(); + } + + checkIfAvailable() { + this.faio.isAvailable().then( + options => { + this.isFaceorFinger = options; + if (this.isFaceorFinger === 'finger' && this.lastLogin === 1) { + this.selectedOption = 2; + this.cs.presentConfirmDialog( + this.ts.trPK("login", "biometric-support"), + () => { + this.presentBiometricDialog(); + this.cs.sharedService.setSharedData( + this.selectedOption, + AuthenticationService.LAST_LOGIN + ); + }, + () => { } + ); + } + this.button(); + }, + () => { + this.isFaceorFinger = null; + this.button(); + } + ); + } + + button() { + console.log("button"); + + this.buttons = [ + [{ + title: "login,verify-with-fingerprint", + url: null, + icon: "assets/icon/login/102.png", + settings: new ButtonSettings(true, true, true, true), + value: 2, + disabled: this.isFaceorFinger === "finger" ? false : true, + visible: this.onlySMSBox + }, + { + title: "login,verify-with-faceid", + url: null, + icon: "assets/icon/login/101.png", + settings: new ButtonSettings(true, true, true, true), + value: 3, + disabled: this.isFaceorFinger === "face" ? false : true, + visible: this.onlySMSBox + }, + { + title: "login,verify-with-whatsapp", + url: null, + icon: "assets/icon/login/104.png", + settings: new ButtonSettings(true, true, true, true), + value: 4, + visible: true + }, + { + title: "login,verify-with-sms", + url: null, + icon: "assets/icon/login/103.png", + settings: new ButtonSettings(true, true, true, true), + value: 1, + visible: true + } + ] + ]; + } + + confirm(el: any) { + console.log("confirm:"+ el ); + this.selectedOption = this.selectedOption && !this.onlySMSBox ? this.selectedOption : el.value; + switch (el.value) { + case 1: + console.log(el.value); + this.loginWithSMS(el); + break; + case 2: + console.log(el.value); + + this.loginWithFingurePrint(el); + break; + case 3: + console.log(el.value); + + this.faceReconization(el); + break; + case 4: + console.log(el.value); + + this.loginWithWhatsapp(el); + break; + default: + break; + } + this.cs.sharedService.setSharedData( + this.selectedOption, + AuthenticationService.LAST_LOGIN + ); + } + + loginWithSMS(el) { + console.log("loginWithSMS: "+ el); + + if (!el.disabled) { + + // if (this.user && !this.registerd_data) { + //calling because i dont have token id which required to the send activation code + /// this.checkUserAuthentication(1); + // this.checkUserAuthentication(); *** + + // } else { + if (this.loginData.LogInTokenID) { + this.sendActivationCode(1); + } else { + // this.checkUserAuthentication(1); + // this.checkUserAuthentication();** + + } + // } + } + } + + loginWithWhatsapp(el) { + if (!el.disabled) { + // if (this.user && !this.registerd_data) { + //calling because i dont have token id which required to the send activation code + // this.checkUserAuthentication(2); + // } else { + if (this.loginData.LogInTokenID) { + this.sendActivationCode(2); + } else { + // this.checkUserAuthentication(2); + } + // } + } + } + + public sendActivationCode(type: number) { + let request = new SendActivationByType(); + this.authService.setPublicFields(request); + request.OTP_SendType = type; + request.MobileNumber = this.loginData.MobileNumber; + request.IsMobileFingerPrint =0; + request.P_USER_NAME=this.loginData.P_USER_NAME; + request.LogInTokenID =this.loginData.LogInTokenID; + request.P_LEGISLATION_CODE ="SA"; + // request.VersionID ="2.0"; + + + + // request.LanguageID = imeiData && imeiData.PreferredLanguage || request.LanguageID; + this.authService + .sendActivationCodeByType( + request, + () => { }, + this.ts.trPK("general", "ok") + ) + .subscribe((result: any) => { + if (result.isSMSSent) { + this.cs.sharedService.setSharedData({ + MobileNumber: this.loginData.mobileNumber, + loginType: this.selectedOption + }, + SMSCheckRequest.SHARED_DATA + ); + + this.cs.openSMSPage(); + } + }); + } + + loginWithFingurePrint(el: any) { + if (!el.disabled) { + this.startBiometricLoginIfAvailable(); + } + } + faceReconization(el: any) { + if (!el.disabled) { + this.startBiometricLoginIfAvailable(); + } + } + + private startBiometricLoginIfAvailable() { + // this.setting.isBiometricsEnabled().then(result => { + // console.log(result); + this.faio.isAvailable().then( + options => { + // if biometric supported + //if (result) { + // ask if login with face or finger + this.presentBiometricDialog(); + // } else { + // //ask to enable biometric + // this.getPermissionToActivateBiometric(); + // } + }, + () => { + alert("not avaliable ") + // if biometric not supported do nothing unless + // user session time out from last login + // if (AuthenticationService.isRequireRelogin()) { + // this.initializeInputsFromSessionTimeOut(user); + // } + // this.hideSplashScreen(true); + } + ); + //}); + } + + private presentBiometricDialog() { + this.faio + .show({ + clientId: "Fingerprint Authetnciation", + clientSecret: "Ate343_9347lajF", // Only necessary for Android + disableBackup: true, // Only for Android(optional) + localizedFallbackTitle: this.ts.trPK("general", "use-pin"), // Only for iOS + localizedReason: this.ts.trPK("general", "auth-please") // Only for iOS + }) + .then((result: any) => { + console.log("1"); + // this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); + let request = new GetLoginInfoRequest(); + this.authService.setPublicFields(request); + request.MobileNumber = this.loginData.MobileNumber; + request.P_USER_NAME=this.loginData.P_USER_NAME; + request.UserName=this.loginData.P_USER_NAME; + request.LogInTokenID =this.loginData.LogInTokenID; + request.CompanyID =1;//cs=1 , HMG=2 + request.DeviceType= this.cs.getDeviceType(); + request.DeviceToken=this.deviceToken; + + this.getMobileInfo(request); + }) + .catch((error: any) => { + console.log(error); + }); + } + + private getMobileInfo(request: GetLoginInfoRequest) { + console.log("2"); + + this.authService.getLoginInfo(request,() => { },this.ts.trPK("general", "ok")).subscribe((result: GetLoginInfoResponse) => { + console.log("authService.getLoginInfo"); + if(result.Mohemm_GetPatientID_List.length > 0){ + if ( result.Mohemm_GetPatientID_List[0].LoginType == 2 || result.Mohemm_GetPatientID_List[0].LoginType == 3) { + this.loginTokenID = result.LogInTokenID; + this.checkSMS(); + } else { + + this.onlySMSBox = false; + this.button(); + } + }else { + this.onlySMSBox = false; + this.button(); + + } + }); + } + + public checkSMS() { + const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); + const request = new SMSCheckRequest(); + + request.LogInTokenID = data.LogInTokenID; + request.activationCode = ""; + request.P_USER_NAME = data.P_USER_NAME; + request.MobileNumber = data.MobileNumber; + + this.authService + .checkSMS(request, () => {}, this.ts.trPK("general", "ok")) + .subscribe((result: SMSCheckResponse) => { + console.log(result); + if (this.cs.validResponse(result)) { + AuthenticationService.servicePrivilage=result.Privilege_List; + this.authService.setAuthenticatedUser(result).subscribe(() => { + this.insertMobileLogin(); + this.cs.openHome(); + }); + } + }); + } + + + public insertMobileLogin(){ + let request = new GetLoginInfoRequest(); + this.authService.setPublicFields(request); + request.MobileNumber = this.loginData.MobileNumber; + request.P_USER_NAME=this.loginData.P_USER_NAME; + request.UserName=this.loginData.P_USER_NAME; + request.LogInTokenID =this.loginData.LogInTokenID; + request.CompanyID =1;//CompanyID + request.DeviceType= this.cs.getDeviceType(); + request.DeviceToken=this.deviceToken; + //request.TokenID= + request.LoginType=this.selectedOption; + + this.authService + .insertMobileLoginInfo( + request, + () => { }, + this.ts.trPK("general", "ok") + ) + .subscribe((result: any) => { + console.log(result); + +console.log("succssful insertMobileLoginInfo" ); + }); + +} + +} \ 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 7284b5d9..7e05e0b5 100644 --- a/Mohem/src/app/authentication/login/login.component.ts +++ b/Mohem/src/app/authentication/login/login.component.ts @@ -121,7 +121,7 @@ export class LoginComponent implements OnInit, OnDestroy { this.handleAppUpdate(result) }); } else if (result.MessageStatus == 1) { - this.checkUserAuthentication(); + this.checkUserAuthentication(); } }); } @@ -164,7 +164,10 @@ export class LoginComponent implements OnInit, OnDestroy { this.sharedData.setSharedData(this.loginData, AuthenticationService.LOGIN_DATA); this.cs.sharedService.setSharedData(this.loginData.P_USER_NAME, LoginRequest.SHARED_DATA); this.remeberMyInfo(); - this.cs.openSMSPage(); + //this.cs.openSMSPage(); phase#1 one type of OTP + this.cs.openConfirmLoginPage();//phase#2 add 4 types for OTP + + } else { console.log("result.IsPasswordExpired"); console.log(result.IsPasswordExpired); diff --git a/Mohem/src/app/authentication/models/sendActivationByType.ts b/Mohem/src/app/authentication/models/sendActivationByType.ts new file mode 100644 index 00000000..76d2f29e --- /dev/null +++ b/Mohem/src/app/authentication/models/sendActivationByType.ts @@ -0,0 +1,34 @@ +import { Request } from 'src/app/hmg-common/services/models/request'; + +export class SendActivationByType extends Request { + P_USER_NAME: string; // id + UserName:string; + MobileNumber: string; // phone number + ZipCode: string; + LogInTokenID: string; + OTP_SendType:number; + IsMobileFingerPrint:number; + P_LEGISLATION_CODE:string; + // VersionID:string; + + + +// Test +//{ +// "Channel":31, +// "LanguageID":2, +// "LogInTokenID":"Wfm9uDlWhEi3vFsQMqUz3w==", +// "MobileNumber":"0508079569", +// "P_USER_NAME":"191817", +// "UserName":"191817", +// "VersionID":2.0, +// "P_LEGISLATION_CODE":"SA", +// "IsMobileFingerPrint":0, +// "OTP_SendType":1 +// } + + + + + +} \ No newline at end of file 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 ec0d79eb..f2dd4a85 100644 --- a/Mohem/src/app/authentication/sms-page/sms-page.page.ts +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.ts @@ -9,6 +9,7 @@ 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 { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request'; @Component({ selector: "app-sms-page", @@ -33,7 +34,8 @@ export class SmsPageComponent implements OnInit { public isExpiredPwd: boolean = false; public count: number = 0; private loginData = new LoginModel(); - + public deviceToken:any; + public loginTypeData:any; constructor( public navCtrl: NavController, public translate: TranslatorService, @@ -51,6 +53,18 @@ export class SmsPageComponent implements OnInit { this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false; this.isExpiredPwd = this.sharedData.getSharedData(Password.IS_EXPIRED_PSW) || false; + this.loginData= this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); + console.log("loginData : "+ this.loginData); + this.deviceToken= this.common.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); + if(this.deviceToken == undefined){ + this.deviceToken = localStorage.getItem("deviceToken"); + + } + console.log("deviceToken :"+this.deviceToken); + this.loginTypeData= this.common.sharedService.getSharedData(SMSCheckRequest.SHARED_DATA, false); + console.log("loginType :"+this.loginTypeData.loginType); + + } initTimer() { @@ -134,6 +148,7 @@ export class SmsPageComponent implements OnInit { } public checkSMS() { + // alert("checkSMS in page") const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const request = new SMSCheckRequest(); @@ -149,12 +164,39 @@ export class SmsPageComponent implements OnInit { if (this.common.validResponse(result)) { AuthenticationService.servicePrivilage=result.Privilege_List; this.authService.setAuthenticatedUser(result).subscribe(() => { + //call insert Mobile Login + this.insertMobileLogin(); this.common.openHome(); + }); } }); } + public insertMobileLogin(){ + // alert("insertMobileLogin"); + let request = new GetLoginInfoRequest(); + this.authService.setPublicFields(request); + request.MobileNumber = this.loginData.MobileNumber; + request.P_USER_NAME=this.loginData.P_USER_NAME; + request.UserName=this.loginData.P_USER_NAME; + request.LogInTokenID =this.loginData.LogInTokenID; + request.CompanyID =1;//CompanyID + request.DeviceType= this.common.getDeviceType(); + request.DeviceToken=this.deviceToken; + request.LoginType=this.loginTypeData.loginType; + this.authService + .insertMobileLoginInfo( + request, + () => { }, + this.translate.trPK("general", "ok") + ) + .subscribe((result: any) => { + +console.log("successful insertMobileLogin" ); + }); + } + public checkForgetPwdSMS() { const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const request = new SMSCheckRequest(); 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 75b2e85d..1e615403 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -31,6 +31,7 @@ import { SMSCheckResponse } from "./models/smscheck.response"; import { ForgetPassword } from 'src/app/authentication/models/forget.password'; import { CheckAppVersionResponse } from './models/check-app-version.response'; import { PrivilageModel } from './models/privilage-model'; +import { SendActivationByType } from 'src/app/authentication/models/sendActivationByType'; @Injectable({ providedIn: "root" @@ -53,6 +54,10 @@ export class AuthenticationService { public static smsCheckForget='Services/ERP.svc/REST/CheckPublicActivationCode'; public static smsSendCode='Services/ERP.svc/REST/SendPublicActivationCode'; + public static sendActivationCodeByType = 'Services/ERP.svc/REST/Mohemm_SendActivationCodebyOTPNotificationType'; + public static getMobileLoginInfo ='Services/ERP.svc/REST/Mohemm_GetMobileLoginInfo'; + public static insertMobileLoginInfo ='Services/ERP.svc/REST/Mohemm_InsertMobileLoginInfo'; + /* register methods */ public static checkPatientForRegisterationURL = 'Services/Authentication.svc/REST/CheckPatientForRegisteration'; @@ -75,7 +80,9 @@ export class AuthenticationService { public static FAMILY_LOGIN_EVENT = 'family-login-event'; public static AUTHENTICATED_USER_KEY = 'save-authenticated-user'; public static LOGIN_DATA="logindata"; - + public static DEVICE_TOKEN = "device_token"; + public static LAST_LOGIN = 'last-login'; + // private static user: AuthenticatedUser; constructor( @@ -118,7 +125,7 @@ export class AuthenticationService { } public setPublicFields(request: Request): Request { - request.VersionID = 1.4; + request.VersionID = 2.0;//2.0,1.4 request.Channel = 31; request.LanguageID = TranslatorService.getCurrentLanguageCode(); //request.IPAdress = '10.10.10.10'; @@ -303,7 +310,7 @@ export class AuthenticationService { ): Observable { this.setPublicFields(request); return this.con.post( - AuthenticationService.getLoginInfoURL, + AuthenticationService.getMobileLoginInfo, request, onError, errorLabel @@ -546,6 +553,14 @@ export class AuthenticationService { return this.con.post(AuthenticationService.forgotFileIDURL, request, onError, errorLabel); } + + + public insertMobileLoginInfo(request: GetLoginInfoRequest,onError: any, errorLabel: string): Observable { + this.authenticateRequest(request); + + return this.con.post(AuthenticationService.insertMobileLoginInfo,request,onError,errorLabel); + } + public isSAUDIIDValid(id: string): boolean { if (!id) { @@ -673,4 +688,21 @@ export class AuthenticationService { ); } } -} + //**************************// + + public sendActivationCodeByType( + request: SendActivationByType, + onError: any, + errorLabel: string + ): Observable { + this.setPublicFields(request); + //below afifi code + //return this.con.post(AuthenticationService.checkUserAuthURL, request, onError, errorLabel); //afifi code, edit it to display the error msg into pop up ofverfication code + + return this.con.post( + AuthenticationService.sendActivationCodeByType, + request, + onError, + errorLabel + ); + }} diff --git a/Mohem/src/app/hmg-common/services/authentication/models/get-login-info.request.ts b/Mohem/src/app/hmg-common/services/authentication/models/get-login-info.request.ts index 77e5cc74..46671721 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/get-login-info.request.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/get-login-info.request.ts @@ -4,28 +4,32 @@ import { AuthenticatedUser } from './authenticated-user'; import { CountryCode } from 'src/app/hmg-common/ui/mobile-number/international-mobile/models/country-code.model'; export class GetLoginInfoRequest extends Request { - NationalID: string; - MobileNo: string; + UserName: string; + MobileNumber: string; + LogInTokenID: string; DeviceToken: string; - PatientID: number; - ProjectOutSA: boolean; - LoginType: number; // 2 by patient id , 1 by identification number - ZipCode: string; - PatientMobileNumber: string; // same as mobileNO, - SearchType: number; // 2 - PatientIdentificationID: string // "" - isRegister: boolean; // false - constructor(user: AuthenticatedUser) { - super(); + LanguageID: number; + P_USER_NAME: string; + Channel:number; + CompanyID:number; + DeviceType:string; + LoginType:number; + // constructor(user: AuthenticatedUser) { + // super(); // this.NationalID = user.IdentificationNo; // this.MobileNo = this.PatientMobileNumber = user.MobileNo; // this.DeviceToken = user.deviceToken; // this.PatientID = user.PatientID; // this.ProjectOutSA = user.PatientOutSA ; - this.LoginType = 2; - this.ZipCode = CountryCode.localCode( user.ZipCode); - this.SearchType = 2; - this.PatientIdentificationID = ''; - this.isRegister = false; - } + // this.LoginType = 2; + // this.ZipCode = CountryCode.localCode( user.ZipCode); + // this.SearchType = 2; + // this.PatientIdentificationID = ''; + // this.isRegister = false; + //} + + + + + } \ No newline at end of file diff --git a/Mohem/src/app/hmg-common/services/authentication/models/get-login-info.response.ts b/Mohem/src/app/hmg-common/services/authentication/models/get-login-info.response.ts index d60318b6..a43ece48 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/get-login-info.response.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/get-login-info.response.ts @@ -5,5 +5,7 @@ export class GetLoginInfoResponse extends Response { SMSLoginRequired: boolean; isSMSSent: boolean; LogInTokenID: string; - PatientOutSA: boolean; + Mohemm_GetPatientID_List:any + isActiveCode: boolean; + // PatientOutSA: boolean; } \ No newline at end of file diff --git a/Mohem/src/app/hmg-common/services/authentication/models/smscheck.request.ts b/Mohem/src/app/hmg-common/services/authentication/models/smscheck.request.ts index 39dea594..1265b04c 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/smscheck.request.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/smscheck.request.ts @@ -4,4 +4,6 @@ import { Request } from 'src/app/hmg-common/services/models/request'; export class SMSCheckRequest extends Request { LogInTokenID: string ; activationCode?: string; + public static SHARED_DATA = 'check_activation_shared_data'; + } \ No newline at end of file diff --git a/Mohem/src/app/hmg-common/services/common/common.service.ts b/Mohem/src/app/hmg-common/services/common/common.service.ts index 635b6dda..0362734e 100644 --- a/Mohem/src/app/hmg-common/services/common/common.service.ts +++ b/Mohem/src/app/hmg-common/services/common/common.service.ts @@ -437,7 +437,9 @@ export class CommonService { public getDeviceType(): string { if (this.platform.is("mobile")) { - return "Mobile " + (this.platform.is("ios") ? "Iphone" : "android"); + // return "Mobile " + (this.platform.is("ios") ? "Iphone" : "android"); + return (this.platform.is("ios") ? "Iphone" : "android"); + } else { return "Desktop"; } @@ -1017,6 +1019,9 @@ export class CommonService { public openDeductionsPage() { this.nav.navigateForward(["/payslip/Deductions"]); } + public openConfirmLoginPage() { + this.nav.navigateForward(["/authentication/confirmLogin"]); + } public reload(url: string, from: string) { console.log("force reload called from:" + from); diff --git a/Mohem/src/app/hmg-common/services/models/request.ts b/Mohem/src/app/hmg-common/services/models/request.ts index 2ff1aed9..1a9e8fd2 100644 --- a/Mohem/src/app/hmg-common/services/models/request.ts +++ b/Mohem/src/app/hmg-common/services/models/request.ts @@ -18,4 +18,8 @@ export class Request { public P_MOBILE_NUMBER: string; public P_EMAIL_ADDRESS: string; public P_NOTIFICATION_ID: number; + + // public P_LEGISLATION_CODE: string; + // public OTP_SendType: number; + // public IsMobileFingerPrint: boolean; } 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 c4d4ea72..b5490471 100644 --- a/Mohem/src/app/hmg-common/services/push/push.service.ts +++ b/Mohem/src/app/hmg-common/services/push/push.service.ts @@ -16,16 +16,16 @@ import { SessionModel } from './models/session.model'; import { AuthenticatedUser } from '../authentication/models/authenticated-user'; // import { NotificationsCenterService } from 'src/app/eservices/notifications-center/service/notifications-center.service'; // import { NotificationsComponent } from 'src/app/eservices/notifications-center/notifications/notifications.component'; - - +import {OneSignal} from '@ionic-native/onesignal/ngx' @Injectable({ providedIn: 'root' }) export class PushService { private static notLoggedInUserURL = 'Services/MobileNotifications.svc/REST/PushNotification_InsertPatientDeviceInformation'; private static loggedInUserURL = 'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo'; + public static SENDER_ID = '679409052782';//'815750722565'; - public static CHANNEL_ID = '815750722565'; + public static CHANNEL_ID = '679409052782';//'815750722565'; constructor( // public push: Push, public cs: CommonService, @@ -36,14 +36,16 @@ export class PushService { private authService: AuthenticationService, public ngZone: NgZone, // public notifyService: NotificationsCenterService, - public events: Events + public events: Events, + private oneSignal: OneSignal, + ) { } public startReceiving() { this.processStartReceiving(); } - private processStartReceiving() { + private processStartReceiving1() { // if (this.cs.isCordova()) { // this.stopNotifications(() => { // this.push.hasPermission() @@ -158,6 +160,7 @@ export class PushService { } private registerInBackend(data: any) { + console.log("registerInBackend"); if (this.authService.isAuthenticated()) { this.registerAuthenticatedUser(data.registrationId); } else { @@ -207,4 +210,57 @@ export class PushService { } + + private processStartReceiving() { + console.log('processStartReceiving'); + + console.log("processStartReceiving openConference"); + this.oneSignal.startInit('8d9b8313-0365-4934-a2a9-fdee5aeac66e', PushService.SENDER_ID); + this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification); + this.oneSignal.handleNotificationReceived().subscribe(data => this.onPushReceived(data.payload)); + this.oneSignal.handleNotificationOpened().subscribe(data => this.onPushOpened(data.notification.payload)); + console.log("this.oneSignal: "+ this.oneSignal.getIds()); + this.oneSignal.endInit(); + this.oneSignal.getIds().then(result => { + console.log("result.userId: " +result.userId); + + //there is no part for notLoggedInUserURL () as patient app + if(result.userId){ + this.cs.sharedService.setSharedData(result.userId, AuthenticationService.DEVICE_TOKEN); + localStorage.setItem("deviceToken", result.userId); + + } + + this.registerInBackend(result.userId); + }, err => { + console.log("getIds() error: "+err); + + }); + + // if (this.cs.isCordova()) { + // console.log('Notification Channel Called'); + + // if (this.platform.is('android')) { + // this.stopNotifications(() => { + + // }); + // } else { + // //initialize code + // } + // } + } + public onPushReceived(payload: any) { + console.log(JSON.parse(JSON.stringify(payload))); + console.log('Push-Received whole payload: ' + payload); + } + + public onPushOpened(payload: any) { + console.log(JSON.parse(JSON.stringify(payload))); + console.log('Push-opened whole payload: ' + payload); + console.log("onPushOpened openConference"); + this.processNotification(payload); + } + + + } diff --git a/Mohem/src/app/hmg-common/ui/button/button.component.html b/Mohem/src/app/hmg-common/ui/button/button.component.html index 08f3b9c6..31b8632f 100644 --- a/Mohem/src/app/hmg-common/ui/button/button.component.html +++ b/Mohem/src/app/hmg-common/ui/button/button.component.html @@ -7,7 +7,7 @@ --> - \ No newline at end of file diff --git a/Mohem/src/app/hmg-common/ui/button/button.component.scss b/Mohem/src/app/hmg-common/ui/button/button.component.scss index 7ef033f0..f62e14ac 100644 --- a/Mohem/src/app/hmg-common/ui/button/button.component.scss +++ b/Mohem/src/app/hmg-common/ui/button/button.component.scss @@ -11,11 +11,11 @@ border-width: 0.02cm; } -.custom-button:hover { - -webkit-box-shadow: 0px 0px 8px 2px #d1212747;; - -moz-box-shadow: 0px 0px 8px 2px #d1212747;; - box-shadow: 0px 0px 8px 2px #d1212747;; -} +// .custom-button:hover { +// -webkit-box-shadow: 0px 0px 8px 2px #d1212747;; +// -moz-box-shadow: 0px 0px 8px 2px #d1212747;; +// box-shadow: 0px 0px 8px 2px #d1212747;; +// } diff --git a/Mohem/src/app/hmg-common/ui/button/button.component.ts b/Mohem/src/app/hmg-common/ui/button/button.component.ts index 746c4ae7..a88d0184 100644 --- a/Mohem/src/app/hmg-common/ui/button/button.component.ts +++ b/Mohem/src/app/hmg-common/ui/button/button.component.ts @@ -8,13 +8,9 @@ import { TranslatorService } from '../../services/translator/translator.service' styleUrls: ['./button.component.scss'], }) export class ButtonComponent implements OnInit { - constructor() { - } - ngOnInit() { - - } - /* + @Input() strong: boolean; + @Input() class: any = ''; @Input() icon: string; @Input() title: string; @Output() trigger = new EventEmitter(); @@ -29,7 +25,7 @@ export class ButtonComponent implements OnInit { } ngOnInit() { - this.direction = TranslatorService.getCurrentDirection(); + this.direction = TranslatorService.getCurrentLanguageName(); if (this.settings) { this.style = { @@ -40,13 +36,19 @@ export class ButtonComponent implements OnInit { }; } - + /* + const element = document.getElementById('modal'); + element.addEventListener('click', e => { + e.stopImmediatePropagation(); + }); + */ } private isEnabled(enabled: boolean): string { - return enabled ? '30px' : '0px'; + return enabled ? '6px' : '0px'; } public onClicked() { + console.log(this.disabled); if (!this.disabled) { this.trigger.emit(); } @@ -62,17 +64,20 @@ export class Modal implements OnInit { ngOnInit() { console.log(' on initialization'); + //this.elRef.nativeElement.addEventListener('mouseenter', this.onMouseEnter); } ngOnDestroy() { + // this.elRef.nativeElement.removeEventListener('mouseenter', this.onMouseEnter); } onMouseEnter() { + // alert("Don't touch my bacon!") } @HostListener('click', ['$event']) onClick(event: any) { - alert('click'); + // alert('click'); + // event.preventPropagation(); } - */ } diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts index fd491b15..dc33107e 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts @@ -116,7 +116,7 @@ export class WorklistMainComponent implements OnInit { this.worklistMainService .getPRNotificationBody(notificationBodyObj) .subscribe((result: PRNotificatonBodyResponse) => { - //this.handleWorkListBodyResult(result, "MO"); + this.handleWorkListBodyResult(result, "PR"); }); } @@ -168,10 +168,17 @@ export class WorklistMainComponent implements OnInit { this.notificationBodyRes = result.GetAbsenceCollectionNotificationBodyList; } + }else if (Type == "PR") { + if (result.GetAbsenceCollectionNotificationBodyList) { + this.notificationBodyRes = + result.GetAbsenceCollectionNotificationBodyList; + } } } } //End handleWorkListBodyResult + + getNotificationButtons(notificationButtonsObj) { this.worklistMainService .getNotificationButtons(notificationButtonsObj) diff --git a/Mohem/src/app/payslip/service/payslip.service.ts b/Mohem/src/app/payslip/service/payslip.service.ts index cb650ca6..0ef5274f 100644 --- a/Mohem/src/app/payslip/service/payslip.service.ts +++ b/Mohem/src/app/payslip/service/payslip.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { ConnectorService } from '../../hmg-common/services/connector/connector.service'; import { AuthenticationService } from '../../hmg-common/services/authentication/authentication.service'; -import { Observable } from 'rxjs'; +import { Observable } from 'node_modules/@angular/cli/node_modules/rxjs'; @Injectable({ providedIn: 'root' diff --git a/Mohem/src/assets/icon/login/101.png b/Mohem/src/assets/icon/login/101.png new file mode 100644 index 00000000..90c1c575 Binary files /dev/null and b/Mohem/src/assets/icon/login/101.png differ diff --git a/Mohem/src/assets/icon/login/102.png b/Mohem/src/assets/icon/login/102.png new file mode 100644 index 00000000..8502d197 Binary files /dev/null and b/Mohem/src/assets/icon/login/102.png differ diff --git a/Mohem/src/assets/icon/login/103.png b/Mohem/src/assets/icon/login/103.png new file mode 100644 index 00000000..3326814b Binary files /dev/null and b/Mohem/src/assets/icon/login/103.png differ diff --git a/Mohem/src/assets/icon/login/104.png b/Mohem/src/assets/icon/login/104.png new file mode 100644 index 00000000..ad55ff74 Binary files /dev/null and b/Mohem/src/assets/icon/login/104.png differ diff --git a/Mohem/src/assets/localization/i18n.json b/Mohem/src/assets/localization/i18n.json index 9e7c7646..92d8da00 100644 --- a/Mohem/src/assets/localization/i18n.json +++ b/Mohem/src/assets/localization/i18n.json @@ -104,6 +104,46 @@ "password-expired": { "en": "Your password has been expired. Kindly change your password to login again.", "ar": "كلمة المرور الخاصة بك قد انتهت صلاحيتها. يرجى تغيير كلمة المرور لتسجيل الدخول مرة أخرى." + }, + "verify-login": { + "en": "Verify Login", + "ar": "تحقق من تسجيل الدخول" + }, + "verify-login-with": { + "en": "Please verify login with one of the following options", + "ar": "الرجاء التحقق من تسجيل الدخول باستخدام أحد هذه الخيارات" + }, + "verify-with-fingerprint": { + "en": "Verify with fingerprint", + "ar": "تحقق باستخدام بصمة" + }, + "verify-with-faceid": { + "en": "Verify with face ID", + "ar": "تحقق باستخدام معرف الوجه" + }, + "verify-with-sms": { + "en": "Verify with SMS", + "ar": "تحقق مع الرسائل القصيرة" + }, + "verify-with-whatsapp": { + "en": "Verify with Whatsapp", + "ar": "تحقق مع Whatsapp" + }, + "last-login": { + "en": "Last login at:", + "ar": ":آخر تسجيل دخول" + }, + "last-login-with": { + "en": "Last login using:", + "ar": "آخر تسجيل دخول مع" + }, + "biometric-support": { + "en": "It seems that your phone is supporting biometric feature, do you want login with with biometric?", + "ar": "يبدو أن هاتفك يدعم ميزة البيومترية ، هل تريد تسجيل الدخول باستخدام البيومترية؟" + }, + "verify-fingerprint": { + "en": "To activate fingerprint login service, please verify by using one of the following options. ", + "ar": "لتفعيل خدمة الدخول بالبصمة، يرجى التحقق من خلال احدى الخيارات التالية" } }, "verificationcode": {