From 7cc2160145eaf754389faede3e16218e081858a6 Mon Sep 17 00:00:00 2001 From: khk Date: Mon, 20 Jan 2020 10:01:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/layouts/messenger/components/intro.component.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/intro.component.scss b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/intro.component.scss index 800386ae..aa90f203 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/intro.component.scss +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/intro.component.scss @@ -20,7 +20,6 @@ } .app-title { - margin-top: 1.4em; font-weight: 600; font-size: 2.6em; } From f606f89ded216c1917ea89342cc5e2663506ce2a Mon Sep 17 00:00:00 2001 From: leejinho Date: Mon, 20 Jan 2020 13:25:59 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20intro=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/profile.dialog.component.html | 1 + .../profile/profile.dialog.component.ts | 40 ++++++++++++++--- .../native/components/top-bar.component.html | 3 ++ .../native/components/top-bar.component.ts | 32 +++++-------- .../store/account/authentication/actions.ts | 8 ++++ .../store/account/authentication/reducers.ts | 45 ++++++++++++++----- .../src/app/store/messenger/status/actions.ts | 12 ++++- .../src/app/store/messenger/status/effects.ts | 22 ++++++++- .../src/lib/protocols/status.ts | 4 +- .../src/lib/protocols/user-option.ts | 16 +++---- .../src/lib/protocols/user.ts | 1 - .../src/lib/components/profile.component.html | 27 ++++++++++- .../src/lib/components/profile.component.ts | 6 +++ 13 files changed, 162 insertions(+), 55 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.html index bce9f24d..afeedb1c 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.html @@ -16,5 +16,6 @@ (toggleFavorit)="onClickToggleFavorit($event)" (toggleBuddy)="onClickToggleBuddy($event)" (uploadProfileImage)="onUploadProfileImage($event)" + (updateIntro)="onUpdateIntro($event)" > diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.ts index 2a3681ac..cfa3e5a8 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.ts @@ -28,7 +28,7 @@ import { } from '@ucap-webmessenger/ui'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; -import { map, take, finalize, catchError } from 'rxjs/operators'; +import { map, take, finalize, catchError, tap } from 'rxjs/operators'; import { Subscription, of } from 'rxjs'; import { SelectGroupDialogComponent, @@ -54,6 +54,7 @@ import { SmsUtils } from '@ucap-webmessenger/daesang'; import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native'; import { environment } from '../../../../../environments/environment'; import { TranslateService } from '@ngx-translate/core'; +import { UserInfoUpdateType } from '@ucap-webmessenger/protocol-info'; export interface ProfileDialogData { userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN; @@ -70,6 +71,7 @@ export interface ProfileDialogResult {} export class ProfileDialogComponent implements OnInit, OnDestroy { userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN; loginRes: LoginResponse; + loginResSubscription: Subscription; sessionVerinfo: VersionInfo2Response; environmentsInfo: EnvironmentsInfo; authInfo: AuthResponse; @@ -99,9 +101,6 @@ export class ProfileDialogComponent implements OnInit, OnDestroy { this.sessionVerinfo = this.sessionStorageService.get( KEY_VER_INFO ); - this.loginRes = this.sessionStorageService.get( - KEY_LOGIN_RES_INFO - ); this.environmentsInfo = this.sessionStorageService.get( KEY_ENVIRONMENTS_INFO ); @@ -114,7 +113,24 @@ export class ProfileDialogComponent implements OnInit, OnDestroy { } ngOnInit() { - this.isMe = this.loginRes.userSeq === this.data.userInfo.seq; + this.loginResSubscription = this.store + .pipe( + select(AppStore.AccountSelector.AuthenticationSelector.loginRes), + tap(loginRes => { + this.loginRes = loginRes; + if (loginRes.userSeq === this.data.userInfo.seq) { + this.isMe = true; + this.userInfo = { + ...this.userInfo, + intro: loginRes.userInfo.intro + }; + } else { + this.isMe = false; + } + 1; + }) + ) + .subscribe(); this.selectAllBuddy2Subscription = this.store .pipe( @@ -145,6 +161,9 @@ export class ProfileDialogComponent implements OnInit, OnDestroy { if (!!this.myDeptUserListSubscription) { this.myDeptUserListSubscription.unsubscribe(); } + if (!!this.loginResSubscription) { + this.loginResSubscription.unsubscribe(); + } } getCheckMyDeptUser() { @@ -433,4 +452,15 @@ export class ProfileDialogComponent implements OnInit, OnDestroy { } ); } + + onUpdateIntro(intro: string) { + this.store.dispatch( + AuthenticationStore.infoUser({ + req: { + type: UserInfoUpdateType.Intro, + info: intro + } + }) + ); + } } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html index 4bdc69e7..64a1a0f5 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html @@ -358,6 +358,7 @@ matInput #statusMessage1 type="text" + maxlength="5" [value]="loginRes?.statusMessage1" (click)="$event.stopPropagation()" @@ -383,6 +384,7 @@ matInput #statusMessage2 type="text" + maxlength="5" [value]="loginRes?.statusMessage2" (click)="$event.stopPropagation()" /> @@ -407,6 +409,7 @@ matInput #statusMessage3 type="text" + maxlength="5" [value]="loginRes?.statusMessage3" (click)="$event.stopPropagation()" /> diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts index 0160fc74..e6c4cce3 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts @@ -58,8 +58,11 @@ import { DialogService } from '@ucap-webmessenger/ui'; import { DOCUMENT } from '@angular/common'; import { MatMenu, MatRadioChange } from '@angular/material'; import { StatusCode, StatusType } from '@ucap-webmessenger/core'; -import { StatusInfo } from '@ucap-webmessenger/protocol-status'; -import { UserInfoUpdateType } from '@ucap-webmessenger/protocol-info'; +import { + StatusInfo, + MessageIndexType, + MessageUpdateRequest +} from '@ucap-webmessenger/protocol-status'; const zoomFactors = [60, 70, 85, 100, 120, 145, 170, 200]; @@ -462,29 +465,14 @@ export class TopBarComponent implements OnInit, OnDestroy { ); } - onApplyStatusMessage(index: number, statusMessage: string) { + onApplyStatusMessage(index: MessageIndexType, statusMessage: string) { this.logger.debug('StatusMessage', index, statusMessage); - let updateType: UserInfoUpdateType; - switch (index) { - case 1: - updateType = UserInfoUpdateType.StatusMessage1; - break; - case 2: - updateType = UserInfoUpdateType.StatusMessage2; - break; - case 3: - updateType = UserInfoUpdateType.StatusMessage3; - break; - - default: - return; - } - this.store.dispatch( - AuthenticationStore.infoUser({ - req: { type: updateType, info: statusMessage } - }) + StatusStore.messageUpdate({ + index, + statusMessage + } as MessageUpdateRequest) ); } diff --git a/projects/ucap-webmessenger-app/src/app/store/account/authentication/actions.ts b/projects/ucap-webmessenger-app/src/app/store/account/authentication/actions.ts index cd3a61d6..fc728bb2 100644 --- a/projects/ucap-webmessenger-app/src/app/store/account/authentication/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/account/authentication/actions.ts @@ -9,6 +9,7 @@ import { UserPasswordSetResponse } from '@ucap-webmessenger/protocol-service'; import { UserRequest, UserResponse } from '@ucap-webmessenger/protocol-info'; +import { MessageUpdateResponse } from '@ucap-webmessenger/protocol-status'; export const webLogin = createAction( '[Account::Authentication] Web Login', @@ -140,3 +141,10 @@ export const infoUserFailure = createAction( '[Account::Authentication] Info User Failure', props<{ error: any }>() ); + +export const updateStatusMessageSuccess = createAction( + '[Account::Authentication] Status message update Success', + props<{ + res: MessageUpdateResponse; + }>() +); diff --git a/projects/ucap-webmessenger-app/src/app/store/account/authentication/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/account/authentication/reducers.ts index 7429a773..e6da2782 100644 --- a/projects/ucap-webmessenger-app/src/app/store/account/authentication/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/account/authentication/reducers.ts @@ -1,15 +1,16 @@ -import { Action, combineReducers, createReducer, on } from '@ngrx/store'; -import { State, initialState } from './state'; +import { createReducer, on } from '@ngrx/store'; +import { initialState } from './state'; import { loginSuccess, increaseLoginFailCount, initialLoginFailCount, - logout, logoutInitialize, updateLoginRes, - infoUserSuccess + infoUserSuccess, + updateStatusMessageSuccess } from './actions'; import { UserInfoUpdateType } from '@ucap-webmessenger/protocol-info'; +import { MessageIndexType } from '@ucap-webmessenger/protocol-status'; export const reducer = createReducer( initialState, @@ -54,7 +55,11 @@ export const reducer = createReducer( break; case UserInfoUpdateType.Intro: loginRes = { - ...loginRes + ...loginRes, + userInfo: { + ...loginRes.userInfo, + intro: action.res.info + } }; break; case UserInfoUpdateType.TelephoneVisible: @@ -62,22 +67,40 @@ export const reducer = createReducer( ...loginRes }; break; - case UserInfoUpdateType.StatusMessage1: + default: + break; + } + + return { + ...state, + loginRes: { + ...loginRes + } + }; + }), + + on(updateStatusMessageSuccess, (state, action) => { + let loginRes = { + ...state.loginRes + }; + + switch (action.res.index) { + case MessageIndexType.First: loginRes = { ...loginRes, - statusMessage1: action.res.info + statusMessage1: action.res.statusMessage }; break; - case UserInfoUpdateType.StatusMessage2: + case MessageIndexType.Second: loginRes = { ...loginRes, - statusMessage2: action.res.info + statusMessage2: action.res.statusMessage }; break; - case UserInfoUpdateType.StatusMessage3: + case MessageIndexType.Third: loginRes = { ...loginRes, - statusMessage3: action.res.info + statusMessage3: action.res.statusMessage }; break; default: diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/status/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/status/actions.ts index 31b6ac56..96879379 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/status/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/status/actions.ts @@ -4,7 +4,8 @@ import { StatusBulkInfo, StatusNotification, StatusRequest, - StatusResponse + StatusResponse, + MessageUpdateRequest } from '@ucap-webmessenger/protocol-status'; export const bulkInfo = createAction( @@ -46,3 +47,12 @@ export const changeMyIdleCheckTime = createAction( '[Messenger::Status] Change MyIdleCheckTime', props<{ checkTime: number }>() ); + +export const messageUpdate = createAction( + '[Messenger::Status] status message update of Others', + props() +); +export const messageUpdateFailure = createAction( + '[Messenger::Status] status message update of Others Failure', + props<{ error: any }>() +); diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/status/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/status/effects.ts index 6b6fdb80..de6c1509 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/status/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/status/effects.ts @@ -6,13 +6,16 @@ import { Store } from '@ngrx/store'; import { NGXLogger } from 'ngx-logger'; import * as SyncStore from '@app/store/messenger/sync'; +import * as AuthStore from '@app/store/account/authentication'; import { bulkInfo, bulkInfoSuccess, bulkInfoFailure, status, statusFailure, - statusSuccess + statusSuccess, + messageUpdate, + messageUpdateFailure } from './actions'; import { tap, switchMap, map, catchError, exhaustMap } from 'rxjs/operators'; import { @@ -21,7 +24,8 @@ import { SSVC_TYPE_STATUS_BULK_INFO_RES, BulkInfoData, StatusBulkInfo, - StatusResponse + StatusResponse, + MessageUpdateResponse } from '@ucap-webmessenger/protocol-status'; import { of } from 'rxjs'; @@ -102,6 +106,20 @@ export class Effects { ) ); + messageUpdate$ = createEffect(() => + this.actions$.pipe( + ofType(messageUpdate), + exhaustMap(action => { + return this.statusProtocolService.messageUpdate(action).pipe( + map((res: MessageUpdateResponse) => { + return AuthStore.updateStatusMessageSuccess({ res }); + }), + catchError(error => of(messageUpdateFailure({ error }))) + ); + }) + ) + ); + constructor( private actions$: Actions, private store: Store, diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/protocols/status.ts b/projects/ucap-webmessenger-protocol-info/src/lib/protocols/status.ts index c293671a..f75650a4 100644 --- a/projects/ucap-webmessenger-protocol-info/src/lib/protocols/status.ts +++ b/projects/ucap-webmessenger-protocol-info/src/lib/protocols/status.ts @@ -1,4 +1,4 @@ -import { DeviceType, LocaleCode, StatusCode } from '@ucap-webmessenger/core'; +import { StatusCode } from '@ucap-webmessenger/core'; import { ProtocolRequest, ProtocolResponse, @@ -7,11 +7,9 @@ import { PacketBodyValue, ProtocolDecoder, ProtocolMessage, - ProtocolNotification, BodyStringDivider, decodeProtocolMessage } from '@ucap-webmessenger/protocol'; -import { UserInfoUpdateType } from '../types/user-info-update.type'; import { StatusInfo } from '@ucap-webmessenger/protocol-status'; export interface StatusRequest extends ProtocolRequest { diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/protocols/user-option.ts b/projects/ucap-webmessenger-protocol-info/src/lib/protocols/user-option.ts index 488a87da..71c7bd04 100644 --- a/projects/ucap-webmessenger-protocol-info/src/lib/protocols/user-option.ts +++ b/projects/ucap-webmessenger-protocol-info/src/lib/protocols/user-option.ts @@ -1,4 +1,4 @@ -import { DeviceType, LocaleCode, CallerType } from '@ucap-webmessenger/core'; +import { CallerType } from '@ucap-webmessenger/core'; import { ProtocolRequest, ProtocolResponse, @@ -7,10 +7,8 @@ import { PacketBodyValue, ProtocolDecoder, ProtocolMessage, - ProtocolNotification, decodeProtocolMessage } from '@ucap-webmessenger/protocol'; -import { UserInfoUpdateType } from '../types/user-info-update.type'; export interface UserOptionResponse extends ProtocolResponse { // 타입(s) @@ -33,18 +31,18 @@ export interface UserOptionUpdateResponse extends ProtocolResponse { type: CallerType; } -export const encodeUserOptionUpdate: ProtocolEncoder< - UserOptionUpdateRequest -> = (req: UserOptionUpdateRequest) => { +export const encodeUserOptionUpdate: ProtocolEncoder = ( + req: UserOptionUpdateRequest +) => { const bodyList: PacketBody[] = []; bodyList.push({ type: PacketBodyValue.String, value: req.type }); return bodyList; }; -export const decodeUserOptionUpdate: ProtocolDecoder< - UserOptionUpdateResponse -> = (message: ProtocolMessage) => { +export const decodeUserOptionUpdate: ProtocolDecoder = ( + message: ProtocolMessage +) => { return decodeProtocolMessage(message, { type: message.bodyList[0] as CallerType } as UserOptionUpdateResponse); diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/protocols/user.ts b/projects/ucap-webmessenger-protocol-info/src/lib/protocols/user.ts index 156fa4b7..589f800e 100644 --- a/projects/ucap-webmessenger-protocol-info/src/lib/protocols/user.ts +++ b/projects/ucap-webmessenger-protocol-info/src/lib/protocols/user.ts @@ -1,4 +1,3 @@ -import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; import { ProtocolRequest, ProtocolResponse, diff --git a/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.html b/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.html index 3f58ac48..5effde68 100644 --- a/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.html +++ b/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.html @@ -63,7 +63,32 @@ {{ userInfo | ucapTranslate: 'grade' }} -
{{ userInfo.intro }}
+
+ + {{ userInfo.intro }} + + + + {{ userInfo.intro }} + + + +
diff --git a/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.ts b/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.ts index 1e7c984d..23876e54 100644 --- a/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.ts +++ b/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.ts @@ -66,6 +66,8 @@ export class ProfileComponent implements OnInit { @Output() uploadProfileImage = new EventEmitter(); + @Output() + updateIntro = new EventEmitter(); @ViewChild('profileImageFileInput', { static: false }) profileImageFileInput: ElementRef; @@ -129,6 +131,10 @@ export class ProfileComponent implements OnInit { }); } + onApplyIntroMessage(intro: string) { + this.updateIntro.emit(intro); + } + onChangeFileInput() { this.profileImageFileUploadItem = FileUploadItem.fromFiles( this.profileImageFileInput.nativeElement.files