2019-10-24 17:04:58 +09:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
Input,
|
|
|
|
Output,
|
|
|
|
EventEmitter,
|
|
|
|
ViewChildren
|
|
|
|
} from '@angular/core';
|
2019-10-10 15:50:50 +09:00
|
|
|
import {
|
|
|
|
RoomInfo,
|
|
|
|
UserInfoShort,
|
2019-10-16 09:01:03 +09:00
|
|
|
UserInfo as RoomUserInfo,
|
|
|
|
RoomType
|
2019-10-10 15:50:50 +09:00
|
|
|
} from '@ucap-webmessenger/protocol-room';
|
|
|
|
import { NGXLogger } from 'ngx-logger';
|
2019-10-15 16:59:05 +09:00
|
|
|
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
2019-10-24 17:04:58 +09:00
|
|
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
|
import { MatCheckbox } from '@angular/material';
|
2019-10-10 15:50:50 +09:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'ucap-room-list-item',
|
|
|
|
templateUrl: './list-item.component.html',
|
|
|
|
styleUrls: ['./list-item.component.scss']
|
|
|
|
})
|
|
|
|
export class ListItemComponent implements OnInit {
|
2019-10-16 14:53:53 +09:00
|
|
|
@Input()
|
|
|
|
loginRes: LoginResponse;
|
2019-10-10 15:50:50 +09:00
|
|
|
@Input()
|
|
|
|
roomInfo: RoomInfo;
|
|
|
|
@Input()
|
2019-10-21 15:03:27 +09:00
|
|
|
roomUserInfo: (RoomUserInfo | UserInfoShort)[];
|
2019-10-15 16:59:05 +09:00
|
|
|
@Input()
|
|
|
|
sessionVerinfo: VersionInfo2Response;
|
2019-10-24 17:04:58 +09:00
|
|
|
@Input()
|
|
|
|
checkable = false;
|
|
|
|
@Input()
|
|
|
|
isChecked = false;
|
|
|
|
@Input()
|
|
|
|
multiCheckable = true;
|
|
|
|
|
|
|
|
@Output()
|
|
|
|
checkRoom = new EventEmitter<{
|
|
|
|
isChecked: boolean;
|
|
|
|
roomInfo: RoomInfo;
|
|
|
|
}>();
|
2019-10-10 15:50:50 +09:00
|
|
|
|
2019-10-21 15:03:27 +09:00
|
|
|
imagePath: string;
|
|
|
|
defaultPath = 'assets/images/img_nophoto_50.png';
|
2019-10-16 09:01:03 +09:00
|
|
|
finalEventMessage: string;
|
2019-10-21 15:03:27 +09:00
|
|
|
RoomType = RoomType;
|
2019-10-16 09:01:03 +09:00
|
|
|
|
2019-10-10 15:50:50 +09:00
|
|
|
constructor(private logger: NGXLogger) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2019-10-16 09:01:03 +09:00
|
|
|
if (this.roomInfo.isTimeRoom) {
|
|
|
|
this.finalEventMessage = '비밀 대화방입니다.';
|
|
|
|
} else {
|
2019-10-16 10:22:05 +09:00
|
|
|
this.finalEventMessage = this.roomInfo.finalEventMessage;
|
2019-10-16 09:01:03 +09:00
|
|
|
}
|
2019-10-21 15:03:27 +09:00
|
|
|
|
|
|
|
switch (this.roomInfo.roomType) {
|
|
|
|
case RoomType.Multi:
|
|
|
|
this.defaultPath = 'assets/images/img_groupphoto_80.png';
|
|
|
|
break;
|
|
|
|
case RoomType.Mytalk:
|
|
|
|
const me = this.roomUserInfo.filter(
|
|
|
|
v => v.seq === this.loginRes.userSeq
|
|
|
|
);
|
|
|
|
if (!!me && me.length > 0) {
|
|
|
|
this.imagePath = me[0].profileImageFile;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RoomType.Single:
|
|
|
|
case RoomType.Bot:
|
|
|
|
case RoomType.Allim:
|
|
|
|
const others = this.roomUserInfo.filter(
|
|
|
|
v => v.seq !== this.loginRes.userSeq
|
|
|
|
);
|
|
|
|
if (!!others && others.length > 0) {
|
|
|
|
this.imagePath = others[0].profileImageFile;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2019-10-10 15:50:50 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
getRoomName(roomInfo: RoomInfo): string {
|
|
|
|
if (!!roomInfo.roomName && '' !== roomInfo.roomName.trim()) {
|
|
|
|
return roomInfo.roomName;
|
|
|
|
}
|
|
|
|
|
2019-10-16 09:01:03 +09:00
|
|
|
if (roomInfo.roomType === RoomType.Mytalk) {
|
|
|
|
return 'MyTalk';
|
|
|
|
}
|
|
|
|
|
2019-10-10 15:50:50 +09:00
|
|
|
if (!!this.roomUserInfo && 0 < this.roomUserInfo.length) {
|
|
|
|
let roomName = '';
|
2019-10-16 14:53:53 +09:00
|
|
|
this.roomUserInfo.forEach(
|
|
|
|
(roomUserInfo: RoomUserInfo | UserInfoShort, index: number) => {
|
|
|
|
if (this.loginRes.userSeq === roomUserInfo.seq) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ('' === roomName.trim()) {
|
|
|
|
roomName = roomName.concat('', roomUserInfo.name);
|
|
|
|
} else {
|
|
|
|
roomName = roomName.concat(',', roomUserInfo.name);
|
|
|
|
}
|
2019-10-10 15:50:50 +09:00
|
|
|
}
|
2019-10-16 14:53:53 +09:00
|
|
|
);
|
2019-10-10 15:50:50 +09:00
|
|
|
return roomName;
|
|
|
|
}
|
|
|
|
}
|
2019-10-24 17:04:58 +09:00
|
|
|
|
|
|
|
// getChecked(value: boolean, roomInfo: RoomInfo) {
|
|
|
|
// if (value && !this.multiCheckable) {
|
|
|
|
// if (this.selected === roomInfo.roomSeq) {
|
|
|
|
// return true;
|
|
|
|
// } else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
onChangeCheck(value: boolean, roomInfo: RoomInfo) {
|
|
|
|
this.checkRoom.emit({
|
|
|
|
isChecked: value,
|
|
|
|
roomInfo
|
|
|
|
});
|
|
|
|
}
|
2019-10-10 15:50:50 +09:00
|
|
|
}
|