register group is added

This commit is contained in:
병준 박 2019-10-16 14:53:53 +09:00
parent c651b5773b
commit 2764d5f995
10 changed files with 197 additions and 15 deletions

View File

@ -1,3 +1,9 @@
<ucap-room-list-item *ngFor="let room of roomList" [roomInfo]="room" [roomUserInfo]="getRoomUserList(room)"
[sessionVerinfo]="sessionVerinfo" (click)="onSelectedRoom(room)">
<ucap-room-list-item
*ngFor="let room of roomList"
[loginRes]="loginRes$ | async"
[roomInfo]="room"
[roomUserInfo]="getRoomUserList(room)"
[sessionVerinfo]="sessionVerinfo"
(click)="onSelectedRoom(room)"
>
</ucap-room-list-item>

View File

@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
import { ucapAnimations } from '@ucap-webmessenger/ui';
import { NGXLogger } from 'ngx-logger';
import { Store, select } from '@ngrx/store';
import { Subscription, combineLatest } from 'rxjs';
import { Subscription, combineLatest, Observable } from 'rxjs';
import {
RoomInfo,
UserInfoShort,
@ -18,6 +18,7 @@ import {
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';
@Component({
selector: 'app-layout-chat-left-sidenav-chat',
@ -30,6 +31,7 @@ export class ChatComponent implements OnInit, OnDestroy {
roomUserList: RoomUserDetailData[];
roomUserShortList: RoomUserData[];
sessionVerinfo: VersionInfo2Response;
loginRes$: Observable<LoginResponse>;
roomSubscription: Subscription;
@ -60,6 +62,10 @@ export class ChatComponent implements OnInit, OnDestroy {
)
.subscribe();
this.loginRes$ = this.store.pipe(
select(AppStore.AccountSelector.AuthenticationSelector.loginRes)
);
this.sessionVerinfo = this.sessionStorageService.get<VersionInfo2Response>(
KEY_VER_INFO
);

View File

@ -238,6 +238,23 @@ export class GroupComponent implements OnInit, OnDestroy {
'group',
group
);
switch (menuType) {
case 'CHAT':
this.store.dispatch(
ChatStore.openRoom({ userSeqList: group.userSeqs })
);
break;
case 'SEND_NOTE':
break;
case 'RENAME':
break;
case 'EDIT_MEMBER':
break;
case 'REMOVE':
break;
default:
break;
}
}
onMoreGroup(params: { event: MouseEvent; group: GroupDetailData }) {

View File

@ -34,3 +34,8 @@ export const massTalkDownloadFailure = createAction(
'[Messenger::Chat] massTalkDownload Failure',
props<{ error: any }>()
);
export const openRoom = createAction(
'[Messenger::Chat] Open Room',
props<{ userSeqList: number[] }>()
);

View File

@ -9,7 +9,9 @@ import {
ExitForcingNotification,
UpdateFontNotification,
UpdateResponse,
UpdateRequest
UpdateRequest,
OpenRequest,
OpenResponse
} from '@ucap-webmessenger/protocol-room';
export const info = createAction(
@ -72,3 +74,20 @@ export const updateFailure = createAction(
'[Messenger::Room] Update Failure',
props<{ error: any }>()
);
export const open = createAction(
'[Messenger::Room] Open',
props<{ req: OpenRequest }>()
);
export const openSuccess = createAction(
'[Messenger::Room] Open Success',
props<{
res: OpenResponse;
}>()
);
export const openFailure = createAction(
'[Messenger::Room] Open Failure',
props<{ error: any }>()
);

View File

@ -27,7 +27,8 @@ import {
SSVC_TYPE_ROOM_INFO_RES,
UserShortData,
UserData,
UpdateResponse
UpdateResponse,
OpenResponse
} from '@ucap-webmessenger/protocol-room';
import * as ChatStore from '@app/store/messenger/chat';
@ -43,7 +44,10 @@ import {
updateOnlyAlarm,
update,
updateSuccess,
updateFailure
updateFailure,
open,
openSuccess,
openFailure
} from './actions';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
@ -143,6 +147,30 @@ export class Effects {
)
);
open$ = createEffect(() =>
this.actions$.pipe(
ofType(open),
map(action => action.req),
exhaustMap(req => {
return this.roomProtocolService.open(req).pipe(
map((res: OpenResponse) => {
return openSuccess({ res });
}),
catchError(error => of(openFailure({ error })))
);
})
)
);
openSuccess$ = createEffect(() =>
this.actions$.pipe(
ofType(openSuccess),
map(action => {
return ChatStore.selectedRoom({ roomSeq: action.res.roomSeq });
})
)
);
inviteNotification$ = createEffect(
() => {
return this.actions$.pipe(

View File

@ -59,6 +59,9 @@ import {
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
import * as ChatStore from '@app/store/messenger/chat';
import * as RoomStore from '@app/store/messenger/room';
import { Dictionary } from '@ngrx/entity';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
@Injectable()
export class Effects {
@ -241,6 +244,90 @@ export class Effects {
{ dispatch: false }
);
openRoom$ = createEffect(
() =>
this.actions$.pipe(
ofType(ChatStore.openRoom),
withLatestFrom(
this.store.pipe(
select(
(state: any) =>
state.account.authentication.loginRes as LoginResponse
)
),
this.store.pipe(
select(
(state: any) =>
state.messenger.sync.roomUser.entities as Dictionary<
RoomUserDetailData
>
)
),
this.store.pipe(
select(
(state: any) =>
state.messenger.sync.roomUserShort.entities as Dictionary<
RoomUserData
>
)
)
),
tap(([action, loginRes, roomUsers, roomUserShorts]) => {
const userSeqList = [...action.userSeqList, loginRes.userSeq];
let roomSeq = null;
for (const key in roomUsers) {
if (roomUsers.hasOwnProperty(key)) {
const element = roomUsers[key];
if (userSeqList.length === element.userInfos.length) {
roomSeq = key;
for (const roomUserInfo of element.userInfos) {
if (-1 === userSeqList.indexOf(roomUserInfo.seq)) {
roomSeq = null;
break;
}
}
}
}
}
for (const key in roomUserShorts) {
if (roomUserShorts.hasOwnProperty(key)) {
const element = roomUserShorts[key];
if (userSeqList.length === element.userInfos.length) {
roomSeq = key;
for (const roomUserDetailData of element.userInfos) {
if (-1 === userSeqList.indexOf(roomUserDetailData.seq)) {
roomSeq = null;
break;
}
}
}
}
}
this.logger.debug(
'openRoom',
'userSeqList',
userSeqList,
'roomSeq',
roomSeq
);
if (!!roomSeq) {
this.store.dispatch(ChatStore.selectedRoom({ roomSeq }));
return;
}
this.store.dispatch(
RoomStore.open({
req: { divCd: 'DivCode', userSeqs: userSeqList }
})
);
})
),
{ dispatch: false }
);
constructor(
private actions$: Actions,
private store: Store<any>,

View File

@ -10,16 +10,15 @@ import { MatIconModule } from '@angular/material/icon';
import { ExpansionPanelComponent } from './components/expansion-panel.component';
import { ExpansionPanelItemDirective } from './directives/expansion-panel-item.directive';
import { UCapUiProfileModule } from '@ucap-webmessenger/ui-profile';
const COMPONENTS = [ExpansionPanelComponent];
const DIALOGS = [];
const DIRECTIVES = [ExpansionPanelItemDirective];
const SERVICES = [];
@NgModule({
imports: [
CommonModule,
UCapUiProfileModule,
ReactiveFormsModule,
FlexLayoutModule,
MatButtonModule,
@ -27,7 +26,8 @@ const SERVICES = [];
MatIconModule
],
exports: [...COMPONENTS, ...DIRECTIVES],
declarations: [...COMPONENTS, ...DIRECTIVES]
declarations: [...COMPONENTS, ...DIRECTIVES],
entryComponents: []
})
export class UCapUiGroupModule {
public static forRoot(): ModuleWithProviders<UCapUiGroupModule> {

View File

@ -4,4 +4,6 @@
export * from './lib/components/expansion-panel.component';
export * from './lib/directives/expansion-panel-item.directive';
export * from './lib/ucap-ui-group.module';

View File

@ -14,6 +14,10 @@ import {
MassTextInfo
} from '@ucap-webmessenger/ui-chat';
import { FileType } from '@ucap-webmessenger/protocol-file';
import {
LoginResponse,
UserInfo
} from '@ucap-webmessenger/protocol-authentication';
@Component({
selector: 'ucap-room-list-item',
@ -21,6 +25,9 @@ import { FileType } from '@ucap-webmessenger/protocol-file';
styleUrls: ['./list-item.component.scss']
})
export class ListItemComponent implements OnInit {
@Input()
loginRes: LoginResponse;
@Input()
roomInfo: RoomInfo;
@Input()
@ -95,13 +102,18 @@ export class ListItemComponent implements OnInit {
if (!!this.roomUserInfo && 0 < this.roomUserInfo.length) {
let roomName = '';
this.roomUserInfo.forEach((roomUserInfo, index) => {
if (0 === index) {
this.roomUserInfo.forEach(
(roomUserInfo: RoomUserInfo | UserInfoShort, index: number) => {
if (this.loginRes.userSeq === roomUserInfo.seq) {
return;
}
if ('' === roomName.trim()) {
roomName = roomName.concat('', roomUserInfo.name);
} else {
roomName = roomName.concat(',', roomUserInfo.name);
}
});
}
);
return roomName;
}
}