added changes for NFC

mohemm-issues-18-jan
umasoodch 5 years ago
parent 0816b3af40
commit 1424c27008

@ -17,6 +17,7 @@ import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/aut
import { LoginModel } from '../models/LoginModel'; import { LoginModel } from '../models/LoginModel';
import * as moment from 'moment'; import * as moment from 'moment';
import { CheckAppVersionResponse } from 'src/app/hmg-common/services/authentication/models/check-app-version.response'; import { CheckAppVersionResponse } from 'src/app/hmg-common/services/authentication/models/check-app-version.response';
import { NFC } from "@ionic-native/nfc/ngx";
@Component({ @Component({
selector: 'app-confirm-login', selector: 'app-confirm-login',
@ -47,7 +48,7 @@ export class ConfirmLoginComponent implements OnInit {
public isPostNoLoad = true; public isPostNoLoad = true;
private iosLink: string; private iosLink: string;
private androidLink: string; private androidLink: string;
public isNFCAvailable = false;
constructor( constructor(
public ts: TranslatorService, public ts: TranslatorService,
@ -57,6 +58,7 @@ export class ConfirmLoginComponent implements OnInit {
private faio: FingerprintAIO, private faio: FingerprintAIO,
public pushService: PushService, public pushService: PushService,
public platform: Platform, public platform: Platform,
private nfc: NFC
) { ) {
this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
this.deviceToken = this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); this.deviceToken = this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
@ -73,6 +75,7 @@ export class ConfirmLoginComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.checkNFCStatus();
// **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 **//
@ -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() { 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();
@ -336,6 +356,7 @@ export class ConfirmLoginComponent implements OnInit {
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;
request.IsDeviceNFC = this.isNFCAvailable;
this.authService.checkSMS(request, () => {}, this.ts.trPK('general', 'ok')) this.authService.checkSMS(request, () => {}, this.ts.trPK('general', 'ok'))
.subscribe((result: SMSCheckResponse) => { .subscribe((result: SMSCheckResponse) => {
if (this.cs.validResponse(result)) { if (this.cs.validResponse(result)) {

@ -12,6 +12,7 @@ import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/mod
import { Password } from '../models/password'; import { Password } from '../models/password';
import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request'; import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request';
import * as moment from 'moment'; import * as moment from 'moment';
import { NFC } from "@ionic-native/nfc/ngx";
@Component({ @Component({
selector: 'app-sms-page', selector: 'app-sms-page',
@ -48,7 +49,7 @@ export class SmsPageComponent implements OnInit {
public isPostNoLoad = true; public isPostNoLoad = true;
loginType: any; loginType: any;
activeType: any; activeType: any;
public isNFCAvailable = false;
constructor( constructor(
public navCtrl: NavController, public navCtrl: NavController,
@ -58,9 +59,11 @@ export class SmsPageComponent implements OnInit {
public authService: AuthenticationService, public authService: AuthenticationService,
public sharedData: SharedDataService, public sharedData: SharedDataService,
public platform: Platform, public platform: Platform,
private nfc: NFC
) {} ) {}
ngOnInit() { ngOnInit() {
this.checkNFCStatus();
this.activeType=this.common.getActiveTypeLogin(); this.activeType=this.common.getActiveTypeLogin();
console.log("active "+ this.common.sharedService.getSharedData('active-type',true)); 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() { 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();
@ -169,6 +189,7 @@ export class SmsPageComponent implements OnInit {
request.activationCode = this.code; // code;this.activationCode; request.activationCode = this.code; // code;this.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;
request.IsDeviceNFC = this.isNFCAvailable;
this.authService.checkSMS(request, () => {}, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => { this.authService.checkSMS(request, () => {}, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => {
if (this.common.validResponse(result)) { if (this.common.validResponse(result)) {
AuthenticationService.servicePrivilage = result.Privilege_List; AuthenticationService.servicePrivilage = result.Privilege_List;

@ -134,7 +134,7 @@ export class AuthenticationService {
} else if (isIOS) { } else if (isIOS) {
mobileType = 'ios'; mobileType = 'ios';
} }
request.VersionID = 2.5; request.VersionID = 2.6;
request.Channel = 31; request.Channel = 31;
request.LanguageID = TranslatorService.getCurrentLanguageCode(); request.LanguageID = TranslatorService.getCurrentLanguageCode();
request.MobileType = mobileType; request.MobileType = mobileType;

@ -18,4 +18,5 @@ export class LoginRequest extends Request {
public static NATIONALITY_CODE = "Nationality_Code"; public static NATIONALITY_CODE = "Nationality_Code";
// isDentalAllowedBackend: false // isDentalAllowedBackend: false
isRegister: boolean; // false isRegister: boolean; // false
IsDeviceNFC: boolean;
} }

@ -4,6 +4,7 @@ import { Request } from 'src/app/hmg-common/services/models/request';
export class SMSCheckRequest extends Request { export class SMSCheckRequest extends Request {
LogInTokenID: string ; LogInTokenID: string ;
activationCode?: string; activationCode?: string;
IsDeviceNFC: boolean;
public static SHARED_DATA = 'check_activation_shared_data'; public static SHARED_DATA = 'check_activation_shared_data';
} }

@ -24,8 +24,8 @@ export class ConnectorService {
public static timeOut = 120 * 1000; public static timeOut = 120 * 1000;
// public static host = 'http://10.50.100.113:6060/'; // development service // public static host = 'http://10.50.100.113:6060/'; // development service
// public static host = 'https://uat.hmgwebservices.com/'; public static host = 'https://uat.hmgwebservices.com/';
public static host = 'https://hmgwebservices.com/'; // public static host = 'https://hmgwebservices.com/';
// public static host = 'http://10.50.100.198:6060/'; // 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.113:6060/'; // development service
/* public static host = 'http://10.50.100.198:6060/'; /* public static host = 'http://10.50.100.198:6060/';

@ -1,45 +1,37 @@
<app-generic-header <app-generic-header
showBack="true" showBack="true"
backLink="/home" backLink="/home"
[headerText]="'general,option-attendance' | translate" [headerText]="'general,option-attendance' | translate">
>
</app-generic-header> </app-generic-header>
<ion-content> <ion-content>
<ion-grid *ngIf="!nfcIOSSuccess" class="attendance-grid"> <ion-grid *ngIf="!nfcIOSSuccess" class="attendance-grid">
<ion-row> <ion-row>
<ion-col size="12" class="nfc-clock"> <ion-col size="12" class="nfc-clock">
<img src="../assets/imgs/nfc_clock.png" /> <img src="../assets/imgs/nfc_clock.png" />
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
<ion-col padding> <ion-col padding>
<h4>{{ "general, select-attendance" | translate }}</h4> <h4>{{ "general, select-attendance" | translate }}</h4>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row padding> <ion-row padding>
<ion-col <ion-col size="5" [ngClass]="{'margin-col': direction === 'en', 'disable-attendance': !serviceEnableNFC}" class="buttonStyle" >
size="5"
[ngClass]="{
'margin-col': direction === 'en',
'disable-attendance': !serviceEnableNFC
}"
class="buttonStyle"
>
<div class="textAndIcon" (click)="checkNFCStatus('two')"> <div class="textAndIcon" (click)="checkNFCStatus('two')">
<img src="../assets/imgs/nfc_icon.png" /> <img src="../assets/imgs/nfc_icon.png" />
<p>{{ "general, nfc-text" | translate }}</p> <p>{{ "general, nfc-text" | translate }}</p>
</div> </div>
</ion-col> </ion-col>
<ion-col <ion-col
[ngClass]="{ [ngClass]="{'margin-col-right': direction === 'ar','disable-attendance': !serviceEnableQR}"
'margin-col-right': direction === 'ar',
'disable-attendance': !serviceEnableQR
}"
size="5" size="5"
offset="1" offset="1"
class="buttonStyle" class="buttonStyle">
>
<div class="textAndIcon" (click)="startQRCode()"> <div class="textAndIcon" (click)="startQRCode()">
<img src="../assets/imgs/nfc_QR.png" /> <img src="../assets/imgs/nfc_QR.png" />
<p>{{ "general, qr-text" | translate }}</p> <p>{{ "general, qr-text" | translate }}</p>
@ -47,10 +39,8 @@
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-grid> </ion-grid>
<div
*ngIf="nfcIOSSuccess" <div *ngIf="nfcIOSSuccess" style="display: block; text-align: center; margin-top: 50%" >
style="display: block; text-align: center; margin-top: 50%"
>
<img src="../assets/imgs/check.png" /> <img src="../assets/imgs/check.png" />
</div> </div>
</ion-content> </ion-content>

@ -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 { NFC } from "@ionic-native/nfc/ngx";
import { CommonService } from "src/app/hmg-common/services/common/common.service"; import { CommonService } from "src/app/hmg-common/services/common/common.service";
import { Platform } from "@ionic/angular"; import { Platform } from "@ionic/angular";
@ -36,7 +36,8 @@ export class AttendanceOptionsComponent implements OnInit {
public ts: TranslatorService, public ts: TranslatorService,
public modalController: ModalController, public modalController: ModalController,
private device: Device, private device: Device,
private attendance_service: AttendanceService private attendance_service: AttendanceService,
public ngZone: NgZone
) {} ) {}
ngOnInit() { ngOnInit() {
@ -132,10 +133,12 @@ export class AttendanceOptionsComponent implements OnInit {
}) })
.subscribe((result: Response) => { .subscribe((result: Response) => {
if (this.common.validResponse(result)) { if (this.common.validResponse(result)) {
this.nfcIOSSuccess = true; this.ngZone.run(() => {
this.nfcIOSSuccess = true;
});
setTimeout(() => { setTimeout(() => {
this.common.openHome(); this.common.openHome();
}, 1000); }, 4000);
} }
}); });
} }

@ -1,15 +1,16 @@
<ion-content> <ion-content>
<div style="display: block; text-align: center;"> <div class="heading-div">
<p *ngIf="!gifStatus" style="font-size: 20px;">Detecting NFC for marking attendance</p> <p *ngIf="!gifStatus" class="heading-text">{{ "general, nfc-detect" | translate }}</p>
<p *ngIf="gifStatus" style="font-size: 20px;">Swipe Attendance Done!</p> <p *ngIf="gifStatus" class="heading-text">{{ "general, nfc-swipe-done" | translate }}</p>
</div> </div>
<div *ngIf="!gifStatus" style="display: block; text-align: center;margin-top: -50px;"> <div *ngIf="!gifStatus" class="ripple-div">
<img src="../assets/imgs/rippleNFC.gif" /> <img src="../assets/imgs/rippleNFC.gif" />
<p>{{ "general, nfc-detect-2" | translate }}</p>
<ion-button (click)="closeModal();">{{ "general, nfc-cancel" | translate }}</ion-button>
</div> </div>
<div *ngIf="gifStatus" style="display: block; text-align: center;margin-top: 25%;"> <div *ngIf="gifStatus" class="checked-img">
<img src="../assets/imgs/check.png" /> <img src="../assets/imgs/check.png" />
</div> </div>
</ion-content> </ion-content>

@ -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%;
}

@ -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 { NFC } from "@ionic-native/nfc/ngx"
import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import {AttendScanService} from '../../hmg-common/services/attend-services/attend-scan.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 device: Device,
private attendance_service: AttendanceService, private attendance_service: AttendanceService,
public modalController: ModalController, public modalController: ModalController,
public ts: TranslatorService public ts: TranslatorService,
public ngZone: NgZone
) { } ) { }
ngOnInit() { ngOnInit() {
@ -66,13 +67,19 @@ export class NfcModalComponent implements OnInit {
this.modalController.dismiss(); this.modalController.dismiss();
}).subscribe((result: Response) => { }).subscribe((result: Response) => {
if (this.common.validResponse(result)) { if (this.common.validResponse(result)) {
this.gifStatus = true; this.ngZone.run(() => {
this.gifStatus = true;
});
setTimeout(() => { setTimeout(() => {
this.modalController.dismiss(); this.modalController.dismiss();
this.common.openHome(); this.common.openHome();
}, 2000); }, 4000);
} }
}); });
} }
public closeModal() {
this.modalController.dismiss();
}
} }

@ -898,6 +898,22 @@
"nfc-error": { "nfc-error": {
"en": "NFC Scan Failed! Please try again", "en": "NFC Scan Failed! Please try again",
"ar": "فشل مسح NFC! حاول مرة اخرى" "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": { "home": {

@ -1377,8 +1377,8 @@ border:0px
} }
.nfc-modal { .nfc-modal {
--height: 10cm !important; --height: 11cm !important;
--width: 88% !important; --width: 90% !important;
--border-radius: 0.4cm; --border-radius: 0.4cm;
} }

Loading…
Cancel
Save