|
|
|
|
@ -51,56 +51,87 @@ export class WifiModalComponent implements OnInit {
|
|
|
|
|
const isIOS = this.platform.is("ios");
|
|
|
|
|
|
|
|
|
|
if (isAndroid) {
|
|
|
|
|
this.wifiWizard2.connect(this.ssid, true, this.password, this.algo).then(async (value) =>{
|
|
|
|
|
let isWifiAvailable = await this.isWifiAvailable(this.ssid);
|
|
|
|
|
console.debug("isWifiAvailable: " + isWifiAvailable);
|
|
|
|
|
if(isWifiAvailable){
|
|
|
|
|
console.debug("Wifi Credientials: " + this.ssid + " | " + this.password);
|
|
|
|
|
this.wifiWizard2.connect(this.ssid, true, this.password, this.algo).then(async (value) =>{
|
|
|
|
|
let ssid_ = await this.wifiWizard2.getConnectedSSID();
|
|
|
|
|
if(ssid_ == this.ssid){
|
|
|
|
|
console.debug("Wifi Connected: Verified Access | " + value + " | " + ssid_);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.swipeAttendanceWifi(ssid_);
|
|
|
|
|
},2000);
|
|
|
|
|
}else{
|
|
|
|
|
this.showErrorInvalidWorkspace();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.debug(err);
|
|
|
|
|
this.showErrorForgetWifiConfiguration();
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
console.debug("Wifi is not available considered your device is not in range");
|
|
|
|
|
this.showErrorInvalidWorkspace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (isIOS) {
|
|
|
|
|
this.wifiWizard2.iOSConnectNetwork(this.ssid,this.password).then(async (value) => {
|
|
|
|
|
let ssid_ = await this.wifiWizard2.getConnectedSSID();
|
|
|
|
|
let bssid = await this.wifiWizard2.getConnectedBSSID();
|
|
|
|
|
console.log("Wifi Connected: Verified Access | " + value + " | " + ssid_ + " | " + bssid);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.swipeAttendanceWifi(bssid);
|
|
|
|
|
},2000);
|
|
|
|
|
if(ssid_ == this.ssid){
|
|
|
|
|
console.debug("Wifi Connected: Verified Access | " + value + " | " + ssid_);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.swipeAttendanceWifi(ssid_);
|
|
|
|
|
},2000);
|
|
|
|
|
}else{
|
|
|
|
|
this.showErrorInvalidWorkspace();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.debug(err);
|
|
|
|
|
this.showErrorInvalidWorkspace();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else if (isIOS) {
|
|
|
|
|
if(this.wifiWizard2.isWifiEnabled){
|
|
|
|
|
this.wifiWizard2.iOSConnectNetwork(this.ssid,this.password).then((value) => {
|
|
|
|
|
let bssid = this.wifiWizard2.getConnectedBSSID();
|
|
|
|
|
console.log("Wifi Connected: Verified Access | " + value + " | " + bssid);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.swipeAttendanceWifi(this.ssid);
|
|
|
|
|
},1000);
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
this.showErrorInvalidWorkspace();
|
|
|
|
|
});
|
|
|
|
|
} else{
|
|
|
|
|
this.common.showErrorMessageDialog(()=>{
|
|
|
|
|
this.openNativeSettings.open('wifi').then(()=>{});
|
|
|
|
|
},
|
|
|
|
|
this.ts.trPK("general", "ok"),
|
|
|
|
|
this.ts.trPK("general","wifi-not-enable-text"));
|
|
|
|
|
this.showWifiNotEnabled();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showWifiNotEnabled(){
|
|
|
|
|
this.common.showErrorMessageDialog(()=>{
|
|
|
|
|
this.openNativeSettings.open('wifi').then(()=>{});
|
|
|
|
|
},
|
|
|
|
|
this.ts.trPK("general", "ok"),
|
|
|
|
|
this.ts.trPK("general","wifi-not-enable-text"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showErrorInvalidWorkspace() {
|
|
|
|
|
this.closeModal();
|
|
|
|
|
this.common.showErrorMessageDialog(()=>{
|
|
|
|
|
},
|
|
|
|
|
this.ts.trPK("general", "ok"),
|
|
|
|
|
this.ts.trPK("general","wifi-not-enable-text"));
|
|
|
|
|
this.ts.trPK("general","wifi-connection-failed-text"));
|
|
|
|
|
this.disconnectWifi();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showErrorForgetWifiConfiguration() {
|
|
|
|
|
this.closeModal();
|
|
|
|
|
this.common.confirmAlertDialog(() => {
|
|
|
|
|
this.openNativeSettings.open('wifi').then(()=>{});
|
|
|
|
|
}, this.ts.trPK('general', 'settings'), () => {
|
|
|
|
|
}, this.ts.trPK('general', 'cancel'), this.ts.trPK('vacation-rule', 'confirmation'), this.ts.trPK("general","forget-wifi-connection-text"));
|
|
|
|
|
this.disconnectWifi();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
disconnectWifi(){
|
|
|
|
|
async disconnectWifi() {
|
|
|
|
|
const isAndroid = this.platform.is("android");
|
|
|
|
|
const isIOS = this.platform.is("ios");
|
|
|
|
|
if(isAndroid){
|
|
|
|
|
this.wifiWizard2.disconnect(this.ssid);
|
|
|
|
|
this.wifiWizard2.remove(this.ssid);
|
|
|
|
|
console.log("Wifi Removed");
|
|
|
|
|
await this.wifiWizard2.disconnect(this.ssid).catch((error)=>{ console.error(error) });
|
|
|
|
|
await this.wifiWizard2.remove(this.ssid).catch((error)=>{ console.error(error) });
|
|
|
|
|
console.debug("Wifi Removed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -117,7 +148,9 @@ export class WifiModalComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
this.attendance_service
|
|
|
|
|
.attendanceSwipeScanner(request, () => {
|
|
|
|
|
console.log("Error inside in swipe attendance");
|
|
|
|
|
console.debug("Error inside in swipe attendance");
|
|
|
|
|
this.closeModal();
|
|
|
|
|
this.disconnectWifi();
|
|
|
|
|
})
|
|
|
|
|
.subscribe((result: Response) => {
|
|
|
|
|
this.disconnectWifi();
|
|
|
|
|
@ -127,10 +160,10 @@ export class WifiModalComponent implements OnInit {
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.closeModal();
|
|
|
|
|
this.common.openHome();
|
|
|
|
|
}, 6000);
|
|
|
|
|
// this.common.openAttenTrackingpage();
|
|
|
|
|
}, 4000);
|
|
|
|
|
}else{
|
|
|
|
|
console.log(result);
|
|
|
|
|
console.debug(result);
|
|
|
|
|
this.closeModal();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
@ -140,4 +173,14 @@ export class WifiModalComponent implements OnInit {
|
|
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async isWifiAvailable(ssid:string){
|
|
|
|
|
|
|
|
|
|
let avaialble_wifi = await this.wifiWizard2.scan();
|
|
|
|
|
let find_ = avaialble_wifi.find(element => {
|
|
|
|
|
return element.SSID == ssid;
|
|
|
|
|
});
|
|
|
|
|
console.log("find: " + find_.SSID);
|
|
|
|
|
return find_.SSID == ssid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|