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

60 lines
1.9 KiB
TypeScript

7 years ago
import { Component, OnInit } from "@angular/core";
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
import { MenuController } from "@ionic/angular";
7 years ago
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response";
7 years ago
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({
7 years ago
selector: "app-home",
templateUrl: "./home.page.html",
styleUrls: ["./home.page.scss"]
})
export class HomePage implements OnInit {
7 years ago
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
) {}
ngOnInit() {
7 years ago
this.getUserDetails();
7 years ago
this.getMenu();
}
7 years ago
private openMenu() {
7 years ago
this.menu.toggle();
}
7 years ago
private getUserDetails() {
const user = this.authService
.loadAuthenticatedUser()
.subscribe((user: AuthenticatedUser) => {
7 years ago
if (user) {
7 years ago
this.userData = user;
7 years ago
console.log(user);
7 years ago
} else {
7 years ago
console.log(user);
}
7 years ago
});
}
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;
}
}
7 years ago
}
}