fixed production abscence issue

MOHEMM-HUAWEI-RELEASE
umasoodch 4 years ago
parent 5411a068bf
commit f00643dbf6

@ -7,7 +7,7 @@
<div [ngClass]=" direction === 'en' ? 'custom-text-area-element Field-en' : 'custom-text-area-element Field-ar'" > <div [ngClass]=" direction === 'en' ? 'custom-text-area-element Field-en' : 'custom-text-area-element Field-ar'" >
<label class="label" position='floating' class="colBold requiredClass">{{ts.trPK('submitAbsence','absenceType')}} </label> <label class="label" position='floating' class="colBold requiredClass">{{ts.trPK('submitAbsence','absenceType')}} </label>
<select class="label-Select" (ionChange)="calcDay()" [(ngModel)]="absenceType" (ionChange)="onTypeAbsenceChange()" required> <select class="label-Select" [(ngModel)]="absenceType" (change)="onTypeAbsenceChange()" required>
<option value= "{{item.ABSENCE_ATTENDANCE_TYPE_ID}}" *ngFor="let item of absenceTypeList; let i=index;">{{item.ABSENCE_ATTENDANCE_TYPE_NAME}} </option> <option value= "{{item.ABSENCE_ATTENDANCE_TYPE_ID}}" *ngFor="let item of absenceTypeList; let i=index;">{{item.ABSENCE_ATTENDANCE_TYPE_NAME}} </option>
</select> </select>
</div> </div>

@ -6,7 +6,7 @@ import { DevicePermissionsService } from 'src/app/hmg-common/services/device-per
import { Geolocation } from '@ionic-native/geolocation/ngx'; import { Geolocation } from '@ionic-native/geolocation/ngx';
import { Platform } from "@ionic/angular"; import { Platform } from "@ionic/angular";
declare var cordova: any; declare const cordova: any;
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -41,16 +41,16 @@ export class HMGUtils {
async isHuaweiDevice(): Promise<boolean> { async isHuaweiDevice(): Promise<boolean> {
var result: any = await new Promise((resolve, reject) => { const result: any = await new Promise((resolve, reject) => {
cordova.plugins.CordovaHMSGMSCheckPlugin.isHmsAvailable( cordova.plugins.CordovaHMSGMSCheckPlugin.isHmsAvailable(
"index.js", "index.js",
(_res) => { (_res) => {
var hmsAvailable = _res === "true"; const hmsAvailable = _res === "true";
resolve(hmsAvailable); resolve(hmsAvailable);
}, },
(_err) => { (_err) => {
reject({ "status": false, "error": JSON.stringify(_err) }); reject({ "status": false, "error": JSON.stringify(_err) });
alert("Error checking device HMS/GMS") // add your popup this.common.presentAlert(this.ts.trPK('general', 'huawei-hms-gms-error'));
} }
); );
}); });
@ -60,42 +60,40 @@ export class HMGUtils {
private getHMSLocation(callBack: Function) { private getHMSLocation(callBack: Function) {
try { try {
console.log("Huawei Location [Getting]");
cordova.plugins.CordovaHMSLocationPlugin.requestLocation( cordova.plugins.CordovaHMSLocationPlugin.requestLocation(
"index.js", "index.js",
(_res) => { (_res) => {
console.log("Huawei Location Success: [Stop Getting]"); console.log("Huawei Location Success: [Stop Getting]");
cordova.plugins.CordovaHMSLocationPlugin.removeLocation("", (_res) => { }, (_err) => { }); cordova.plugins.CordovaHMSLocationPlugin.removeLocation("", (_res) => { }, (_err) => { });
var location = _res.split(',') const location = _res.split(',')
console.log(location); console.log(location);
if (location.length == 2) { if (location.length == 3) {
var lat = Number(_res.split(',')[0]); const lat = Number(_res.split(',')[0]);
var long = Number(_res.split(',')[1]); const long = Number(_res.split(',')[1]);
var mock = Boolean(_res.split(',')[2]); const mock = Boolean(_res.split(',')[2]);
callBack({"latitude":lat, "longitude":long, "isfake":mock}) callBack({"latitude":lat, "longitude":long, "isfake":mock})
} else { } else {
alert("Invalid Huawei location from plugin."); this.common.presentAlert(this.ts.trPK('general', 'invalid-huawei-location'));
} }
}, },
(_err) => { (_err) => {
console.log("Huawei Location [Getting Error]: " + + JSON.stringify(_err)); console.log("Huawei Location [Getting Error]: " + JSON.stringify(_err));
alert("Error while getting Huawei location"); this.common.presentAlert(this.ts.trPK('general', 'invalid-huawei-location'));
} }
); );
} catch (_err) { } catch (_err) {
console.log("Huawei Location Plugin [Error]: " + + JSON.stringify(_err)); console.log("Huawei Location Plugin [Error]: " + + JSON.stringify(_err));
alert("Error while initializing Huawei Location Plugin"); this.common.presentAlert('Error while initializing Huawei Location Plugin');
} }
} }
private getGMSLocation(callBack: Function) { private getGMSLocation(callBack: Function) {
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)) {
var isFakeLocation = resp.isFromMockProvider || resp.mockLocationsEnabled; const isFakeLocation = resp.isFromMockProvider || resp.mockLocationsEnabled;
var lat = resp.latitude; const lat = resp.latitude;
var long = resp.longitude; const long = resp.longitude;
callBack({"latitude":lat, "longitude":long, "isfake":isFakeLocation}) callBack({"latitude":lat, "longitude":long, "isfake":isFakeLocation})
} else { } else {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); this.common.presentAlert(this.ts.trPK('home', 'position-error'));
@ -108,8 +106,8 @@ export class HMGUtils {
private getIOSLocation(callBack: Function) { private getIOSLocation(callBack: Function) {
this.geolocation.getCurrentPosition({ maximumAge: 3000, timeout: 10000, enableHighAccuracy: true }).then(resp => { this.geolocation.getCurrentPosition({ maximumAge: 3000, timeout: 10000, enableHighAccuracy: true }).then(resp => {
if (resp && resp.coords.latitude && resp.coords.longitude) { if (resp && resp.coords.latitude && resp.coords.longitude) {
var lat = resp.coords.latitude; const lat = resp.coords.latitude;
var long = resp.coords.longitude; const long = resp.coords.longitude;
callBack({"latitude":lat, "longitude":long, "isfake":false}) callBack({"latitude":lat, "longitude":long, "isfake":false})
} else { } else {
this.common.presentAlert(this.ts.trPK('home', 'position-error')); this.common.presentAlert(this.ts.trPK('home', 'position-error'));

@ -92,6 +92,10 @@ export class AttendanceOptionsComponent implements OnInit {
this.check = 'this device is not huawei device :' + test; this.check = 'this device is not huawei device :' + test;
console.log('this device is non-huawei device :' + test); console.log('this device is non-huawei device :' + test);
} }
this.hmgUtils.getCurrentLocation((data) => {
console.log(data);
});
} }
public checkFirebaseDocument() { public checkFirebaseDocument() {

@ -142,7 +142,7 @@
</ion-card> </ion-card>
<ion-card *ngIf="basicDetailsSegment" [ngClass]="direction === 'ltr'? 'card-size-info-en': 'card-size-info-ar' "> <ion-card *ngIf="basicDetailsSegment" [ngClass]="direction === 'ltr'? 'card-size-info-en': 'card-size-info-ar' ">
<ion-card-content *ngIf="!editBasic && (fullName && maritalStatus && birthDate && civilIdentityNumber)"> <ion-card-content *ngIf="!editBasic && employeeBasicDetails">
<ion-grid> <ion-grid>
<ion-row style="width: 113%;"> <ion-row style="width: 113%;">
<ion-col size="10"> <ion-col size="10">

@ -1209,6 +1209,8 @@ $actionBtnSize: 36px;
height: 35px; height: 35px;
color: white; color: white;
border-radius: 50%; border-radius: 50%;
position: absolute;
right: 30px;
} }
.name{ .name{

@ -209,6 +209,14 @@
} }
}, },
"general": { "general": {
"invalid-huawei-location": {
"en": "Error while getting location from Huawei HMS services",
"ar": "خطأ أثناء الحصول على الموقع من خدمات Huawei HMS"
},
"huawei-hms-gms-error": {
"en": "Error checking device HMS/GMS availability",
"ar": "خطأ في التحقق من توفر جهاز HMS / GMS"
},
"location-permission-dialog": { "location-permission-dialog": {
"en": "Allow the Mohemm app to access your location for marking your attendance", "en": "Allow the Mohemm app to access your location for marking your attendance",
"ar": "اسمح لتطبيق مهم بالوصول إلى موقعك لتحديد حضورك" "ar": "اسمح لتطبيق مهم بالوصول إلى موقعك لتحديد حضورك"

Loading…
Cancel
Save