2019-09-23 14:23:24 +09:00
|
|
|
import { Component, OnInit, Input } from '@angular/core';
|
|
|
|
|
2019-10-08 16:41:23 +09:00
|
|
|
import { Info, EventType } from '@ucap-webmessenger/protocol-event';
|
2019-10-11 11:40:35 +09:00
|
|
|
import {
|
|
|
|
LoginResponse,
|
|
|
|
UserInfo
|
|
|
|
} from '@ucap-webmessenger/protocol-authentication';
|
2019-10-08 15:13:01 +09:00
|
|
|
import { NGXLogger } from 'ngx-logger';
|
2019-10-11 11:40:35 +09:00
|
|
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
|
|
|
import { KEY_VER_INFO, VerInfo2 } from '@app/types/ver-info.type';
|
2019-10-08 13:31:33 +09:00
|
|
|
|
2019-09-23 14:23:24 +09:00
|
|
|
@Component({
|
|
|
|
selector: 'ucap-chat-messages',
|
|
|
|
templateUrl: './messages.component.html',
|
|
|
|
styleUrls: ['./messages.component.scss']
|
|
|
|
})
|
|
|
|
export class MessagesComponent implements OnInit {
|
|
|
|
@Input()
|
2019-10-08 13:31:33 +09:00
|
|
|
loginRes: LoginResponse;
|
|
|
|
@Input()
|
|
|
|
messages: Info[];
|
2019-10-11 11:40:35 +09:00
|
|
|
@Input()
|
|
|
|
userInfos?: UserInfo[];
|
2019-09-23 14:23:24 +09:00
|
|
|
|
2019-10-08 16:41:23 +09:00
|
|
|
EventType = EventType;
|
2019-10-11 11:40:35 +09:00
|
|
|
profileImageRoot: string;
|
2019-10-08 16:41:23 +09:00
|
|
|
|
2019-10-11 11:40:35 +09:00
|
|
|
constructor(
|
|
|
|
private logger: NGXLogger,
|
|
|
|
private sessionStorageService: SessionStorageService
|
|
|
|
) {}
|
2019-09-23 14:23:24 +09:00
|
|
|
|
2019-10-08 15:13:01 +09:00
|
|
|
ngOnInit() {
|
2019-10-11 11:40:35 +09:00
|
|
|
const verInfo = this.sessionStorageService.get<VerInfo2>(KEY_VER_INFO);
|
|
|
|
this.profileImageRoot = this.profileImageRoot || verInfo.profileRoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
getUserName(seq: number): string {
|
2019-10-11 18:02:27 +09:00
|
|
|
if (!!this.userInfos) {
|
|
|
|
const userInfo: UserInfo[] = this.userInfos.filter(
|
|
|
|
user => user.seq === seq
|
|
|
|
);
|
|
|
|
if (!!userInfo && userInfo.length > 0) {
|
|
|
|
return userInfo[0].name;
|
|
|
|
}
|
2019-10-11 11:40:35 +09:00
|
|
|
}
|
|
|
|
return '(알수없는 사용자)';
|
|
|
|
}
|
|
|
|
getUserProfile(seq: number): string {
|
2019-10-11 18:02:27 +09:00
|
|
|
if (!!this.userInfos) {
|
|
|
|
const userInfo: UserInfo[] = this.userInfos.filter(
|
|
|
|
user => user.seq === seq
|
|
|
|
);
|
|
|
|
if (!!userInfo && userInfo.length > 0) {
|
|
|
|
return this.profileImageRoot + userInfo[0].profileImageFile;
|
|
|
|
}
|
2019-10-11 11:40:35 +09:00
|
|
|
}
|
|
|
|
return '';
|
2019-10-08 15:13:01 +09:00
|
|
|
}
|
2019-09-23 14:23:24 +09:00
|
|
|
}
|