2019-10-15 11:07:26 +09:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
Input,
|
|
|
|
Output,
|
2019-10-17 18:11:38 +09:00
|
|
|
EventEmitter,
|
|
|
|
ViewEncapsulation
|
2019-10-15 11:07:26 +09:00
|
|
|
} from '@angular/core';
|
2019-10-02 17:12:51 +09:00
|
|
|
import { UserInfo } from '@ucap-webmessenger/protocol-sync';
|
|
|
|
import {
|
|
|
|
UserInfoSS,
|
|
|
|
UserInfoF,
|
|
|
|
UserInfoDN
|
|
|
|
} from '@ucap-webmessenger/protocol-query';
|
|
|
|
import { StatusBulkInfo, StatusInfo } from '@ucap-webmessenger/protocol-status';
|
2019-10-10 15:50:50 +09:00
|
|
|
import { NGXLogger } from 'ngx-logger';
|
2019-10-14 10:31:28 +09:00
|
|
|
import { StatusCode } from '@ucap-webmessenger/core';
|
2019-10-02 17:12:51 +09:00
|
|
|
|
2019-10-15 13:54:58 +09:00
|
|
|
import { PresenceType } from '../types/presence-type.type';
|
2019-10-15 14:58:11 +09:00
|
|
|
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
2019-10-15 13:54:58 +09:00
|
|
|
|
2019-10-02 17:12:51 +09:00
|
|
|
@Component({
|
|
|
|
selector: 'ucap-profile-user-list-item',
|
|
|
|
templateUrl: './user-list-item.component.html',
|
2019-10-17 18:11:38 +09:00
|
|
|
styleUrls: ['./user-list-item.component.scss'],
|
|
|
|
encapsulation: ViewEncapsulation.None
|
2019-10-02 17:12:51 +09:00
|
|
|
})
|
2019-10-28 11:15:38 +09:00
|
|
|
export class UserListItemComponent implements OnInit {
|
2019-10-02 17:12:51 +09:00
|
|
|
@Input()
|
|
|
|
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
|
|
|
|
@Input()
|
2019-10-10 15:50:50 +09:00
|
|
|
profileImageRoot?: string;
|
2019-10-02 17:12:51 +09:00
|
|
|
@Input()
|
2019-10-18 12:49:23 +09:00
|
|
|
presence: StatusBulkInfo | StatusInfo;
|
2019-10-02 17:12:51 +09:00
|
|
|
@Input()
|
|
|
|
checkable = false;
|
|
|
|
@Input()
|
2019-10-17 11:49:41 +09:00
|
|
|
isChecked = false;
|
|
|
|
@Input()
|
2019-10-02 17:12:51 +09:00
|
|
|
compactable = false;
|
2019-10-15 14:58:11 +09:00
|
|
|
@Input()
|
|
|
|
sessionVerinfo: VersionInfo2Response;
|
2019-10-17 17:02:20 +09:00
|
|
|
@Input()
|
|
|
|
/** 선택된 사용자의 리스트 */
|
|
|
|
selectedUserList?: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[] = [];
|
2019-10-02 17:12:51 +09:00
|
|
|
|
2019-10-17 11:49:41 +09:00
|
|
|
@Output()
|
|
|
|
checkUser = new EventEmitter<{
|
|
|
|
isChecked: boolean;
|
|
|
|
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
|
|
|
|
}>();
|
2019-11-08 13:35:39 +09:00
|
|
|
@Output()
|
|
|
|
openProfile = new EventEmitter<
|
|
|
|
UserInfo | UserInfoSS | UserInfoF | UserInfoDN
|
|
|
|
>();
|
2019-10-11 18:24:57 +09:00
|
|
|
|
2019-10-14 13:53:44 +09:00
|
|
|
PresenceType = PresenceType;
|
2019-10-14 10:31:28 +09:00
|
|
|
|
2019-10-28 11:15:38 +09:00
|
|
|
constructor(private logger: NGXLogger) {}
|
2019-10-10 15:50:50 +09:00
|
|
|
|
|
|
|
ngOnInit() {
|
2019-10-15 14:58:11 +09:00
|
|
|
this.profileImageRoot =
|
|
|
|
this.profileImageRoot || this.sessionVerinfo.profileRoot;
|
2019-10-10 15:50:50 +09:00
|
|
|
}
|
2019-10-02 17:12:51 +09:00
|
|
|
|
2019-10-14 10:31:28 +09:00
|
|
|
getPresence(type: string): string {
|
|
|
|
let status: string;
|
|
|
|
let rtnClass = '';
|
|
|
|
switch (type) {
|
|
|
|
case 'pc':
|
2019-11-18 18:06:38 +09:00
|
|
|
status = !!this.presence ? this.presence.pcStatus : undefined;
|
2019-10-14 10:31:28 +09:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!status) {
|
|
|
|
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;
|
|
|
|
}
|
2019-10-17 11:49:41 +09:00
|
|
|
|
2019-10-17 18:05:44 +09:00
|
|
|
/** 리스트가 checkable 할 경우 checkbox 의 change 이벤트를 상위 컴포넌트로 전달한다. */
|
2019-10-17 11:49:41 +09:00
|
|
|
onChangeCheck(
|
|
|
|
value: boolean,
|
|
|
|
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN
|
|
|
|
) {
|
|
|
|
this.checkUser.emit({
|
|
|
|
isChecked: value,
|
|
|
|
userInfo
|
|
|
|
});
|
|
|
|
}
|
2019-11-08 13:35:39 +09:00
|
|
|
|
|
|
|
onClickOpenProfile(
|
|
|
|
event: MouseEvent,
|
|
|
|
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN
|
|
|
|
) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
this.openProfile.emit(userInfo);
|
|
|
|
}
|
2019-10-14 10:31:28 +09:00
|
|
|
}
|