receive alarm is implemented

This commit is contained in:
병준 박 2019-10-11 15:55:27 +09:00
parent 37691a565f
commit 9b0106a4be
12 changed files with 183 additions and 43 deletions

View File

@ -5,14 +5,37 @@
<div fxFlex fxLayout="row" fxLayoutAlign="space-between center"> <div fxFlex fxLayout="row" fxLayoutAlign="space-between center">
<div fxLayout="row" fxLayoutAlign="start center"> <div fxLayout="row" fxLayoutAlign="start center">
<!-- RESPONSIVE CHATS BUTTON--> <!-- RESPONSIVE CHATS BUTTON-->
<button mat-icon-button aria-label="chats button" fxHide.gt-md class="responsive-chats-button"> <button
mat-icon-button
aria-label="chats button"
fxHide.gt-md
class="responsive-chats-button"
>
<mat-icon>chat</mat-icon> <mat-icon>chat</mat-icon>
</button> </button>
<!-- / RESPONSIVE CHATS BUTTON--> <!-- / RESPONSIVE CHATS BUTTON-->
</div> </div>
<div> <div>
<button mat-icon-button [matMenuTriggerFor]="contactMenu" aria-label="more"> <button
*ngIf="!!roomInfo"
mat-icon-button
(click)="onClickReceiveAlarm($event)"
aria-label="Toggle Receive Alarm"
>
<mat-icon class="amber-fg" *ngIf="roomInfo.receiveAlarm"
>notifications_active</mat-icon
>
<mat-icon class="secondary-text" *ngIf="!roomInfo.receiveAlarm"
>notifications_off</mat-icon
>
</button>
<button
mat-icon-button
[matMenuTriggerFor]="contactMenu"
aria-label="more"
>
<mat-icon>more_vert</mat-icon> <mat-icon>more_vert</mat-icon>
</button> </button>
@ -25,11 +48,18 @@
</div> </div>
</mat-toolbar> </mat-toolbar>
<!-- / CHAT TOOLBAR --> <!-- / CHAT TOOLBAR -->
<mat-progress-bar *ngIf="eventListProcessing$ | async" mode="indeterminate"></mat-progress-bar> <mat-progress-bar
*ngIf="eventListProcessing$ | async"
mode="indeterminate"
></mat-progress-bar>
<!-- CHAT CONTENT --> <!-- CHAT CONTENT -->
<div fxFlex="1 1 auto" class="chat-content" #messageBoxContainer> <div fxFlex="1 1 auto" class="chat-content" #messageBoxContainer>
<!-- CHAT MESSAGES --> <!-- CHAT MESSAGES -->
<ucap-chat-messages [messages]="eventList$ | async" [userInfos]="userInfoList$ | async" [loginRes]="loginRes"> <ucap-chat-messages
[messages]="eventList$ | async"
[userInfos]="userInfoList$ | async"
[loginRes]="loginRes"
>
</ucap-chat-messages> </ucap-chat-messages>
<!-- CHAT MESSAGES --> <!-- CHAT MESSAGES -->
</div> </div>

View File

@ -14,6 +14,7 @@ import { Info, EventType } from '@ucap-webmessenger/protocol-event';
import * as AppStore from '@app/store'; import * as AppStore from '@app/store';
import * as EventStore from '@app/store/messenger/event'; import * as EventStore from '@app/store/messenger/event';
import * as RoomStore from '@app/store/messenger/room';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
@ -108,6 +109,10 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
); );
} }
onClickReceiveAlarm() {
this.store.dispatch(RoomStore.updateOnlyAlarm({ roomInfo: this.roomInfo }));
}
private scrollToBottomForMessageBoxContainer(): void { private scrollToBottomForMessageBoxContainer(): void {
try { try {
this.messageBoxContainer.nativeElement.scrollTop = this.messageBoxContainer.nativeElement.scrollHeight; this.messageBoxContainer.nativeElement.scrollTop = this.messageBoxContainer.nativeElement.scrollHeight;

View File

@ -106,7 +106,7 @@ const roomInfo: RoomInfo = {
finalEventDate: '2019-09-30 13:57:06', finalEventDate: '2019-09-30 13:57:06',
joinUserCount: 2, joinUserCount: 2,
noReadCnt: 0, noReadCnt: 0,
isAlarm: true, receiveAlarm: true,
isJoinRoom: true, isJoinRoom: true,
expiredFileStdSeq: 0, expiredFileStdSeq: 0,
isTimeRoom: true, isTimeRoom: true,

View File

@ -7,7 +7,9 @@ import {
InviteNotification, InviteNotification,
ExitNotification, ExitNotification,
ExitForcingNotification, ExitForcingNotification,
UpdateFontNotification UpdateFontNotification,
UpdateResponse,
UpdateRequest
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
export const info = createAction( export const info = createAction(
@ -48,3 +50,25 @@ export const updateFontNotification = createAction(
'[Messenger::Room] Update Font Notification', '[Messenger::Room] Update Font Notification',
props<{ noti: UpdateFontNotification }>() props<{ noti: UpdateFontNotification }>()
); );
export const updateOnlyAlarm = createAction(
'[Messenger::Room] Update Only Alarm',
props<{ roomInfo: RoomInfo }>()
);
export const update = createAction(
'[Messenger::Room] Update',
props<{ req: UpdateRequest }>()
);
export const updateSuccess = createAction(
'[Messenger::Room] Update Success',
props<{
res: UpdateResponse;
}>()
);
export const updateFailure = createAction(
'[Messenger::Room] Update Failure',
props<{ error: any }>()
);

View File

@ -2,12 +2,19 @@ import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Store } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { tap, switchMap, map, catchError } from 'rxjs/operators'; import {
tap,
switchMap,
map,
catchError,
exhaustMap,
withLatestFrom
} from 'rxjs/operators';
import { import {
RoomInfo, RoomInfo,
UserInfoShort, UserInfoShort,
@ -19,7 +26,8 @@ import {
SSVC_TYPE_ROOM_INFO_USER2, SSVC_TYPE_ROOM_INFO_USER2,
SSVC_TYPE_ROOM_INFO_RES, SSVC_TYPE_ROOM_INFO_RES,
UserShortData, UserShortData,
UserData UserData,
UpdateResponse
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
import * as ChatStore from '@app/store/messenger/chat'; import * as ChatStore from '@app/store/messenger/chat';
@ -31,7 +39,11 @@ import {
inviteNotification, inviteNotification,
exitNotification, exitNotification,
exitForcingNotification, exitForcingNotification,
updateFontNotification updateFontNotification,
updateOnlyAlarm,
update,
updateSuccess,
updateFailure
} from './actions'; } from './actions';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
@ -99,6 +111,38 @@ export class Effects {
{ dispatch: false } { dispatch: false }
); );
update$ = createEffect(() =>
this.actions$.pipe(
ofType(update),
map(action => action.req),
exhaustMap(req => {
return this.roomProtocolService.update(req).pipe(
map((res: UpdateResponse) => {
return updateSuccess({ res });
}),
catchError(error => of(updateFailure({ error })))
);
})
)
);
updateOnlyAlarm$ = createEffect(() =>
this.actions$.pipe(
ofType(updateOnlyAlarm),
map(action => action.roomInfo),
map(roomInfo =>
update({
req: {
roomSeq: roomInfo.roomSeq,
roomName: roomInfo.roomName,
receiveAlarm: !roomInfo.receiveAlarm,
syncAll: false
}
})
)
)
);
inviteNotification$ = createEffect( inviteNotification$ = createEffect(
() => { () => {
return this.actions$.pipe( return this.actions$.pipe(

View File

@ -1,6 +1,6 @@
import { createReducer, on } from '@ngrx/store'; import { createReducer, on } from '@ngrx/store';
import { initialState } from './state'; import { initialState } from './state';
import { infoSuccess } from './actions'; import { infoSuccess, updateSuccess } from './actions';
import * as AuthenticationStore from '@app/store/account/authentication'; import * as AuthenticationStore from '@app/store/account/authentication';
@ -15,6 +15,17 @@ export const reducer = createReducer(
}; };
}), }),
on(updateSuccess, (state, action) => {
return {
...state,
roomInfo: {
...state.roomInfo,
roomName: action.res.roomName,
receiveAlarm: action.res.receiveAlarm
}
};
}),
on(AuthenticationStore.logout, (state, action) => { on(AuthenticationStore.logout, (state, action) => {
return { return {
...initialState ...initialState

View File

@ -19,6 +19,8 @@ import {
} from '@ucap-webmessenger/protocol-sync'; } from '@ucap-webmessenger/protocol-sync';
import * as AuthenticationStore from '@app/store/account/authentication'; import * as AuthenticationStore from '@app/store/account/authentication';
import * as RoomStore from '@app/store/messenger/room';
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
export const reducer = createReducer( export const reducer = createReducer(
initialState, initialState,
@ -95,6 +97,22 @@ export const reducer = createReducer(
}; };
}), }),
on(RoomStore.updateSuccess, (state, action) => {
const roomInfo: RoomInfo = {
...state.room.entities[action.res.roomSeq],
roomName: action.res.roomName,
receiveAlarm: action.res.receiveAlarm
};
return {
...state,
room: adapterRoom.updateOne(
{ id: action.res.roomSeq, changes: roomInfo },
{ ...state.room }
)
};
}),
on(AuthenticationStore.logout, (state, action) => { on(AuthenticationStore.logout, (state, action) => {
return { return {
...initialState ...initialState

View File

@ -2,30 +2,30 @@ import { RoomType } from '../types/room.type';
import { EventType } from '@ucap-webmessenger/protocol-event'; import { EventType } from '@ucap-webmessenger/protocol-event';
export interface RoomInfo { export interface RoomInfo {
// 0. 대화방SEQ /** 0. 대화방SEQ */
roomSeq: string; roomSeq: string;
// 1. 대화방종류 /** 1. 대화방종류 */
roomType: RoomType; roomType: RoomType;
// 2. 대화방명 /** 2. 대화방명 */
roomName: string; roomName: string;
// 3. 최종타입 /** 3. 최종타입 */
finalEventType: EventType; finalEventType: EventType;
// 4. 최종대화 /** 4. 최종대화 */
finalEventMessage: string; finalEventMessage: string;
// 5. 최종시간 /** 5. 최종시간 */
finalEventDate: string; finalEventDate: string;
// 6. 참여인원수 /** 6. 참여인원수 */
joinUserCount: number; joinUserCount: number;
// 7. 안읽은수 /** 7. 안읽은수 */
noReadCnt: number; noReadCnt: number;
// 8. 알람여부 /** 8. 알람여부 */
isAlarm: boolean; receiveAlarm: boolean;
// 9. 참여여부 /** 9. 참여여부 */
isJoinRoom: boolean; isJoinRoom: boolean;
// 10. 유효한파일 이벤트 기준 SEQ /** 10. 유효한파일 이벤트 기준 SEQ */
expiredFileStdSeq: number; expiredFileStdSeq: number;
// 11. 타이머대화방여부YN /** 11. 타이머대화방여부YN */
isTimeRoom: boolean; isTimeRoom: boolean;
// 12. 타이머시간(n) /** 12. 타이머시간(n) */
timeRoomInterval: number; timeRoomInterval: number;
} }

View File

@ -90,7 +90,7 @@ export const decodeInfoData: ProtocolDecoder<InfoData> = (
finalEventDate: info[5], finalEventDate: info[5],
joinUserCount: Number(info[6]), joinUserCount: Number(info[6]),
noReadCnt: Number(info[7]), noReadCnt: Number(info[7]),
isAlarm: info[8] !== 'N' ? true : false, receiveAlarm: info[8] !== 'N' ? true : false,
isJoinRoom: info[9] === 'Y' ? true : false, isJoinRoom: info[9] === 'Y' ? true : false,
expiredFileStdSeq: Number(info[10]), expiredFileStdSeq: Number(info[10]),
isTimeRoom: info[11] === 'Y' ? true : false, isTimeRoom: info[11] === 'Y' ? true : false,

View File

@ -11,25 +11,25 @@ import {
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface UpdateRequest extends ProtocolRequest { export interface UpdateRequest extends ProtocolRequest {
// 대화방SEQ(s) /** 대화방SEQ(s) */
roomSeq: string; roomSeq: string;
// 대화방제목(s) /** 대화방제목(s) */
roomName: string; roomName: string;
// 알람여부(y) /** 알람여부(y) */
isAlarm: boolean; receiveAlarm: boolean;
// 동기화여부(s) /** 동기화여부(s) */
isSyncAll: boolean; syncAll: boolean;
} }
export interface UpdateResponse extends ProtocolResponse { export interface UpdateResponse extends ProtocolResponse {
// 대화방SEQ(s) /** 대화방SEQ(s) */
roomSeq: string; roomSeq: string;
// 대화방제목(s) /** 대화방제목(s) */
roomName: string; roomName: string;
// 알람여부(y) /** 알람여부(y) */
isAlarm: boolean; receiveAlarm: boolean;
// 동기화여부(s) /** 동기화여부(s) */
isSyncAll: boolean; syncAll: boolean;
} }
export const encodeUpdate: ProtocolEncoder<UpdateRequest> = ( export const encodeUpdate: ProtocolEncoder<UpdateRequest> = (
@ -41,11 +41,11 @@ export const encodeUpdate: ProtocolEncoder<UpdateRequest> = (
bodyList.push({ type: PacketBodyValue.String, value: req.roomName }); bodyList.push({ type: PacketBodyValue.String, value: req.roomName });
bodyList.push({ bodyList.push({
type: PacketBodyValue.String, type: PacketBodyValue.String,
value: req.isAlarm ? 'Y' : 'N' value: req.receiveAlarm ? 'Y' : 'N'
}); });
bodyList.push({ bodyList.push({
type: PacketBodyValue.String, type: PacketBodyValue.String,
value: req.isSyncAll ? 'Y' : 'N' value: req.syncAll ? 'Y' : 'N'
}); });
return bodyList; return bodyList;
}; };
@ -56,8 +56,8 @@ export const decodeUpdate: ProtocolDecoder<UpdateResponse> = (
return decodeProtocolMessage(message, { return decodeProtocolMessage(message, {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
roomName: message.bodyList[1], roomName: message.bodyList[1],
isAlarm: message.bodyList[2] === 'Y' ? true : false, receiveAlarm: message.bodyList[2] === 'Y' ? true : false,
isSyncAll: message.bodyList[3] === 'Y' ? true : false syncAll: message.bodyList[3] === 'Y' ? true : false
} as UpdateResponse); } as UpdateResponse);
}; };

View File

@ -84,7 +84,7 @@ export const decodeRoomData: ProtocolDecoder<RoomData> = (
finalEventDate: info[5], finalEventDate: info[5],
joinUserCount: Number(info[6]), joinUserCount: Number(info[6]),
noReadCnt: Number(info[7]), noReadCnt: Number(info[7]),
isAlarm: info[8] !== 'N' ? true : false, receiveAlarm: info[8] !== 'N' ? true : false,
isJoinRoom: info[9] === 'Y' ? true : false, isJoinRoom: info[9] === 'Y' ? true : false,
expiredFileStdSeq: Number(info[10]), expiredFileStdSeq: Number(info[10]),
isTimeRoom: info[11] === 'Y' ? true : false, isTimeRoom: info[11] === 'Y' ? true : false,

View File

@ -36,6 +36,10 @@ export class MessagesComponent implements OnInit {
} }
getUserName(seq: number): string { getUserName(seq: number): string {
if (!this.userInfos) {
return '';
}
const userInfo: UserInfo[] = this.userInfos.filter( const userInfo: UserInfo[] = this.userInfos.filter(
user => user.seq === seq user => user.seq === seq
); );
@ -45,6 +49,10 @@ export class MessagesComponent implements OnInit {
return '(알수없는 사용자)'; return '(알수없는 사용자)';
} }
getUserProfile(seq: number): string { getUserProfile(seq: number): string {
if (!this.userInfos) {
return '';
}
const userInfo: UserInfo[] = this.userInfos.filter( const userInfo: UserInfo[] = this.userInfos.filter(
user => user.seq === seq user => user.seq === seq
); );