From b49a8313a9e95bf2c8fa085d6aba3f34e479d94e Mon Sep 17 00:00:00 2001 From: leejh Date: Fri, 11 Oct 2019 18:01:39 +0900 Subject: [PATCH 1/4] save LOGIN_RES info in sessionstorage --- .../src/app/resolvers/messenger.resolver.ts | 6 ++++++ .../src/app/types/login-res-info.type.ts | 1 + 2 files changed, 7 insertions(+) create mode 100644 projects/ucap-webmessenger-app/src/app/types/login-res-info.type.ts diff --git a/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts b/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts index fccc317b..804b1cb8 100644 --- a/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts +++ b/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts @@ -45,6 +45,7 @@ import * as OptionStore from '@app/store/messenger/option'; import * as QueryStore from '@app/store/messenger/query'; import * as SyncStore from '@app/store/messenger/sync'; import { VerInfo2, KEY_VER_INFO } from '@app/types/ver-info.type'; +import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; @Injectable() export class AppMessengerResolver implements Resolve { @@ -114,6 +115,11 @@ export class AppMessengerResolver implements Resolve { }), switchMap(res => { loginRes = res; + + this.sessionStorageService.set(KEY_LOGIN_RES_INFO, { + ...loginRes + }); + return forkJoin([ this.queryProtocolService.auth({ deviceType: environmentsInfo.deviceType diff --git a/projects/ucap-webmessenger-app/src/app/types/login-res-info.type.ts b/projects/ucap-webmessenger-app/src/app/types/login-res-info.type.ts new file mode 100644 index 00000000..e144ec64 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/types/login-res-info.type.ts @@ -0,0 +1 @@ +export const KEY_LOGIN_RES_INFO = 'ucap::LOGIN_RES_INFO'; From 06ffd4e2138ca5f78d3333425916d46834b1f337 Mon Sep 17 00:00:00 2001 From: leejh Date: Fri, 11 Oct 2019 18:02:27 +0900 Subject: [PATCH 2/4] bug fix --- .../src/lib/components/messages.component.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts index 797d512e..391b45d9 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts @@ -36,20 +36,24 @@ export class MessagesComponent implements OnInit { } getUserName(seq: number): string { - const userInfo: UserInfo[] = this.userInfos.filter( - user => user.seq === seq - ); - if (!!userInfo && userInfo.length > 0) { - return userInfo[0].name; + if (!!this.userInfos) { + const userInfo: UserInfo[] = this.userInfos.filter( + user => user.seq === seq + ); + if (!!userInfo && userInfo.length > 0) { + return userInfo[0].name; + } } return '(알수없는 사용자)'; } getUserProfile(seq: number): string { - const userInfo: UserInfo[] = this.userInfos.filter( - user => user.seq === seq - ); - if (!!userInfo && userInfo.length > 0) { - return this.profileImageRoot + userInfo[0].profileImageFile; + if (!!this.userInfos) { + const userInfo: UserInfo[] = this.userInfos.filter( + user => user.seq === seq + ); + if (!!userInfo && userInfo.length > 0) { + return this.profileImageRoot + userInfo[0].profileImageFile; + } } return ''; } From 5ccb2b41b5a096db82f5a125068ee63f20c4d832 Mon Sep 17 00:00:00 2001 From: leejh Date: Fri, 11 Oct 2019 18:03:01 +0900 Subject: [PATCH 3/4] mass text component modify --- .../src/lib/apis/mass-talk-download.ts | 25 +++++-- .../components/messages.component.html | 3 +- .../components/messages.component.ts | 10 +++ .../src/app/store/messenger/chat/actions.ts | 21 ++++++ .../src/app/store/messenger/chat/effects.ts | 74 ++++++++++++++++++- .../src/app/store/messenger/chat/reducers.ts | 34 ++++++++- .../src/app/store/messenger/chat/state.ts | 11 ++- .../message-box/file.component.html | 3 + .../message-box/mass.component.html | 6 +- .../components/message-box/mass.component.ts | 47 +++++++++++- .../lib/components/messages.component.html | 4 +- .../src/lib/components/messages.component.ts | 9 ++- .../src/lib/ucap-ui-chat.module.ts | 4 +- 13 files changed, 232 insertions(+), 19 deletions(-) diff --git a/projects/ucap-webmessenger-api-common/src/lib/apis/mass-talk-download.ts b/projects/ucap-webmessenger-api-common/src/lib/apis/mass-talk-download.ts index ec31ac3f..cfbdc407 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/apis/mass-talk-download.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/apis/mass-talk-download.ts @@ -8,19 +8,24 @@ import { } from '@ucap-webmessenger/api'; export interface MassTalkDownloadRequest extends APIRequest { - userSeq: string; + userSeq: number; deviceType: DeviceType; token: string; - eventMassSeq?: string; + eventMassSeq?: number; } export interface MassTalkDownloadResponse extends APIResponse { - Content?: string; - UserName?: string; - RegDate?: string; + content?: string; + userName?: string; + regDate?: string; } -const massTalkDownloadEncodeMap = {}; +const massTalkDownloadEncodeMap = { + userSeq: 'p_user_seq', + deviceType: 'p_device_type', + token: 'p_token', + eventMassSeq: 'p_event_mass_seq' +}; export const encodeMassTalkDownload: APIEncoder = ( req: MassTalkDownloadRequest @@ -31,5 +36,11 @@ export const encodeMassTalkDownload: APIEncoder = ( export const decodeMassTalkDownload: APIDecoder = ( res: any ) => { - return {} as MassTalkDownloadResponse; + return { + statusCode: res.StatusCode, + errorMessage: res.ErrorMessage, + content: res.Content, + userName: res.UserName, + regDate: res.RegDate + } as MassTalkDownloadResponse; }; 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 c2cf30a0..d997c05f 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 @@ -29,7 +29,8 @@
- +
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 25deb750..fb1ac7ba 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 @@ -14,6 +14,7 @@ import { Info, EventType } from '@ucap-webmessenger/protocol-event'; import * as AppStore from '@app/store'; import * as EventStore from '@app/store/messenger/event'; +import * as ChatStore from '@app/store/messenger/chat'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; @@ -113,4 +114,13 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked { this.messageBoxContainer.nativeElement.scrollTop = this.messageBoxContainer.nativeElement.scrollHeight; } catch (err) {} } + + /** MassText Detail View */ + onMassDetail(value: number) { + this.store.dispatch( + ChatStore.selectedMassDetail({ + massEventSeq: value + }) + ); + } } diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts index 0c806b39..7ca32baa 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts @@ -1,5 +1,9 @@ import { createAction, props } from '@ngrx/store'; import { Info } from '@ucap-webmessenger/protocol-event'; +import { + MassTalkDownloadRequest, + MassTalkDownloadResponse +} from '@ucap-webmessenger/api-common'; export const selectedRoom = createAction( '[Messenger::Chat] selectedRoom', @@ -13,3 +17,20 @@ export const newEventMessage = createAction( info: Info; }>() ); + +export const selectedMassDetail = createAction( + '[Messenger::Chat] selectedMassDetail', + props<{ massEventSeq: number }>() +); +export const massTalkDownload = createAction( + '[Messenger::Chat] massTalkDownload', + props() +); +export const massTalkDownloadSuccess = createAction( + '[Messenger::Chat] massTalkDownload Success', + props() +); +export const massTalkDownloadFailure = createAction( + '[Messenger::Chat] massTalkDownload Failure', + props<{ error: any }>() +); diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/effects.ts index 511eba9c..34378161 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/effects.ts @@ -1,15 +1,85 @@ -import { Injectable } from '@angular/core'; +import { Injectable, Inject } from '@angular/core'; -import { Actions } from '@ngrx/effects'; +import { Actions, ofType, createEffect } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { NGXLogger } from 'ngx-logger'; +import { catchError, exhaustMap, map, tap, switchMap } from 'rxjs/operators'; +import { + selectedMassDetail, + massTalkDownload, + massTalkDownloadFailure, + massTalkDownloadSuccess +} from './actions'; +import { Login2Response } from '@ucap-webmessenger/pi'; +import { + webLoginFailure, + webLoginSuccess +} from '@app/store/account/authentication'; +import { of } from 'rxjs'; +import { PublicApiService } from '@ucap-webmessenger/api-public'; +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; +import { StatusCode } from '@ucap-webmessenger/api'; +import { + CommonApiService, + MassTalkDownloadRequest +} from '@ucap-webmessenger/api-common'; +import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; +import { EnvironmentsInfo, KEY_ENVIRONMENTS_INFO } from '@app/types'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; @Injectable() export class Effects { + selectedMassDetail$ = createEffect(() => + this.actions$.pipe( + ofType(selectedMassDetail), + map(action => { + const loginResInfo: LoginResponse = this.sessionStorageService.get< + LoginResponse + >(KEY_LOGIN_RES_INFO); + + const environmentsInfo = this.sessionStorageService.get< + EnvironmentsInfo + >(KEY_ENVIRONMENTS_INFO); + + return massTalkDownload({ + userSeq: loginResInfo.userSeq, + deviceType: environmentsInfo.deviceType, + eventMassSeq: Number(action.massEventSeq), + token: loginResInfo.tokenString + }); + }) + ) + ); + + massTalkDownload$ = createEffect( + () => { + return this.actions$.pipe( + ofType(massTalkDownload), + map(action => action), + exhaustMap(req => { + return this.commonApiService.massTalkDownload(req).pipe( + map(res => { + this.logger.debug(res); + if (res.statusCode === StatusCode.Success) { + this.store.dispatch(massTalkDownloadSuccess(res)); + } else { + this.store.dispatch(massTalkDownloadFailure({ error: res })); + } + }), + catchError(error => of(massTalkDownloadFailure({ error }))) + ); + }) + ); + }, + { dispatch: false } + ); + constructor( private actions$: Actions, + private commonApiService: CommonApiService, + private sessionStorageService: SessionStorageService, private store: Store, private logger: NGXLogger ) {} diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/reducers.ts index c2ba4566..cd779437 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/reducers.ts @@ -1,6 +1,12 @@ import { createReducer, on } from '@ngrx/store'; import { initialState } from './state'; -import { selectedRoom } from './actions'; +import { + selectedRoom, + selectedMassDetail, + massTalkDownloadFailure, + massTalkDownload, + massTalkDownloadSuccess +} from './actions'; export const reducer = createReducer( initialState, @@ -9,5 +15,31 @@ export const reducer = createReducer( ...state, selectedRoom: action.roomSeq }; + }), + + on(selectedMassDetail, (state, action) => { + return { + ...state, + selectedMassDetail: action.massEventSeq + }; + }), + + on(massTalkDownload, (state, action) => { + return { + ...state, + massDetailProcessing: true + }; + }), + on(massTalkDownloadSuccess, (state, action) => { + return { + ...state, + massDetailProcessing: false + }; + }), + on(massTalkDownloadFailure, (state, action) => { + return { + ...state, + massDetailProcessing: false + }; }) ); diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/state.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/state.ts index 24114eb8..42bd9edd 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/state.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/state.ts @@ -2,10 +2,15 @@ import { Selector, createSelector } from '@ngrx/store'; export interface State { selectedRoom: string | null; + + selectedMassDetail: number | null; + massDetailProcessing: boolean; } export const initialState: State = { - selectedRoom: null + selectedRoom: null, + selectedMassDetail: null, + massDetailProcessing: false }; export function selectors(selector: Selector) { @@ -13,6 +18,10 @@ export function selectors(selector: Selector) { selectedRoom: createSelector( selector, (state: State) => state.selectedRoom + ), + selectedMassDetail: createSelector( + selector, + (state: State) => state.selectedMassDetail ) }; } diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/file.component.html b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/file.component.html index e69de29b..316cf00d 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/file.component.html +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/file.component.html @@ -0,0 +1,3 @@ +

+ file +

diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass.component.html b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass.component.html index 04a3f68e..2608e1df 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass.component.html +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass.component.html @@ -1,8 +1,12 @@

- {{ message.sentMessage }} + {{ content }} {{ message.sendDate | date: 'short' }} + {{detailButteonShow}} + + +

diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass.component.ts index ce58dbd1..bab0cd82 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/message-box/mass.component.ts @@ -1,5 +1,7 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Info } from '@ucap-webmessenger/protocol-event'; +import { NGXLogger } from 'ngx-logger'; +import { StatusCode } from '@ucap-webmessenger/api'; @Component({ selector: 'ucap-chat-message-box-mass', @@ -10,7 +12,46 @@ export class MassComponent implements OnInit { @Input() message: Info; - constructor() {} + @Output() + massDetail = new EventEmitter(); - ngOnInit() {} + content: string; + eventMassSeq: number; + detailButteonShow = true; + + constructor(private logger: NGXLogger) {} + + ngOnInit() { + try { + const contentJson: MassTextInfo = JSON.parse(this.message.sentMessage); + if (contentJson.StatusCode === StatusCode.Success) { + this.content = contentJson.Content; + } else { + this.content = contentJson.ErrorMessage || '[Error] System Error!!'; + this.detailButteonShow = false; + } + + if (!!contentJson.EventMassSeq) { + this.eventMassSeq = contentJson.EventMassSeq; + } else { + this.detailButteonShow = false; + } + } catch (e) { + this.logger.error(e); + this.detailButteonShow = false; + } + } + + onClickDetailView() { + this.massDetail.emit(this.eventMassSeq); + } +} + +export interface MassTextInfo { + StatusCode?: StatusCode; + ErrorMessage?: string; + EventMassSeq?: number; + RoomID?: string; + RegDate?: Date; + Content?: string; } 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 261e2898..c3602fc1 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 @@ -17,7 +17,9 @@ - + +
Join
date splitter diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts index 391b45d9..d4706472 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core'; import { Info, EventType } from '@ucap-webmessenger/protocol-event'; import { @@ -22,6 +22,9 @@ export class MessagesComponent implements OnInit { @Input() userInfos?: UserInfo[]; + @Output() + massDetail = new EventEmitter(); + EventType = EventType; profileImageRoot: string; @@ -57,4 +60,8 @@ export class MessagesComponent implements OnInit { } return ''; } + + onMassDetail(value: number) { + this.massDetail.emit(value); + } } diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/ucap-ui-chat.module.ts b/projects/ucap-webmessenger-ui-chat/src/lib/ucap-ui-chat.module.ts index cb60c251..d4af1d81 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/ucap-ui-chat.module.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/ucap-ui-chat.module.ts @@ -7,6 +7,7 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; +import { MatButtonModule } from '@angular/material/button'; import { FormComponent } from './components/form.component'; import { MessagesComponent } from './components/messages.component'; @@ -55,7 +56,8 @@ const SERVICES = []; FlexLayoutModule, MatFormFieldModule, MatIconModule, - MatInputModule + MatInputModule, + MatButtonModule ], exports: [...COMPONENTS], declarations: [...COMPONENTS] From ed7e47246435c3af458f81b35c298823000b746e Mon Sep 17 00:00:00 2001 From: leejh Date: Fri, 11 Oct 2019 18:18:58 +0900 Subject: [PATCH 4/4] unused code delete --- .../src/app/store/messenger/chat/effects.ts | 11 +---------- .../src/lib/components/expansion-panel.component.ts | 7 ------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/effects.ts index 34378161..3be25ffa 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/effects.ts @@ -12,19 +12,10 @@ import { massTalkDownloadFailure, massTalkDownloadSuccess } from './actions'; -import { Login2Response } from '@ucap-webmessenger/pi'; -import { - webLoginFailure, - webLoginSuccess -} from '@app/store/account/authentication'; import { of } from 'rxjs'; -import { PublicApiService } from '@ucap-webmessenger/api-public'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { StatusCode } from '@ucap-webmessenger/api'; -import { - CommonApiService, - MassTalkDownloadRequest -} from '@ucap-webmessenger/api-common'; +import { CommonApiService } from '@ucap-webmessenger/api-common'; import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; import { EnvironmentsInfo, KEY_ENVIRONMENTS_INFO } from '@app/types'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; diff --git a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts index d5de689d..d9b43202 100644 --- a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts +++ b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts @@ -28,9 +28,6 @@ export class ExpansionPanelComponent implements OnInit { @Input() favoritBuddyList: UserInfo[]; - @Output() - selectBuddy = new EventEmitter(); - @ContentChild(ExpansionPanelItemDirective, { read: TemplateRef, static: true @@ -43,10 +40,6 @@ export class ExpansionPanelComponent implements OnInit { ngOnInit() {} - onClickBuddy(buddy: UserInfo) { - this.selectBuddy.emit(buddy); - } - expandMore() { this.groupAccordion.openAll(); }