2019-10-07 08:02:14 +00:00
|
|
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
2019-09-25 08:26:19 +00:00
|
|
|
|
2019-09-27 03:53:21 +00:00
|
|
|
import { Observable, combineLatest } from 'rxjs';
|
|
|
|
import { map } from 'rxjs/operators';
|
2019-09-25 08:26:19 +00:00
|
|
|
|
|
|
|
import { Store, select } from '@ngrx/store';
|
|
|
|
|
2019-10-08 00:18:40 +00:00
|
|
|
import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui';
|
2019-09-25 09:08:50 +00:00
|
|
|
import { UserInfo, GroupDetailData } from '@ucap-webmessenger/protocol-sync';
|
2019-09-25 08:26:19 +00:00
|
|
|
|
|
|
|
import * as AppStore from '@app/store';
|
2019-09-27 03:53:21 +00:00
|
|
|
import * as ChatStore from '@app/store/messenger/chat';
|
|
|
|
import { NGXLogger } from 'ngx-logger';
|
2019-10-07 07:29:38 +00:00
|
|
|
import { Company } from '@ucap-webmessenger/api-external';
|
|
|
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
|
|
|
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
2019-10-07 08:02:14 +00:00
|
|
|
import { ExpansionPanelComponent as GroupExpansionPanelComponent } from '@ucap-webmessenger/ui-group';
|
2019-10-08 00:18:40 +00:00
|
|
|
import {
|
|
|
|
CreateGroupDialogComponent,
|
|
|
|
CreateGroupDialogData,
|
|
|
|
CreateGroupDialogResult
|
|
|
|
} from '@app/layouts/messenger/dialogs/create-group.dialog.component';
|
2019-09-23 05:23:24 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-layout-chat-left-sidenav-group',
|
|
|
|
templateUrl: './group.component.html',
|
|
|
|
styleUrls: ['./group.component.scss'],
|
|
|
|
animations: ucapAnimations
|
|
|
|
})
|
|
|
|
export class GroupComponent implements OnInit {
|
2019-10-07 08:02:14 +00:00
|
|
|
@ViewChild('groupExpansionPanel', { static: true })
|
|
|
|
groupExpansionPanel: GroupExpansionPanelComponent;
|
|
|
|
|
2019-09-27 03:53:21 +00:00
|
|
|
groupBuddyList$: Observable<
|
|
|
|
{ group: GroupDetailData; buddyList: UserInfo[] }[]
|
|
|
|
>;
|
2019-10-07 07:29:38 +00:00
|
|
|
companyList$: Observable<Company[]>;
|
|
|
|
companyCode: string;
|
2019-09-25 08:26:19 +00:00
|
|
|
|
2019-10-07 07:29:38 +00:00
|
|
|
constructor(
|
|
|
|
private store: Store<any>,
|
|
|
|
private sessionStorageService: SessionStorageService,
|
2019-10-08 00:18:40 +00:00
|
|
|
private dialogService: DialogService,
|
2019-10-07 07:29:38 +00:00
|
|
|
private logger: NGXLogger
|
|
|
|
) {}
|
2019-09-23 05:23:24 +00:00
|
|
|
|
2019-09-25 08:26:19 +00:00
|
|
|
ngOnInit() {
|
2019-10-07 07:29:38 +00:00
|
|
|
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
|
|
|
|
this.companyCode = loginInfo.companyCode;
|
|
|
|
|
|
|
|
this.companyList$ = this.store.pipe(
|
2019-10-08 00:18:40 +00:00
|
|
|
select(AppStore.SettingSelector.CompanySelector.companyList)
|
2019-10-07 07:29:38 +00:00
|
|
|
);
|
|
|
|
|
2019-09-27 03:53:21 +00:00
|
|
|
this.groupBuddyList$ = this.store
|
|
|
|
.pipe(
|
|
|
|
select(AppStore.MessengerSelector.SyncSelector.groupListAndBuddyList)
|
|
|
|
)
|
|
|
|
.pipe(
|
|
|
|
map(groupListAndBuddyList => {
|
|
|
|
const groupList = groupListAndBuddyList.groupList
|
|
|
|
.slice()
|
|
|
|
.sort((a, b) => {
|
|
|
|
// 기본그룹은 제일 하단
|
|
|
|
if (0 === a.seq) {
|
|
|
|
return 1;
|
|
|
|
} else if (0 === b.seq) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
if (a.name > b.name) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (b.name > a.name) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const groupBuddyList: {
|
|
|
|
group: GroupDetailData;
|
|
|
|
buddyList: UserInfo[];
|
|
|
|
}[] = [];
|
|
|
|
for (const group of groupList) {
|
|
|
|
const buddyList = groupListAndBuddyList.buddyList.filter(buddy => {
|
|
|
|
return group.userSeqs.indexOf(buddy.seq) > -1;
|
|
|
|
});
|
|
|
|
|
|
|
|
groupBuddyList.push({
|
|
|
|
group,
|
|
|
|
buddyList
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return groupBuddyList;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-10-08 00:18:40 +00:00
|
|
|
async onClickGroupMenu(menuType: string) {
|
2019-10-07 08:02:14 +00:00
|
|
|
this.logger.debug('menuType', menuType);
|
|
|
|
switch (menuType) {
|
|
|
|
case 'GROUP_NEW':
|
2019-10-08 00:18:40 +00:00
|
|
|
{
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
CreateGroupDialogComponent,
|
|
|
|
CreateGroupDialogData,
|
|
|
|
CreateGroupDialogResult
|
|
|
|
>(CreateGroupDialogComponent, {
|
|
|
|
width: '220px',
|
|
|
|
data: {
|
|
|
|
title: 'Logout',
|
|
|
|
message: 'Logout ?'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-10-07 08:02:14 +00:00
|
|
|
break;
|
|
|
|
case 'GROUP_EXPAND_MORE':
|
2019-10-08 00:18:40 +00:00
|
|
|
{
|
|
|
|
this.groupExpansionPanel.expandMore();
|
|
|
|
}
|
2019-10-07 08:02:14 +00:00
|
|
|
break;
|
|
|
|
case 'GROUP_EXPAND_LESS':
|
2019-10-08 00:18:40 +00:00
|
|
|
{
|
|
|
|
this.groupExpansionPanel.expandLess();
|
|
|
|
}
|
2019-10-07 08:02:14 +00:00
|
|
|
break;
|
|
|
|
case 'GROUP_SAVE':
|
|
|
|
break;
|
|
|
|
case 'GROUP_RESTORE':
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-27 03:53:21 +00:00
|
|
|
onSelectBuddy(buddy: UserInfo) {
|
|
|
|
this.store.dispatch(ChatStore.selectedRoom({ roomSeq: buddy.seq }));
|
2019-09-25 08:26:19 +00:00
|
|
|
}
|
2019-10-07 07:29:38 +00:00
|
|
|
|
|
|
|
onKeyDownEnterOrganizationTenantSearch(params: {
|
|
|
|
companyCode: string;
|
|
|
|
searchWord: string;
|
|
|
|
}) {
|
|
|
|
this.logger.debug('params', params);
|
|
|
|
}
|
2019-09-23 05:23:24 +00:00
|
|
|
}
|