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.
85 lines
2.9 KiB
TypeScript
85 lines
2.9 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
|
|
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
|
|
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
|
|
import { MenuResponse } from 'src/app/hmg-common/services/menu/models/menu-response';
|
|
import { MyTeamService } from '../service/my-team.service';
|
|
import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user';
|
|
import { AnyARecord } from 'dns';
|
|
|
|
@Component({
|
|
selector: 'app-employee-hierarchy',
|
|
templateUrl: './employee-hierarchy.component.html',
|
|
styleUrls: ['./employee-hierarchy.component.scss'],
|
|
})
|
|
export class EmployeeHierarchyComponent implements OnInit {
|
|
public personalInfo: any;
|
|
public hierarchyData: any;
|
|
public subordinateHierarchyList: any;
|
|
public supervisorHierarchyList: any;
|
|
public currentEmployee: any;
|
|
public direction: String;
|
|
constructor(
|
|
public ts: TranslatorService,
|
|
public authService: AuthenticationService,
|
|
public common: CommonService,
|
|
public myTeamService: MyTeamService,
|
|
public cs: CommonService
|
|
) { }
|
|
|
|
ngOnInit() {
|
|
this.currentEmployee = this.common.sharedService.getSharedData('employee-hierarchy', false);
|
|
this.direction = TranslatorService.getCurrentLanguageName();
|
|
if (!this.currentEmployee) {
|
|
this.getProfile();
|
|
} else {
|
|
this.personalInfo = this.currentEmployee;
|
|
this.getEmployeeHierachy();
|
|
}
|
|
}
|
|
|
|
public getProfile() {
|
|
this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => {
|
|
if (user) {
|
|
this.personalInfo = user;
|
|
this.getEmployeeHierachy();
|
|
}
|
|
});
|
|
}
|
|
|
|
public filterArrayOnLVL(incomingArray: any) {
|
|
return incomingArray.filter(a => {
|
|
return a.LVL != 1;
|
|
});
|
|
}
|
|
|
|
public getEmployeeHierachy() {
|
|
const body = {
|
|
P_SELECTED_EMPLOYEE_NUMBER: this.personalInfo.EMPLOYEE_NUMBER,
|
|
P_MENU_TYPE: "E",
|
|
P_SELECTED_RESP_ID: -999
|
|
};
|
|
this.myTeamService.getEmployeeHierachy(body).subscribe((result: any) => {
|
|
if (this.cs.validResponse(result)) {
|
|
this.hierarchyData = result.SupervisorHierarchyLists;
|
|
|
|
let serverSubordinateData = this.hierarchyData.SubordinateHierarchyList;
|
|
this.subordinateHierarchyList = this.filterArrayOnLVL(serverSubordinateData);
|
|
|
|
let serverSupervisorHierarchyList = this.hierarchyData.SupervisorHierarchyList;
|
|
let serverSupervisorData = serverSupervisorHierarchyList.reverse();
|
|
this.supervisorHierarchyList = this.filterArrayOnLVL(serverSupervisorData);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
public getDetails(i: any) {
|
|
if (i.NUM_OF_SUBORDINATES > 0) {
|
|
this.common.sharedService.setSharedData(i, 'employee-hierarchy');
|
|
this.cs.openEmployeeHierarchy();
|
|
}
|
|
}
|
|
|
|
}
|