|
|
|
|
@ -12,7 +12,8 @@ import { LazyLoadingService } from './hmg-common/services/lazy-loading/lazy-load
|
|
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
|
|
|
// import { SplashScreen } from '@ionic-native/splash-screen';
|
|
|
|
|
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
|
|
|
|
|
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
import { rejects } from 'assert';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
|
|
|
|
@ -50,8 +51,8 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
private authService: AuthenticationService,
|
|
|
|
|
private sanitizer: DomSanitizer,
|
|
|
|
|
public pushService: PushService,
|
|
|
|
|
private splashScreen: SplashScreen
|
|
|
|
|
|
|
|
|
|
private splashScreen: SplashScreen,
|
|
|
|
|
public router: Router,
|
|
|
|
|
) {
|
|
|
|
|
this.events.subscribe('img-change', displayImg => {
|
|
|
|
|
console.log('app compont: ' + displayImg);
|
|
|
|
|
@ -63,8 +64,6 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.initializeApp();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
ngAfterViewInit() {}
|
|
|
|
|
initializeApp() {
|
|
|
|
|
@ -94,6 +93,12 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
subscribeEvents() {
|
|
|
|
|
this.platform.backButton.subscribe(() => {
|
|
|
|
|
if (this.router.isActive('/authentication/login', true)) {
|
|
|
|
|
// tslint:disable-next-line: no-string-literal
|
|
|
|
|
navigator['app'].exitApp();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.events.subscribe('setMenu', () => {
|
|
|
|
|
const user = this.authService
|
|
|
|
|
.loadAuthenticatedUser()
|
|
|
|
|
@ -204,83 +209,57 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
} else {
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.deviceToken = localStorage.getItem('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 => {
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|