|
|
|
|
@ -10,6 +10,9 @@ import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/mod
|
|
|
|
|
import { PushService } from '../../src/app/hmg-common/services/push/push.service';
|
|
|
|
|
import { LazyLoadingService } from "./hmg-common/services/lazy-loading/lazy-loading.service";
|
|
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
|
|
|
// import { SplashScreen } from '@ionic-native/splash-screen';
|
|
|
|
|
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: "app-root",
|
|
|
|
|
@ -29,10 +32,12 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
companyDesc: string = "Powered By Cloud Solutions";
|
|
|
|
|
public direction = "ltr";
|
|
|
|
|
User_Job_name: string;
|
|
|
|
|
public logoutFlage: any =false;
|
|
|
|
|
requestGetLoginInfo: {
|
|
|
|
|
DeviceType: string; DeviceToken: string; //this.deviceToken
|
|
|
|
|
};
|
|
|
|
|
user: boolean;
|
|
|
|
|
deviceToken: string;
|
|
|
|
|
TeamFlag :string = "false";
|
|
|
|
|
constructor(
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
@ -44,7 +49,9 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
private menu: MenuController,
|
|
|
|
|
private authService: AuthenticationService,
|
|
|
|
|
private sanitizer: DomSanitizer,
|
|
|
|
|
public pushService: PushService
|
|
|
|
|
public pushService: PushService,
|
|
|
|
|
private splashScreen: SplashScreen
|
|
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
this.events.subscribe("img-change", displayImg => {
|
|
|
|
|
console.log("app compont: "+displayImg);
|
|
|
|
|
@ -80,6 +87,11 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
private startReceivingPushService() {
|
|
|
|
|
console.log("platform.ready")
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
console.log(" in setTimeout startReceiving");
|
|
|
|
|
this.getLastLoginInfo();
|
|
|
|
|
},4000);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
subscribeEvents() {
|
|
|
|
|
this.events.subscribe("setMenu", () => {
|
|
|
|
|
@ -139,8 +151,14 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
logout() {
|
|
|
|
|
this.cs.sharedService.clearAll();
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
this.cs.openLogin();
|
|
|
|
|
//this.menu.toggle();
|
|
|
|
|
this.menu.enable(false);
|
|
|
|
|
this.logoutFlage=true;
|
|
|
|
|
this.events.publish('logoutFlage', this.logoutFlage);
|
|
|
|
|
|
|
|
|
|
this.getLastLoginInfo();
|
|
|
|
|
// this.cs.openLogin();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -183,6 +201,86 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getLastLoginInfo(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(" getLastLoginInfo");
|
|
|
|
|
console.log("get method :"+this.cs.getDeviceToken());
|
|
|
|
|
this.deviceToken= this.cs.getDeviceToken();
|
|
|
|
|
//this.cs.sharedService.getSharedData("new-device-token",false);// localStorage.getItem('devicyeToken');
|
|
|
|
|
console.log("let deviceToken app" + this.cs.sharedService.getSharedData("new-device-token",false));
|
|
|
|
|
console.log("localStorage.getItem app" + localStorage.getItem('devicyeToken'));
|
|
|
|
|
console.log("sheard DEVICE_TOKEN" + this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
} else {
|
|
|
|
|
console.log("no deviceToken" );
|
|
|
|
|
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.deviceToken= localStorage.getItem('deviceToken');
|
|
|
|
|
console.log('login enabled second time: ' + this.deviceToken);
|
|
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.requestGetLoginInfo= {
|
|
|
|
|
DeviceType:this.cs.getDeviceType(),//'Android',
|
|
|
|
|
DeviceToken:this.deviceToken//"5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken
|
|
|
|
|
}
|
|
|
|
|
this.authService.getLoginInfo(this.requestGetLoginInfo,() => {}, this.ts.trPK('general', 'ok')).subscribe(res => {
|
|
|
|
|
|
|
|
|
|
if (this.cs.validResponse(res)) {
|
|
|
|
|
|
|
|
|
|
if(res.Mohemm_GetMobileLoginInfoList.length > 0){
|
|
|
|
|
|
|
|
|
|
this.cs.sharedService.setSharedData(
|
|
|
|
|
// res.Patient_SELECTDeviceIMEIbyIMEIList[0],
|
|
|
|
|
res.Mohemm_GetMobileLoginInfoList[0],
|
|
|
|
|
AuthenticationService.IMEI_USER_DATA
|
|
|
|
|
);
|
|
|
|
|
this.user = true;
|
|
|
|
|
this.events.publish('user', this.user);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.splashScreen.hide();
|
|
|
|
|
},3000);
|
|
|
|
|
|
|
|
|
|
if(this.logoutFlage){
|
|
|
|
|
this.cs.openLogin();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.user = false;
|
|
|
|
|
this.events.publish('user', this.user);
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.splashScreen.hide();
|
|
|
|
|
},3000);
|
|
|
|
|
|
|
|
|
|
if(this.logoutFlage){
|
|
|
|
|
this.cs.openLogin();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
// this.user = false;
|
|
|
|
|
// this.splashScreen.hide();
|
|
|
|
|
// if(this.logoutFlage){
|
|
|
|
|
// this.cs.openLogin();
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|