|
|
|
|
@ -1,44 +1,44 @@
|
|
|
|
|
import { Component, OnInit, ViewChild, AfterViewInit } 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 { Component, OnInit, ViewChild, AfterViewInit } 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 { 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",
|
|
|
|
|
styleUrls: ["./app.component.scss"],
|
|
|
|
|
templateUrl: "app.component.html"
|
|
|
|
|
selector: 'app-root',
|
|
|
|
|
styleUrls: ['./app.component.scss'],
|
|
|
|
|
templateUrl: 'app.component.html'
|
|
|
|
|
})
|
|
|
|
|
export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
// rootPage:any = LoginPage;
|
|
|
|
|
// @ViewChild(Nav) nav: Nav;
|
|
|
|
|
start: any = false;
|
|
|
|
|
menuList: any = [];
|
|
|
|
|
User_name_Emp: string = "";
|
|
|
|
|
user_image: any = "../assets/imgs/profile.png";
|
|
|
|
|
menuSide: string = "left";
|
|
|
|
|
User_name_Emp = '';
|
|
|
|
|
user_image: any = '../assets/imgs/profile.png';
|
|
|
|
|
menuSide = 'left';
|
|
|
|
|
notBadge: number;
|
|
|
|
|
companyUrl: string = "../assets/imgs/CS.png";
|
|
|
|
|
companyDesc: string = "Powered By Cloud Solutions";
|
|
|
|
|
public direction = "ltr";
|
|
|
|
|
companyUrl = '../assets/imgs/CS.png';
|
|
|
|
|
companyDesc = 'Powered By Cloud Solutions';
|
|
|
|
|
direction = 'ltr';
|
|
|
|
|
User_Job_name: string;
|
|
|
|
|
public logoutFlage: any =false;
|
|
|
|
|
public logoutFlage: any = false;
|
|
|
|
|
requestGetLoginInfo: {
|
|
|
|
|
DeviceType: string; DeviceToken: string; //this.deviceToken
|
|
|
|
|
DeviceType: string; DeviceToken: string; // this.deviceToken
|
|
|
|
|
};
|
|
|
|
|
user: boolean;
|
|
|
|
|
deviceToken: string;
|
|
|
|
|
TeamFlag :string = "false";
|
|
|
|
|
TeamFlag: string = 'false';
|
|
|
|
|
constructor(
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
private cs: CommonService,
|
|
|
|
|
@ -53,23 +53,23 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
private splashScreen: SplashScreen
|
|
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
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);
|
|
|
|
|
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() {
|
|
|
|
|
this.start = false;
|
|
|
|
|
this.menu.enable(false)
|
|
|
|
|
this.menu.enable(false);
|
|
|
|
|
this.lazyLoadingService.monitorLazyLoading(15, true);
|
|
|
|
|
this.platform.ready().then(() => {
|
|
|
|
|
this.ts.loadResources(() => {
|
|
|
|
|
@ -85,44 +85,44 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private startReceivingPushService() {
|
|
|
|
|
console.log("platform.ready")
|
|
|
|
|
console.log('platform.ready');
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
console.log(" in setTimeout startReceiving");
|
|
|
|
|
this.getLastLoginInfo();
|
|
|
|
|
},4000);
|
|
|
|
|
console.log(' in setTimeout startReceiving');
|
|
|
|
|
this.getLastLoginInfo();
|
|
|
|
|
}, 4000);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
subscribeEvents() {
|
|
|
|
|
this.events.subscribe("setMenu", () => {
|
|
|
|
|
this.events.subscribe('setMenu', () => {
|
|
|
|
|
const user = this.authService
|
|
|
|
|
.loadAuthenticatedUser()
|
|
|
|
|
.subscribe((user: AuthenticatedUser) => {
|
|
|
|
|
if (user) {
|
|
|
|
|
this.companyUrl = user.CompanyImageURL
|
|
|
|
|
? user.CompanyImageURL
|
|
|
|
|
: "../assets/imgs/CS.png";
|
|
|
|
|
: '../assets/imgs/CS.png';
|
|
|
|
|
|
|
|
|
|
this.companyDesc = user.CompanyImageDescription
|
|
|
|
|
? user.CompanyImageDescription
|
|
|
|
|
: "Powered By Cloud Solutions";
|
|
|
|
|
: '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{
|
|
|
|
|
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";
|
|
|
|
|
? 'data:image/png;base64,' + user.EMPLOYEE_IMAGE
|
|
|
|
|
: '../assets/imgs/profile.png';
|
|
|
|
|
}
|
|
|
|
|
this.User_Job_name=user.JOB_NAME;
|
|
|
|
|
|
|
|
|
|
this.User_Job_name = user.JOB_NAME;
|
|
|
|
|
|
|
|
|
|
console.log(user);
|
|
|
|
|
} else {
|
|
|
|
|
console.log(user);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
this.events.subscribe("getNotCount", badge => {
|
|
|
|
|
this.events.subscribe('getNotCount', badge => {
|
|
|
|
|
this.notBadge = badge;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -152,12 +152,12 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
logout() {
|
|
|
|
|
this.cs.sharedService.clearAll();
|
|
|
|
|
//this.menu.toggle();
|
|
|
|
|
// this.menu.toggle();
|
|
|
|
|
this.menu.enable(false);
|
|
|
|
|
this.logoutFlage=true;
|
|
|
|
|
this.logoutFlage = true;
|
|
|
|
|
this.events.publish('logoutFlage', this.logoutFlage);
|
|
|
|
|
this.cs.setUpdateImage("",false);
|
|
|
|
|
this.TeamFlag ="false";
|
|
|
|
|
this.cs.setUpdateImage('', false);
|
|
|
|
|
this.TeamFlag = 'false';
|
|
|
|
|
this.getLastLoginInfo();
|
|
|
|
|
// this.cs.openLogin();
|
|
|
|
|
|
|
|
|
|
@ -167,7 +167,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
openMyTeamPage() {
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
this.cs.openMyTeamPage();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// profile() {
|
|
|
|
|
// this.cs.openProfile();
|
|
|
|
|
@ -178,17 +178,17 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
this.cs.openEditProfile();
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
openNotification(){
|
|
|
|
|
openNotification() {
|
|
|
|
|
|
|
|
|
|
this.cs.openNotificationPage();
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openChangePassword(){
|
|
|
|
|
|
|
|
|
|
openChangePassword() {
|
|
|
|
|
this.cs.openChangePassword();
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// openPayslipPage(){
|
|
|
|
|
// this.cs.openPayslipPage();
|
|
|
|
|
// this.menu.toggle();
|
|
|
|
|
@ -199,47 +199,47 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closeMenu(){
|
|
|
|
|
closeMenu() {
|
|
|
|
|
this.menu.toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getLastLoginInfo(){
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
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) {
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
} else {
|
|
|
|
|
console.log("no deviceToken" );
|
|
|
|
|
console.log('no deviceToken' );
|
|
|
|
|
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.deviceToken= localStorage.getItem('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 => {
|
|
|
|
|
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){
|
|
|
|
|
if (res.Mohemm_GetMobileLoginInfoList.length > 0) {
|
|
|
|
|
|
|
|
|
|
this.cs.sharedService.setSharedData(
|
|
|
|
|
// res.Patient_SELECTDeviceIMEIbyIMEIList[0],
|
|
|
|
|
@ -250,31 +250,30 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
this.events.publish('user', this.user);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.splashScreen.hide();
|
|
|
|
|
},3000);
|
|
|
|
|
}, 3000);
|
|
|
|
|
|
|
|
|
|
if(this.logoutFlage){
|
|
|
|
|
if (this.logoutFlage) {
|
|
|
|
|
this.cs.openLogin();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
} else {
|
|
|
|
|
this.user = false;
|
|
|
|
|
this.events.publish('user', this.user);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.splashScreen.hide();
|
|
|
|
|
},3000);
|
|
|
|
|
|
|
|
|
|
if(this.logoutFlage){
|
|
|
|
|
}, 3000);
|
|
|
|
|
|
|
|
|
|
if (this.logoutFlage) {
|
|
|
|
|
this.cs.openLogin();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// this.user = false;
|
|
|
|
|
// this.splashScreen.hide();
|
|
|
|
|
// if(this.logoutFlage){
|
|
|
|
|
@ -284,5 +283,5 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|