EchoTex_Payroll/HRM.UI/ClientApp/src/app/demo/view/dashboarddemo.component.ts

87 lines
3.1 KiB
TypeScript
Raw Normal View History

2024-10-14 10:01:49 +06:00
import {Component, OnInit} from '@angular/core';
import {AuthService} from '../../_services/auth/auth.service';
import {ApiService} from '../../app.api.service';
import {AuthGuard} from '../../_guards/auth.guard';
import {ActivatedRoute, Router} from '@angular/router';
import {EnumUserType} from '../../_models/enums';
import {loadingPanelService} from '../../hrm-loding panel/loding.panel.service';
import {HRMNotificationService} from '../../app.notification.service';
import {DomSanitizer} from '@angular/platform-browser';
import {EmployeeServices} from '../../_services/employee/employee.service';
@Component({
templateUrl: './dashboard.component.html'
})
export class DashboardDemoComponent implements OnInit {
public selfProfile: boolean = false;
public userType: any;
public companyImg: any;
public payrollTypeName: string;
constructor(public userService: AuthService,
public employeeService: EmployeeServices,
public apiService: ApiService,
private _auth: AuthGuard, private route: ActivatedRoute,
private router: Router, public loadingPanel: loadingPanelService,
public notificationService: HRMNotificationService,
private sanitizer: DomSanitizer) {
this.userType = undefined;
this.apiService.selectedMenuName = 'Dash-Board';
}
ngOnInit() {
this.loadingPanel.ShowLoadingPanel = true;
this.userService.GetLogInUserType().subscribe(
(resc: any) => {
this.userType = resc;
if (this.userType == EnumUserType.Employee) {
this.router.navigate(['/ess/ess-dashboard']);
} else if (this.userType == EnumUserType.User) {
// this.selfProfile = true;
// this.router.navigate(['/core-hr/core-hr-dashboard']);
this.router.navigate(['/ess/landing-page']);
}
},
(errmenu: any) => { //for error
this.loadingPanel.ShowLoadingPanel = false;
},
() => {
// this.showEmpImage();
this.loadingPanel.ShowLoadingPanel = false;
}
);
}
showEmpImage() {
this.employeeService.GetCompanyImage().subscribe(
(resp: any) => {
this.companyImg = this.sanitizer.bypassSecurityTrustResourceUrl(`data:image/png;base64, ${resp}`);
},
(err: any) => {
this.notificationService.showError(err.error);
this.loadingPanel.ShowLoadingPanel = false;
},
() => {
this.employeeService.GetPayrollTypeNameByLoginID().subscribe(
(resc2: any) => {
this.payrollTypeName = resc2;
},
(errmenu: any) => {
this.notificationService.showError(errmenu.error);
},
() => {
}
);
}
);
}
}