From 4461c203da52b6fff8464b3ae627ba4bb7a1eea4 Mon Sep 17 00:00:00 2001 From: umasoodch Date: Sun, 27 Dec 2020 09:42:10 +0300 Subject: [PATCH] version issue resolved --- .../check-user/check-user.component.html | 2 +- .../check-user/check-user.component.ts | 7 ++ .../confirm-login/confirm-login.component.ts | 35 ++++++- .../authentication/login/login.component.html | 93 ++++++------------- .../authentication/login/login.component.ts | 84 ++++------------- .../authentication/authentication.service.ts | 16 +++- Mohem/src/app/home/home.page.ts | 6 +- Mohem/src/theme/styles.scss | 4 + 8 files changed, 104 insertions(+), 143 deletions(-) diff --git a/Mohem/src/app/authentication/check-user/check-user.component.html b/Mohem/src/app/authentication/check-user/check-user.component.html index 841a2b96..509dcd69 100644 --- a/Mohem/src/app/authentication/check-user/check-user.component.html +++ b/Mohem/src/app/authentication/check-user/check-user.component.html @@ -32,6 +32,6 @@
- +
\ No newline at end of file diff --git a/Mohem/src/app/authentication/check-user/check-user.component.ts b/Mohem/src/app/authentication/check-user/check-user.component.ts index 5e9f5dab..bd84b4c4 100644 --- a/Mohem/src/app/authentication/check-user/check-user.component.ts +++ b/Mohem/src/app/authentication/check-user/check-user.component.ts @@ -39,6 +39,13 @@ export class CheckUserComponent implements OnInit { this.sendSMSForForgotPassword(); } + public isValidForm(): boolean { + if (this.P_USER_NAME) { + return false; + } + return true; + } + public userCheck() { this.cs.startLoading(); 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 2865efee..f7455a9d 100644 --- a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts +++ b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts @@ -16,6 +16,7 @@ import { Platform } 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'; +import { CheckAppVersionResponse } from 'src/app/hmg-common/services/authentication/models/check-app-version.response'; @Component({ selector: 'app-confirm-login', @@ -44,6 +45,8 @@ export class ConfirmLoginComponent implements OnInit { user_name: string; FFloginType: any; public isPostNoLoad = true; + private iosLink: string; + private androidLink: string; constructor( public ts: TranslatorService, @@ -401,17 +404,45 @@ private checkUserAuthentication() { }); } +private handleAppUpdate(result) { + this.iosLink = result.IOSLink; + this.androidLink = result.AndroidLink; + if (this.platform.is('android')) { + if (this.androidLink) { + window.open(this.androidLink, '_system'); + } + } else if (this.platform.is('ios')) { + if (this.iosLink) { + window.open(this.iosLink, '_system'); + } + } +} + +public checkAppUpdated() { + this.authService.checkApplicationVersion(() => {}).subscribe((result: CheckAppVersionResponse) => { + // tslint:disable-next-line: triple-equals + if (result.MessageStatus == 2 && result.ErrorType == 4) { + this.cs.presentAcceptDialog(result.ErrorEndUserMessage, () => { + this.handleAppUpdate(result); + }); + // tslint:disable-next-line: triple-equals + } else if (result.MessageStatus == 1) { + this.checkUserAuthentication(); + } + }); +} + checkAccess(el: any) { const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); this.loginType = el; if (this.accessFromOutSide) { - this.checkUserAuthentication(); + this.checkAppUpdated(); } else { // tslint:disable-next-line: triple-equals if (!data == undefined ) { this.confirm(this.loginType); } else { - this.checkUserAuthentication(); + this.checkAppUpdated(); } } } diff --git a/Mohem/src/app/authentication/login/login.component.html b/Mohem/src/app/authentication/login/login.component.html index f499b664..94cf254d 100644 --- a/Mohem/src/app/authentication/login/login.component.html +++ b/Mohem/src/app/authentication/login/login.component.html @@ -1,33 +1,12 @@ - -
- -
-
- - - +
- - - - @@ -35,63 +14,43 @@
-
- - - - - - - -
- - - +
+ + + + + +
+ + +
- -
- - - -
- +
- - - - - - + diff --git a/Mohem/src/app/authentication/login/login.component.ts b/Mohem/src/app/authentication/login/login.component.ts index 65e126aa..e85917ac 100644 --- a/Mohem/src/app/authentication/login/login.component.ts +++ b/Mohem/src/app/authentication/login/login.component.ts @@ -26,7 +26,6 @@ import { KeyboardStatusModel } from 'src/app/hmg-common/services/keyboard/keyboa }) export class LoginComponent implements OnInit, OnDestroy { deviceToken1: any; - constructor( public cs: CommonService, @@ -45,7 +44,6 @@ export class LoginComponent implements OnInit, OnDestroy { public pushService: PushService, public keyboardService: KeyboardService ) { - this.events.subscribe('logoutFlage', logoutFlage => { console.log('login compont logoutFlage: ' + logoutFlage); // tslint:disable-next-line: triple-equals @@ -55,20 +53,18 @@ export class LoginComponent implements OnInit, OnDestroy { localStorage.setItem('logoutFlage', logoutFlage); } }); - this.getuser = this.cs.sharedService.getSharedData( AuthenticationService.IMEI_USER_DATA, false ); - // alert(" this.getuser "+this.getuser); if (this.getuser) { this.user = true; } else { this.user = false; - } } + appLang = 1; isExpired = false; isSupportAr = false; @@ -99,17 +95,9 @@ export class LoginComponent implements OnInit, OnDestroy { getuser: any = ''; getlastlogin: any; public keyboardOpened = false; - private checkUserResult: CheckUserAuthenticationResponse; ngOnInit() { - // if(!this.cs.getIsTimeSessionOut()){ - // this.getlastlogin = this.cs.sharedService.getSharedData( - // AuthenticationService.IMEI_USER_DATA, - // false - // ); - // console.log("this.getlastlogin"+ this.getlastlogin); - // } this.monitorKeyboardChange(); this.currentLang = TranslatorService.getCurrentLanguageCode(); console.log(TranslatorService.CURRENT_LANGUAGE) @@ -121,38 +109,11 @@ export class LoginComponent implements OnInit, OnDestroy { this.language = "AR"; this.changeLanguage('1') } - console.log("current lang: "+this.currentLang) - //this.ts.switchLanguage(); - // this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); - // console.log("get deviceToken login"+ this.deviceToken) - - - // this.getuser = this.cs.sharedService.getSharedData( - // AuthenticationService.IMEI_USER_DATA, - // false - // ); - - // if(this.getuser){ - // console.log("this.getuser"+this.getuser); - // this.logoutFlage = true; - - // } - + console.log("current lang: "+this.currentLang); this.events.subscribe('user', user => { this.user = user; }); - - //this.deviceToken = localStorage.getItem('devicyeToken'); - //this.deviceToken1 =this.cs.getDeviceToken(); - - console.log(" this.user login in init" + this.user); - //this.deviceToken = localStorage.getItem('devicyeToken'); this.deviceToken =this.cs.getDeviceToken(); - - - console.log('lngOnInit localStorage: ' + this.deviceToken1); - console.log('lngOnInit getDeviceToken: ' + this.deviceToken); - if (this.deviceToken) { console.log('login enabled first time: ' + this.deviceToken); } else { @@ -160,7 +121,7 @@ export class LoginComponent implements OnInit, OnDestroy { this.pushService.startReceiving(); } - // here will delete below part and depdding on user (response from getMobileInfo) + // here will delete below part and depdding on user (response from getMobileInfo) this.username = localStorage.getItem('user'); this.password = localStorage.getItem('password'); // ****// const remember = localStorage.getItem('remember'); // ****// @@ -192,6 +153,7 @@ export class LoginComponent implements OnInit, OnDestroy { } this.currentLang = langNumber; } + public forgetPasswordPage() { this.cs.openUserForgot(); } @@ -214,12 +176,12 @@ export class LoginComponent implements OnInit, OnDestroy { } public onLogin() { - this.deviceToken = localStorage.getItem('deviceToken'); - if (this.deviceToken) { + this.deviceToken = localStorage.getItem('deviceToken'); + if (this.deviceToken) { this.checkAppUpdated(); - } else { - this.pushService.startReceiving(); - setTimeout(() => { + } else { + this.pushService.startReceiving(); + setTimeout(() => { this.deviceToken = localStorage.getItem('deviceToken'); this.checkAppUpdated(); console.log('login enabled second time: ' + this.deviceToken); @@ -228,10 +190,7 @@ export class LoginComponent implements OnInit, OnDestroy { } public checkAppUpdated() { - this.authService.checkApplicationVersion( - () => { - /* Write code for error */ - }).subscribe((result: CheckAppVersionResponse) => { + this.authService.checkApplicationVersion(() => {}).subscribe((result: CheckAppVersionResponse) => { // tslint:disable-next-line: triple-equals if (result.MessageStatus == 2 && result.ErrorType == 4) { this.cs.presentAcceptDialog(result.ErrorEndUserMessage, () => { @@ -258,12 +217,14 @@ export class LoginComponent implements OnInit, OnDestroy { } } - private checkUserAuthentication() { - console.log('debug Here!!'); - console.log(this.username); - console.log(this.language); - console.log(this.password); + public isValidForm(): boolean { + if (this.username && this.password) { + return false; + } + return true; + } + private checkUserAuthentication() { this.cs.startLoading(); const request = new LoginRequest(); request.P_USER_NAME = this.username; @@ -273,16 +234,12 @@ export class LoginComponent implements OnInit, OnDestroy { this.authService .login(request, () => { console.log('error here'); - // console.log(result.MessageStatus); - // this.sharedData.setSharedData(true, Password.IS_EXPIRED_PSW); - // this.userCheck(); }, this.ts.trPK('general', 'ok')) .subscribe((result: CheckUserAuthenticationResponse) => { console.log('success'); this.cs.stopLoading(); if (this.cs.validResponse(result)) { // alert("result.MemberLoginList.EMPLOYEE_NAME :" + result.MemberLoginList[0].EMPLOYEE_NAME); - this.loginData.LogInTokenID = result.LogInTokenID; this.loginData.MobileNumber = result.MemberLoginList.P_MOBILE_NUMBER; this.loginData.P_USER_NAME = this.username; @@ -294,8 +251,6 @@ export class LoginComponent implements OnInit, OnDestroy { // if(!this.welcomeBack){ this.cs.openConfirmLoginPage(); // phase#2 add 4 types for OTP // } - - } else { console.log('result.IsPasswordExpired'); console.log(result.IsPasswordExpired); @@ -386,7 +341,6 @@ export class LoginComponent implements OnInit, OnDestroy { } console.log('login emit'); console.log('login'); - // this.checkUserAuthentication(); // this.loginDiv=true; this.user = false; } @@ -397,9 +351,6 @@ export class LoginComponent implements OnInit, OnDestroy { this.cs.openConfirmLoginPage(); } - - /// - getLastLoginInfo() { this.requestGetLoginInfo = { DeviceType: this.cs.getDeviceType(), // "Android",//this.cs.getDeviceType(), @@ -419,7 +370,6 @@ export class LoginComponent implements OnInit, OnDestroy { } else { this.user = false; - } } }); 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 a2bee59c..91213a0c 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -24,7 +24,7 @@ import { EmailInput } from "../../ui/email/models/email-input"; import { GetLoginInfoRequest } from "./models/get-login-info.request"; import { GetLoginInfoResponse } from "./models/get-login-info.response"; import { analyzeAndValidateNgModules } from "@angular/compiler"; -import { Events, MenuController } from "@ionic/angular"; +import { Events, MenuController, Platform } from "@ionic/angular"; import { InternationalMobileComponent } from "../../ui/mobile-number/international-mobile/international-mobile.component"; import { SMSCheckRequest } from "./models/smscheck.request"; import { SMSCheckResponse } from "./models/smscheck.response"; @@ -94,6 +94,7 @@ export class AuthenticationService { // public localNotifications: UserLocalNotificationService, private events: Events, private menu: MenuController, + public platform: Platform ) { } public authenticateRequest(request: Request, automaticLogin = true): Request { @@ -125,13 +126,18 @@ export class AuthenticationService { } public setPublicFields(request: Request): Request { + const isAndroid = this.platform.is('android'); + const isIOS = this.platform.is('ios'); + let mobileType = ''; + if (isAndroid) { + mobileType = 'android'; + } else if (isIOS) { + mobileType = 'ios'; + } request.VersionID = 2.3; request.Channel = 33; request.LanguageID = TranslatorService.getCurrentLanguageCode(); - //request.IPAdress = '10.10.10.10'; - //request.SessionID = "any thing"; // ??? required for not authorized login funny - request.MobileType = ""; - //request.isDentalAllowedBackend = false; + request.MobileType = mobileType; return request; } public authenticateAndSetPersonalInformation( diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index e1733fd4..ae038d16 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -62,6 +62,7 @@ export class HomePage implements OnInit { public isShow = false; public showVcationRule = false; public isFakeLocationUsed = false; + public intervalCountdown: any; public statsButtons = [ { title: this.ts.trPK('attendance-tracking', 'title'), @@ -128,6 +129,7 @@ export class HomePage implements OnInit { public vacationRuleIcon: string; direction: string; public isPostNoLoad = true; + public locationResponse: any; constructor( public ts: TranslatorService, @@ -202,7 +204,7 @@ export class HomePage implements OnInit { } timerTick() { - setTimeout(() => { + this.intervalCountdown = setTimeout(() => { if (!this.runTimer) { return; } @@ -248,6 +250,7 @@ export class HomePage implements OnInit { if (this.platform.is('android')) { this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { if (resp && (resp.latitude && resp.longitude)) { + this.locationResponse = resp; if (resp.isFromMockProvider || resp.mockLocationsEnabled) { this.isFakeLocationUsed = true; } @@ -614,6 +617,7 @@ showAttendanceTracking() { }; this.DS.getAttendanceTracking(request, '', '', this.isPostNoLoad).subscribe((result: AttendanceTrackingResponse) => { if (this.common.validResponse(result)) { + clearTimeout(this.intervalCountdown); const key = 'GetAttendanceTrackingList'; this.convertAndAssignTime(result[key]); } diff --git a/Mohem/src/theme/styles.scss b/Mohem/src/theme/styles.scss index 983a2d04..8c27b149 100644 --- a/Mohem/src/theme/styles.scss +++ b/Mohem/src/theme/styles.scss @@ -1529,3 +1529,7 @@ table.monthview-datetable th small { .alert-wrapper { min-width: 80% !important;//what ever you like } + + .disable-button-opacity { + opacity: .5; +}