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

85 lines
2.7 KiB
TypeScript

7 years ago
import { Component, OnInit } from "@angular/core";
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
import { MenuController, Events } from "@ionic/angular";
7 years ago
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
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 {
userData: any = {};
user_image: any = "../assets/imgs/profile.png";
7 years ago
menuList: any = [];
constructor(
public ts: TranslatorService,
public menu: MenuController,
public authService: AuthenticationService,
public menuService: MenuService,
public common: CommonService,
public events: Events
7 years ago
) {}
ngOnInit() {
7 years ago
this.getUserDetails();
7 years ago
this.getMenu();
}
private openMenu() {
7 years ago
this.menu.toggle();
}
private getUserDetails() {
this.authService
7 years ago
.loadAuthenticatedUser()
.subscribe((user: AuthenticatedUser) => {
7 years ago
if (user) {
this.events.publish("setMenu");
7 years ago
this.userData = user;
this.user_image = user.EMPLOYEE_IMAGE
? "data:image/png;base64," + user.EMPLOYEE_IMAGE
: this.user_image;
7 years ago
console.log(user);
7 years ago
} else {
7 years ago
console.log(user);
}
7 years ago
});
}
public Vacation_Rule() {
this.common.navigateForward("/vacation-rule/home");
}
7 years ago
private getMenu() {
this.menuService.getMenu().subscribe((result: MenuResponse) => {
this.handleMenuResult(result);
});
7 years ago
}
7 years ago
private handleMenuResult(result) {
if (this.common.validResponse(result)) {
if (this.common.hasData(result.List_Menu)) {
this.menuList = result.List_Menu;
}
}
}
private accrualBalance() {
this.common.openAccuralPage();
}
public getMeunDetails(index) {
let item = this.menuList[index];
let selMenu: MenuResponse = new MenuResponse();
selMenu.List_Menu = item;
selMenu.userid = this.userData.EMPLOYEE_NUMBER;
this.common.sharedService.setSharedData(selMenu, MenuResponse.SHARED_DATA);
if (item.MENU_TYPE == "M") {
this.common.openMyTeamPage();
// this.navCtrl.push("MySubordinatePage");
} else if (item.MENU_TYPE == "S") {
//this.navCtrl.push('MySpecialistPage',{"mySpecList":item});
} else {
//this.getMenuEntries(item);
}
}
}