added changes for NFC

MOHEMM-SFH-COLORS
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 * 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)) {

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

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

@ -18,4 +18,5 @@ export class LoginRequest extends Request {
public static NATIONALITY_CODE = "Nationality_Code";
// isDentalAllowedBackend: 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 {
LogInTokenID: string ;
activationCode?: string;
IsDeviceNFC: boolean;
public static SHARED_DATA = 'check_activation_shared_data';
}

@ -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/';

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

@ -1,15 +1,16 @@
<ion-content>
<div style="display: block; text-align: center;">
<p *ngIf="!gifStatus" style="font-size: 20px;">Detecting NFC for marking attendance</p>
<p *ngIf="gifStatus" style="font-size: 20px;">Swipe Attendance Done!</p>
<div class="heading-div">
<p *ngIf="!gifStatus" class="heading-text">{{ "general, nfc-detect" | translate }}</p>
<p *ngIf="gifStatus" class="heading-text">{{ "general, nfc-swipe-done" | translate }}</p>
</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" />
<p>{{ "general, nfc-detect-2" | translate }}</p>
<ion-button (click)="closeModal();">{{ "general, nfc-cancel" | translate }}</ion-button>
</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" />
</div>
</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 { 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();
}
}

@ -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": {

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

Loading…
Cancel
Save