From 57be247a0a635c9919083c5fd559a59bee1366b9 Mon Sep 17 00:00:00 2001 From: enadhilal Date: Thu, 20 Jan 2022 14:43:35 +0300 Subject: [PATCH] fixed change password in welcome page and added CONTACT request type in worklist --- .../confirm-login/confirm-login.component.ts | 87 ++++++++++++++++--- .../service/work-list.main.service.ts | 16 ++++ .../worklist-main.component.html | 8 +- .../worklist-main/worklist-main.component.ts | 17 ++++ Mohem/src/theme/styles.scss | 2 +- 5 files changed, 116 insertions(+), 14 deletions(-) diff --git a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts index 4be507ff..10e04150 100644 --- a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts +++ b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts @@ -12,7 +12,7 @@ import { GetLoginInfoResponse } from '../../hmg-common/services/authentication/m 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'; -import { ModalController, Platform } from '@ionic/angular'; +import { ModalController, Platform, AlertController } from '@ionic/angular'; import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response'; import { LoginModel } from '../models/LoginModel'; import * as moment from 'moment'; @@ -20,6 +20,8 @@ import { CheckAppVersionResponse } from 'src/app/hmg-common/services/authenticat import { NFC } from "@ionic-native/nfc/ngx"; import { DigitalIdComponent } from '../digital-id/digital-id.component'; import { AppUpdateComponent } from '../app-update/app-update.component'; +import { Password } from '../models/password'; +import { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request'; @Component({ selector: 'app-confirm-login', @@ -54,7 +56,7 @@ export class ConfirmLoginComponent implements OnInit { direction: string; userInfo: any; public businessInfo: object; - + private checkUserResult: CheckUserAuthenticationResponse; constructor( public ts: TranslatorService, public cs: CommonService, @@ -64,6 +66,7 @@ export class ConfirmLoginComponent implements OnInit { public pushService: PushService, public platform: Platform, public modalController: ModalController, + public alertController: AlertController, private nfc: NFC ) { this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); @@ -376,7 +379,7 @@ export class ConfirmLoginComponent implements OnInit { job_ar: result.MemberInformationList[0].JOB_NAME_Ar, mobile: result.MemberInformationList[0].MobileNumberWithZipCode, qr: result.MemberInformationList[0].BusinessCardQR, - company_logo: result.BC_Logo ? result.BC_Logo: result.CompanyImageURL, + company_logo: result.BC_Logo ? result.BC_Logo : result.CompanyImageURL, company_url: result.BC_Domain, company_type: result.CompanyMainCompany, email: result.MemberInformationList[0].EMPLOYEE_EMAIL_ADDRESS @@ -446,13 +449,77 @@ export class ConfirmLoginComponent implements OnInit { this.confirm(this.loginType); } else { if (result.IsPasswordExpired) { - // alert("dont forget to handelpresentPasswordExpiredDialog() "); - // this.presentPasswordExpiredDialog(); ***** + this.presentPasswordExpiredDialog(); } } }); } + async presentPasswordExpiredDialog() { + const alert = await this.alertController.create({ + header: this.ts.trPK('general', 'confirm'), + message: this.ts.trPK('login', 'password-expired'), + buttons: [ + { + text: this.ts.trPK('general', 'ok'), + handler: () => { + console.log('Confirm Okay'); + this.sharedData.setSharedData(true, Password.IS_EXPIRED_PSW); + this.userCheck(); + } + } + ] + }); + await alert.present(); + } + + public userCheck() { + this.cs.startLoading(); + const request = new CheckUserAuthenticationRequest(); + request.P_USER_NAME = this.username; + this.authService.checkUserAuthentication( + request, + () => { + /* Write code for error */ + }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { + if (this.cs.validResponse(result)) { + this.checkUserResult = result; + this.cs.stopLoading(); + this.sendSMSForForgotPassword(); + } + }); + } + + + private sendSMSForForgotPassword() { + this.cs.startLoading(); + const changePwdObj = new LoginRequest(); + changePwdObj.MobileNumber = this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER; + changePwdObj.P_USER_NAME = this.username; + changePwdObj.P_MOBILE_NUMBER = this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER; + this.authService.sendPublicSMS( + changePwdObj, + () => { + // this.sendSMSForForgotPassword(); + /* Write code for error */ + }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { + if (this.cs.validResponse(result)) { + this.checkUserResult = result; + console.log('2'); + console.log(result); + this.loginData.LogInTokenID = result.LogInTokenID; + this.loginData.P_USER_NAME = this.username; + // this.loginData.EmployeeName =result.MemberLoginList[0].EMPLOYEE_NAME; + + this.cs.sharedService.setSharedData(this.loginData.P_USER_NAME, LoginRequest.SHARED_DATA); + this.sharedData.setSharedData(this.loginData, AuthenticationService.LOGIN_DATA); + this.sharedData.setSharedData(true, Password.IS_FORGET_PSW); + this.cs.stopLoading(); + this.cs.openSMSPage(); + } + }); + } + private handleAppUpdate(result) { this.iosLink = result.IOSLink; this.androidLink = result.AndroidLink; @@ -478,14 +545,14 @@ export class ConfirmLoginComponent implements OnInit { }); } - async appUpdate(msg, result) { + async appUpdate(msg, result) { const modal = await this.modalController.create({ component: AppUpdateComponent, cssClass: 'app-update-modal-css', - componentProps: {'msg':msg} + componentProps: { 'msg': msg } }); modal.onDidDismiss().then((data) => { - this.handleAppUpdate(result); + this.handleAppUpdate(result); }); return await modal.present(); } @@ -517,9 +584,9 @@ export class ConfirmLoginComponent implements OnInit { let buttonSelected; this.buttons.forEach(element => { element.forEach(elementValue => { - if(typeNumber === elementValue.value){ + if (typeNumber === elementValue.value) { buttonSelected = elementValue; - }else{ + } else { elementValue.visible = false; } }); diff --git a/Mohem/src/app/notification/service/work-list.main.service.ts b/Mohem/src/app/notification/service/work-list.main.service.ts index bfd42c63..d83f642e 100644 --- a/Mohem/src/app/notification/service/work-list.main.service.ts +++ b/Mohem/src/app/notification/service/work-list.main.service.ts @@ -33,6 +33,7 @@ export class WorklistMainService { public static getBasicDetailNotificationBody = "Services/ERP.svc/REST/GET_BASIC_DET_NTF_BODY"; public static getPhoneNotificationBody = "Services/ERP.svc/REST/GET_PHONES_NOTIFICATION_BODY"; public static getTerminationNotificationBody = "Services/ERP.svc/REST/GET_TERM_NOTIFICATION_BODY"; + public static getContactNotificationBody = "Services/ERP.svc/REST/GET_CONTACT_NOTIFICATION_BODY"; public static getStampMSNotificationBody = "Services/ERP.svc/REST/GET_STAMP_MS_NOTIFICATION_BODY"; public static getStampNSNotificationBody = "Services/ERP.svc/REST/GET_STAMP_NS_NOTIFICATION_BODY"; public static getAddressNotificationBody = "Services/ERP.svc/REST/GET_ADDRESS_NOTIFICATION_BODY"; @@ -222,6 +223,21 @@ export class WorklistMainService { ); } + public getContactNotificationBody( + WorkListBodyRequest: any, + onError?: any, + errorLabel?: string + ): Observable { + const request = WorkListBodyRequest; + this.authService.authenticateRequest(request); + return this.api.post( + WorklistMainService.getContactNotificationBody, + request, + onError, + errorLabel + ); + } + public getPOItemHistory( POItemHistoryReq: any, onError?: any, diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.html b/Mohem/src/app/notification/worklist-main/worklist-main.component.html index dd8138e2..c093dc71 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.html +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.html @@ -48,7 +48,8 @@ @@ -293,9 +294,10 @@ - +
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 3cfa8951..5fcabd74 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts @@ -292,6 +292,8 @@ export class WorklistMainComponent implements OnInit { this.getTerminationNotificationDetails(this.WorkListBodyObj); } else if (this.getPassNotificationDetails.REQUEST_TYPE === 'PHONE_NUMBERS') { this.getPhoneNotificationDetails(this.WorkListBodyObj); + } else if (this.getPassNotificationDetails.REQUEST_TYPE === 'CONTACT') { + this.getContactNotificationDetails(this.WorkListBodyObj); } } @@ -327,6 +329,14 @@ export class WorklistMainComponent implements OnInit { }); } + getContactNotificationDetails(notificationBodyObj) { + this.worklistMainService + .getContactNotificationBody(notificationBodyObj) + .subscribe((result: PRNotificatonBodyResponse) => { + this.handleWorkListBodyResult(result, "CONTACT"); + }); + } + getBasicDetailsNotification(notificationBodyObj) { this.worklistMainService .getBasicDetailNotificationBody(notificationBodyObj) @@ -455,6 +465,13 @@ export class WorklistMainComponent implements OnInit { console.log(result); } } + else if (Type === "CONTACT"){ + if (result.GetContactNotificationBodyList) { + this.notificationBodyRes = + result.GetContactNotificationBodyList.ContactNotificationBody; + console.log(result); + } + } } } //End handleWorkListBodyResult diff --git a/Mohem/src/theme/styles.scss b/Mohem/src/theme/styles.scss index ea426604..73c0b0a2 100644 --- a/Mohem/src/theme/styles.scss +++ b/Mohem/src/theme/styles.scss @@ -1176,7 +1176,7 @@ border:0px } .logoHeader { - max-width: 130%; + max-width: 90%; width: 130%; border: 0px; }