Merge branch 'master-newdesign-15-Dec-location' into enad-Q1

MOHEMM-Q3-DEV-LATEST
enadhilal 5 years ago
commit c0d4ab610d

@ -23,8 +23,8 @@
<ion-item class="item-input-login"> <ion-item class="item-input-login">
<img class="item-icon" src="assets/imgs/username.png" item-start /> <img class="item-icon" src="assets/imgs/username.png" item-start />
<ion-label>{{ts.trPK('login','check-user-place-holder')}}</ion-label> <!-- <ion-label>{{ts.trPK('login','check-user-place-holder')}}</ion-label> -->
<ion-input class="login-input" required type="text" [(ngModel)]="P_USER_NAME"> <ion-input placeholder="{{ts.trPK('login','check-user-place-holder')}}" class="login-input" required type="text" [(ngModel)]="P_USER_NAME">
</ion-input> </ion-input>
</ion-item> </ion-item>
</ion-grid> </ion-grid>

@ -25,12 +25,13 @@ import { ModalController } from '@ionic/angular';
export class AttendScanService { export class AttendScanService {
location: boolean; location: boolean;
camera: boolean; camera: boolean;
lat: any; lat = 0;
longt: any; longt = 0;
deviceID: string; deviceID: string;
scannedResult: any; scannedResult: any;
userData: any = {}; userData: any = {};
public isFakeLocationUsed = false; public isFakeLocationUsed = false;
public isGpsRequired = false;
constructor(private device: Device, constructor(private device: Device,
private zbar: ZBar, private zbar: ZBar,
@ -51,6 +52,7 @@ export class AttendScanService {
} }
getDeviceLocation() { getDeviceLocation() {
this.isGpsRequired = true;
this.isFakeLocationUsed = false; this.isFakeLocationUsed = false;
const isVirtual = this.device.isVirtual; const isVirtual = this.device.isVirtual;
if (isVirtual === true) { if (isVirtual === true) {
@ -69,7 +71,7 @@ export class AttendScanService {
} }
this.lat = resp.latitude; this.lat = resp.latitude;
this.longt = resp.longitude; this.longt = resp.longitude;
this.attendance(); this.attendance(true);
} else { } else {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); this.common.presentAlert(this.ts.trPK('home', 'position-error'));
@ -82,7 +84,7 @@ export class AttendScanService {
if(resp && resp.coords.latitude && resp.coords.longitude) { if(resp && resp.coords.latitude && resp.coords.longitude) {
this.lat = resp.coords.latitude; this.lat = resp.coords.latitude;
this.longt = resp.coords.longitude; this.longt = resp.coords.longitude;
this.attendance(); this.attendance(true);
} else { } else {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); this.common.presentAlert(this.ts.trPK('home', 'position-error'));
@ -97,7 +99,12 @@ export class AttendScanService {
}); });
} }
public attendance() { public attendance(isGPSValue: boolean) {
this.isGpsRequired = isGPSValue;
if (!this.isGpsRequired) {
this.lat = 0;
this.longt = 0;
}
this.permissions.requestCameraAutherization().then(granted => { this.permissions.requestCameraAutherization().then(granted => {
this.camera = granted as boolean; this.camera = granted as boolean;
if (this.camera) { if (this.camera) {
@ -150,6 +157,7 @@ export class AttendScanService {
request.NFCValue = ''; request.NFCValue = '';
request.UID = this.deviceID; request.UID = this.deviceID;
request.UserName = this.userData.EMPLOYEE_NUMBER; request.UserName = this.userData.EMPLOYEE_NUMBER;
request.IsGpsRequired = this.isGpsRequired;
console.log('request'); console.log('request');
console.log(JSON.stringify(request)); console.log(JSON.stringify(request));
this.attendance_service this.attendance_service

@ -35,8 +35,18 @@ export class PushService {
public startReceiving() { public startReceiving() {
console.log("startReceiving"); console.log("startReceiving");
this.processStartReceivingWithFirebase(); this.firebasex.hasPermission().then(hasPermission => {
} if (!hasPermission) {
this.firebasex.grantPermission().then(hasPermission => {
console.log("Permission was " + (hasPermission ? "granted" : "denied"));
this.processStartReceivingWithFirebase();
});
} else {
this.processStartReceivingWithFirebase();
}
});
}
private processNotification(data: any) { private processNotification(data: any) {
const notification = new NotificationModel(); const notification = new NotificationModel();

@ -21,7 +21,7 @@
<ion-row padding> <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')"> <div class="textAndIcon" (click)="startNFCOperations()">
<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>

@ -16,6 +16,7 @@ import { Response } from "src/app/hmg-common/services/models/response";
import { WifiWizard2 } from "@ionic-native/wifi-wizard-2/ngx"; import { WifiWizard2 } from "@ionic-native/wifi-wizard-2/ngx";
import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx'; import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';
import { DevicePermissionsService } from 'src/app/hmg-common/services/device-permissions/device-permissions.service'; import { DevicePermissionsService } from 'src/app/hmg-common/services/device-permissions/device-permissions.service';
import { Geolocation } from '@ionic-native/geolocation/ngx';
@ -32,8 +33,14 @@ export class AttendanceOptionsComponent implements OnInit {
public serviceEnableNFC = false; public serviceEnableNFC = false;
public serviceEnableQR = false; public serviceEnableQR = false;
public serviceEnableWifi = false; public serviceEnableWifi = false;
public enableLocationQR = false;
public enableLocationNFC = false;
public deviceNFC = false; public deviceNFC = false;
public nfcIOSSuccess = false; public nfcIOSSuccess = false;
public lat = 0;
public longt = 0;
private ssid = CommonService.MOHEMM_WIFI_SSID;
constructor( constructor(
private nfc: NFC, private nfc: NFC,
@ -47,7 +54,8 @@ export class AttendanceOptionsComponent implements OnInit {
public ngZone: NgZone, public ngZone: NgZone,
private wifiWizard2: WifiWizard2, private wifiWizard2: WifiWizard2,
private openNativeSettings: OpenNativeSettings, private openNativeSettings: OpenNativeSettings,
private devicePermissionsService:DevicePermissionsService private devicePermissionsService:DevicePermissionsService,
private geolocation: Geolocation
) {} ) {}
ngOnInit() { ngOnInit() {
@ -90,6 +98,14 @@ export class AttendanceOptionsComponent implements OnInit {
} }
} }
public startNFCOperations() {
if (this.enableLocationNFC) {
this.getDeviceLocation();
} else {
this.checkNFCStatus('two');
}
}
public setServicesPrivilage() { public setServicesPrivilage() {
for (const servicePrivilage of AuthenticationService.servicePrivilage) { for (const servicePrivilage of AuthenticationService.servicePrivilage) {
if ( if (
@ -110,6 +126,18 @@ export class AttendanceOptionsComponent implements OnInit {
) { ) {
this.serviceEnableWifi = true; this.serviceEnableWifi = true;
} }
if (
servicePrivilage.Previlege &&
servicePrivilage.ServiceName === "enableLocationQR"
) {
this.enableLocationQR = true;
}
if (
servicePrivilage.Previlege &&
servicePrivilage.ServiceName === "enableLocationNFC"
) {
this.enableLocationNFC = true;
}
} }
} }
@ -130,6 +158,7 @@ export class AttendanceOptionsComponent implements OnInit {
component: NfcModalComponent, component: NfcModalComponent,
showBackdrop: true, showBackdrop: true,
backdropDismiss: true, backdropDismiss: true,
componentProps:{ enableLocationQR: this.enableLocationQR, lat: this.lat, longt: this.longt},
}); });
modal.cssClass = "nfc-modal"; modal.cssClass = "nfc-modal";
await modal.present(); await modal.present();
@ -138,12 +167,13 @@ export class AttendanceOptionsComponent implements OnInit {
public swipeAttendanceNFC(nfcSerialCode: any) { public swipeAttendanceNFC(nfcSerialCode: any) {
const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest(); const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest();
request.PointType = 2; request.PointType = 2;
request.Latitude = 0; request.Latitude = this.lat;
request.Longitude = 0; request.Longitude = this.longt;
request.QRValue = ""; request.QRValue = "";
request.NFCValue = nfcSerialCode; request.NFCValue = nfcSerialCode;
request.UID = this.device.uuid; request.UID = this.device.uuid;
request.UserName = this.userData.EMPLOYEE_NUMBER; request.UserName = this.userData.EMPLOYEE_NUMBER;
request.IsGpsRequired = this.enableLocationNFC;
this.attendance_service this.attendance_service
.attendanceSwipeScanner(request, () => { .attendanceSwipeScanner(request, () => {
console.log("Error inside in swipe attendance"); console.log("Error inside in swipe attendance");
@ -171,9 +201,25 @@ export class AttendanceOptionsComponent implements OnInit {
} }
public startQRCode() { public startQRCode() {
this.attendScanService.getDeviceLocation(); if (this.enableLocationQR) {
this.attendScanService.getDeviceLocation();
} else {
this.attendScanService.attendance(false);
}
} }
async verifyWIFIConfiguration() {
try {
let ssid_ = await this.wifiWizard2.getConnectedSSID();
if(ssid_ == this.ssid){
this.common.presentAlert(this.ts.trPK("general", "forget-wifi-connection-text"));
} else {
this.startWIFIProcedure();
}
} catch (err) {
this.common.presentAlert(this.ts.trPK("general", "forget-wifi-connection-text"));
}
}
// Wifi Attendance // Wifi Attendance
public async startWifi() { public async startWifi() {
@ -181,30 +227,28 @@ export class AttendanceOptionsComponent implements OnInit {
const isIOS = this.platform.is("ios"); const isIOS = this.platform.is("ios");
const isWifiEnabled = await this.wifiWizard2.isWifiEnabled(); const isWifiEnabled = await this.wifiWizard2.isWifiEnabled();
if(isIOS){ if (isIOS) {
if(!isWifiEnabled){ if(!isWifiEnabled){
this.showWifiNotEnabled(); this.showWifiNotEnabled();
return; return;
} else {
this.verifyWIFIConfiguration();
} }
} else if(isAndroid) {
}else if(isAndroid){
let locationPermission = await this.devicePermissionsService.requestLocationAutherization(); let locationPermission = await this.devicePermissionsService.requestLocationAutherization();
if(!locationPermission){ if (!locationPermission) {
return; return;
} }
if(!isWifiEnabled){ if (!isWifiEnabled) {
this.wifiWizard2.setWifiEnabled(true).then(()=>{
this.startWifi();
}).catch((err) => {
console.debug(err);
this.showWifiNotEnabled(); this.showWifiNotEnabled();
}); } else {
return; this.startWIFIProcedure();
} }
} }
}
// opening wifi dailog if all above conditions are passed (isWifiEnabled == true) async startWIFIProcedure () {
let modal = await this.modalController.create({ let modal = await this.modalController.create({
component: WifiModalComponent, component: WifiModalComponent,
showBackdrop: true, showBackdrop: true,
@ -215,13 +259,32 @@ export class AttendanceOptionsComponent implements OnInit {
} }
showWifiNotEnabled(){ showWifiNotEnabled(){
this.common.showErrorMessageDialog(()=>{ this.common.showErrorMessageDialog(()=>{
// this.openNativeSettings.open('wifi').then(()=>{});
}, },
this.ts.trPK("general", "ok"), this.ts.trPK("general", "ok"),
this.ts.trPK("general","wifi-not-enable-text")); this.ts.trPK("general","wifi-not-enable-text"));
} }
getDeviceLocation() {
this.devicePermissionsService.requestLocationAutherization().then(granted => {
this.location = granted as boolean;
if (this.location) {
this.geolocation.getCurrentPosition({maximumAge: 3000, timeout: 10000, enableHighAccuracy: true}).then(resp => {
if(resp && resp.coords.latitude && resp.coords.longitude) {
this.lat = resp.coords.latitude;
this.longt = resp.coords.longitude;
this.checkNFCStatus('two');
} else {
this.common.presentAlert(this.ts.trPK('home', 'position-error'));
}
}).catch(error => {
this.common.presentAlert(this.ts.trPK('home', 'position-error'));
});
} else {
return false;
}
});
}
} }

@ -18,6 +18,7 @@ export class attendanceSwipeScannerRequest extends Request{
public PointType: number; public PointType: number;
public NFCValue: string; public NFCValue: string;
public WifiValue: string; public WifiValue: string;
public IsGpsRequired: boolean;
} }

@ -19,6 +19,9 @@ export class NfcModalComponent implements OnInit {
public userData: any = {}; public userData: any = {};
public gifStatus = false; public gifStatus = false;
public nfcReader: any; public nfcReader: any;
public enableLocationNFC: boolean;
public lat: number;
public longt: number;
constructor( constructor(
private nfc: NFC, private nfc: NFC,
@ -34,6 +37,7 @@ export class NfcModalComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false); this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false);
this.startAndroidNfc(); this.startAndroidNfc();
console.log(this.enableLocationNFC);
} }
ionViewDidLeave() { ionViewDidLeave() {
@ -56,12 +60,13 @@ export class NfcModalComponent implements OnInit {
this.nfcReader.unsubscribe(); this.nfcReader.unsubscribe();
const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest(); const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest();
request.PointType = 2; request.PointType = 2;
request.Latitude = 0; request.Latitude = this.lat;
request.Longitude = 0; request.Longitude = this.longt;
request.QRValue = ""; request.QRValue = "";
request.NFCValue = nfcSerialCode; request.NFCValue = nfcSerialCode;
request.UID = this.device.uuid; request.UID = this.device.uuid;
request.UserName = this.userData.EMPLOYEE_NUMBER; request.UserName = this.userData.EMPLOYEE_NUMBER;
request.IsGpsRequired = this.enableLocationNFC;
this.attendance_service.attendanceSwipeScanner(request, () => { this.attendance_service.attendanceSwipeScanner(request, () => {
console.log('Error inside in swipe attendance'); console.log('Error inside in swipe attendance');
this.modalController.dismiss(); this.modalController.dismiss();

@ -1068,8 +1068,8 @@
"ar": "بحث متقدم" "ar": "بحث متقدم"
}, },
"No-data-available": { "No-data-available": {
"en": "No Data Available", "en": "No History Available",
"ar": "لا يوجد بيانات" "ar": "لا يوجد محفوظات متاحة"
} }
}, },
"userProfile": { "userProfile": {

Loading…
Cancel
Save