From 72c704e9afd0854941560f4ce5f39e2ea493a8ac Mon Sep 17 00:00:00 2001 From: leejh Date: Wed, 23 Oct 2019 17:03:34 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20::=20?= =?UTF-8?q?=EB=8C=80=ED=99=94=20>=20=EB=8C=80=ED=99=94=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=20::=20context=20menu=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?.=201.=20=EB=8C=80=ED=99=94=EB=B0=A9=20=EC=97=B4=EA=B8=B0,=202.?= =?UTF-8?q?=20=EB=8C=80=ED=99=94=EB=B0=A9=20=EC=95=8C=EB=A6=BC=20=ED=86=A0?= =?UTF-8?q?=EB=93=A4=203.=20=EB=8C=80=ED=99=94=EB=B0=A9=20=EB=82=98?= =?UTF-8?q?=EA=B0=80=EA=B8=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../left-sidenav/chat.component.html | 22 +++++++++++++ .../components/left-sidenav/chat.component.ts | 32 +++++++++++++++++-- .../src/app/store/messenger/room/actions.ts | 21 +++++++++++- .../src/app/store/messenger/room/effects.ts | 22 +++++++++++-- .../src/app/store/messenger/sync/reducers.ts | 10 ++++-- .../lib/components/list-item.component.html | 3 ++ 6 files changed, 102 insertions(+), 8 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html index 539f541a..e4a43a3e 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html @@ -28,6 +28,28 @@ [roomUserInfo]="getRoomUserList(room)" [sessionVerinfo]="sessionVerinfo" (click)="onSelectedRoom(room)" + (contextmenu)="onContextMenuChat($event, room)" > + +
+ + + + + + + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts index 8f2979e7..27a75690 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts @@ -1,4 +1,5 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; +import { exit } from './../../../../store/messenger/room/actions'; +import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { ucapAnimations } from '@ucap-webmessenger/ui'; import { NGXLogger } from 'ngx-logger'; import { Store, select } from '@ngrx/store'; @@ -10,7 +11,8 @@ import { } from '@ucap-webmessenger/protocol-room'; import * as AppStore from '@app/store'; import * as ChatStore from '@app/store/messenger/chat'; -import { tap, map } from 'rxjs/operators'; +import * as RoomStore from '@app/store/messenger/room'; +import { tap } from 'rxjs/operators'; import { RoomUserDetailData, RoomUserData @@ -19,6 +21,7 @@ import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { KEY_VER_INFO } from '@app/types/ver-info.type'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; +import { MatMenuTrigger } from '@angular/material'; @Component({ selector: 'app-layout-chat-left-sidenav-chat', @@ -27,6 +30,10 @@ import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; animations: ucapAnimations }) export class ChatComponent implements OnInit, OnDestroy { + @ViewChild('chatContextMenuTrigger', { static: true }) + chatContextMenuTrigger: MatMenuTrigger; + chatContextMenuPosition = { x: '0px', y: '0px' }; + roomList: RoomInfo[]; roomUserList: RoomUserDetailData[]; roomUserShortList: RoomUserData[]; @@ -100,9 +107,30 @@ export class ChatComponent implements OnInit, OnDestroy { } } + onContextMenuChat(event: MouseEvent, roomInfo: RoomInfo) { + event.preventDefault(); + event.stopPropagation(); + + this.chatContextMenuPosition.x = event.clientX + 'px'; + this.chatContextMenuPosition.y = event.clientY + 'px'; + this.chatContextMenuTrigger.menu.focusFirstItem('mouse'); + this.chatContextMenuTrigger.menuData = { roomInfo }; + this.chatContextMenuTrigger.openMenu(); + } + onSelectedRoom(roomInfo: RoomInfo) { this.store.dispatch(ChatStore.selectedRoom({ roomSeq: roomInfo.roomSeq })); } + onClickToggleAlarm(roomInfo: RoomInfo) { + this.store.dispatch(RoomStore.updateOnlyAlarm({ roomInfo })); + } + onClickExit(roomInfo: RoomInfo) { + this.store.dispatch( + RoomStore.exit({ + roomSeq: roomInfo.roomSeq + }) + ); + } getRoomList() { if (this.isSearch && this.searchWord.trim().length > 0) { diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts index c1121182..29974252 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts @@ -11,7 +11,9 @@ import { UpdateResponse, UpdateRequest, OpenRequest, - OpenResponse + OpenResponse, + ExitRequest, + ExitResponse } from '@ucap-webmessenger/protocol-room'; export const info = createAction( @@ -91,3 +93,20 @@ export const openFailure = createAction( '[Messenger::Room] Open Failure', props<{ error: any }>() ); + +export const exit = createAction( + '[Messenger::Room] Exit', + props() +); + +export const exitSuccess = createAction( + '[Messenger::Room] Exit Success', + props<{ + res: ExitResponse; + }>() +); + +export const exitFailure = createAction( + '[Messenger::Room] Exit Failure', + props<{ error: any }>() +); diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts index ea6cca3c..c62c3b18 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts @@ -28,7 +28,8 @@ import { UserShortData, UserData, UpdateResponse, - OpenResponse + OpenResponse, + ExitResponse } from '@ucap-webmessenger/protocol-room'; import * as ChatStore from '@app/store/messenger/chat'; @@ -47,7 +48,10 @@ import { updateFailure, open, openSuccess, - openFailure + openFailure, + exit, + exitSuccess, + exitFailure } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; @@ -171,6 +175,20 @@ export class Effects { ) ); + exit$ = createEffect(() => + this.actions$.pipe( + ofType(exit), + exhaustMap(req => { + return this.roomProtocolService.exit(req).pipe( + map((res: ExitResponse) => { + return exitSuccess({ res }); + }), + catchError(error => of(exitFailure({ error }))) + ); + }) + ) + ); + inviteNotification$ = createEffect( () => { return this.actions$.pipe( diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts index 4ce8d801..4f2bd9e9 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts @@ -15,7 +15,6 @@ import { refreshRoomSuccess, updateUnreadCount, createGroupSuccess, - addBuddySuccess, delBuddySuccess, delGroupSuccess, updateBuddySuccess @@ -27,10 +26,8 @@ import { UserInfo } from '@ucap-webmessenger/protocol-sync'; -import * as AuthenticationStore from '@app/store/account/authentication'; import * as RoomStore from '@app/store/messenger/room'; import { RoomInfo } from '@ucap-webmessenger/protocol-room'; -import { UpdateResponse } from '@ucap-webmessenger/protocol-buddy'; export const reducer = createReducer( initialState, @@ -133,6 +130,13 @@ export const reducer = createReducer( }; }), + on(RoomStore.exitSuccess, (state, action) => { + return { + ...state, + room: adapterRoom.removeOne(action.res.roomSeq, { ...state.room }) + }; + }), + on(refreshRoomSuccess, (state, action) => { const roomUserList: RoomUserDetailData[] = []; const roomUserShortList: RoomUserData[] = []; 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 0d24b2e3..bd2f916b 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,6 +16,9 @@
{{ roomInfo.joinUserCount }}명
+
+ notifications_off +
{{ finalEventMessage }}