You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mohemmionic5/Mohem/src/app/app.component.ts

131 lines
4.2 KiB
TypeScript

7 years ago
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";
7 years ago
import { LazyLoadingService } from "./hmg-common/services/lazy-loading/lazy-loading.service";
import { DomSanitizer } from '@angular/platform-browser';
@Component({
7 years ago
selector: "app-root",
styleUrls: ["./app.component.scss"],
templateUrl: "app.component.html"
})
export class AppComponent implements OnInit, AfterViewInit {
// rootPage:any = LoginPage;
// @ViewChild(Nav) nav: Nav;
7 years ago
start: any = false;
menuList: any = [];
User_name_Emp: string = "";
user_image: any = "../assets/imgs/profile.png";
7 years ago
menuSide: string = "left";
notBadge: number;
companyUrl: string = "../assets/imgs/CS.png";
7 years ago
companyDesc: string = "Powered By Cloud Solutions";
public direction = "ltr";
constructor(
7 years ago
public ts: TranslatorService,
7 years ago
private cs: CommonService,
private lazyLoadingService: LazyLoadingService,
private platform: Platform,
private events: Events,
private keyboardService: KeyboardService,
private menu: MenuController,
private authService: AuthenticationService,
private sanitizer: DomSanitizer,
) {
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);
});
}
7 years ago
ngOnInit() {
this.initializeApp();
}
ngAfterViewInit() {}
initializeApp() {
this.start = false;
this.lazyLoadingService.monitorLazyLoading(15, true);
this.platform.ready().then(() => {
7 years ago
this.ts.loadResources(() => {
7 years ago
this.initializeDirection();
// this.statusBar.styleDefault();
this.start = true;
7 years ago
this.watchLanguageChangeEvents();
this.subscribeEvents();
7 years ago
this.keyboardService.watchKeyboard();
});
});
}
subscribeEvents() {
this.events.subscribe("setMenu", () => {
const user = this.authService
.loadAuthenticatedUser()
.subscribe((user: AuthenticatedUser) => {
if (user) {
this.companyUrl = user.CompanyImageURL
? user.CompanyImageURL
: "../assets/imgs/CS.png";
this.companyDesc = user.CompanyImageDescription
? user.CompanyImageDescription
: "Powered By Cloud Solutions";
this.User_name_Emp = user.EMPLOYEE_DISPLAY_NAME;
this.user_image = user.EMPLOYEE_IMAGE
? "data:image/png;base64," + user.EMPLOYEE_IMAGE
: "../assets/imgs/profile.png";
console.log(user);
} else {
console.log(user);
}
});
});
this.events.subscribe("getNotCount", badge => {
this.notBadge = badge;
});
}
7 years ago
private initializeDirection() {
this.direction = TranslatorService.getCurrentDirection();
}
private watchUserLoginChangeEvents() {
this.events.subscribe(
AuthenticationService.LOGIN_EVENT,
(user: AuthenticatedUser, time: Date) => {}
7 years ago
);
}
private watchLanguageChangeEvents() {
this.events.subscribe(TranslatorService.CHANGE_EVENT, () => {
this.start = false;
this.initializeDirection();
setTimeout(() => {
this.start = true;
}, 100);
});
}
logout() {
this.cs.sharedService.clearAll();
7 years ago
this.menu.toggle();
this.cs.openLogin();
7 years ago
}
profile() {
this.cs.openProfile();
this.menu.toggle();
}
openNotification(){
this.cs.openNotificationPage();
this.menu.toggle();
}
}