added NFC for hmg mohemm
parent
2e1860b798
commit
908fc58af0
@ -0,0 +1,56 @@
|
|||||||
|
<app-generic-header
|
||||||
|
showBack="true"
|
||||||
|
backLink="/home"
|
||||||
|
[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"
|
||||||
|
>
|
||||||
|
<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
|
||||||
|
}"
|
||||||
|
size="5"
|
||||||
|
offset="1"
|
||||||
|
class="buttonStyle"
|
||||||
|
>
|
||||||
|
<div class="textAndIcon" (click)="startQRCode()">
|
||||||
|
<img src="../assets/imgs/nfc_QR.png" />
|
||||||
|
<p>{{ "general, qr-text" | translate }}</p>
|
||||||
|
</div>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
</ion-grid>
|
||||||
|
<div
|
||||||
|
*ngIf="nfcIOSSuccess"
|
||||||
|
style="display: block; text-align: center; margin-top: 50%"
|
||||||
|
>
|
||||||
|
<img src="../assets/imgs/check.png" />
|
||||||
|
</div>
|
||||||
|
</ion-content>
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
.attendance-grid {
|
||||||
|
padding-right: 20px;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
.nfc-clock {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
.buttonStyle{
|
||||||
|
border: 1px solid black;
|
||||||
|
border-radius: 16px;
|
||||||
|
height: 120px;
|
||||||
|
text-align: -webkit-center;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.margin-col {
|
||||||
|
margin-right: 15px !important;
|
||||||
|
}
|
||||||
|
.margin-col-right {
|
||||||
|
margin-right: 25px !important ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textAndIcon{
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
.disable-attendance {
|
||||||
|
opacity: .2;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { AttendanceOptionsComponent } from './attendance-options.component';
|
||||||
|
|
||||||
|
describe('AttendanceOptionsComponent', () => {
|
||||||
|
let component: AttendanceOptionsComponent;
|
||||||
|
let fixture: ComponentFixture<AttendanceOptionsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ AttendanceOptionsComponent ],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(AttendanceOptionsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,156 @@
|
|||||||
|
import { Component, OnInit } 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";
|
||||||
|
import { AttendScanService } from "../../hmg-common/services/attend-services/attend-scan.service";
|
||||||
|
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
|
||||||
|
import { ModalController } from "@ionic/angular";
|
||||||
|
import { NfcModalComponent } from "../nfc-modal/nfc-modal.component";
|
||||||
|
import { AuthenticatedUser } from "../../hmg-common/services/authentication/models/authenticated-user";
|
||||||
|
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
|
||||||
|
import { attendanceSwipeScannerRequest } from "src/app/home/models/attendanceSwipe.Request";
|
||||||
|
import { Device } from "@ionic-native/device/ngx";
|
||||||
|
import { AttendanceService } from "src/app/home/services/attendance.services";
|
||||||
|
import { Response } from "src/app/hmg-common/services/models/response";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-attendance-options",
|
||||||
|
templateUrl: "./attendance-options.component.html",
|
||||||
|
styleUrls: ["./attendance-options.component.scss"],
|
||||||
|
})
|
||||||
|
export class AttendanceOptionsComponent implements OnInit {
|
||||||
|
public location: boolean;
|
||||||
|
public direction: string;
|
||||||
|
public userData: any = {};
|
||||||
|
public priviligeList: any;
|
||||||
|
public serviceEnableNFC = false;
|
||||||
|
public serviceEnableQR = false;
|
||||||
|
public deviceNFC = false;
|
||||||
|
public nfcIOSSuccess = false;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private nfc: NFC,
|
||||||
|
public common: CommonService,
|
||||||
|
public platform: Platform,
|
||||||
|
public attendScanService: AttendScanService,
|
||||||
|
public ts: TranslatorService,
|
||||||
|
public modalController: ModalController,
|
||||||
|
private device: Device,
|
||||||
|
private attendance_service: AttendanceService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.direction = TranslatorService.getCurrentLanguageName();
|
||||||
|
this.userData = this.common.sharedService.getSharedData(
|
||||||
|
AuthenticatedUser.SHARED_DATA,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
this.priviligeList = AuthenticationService.servicePrivilage;
|
||||||
|
this.setServicesPrivilage();
|
||||||
|
this.checkNFCStatus("one");
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkNFCStatus(checkValue: string) {
|
||||||
|
try {
|
||||||
|
let nfcStatus = await this.nfc.enabled();
|
||||||
|
console.log("nfc status >>>>>>>>>>" + nfcStatus);
|
||||||
|
if (nfcStatus === "NFC_OK") {
|
||||||
|
this.deviceNFC = true;
|
||||||
|
if (checkValue === "two") {
|
||||||
|
this.startNFC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nfcStatus === null && checkValue === "two") {
|
||||||
|
this.startNFC();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Error reading tag", err);
|
||||||
|
if (err === "NO_NFC") {
|
||||||
|
this.deviceNFC = false;
|
||||||
|
} else if (err === "NFC_DISABLED") {
|
||||||
|
this.deviceNFC = true;
|
||||||
|
if (checkValue === "two") {
|
||||||
|
this.common.presentAlert(this.ts.trPK("general", "nfc-settings"));
|
||||||
|
}
|
||||||
|
} else if (checkValue === "two") {
|
||||||
|
this.common.presentAlert(this.ts.trPK("general", "nfc-error"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public setServicesPrivilage() {
|
||||||
|
for (const servicePrivilage of AuthenticationService.servicePrivilage) {
|
||||||
|
if (
|
||||||
|
servicePrivilage.Previlege &&
|
||||||
|
servicePrivilage.ServiceName === "enableNFC"
|
||||||
|
) {
|
||||||
|
this.serviceEnableNFC = true;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
servicePrivilage.Previlege &&
|
||||||
|
servicePrivilage.ServiceName === "enableQR"
|
||||||
|
) {
|
||||||
|
this.serviceEnableQR = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async startIOSNfc() {
|
||||||
|
try {
|
||||||
|
let tag = await this.nfc.scanTag();
|
||||||
|
console.log(JSON.stringify(tag));
|
||||||
|
const serialNumber = this.nfc.bytesToHexString(tag.id);
|
||||||
|
this.swipeAttendanceNFC(serialNumber);
|
||||||
|
} catch (err) {
|
||||||
|
this.common.presentAlert(this.ts.trPK("general", "nfc-error"));
|
||||||
|
console.log("Error reading tag", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async nfcModal() {
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: NfcModalComponent,
|
||||||
|
showBackdrop: true,
|
||||||
|
backdropDismiss: true,
|
||||||
|
});
|
||||||
|
modal.cssClass = "nfc-modal";
|
||||||
|
await modal.present();
|
||||||
|
}
|
||||||
|
|
||||||
|
public swipeAttendanceNFC(nfcSerialCode: any) {
|
||||||
|
const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest();
|
||||||
|
request.PointType = 2;
|
||||||
|
request.Latitude = 0;
|
||||||
|
request.Longitude = 0;
|
||||||
|
request.QRValue = "";
|
||||||
|
request.NFCValue = nfcSerialCode;
|
||||||
|
request.UID = this.device.uuid;
|
||||||
|
request.UserName = this.userData.EMPLOYEE_NUMBER;
|
||||||
|
this.attendance_service
|
||||||
|
.attendanceSwipeScanner(request, () => {
|
||||||
|
console.log("Error inside in swipe attendance");
|
||||||
|
})
|
||||||
|
.subscribe((result: Response) => {
|
||||||
|
if (this.common.validResponse(result)) {
|
||||||
|
this.nfcIOSSuccess = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.common.openHome();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public startNFC() {
|
||||||
|
const isAndroid = this.platform.is("android");
|
||||||
|
const isIOS = this.platform.is("ios");
|
||||||
|
if (isAndroid) {
|
||||||
|
this.nfcModal();
|
||||||
|
} else if (isIOS) {
|
||||||
|
this.startIOSNfc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public startQRCode() {
|
||||||
|
this.attendScanService.getDeviceLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
<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>
|
||||||
|
|
||||||
|
<div *ngIf="!gifStatus" style="display: block; text-align: center;margin-top: -50px;">
|
||||||
|
<img src="../assets/imgs/rippleNFC.gif" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div *ngIf="gifStatus" style="display: block; text-align: center;margin-top: 25%;">
|
||||||
|
<img src="../assets/imgs/check.png" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</ion-content>
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NfcModalComponent } from './nfc-modal.component';
|
||||||
|
|
||||||
|
describe('NfcModalComponent', () => {
|
||||||
|
let component: NfcModalComponent;
|
||||||
|
let fixture: ComponentFixture<NfcModalComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ NfcModalComponent ],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(NfcModalComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 442 KiB |
Loading…
Reference in New Issue