187 lines
4.6 KiB
TypeScript
187 lines
4.6 KiB
TypeScript
import {
|
|
Component,
|
|
OnInit,
|
|
Input,
|
|
Output,
|
|
EventEmitter,
|
|
ViewEncapsulation
|
|
} from '@angular/core';
|
|
import { UserInfo } from '@ucap-webmessenger/protocol-sync';
|
|
import {
|
|
UserInfoSS,
|
|
UserInfoF,
|
|
UserInfoDN
|
|
} from '@ucap-webmessenger/protocol-query';
|
|
import {
|
|
StatusBulkInfo,
|
|
StatusInfo,
|
|
WorkStatusType
|
|
} from '@ucap-webmessenger/protocol-status';
|
|
import { NGXLogger } from 'ngx-logger';
|
|
import { StatusCode, PresenceType } from '@ucap-webmessenger/core';
|
|
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
@Component({
|
|
selector: 'ucap-daesang-profile-user-list-item',
|
|
templateUrl: './user-list-item.component.html',
|
|
styleUrls: ['./user-list-item.component.scss'],
|
|
encapsulation: ViewEncapsulation.None
|
|
})
|
|
export class UserListItemComponent implements OnInit {
|
|
@Input()
|
|
userInfo: UserInfoSS;
|
|
@Input()
|
|
profileImageRoot?: string;
|
|
@Input()
|
|
presence: StatusBulkInfo | StatusInfo;
|
|
@Input()
|
|
showPresence = true;
|
|
@Input()
|
|
checkable = false;
|
|
@Input()
|
|
checkDisabled = false;
|
|
@Input()
|
|
isChecked = false;
|
|
@Input()
|
|
compactable = false;
|
|
@Input()
|
|
sessionVerinfo: VersionInfo2Response;
|
|
@Input()
|
|
/** 선택된 사용자의 리스트 */
|
|
selectedUserList?: UserInfoSS[] = [];
|
|
|
|
@Output()
|
|
checkUser = new EventEmitter<{
|
|
isChecked: boolean;
|
|
userInfo: UserInfoSS;
|
|
}>();
|
|
@Output()
|
|
openProfile = new EventEmitter<number>();
|
|
|
|
PresenceType = PresenceType;
|
|
|
|
constructor(
|
|
private logger: NGXLogger,
|
|
private translateService: TranslateService
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
this.profileImageRoot =
|
|
this.profileImageRoot || this.sessionVerinfo.profileRoot;
|
|
}
|
|
|
|
getPresence(type: PresenceType): string {
|
|
let status: string;
|
|
let rtnClass = '';
|
|
switch (type) {
|
|
case PresenceType.PC:
|
|
status = !!this.presence ? this.presence.pcStatus : undefined;
|
|
break;
|
|
case PresenceType.MOBILE:
|
|
status = !!this.presence ? this.presence.mobileStatus : undefined;
|
|
break;
|
|
}
|
|
|
|
switch (status) {
|
|
case StatusCode.OnLine:
|
|
rtnClass = type + 'On';
|
|
break;
|
|
case StatusCode.Away:
|
|
rtnClass = type + 'Out';
|
|
break;
|
|
case StatusCode.Busy:
|
|
rtnClass = type + 'Other';
|
|
break;
|
|
default:
|
|
rtnClass = type + 'Off';
|
|
break;
|
|
}
|
|
|
|
return rtnClass;
|
|
}
|
|
getPresenceMsg(): string {
|
|
let presenceMsg = this.translateService.instant('presence.offline');
|
|
|
|
if (!!this.presence) {
|
|
switch (this.presence.pcStatus) {
|
|
case StatusCode.OnLine:
|
|
presenceMsg = this.translateService.instant('presence.online');
|
|
break;
|
|
case StatusCode.Away:
|
|
presenceMsg = this.translateService.instant('presence.away');
|
|
break;
|
|
case StatusCode.Busy:
|
|
if (
|
|
!!this.presence.statusMessage &&
|
|
this.presence.statusMessage !== '.'
|
|
) {
|
|
presenceMsg = this.presence.statusMessage;
|
|
} else {
|
|
presenceMsg = this.translateService.instant(
|
|
'presence.statusMessage1'
|
|
);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
return presenceMsg;
|
|
}
|
|
|
|
/** 리스트가 checkable 할 경우 checkbox 의 change 이벤트를 상위 컴포넌트로 전달한다. */
|
|
onChangeCheck(value: boolean, userInfo: UserInfoSS) {
|
|
this.checkUser.emit({
|
|
isChecked: value,
|
|
userInfo
|
|
});
|
|
}
|
|
|
|
onClickOpenProfile(event: MouseEvent, userSeq: number) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
|
|
this.openProfile.emit(userSeq);
|
|
}
|
|
|
|
getWorkstatusInfo(type: string): string {
|
|
let workstatus = this.userInfo.workstatus;
|
|
|
|
if (
|
|
!!this.presence &&
|
|
!!this.presence.workstatus &&
|
|
this.presence.workstatus.trim().length > 0
|
|
) {
|
|
workstatus = this.presence.workstatus;
|
|
}
|
|
|
|
let text = '';
|
|
// morning-off: 오전 afternoon-off: 오후 day-off: 휴가 long-time: 장기 leave-of-absence: 휴직
|
|
let style = '';
|
|
switch (workstatus) {
|
|
case WorkStatusType.VacationAM:
|
|
style = 'morning-off';
|
|
text = '오전';
|
|
break;
|
|
case WorkStatusType.VacationPM:
|
|
style = 'afternoon-off';
|
|
text = '오후';
|
|
break;
|
|
case WorkStatusType.VacationAll:
|
|
style = 'day-off';
|
|
text = '휴가';
|
|
break;
|
|
case WorkStatusType.LeaveOfAbsence:
|
|
style = 'leave-of-absence';
|
|
text = '휴직';
|
|
break;
|
|
case WorkStatusType.LongtermRefresh:
|
|
style = 'long-time';
|
|
text = '장기';
|
|
break;
|
|
}
|
|
|
|
return type === 'text' ? text : style;
|
|
}
|
|
}
|