diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.html index 6960b402..30182570 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.html @@ -1,4 +1,10 @@
+
+ LG ucap + +
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts index bbf11992..2a84d702 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts @@ -1,5 +1,11 @@ import { Component, OnInit } from '@angular/core'; -import { ucapAnimations } from '@ucap-webmessenger/ui'; +import { NGXLogger } from 'ngx-logger'; +import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui'; +import { + CreateChatDialogComponent, + CreateChatDialogData, + CreateChatDialogResult +} from '../dialogs/create-chat.dialog.component'; @Component({ selector: 'app-layout-messenger-left-side', @@ -8,7 +14,31 @@ import { ucapAnimations } from '@ucap-webmessenger/ui'; animations: ucapAnimations }) export class LeftSideComponent implements OnInit { - constructor() {} + constructor( + private dialogService: DialogService, + private logger: NGXLogger + ) {} ngOnInit() {} + + async onClickNewChat() { + const result = await this.dialogService.open< + CreateChatDialogComponent, + CreateChatDialogData, + CreateChatDialogResult + >(CreateChatDialogComponent, { + width: '500px', + height: '500px', + data: { + title: 'New Chat' + } + }); + + this.logger.debug(result.choice); + // if (result.choice) { + + // } else { + + // } + } } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html index e15a22b6..90fd5e0f 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html @@ -1,9 +1,3 @@ - + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts index 82779d78..531eb7df 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts @@ -31,8 +31,9 @@ export class ChatComponent implements OnInit, OnDestroy { roomUserList: RoomUserDetailData[]; roomUserShortList: RoomUserData[]; sessionVerinfo: VersionInfo2Response; - loginRes$: Observable; + loginRes: LoginResponse; + loginResSubscription: Subscription; roomSubscription: Subscription; constructor( @@ -66,9 +67,14 @@ export class ChatComponent implements OnInit, OnDestroy { ) .subscribe(); - this.loginRes$ = this.store.pipe( - select(AppStore.AccountSelector.AuthenticationSelector.loginRes) - ); + this.loginResSubscription = this.store + .pipe( + select(AppStore.AccountSelector.AuthenticationSelector.loginRes), + tap(loginRes => { + this.loginRes = loginRes; + }) + ) + .subscribe(); this.sessionVerinfo = this.sessionStorageService.get( KEY_VER_INFO @@ -79,6 +85,9 @@ export class ChatComponent implements OnInit, OnDestroy { if (!!this.roomSubscription) { this.roomSubscription.unsubscribe(); } + if (!!this.loginResSubscription) { + this.loginResSubscription.unsubscribe(); + } } onSelectedRoom(roomInfo: RoomInfo) { diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.html new file mode 100644 index 00000000..77859748 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.html @@ -0,0 +1,55 @@ + + + {{ data.title }} + + +
+ + + + group + + + + + + + + + + + + device_hub + + + + + + + + chat + + + + + + + +
+
+ choiced users +
+
+ + + + +
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.scss b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.spec.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.spec.ts new file mode 100644 index 00000000..6a6f45df --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.spec.ts @@ -0,0 +1,27 @@ +/* tslint:disable:no-unused-variable */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; + +import { CreateChatDialogComponent } from './create-chat.dialog.component'; + +describe('CreateChatDialogComponent', () => { + let component: CreateChatDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [CreateChatDialogComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CreateChatDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.ts new file mode 100644 index 00000000..73c120ef --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/create-chat.dialog.component.ts @@ -0,0 +1,197 @@ +import { Component, OnInit, OnDestroy, Inject } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { NGXLogger } from 'ngx-logger'; +import { Observable, combineLatest, Subscription } from 'rxjs'; +import { map, tap } from 'rxjs/operators'; + +import { Store, select } from '@ngrx/store'; +import * as AppStore from '@app/store'; +import * as QueryStore from '@app/store/messenger/query'; + +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; +import { Company } from '@ucap-webmessenger/api-external'; +import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; +import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; +import { KEY_VER_INFO } from '@app/types/ver-info.type'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; +import { + UserInfo, + GroupDetailData, + RoomUserDetailData, + RoomUserData +} from '@ucap-webmessenger/protocol-sync'; +import { DeptSearchType } from '@ucap-webmessenger/protocol-query'; +import { + RoomInfo, + UserInfoShort, + UserInfo as RoomUserInfo +} from '@ucap-webmessenger/protocol-room'; + +export interface CreateChatDialogData { + title: string; +} + +export interface CreateChatDialogResult { + choice: boolean; +} + +@Component({ + selector: 'app-layout-messenger-create-chat', + templateUrl: './create-chat.dialog.component.html', + styleUrls: ['./create-chat.dialog.component.scss'] +}) +export class CreateChatDialogComponent implements OnInit, OnDestroy { + constructor( + public dialogRef: MatDialogRef< + CreateChatDialogData, + CreateChatDialogResult + >, + @Inject(MAT_DIALOG_DATA) public data: CreateChatDialogData, + private store: Store, + private sessionStorageService: SessionStorageService, + private logger: NGXLogger + ) {} + + loginRes: LoginResponse; + loginResSubscription: Subscription; + sessionVerinfo = this.sessionStorageService.get( + KEY_VER_INFO + ); + + companyList$: Observable; + companyCode: string; + groupBuddyList$: Observable< + { group: GroupDetailData; buddyList: UserInfo[] }[] + >; + favoritBuddyList$: Observable; + + roomList: RoomInfo[]; + roomUserList: RoomUserDetailData[]; + roomUserShortList: RoomUserData[]; + roomSubscription: Subscription; + + ngOnInit() { + const loginInfo = this.sessionStorageService.get(KEY_LOGIN_INFO); + this.companyCode = loginInfo.companyCode; + + this.companyList$ = this.store.pipe( + select(AppStore.SettingSelector.CompanySelector.companyList) + ); + + this.loginResSubscription = this.store + .pipe( + select(AppStore.AccountSelector.AuthenticationSelector.loginRes), + tap(loginRes => { + this.loginRes = loginRes; + }) + ) + .subscribe(); + + this.groupBuddyList$ = combineLatest([ + this.store.pipe( + select(AppStore.MessengerSelector.SyncSelector.selectAllBuddy2) + ), + this.store.pipe( + select(AppStore.MessengerSelector.SyncSelector.selectAllGroup2) + ) + ]).pipe( + map(([buddyList, groupList]) => { + const groupBuddyList: { + group: GroupDetailData; + buddyList: UserInfo[]; + }[] = []; + for (const group of groupList) { + groupBuddyList.push({ + group, + buddyList: buddyList.filter(buddy => { + return group.userSeqs.indexOf(buddy.seq) > -1; + }) + }); + } + + return groupBuddyList; + }) + ); + + this.favoritBuddyList$ = this.store + .pipe(select(AppStore.MessengerSelector.SyncSelector.selectAllBuddy2)) + .pipe( + map(buddyInfoList => { + return buddyInfoList + .filter(buddy => buddy.isFavorit) + .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)); + }) + ); + + this.roomSubscription = combineLatest([ + this.store.pipe( + select(AppStore.MessengerSelector.SyncSelector.selectAllRoom) + ), + this.store.pipe( + select(AppStore.MessengerSelector.SyncSelector.selectAllRoomUser) + ), + this.store.pipe( + select(AppStore.MessengerSelector.SyncSelector.selectAllRoomUserShort) + ) + ]) + .pipe( + tap(([room, roomUser, roomUserShort]) => { + this.roomList = room; + this.roomUserList = roomUser; + this.roomUserShortList = roomUserShort; + }) + ) + .subscribe(); + } + + ngOnDestroy(): void { + if (!!this.roomSubscription) { + this.roomSubscription.unsubscribe(); + } + if (!!this.loginResSubscription) { + this.loginResSubscription.unsubscribe(); + } + } + + getRoomUserList(roomInfo: RoomInfo): RoomUserInfo[] | UserInfoShort[] { + if (!!this.roomUserList && 0 < this.roomUserList.length) { + const i = this.roomUserList.findIndex( + value => roomInfo.roomSeq === value.roomSeq + ); + if (-1 < i) { + return this.roomUserList[i].userInfos; + } + } + + if (!!this.roomUserShortList && 0 < this.roomUserShortList.length) { + const i = this.roomUserShortList.findIndex( + value => roomInfo.roomSeq === value.roomSeq + ); + if (-1 < i) { + return this.roomUserShortList[i].userInfos; + } + } + } + + onKeyDownEnterOrganizationTenantSearch(params: { + companyCode: string; + searchWord: string; + }) { + this.store.dispatch( + QueryStore.deptUser({ + divCd: 'GRP', + companyCode: params.companyCode, + searchRange: DeptSearchType.All, + search: params.searchWord, + senderCompanyCode: params.companyCode, + senderEmployeeType: this.loginRes.userInfo.employeeType + }) + ); + } + + onClickChoice(choice: boolean): void { + this.dialogRef.close({ + choice + }); + } +} diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts index dc006a67..ca2df322 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts @@ -1,3 +1,4 @@ import { CreateGroupDialogComponent } from './create-group.dialog.component'; +import { CreateChatDialogComponent } from './create-chat.dialog.component'; -export const DIALOGS = [CreateGroupDialogComponent]; +export const DIALOGS = [CreateGroupDialogComponent, CreateChatDialogComponent]; diff --git a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html index fab50538..17a31394 100644 --- a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html +++ b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html @@ -1,18 +1,13 @@ - + 즐겨찾기 - + @@ -24,29 +19,22 @@ --> - + {{ groupBuddy.group.name }} - + - +