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 2d0c8206..9e1aae3f 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 @@ -101,10 +101,16 @@ (click)="onClickReceiveAlarm()" aria-label="Toggle Receive Alarm" > - notifications_active - notifications_off 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 2c3ac0b3..2045913b 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 @@ -36,7 +36,8 @@ import { FileEventJson, StickerEventJson, MassTextEventJson, - TranslationEventJson + TranslationEventJson, + MassTranslationEventJson } from '@ucap-webmessenger/protocol-event'; import * as AppStore from '@app/store'; @@ -75,7 +76,8 @@ import { FileTalkSaveRequest, FileTalkSaveResponse, TranslationReqRequest, - TranslationSaveRequest + TranslationSaveRequest, + TranslationSaveResponse } from '@ucap-webmessenger/api-common'; import { CreateChatDialogComponent, @@ -174,7 +176,10 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { translationSimpleview = false; translationPreview = false; destLocale = 'en'; // default English :: en - translationPreviewInfo: TranslationEventJson | null; + translationPreviewInfo: { + previewInfo: TranslationSaveResponse | null; + translationType: EventType.Translation | EventType.MassTranslation; + }; /** About ReadHere */ firstcheckReadHere = true; @@ -620,8 +625,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { if (!!this.isShowTranslation && this.destLocale.trim().length > 0) { /** CASE : Translation */ - console.log('번역들어간다.'); - const destLocale = this.destLocale; const original = message; const roomSeq = this.roomInfo.roomSeq; @@ -638,13 +641,21 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { .pipe( take(1), map(res => { - console.log(res); if (res.statusCode === StatusCode.Success) { + let sentMessage = ''; + let eventType = EventType.Translation; + let previewObject: + | TranslationEventJson + | MassTranslationEventJson; + if (res.translationSeq > 0) { // Mass Text Translation + previewObject = res; + sentMessage = res.returnJson; + eventType = EventType.MassTranslation; } else { // Normal Text Translation - const json: TranslationEventJson = { + previewObject = { locale: destLocale, original, translation: res.translation, @@ -654,32 +665,38 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { : '' }; - if (!!this.translationPreview) { - // preview - this.translationPreviewInfo = json; - } else { - // direct send - this.store.dispatch( - EventStore.send({ - senderSeq: this.loginRes.userSeq, - req: { - roomSeq, - eventType: EventType.Translation, - sentMessage: JSON.stringify(json) - } - }) - ); + sentMessage = JSON.stringify(previewObject); + eventType = EventType.Translation; + } - if (!!this.translationPreviewInfo) { - this.translationPreviewInfo = null; - } - } + if (!!this.translationPreview) { + // preview + this.translationPreviewInfo = { + previewInfo: res, + translationType: eventType + }; + } else { + // direct send + this.store.dispatch( + EventStore.send({ + senderSeq: this.loginRes.userSeq, + req: { + roomSeq, + eventType, + sentMessage + } + }) + ); - if (!!this.selectedSticker) { - this.isShowStickerSelector = false; - this.setStickerHistory(this.selectedSticker); + if (!!this.translationPreviewInfo) { + this.translationPreviewInfo = null; } } + + if (!!this.selectedSticker) { + this.isShowStickerSelector = false; + this.setStickerHistory(this.selectedSticker); + } } else { this.logger.error(res); } @@ -1470,14 +1487,32 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { onCancelTranslation() { this.translationPreviewInfo = null; } - onSendTranslationMessage(translationInfo: TranslationEventJson) { + onSendTranslationMessage(params: { + previewInfo: TranslationSaveResponse | null; + translationType: EventType.Translation | EventType.MassTranslation; + }) { + let sentMessage = ''; + if (params.translationType === EventType.MassTranslation) { + // Mass Text Translation + sentMessage = params.previewInfo.returnJson; + } else { + // Normal Text Translation + sentMessage = JSON.stringify({ + locale: params.previewInfo.destLocale, + original: params.previewInfo.original, + translation: params.previewInfo.translation, + stickername: '', + stickerfile: !!this.selectedSticker ? this.selectedSticker.index : '' + }); + } + this.store.dispatch( EventStore.send({ senderSeq: this.loginRes.userSeq, req: { roomSeq: this.roomInfo.roomSeq, - eventType: EventType.Translation, - sentMessage: JSON.stringify(translationInfo) + eventType: params.translationType, + sentMessage } }) ); diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass-translation.component.html b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass-translation.component.html index 780bf3cc..47090973 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass-translation.component.html +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass-translation.component.html @@ -1,23 +1,26 @@
-
- {{ message.sentMessageJson.translation }} -
-
- Kor - 녕하세요 장문장문 롱텍스트안녕하세요 장문장문 롱텍스트안녕하세요 장문장문 - 롱텍스트안녕하세요 장문장문 롱텍스트안녕하세요 장문장문 롱텍스트안녕하세요 - 장문장문 롱텍스트안녕하세요 장문장문 롱텍스트안녕하세요 장문장문 - 롱텍스트안녕하세요 장문장문 롱텍스트안녕하세요 장문장문 롱텍스트안녕하세요 - 장문장문 롱텍스트안녕하세요 장문장문 롱텍스트안녕하세요 장문장문 - 롱텍스트안녕하세요 장문장문 롱텍스트안녕하세요 장문장문 롱텍스트 +
+
+ {{ message.sentMessageJson.destLocale }} +
  • - +
  • - +
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 a8fc4f72..5e2c190a 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 @@ -1,5 +1,9 @@ import { Component, OnInit, Input } from '@angular/core'; -import { TranslationEventJson, Info } from '@ucap-webmessenger/protocol-event'; +import { + TranslationEventJson, + Info, + MassTranslationEventJson +} from '@ucap-webmessenger/protocol-event'; @Component({ selector: 'ucap-chat-message-box-mass-translation', @@ -8,7 +12,13 @@ import { TranslationEventJson, Info } from '@ucap-webmessenger/protocol-event'; }) export class MassTranslationComponent implements OnInit { @Input() - message: Info; + message: Info; + + @Input() + translationSimpleview: boolean; + + @Input() + isMe: boolean; constructor() {} 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 5482e9a1..19850f98 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 @@ -131,14 +131,14 @@ *ngIf="getUserProfile(message.senderSeq) != ''" class="profile-img thumbnail-mask" > - + diff --git a/projects/ucap-webmessenger-ui/src/lib/components/translation-section.component.ts b/projects/ucap-webmessenger-ui/src/lib/components/translation-section.component.ts index 2b3bc514..f3f0007b 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/translation-section.component.ts +++ b/projects/ucap-webmessenger-ui/src/lib/components/translation-section.component.ts @@ -7,7 +7,12 @@ import { } from '@ucap-webmessenger/core'; import { FormGroup, FormBuilder } from '@angular/forms'; import { MatSlideToggleChange, MatSelectChange } from '@angular/material'; -import { TranslationEventJson } from '@ucap-webmessenger/protocol-event'; +import { + TranslationEventJson, + MassTranslationEventJson, + EventType +} from '@ucap-webmessenger/protocol-event'; +import { TranslationSaveResponse } from '@ucap-webmessenger/api-common'; @Component({ selector: 'ucap-translation-section', @@ -22,7 +27,10 @@ export class TranslationSectionComponent implements OnInit { @Input() preView: boolean; @Input() - translationPreviewInfo: TranslationEventJson | null; + translationPreviewInfo: { + previewInfo: TranslationSaveResponse | null; + translationType: EventType.Translation | EventType.MassTranslation; + }; @Output() changeTranslationSimpleview = new EventEmitter(); @@ -33,7 +41,10 @@ export class TranslationSectionComponent implements OnInit { @Output() cancelTranslation = new EventEmitter(); @Output() - sendTranslationMessage = new EventEmitter(); + sendTranslationMessage = new EventEmitter<{ + previewInfo: TranslationSaveResponse | null; + translationType: EventType.Translation | EventType.MassTranslation; + }>(); isShowTranslationSimpleview = false; isShowTranslationPreview = false; @@ -171,7 +182,10 @@ export class TranslationSectionComponent implements OnInit { this.changeTranslationPreview.emit(event.checked); } - onClickSendTranslationMessage(translationInfo: TranslationEventJson) { + onClickSendTranslationMessage(translationInfo: { + previewInfo: TranslationSaveResponse | null; + translationType: EventType.Translation | EventType.MassTranslation; + }) { this.sendTranslationMessage.emit(translationInfo); }