대용량 번역 더보기 기능 수정.

This commit is contained in:
leejinho 2020-01-09 08:46:04 +09:00
parent 6fde3b5f22
commit b1fd5a457f
6 changed files with 89 additions and 66 deletions

View File

@ -17,7 +17,9 @@ export interface TransMassTalkDownloadRequest extends APIRequest {
} }
export interface TransMassTalkDownloadResponse extends APIResponse { export interface TransMassTalkDownloadResponse extends APIResponse {
content?: string; original?: string;
translation?: string;
locale?: string;
userName?: string; userName?: string;
regDate?: string; regDate?: string;
returnJson?: any; returnJson?: any;
@ -27,7 +29,7 @@ const transMassTalkDownloadEncodeMap = {
userSeq: 'p_user_seq', userSeq: 'p_user_seq',
deviceType: 'p_device_type', deviceType: 'p_device_type',
token: 'p_token', token: 'p_token',
eventTransSeq: 'p_event_mass_seq' eventTransSeq: 'p_event_trans_seq'
}; };
export const encodeTransMassTalkDownload: APIEncoder<TransMassTalkDownloadRequest> = ( export const encodeTransMassTalkDownload: APIEncoder<TransMassTalkDownloadRequest> = (
@ -40,13 +42,14 @@ export const decodeTransMassTalkDownload: APIDecoder<TransMassTalkDownloadRespon
res: any res: any
) => { ) => {
try { try {
const json = JsonAnalization.receiveAnalization(res);
return { return {
statusCode: json.StatusCode, statusCode: res.StatusCode,
content: json.Content, original: res.Original,
userName: json.UserName, translation: res.Translation,
regDate: json.RegDate, locale: res.Locale,
returnJson: res userName: res.UserName,
regDate: res.RegDate,
returnJson: JSON.stringify(res)
} as TransMassTalkDownloadResponse; } as TransMassTalkDownloadResponse;
} catch (e) { } catch (e) {
return { return {

View File

@ -244,7 +244,7 @@
[translationSimpleview]="translationSimpleview" [translationSimpleview]="translationSimpleview"
(moreEvent)="onMoreEvent($event)" (moreEvent)="onMoreEvent($event)"
(massDetail)="onMassDetail($event)" (massDetail)="onMassDetail($event)"
(massTranslationDetail)="onClickMassTranslationDetail($event)" (massTranslationDetail)="onMassTranslationDetail($event)"
(save)="onSave($event)" (save)="onSave($event)"
(fileViewer)="onFileViewer($event)" (fileViewer)="onFileViewer($event)"
(contextMenu)="onContextMenuMessage($event)" (contextMenu)="onContextMenuMessage($event)"

View File

@ -852,21 +852,42 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
); );
} }
onClickMassTranslationDetail(params: { onMassTranslationDetail(params: {
contents: string; message: Info<MassTranslationEventJson>;
contentsType: string; contentsType: string;
}) { }) {
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, MassDetailDialogData>( this.dialogService.open<MassDetailComponent, MassDetailDialogData>(
MassDetailComponent, MassDetailComponent,
{ {
disableClose: false, disableClose: false,
width: '550px', width: '550px',
data: { data: {
title: 'Detail View', title: this.translateService.instant('chat.detailView'),
contents: params.contents contents
} }
} }
); );
});
} }
async onFileViewer(fileInfo: FileEventJson) { async onFileViewer(fileInfo: FileEventJson) {
@ -1131,14 +1152,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
message: Info<EventJson>, message: Info<EventJson>,
clicktype?: string clicktype?: string
) { ) {
this.logger.debug(
'menuType',
menuType,
'message',
message,
'clicktype?',
clicktype
);
switch (menuType) { switch (menuType) {
case 'COPY': case 'COPY':
{ {
@ -1194,18 +1207,30 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
case EventType.Translation: case EventType.Translation:
case EventType.MassTranslation: case EventType.MassTranslation:
{ {
let trgtStr = ''; const sentMessageJson: MassTranslationEventJson = message.sentMessageJson as MassTranslationEventJson;
if (clicktype === 'translation') { this.commonApiService
// translation .transMassTalkDownload({
trgtStr = (message.sentMessageJson as TranslationEventJson) userSeq: this.loginRes.userSeq,
.translation; 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 { } else {
// original contents =
trgtStr = (message.sentMessageJson as TranslationEventJson) clicktype === 'translation'
.original; ? sentMessageJson.translation
: sentMessageJson.original;
} }
if (this.clipboardService.copyFromContent(trgtStr)) { if (this.clipboardService.copyFromContent(contents)) {
this.snackBarService.open( this.snackBarService.open(
this.translateService.instant( this.translateService.instant(
'common.clipboard.results.copied' 'common.clipboard.results.copied'
@ -1218,6 +1243,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
} }
); );
} }
});
} }
break; break;
default: default:

View File

@ -22,7 +22,7 @@ export class MassTranslationComponent implements OnInit {
@Output() @Output()
massTranslationDetail = new EventEmitter<{ massTranslationDetail = new EventEmitter<{
contents: string; message: Info<MassTranslationEventJson>;
contentsType: string; contentsType: string;
}>(); }>();
@ -37,15 +37,8 @@ export class MassTranslationComponent implements OnInit {
ngOnInit() {} ngOnInit() {}
onClickMassDetail(contentsType: string) { onClickMassDetail(contentsType: string) {
let contents = '';
if (contentsType === 'O') {
contents = this.message.sentMessageJson.original;
} else {
contents = this.message.sentMessageJson.translation;
}
this.massTranslationDetail.emit({ this.massTranslationDetail.emit({
contents, message: this.message,
contentsType contentsType
}); });
} }

View File

@ -197,7 +197,7 @@
[translationSimpleview]="translationSimpleview" [translationSimpleview]="translationSimpleview"
[isMe]="message.senderSeq === loginRes.userSeq" [isMe]="message.senderSeq === loginRes.userSeq"
(contextMenu)="onContextMenuMessage($event, message)" (contextMenu)="onContextMenuMessage($event, message)"
(massTranslationDetail)="onClickMassTranslationDetail($event)" (massTranslationDetail)="onMassTranslationDetail($event)"
> >
</ucap-chat-message-box-mass-translation> </ucap-chat-message-box-mass-translation>

View File

@ -5,7 +5,8 @@ import {
EventType, EventType,
InfoResponse, InfoResponse,
EventJson, EventJson,
FileEventJson FileEventJson,
MassTranslationEventJson
} from '@ucap-webmessenger/protocol-event'; } from '@ucap-webmessenger/protocol-event';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { UserInfo, RoomInfo, RoomType } from '@ucap-webmessenger/protocol-room'; import { UserInfo, RoomInfo, RoomType } from '@ucap-webmessenger/protocol-room';
@ -63,7 +64,7 @@ export class MessagesComponent implements OnInit {
massDetail = new EventEmitter<number>(); massDetail = new EventEmitter<number>();
@Output() @Output()
massTranslationDetail = new EventEmitter<{ massTranslationDetail = new EventEmitter<{
contents: string; message: Info<MassTranslationEventJson>;
contentsType: string; contentsType: string;
}>(); }>();
@Output() @Output()
@ -227,8 +228,8 @@ export class MessagesComponent implements OnInit {
this.massDetail.emit(value); this.massDetail.emit(value);
} }
onClickMassTranslationDetail(params: { onMassTranslationDetail(params: {
contents: string; message: Info<MassTranslationEventJson>;
contentsType: string; contentsType: string;
}) { }) {
this.massTranslationDetail.emit(params); this.massTranslationDetail.emit(params);