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 26da532d..23bcf302 100644 --- a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts +++ b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts @@ -17,6 +17,7 @@ import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/aut import { LoginModel } from '../models/LoginModel'; import * as moment from 'moment'; import { CheckAppVersionResponse } from 'src/app/hmg-common/services/authentication/models/check-app-version.response'; +import { NFC } from "@ionic-native/nfc/ngx"; @Component({ selector: 'app-confirm-login', @@ -47,7 +48,7 @@ export class ConfirmLoginComponent implements OnInit { public isPostNoLoad = true; private iosLink: string; private androidLink: string; - + public isNFCAvailable = false; constructor( public ts: TranslatorService, @@ -57,6 +58,7 @@ export class ConfirmLoginComponent implements OnInit { private faio: FingerprintAIO, public pushService: PushService, public platform: Platform, + private nfc: NFC ) { this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); this.deviceToken = this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); @@ -73,6 +75,7 @@ export class ConfirmLoginComponent implements OnInit { } ngOnInit() { + this.checkNFCStatus(); // **checkIfAvailable FAIO **// this.checkIfAvailable(); // **getSharedData of IMEI_USER_DATA and REGISTER_DATA_FOR_LOGIIN to set defult value **// @@ -329,6 +332,23 @@ export class ConfirmLoginComponent implements OnInit { } + async checkNFCStatus() { + try { + let nfcStatus = await this.nfc.enabled(); + console.log("nfc status >>>>>>>>>>" + nfcStatus); + this.isNFCAvailable = true; + } catch (err) { + console.log("Error reading tag", err); + if (err === "NO_NFC") { + this.isNFCAvailable = false; + } else if (err === "NFC_DISABLED") { + this.isNFCAvailable = true; + } else { + this.isNFCAvailable = false; + } + } + } + public checkSMS() { const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const request = new SMSCheckRequest(); @@ -336,6 +356,7 @@ export class ConfirmLoginComponent implements OnInit { request.activationCode = ''; request.P_USER_NAME = data.P_USER_NAME; request.MobileNumber = data.MobileNumber; + request.IsDeviceNFC = this.isNFCAvailable; this.authService.checkSMS(request, () => {}, this.ts.trPK('general', 'ok')) .subscribe((result: SMSCheckResponse) => { if (this.cs.validResponse(result)) { 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 f5fffbc7..2659c184 100644 --- a/Mohem/src/app/authentication/sms-page/sms-page.page.ts +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.ts @@ -12,6 +12,7 @@ import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/mod import { Password } from '../models/password'; import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request'; import * as moment from 'moment'; +import { NFC } from "@ionic-native/nfc/ngx"; @Component({ selector: 'app-sms-page', @@ -48,7 +49,7 @@ export class SmsPageComponent implements OnInit { public isPostNoLoad = true; loginType: any; activeType: any; - + public isNFCAvailable = false; constructor( public navCtrl: NavController, @@ -58,9 +59,11 @@ export class SmsPageComponent implements OnInit { public authService: AuthenticationService, public sharedData: SharedDataService, public platform: Platform, + private nfc: NFC ) {} ngOnInit() { + this.checkNFCStatus(); this.activeType=this.common.getActiveTypeLogin(); console.log("active "+ this.common.sharedService.getSharedData('active-type',true)); @@ -162,6 +165,23 @@ export class SmsPageComponent implements OnInit { } } + async checkNFCStatus() { + try { + let nfcStatus = await this.nfc.enabled(); + console.log("nfc status >>>>>>>>>>" + nfcStatus); + this.isNFCAvailable = true; + } catch (err) { + console.log("Error reading tag", err); + if (err === "NO_NFC") { + this.isNFCAvailable = false; + } else if (err === "NFC_DISABLED") { + this.isNFCAvailable = true; + } else { + this.isNFCAvailable = false; + } + } + } + public checkSMS() { const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const request = new SMSCheckRequest(); @@ -169,6 +189,7 @@ export class SmsPageComponent implements OnInit { request.activationCode = this.code; // code;this.activationCode; request.P_USER_NAME = data.P_USER_NAME; request.MobileNumber = data.MobileNumber; + request.IsDeviceNFC = this.isNFCAvailable; this.authService.checkSMS(request, () => {}, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => { if (this.common.validResponse(result)) { AuthenticationService.servicePrivilage = result.Privilege_List; 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 22f0c2de..bd667936 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -134,7 +134,7 @@ export class AuthenticationService { } else if (isIOS) { mobileType = 'ios'; } - request.VersionID = 2.5; + request.VersionID = 2.6; request.Channel = 31; request.LanguageID = TranslatorService.getCurrentLanguageCode(); request.MobileType = mobileType; diff --git a/Mohem/src/app/hmg-common/services/authentication/models/login.request.ts b/Mohem/src/app/hmg-common/services/authentication/models/login.request.ts index c7623ff3..46bc0f64 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/login.request.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/login.request.ts @@ -18,4 +18,5 @@ export class LoginRequest extends Request { public static NATIONALITY_CODE = "Nationality_Code"; // isDentalAllowedBackend: false isRegister: boolean; // false + IsDeviceNFC: boolean; } 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 1265b04c..6b61dd53 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,6 +4,7 @@ import { Request } from 'src/app/hmg-common/services/models/request'; export class SMSCheckRequest extends Request { LogInTokenID: string ; activationCode?: string; + IsDeviceNFC: boolean; public static SHARED_DATA = 'check_activation_shared_data'; } \ No newline at end of file diff --git a/Mohem/src/app/hmg-common/services/connector/connector.service.ts b/Mohem/src/app/hmg-common/services/connector/connector.service.ts index acd8ff0e..2857c3b1 100644 --- a/Mohem/src/app/hmg-common/services/connector/connector.service.ts +++ b/Mohem/src/app/hmg-common/services/connector/connector.service.ts @@ -24,8 +24,8 @@ export class ConnectorService { public static timeOut = 120 * 1000; // public static host = 'http://10.50.100.113:6060/'; // development service -// public static host = 'https://uat.hmgwebservices.com/'; - public static host = 'https://hmgwebservices.com/'; +public static host = 'https://uat.hmgwebservices.com/'; + // public static host = 'https://hmgwebservices.com/'; // public static host = 'http://10.50.100.198:6060/'; // public static host = 'http://10.50.100.113:6060/'; // development service /* public static host = 'http://10.50.100.198:6060/'; diff --git a/Mohem/src/app/home/attendance-options/attendance-options.component.html b/Mohem/src/app/home/attendance-options/attendance-options.component.html index ecd2cbc8..49f1b330 100644 --- a/Mohem/src/app/home/attendance-options/attendance-options.component.html +++ b/Mohem/src/app/home/attendance-options/attendance-options.component.html @@ -1,45 +1,37 @@ + [headerText]="'general,option-attendance' | translate"> + +

{{ "general, select-attendance" | translate }}

+ - +

{{ "general, nfc-text" | translate }}

- + class="buttonStyle">

{{ "general, qr-text" | translate }}

@@ -47,10 +39,8 @@ -
+ +
diff --git a/Mohem/src/app/home/attendance-options/attendance-options.component.ts b/Mohem/src/app/home/attendance-options/attendance-options.component.ts index 386a46e6..33c06bab 100644 --- a/Mohem/src/app/home/attendance-options/attendance-options.component.ts +++ b/Mohem/src/app/home/attendance-options/attendance-options.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from "@angular/core"; +import { Component, OnInit, NgZone } from "@angular/core"; import { NFC } from "@ionic-native/nfc/ngx"; import { CommonService } from "src/app/hmg-common/services/common/common.service"; import { Platform } from "@ionic/angular"; @@ -36,7 +36,8 @@ export class AttendanceOptionsComponent implements OnInit { public ts: TranslatorService, public modalController: ModalController, private device: Device, - private attendance_service: AttendanceService + private attendance_service: AttendanceService, + public ngZone: NgZone ) {} ngOnInit() { @@ -132,10 +133,12 @@ export class AttendanceOptionsComponent implements OnInit { }) .subscribe((result: Response) => { if (this.common.validResponse(result)) { - this.nfcIOSSuccess = true; + this.ngZone.run(() => { + this.nfcIOSSuccess = true; + }); setTimeout(() => { this.common.openHome(); - }, 1000); + }, 4000); } }); } diff --git a/Mohem/src/app/home/nfc-modal/nfc-modal.component.html b/Mohem/src/app/home/nfc-modal/nfc-modal.component.html index dc51de14..6375327f 100644 --- a/Mohem/src/app/home/nfc-modal/nfc-modal.component.html +++ b/Mohem/src/app/home/nfc-modal/nfc-modal.component.html @@ -1,15 +1,16 @@ -
-

Detecting NFC for marking attendance

-

Swipe Attendance Done!

+
+

{{ "general, nfc-detect" | translate }}

+

{{ "general, nfc-swipe-done" | translate }}

-
+
+

{{ "general, nfc-detect-2" | translate }}

+ {{ "general, nfc-cancel" | translate }}
-
+
- \ No newline at end of file diff --git a/Mohem/src/app/home/nfc-modal/nfc-modal.component.scss b/Mohem/src/app/home/nfc-modal/nfc-modal.component.scss index e69de29b..1da684f1 100644 --- a/Mohem/src/app/home/nfc-modal/nfc-modal.component.scss +++ b/Mohem/src/app/home/nfc-modal/nfc-modal.component.scss @@ -0,0 +1,39 @@ +.centerDiv { + margin: auto; + text-align: center; + display: block; +} + +.heading-div { + display: block; + text-align: center; +} +.heading-text { + font-size: 16px; + color: #bbbbbb; + font-family: 'WorkSans-Bold'; + margin-top: 7%; +} +.ripple-div { + display: block; + text-align: center; + margin-top: -20%; + p { + font-size: 16px; + color: #bbbbbb; + font-family: 'WorkSans-Bold'; + margin-top: -20%; + } + ion-button { + --background: #282f42; + color: var(--light); + border-radius: 33px; + width: 270px; + } +} + +.checked-img { + display: block; + text-align: center; + margin-top: 25%; +} \ No newline at end of file diff --git a/Mohem/src/app/home/nfc-modal/nfc-modal.component.ts b/Mohem/src/app/home/nfc-modal/nfc-modal.component.ts index eccab473..1117ea7c 100644 --- a/Mohem/src/app/home/nfc-modal/nfc-modal.component.ts +++ b/Mohem/src/app/home/nfc-modal/nfc-modal.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, NgZone } from '@angular/core'; import { NFC } from "@ionic-native/nfc/ngx" import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import {AttendScanService} from '../../hmg-common/services/attend-services/attend-scan.service'; @@ -27,7 +27,8 @@ export class NfcModalComponent implements OnInit { private device: Device, private attendance_service: AttendanceService, public modalController: ModalController, - public ts: TranslatorService + public ts: TranslatorService, + public ngZone: NgZone ) { } ngOnInit() { @@ -66,13 +67,19 @@ export class NfcModalComponent implements OnInit { this.modalController.dismiss(); }).subscribe((result: Response) => { if (this.common.validResponse(result)) { - this.gifStatus = true; + this.ngZone.run(() => { + this.gifStatus = true; + }); setTimeout(() => { this.modalController.dismiss(); this.common.openHome(); - }, 2000); + }, 4000); } }); } + public closeModal() { + this.modalController.dismiss(); + } + } diff --git a/Mohem/src/assets/localization/i18n.json b/Mohem/src/assets/localization/i18n.json index 537c0ef7..f6804469 100644 --- a/Mohem/src/assets/localization/i18n.json +++ b/Mohem/src/assets/localization/i18n.json @@ -898,6 +898,22 @@ "nfc-error": { "en": "NFC Scan Failed! Please try again", "ar": "فشل مسح NFC! حاول مرة اخرى" + }, + "nfc-detect": { + "en": "Detecting NFC to mark attendance", + "ar": "الكشف عن NFC للاحتفال بالحضور" + }, + "nfc-swipe-done": { + "en": "Swipe Attendance Done!", + "ar": "انتقد الحضور!" + }, + "nfc-detect-2": { + "en": "Keep device close to NFC spot", + "ar": "احتفظ بالجهاز بالقرب من بقعة NFC" + }, + "nfc-cancel": { + "en": "CANCEL", + "ar": "إلغاء" } }, "home": { diff --git a/Mohem/src/theme/styles.scss b/Mohem/src/theme/styles.scss index 1ab451d7..10f3448a 100644 --- a/Mohem/src/theme/styles.scss +++ b/Mohem/src/theme/styles.scss @@ -1377,8 +1377,8 @@ border:0px } .nfc-modal { - --height: 10cm !important; - --width: 88% !important; + --height: 11cm !important; + --width: 90% !important; --border-radius: 0.4cm; }