From cbe1ddbd29a9bee0f401c2c426d1473b5c5ff7be Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Sun, 31 May 2020 18:35:45 +0900 Subject: [PATCH] 0530 sync --- package-lock.json | 18 +-- package.json | 8 +- projects/store-chat/package.json | 2 +- .../src/lib/store/chatting/effects.ts | 46 +++--- .../src/lib/store/chatting/reducers.ts | 51 ++++--- .../store-chat/src/lib/store/room/actions.ts | 30 +++- .../store-chat/src/lib/store/room/effects.ts | 64 +++++++- .../store-chat/src/lib/store/room/reducers.ts | 30 +++- projects/ui-chat/package.json | 2 +- .../components/room-expansion.component.ts | 14 ++ projects/ui-organization/package.json | 2 +- .../lib/components/profile-01.component.html | 110 ++++++++------ .../lib/components/profile-01.component.scss | 138 +++--------------- .../profile-list-item-01.component.html | 6 +- .../profile-list-item-01.component.scss | 57 +------- .../profile-selection-01.component.ts | 1 - .../search-for-tenant.component.html | 2 +- .../search-for-tenant.component.scss | 26 +--- .../src/lib/components/tree.component.scss | 8 +- .../assets/scss/partials/_search-frame.scss | 3 +- projects/ui/package.json | 2 +- projects/ui/src/lib/ui.module.ts | 4 + 22 files changed, 321 insertions(+), 303 deletions(-) diff --git a/package-lock.json b/package-lock.json index 10fd1d0..37a780f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3508,8 +3508,8 @@ "dev": true }, "@ucap/ng-store-chat": { - "version": "file:pack/ucap-ng-store-chat-0.0.16.tgz", - "integrity": "sha512-Rwupo2Gqa+4+0ANBZLtup+mdlTU42Tj5gkGnJJ86Vylo4xQcdR+PUdedWZ/lG7DyzrfBc8ON80aUPRikpWUCow==", + "version": "file:pack/ucap-ng-store-chat-0.0.19.tgz", + "integrity": "sha512-J6jhvJW7GfFOIrPfXnDZ2sqUF10C7cJm8d/9O7ThxJ8muvKhQ/ZN86yJLLtA8Y+sIIupnUikH2MGNW7mgZjHPg==", "dev": true }, "@ucap/ng-store-group": { @@ -3523,8 +3523,8 @@ "dev": true }, "@ucap/ng-ui": { - "version": "file:pack/ucap-ng-ui-0.0.19.tgz", - "integrity": "sha512-UuZSzWM4tBR+e5Z/1PFdNenHS00Pn4K7dTafIicG29YjHE5sTXXRqjDCVrKNxJQoMSEPWjUj7qnTgYwP2U83Vg==", + "version": "file:pack/ucap-ng-ui-0.0.24.tgz", + "integrity": "sha512-7G+Ee2EPYwDv64yMmy+Ga5Wcj7HK8YC0WLqvRWrLv3XZQtLfZ/oP/lWyjPvCNme0hNQo6EH1MpPn6u+uhoST6w==", "dev": true }, "@ucap/ng-ui-authentication": { @@ -3533,8 +3533,8 @@ "dev": true }, "@ucap/ng-ui-chat": { - "version": "file:pack/ucap-ng-ui-chat-0.0.12.tgz", - "integrity": "sha512-uXtqUm3O0l/7jIh9KAXrxFxma/EAtnwpr1c30gOSxDcsMgp/Tuuqb/7YjI2AOIYHaq9iWX0yNNab1ijH5Pcj+g==", + "version": "file:pack/ucap-ng-ui-chat-0.0.13.tgz", + "integrity": "sha512-ytFXvVxwkaNXH6RY4jdXpwqwfq6+HPiYN+Jqv1o5oddhlpBd7OSzhudUew318GJgclxoXbStcSc0/UODDdTptw==", "dev": true }, "@ucap/ng-ui-group": { @@ -3548,13 +3548,13 @@ "dev": true }, "@ucap/ng-ui-organization": { - "version": "file:pack/ucap-ng-ui-organization-0.0.83.tgz", - "integrity": "sha512-ls2xfMNbceUecR0Vrhm/qzbKDJmBENtA4Y0ODVKVgjui8IQnS/EXGXSeNS+rFrnASTlI2XHWiaVHFqdZi/4ipQ==", + "version": "file:pack/ucap-ng-ui-organization-0.0.84.tgz", + "integrity": "sha512-T2q3KPCjY1ZZ1bY4UtSvY1XWpb0T8AZ9GbuOFlAJK3rs+grZC+iAmC8NO8iWhUgELdUStN1Mh8ja77RSo9Nqlg==", "dev": true }, "@ucap/ng-ui-skin-default": { "version": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz", - "integrity": "sha512-+lHYAzbnyyWh6hf+Ui7vP/ibyGJXuDUO++82jOiOsnPMCl17hkCCag8vQcB/aVgl0iHmebiPshnsL3CptJfeAg==" + "integrity": "sha512-xYq5hlNUjo39R1TLBaUR59GjgGyCzTdj5CWZyUIBbFicBirsSERoUX5704HlTa0L8YSjW7exOL8VWSgEsMng6g==" }, "@ucap/ng-web-socket": { "version": "file:pack/ucap-ng-web-socket-0.0.2.tgz", diff --git a/package.json b/package.json index 80d691c..400468e 100644 --- a/package.json +++ b/package.json @@ -185,15 +185,15 @@ "@ucap/ng-protocol-sync": "file:pack/ucap-ng-protocol-sync-0.0.3.tgz", "@ucap/ng-protocol-umg": "file:pack/ucap-ng-protocol-umg-0.0.3.tgz", "@ucap/ng-store-authentication": "file:pack/ucap-ng-store-authentication-0.0.11.tgz", - "@ucap/ng-store-chat": "file:pack/ucap-ng-store-chat-0.0.16.tgz", + "@ucap/ng-store-chat": "file:pack/ucap-ng-store-chat-0.0.19.tgz", "@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.14.tgz", "@ucap/ng-store-organization": "file:pack/ucap-ng-store-organization-0.0.8.tgz", - "@ucap/ng-ui": "file:pack/ucap-ng-ui-0.0.19.tgz", + "@ucap/ng-ui": "file:pack/ucap-ng-ui-0.0.24.tgz", "@ucap/ng-ui-authentication": "file:pack/ucap-ng-ui-authentication-0.0.25.tgz", - "@ucap/ng-ui-chat": "file:pack/ucap-ng-ui-chat-0.0.12.tgz", + "@ucap/ng-ui-chat": "file:pack/ucap-ng-ui-chat-0.0.13.tgz", "@ucap/ng-ui-group": "file:pack/ucap-ng-ui-group-0.0.33.tgz", "@ucap/ng-ui-material": "file:pack/ucap-ng-ui-material-0.0.4.tgz", - "@ucap/ng-ui-organization": "file:pack/ucap-ng-ui-organization-0.0.83.tgz", + "@ucap/ng-ui-organization": "file:pack/ucap-ng-ui-organization-0.0.84.tgz", "@ucap/ng-ui-skin-default": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz", "@ucap/ng-web-socket": "file:pack/ucap-ng-web-socket-0.0.2.tgz", "@ucap/ng-web-storage": "file:pack/ucap-ng-web-storage-0.0.3.tgz", diff --git a/projects/store-chat/package.json b/projects/store-chat/package.json index 1727fba..756c875 100644 --- a/projects/store-chat/package.json +++ b/projects/store-chat/package.json @@ -1,6 +1,6 @@ { "name": "@ucap/ng-store-chat", - "version": "0.0.16", + "version": "0.0.19", "publishConfig": { "registry": "https://nexus.loafle.net/repository/npm-ucap/" }, diff --git a/projects/store-chat/src/lib/store/chatting/effects.ts b/projects/store-chat/src/lib/store/chatting/effects.ts index ce36b6b..405b5f1 100644 --- a/projects/store-chat/src/lib/store/chatting/effects.ts +++ b/projects/store-chat/src/lib/store/chatting/effects.ts @@ -20,7 +20,7 @@ import { EventProtocolService } from '@ucap/ng-protocol-event'; import { RoomProtocolService } from '@ucap/ng-protocol-room'; import { FileProtocolService } from '@ucap/ng-protocol-file'; -import * as roomActions from '../room/actions'; +import * as RoomActions from '../room/actions'; import { events, eventsFailure, @@ -51,26 +51,6 @@ import { Chatting } from './state'; @Injectable() export class Effects { - selectedRoom$ = createEffect( - () => { - return this.actions$.pipe( - ofType(roomActions.selectedRoom), - debounceTime(300), - tap((action) => { - const requestCount = this.moduleConfig?.eventRequestInitCount || 50; - const req: InfoRequest = { - roomId: action.roomId, - baseSeq: 0, - requestCount - }; - - this.store.dispatch(events({ req })); - }) - ); - }, - { dispatch: false } - ); - events$ = createEffect( () => { return this.actions$.pipe( @@ -239,7 +219,6 @@ export class Effects { ofType(sendSuccess), tap((action) => { const res = action.res; - console.log('sendSuccess', action); this.store.dispatch( addEvent({ @@ -255,6 +234,29 @@ export class Effects { { dispatch: false } ); + /******************************************************************* + * [Room Action watching.] + *******************************************************************/ + selectedRoomSuccess$ = createEffect( + () => { + return this.actions$.pipe( + ofType(RoomActions.selectedRoomSuccess), + debounceTime(300), + tap((action) => { + const requestCount = this.moduleConfig?.eventRequestInitCount || 50; + const req: InfoRequest = { + roomId: action.roomId, + baseSeq: 0, + requestCount + }; + + this.store.dispatch(events({ req })); + }) + ); + }, + { dispatch: false } + ); + constructor( private actions$: Actions, private store: Store, diff --git a/projects/store-chat/src/lib/store/chatting/reducers.ts b/projects/store-chat/src/lib/store/chatting/reducers.ts index 036c391..6f0a564 100644 --- a/projects/store-chat/src/lib/store/chatting/reducers.ts +++ b/projects/store-chat/src/lib/store/chatting/reducers.ts @@ -9,11 +9,10 @@ import { adapterFileInfoCheckList } from './state'; -import * as roomActions from '../room/actions'; +import * as RoomActions from '../room/actions'; import { eventsSuccess, eventsFailure, - readSuccess, fileInfosSuccess, fileInfosFailure, addEvent @@ -22,24 +21,6 @@ import { export const reducer = createReducer( initialState, - on(roomActions.selectedRoom, (state, action) => { - return { - ...state, - activeRoomId: action.roomId - }; - }), - - on(roomActions.clearSelectedRoom, (state, action) => { - if (action.roomId === state.activeRoomId) { - return { - ...state, - activeRoomId: null - }; - } else { - return state; - } - }), - on(eventsSuccess, (state, action) => { const roomId = action.res.roomId; @@ -188,5 +169,35 @@ export const reducer = createReducer( } else { return state; } + }), + + /******************************************************************* + * [Room Action watching.] + *******************************************************************/ + on(RoomActions.selectedRoomSuccess, (state, action) => { + return { + ...state, + activeRoomId: action.roomId + }; + }), + + on(RoomActions.clearSelectedRoom, (state, action) => { + if (action.roomId === state.activeRoomId) { + return { + ...state, + activeRoomId: null + }; + } else { + return state; + } + }), + + on(RoomActions.close, (state, action) => { + const roomIds = action.roomIds; + + return { + ...state, + chattings: adapterChatting.removeMany(roomIds, { ...state.chattings }) + }; }) ); diff --git a/projects/store-chat/src/lib/store/room/actions.ts b/projects/store-chat/src/lib/store/room/actions.ts index 4e72a6c..d6af7f6 100644 --- a/projects/store-chat/src/lib/store/room/actions.ts +++ b/projects/store-chat/src/lib/store/room/actions.ts @@ -23,7 +23,9 @@ import { ExitForcingResponse, UpdateTimerSetRequest, UpdateTimerSetResponse, - UserInfoShort + UserInfo, + UserInfoShort, + InfoResponse } from '@ucap/protocol-room'; /** @@ -33,6 +35,23 @@ export const selectedRoom = createAction( '[ucap::chat::selectedRoom] selected room', props<{ roomId: string; localeCode: LocaleCode }>() ); +/** + * retrieve selected Room Success. + */ +export const selectedRoomSuccess = createAction( + '[ucap::chat::selectedRoom] selected room validation Success', + props<{ + roomId: string; + roomInfo2Res: { + roomInfo: RoomInfo; + roomUserInfo: { + userInfoList: UserInfo[]; + userInfoShortList: UserInfoShort[]; + }; + res: InfoResponse; + }; + }>() +); /** * clear selected Room. */ @@ -391,7 +410,7 @@ export const updateTimeRoomIntervalFailure = createAction( ); /** - * norification for invited users + * notification for invited users */ export const inviteNotification = createAction( '[ucap::chat::room] invite Notification', @@ -399,9 +418,14 @@ export const inviteNotification = createAction( ); /** - * norification for exited user + * notification for exited user */ export const exitNotification = createAction( '[ucap::chat::room] Exit Notification', props<{ roomId: string; userSeq: string; senderSeq: string }>() ); + +export const updateUnreadCount = createAction( + '[ucap::chat::room] Update unread count', + props<{ roomId: string; noReadCnt?: number }>() +); diff --git a/projects/store-chat/src/lib/store/room/effects.ts b/projects/store-chat/src/lib/store/room/effects.ts index 4326967..053c5f9 100644 --- a/projects/store-chat/src/lib/store/room/effects.ts +++ b/projects/store-chat/src/lib/store/room/effects.ts @@ -31,8 +31,7 @@ import { RoomProtocolService } from '@ucap/ng-protocol-room'; import { SyncProtocolService } from '@ucap/ng-protocol-sync'; import { LoginActions } from '@ucap/ng-store-authentication'; -import { addEventSuccess } from '../Chatting/actions'; - +import * as ChattingAction from '../Chatting/actions'; import { RoomSelector } from '../state'; import { @@ -78,7 +77,9 @@ import { delMultiSuccess, delMultiFailure, selectedRoom, - room2Success + room2Success, + selectedRoomSuccess, + clearSelectedRoom } from './actions'; import { Router } from '@angular/router'; import { LocaleCode } from '@ucap/core'; @@ -104,7 +105,38 @@ export class Effects { }; // retrieve room info - this.store.dispatch(room({ req })); + this.roomProtocolService + .info2(req) + .pipe( + map((res) => { + let isJoinRoom = true; + if (!res.roomInfo || !res.roomInfo.isJoinRoom) { + isJoinRoom = false; + } + + if (!!isJoinRoom) { + this.store.dispatch( + selectedRoomSuccess({ + roomId: req.roomId, + roomInfo2Res: res + }) + ); + } else { + // is not join room. so, redirect chat main. + this.router.navigate([ + 'chat', + { + outlets: { content: 'index' } + } + ]); + this.store.dispatch( + clearSelectedRoom({ roomId: req.roomId }) + ); + } + }), + catchError((error) => of(roomFailure({ error }))) + ) + .subscribe(); // retrieve event info >> chatting.effect.selectedRoom$ }) @@ -113,6 +145,24 @@ export class Effects { { dispatch: false } ); + selectedRoomSuccess$ = createEffect( + () => { + return this.actions$.pipe( + ofType(selectedRoomSuccess), + tap((action) => { + // room info success reduce. + this.store.dispatch( + room2Success({ + roomInfo: action.roomInfo2Res.roomInfo, + roomUserInfo: action.roomInfo2Res.roomUserInfo + }) + ); + }) + ); + }, + { dispatch: false } + ); + rooms$ = createEffect(() => { return this.actions$.pipe( ofType(rooms), @@ -237,7 +287,9 @@ export class Effects { exhaustMap((req) => { return this.roomProtocolService.exit(req).pipe( switchMap((res: DeleteResponse) => [ + // close room, clear chatting close({ roomIds: [res.roomId] }), + // clear room in rooms. delSuccess({ res }) ]), catchError((error) => of(delFailure({ error }))) @@ -253,7 +305,9 @@ export class Effects { exhaustMap((req) => { return this.roomProtocolService.exitAll(req).pipe( switchMap((res: DeleteMultiResponse) => [ + // close room, clear chatting close({ roomIds: res.roomIds }), + // clear room in rooms. delMultiSuccess({ res }) ]), catchError((error) => of(delMultiFailure({ error }))) @@ -430,7 +484,7 @@ export class Effects { addEventSuccess$ = createEffect( () => { return this.actions$.pipe( - ofType(addEventSuccess), + ofType(ChattingAction.addEventSuccess), withLatestFrom(this.store.pipe(select(RoomSelector.rooms))), map(([action, roomList]) => { const roomId = action.roomId; diff --git a/projects/store-chat/src/lib/store/room/reducers.ts b/projects/store-chat/src/lib/store/room/reducers.ts index b9d7663..fc59df7 100644 --- a/projects/store-chat/src/lib/store/room/reducers.ts +++ b/projects/store-chat/src/lib/store/room/reducers.ts @@ -26,7 +26,8 @@ import { delMultiSuccess, updateSuccess, room2Success, - createSuccess + createSuccess, + updateUnreadCount } from './actions'; import { Info, EventJson } from '@ucap/protocol-event'; import { ChatUtil } from '../../utils/chat.util'; @@ -53,7 +54,6 @@ export const reducer = createReducer( const value = state.rooms.entities[key]; unreadTotal += isNaN(value.noReadCnt) ? 0 : value.noReadCnt; } - action.roomList.map((item) => (unreadTotal += item.noReadCnt)); return { ...state, @@ -324,6 +324,32 @@ export const reducer = createReducer( }; }), + on(updateUnreadCount, (state, action) => { + const roomId = action.roomId; + const noReadCnt = action.noReadCnt || 0; + const roomInfo = state.rooms.entities[roomId]; + + let unreadTotal = 0; + // tslint:disable-next-line: forin + for (const key in state.rooms.entities) { + const value = state.rooms.entities[key]; + unreadTotal += isNaN(value.noReadCnt) ? 0 : value.noReadCnt; + } + + if (!!roomInfo) { + return { + ...state, + rooms: adapterRoom.updateOne( + { id: roomId, changes: { ...roomInfo, noReadCnt } }, + { ...state.rooms } + ), + unreadTotal + }; + } else { + return state; + } + }), + /******************************************************************* * [Chatting Action watching.] *******************************************************************/ diff --git a/projects/ui-chat/package.json b/projects/ui-chat/package.json index 067a90c..6d7f06e 100644 --- a/projects/ui-chat/package.json +++ b/projects/ui-chat/package.json @@ -1,6 +1,6 @@ { "name": "@ucap/ng-ui-chat", - "version": "0.0.12", + "version": "0.0.13", "publishConfig": { "registry": "https://nexus.loafle.net/repository/npm-ucap/" }, diff --git a/projects/ui-chat/src/lib/components/room-expansion.component.ts b/projects/ui-chat/src/lib/components/room-expansion.component.ts index 84af8da..c7d8562 100644 --- a/projects/ui-chat/src/lib/components/room-expansion.component.ts +++ b/projects/ui-chat/src/lib/components/room-expansion.component.ts @@ -90,6 +90,20 @@ export class RoomExpansionComponent implements OnInit, OnDestroy { this.nodeMap.set(item.division, [node]); } } + + // deleted filtering. + this.nodeMap = new Map( + [...this.nodeMap.entries()].filter( + (map) => list.findIndex((item) => item.division === map[0]) > -1 + ) + ); + + // sorting. + this.nodeMap = new Map( + [...this.nodeMap.entries()].sort((a, b) => + b[0] > a[0] ? 1 : b[0] < a[0] ? -1 : 0 + ) + ); } this.refreshNodes(); } diff --git a/projects/ui-organization/package.json b/projects/ui-organization/package.json index 56c6fc9..47d12d5 100644 --- a/projects/ui-organization/package.json +++ b/projects/ui-organization/package.json @@ -1,6 +1,6 @@ { "name": "@ucap/ng-ui-organization", - "version": "0.0.83", + "version": "0.0.84", "publishConfig": { "registry": "https://nexus.loafle.net/repository/npm-ucap/" }, diff --git a/projects/ui-organization/src/lib/components/profile-01.component.html b/projects/ui-organization/src/lib/components/profile-01.component.html index 1ffb2a4..f0150ca 100644 --- a/projects/ui-organization/src/lib/components/profile-01.component.html +++ b/projects/ui-organization/src/lib/components/profile-01.component.html @@ -1,7 +1,48 @@
-
-