fixed issues

MOHEMM-Q3-DEV-LATEST
umasoodch 6 years ago
parent 74c2d4c6ca
commit 06226c89e7

@ -12,7 +12,8 @@ import { LazyLoadingService } from './hmg-common/services/lazy-loading/lazy-load
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
// import { SplashScreen } from '@ionic-native/splash-screen'; // import { SplashScreen } from '@ionic-native/splash-screen';
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { Router } from '@angular/router';
import { rejects } from 'assert';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -50,8 +51,8 @@ export class AppComponent implements OnInit, AfterViewInit {
private authService: AuthenticationService, private authService: AuthenticationService,
private sanitizer: DomSanitizer, private sanitizer: DomSanitizer,
public pushService: PushService, public pushService: PushService,
private splashScreen: SplashScreen private splashScreen: SplashScreen,
public router: Router,
) { ) {
this.events.subscribe('img-change', displayImg => { this.events.subscribe('img-change', displayImg => {
console.log('app compont: ' + displayImg); console.log('app compont: ' + displayImg);
@ -63,8 +64,6 @@ export class AppComponent implements OnInit, AfterViewInit {
} }
ngOnInit() { ngOnInit() {
this.initializeApp(); this.initializeApp();
} }
ngAfterViewInit() {} ngAfterViewInit() {}
initializeApp() { initializeApp() {
@ -94,6 +93,12 @@ export class AppComponent implements OnInit, AfterViewInit {
} }
subscribeEvents() { subscribeEvents() {
this.platform.backButton.subscribe(() => {
if (this.router.isActive('/authentication/login', true)) {
// tslint:disable-next-line: no-string-literal
navigator['app'].exitApp();
}
});
this.events.subscribe('setMenu', () => { this.events.subscribe('setMenu', () => {
const user = this.authService const user = this.authService
.loadAuthenticatedUser() .loadAuthenticatedUser()
@ -204,43 +209,26 @@ export class AppComponent implements OnInit, AfterViewInit {
} }
getLastLoginInfo() { getLastLoginInfo() {
console.log(' getLastLoginInfo');
console.log('get method :' + this.cs.getDeviceToken());
this.deviceToken = this.cs.getDeviceToken(); this.deviceToken = this.cs.getDeviceToken();
// this.cs.sharedService.getSharedData("new-device-token",false);// localStorage.getItem('devicyeToken'); // this.cs.sharedService.getSharedData("new-device-token",false);// localStorage.getItem('devicyeToken');
console.log('let deviceToken app' + this.cs.sharedService.getSharedData('new-device-token', false));
console.log('localStorage.getItem app' + localStorage.getItem('devicyeToken'));
console.log('sheard DEVICE_TOKEN' + this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false));
if (this.deviceToken) { if (this.deviceToken) {
console.log('login enabled first time: ' + this.deviceToken); console.log('login enabled first time: ' + this.deviceToken);
} else { } else {
console.log('no deviceToken' );
this.pushService.startReceiving(); this.pushService.startReceiving();
setTimeout(() => { setTimeout(() => {
this.deviceToken = localStorage.getItem('deviceToken'); this.deviceToken = localStorage.getItem('deviceToken');
console.log('login enabled second time: ' + this.deviceToken);
}, 1000); }, 1000);
} }
this.requestGetLoginInfo = { this.requestGetLoginInfo = {
DeviceType: this.cs.getDeviceType(), // 'Android', DeviceType: this.cs.getDeviceType(), // 'Android',
DeviceToken: this.deviceToken// "5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken DeviceToken: this.deviceToken// "5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken
}; };
this.authService.getLoginInfo(this.requestGetLoginInfo, () => {}, this.ts.trPK('general', 'ok')).subscribe(res => {
this.authService.getLoginInfo(this.requestGetLoginInfo, () => {}, this.ts.trPK('general', 'ok')).subscribe(res => {
if (this.cs.validResponse(res)) { if (this.cs.validResponse(res)) {
if (res.Mohemm_GetMobileLoginInfoList.length > 0) { if (res.Mohemm_GetMobileLoginInfoList.length > 0) {
this.cs.sharedService.setSharedData( this.cs.sharedService.setSharedData(
// res.Patient_SELECTDeviceIMEIbyIMEIList[0], // res.Patient_SELECTDeviceIMEIbyIMEIList[0],
res.Mohemm_GetMobileLoginInfoList[0], res.Mohemm_GetMobileLoginInfoList[0],
@ -254,31 +242,22 @@ export class AppComponent implements OnInit, AfterViewInit {
if (this.logoutFlage) { if (this.logoutFlage) {
this.cs.openLogin(); this.cs.openLogin();
} }
} else { } else {
this.user = false; this.user = false;
this.events.publish('user', this.user); this.events.publish('user', this.user);
setTimeout(() => { setTimeout(() => {
this.splashScreen.hide(); this.splashScreen.hide();
}, 3000); }, 3000);
if (this.logoutFlage) { if (this.logoutFlage) {
this.cs.openLogin(); this.cs.openLogin();
} }
} }
} else { } else {
// this.user = false; // this.user = false;
// this.splashScreen.hide(); // this.splashScreen.hide();
// if(this.logoutFlage){ // if(this.logoutFlage){
// this.cs.openLogin(); // this.cs.openLogin();
// } // }
} }
}); });

@ -1,70 +1,38 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import {ButtonSettings} from 'src/app/hmg-common/ui/button/models/button-settingsl';
import {ButtonSettings} from "src/app/hmg-common/ui/button/models/button-settingsl"; import {TranslatorService} from 'src/app/hmg-common/services/translator/translator.service';
import {TranslatorService} from "src/app/hmg-common/services/translator/translator.service";
import { CommonService } from 'src/app/hmg-common/services/common/common.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 { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; 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 { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
import { SendActivationByType } from '../models/sendActivationByType'; import { SendActivationByType } from '../models/sendActivationByType';
import { FingerprintAIO } from '@ionic-native/fingerprint-aio/ngx'; import { FingerprintAIO } from '@ionic-native/fingerprint-aio/ngx';
import { GetLoginInfoRequest } from '../../hmg-common/services/authentication/models/get-login-info.request';
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 { GetLoginInfoResponse } from "../../hmg-common/services/authentication/models/get-login-info.response"; import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.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'; import { PushService } from 'src/app/hmg-common/services/push/push.service';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response'; import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response';
import { LoginModel } from '../models/LoginModel'; import { LoginModel } from '../models/LoginModel';
import * as moment from "moment"; import * as moment from 'moment';
@Component({ @Component({
selector: 'app-confirm-login', selector: 'app-confirm-login',
templateUrl: './confirm-login.component.html', templateUrl: './confirm-login.component.html',
styleUrls: ['./confirm-login.component.scss'], styleUrls: ['./confirm-login.component.scss'],
}) })
export class ConfirmLoginComponent implements OnInit { export class ConfirmLoginComponent implements OnInit {
public logo = 'assets/icon/login/password.png';
public logo = "assets/icon/login/password.png";
public buttons: any = []; public buttons: any = [];
isFaceorFinger: any; isFaceorFinger: any;
onlySMSBox: any = true; onlySMSBox: any = true;
public loginData = new LoginModel(); public loginData = new LoginModel();
selectedOption: any; selectedOption: any;
lastLogin: any; lastLogin: any;
loginTokenID: any;
loginTokenID:any
deviceToken: any; deviceToken: any;
@Input() accessFromOutSide = false; @Input() accessFromOutSide = false;
@Input() visible = true; @Input() visible = true;
username: any; username: any;
@ -72,807 +40,318 @@ export class ConfirmLoginComponent implements OnInit {
loginType: any; loginType: any;
empname: string; empname: string;
lastLoginDate: string; lastLoginDate: string;
// tslint:disable-next-line: variable-name
user_name: string; user_name: string;
FFloginType: any; FFloginType: any;
public isPostNoLoad = true;
constructor( constructor(
public ts: TranslatorService, public ts: TranslatorService,
public cs: CommonService, public cs: CommonService,
public authService: AuthenticationService, public authService: AuthenticationService,
public sharedData: SharedDataService, public sharedData: SharedDataService,
private faio: FingerprintAIO, private faio: FingerprintAIO,
public pushService: PushService, public pushService: PushService,
public platform: Platform, public platform: Platform,
) { ) {
this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
console.log("logindata: "+this.loginData);
this.deviceToken = this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); this.deviceToken = this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
console.log("deviceToken :"+this.deviceToken);
// if device token undefind // if device token undefind
// tslint:disable-next-line: triple-equals
if (this.deviceToken == undefined) { if (this.deviceToken == undefined) {
this.deviceToken = localStorage.getItem('deviceToken');
this.deviceToken = localStorage.getItem("deviceToken");
} }
this.lastLogin = this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false); this.lastLogin = this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false);
this.username = localStorage.getItem('user');
this.username = localStorage.getItem("user"); this.password = localStorage.getItem('password');
this.password = localStorage.getItem("password"); this.empname = localStorage.getItem('emp-name');
this.empname = localStorage.getItem("emp-name");
} }
ngOnInit() { ngOnInit() {
// **checkIfAvailable FAIO **// // **checkIfAvailable FAIO **//
this.checkIfAvailable(); this.checkIfAvailable();
// **getSharedData of IMEI_USER_DATA and REGISTER_DATA_FOR_LOGIIN to set defult value **// // **getSharedData of IMEI_USER_DATA and REGISTER_DATA_FOR_LOGIIN to set defult value **//
this.username = localStorage.getItem("user"); this.username = localStorage.getItem('user');
this.password = localStorage.getItem("password"); this.password = localStorage.getItem('password');
this.empname = localStorage.getItem("emp-name"); this.empname = localStorage.getItem('emp-name');
// this.setDefault();
this.button(); this.button();
} }
checkIfAvailable() { checkIfAvailable() {
this.faio.isAvailable().then( this.faio.isAvailable().then(
options => { options => {
this.isFaceorFinger = options; this.isFaceorFinger = options;
// && this.lastLogin === 1
// if (this.isFaceorFinger === 'finger' || this.isFaceorFinger === 'biometric') {
// 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.button();
}, () => {
},
() => {
this.isFaceorFinger = null; this.isFaceorFinger = null;
this.button(); this.button();
} }
); );
} }
button() { button() {
console.log("button");
this.buttons = [ this.buttons = [
[{ [{
title: 'login,verify-with-fingerprint',
title: "login,verify-with-fingerprint",
url: null, url: null,
icon: 'assets/icon/login/102.png',
icon: "assets/icon/login/102.png",
settings: new ButtonSettings(true, true, true, true), settings: new ButtonSettings(true, true, true, true),
value: 2, value: 2,
disabled: this.isFaceorFinger === 'finger' || this.isFaceorFinger === 'biometric' ? false : true,
disabled: this.isFaceorFinger === "finger" || this.isFaceorFinger === "biometric" ? false : true,
visible: this.onlySMSBox, visible: this.onlySMSBox,
buttonClass: 'buttonClassWhite', buttonClass: 'buttonClassWhite',
pClass: 'pClassMyFileIconBlack', pClass: 'pClassMyFileIconBlack',
class: 'nationalIdIcon', class: 'nationalIdIcon',
}, },
{ {
title: 'login,verify-with-faceid',
title: "login,verify-with-faceid",
url: null, url: null,
icon: 'assets/icon/login/101.png',
icon: "assets/icon/login/101.png",
settings: new ButtonSettings(true, true, true, true), settings: new ButtonSettings(true, true, true, true),
value: 3, value: 3,
disabled: this.isFaceorFinger === 'face' ? false : true,
disabled: this.isFaceorFinger === "face" ? false : true,
visible: this.onlySMSBox, visible: this.onlySMSBox,
buttonClass: 'buttonClassWhite', buttonClass: 'buttonClassWhite',
pClass: 'pClassMyFileIconBlack', pClass: 'pClassMyFileIconBlack',
class: 'nationalIdIcon', class: 'nationalIdIcon',
}, },
{ {
title: 'login,verify-with-whatsapp',
title: "login,verify-with-whatsapp",
url: null, url: null,
icon: 'assets/icon/login/104.png',
icon: "assets/icon/login/104.png",
settings: new ButtonSettings(true, true, true, true), settings: new ButtonSettings(true, true, true, true),
value: 4, value: 4,
visible: true, visible: true,
buttonClass: 'buttonClassWhite', buttonClass: 'buttonClassWhite',
pClass: 'pClassMyFileIconBlack', pClass: 'pClassMyFileIconBlack',
class: 'nationalIdIcon', class: 'nationalIdIcon',
}, },
{ {
title: 'login,verify-with-sms',
title: "login,verify-with-sms",
url: null, url: null,
icon: 'assets/icon/login/103.png',
icon: "assets/icon/login/103.png",
settings: new ButtonSettings(true, true, true, true), settings: new ButtonSettings(true, true, true, true),
value: 1, value: 1,
visible: true, visible: true,
buttonClass: 'buttonClassWhite', buttonClass: 'buttonClassWhite',
pClass: 'pClassMyFileIconBlack', pClass: 'pClassMyFileIconBlack',
class: 'nationalIdIcon', class: 'nationalIdIcon'
}]
}
]
]; ];
} }
confirm(el: any) { confirm(el: any) {
console.log("confirm:"+ el );
this.selectedOption = this.selectedOption && !this.onlySMSBox ? this.selectedOption : el.value; this.selectedOption = this.selectedOption && !this.onlySMSBox ? this.selectedOption : el.value;
switch (el.value) { switch (el.value) {
case 1: case 1:
localStorage.setItem('login-type', el.value);
console.log(el.value);
localStorage.setItem("login-type",el.value);
console.log("login-type: "+ localStorage.getItem("login-type"))
this.loginWithSMS(el); this.loginWithSMS(el);
break; break;
case 2: case 2:
localStorage.setItem("login-type",el.value); localStorage.setItem('login-type', el.value);
console.log(el.value);
this.loginWithFingurePrint(el); this.loginWithFingurePrint(el);
break; break;
case 3: case 3:
localStorage.setItem("login-type",el.value); localStorage.setItem('login-type', el.value);
console.log(el.value);
this.faceReconization(el); this.faceReconization(el);
break; break;
case 4: case 4:
localStorage.setItem('login-type', el.value);
console.log(el.value);
localStorage.setItem("login-type",el.value);
this.loginWithWhatsapp(el); this.loginWithWhatsapp(el);
break; break;
default: default:
break; break;
} }
this.cs.sharedService.setSharedData( this.cs.sharedService.setSharedData(this.selectedOption, AuthenticationService.LAST_LOGIN);
this.selectedOption,
AuthenticationService.LAST_LOGIN
);
} }
loginWithSMS(el) { loginWithSMS(el) {
console.log("loginWithSMS: "+ el);
if (!el.disabled) { 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) { if (this.loginData.LogInTokenID) {
this.sendActivationCode(1); this.sendActivationCode(1);
} else { } else {
// this.checkUserAuthentication(1); // this.checkUserAuthentication(1);
// this.checkUserAuthentication();** // this.checkUserAuthentication();**
} }
// }
} }
} }
loginWithWhatsapp(el) { loginWithWhatsapp(el) {
if (!el.disabled) { 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) { if (this.loginData.LogInTokenID) {
this.sendActivationCode(2); this.sendActivationCode(2);
} else { } else {
// this.checkUserAuthentication(2); // this.checkUserAuthentication(2);
} }
// }
} }
} }
public sendActivationCode(type: number) { public sendActivationCode(type: number) {
const request = new SendActivationByType();
let request = new SendActivationByType();
this.authService.setPublicFields(request); this.authService.setPublicFields(request);
request.OTP_SendType = type; request.OTP_SendType = type;
request.MobileNumber = this.loginData.MobileNumber; request.MobileNumber = this.loginData.MobileNumber;
request.IsMobileFingerPrint = 0; request.IsMobileFingerPrint = 0;
request.P_USER_NAME = this.loginData.P_USER_NAME; request.P_USER_NAME = this.loginData.P_USER_NAME;
request.LogInTokenID = this.loginData.LogInTokenID; request.LogInTokenID = this.loginData.LogInTokenID;
request.P_LEGISLATION_CODE = 'SA';
request.P_LEGISLATION_CODE ="SA"; this.authService.sendActivationCodeByType(request, () => { }, this.ts.trPK('general', 'ok'))
// request.VersionID ="2.0";
// request.LanguageID = imeiData && imeiData.PreferredLanguage || request.LanguageID;
this.authService
.sendActivationCodeByType(
request,
() => { },
this.ts.trPK("general", "ok")
)
.subscribe((result: any) => { .subscribe((result: any) => {
if (result.isSMSSent) { if (result.isSMSSent) {
// tslint:disable-next-line: max-line-length
this.cs.sharedService.setSharedData({ this.cs.sharedService.setSharedData({MobileNumber: this.loginData.MobileNumber, loginType: this.selectedOption}, SMSCheckRequest.SHARED_DATA);
MobileNumber: this.loginData.MobileNumber,
loginType: this.selectedOption
},
SMSCheckRequest.SHARED_DATA
);
this.cs.openSMSPage(); this.cs.openSMSPage();
} }
}); });
} }
loginWithFingurePrint(el: any) { loginWithFingurePrint(el: any) {
if (!el.disabled) { if (!el.disabled) {
this.FFloginType = el.value; this.FFloginType = el.value;
this.startBiometricLoginIfAvailable(); this.startBiometricLoginIfAvailable();
} }
} }
faceReconization(el: any) { faceReconization(el: any) {
if (!el.disabled) { if (!el.disabled) {
this.FFloginType = el.value; this.FFloginType = el.value;
this.startBiometricLoginIfAvailable(); this.startBiometricLoginIfAvailable();
} }
} }
private startBiometricLoginIfAvailable() { private startBiometricLoginIfAvailable() {
// this.setting.isBiometricsEnabled().then(result => {
// console.log(result);
this.faio.isAvailable().then( this.faio.isAvailable().then(
options => { options => {
// if biometric supported
//if (result) {
// ask if login with face or finger
this.presentBiometricDialog(); this.presentBiometricDialog();
}, () => {
// } else { alert('not avaliable ');
// //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() { private presentBiometricDialog() {
this.faio.show({
this.faio
.show({
title: 'Biometric Authetnciation', // (Android Only) | optional | Default: "<APP_NAME> Biometric Sign On" title: 'Biometric Authetnciation', // (Android Only) | optional | Default: "<APP_NAME> Biometric Sign On"
subtitle: 'Coolest Plugin ever' , // (Android Only) | optional | Default: null subtitle: 'Coolest Plugin ever' , // (Android Only) | optional | Default: null
description: this.ts.trPK('general', 'auth-please'), // optional | Default: null
description: this.ts.trPK("general", "auth-please"),// optional | Default: null fallbackButtonTitle: this.ts.trPK('general', 'use-pin'), // optional | When disableBackup is false defaults to "Use Pin".
fallbackButtonTitle: this.ts.trPK("general", "use-pin"), // optional | When disableBackup is false defaults to "Use Pin".
// When disableBackup is true defaults to "Cancel"
disableBackup: true, // optional | default: false disableBackup: true, // optional | default: false
// clientId: "Fingerprint Authetnciation", // clientId: "Fingerprint Authetnciation",
// clientSecret: "Ate343_9347lajF", // Only necessary for Android // clientSecret: "Ate343_9347lajF", // Only necessary for Android
// disableBackup: true, // Only for Android(optional) // disableBackup: true, // Only for Android(optional)
// localizedFallbackTitle: this.ts.trPK("general", "use-pin"), // Only for iOS // localizedFallbackTitle: this.ts.trPK("general", "use-pin"), // Only for iOS
// localizedReason: this.ts.trPK("general", "auth-please") // Only for iOS // localizedReason: this.ts.trPK("general", "auth-please") // Only for iOS
}).then((result: any) => {
}) const request = {
.then((result: any) => {
console.log("1");
// this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
let request ={
DeviceType: this.cs.getDeviceType(), DeviceType: this.cs.getDeviceType(),
DeviceToken: this.deviceToken DeviceToken: this.deviceToken
}; };
// this.authService.setPublicFields(request); // this.authService.setPublicFields(request);
// request.MobileNumber = this.loginData.MobileNumber; // request.MobileNumber = this.loginData.MobileNumber;
// request.P_USER_NAME=this.loginData.P_USER_NAME; // request.P_USER_NAME=this.loginData.P_USER_NAME;
// request.UserName=this.loginData.P_USER_NAME; // request.UserName=this.loginData.P_USER_NAME;
// request.LogInTokenID =this.loginData.LogInTokenID; // request.LogInTokenID =this.loginData.LogInTokenID;
// request.CompanyID =1;//cs=1 , HMG=2 // request.CompanyID =1;//cs=1 , HMG=2
this.getMobileInfo(request); this.getMobileInfo(request);
}).catch((error: any) => {
})
.catch((error: any) => {
console.log(error); console.log(error);
}); });
} }
private getMobileInfo(request: any) { private getMobileInfo(request: any) {
this.authService.getLoginInfo(request, () => { }, this.ts.trPK('general', 'ok')).subscribe((result: GetLoginInfoResponse) => {
console.log("2");
this.authService.getLoginInfo(request,() => { },this.ts.trPK("general", "ok")).subscribe((result: GetLoginInfoResponse) => {
console.log("authService.getLoginInfo");
if (result.Mohemm_GetMobileLoginInfoList.length > 0) { if (result.Mohemm_GetMobileLoginInfoList.length > 0) {
// tslint:disable-next-line: triple-equals
if ( result.Mohemm_GetMobileLoginInfoList[0].LoginType == 2 || result.Mohemm_GetMobileLoginInfoList[0].LoginType == 3) { if ( result.Mohemm_GetMobileLoginInfoList[0].LoginType == 2 || result.Mohemm_GetMobileLoginInfoList[0].LoginType == 3) {
this.loginTokenID = result.LogInTokenID; this.loginTokenID = result.LogInTokenID;
//send silent sms
this.checkSMS(); this.checkSMS();
} else { } else {
this.onlySMSBox = false; this.onlySMSBox = false;
this.button(); this.button();
} }
} else { } else {
this.onlySMSBox = false; this.onlySMSBox = false;
this.button(); this.button();
} }
}); });
} }
public checkSMS() { public checkSMS() {
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
const request = new SMSCheckRequest(); const request = new SMSCheckRequest();
request.LogInTokenID = data.LogInTokenID; request.LogInTokenID = data.LogInTokenID;
request.activationCode = '';
request.activationCode = "";
request.P_USER_NAME = data.P_USER_NAME; request.P_USER_NAME = data.P_USER_NAME;
request.MobileNumber = data.MobileNumber; request.MobileNumber = data.MobileNumber;
this.authService.checkSMS(request, () => {}, this.ts.trPK('general', 'ok'))
this.authService
.checkSMS(request, () => {}, this.ts.trPK("general", "ok"))
.subscribe((result: SMSCheckResponse) => { .subscribe((result: SMSCheckResponse) => {
console.log(result);
if (this.cs.validResponse(result)) { if (this.cs.validResponse(result)) {
AuthenticationService.servicePrivilage = result.Privilege_List; AuthenticationService.servicePrivilage = result.Privilege_List;
this.authService.setAuthenticatedUser(result).subscribe(() => { this.authService.setAuthenticatedUser(result).subscribe(() => {
console.log("insert"); localStorage.setItem('emp-name', result.MemberInformationList[0].EMPLOYEE_NAME);
localStorage.setItem("emp-name",result.MemberInformationList[0].EMPLOYEE_NAME);
console.log("empnmae: "+ localStorage.getItem("emp-name"));
this.user_name = result.MemberInformationList[0].EMPLOYEE_NAME; this.user_name = result.MemberInformationList[0].EMPLOYEE_NAME;
//get date and time of last login const currDateTime = moment().format('MMM DD , YYYY HH:mm');
let currDateTime = moment().format('MMM DD , YYYY HH:mm') localStorage.setItem('login-at', currDateTime);
localStorage.setItem("login-at",currDateTime); if (this.platform.is('cordova')) {
if (this.platform.is("cordova")) {
this.insertMobileLogin(); this.insertMobileLogin();
} }
this.cs.openHome(); this.cs.openHome();
}); });
} }
}); });
} }
public insertMobileLogin() { public insertMobileLogin() {
const request = new GetLoginInfoRequest();
let request = new GetLoginInfoRequest();
this.authService.setPublicFields(request); this.authService.setPublicFields(request);
request.MobileNumber = this.loginData.MobileNumber; request.MobileNumber = this.loginData.MobileNumber;
request.P_USER_NAME = this.loginData.P_USER_NAME; request.P_USER_NAME = this.loginData.P_USER_NAME;
request.UserName = this.loginData.P_USER_NAME; request.UserName = this.loginData.P_USER_NAME;
request.LogInTokenID = this.loginData.LogInTokenID; request.LogInTokenID = this.loginData.LogInTokenID;
request.CompanyID = 1; // CompanyID request.CompanyID = 1; // CompanyID
request.DeviceType = this.cs.getDeviceType(); request.DeviceType = this.cs.getDeviceType();
request.DeviceToken = this.deviceToken; // "5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36";//this.deviceToken; request.DeviceToken = this.deviceToken; // "5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36";//this.deviceToken;
// request.TokenID= // request.TokenID=
request.LoginType = this.selectedOption; request.LoginType = this.selectedOption;
request.EmployeeName = this.user_name; request.EmployeeName = this.user_name;
this.authService.insertMobileLoginInfo(request, () => { }, this.ts.trPK('general', 'ok'), this.isPostNoLoad)
this.authService
.insertMobileLoginInfo(
request,
() => { },
this.ts.trPK("general", "ok")
)
.subscribe((result: any) => { .subscribe((result: any) => {
console.log('successful insertMobileLoginInfo' );
console.log(result);
console.log("succssful insertMobileLoginInfo" );
}); });
} }
// do silent login // do silent login
private checkUserAuthentication() { private checkUserAuthentication() {
console.log("debug Here!!");
this.cs.startLoading(); this.cs.startLoading();
const request = new LoginRequest(); const request = new LoginRequest();
request.P_USER_NAME = this.username; request.P_USER_NAME = this.username;
request.P_LANGUAGE = "US";//this.language; request.P_LANGUAGE = 'US'; // this.language;
request.P_PASSWORD = this.password; request.P_PASSWORD = this.password;
console.log(request);
this.authService this.authService
.login(request, () => { .login(request, () => {
console.log("error here"); console.log('error here');
//console.log(result.MessageStatus); }, this.ts.trPK('general', 'ok'))
//this.sharedData.setSharedData(true, Password.IS_EXPIRED_PSW);
//this.userCheck();
}, this.ts.trPK("general", "ok"))
.subscribe((result: CheckUserAuthenticationResponse) => { .subscribe((result: CheckUserAuthenticationResponse) => {
console.log("success"); console.log('success');
this.cs.stopLoading(); this.cs.stopLoading();
if (this.cs.validResponse(result)) { if (this.cs.validResponse(result)) {
console.log("result.LogInTokenID "+ result.LogInTokenID);
console.log("this.loginData before "+ this.loginData);
this.loginData = new LoginModel(); this.loginData = new LoginModel();
console.log("this.loginData after "+ this.loginData);
// console.log("result.MemberLoginList.EMPLOYEE_NAME "+ result.MemberInformationList[0].EMPLOYEE_NAME);
this.loginData.LogInTokenID = result.LogInTokenID; this.loginData.LogInTokenID = result.LogInTokenID;
this.loginData.MobileNumber = result.MemberLoginList.P_MOBILE_NUMBER; this.loginData.MobileNumber = result.MemberLoginList.P_MOBILE_NUMBER;
this.loginData.P_USER_NAME = this.username; this.loginData.P_USER_NAME = this.username;
this.loginData.EmployeeName = this.user_name; this.loginData.EmployeeName = this.user_name;
this.sharedData.setSharedData(this.loginData, AuthenticationService.LOGIN_DATA); this.sharedData.setSharedData(this.loginData, AuthenticationService.LOGIN_DATA);
this.cs.sharedService.setSharedData(this.loginData.P_USER_NAME, LoginRequest.SHARED_DATA); this.cs.sharedService.setSharedData(this.loginData.P_USER_NAME, LoginRequest.SHARED_DATA);
//this.remeberMyInfo();
//this.cs.openSMSPage(); phase#1 one type of OTP
// if(!this.welcomeBack){
//this.cs.openConfirmLoginPage();//phase#2 add 4 types for OTP
// }
this.confirm(this.loginType); this.confirm(this.loginType);
} else { } else {
console.log("result.IsPasswordExpired");
console.log(result.IsPasswordExpired);
if (result.IsPasswordExpired) { if (result.IsPasswordExpired) {
// alert("dont forget to handelpresentPasswordExpiredDialog() "); // alert("dont forget to handelpresentPasswordExpiredDialog() ");
// this.presentPasswordExpiredDialog(); ***** // this.presentPasswordExpiredDialog(); *****
@ -882,26 +361,18 @@ private checkUserAuthentication() {
} }
checkAccess(el: any) { checkAccess(el: any) {
let data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
this.loginType = el; this.loginType = el;
if (this.accessFromOutSide) { if (this.accessFromOutSide) {
// alert("this.accessFromOutSide" + this.accessFromOutSide);
this.checkUserAuthentication(); this.checkUserAuthentication();
} } else {
else{ // tslint:disable-next-line: triple-equals
// alert("this.accessFromOutSide" + this.accessFromOutSide);
if (!data == undefined ) { if (!data == undefined ) {
// alert("data.LogInTokenID" + data.LogInTokenID);
this.confirm(this.loginType); this.confirm(this.loginType);
} } else {
else{
this.checkUserAuthentication(); this.checkUserAuthentication();
} }
} }
}//end checkAccess }
} }

@ -96,16 +96,8 @@ export class LoginComponent implements OnInit, OnDestroy {
private checkUserResult: CheckUserAuthenticationResponse; private checkUserResult: CheckUserAuthenticationResponse;
ionViewWillEnter(){
console.log("ionViewWillEnter");
}
ngOnInit() { ngOnInit() {
// if(!this.cs.getIsTimeSessionOut()){ // if(!this.cs.getIsTimeSessionOut()){
// this.getlastlogin = this.cs.sharedService.getSharedData( // this.getlastlogin = this.cs.sharedService.getSharedData(
// AuthenticationService.IMEI_USER_DATA, // AuthenticationService.IMEI_USER_DATA,
// false // false

@ -22,16 +22,9 @@ export class GenericHeaderComponent implements OnInit {
constructor(public common: CommonService) { } constructor(public common: CommonService) { }
ngOnInit() { ngOnInit() {
console.log(this.updateDirection);
console.log(this.showClose);
console.log(this.showBack);
if (this.updateDirection) { if (this.updateDirection) {
this.showBack = false; this.showBack = false;
}else{
} }
} }
openProfilePage() { openProfilePage() {
@ -39,7 +32,6 @@ export class GenericHeaderComponent implements OnInit {
} }
closeModal() { closeModal() {
console.log("closeModal");
this.trigger.emit(); this.trigger.emit();
} }

@ -1,7 +1,7 @@
import { EitService } from './../eit/services/eit.service'; import { EitService } from './../eit/services/eit.service';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { MenuController, Events, ActionSheetController } from '@ionic/angular'; import { Platform, MenuController, Events, ActionSheetController } from '@ionic/angular';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user'; import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user';
import { MenuService } from 'src/app/hmg-common/services/menu/menuservice.service'; import { MenuService } from 'src/app/hmg-common/services/menu/menuservice.service';
@ -35,6 +35,7 @@ import { AccrualService } from '../accrual-balances/services/accrual.service';
import { TimeCardService } from '../time-card/service/time-card.service'; import { TimeCardService } from '../time-card/service/time-card.service';
import { WorklistMainService } from '../notification/service/work-list.main.service'; import { WorklistMainService } from '../notification/service/work-list.main.service';
import { isThisISOWeek } from 'date-fns'; import { isThisISOWeek } from 'date-fns';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@ -148,7 +149,9 @@ export class HomePage implements OnInit {
public DS: DashboredService, public DS: DashboredService,
public accrualService: AccrualService, public accrualService: AccrualService,
public timeCardService: TimeCardService, public timeCardService: TimeCardService,
public workListService: WorklistMainService public workListService: WorklistMainService,
public router: Router,
private platform: Platform,
) { ) {
this.events.subscribe('img-change', displayImg => { this.events.subscribe('img-change', displayImg => {
this.userImage = this.sanitizer.bypassSecurityTrustUrl( this.userImage = this.sanitizer.bypassSecurityTrustUrl(
@ -158,6 +161,11 @@ export class HomePage implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.platform.backButton.subscribeWithPriority(9999, () => {
if (this.router.isActive('/home', true)) {
this.common.openHome();
}
});
// this.getUserDetails(); // this.getUserDetails();
// this.getCount(); // this.getCount();
// this.events.subscribe('getNotCount', badge => { // this.events.subscribe('getNotCount', badge => {
@ -181,6 +189,14 @@ export class HomePage implements OnInit {
this.getUserDetails(); this.getUserDetails();
} }
// ionViewDidEnter() {
// // tslint:disable-next-line: only-arrow-functions
// document.addEventListener('backbutton', function(e) {
// e.preventDefault();
// e.stopPropagation();
// }, false);
// }
initTimer() { initTimer() {
this.runTimer = false; this.runTimer = false;
this.hasStarted = false; this.hasStarted = false;

Loading…
Cancel
Save