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_moe/Mohem/src/app/profile/edit-profile/edit-profile.component.ts

125 lines
4.2 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { Platform, Events, MenuController } from '@ionic/angular';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user';
import { PerformanceAppraisalResponse } from 'src/app/hmg-common/services/dashbored/performance-appraisal.response';
import { DashboredService } from 'src/app/hmg-common/services/dashbored/dashbored.service';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
import { DomSanitizer } from '@angular/platform-browser';
// import { DomSanitizer } from '@angular/platform-browser';
@Component({
selector: 'app-edit-profile',
templateUrl: './edit-profile.component.html',
styleUrls: ['./edit-profile.component.scss'],
})
export class EditProfileComponent implements OnInit {
User_name_Emp: string = '';
User_Job_name: string;
6 years ago
public direction: string;
private menu: MenuController;
setImage:any;
// imageSrc: any = "../assets/imgs/profile.png";
user_image: any = '../assets/imgs/profile.png';
personalInfo: any;
appraisalArr :any =[];
public performanceData: any=[];
public static PERFORMANCE_DATA = 'perAppData';
constructor(
public ts: TranslatorService,
public cs: CommonService,
public authService: AuthenticationService,
public DS :DashboredService,
public sharedData: SharedDataService,
public events: Events,
private sanitizer: DomSanitizer,
// private events: Events,
// private sanitizer: DomSanitizer,
)
{
6 years ago
this.direction = TranslatorService.getCurrentDirection();
this.events.subscribe('img-change', displayImg => {
console.log('app compont: '+displayImg);
this.user_image = this.sanitizer.bypassSecurityTrustUrl('data:Image/*;base64,'+displayImg);
});
}
ngOnInit() {
this.getProfile();
}
getProfile() {
console.log('getProfile');
this.authService
.loadAuthenticatedUser()
.subscribe((user: AuthenticatedUser) => {
if (user) {
this.personalInfo = user;
this.User_name_Emp=this.personalInfo.EMPLOYEE_NAME;
this.User_Job_name=this.personalInfo.JOB_NAME;
if(this.cs.getUpdateImage().status){
this.user_image =this.sanitizer.bypassSecurityTrustUrl('data:image/png;base64,'+this.cs.getUpdateImage().img);
}else{
this.user_image = user.EMPLOYEE_IMAGE
? 'data:image/png;base64,' + user.EMPLOYEE_IMAGE
: '../assets/imgs/profile.png';
}
console.log('name: '+ this.personalInfo.EMPLOYEE_NAME);
console.log('user name: '+ user.EMPLOYEE_NAME);
console.log('name: '+ this.personalInfo.JOB_NAME);
console.log('job name: '+ user.JOB_NAME);
}});
}
openEditprofile(){
this.cs.openProfile();
}
openPerormance(){
this.showPerformanceAppraisal();
}
showPerformanceAppraisal(){
this.DS.getPerformanceAppraisal(()=>{
this.showPerformanceAppraisal();
}).subscribe((result: PerformanceAppraisalResponse) => {
this.handlePerformanceAppraisalResult(result);
});
}
private handlePerformanceAppraisalResult(result){
if (this.cs.validResponse(result)) {
if (this.cs.hasData(result.GetPerformanceAppraisalList)) {
this.appraisalArr =result.GetPerformanceAppraisalList;
this.performanceData=[];
for(let i=0;i<this.appraisalArr.length;i++){
6 years ago
this.performanceData.push({name:this.appraisalArr[i].APPRAISAL_YEAR,value :parseInt(this.appraisalArr[i].APPRAISAL_SCORE).toFixed()});
}
console.log('PerformanceAppraisalResponse');
this.sharedData.setSharedData(this.performanceData, PerformanceAppraisalResponse.PERFORMANCE_DATA);
//localStorage.setItem("performanceData", this.performanceData)
this.cs.openPerformanceevaluation();
6 years ago
}else{
let msg: string = this.ts.trPK("userProfile", "no-appraisal");
this.cs.presentAlert(msg);
}
}
}
}