|
|
|
|
@ -1,28 +1,22 @@
|
|
|
|
|
import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
|
|
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
|
import { Platform, Events, MenuController } from '@ionic/angular';
|
|
|
|
|
import { TranslatorService } from './hmg-common/services/translator/translator.service';
|
|
|
|
|
import { CommonService } from './hmg-common/services/common/common.service';
|
|
|
|
|
import { AuthenticationService } from './hmg-common/services/authentication/authentication.service';
|
|
|
|
|
import { AuthenticatedUser } from './hmg-common/services/authentication/models/authenticated-user';
|
|
|
|
|
import { TabsBarComponent } from './hmg-common/ui/tabs-bar/tabs-bar.component';
|
|
|
|
|
import { KeyboardService } from './hmg-common/services/keyboard/keyboard.service';
|
|
|
|
|
import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.response';
|
|
|
|
|
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';
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
import { rejects } from 'assert';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
|
|
|
|
styleUrls: ['./app.component.scss'],
|
|
|
|
|
templateUrl: 'app.component.html'
|
|
|
|
|
})
|
|
|
|
|
export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
// rootPage:any = LoginPage;
|
|
|
|
|
// @ViewChild(Nav) nav: Nav;
|
|
|
|
|
export class AppComponent implements OnInit {
|
|
|
|
|
start: any = false;
|
|
|
|
|
menuList: any = [];
|
|
|
|
|
User_name_Emp = '';
|
|
|
|
|
@ -34,13 +28,15 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
direction = 'ltr';
|
|
|
|
|
User_Job_name: string;
|
|
|
|
|
public logoutFlage: any = false;
|
|
|
|
|
requestGetLoginInfo: {
|
|
|
|
|
DeviceType: string; DeviceToken: string; // this.deviceToken
|
|
|
|
|
};
|
|
|
|
|
user: boolean;
|
|
|
|
|
deviceToken: string;
|
|
|
|
|
TeamFlag: string = 'false';
|
|
|
|
|
isIOS = false;
|
|
|
|
|
public requestGetLoginInfo: {
|
|
|
|
|
DeviceType: string;
|
|
|
|
|
DeviceToken: string; // this.deviceToken
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
private cs: CommonService,
|
|
|
|
|
@ -57,17 +53,15 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
) {
|
|
|
|
|
this.events.subscribe('img-change', displayImg => {
|
|
|
|
|
console.log('app compont: ' + displayImg);
|
|
|
|
|
// this.user_image = "data:image/png;base64"+displayImg;
|
|
|
|
|
this.user_image = this.sanitizer.bypassSecurityTrustUrl('data:Image/*;base64,' + displayImg);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.initializeApp();
|
|
|
|
|
}
|
|
|
|
|
ngAfterViewInit() {}
|
|
|
|
|
initializeApp() {
|
|
|
|
|
|
|
|
|
|
public initializeApp() {
|
|
|
|
|
this.start = false;
|
|
|
|
|
this.menu.enable(false);
|
|
|
|
|
this.lazyLoadingService.monitorLazyLoading(15, true);
|
|
|
|
|
@ -75,7 +69,6 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
this.ts.loadResources(() => {
|
|
|
|
|
this.isIOS = this.platform.is('ios') ? true : false;
|
|
|
|
|
this.initializeDirection();
|
|
|
|
|
// this.statusBar.styleDefault();
|
|
|
|
|
this.start = true;
|
|
|
|
|
if (this.isIOS) {
|
|
|
|
|
this.monitUrlChange();
|
|
|
|
|
@ -88,7 +81,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private monitUrlChange() {
|
|
|
|
|
private monitUrlChange() {
|
|
|
|
|
this.router.events.subscribe((val) => {
|
|
|
|
|
if (this.router.isActive('/authentication/login', true)) {
|
|
|
|
|
this.direction = 'ltr';
|
|
|
|
|
@ -96,7 +89,6 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
this.direction = TranslatorService.getCurrentDirection();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private startReceivingPushService() {
|
|
|
|
|
@ -106,52 +98,35 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
console.log(' in setTimeout startReceiving');
|
|
|
|
|
this.getLastLoginInfo();
|
|
|
|
|
}, 4000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
subscribeEvents() {
|
|
|
|
|
public 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()
|
|
|
|
|
.subscribe((user: AuthenticatedUser) => {
|
|
|
|
|
const user = this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => {
|
|
|
|
|
if (user) {
|
|
|
|
|
this.companyUrl = user.CompanyImageURL
|
|
|
|
|
? user.CompanyImageURL
|
|
|
|
|
: '../assets/imgs/CSLogo.png';
|
|
|
|
|
|
|
|
|
|
this.companyDesc = user.CompanyImageDescription
|
|
|
|
|
? user.CompanyImageDescription
|
|
|
|
|
: 'Powered By Cloud Solutions';
|
|
|
|
|
this.companyUrl = user.CompanyImageURL ? user.CompanyImageURL : '../assets/imgs/CSLogo.png';
|
|
|
|
|
this.companyDesc = user.CompanyImageDescription ? user.CompanyImageDescription : 'Powered By Cloud Solutions';
|
|
|
|
|
this.User_name_Emp = user.EMPLOYEE_DISPLAY_NAME;
|
|
|
|
|
if (this.cs.getUpdateImage().status) {
|
|
|
|
|
this.user_image = this.sanitizer.bypassSecurityTrustUrl('data:image/png;base64,' + this.cs.getUpdateImage().img);
|
|
|
|
|
} else {
|
|
|
|
|
this.user_image = user.EMPLOYEE_IMAGE
|
|
|
|
|
? 'data:image/png;base64,' + user.EMPLOYEE_IMAGE
|
|
|
|
|
: '../assets/imgs/profile.png';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.user_image = user.EMPLOYEE_IMAGE ? 'data:image/png;base64,' + user.EMPLOYEE_IMAGE : '../assets/imgs/profile.png';
|
|
|
|
|
}
|
|
|
|
|
this.User_Job_name = user.JOB_NAME;
|
|
|
|
|
|
|
|
|
|
console.log(user);
|
|
|
|
|
} else {
|
|
|
|
|
console.log(user);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
this.events.subscribe('getNotCount', badge => {
|
|
|
|
|
this.notBadge = badge;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.events.subscribe('myTeamFlag', myTeamFlag => {
|
|
|
|
|
this.TeamFlag = myTeamFlag;
|
|
|
|
|
});
|
|
|
|
|
console.log("this.TeamFlag>>>>>>>>>"+ this.TeamFlag);
|
|
|
|
|
this.events.subscribe('getNotCount', badge => { this.notBadge = badge; });
|
|
|
|
|
this.events.subscribe('myTeamFlag', myTeamFlag => { this.TeamFlag = myTeamFlag; });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private initializeDirection() {
|
|
|
|
|
if (this.isIOS) {
|
|
|
|
|
if (this.router.isActive('/authentication/login', true)) {
|
|
|
|
|
@ -162,14 +137,8 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
} else {
|
|
|
|
|
this.direction = TranslatorService.getCurrentDirection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private watchUserLoginChangeEvents() {
|
|
|
|
|
this.events.subscribe(
|
|
|
|
|
AuthenticationService.LOGIN_EVENT,
|
|
|
|
|
(user: AuthenticatedUser, time: Date) => {}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private watchLanguageChangeEvents() {
|
|
|
|
|
this.events.subscribe(TranslatorService.CHANGE_EVENT, () => {
|
|
|
|
|
this.start = false;
|
|
|
|
|
@ -179,92 +148,71 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
}, 100);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
logout() {
|
|
|
|
|
|
|
|
|
|
public logout() {
|
|
|
|
|
this.cs.sharedService.clearAll();
|
|
|
|
|
// this.menu.toggle();
|
|
|
|
|
this.menu.enable(false);
|
|
|
|
|
this.logoutFlage = true;
|
|
|
|
|
this.events.publish('logoutFlage', this.logoutFlage);
|
|
|
|
|
|
|
|
|
|
this.cs.setUpdateImage('', false);
|
|
|
|
|
this.TeamFlag = 'false';
|
|
|
|
|
this.getLastLoginInfo();
|
|
|
|
|
// this.cs.openLogin();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openMyTeamPage() {
|
|
|
|
|
public openMyTeamPage() {
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
this.cs.openMyTeamPage();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// profile() {
|
|
|
|
|
// this.cs.openProfile();
|
|
|
|
|
// this.menu.toggle();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
profile() {
|
|
|
|
|
public profile() {
|
|
|
|
|
this.cs.openEditProfile();
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
openNotification() {
|
|
|
|
|
|
|
|
|
|
public openNotification() {
|
|
|
|
|
this.cs.openNotificationPage();
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openChangePassword() {
|
|
|
|
|
public openChangePassword() {
|
|
|
|
|
this.cs.openChangePassword();
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// openPayslipPage(){
|
|
|
|
|
// this.cs.openPayslipPage();
|
|
|
|
|
// this.menu.toggle();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
private changeImage() {
|
|
|
|
|
this.cs.openChangeImagePage();
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closeMenu() {
|
|
|
|
|
public closeMenu() {
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getLastLoginInfo() {
|
|
|
|
|
public getLastLoginInfo() {
|
|
|
|
|
this.deviceToken = this.cs.getDeviceToken();
|
|
|
|
|
// this.cs.sharedService.getSharedData("new-device-token",false);// localStorage.getItem('devicyeToken');
|
|
|
|
|
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
} else {
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
}, 1000);
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.requestGetLoginInfo = {
|
|
|
|
|
DeviceType: this.cs.getDeviceType(), // 'Android',
|
|
|
|
|
DeviceToken: this.deviceToken// "5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken
|
|
|
|
|
DeviceType: this.cs.getDeviceType(),
|
|
|
|
|
DeviceToken: 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.cs.sharedService.setSharedData(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();
|
|
|
|
|
}
|
|
|
|
|
@ -278,14 +226,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
this.cs.openLogin();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// this.user = false;
|
|
|
|
|
// this.splashScreen.hide();
|
|
|
|
|
// if(this.logoutFlage){
|
|
|
|
|
// this.cs.openLogin();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
} else {}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|