From e927163f95eacbb437f73d36a29ef87fee3af462 Mon Sep 17 00:00:00 2001 From: leejinho Date: Mon, 9 Dec 2019 13:42:40 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=A8=EB=B2=94=ED=95=A8=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=8D=B8=EB=84=A4=EC=9D=BC=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95.=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=ED=95=A8=20=EB=82=98=EC=97=90=EA=B2=8C=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC,=20=EC=A0=84=EB=8B=AC,=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/messages.component.ts | 5 +- .../right-drawer/album-box.component.html | 20 ++-- .../right-drawer/album-box.component.ts | 27 +---- .../right-drawer/file-box.component.html | 3 + .../right-drawer/file-box.component.ts | 105 +++++++++++++++++- .../src/lib/models/file-info.ts | 5 + .../src/lib/protocols/info.ts | 12 +- 7 files changed, 133 insertions(+), 44 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index f8c4d5a9..0fa78e52 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -87,10 +87,7 @@ import { import { CONST, FileUtil, - StickerFilesInfo, - StickerUtil, - StickerInfo, - StickerMap + StickerFilesInfo } from '@ucap-webmessenger/core'; import { PerfectScrollbarComponent } from 'ngx-perfect-scrollbar'; import { StatusCode } from '@ucap-webmessenger/api'; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.html index 1d654395..2587ae2a 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.html @@ -99,25 +99,21 @@ > - - +
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.ts index 692c48c0..07bf9a5b 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.ts @@ -28,7 +28,6 @@ import { _MODULE_CONFIG } from 'projects/ucap-webmessenger-api-common/src/lib/co export interface FileInfoTotal { info: FileInfo; checkInfo: FileDownloadInfo[]; - eventInfo?: Info; fileDownloadItem: FileDownloadItem; } @@ -89,14 +88,11 @@ export class AlbumBoxComponent implements OnInit, OnDestroy { select( AppStore.MessengerSelector.EventSelector.selectAllFileInfoCheckList ) - ), - this.store.pipe( - select(AppStore.MessengerSelector.EventSelector.selectAllInfoList) ) ]) .pipe( tap(() => (this.fileInfoTotal = [])), - tap(([roomInfo, fileInfoList, fileInfoCheckList, eventList]) => { + tap(([roomInfo, fileInfoList, fileInfoCheckList]) => { this.fileInfoList = fileInfoList.filter(fileInfo => { if ( fileInfo.roomSeq === roomInfo.roomSeq && @@ -110,17 +106,11 @@ export class AlbumBoxComponent implements OnInit, OnDestroy { }); this.fileInfoList.map(fileInfo => { - const events = eventList.filter( - event => event.seq === fileInfo.eventSeq - ); - this.fileInfoTotal.push({ info: fileInfo, checkInfo: fileInfoCheckList.filter( checkInfo => checkInfo.seq === fileInfo.seq ), - eventInfo: - events.length > 0 ? (events[0] as Info) : null, fileDownloadItem: new FileDownloadItem() }); }); @@ -153,21 +143,6 @@ export class AlbumBoxComponent implements OnInit, OnDestroy { ); } - getThumbnailUrl(fileInfo: FileInfoTotal): string { - if ( - !!fileInfo.eventInfo && - !!fileInfo.eventInfo.sentMessageJson && - !!fileInfo.eventInfo.sentMessageJson.thumbUrl - ) { - return fileInfo.eventInfo.sentMessageJson.thumbUrl; - } else { - return `${this.thumbBaseUrl}${fileInfo.info.url.replace( - '/AttFile/', - '/WebFile/' - )}.thumb.jpg`; - } - } - onErrorThumbnail(el: HTMLElement, fileInfo: FileInfoTotal): void { const iconEl = document.createElement('div'); iconEl.setAttribute( diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.html index 1a7dd94b..0e46c4cc 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.html @@ -103,6 +103,7 @@ stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="round" + (click)="onClickForwardMe(selectedFile)" > diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.ts index eb8a3dd6..2d8eadbb 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.ts @@ -9,6 +9,7 @@ import { Subscription, combineLatest } from 'rxjs'; import { Store, select } from '@ngrx/store'; import * as AppStore from '@app/store'; +import * as EventStore from '@app/store/messenger/event'; import { tap, map, take, finalize } from 'rxjs/operators'; import { FileUtil, MimeUtil, DeviceType } from '@ucap-webmessenger/core'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; @@ -17,8 +18,22 @@ import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native'; import { NGXLogger } from 'ngx-logger'; import { FileDownloadItem } from '@ucap-webmessenger/api'; -import { SnackBarService } from '@ucap-webmessenger/ui'; +import { + SnackBarService, + DialogService, + ConfirmDialogComponent, + ConfirmDialogResult, + ConfirmDialogData +} from '@ucap-webmessenger/ui'; import { CommonApiService } from '@ucap-webmessenger/api-common'; +import { EventType } from '@ucap-webmessenger/protocol-event'; +import { + CreateChatDialogComponent, + CreateChatDialogResult, + CreateChatDialogData +} from '../../dialogs/chat/create-chat.dialog.component'; +import { UserSelectDialogType } from '@app/types'; +import { RoomInfo } from '@ucap-webmessenger/protocol-room'; export interface FileInfoTotal { info: FileInfo; @@ -38,6 +53,7 @@ export class FileBoxComponent implements OnInit, OnDestroy { fileInfoTotal: FileInfoTotal[]; fileInfoList: FileInfo[]; fileInfoListSubscription: Subscription; + roomInfo: RoomInfo; selectedFile: FileInfoTotal; selectedFileList: FileInfoTotal[] = []; @@ -55,6 +71,7 @@ export class FileBoxComponent implements OnInit, OnDestroy { private commonApiService: CommonApiService, private snackBarService: SnackBarService, @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, + private dialogService: DialogService, private logger: NGXLogger ) { this.loginRes = this.sessionStorageService.get( @@ -77,6 +94,8 @@ export class FileBoxComponent implements OnInit, OnDestroy { .pipe( tap(() => (this.fileInfoTotal = [])), tap(([roomInfo, fileInfoList, fileInfoCheckList]) => { + this.roomInfo = roomInfo; + this.fileInfoList = fileInfoList.filter(fileInfo => { if ( fileInfo.roomSeq === roomInfo.roomSeq && @@ -294,4 +313,88 @@ export class FileBoxComponent implements OnInit, OnDestroy { this.logger.error(reason); }); } + + onClickForwardMe(fileInfo: FileInfoTotal) { + this.store.dispatch( + EventStore.forward({ + senderSeq: this.loginRes.userSeq, + req: { + roomSeq: '-999', + eventType: EventType.File, + sentMessage: fileInfo.info.sentMessage + }, + trgtUserSeqs: [this.loginRes.talkWithMeBotSeq] + }) + ); + } + + async onClickForward(fileInfo: FileInfoTotal) { + const result = await this.dialogService.open< + CreateChatDialogComponent, + CreateChatDialogData, + CreateChatDialogResult + >(CreateChatDialogComponent, { + width: '600px', + data: { + type: UserSelectDialogType.MessageForward, + title: 'MessageForward', + ignoreRoom: [this.roomInfo] + } + }); + + if (!!result && !!result.choice && result.choice) { + const userSeqs: number[] = []; + let roomSeq = ''; + if (!!result.selectedUserList && result.selectedUserList.length > 0) { + result.selectedUserList.map(user => userSeqs.push(user.seq)); + } + + if (!!result.selectedRoom) { + roomSeq = result.selectedRoom.roomSeq; + } + + if (userSeqs.length > 0 || roomSeq.trim().length > 0) { + this.store.dispatch( + EventStore.forward({ + senderSeq: this.loginRes.userSeq, + req: { + roomSeq: '-999', + eventType: EventType.File, + sentMessage: fileInfo.info.sentMessage + }, + trgtUserSeqs: userSeqs, + trgtRoomSeq: roomSeq + }) + ); + } + } + } + + async onClickDelete(fileInfo: FileInfoTotal) { + const result = await this.dialogService.open< + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult + >(ConfirmDialogComponent, { + width: '400px', + data: { + title: 'Delete', + html: `선택한 파일(메시지)를 삭제하시겠습니까?
삭제된 파일(메시지)는 내 대화방에서만 적용되며 상대방의 대화방에서는 삭제되지 않습니다.` + } + }); + + if (!!result && !!result.choice && result.choice) { + this.store.dispatch( + EventStore.del({ + roomSeq: this.roomInfo.roomSeq, + eventSeq: fileInfo.info.eventSeq + }) + ); + + this.fileInfoTotal = this.fileInfoTotal.filter( + fInfo => fInfo.info.seq !== fileInfo.info.seq + ); + this.onSelectedIndexChange(this.currentTabIndex); + } + } } diff --git a/projects/ucap-webmessenger-protocol-file/src/lib/models/file-info.ts b/projects/ucap-webmessenger-protocol-file/src/lib/models/file-info.ts index 94daf82b..41f90311 100644 --- a/projects/ucap-webmessenger-protocol-file/src/lib/models/file-info.ts +++ b/projects/ucap-webmessenger-protocol-file/src/lib/models/file-info.ts @@ -1,4 +1,5 @@ import { FileType } from '../types/file.type'; +import { FileEventJson } from '@ucap-webmessenger/protocol-event'; export interface FileInfo { // 대화방SEQ @@ -23,4 +24,8 @@ export interface FileInfo { receivedUserCount: number; // 수신자수 receiverCount: number; + // 발신내용 + sentMessage: string; + // 발신내용 For Json + sentMessageJson?: FileEventJson; } diff --git a/projects/ucap-webmessenger-protocol-file/src/lib/protocols/info.ts b/projects/ucap-webmessenger-protocol-file/src/lib/protocols/info.ts index 27a0e051..274c44e2 100644 --- a/projects/ucap-webmessenger-protocol-file/src/lib/protocols/info.ts +++ b/projects/ucap-webmessenger-protocol-file/src/lib/protocols/info.ts @@ -13,6 +13,11 @@ import { import { FileType } from '../types/file.type'; import { FileInfo } from '../models/file-info'; import { FileDownloadInfo } from '../models/file-download-info'; +import { + decodeEventJson, + EventType, + FileEventJson +} from '@ucap-webmessenger/protocol-event'; export interface InfoRequest extends ProtocolRequest { // 대화방SEQ(s) @@ -65,7 +70,12 @@ export const decodeInfoData: ProtocolDecoder = ( size: info[7], sendDate: info[8], receivedUserCount: Number(info[9]), - receiverCount: Number(info[10]) + receiverCount: Number(info[10]), + sentMessage: info[11], + sentMessageJson: decodeEventJson( + EventType.File, + info[11] + ) as FileEventJson }); });