diff --git a/projects/ucap-webmessenger-api-common/src/lib/apis/trans-mass-talk-download.ts b/projects/ucap-webmessenger-api-common/src/lib/apis/trans-mass-talk-download.ts index 04ad23a5..2b2b3279 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/apis/trans-mass-talk-download.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/apis/trans-mass-talk-download.ts @@ -17,7 +17,9 @@ export interface TransMassTalkDownloadRequest extends APIRequest { } export interface TransMassTalkDownloadResponse extends APIResponse { - content?: string; + original?: string; + translation?: string; + locale?: string; userName?: string; regDate?: string; returnJson?: any; @@ -27,7 +29,7 @@ const transMassTalkDownloadEncodeMap = { userSeq: 'p_user_seq', deviceType: 'p_device_type', token: 'p_token', - eventTransSeq: 'p_event_mass_seq' + eventTransSeq: 'p_event_trans_seq' }; export const encodeTransMassTalkDownload: APIEncoder = ( @@ -40,13 +42,14 @@ export const decodeTransMassTalkDownload: APIDecoder { try { - const json = JsonAnalization.receiveAnalization(res); return { - statusCode: json.StatusCode, - content: json.Content, - userName: json.UserName, - regDate: json.RegDate, - returnJson: res + statusCode: res.StatusCode, + original: res.Original, + translation: res.Translation, + locale: res.Locale, + userName: res.UserName, + regDate: res.RegDate, + returnJson: JSON.stringify(res) } as TransMassTalkDownloadResponse; } catch (e) { return { diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html index 5cc2a6b0..151facbc 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html @@ -244,7 +244,7 @@ [translationSimpleview]="translationSimpleview" (moreEvent)="onMoreEvent($event)" (massDetail)="onMassDetail($event)" - (massTranslationDetail)="onClickMassTranslationDetail($event)" + (massTranslationDetail)="onMassTranslationDetail($event)" (save)="onSave($event)" (fileViewer)="onFileViewer($event)" (contextMenu)="onContextMenuMessage($event)" 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 dd5b892d..2f7265f9 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 @@ -852,21 +852,42 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { ); } - onClickMassTranslationDetail(params: { - contents: string; + onMassTranslationDetail(params: { + message: Info; contentsType: string; }) { - this.dialogService.open( - MassDetailComponent, - { - disableClose: false, - width: '550px', - data: { - title: 'Detail View', - contents: params.contents + this.commonApiService + .transMassTalkDownload({ + userSeq: this.loginRes.userSeq, + deviceType: this.environmentsInfo.deviceType, + token: this.loginRes.tokenString, + eventTransSeq: params.message.sentMessageJson.translationSeq.toString() + }) + .pipe(take(1)) + .subscribe(res => { + let contents = ''; + if (res.statusCode === StatusCode.Success) { + contents = + params.contentsType === 'T' ? res.translation : res.original; + } else { + contents = + params.contentsType === 'T' + ? params.message.sentMessageJson.translation + : params.message.sentMessageJson.original; } - } - ); + + this.dialogService.open( + MassDetailComponent, + { + disableClose: false, + width: '550px', + data: { + title: this.translateService.instant('chat.detailView'), + contents + } + } + ); + }); } async onFileViewer(fileInfo: FileEventJson) { @@ -1131,14 +1152,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { message: Info, clicktype?: string ) { - this.logger.debug( - 'menuType', - menuType, - 'message', - message, - 'clicktype?', - clicktype - ); switch (menuType) { case 'COPY': { @@ -1194,30 +1207,43 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { case EventType.Translation: case EventType.MassTranslation: { - let trgtStr = ''; - if (clicktype === 'translation') { - // translation - trgtStr = (message.sentMessageJson as TranslationEventJson) - .translation; - } else { - // original - trgtStr = (message.sentMessageJson as TranslationEventJson) - .original; - } - - if (this.clipboardService.copyFromContent(trgtStr)) { - this.snackBarService.open( - this.translateService.instant( - 'common.clipboard.results.copied' - ), - '', - { - duration: 3000, - verticalPosition: 'top', - horizontalPosition: 'center' + const sentMessageJson: MassTranslationEventJson = message.sentMessageJson as MassTranslationEventJson; + this.commonApiService + .transMassTalkDownload({ + userSeq: this.loginRes.userSeq, + deviceType: this.environmentsInfo.deviceType, + token: this.loginRes.tokenString, + eventTransSeq: sentMessageJson.translationSeq.toString() + }) + .pipe(take(1)) + .subscribe(res => { + let contents = ''; + if (res.statusCode === StatusCode.Success) { + contents = + clicktype === 'translation' + ? res.translation + : res.original; + } else { + contents = + clicktype === 'translation' + ? sentMessageJson.translation + : sentMessageJson.original; } - ); - } + + if (this.clipboardService.copyFromContent(contents)) { + this.snackBarService.open( + this.translateService.instant( + 'common.clipboard.results.copied' + ), + '', + { + duration: 3000, + verticalPosition: 'top', + horizontalPosition: 'center' + } + ); + } + }); } break; default: diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass-translation.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass-translation.component.ts index 8c5386aa..ff1097a5 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass-translation.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass-translation.component.ts @@ -22,7 +22,7 @@ export class MassTranslationComponent implements OnInit { @Output() massTranslationDetail = new EventEmitter<{ - contents: string; + message: Info; contentsType: string; }>(); @@ -37,15 +37,8 @@ export class MassTranslationComponent implements OnInit { ngOnInit() {} onClickMassDetail(contentsType: string) { - let contents = ''; - if (contentsType === 'O') { - contents = this.message.sentMessageJson.original; - } else { - contents = this.message.sentMessageJson.translation; - } - this.massTranslationDetail.emit({ - contents, + message: this.message, contentsType }); } diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html index b3769536..fb12c61c 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html @@ -197,7 +197,7 @@ [translationSimpleview]="translationSimpleview" [isMe]="message.senderSeq === loginRes.userSeq" (contextMenu)="onContextMenuMessage($event, message)" - (massTranslationDetail)="onClickMassTranslationDetail($event)" + (massTranslationDetail)="onMassTranslationDetail($event)" > diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts index 0728c15e..47f28103 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts @@ -5,7 +5,8 @@ import { EventType, InfoResponse, EventJson, - FileEventJson + FileEventJson, + MassTranslationEventJson } from '@ucap-webmessenger/protocol-event'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { UserInfo, RoomInfo, RoomType } from '@ucap-webmessenger/protocol-room'; @@ -63,7 +64,7 @@ export class MessagesComponent implements OnInit { massDetail = new EventEmitter(); @Output() massTranslationDetail = new EventEmitter<{ - contents: string; + message: Info; contentsType: string; }>(); @Output() @@ -227,8 +228,8 @@ export class MessagesComponent implements OnInit { this.massDetail.emit(value); } - onClickMassTranslationDetail(params: { - contents: string; + onMassTranslationDetail(params: { + message: Info; contentsType: string; }) { this.massTranslationDetail.emit(params);