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.
mohemm_srca/Mohem/src/app/home/home.page.ts

63 lines
2.0 KiB
TypeScript

import { Component, OnInit } from "@angular/core";
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
import { MenuController,Events } from "@ionic/angular";
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
import { AuthenticatedUser } from "src/app/hmg-common/services/authentication/models/authenticated-user";
import { MenuService } from "src/app/hmg-common/services/menu/menuservice.service";
import { MenuResponse } from "src/app/hmg-common/services/menu/models/menu-response";
import { CommonService } from "src/app/hmg-common/services/common/common.service";
@Component({
selector: "app-home",
templateUrl: "./home.page.html",
styleUrls: ["./home.page.scss"]
})
export class HomePage implements OnInit {
userData: any = {};
user_image: any = "../assets/imgs/profile.png";
menuList: any = [];
constructor(
public ts: TranslatorService,
public menu: MenuController,
public authService: AuthenticationService,
public menuService: MenuService,
public common: CommonService,
public events:Events
) {}
ngOnInit() {
this.getUserDetails();
this.getMenu();
}
private openMenu() {
this.menu.toggle();
}
private getUserDetails() {
this.authService
.loadAuthenticatedUser()
.subscribe((user: AuthenticatedUser) => {
if (user) {
this.events.publish('setMenu');
this.userData = user;
this.user_image = user.EMPLOYEE_IMAGE ? "data:image/png;base64,"+user.EMPLOYEE_IMAGE : this.user_image;
console.log(user);
} else {
console.log(user);
}
});
}
private getMenu() {
this.menuService.getMenu().subscribe((result: MenuResponse) => {
this.handleMenuResult(result);
});
}
private handleMenuResult(result) {
if (this.common.validResponse(result)) {
if (this.common.hasData(result.List_Menu)) {
this.menuList = result.List_Menu;
}
}
}
}