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 40a0d7e0..a837ee28 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 @@ -1,3 +1,4 @@ +import { forward } from './../../../store/messenger/event/actions'; import { Component, OnInit, @@ -32,7 +33,11 @@ import * as ChatStore from '@app/store/messenger/chat'; import * as RoomStore from '@app/store/messenger/room'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; -import { EnvironmentsInfo, KEY_ENVIRONMENTS_INFO } from '@app/types'; +import { + EnvironmentsInfo, + KEY_ENVIRONMENTS_INFO, + UserSelectDialogType +} from '@app/types'; import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room'; import { tap, take } from 'rxjs/operators'; import { FileInfo } from '@ucap-webmessenger/ui-chat'; @@ -40,22 +45,11 @@ import { KEY_VER_INFO } from '@app/types/ver-info.type'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { MatMenuTrigger } from '@angular/material'; import { CommonApiService } from '@ucap-webmessenger/api-common'; - import { - DeleteMessageDialogComponent, - DeleteMessageDialogData, - DeleteMessageDialogResult -} from '@app/layouts/messenger/dialogs/message/delete-message.dialog.component'; -import { - RelayMessageDialogComponent, - RelayMessageDialogData, - RelayMessageDialogResult -} from '@app/layouts/messenger/dialogs/message/relay-message.dialog.component'; -import { - RecallMessageDialogComponent, - RecallMessageDialogData, - RecallMessageDialogResult -} from '@app/layouts/messenger/dialogs/message/recall-message.dialog.component'; + CreateChatDialogComponent, + CreateChatDialogData, + CreateChatDialogResult +} from '../dialogs/chat/create-chat.dialog.component'; @Component({ selector: 'app-layout-messenger-messages', @@ -320,16 +314,48 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked { case 'REPLAY': { const result = await this.dialogService.open< - RelayMessageDialogComponent, - RelayMessageDialogData, - RelayMessageDialogResult - >(RelayMessageDialogComponent, { - width: '220px', + CreateChatDialogComponent, + CreateChatDialogData, + CreateChatDialogResult + >(CreateChatDialogComponent, { + width: '600px', + height: '500px', data: { - title: 'Logout', - message: 'Logout ?' + 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: message.type, + sentMessage: message.sentMessage + }, + trgtUserSeqs: userSeqs, + trgtRoomSeq: roomSeq + }) + ); + } + } } break; case 'REPLAY_TO_ME': diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html index 6388a0b6..28c11a9e 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html @@ -25,7 +25,10 @@ fxLayoutGap.xs="0" >
- + group @@ -98,12 +101,16 @@ [roomInfo]="room" [roomUserInfo]="getRoomUserList(room)" [sessionVerinfo]="sessionVerinfo" + [checkable]="getCheckableRoom(room)" + [isChecked]="getCheckedRoom(room)" + [multiCheckable]="false" + (checkRoom)="onCheckRoom($event)" >
-
+
대화방 선택 :: 해당 팝업에서는 대화방을 중복 선택하지 않는다 */ + onCheckRoom(params: { isChecked: boolean; roomInfo: RoomInfo }) { + if (params.isChecked) { + this.selectedRoom = params.roomInfo; + } else { + this.selectedRoom = null; + } + } + /** 그룹>부서원 리스트의 ischecked 를 판단. */ getCheckedUser(userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN) { if (!!this.selectedUserList && this.selectedUserList.length > 0) { @@ -334,6 +368,22 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { return false; } + getCheckableRoom(roomInfo: RoomInfo) { + if (!!this.data.ignoreRoom && this.data.ignoreRoom.length > 0) { + return !( + this.data.ignoreRoom.filter(room => room.roomSeq === roomInfo.roomSeq) + .length > 0 + ); + } + return true; + } + getCheckedRoom(roomInfo: RoomInfo) { + if (!!this.selectedRoom) { + return this.selectedRoom.roomSeq === roomInfo.roomSeq; + } + return false; + } + /** 선택된 사용자 취소 */ onClickDeleteUser(userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN) { this.selectedUserList = this.selectedUserList.filter( @@ -346,6 +396,7 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { this.dialogRef.close({ choice, selectedUserList: this.selectedUserList, + selectedRoom: this.selectedRoom, groupName: this.data.type === UserSelectDialogType.NewGroup ? this.inputForm.get('groupName').value diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts index eeabacb9..69e78390 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts @@ -72,6 +72,29 @@ export const sendNotification = createAction( props<{ noti: SendNotification }>() ); +export const forward = createAction( + '[Messenger::Event] forward', + props<{ + senderSeq: number; + req: SendRequest; + trgtUserSeqs?: number[]; + trgtRoomSeq?: string; + }>() +); +export const forwardFailure = createAction( + '[Messenger::Event] Forward Failure', + props<{ error: any }>() +); +export const forwardAfterRoomOpen = createAction( + '[Messenger::Event] forwardAfterRoomOpen', + props<{ + senderSeq: number; + req: SendRequest; + trgtUserSeqs?: number[]; + trgtRoomSeq?: string; + }>() +); + export const read = createAction( '[Messenger::Event] read', props() diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts index c0631f7f..74959c69 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts @@ -29,6 +29,7 @@ import { } from '@ucap-webmessenger/protocol-event'; import * as ChatStore from '@app/store/messenger/chat'; +import * as EventStore from '@app/store/messenger/event'; import * as SyncStore from '@app/store/messenger/sync'; import { @@ -51,12 +52,20 @@ import { delFailure, delInfoList, cancel, - cancelFailure + cancelFailure, + forward, + forwardFailure, + forwardAfterRoomOpen } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; -import { RoomInfo } from '@ucap-webmessenger/protocol-room'; +import { + RoomInfo, + RoomProtocolService, + OpenResponse +} from '@ucap-webmessenger/protocol-room'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; import { Dictionary } from '@ngrx/entity'; +import { openSuccess, openFailure } from '../room'; @Injectable() export class Effects { @@ -220,6 +229,67 @@ export class Effects { { dispatch: false } ); + forward$ = createEffect( + () => { + return this.actions$.pipe( + ofType(forward), + map(action => { + if (!!action.trgtRoomSeq) { + this.store.dispatch( + ChatStore.selectedRoom({ roomSeq: action.trgtRoomSeq }) + ); + this.store.dispatch( + EventStore.send({ + senderSeq: action.senderSeq, + req: { + roomSeq: action.trgtRoomSeq, + eventType: action.req.eventType, + sentMessage: action.req.sentMessage + } + }) + ); + } else if (!!action.trgtUserSeqs && action.trgtUserSeqs.length > 0) { + // 방오픈 후 대화전달. + this.store.dispatch(forwardAfterRoomOpen(action)); + } + }) + ); + }, + { dispatch: false } + ); + + forwardAfterRoomOpen$ = createEffect(() => + this.actions$.pipe( + ofType(forwardAfterRoomOpen), + exhaustMap(action => { + return this.roomProtocolService + .open({ + divCd: 'forwardOpen', + userSeqs: action.trgtUserSeqs + }) + .pipe( + map((res: OpenResponse) => { + return openSuccess({ res }); + }), + map(res => { + this.store.dispatch( + EventStore.send({ + senderSeq: action.senderSeq, + req: { + roomSeq: res.res.roomSeq, + eventType: action.req.eventType, + sentMessage: action.req.sentMessage + } + }) + ); + return res; + }), + catchError(error => of(openFailure({ error }))) + ); + }) + ) + ); + newInfo$ = createEffect( () => { return this.actions$.pipe( @@ -360,6 +430,7 @@ export class Effects { private actions$: Actions, private store: Store, private eventProtocolService: EventProtocolService, + private roomProtocolService: RoomProtocolService, private sessionStorageService: SessionStorageService, private logger: NGXLogger ) {} diff --git a/projects/ucap-webmessenger-ui-room/src/lib/components/list-item.component.html b/projects/ucap-webmessenger-ui-room/src/lib/components/list-item.component.html index bd2f916b..38425214 100644 --- a/projects/ucap-webmessenger-ui-room/src/lib/components/list-item.component.html +++ b/projects/ucap-webmessenger-ui-room/src/lib/components/list-item.component.html @@ -16,7 +16,7 @@
{{ roomInfo.joinUserCount }}명
-
+
notifications_off
@@ -25,6 +25,15 @@
{{ roomInfo.finalEventDate }}
+
+ + +
(); imagePath: string; defaultPath = 'assets/images/img_nophoto_50.png'; @@ -95,4 +110,21 @@ export class ListItemComponent implements OnInit { return roomName; } } + + // getChecked(value: boolean, roomInfo: RoomInfo) { + // if (value && !this.multiCheckable) { + // if (this.selected === roomInfo.roomSeq) { + // return true; + // } else { + // return false; + // } + // } + // } + + onChangeCheck(value: boolean, roomInfo: RoomInfo) { + this.checkRoom.emit({ + isChecked: value, + roomInfo + }); + } } diff --git a/projects/ucap-webmessenger-ui-room/src/lib/ucap-ui-room.module.ts b/projects/ucap-webmessenger-ui-room/src/lib/ucap-ui-room.module.ts index 33a792d5..63c509b3 100644 --- a/projects/ucap-webmessenger-ui-room/src/lib/ucap-ui-room.module.ts +++ b/projects/ucap-webmessenger-ui-room/src/lib/ucap-ui-room.module.ts @@ -8,7 +8,7 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { ListItemComponent } from './components/list-item.component'; -import { MatBadgeModule } from '@angular/material'; +import { MatBadgeModule, MatCheckboxModule } from '@angular/material'; import { UCapUiModule } from '@ucap-webmessenger/ui'; @@ -26,6 +26,7 @@ const SERVICES = []; MatIconModule, MatInputModule, MatBadgeModule, + MatCheckboxModule, UCapUiModule ],