added NFC for hmg mohemm

enad-Q1-HMG
umasoodch 5 years ago
parent 2e1860b798
commit 908fc58af0

@ -29,7 +29,7 @@ export class AppComponent implements OnInit, AfterViewInit {
user_image: any = '../assets/imgs/profile.png'; user_image: any = '../assets/imgs/profile.png';
menuSide = 'left'; menuSide = 'left';
notBadge: number; notBadge: number;
companyUrl = '../assets/imgs/HMG.png'; companyUrl = '../assets/imgs/CSLogo.png';
companyDesc = 'Powered By Cloud Solutions'; companyDesc = 'Powered By Cloud Solutions';
direction = 'ltr'; direction = 'ltr';
User_Job_name: string; User_Job_name: string;
@ -122,7 +122,7 @@ export class AppComponent implements OnInit, AfterViewInit {
if (user) { if (user) {
this.companyUrl = user.CompanyImageURL this.companyUrl = user.CompanyImageURL
? user.CompanyImageURL ? user.CompanyImageURL
: '../assets/imgs/HMG.png'; : '../assets/imgs/CSLogo.png';
this.companyDesc = user.CompanyImageDescription this.companyDesc = user.CompanyImageDescription
? user.CompanyImageDescription ? user.CompanyImageDescription

@ -16,7 +16,7 @@ import { File } from '@ionic-native/file/ngx';
import { Base64 } from '@ionic-native/base64/ngx'; import { Base64 } from '@ionic-native/base64/ngx';
import { FirebaseX } from '@ionic-native/firebase-x/ngx'; import { FirebaseX } from '@ionic-native/firebase-x/ngx';
import { NgCalendarModule } from 'ionic2-calendar'; import { NgCalendarModule } from 'ionic2-calendar';
import { NFC, Ndef} from "@ionic-native/nfc/ngx"
@NgModule({ @NgModule({
declarations: [AppComponent], declarations: [AppComponent],
@ -41,7 +41,9 @@ import { NgCalendarModule } from 'ionic2-calendar';
FilePath, FilePath,
Base64, Base64,
FirebaseX, FirebaseX,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy } { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
NFC,
Ndef
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })

@ -129,12 +129,13 @@ export class HomeComponent implements OnInit {
} }
openDialog() { openDialog() {
this.cs.confirmAlertDialogAttendance(() => { // this.cs.confirmAlertDialogAttendance(() => {
this.attendScanService.getDeviceLocation(); // this.attendScanService.getDeviceLocation();
}, this.ts.trPK('general', 'ok'), // }, this.ts.trPK('general', 'ok'),
() => {}, this.ts.trPK('general', 'cancel'), // () => {}, this.ts.trPK('general', 'cancel'),
this.ts.trPK('vacation-rule', 'confirmation'), // this.ts.trPK('vacation-rule', 'confirmation'),
this.ts.trPK('attendance-tracking', 'confirm-alert1')); // this.ts.trPK('attendance-tracking', 'confirm-alert1'));
} this.cs.openAttendanceOptionsComponent();
}
} }

@ -44,7 +44,7 @@ export class CheckUserComponent implements OnInit {
return false; return false;
} }
return true; return true;
} }
public userCheck() public userCheck()
{ {

@ -48,6 +48,7 @@ export class ConfirmLoginComponent implements OnInit {
private iosLink: string; private iosLink: string;
private androidLink: string; private androidLink: string;
constructor( constructor(
public ts: TranslatorService, public ts: TranslatorService,
public cs: CommonService, public cs: CommonService,

@ -9,7 +9,7 @@
<ion-col [size]="4"> <ion-col [size]="4">
<img [src]="logo" class="logo" /> <img [src]="logo" class="logo" />
<ion-img class="centerDiv" src="../assets/imgs/CSLogo.png"></ion-img> <ion-img class="centerDiv" src="../assets/imgs/CS.png"></ion-img>
</ion-col> </ion-col>
</ion-row> --> </ion-row> -->
<br/> <br/>

@ -119,6 +119,7 @@ import { DateInfoModalComponent } from './ui/circle-calendar/date-info-modal/dat
import { ChartModule } from 'primeng/chart'; import { ChartModule } from 'primeng/chart';
import { GenericHeaderComponent } from './ui/generic-header/generic-header.component'; import { GenericHeaderComponent } from './ui/generic-header/generic-header.component';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'; import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { AttendanceOptionsComponent } from '../home/attendance-options/attendance-options.component';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
@ -201,7 +202,8 @@ import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'
CircleCalendarComponent, CircleCalendarComponent,
DateInfoModalComponent, DateInfoModalComponent,
Modal, Modal,
GenericHeaderComponent GenericHeaderComponent,
AttendanceOptionsComponent
], ],
exports: [ exports: [
FabButtonComponent, FabButtonComponent,
@ -272,7 +274,8 @@ import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'
ChartModule, ChartModule,
FileUploadModule, FileUploadModule,
Modal, Modal,
GenericHeaderComponent GenericHeaderComponent,
AttendanceOptionsComponent
], ],
providers: [ providers: [
AttendScanService, AttendScanService,

@ -16,6 +16,8 @@ import { DevicePermissionsService } from '../../services/device-permissions/devi
import { Device } from '@ionic-native/device/ngx'; import { Device } from '@ionic-native/device/ngx';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'; import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { ModalController } from '@ionic/angular';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -29,6 +31,7 @@ export class AttendScanService {
scannedResult: any; scannedResult: any;
userData: any = {}; userData: any = {};
public isFakeLocationUsed = false; public isFakeLocationUsed = false;
constructor(private device: Device, constructor(private device: Device,
private zbar: ZBar, private zbar: ZBar,
private geolocation: Geolocation, private geolocation: Geolocation,
@ -41,7 +44,9 @@ export class AttendScanService {
public common: CommonService, public common: CommonService,
public ts: TranslatorService, public ts: TranslatorService,
public backgroundGeolocation: BackgroundGeolocation, public backgroundGeolocation: BackgroundGeolocation,
public platform: Platform ) { public platform: Platform,
public modalController: ModalController
) {
this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false); this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false);
} }
@ -100,7 +105,6 @@ export class AttendScanService {
); );
} }
scanCode() { scanCode() {
this.barcodeScanner this.barcodeScanner
.scan() .scan()
@ -135,11 +139,14 @@ export class AttendScanService {
}); });
} }
public swipeAttendance() { public swipeAttendance() {
const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest(); const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest();
request.PointType = 1;
request.Latitude = this.lat; request.Latitude = this.lat;
request.Longitude = this.longt; request.Longitude = this.longt;
request.QRValue = this.scannedResult.text; request.QRValue = this.scannedResult.text;
request.NFCValue = '';
request.UID = this.deviceID; request.UID = this.deviceID;
request.UserName = this.userData.EMPLOYEE_NUMBER; request.UserName = this.userData.EMPLOYEE_NUMBER;
console.log('request'); console.log('request');
@ -154,9 +161,25 @@ export class AttendScanService {
console.log(result); console.log(result);
this.common.presentAlert(this.ts.trPK('home', 'swipeAlertSuccess')); this.common.presentAlert(this.ts.trPK('home', 'swipeAlertSuccess'));
} }
// else {
// this.common.presentAlert(this.ts.trPK("home", "swipeAlertFailed"));
// }
}); });
} }
// 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.modalController.dismiss();
// }
// });
// }
} }

@ -138,6 +138,7 @@ export class AuthenticationService {
request.Channel = 33; request.Channel = 33;
request.LanguageID = TranslatorService.getCurrentLanguageCode(); request.LanguageID = TranslatorService.getCurrentLanguageCode();
request.MobileType = mobileType; request.MobileType = mobileType;
return request; return request;
} }
public authenticateAndSetPersonalInformation( public authenticateAndSetPersonalInformation(
@ -209,7 +210,7 @@ export class AuthenticationService {
public login(request: LoginRequest, onError: any, errorLabel: string): Observable<Response> { public login(request: LoginRequest, onError: any, errorLabel: string): Observable<Response> {
this.setPublicFields(request); this.setPublicFields(request);
request.P_APP_VERSION="HMG"; request.P_APP_VERSION="CS";
return this.con.post(AuthenticationService.login, request, onError, errorLabel); return this.con.post(AuthenticationService.login, request, onError, errorLabel);
} }
@ -464,7 +465,7 @@ export class AuthenticationService {
public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string) public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> { : Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request); this.setPublicFields(request);
request.P_APP_VERSION="HMG"; request.P_APP_VERSION="CS";
return this.con.post(AuthenticationService.userChecking, request, onError, errorLabel); return this.con.post(AuthenticationService.userChecking, request, onError, errorLabel);
} }

@ -1076,7 +1076,9 @@ public getMonthNameAr(value: number): string {
*/ */
public openAttenTrackingpage(){ public openAttenTrackingpage(){
this.nav.navigateForward(['/attendance-tracking/home']); this.nav.navigateForward(['/attendance-tracking/home']);
}
public openAttendanceOptionsComponent(){
this.nav.navigateForward(['/home/attendance-option']);
} }
public openEitListPage() { public openEitListPage() {
this.nav.navigateForward(['/eit/eit-list']); this.nav.navigateForward(['/eit/eit-list']);

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

@ -8,7 +8,7 @@
<ion-grid> <ion-grid>
<ion-row> <ion-row>
<ion-col class="colPad"> <ion-col class="colPad">
<ion-img class="centerDiv" src="../assets/imgs/HMG.png"></ion-img> <ion-img class="centerDiv" src="../assets/imgs/CSLogo.png"></ion-img>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>

@ -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();
}
}

@ -7,14 +7,20 @@ import { IonicModule } from '@ionic/angular';
import { HomePage } from './home.page'; import { HomePage } from './home.page';
import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx'; import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';
import { WorklistMainService } from '../notification/service/work-list.main.service'; import { WorklistMainService } from '../notification/service/work-list.main.service';
import { AttendanceOptionsComponent } from './attendance-options/attendance-options.component';
import { NfcModalComponent } from './nfc-modal/nfc-modal.component';
const routes: Routes = [ const routes: Routes = [
{ {
path: '', path: '',
component: HomePage, component: HomePage,
},
{
path:'attendance-option',
component:AttendanceOptionsComponent
} }
]; ];
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
@ -24,11 +30,13 @@ const routes: Routes = [
RouterModule.forChild(routes) RouterModule.forChild(routes)
], ],
declarations: [ declarations: [
HomePage HomePage,
NfcModalComponent
], ],
providers: [ providers: [
BarcodeScanner, BarcodeScanner,
WorklistMainService WorklistMainService
] ],
entryComponents: [NfcModalComponent]
}) })
export class HomePageModule { } export class HomePageModule { }

@ -89,7 +89,7 @@ ion-label{
ion-button{ ion-button{
border-radius: 10px; border-radius: 10px;
padding: 10px; padding: 10px;
background: #269DB8; background: #269db8;
--background: transparent; --background: transparent;
--box-shadow: none !important; --box-shadow: none !important;
height: auto; height: auto;

@ -37,6 +37,8 @@ import { WorklistMainService } from '../notification/service/work-list.main.serv
import { isThisISOWeek } from 'date-fns'; import { isThisISOWeek } from 'date-fns';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'; import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { NFC, Ndef} from "@ionic-native/nfc/ngx"
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
templateUrl: './home.page.html', templateUrl: './home.page.html',
@ -129,7 +131,6 @@ export class HomePage implements OnInit {
public vacationRuleIcon: string; public vacationRuleIcon: string;
direction: string; direction: string;
public isPostNoLoad = true; public isPostNoLoad = true;
public locationResponse: any;
constructor( constructor(
public ts: TranslatorService, public ts: TranslatorService,
@ -154,7 +155,8 @@ export class HomePage implements OnInit {
public workListService: WorklistMainService, public workListService: WorklistMainService,
public router: Router, public router: Router,
private platform: Platform, private platform: Platform,
public backgroundGeolocation: BackgroundGeolocation public backgroundGeolocation: BackgroundGeolocation,
private nfc: NFC
) { ) {
this.events.subscribe('img-change', displayImg => { this.events.subscribe('img-change', displayImg => {
this.userImage = this.sanitizer.bypassSecurityTrustUrl( this.userImage = this.sanitizer.bypassSecurityTrustUrl(
@ -250,7 +252,6 @@ export class HomePage implements OnInit {
if (this.platform.is('android')) { if (this.platform.is('android')) {
this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => {
if (resp && (resp.latitude && resp.longitude)) { if (resp && (resp.latitude && resp.longitude)) {
this.locationResponse = resp;
if (resp.isFromMockProvider || resp.mockLocationsEnabled) { if (resp.isFromMockProvider || resp.mockLocationsEnabled) {
this.isFakeLocationUsed = true; this.isFakeLocationUsed = true;
} }
@ -557,9 +558,6 @@ export class HomePage implements OnInit {
this.common.presentAlert(this.ts.trPK('home', 'swipeAlertSuccess')); this.common.presentAlert(this.ts.trPK('home', 'swipeAlertSuccess'));
this.showAttendanceTracking(); this.showAttendanceTracking();
} }
// else {
// this.common.presentAlert(this.ts.trPK('home', 'swipeAlertFailed'));
// }
}); });
} }
@ -744,11 +742,16 @@ openattentracking() {
this.common.openAttenTrackingpage(); this.common.openAttenTrackingpage();
} }
public showAttendanceOptions() {
this.common.openAttendanceOptionsComponent();
}
openStatsButton(link: any) { openStatsButton(link: any) {
// tslint:disable-next-line: triple-equals // tslint:disable-next-line: triple-equals
if (link == '0') { if (link == '0') {
this.isFakeLocationUsed = false; this.isFakeLocationUsed = false;
this.getDeviceLocation(); // this.getDeviceLocation();
this.showAttendanceOptions();
// tslint:disable-next-line: triple-equals // tslint:disable-next-line: triple-equals
} else if (link == '1') { } else if (link == '1') {
this.common.startLoading(); this.common.startLoading();

@ -15,6 +15,8 @@ export class attendanceSwipeScannerRequest extends Request{
public EmployeeID: number; public EmployeeID: number;
public IPAdress: string; public IPAdress: string;
public UserID: string; public UserID: string;
public PointType: number;
public NFCValue: string;
} }

@ -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();
});
});

@ -0,0 +1,78 @@
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 {AttendScanService} from '../../hmg-common/services/attend-services/attend-scan.service';
import { attendanceSwipeScannerRequest } from 'src/app/home/models/attendanceSwipe.Request';
import { Device } from '@ionic-native/device/ngx';
import { AuthenticatedUser } from '../../hmg-common/services/authentication/models/authenticated-user';
import { AttendanceService } from 'src/app/home/services/attendance.services';
import { Response } from 'src/app/hmg-common/services/models/response';
import { ModalController } from '@ionic/angular';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
@Component({
selector: 'app-nfc-modal',
templateUrl: './nfc-modal.component.html',
styleUrls: ['./nfc-modal.component.scss'],
})
export class NfcModalComponent implements OnInit {
public userData: any = {};
public gifStatus = false;
public nfcReader: any;
constructor(
private nfc: NFC,
public common: CommonService,
public attendScanService: AttendScanService,
private device: Device,
private attendance_service: AttendanceService,
public modalController: ModalController,
public ts: TranslatorService
) { }
ngOnInit() {
this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false);
this.startAndroidNfc();
}
ionViewDidLeave() {
this.nfcReader.unsubscribe();
}
async startAndroidNfc() {
let flags = this.nfc.FLAG_READER_NFC_A | this.nfc.FLAG_READER_NFC_V;
this.nfcReader = this.nfc.readerMode(flags).subscribe((tag) => {
const serialNumber = this.nfc.bytesToHexString(tag.id);
this.swipeAttendanceNFC(serialNumber);
}, (error) => {
this.modalController.dismiss();
this.common.presentAlert(this.ts.trPK('general', 'nfc-error'));
console.log('error =====>>>>>> + + + =' + error);
});
}
public swipeAttendanceNFC (nfcSerialCode: any) {
this.nfcReader.unsubscribe();
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');
this.modalController.dismiss();
}).subscribe((result: Response) => {
if (this.common.validResponse(result)) {
this.gifStatus = true;
setTimeout(() => {
this.modalController.dismiss();
this.common.openHome();
}, 2000);
}
});
}
}

@ -7,8 +7,9 @@ import { attendanceSwipeScannerRequest } from '../models/attendanceSwipe.Request
providedIn: "root" providedIn: "root"
}) })
export class AttendanceService { export class AttendanceService {
public AttendanceSwipeURL : string ='Services/SWP.svc/REST/AuthenticateAndSwipeUser'; public AttendanceSwipeURL : string ='Services/SWP.svc/REST/AuthenticateAndSwipeUserSupportNFC';
public FakeAttendanceSwipeURL : string ='Services/SWP.svc/REST/CreateIssueInfo'; public FakeAttendanceSwipeURL : string ='Services/SWP.svc/REST/CreateIssueInfo';
constructor( constructor(
public con: ConnectorService, public con: ConnectorService,
public authService: AuthenticationService public authService: AuthenticationService
@ -18,7 +19,6 @@ export class AttendanceService {
this.authService.authenticateRequest(request); this.authService.authenticateRequest(request);
return this.con.post(this.AttendanceSwipeURL,request,onError,errorLabel); return this.con.post(this.AttendanceSwipeURL,request,onError,errorLabel);
} }
public fakeAttendanceSwipeScanner(request, onError?: any, errorLabel?: string): Observable<any> { public fakeAttendanceSwipeScanner(request, onError?: any, errorLabel?: string): Observable<any> {
this.authService.authenticateRequest(request); this.authService.authenticateRequest(request);
return this.con.post(this.FakeAttendanceSwipeURL,request,onError,errorLabel); return this.con.post(this.FakeAttendanceSwipeURL,request,onError,errorLabel);

@ -381,7 +381,7 @@ left: -35px;
border-radius: 50%; border-radius: 50%;
width: 15px; width: 15px;
height: 15px; height: 15px;
background-color: #269DB8; background-color: #269db8;
top: 1px; top: 1px;
} }

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

@ -209,6 +209,10 @@
} }
}, },
"general": { "general": {
"location-permission-dialog": {
"en": "Allow the Mohemm app to access your location for marking your attendance",
"ar": "اسمح لتطبيق مهم بالوصول إلى موقعك لتحديد حضورك"
},
"not-now":{ "not-now":{
"en":"not now", "en":"not now",
"ar":"لاحقاً" "ar":"لاحقاً"
@ -870,6 +874,30 @@
"deletePerm": { "deletePerm": {
"en": "Are you sure from deleting this file permanently?", "en": "Are you sure from deleting this file permanently?",
"ar": "هل أنت متأكد من حذف هذا الملف نهائيًا؟" "ar": "هل أنت متأكد من حذف هذا الملف نهائيًا؟"
},
"option-attendance": {
"en":"Attendance Options",
"ar":"خيارات التبصيم"
},
"select-attendance": {
"en": "Select Method to Mark your Attendance",
"ar": "حدد طريقة لتمييز الحضور الخاص بك"
},
"nfc-text": {
"en": "NFC",
"ar": "NFC"
},
"qr-text": {
"en": "QR Code",
"ar": "الشفرة QR"
},
"nfc-settings": {
"en": "Please enable NFC on your device",
"ar": "يرجى تمكين NFC على جهازك"
},
"nfc-error": {
"en": "NFC Scan Failed! Please try again",
"ar": "فشل مسح NFC! حاول مرة اخرى"
} }
}, },
"home": { "home": {
@ -879,7 +907,7 @@
}, },
"position-error": { "position-error": {
"en": "Error getting your location. Please try again!", "en": "Error getting your location. Please try again!",
"ar": "Error getting your location. Please try again!" "ar": "خطأ في الحصول على موقعك. حاول مرة اخرى!"
}, },
"dashboard": { "dashboard": {
"en": "My Dashboard", "en": "My Dashboard",

@ -1376,6 +1376,12 @@ border:0px
--border-radius: 0.4cm; --border-radius: 0.4cm;
} }
.nfc-modal {
--height: 10cm !important;
--width: 88% !important;
--border-radius: 0.4cm;
}
.monthview-datetable { .monthview-datetable {
@media screen and (min-width: 300px) and (max-width:360px) { @media screen and (min-width: 300px) and (max-width:360px) {
*{ *{
@ -1531,5 +1537,5 @@ table.monthview-datetable th small {
} }
.disable-button-opacity { .disable-button-opacity {
opacity: .5; opacity: .2;
} }

Loading…
Cancel
Save