2019-10-18 04:02:43 +00:00
|
|
|
import { UserSelectDialogType } from './../../../../types/userselect.dialog.type';
|
|
|
|
import {
|
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
|
|
|
CreateChatDialogResult
|
|
|
|
} from './../../dialogs/chat/create-chat.dialog.component';
|
2019-10-16 01:20:49 +00:00
|
|
|
import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core';
|
2019-09-25 08:26:19 +00:00
|
|
|
|
2019-10-08 08:57:57 +00:00
|
|
|
import { Observable, combineLatest, Subscription } from 'rxjs';
|
2019-10-16 01:20:49 +00:00
|
|
|
import { map, tap } 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';
|
2019-10-08 08:57:57 +00:00
|
|
|
import * as QueryStore from '@app/store/messenger/query';
|
2019-10-18 07:48:53 +00:00
|
|
|
import * as SyncStore from '@app/store/messenger/sync';
|
2019-09-27 03:53:21 +00:00
|
|
|
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
|
2019-10-17 00:18:55 +00:00
|
|
|
} from '@app/layouts/messenger/dialogs/group/create-group.dialog.component';
|
2019-10-08 08:57:57 +00:00
|
|
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
2019-10-15 02:07:26 +00:00
|
|
|
import {
|
|
|
|
DeptSearchType,
|
|
|
|
UserInfoSS,
|
|
|
|
UserInfoF,
|
|
|
|
UserInfoDN
|
|
|
|
} from '@ucap-webmessenger/protocol-query';
|
2019-10-16 01:20:49 +00:00
|
|
|
import { MatMenuTrigger } from '@angular/material';
|
2019-10-15 05:58:11 +00:00
|
|
|
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
|
|
|
import { KEY_VER_INFO } from '@app/types/ver-info.type';
|
2019-10-16 06:36:18 +00:00
|
|
|
import {
|
|
|
|
DeleteGroupDialogComponent,
|
|
|
|
DeleteGroupDialogData,
|
|
|
|
DeleteGroupDialogResult
|
2019-10-17 00:18:55 +00:00
|
|
|
} from '@app/layouts/messenger/dialogs/group/delete-group.dialog.component';
|
2019-10-16 06:36:18 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
EditGroupDialogComponent,
|
|
|
|
EditGroupDialogData,
|
|
|
|
EditGroupDialogResult
|
2019-10-17 00:18:55 +00:00
|
|
|
} from '@app/layouts/messenger/dialogs/group/edit-group.dialog.component';
|
2019-10-16 06:36:18 +00:00
|
|
|
import {
|
|
|
|
EditGroupMemberDialogComponent,
|
|
|
|
EditGroupMemberDialogData,
|
|
|
|
EditGroupMemberDialogResult
|
2019-10-17 00:18:55 +00:00
|
|
|
} from '@app/layouts/messenger/dialogs/group/edit-group-member.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
|
|
|
|
})
|
2019-10-15 09:28:01 +00:00
|
|
|
export class GroupComponent implements OnInit, OnDestroy {
|
2019-10-07 08:02:14 +00:00
|
|
|
@ViewChild('groupExpansionPanel', { static: true })
|
|
|
|
groupExpansionPanel: GroupExpansionPanelComponent;
|
|
|
|
|
2019-10-16 01:20:49 +00:00
|
|
|
@ViewChild('profileContextMenuTrigger', { static: true })
|
|
|
|
profileContextMenuTrigger: MatMenuTrigger;
|
2019-10-16 07:33:19 +00:00
|
|
|
profileContextMenuPosition = { x: '0px', y: '0px' };
|
2019-10-16 01:20:49 +00:00
|
|
|
|
|
|
|
@ViewChild('groupContextMenuTrigger', { static: true })
|
|
|
|
groupContextMenuTrigger: MatMenuTrigger;
|
2019-10-15 02:50:59 +00:00
|
|
|
groupContextMenuPosition = { x: '0px', y: '0px' };
|
|
|
|
|
2019-09-27 03:53:21 +00:00
|
|
|
groupBuddyList$: Observable<
|
|
|
|
{ group: GroupDetailData; buddyList: UserInfo[] }[]
|
|
|
|
>;
|
2019-10-10 09:35:23 +00:00
|
|
|
favoritBuddyList$: Observable<UserInfo[]>;
|
2019-10-07 07:29:38 +00:00
|
|
|
companyList$: Observable<Company[]>;
|
|
|
|
companyCode: string;
|
2019-09-25 08:26:19 +00:00
|
|
|
|
2019-10-08 08:57:57 +00:00
|
|
|
loginRes: LoginResponse;
|
|
|
|
loginResSubscription: Subscription;
|
|
|
|
|
2019-10-18 03:49:23 +00:00
|
|
|
sessionVerinfo: VersionInfo2Response;
|
2019-10-15 05:58:11 +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-18 03:49:23 +00:00
|
|
|
this.sessionVerinfo = this.sessionStorageService.get<VersionInfo2Response>(
|
|
|
|
KEY_VER_INFO
|
|
|
|
);
|
2019-10-07 07:29:38 +00:00
|
|
|
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
|
|
|
|
this.companyCode = loginInfo.companyCode;
|
|
|
|
|
2019-10-08 08:57:57 +00:00
|
|
|
this.loginResSubscription = this.store
|
|
|
|
.pipe(
|
|
|
|
select(AppStore.AccountSelector.AuthenticationSelector.loginRes),
|
|
|
|
tap(loginRes => {
|
|
|
|
this.loginRes = loginRes;
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe();
|
|
|
|
|
2019-10-07 07:29:38 +00:00
|
|
|
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-10-11 02:58:03 +00:00
|
|
|
this.groupBuddyList$ = combineLatest([
|
|
|
|
this.store.pipe(
|
|
|
|
select(AppStore.MessengerSelector.SyncSelector.selectAllBuddy2)
|
|
|
|
),
|
|
|
|
this.store.pipe(
|
|
|
|
select(AppStore.MessengerSelector.SyncSelector.selectAllGroup2)
|
2019-09-27 03:53:21 +00:00
|
|
|
)
|
2019-10-11 02:58:03 +00:00
|
|
|
]).pipe(
|
|
|
|
map(([buddyList, groupList]) => {
|
|
|
|
const groupBuddyList: {
|
|
|
|
group: GroupDetailData;
|
|
|
|
buddyList: UserInfo[];
|
|
|
|
}[] = [];
|
|
|
|
for (const group of groupList) {
|
|
|
|
groupBuddyList.push({
|
|
|
|
group,
|
|
|
|
buddyList: buddyList.filter(buddy => {
|
2019-09-27 03:53:21 +00:00
|
|
|
return group.userSeqs.indexOf(buddy.seq) > -1;
|
2019-10-11 02:58:03 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
2019-09-27 03:53:21 +00:00
|
|
|
|
2019-10-11 02:58:03 +00:00
|
|
|
return groupBuddyList;
|
|
|
|
})
|
|
|
|
);
|
2019-10-10 09:35:23 +00:00
|
|
|
|
|
|
|
this.favoritBuddyList$ = this.store
|
2019-10-11 03:58:41 +00:00
|
|
|
.pipe(select(AppStore.MessengerSelector.SyncSelector.selectAllBuddy2))
|
2019-10-10 09:35:23 +00:00
|
|
|
.pipe(
|
|
|
|
map(buddyInfoList => {
|
|
|
|
return buddyInfoList
|
|
|
|
.filter(buddy => buddy.isFavorit)
|
|
|
|
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
|
|
})
|
|
|
|
);
|
2019-09-27 03:53:21 +00:00
|
|
|
}
|
|
|
|
|
2019-10-15 09:28:01 +00:00
|
|
|
ngOnDestroy(): void {
|
2019-10-18 03:49:23 +00:00
|
|
|
this.logger.debug('ngOnDestroy');
|
2019-10-15 09:28:01 +00:00
|
|
|
if (!!this.loginResSubscription) {
|
|
|
|
this.loginResSubscription.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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<
|
2019-10-18 04:02:43 +00:00
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
|
|
|
CreateChatDialogResult
|
|
|
|
>(CreateChatDialogComponent, {
|
|
|
|
width: '600px',
|
|
|
|
height: '500px',
|
2019-10-08 00:18:40 +00:00
|
|
|
data: {
|
2019-10-18 04:02:43 +00:00
|
|
|
type: UserSelectDialogType.NewGroup,
|
|
|
|
title: 'New Group'
|
2019-10-08 00:18:40 +00:00
|
|
|
}
|
|
|
|
});
|
2019-10-18 04:02:43 +00:00
|
|
|
|
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
if (
|
|
|
|
!!result.selectedUserList &&
|
2019-10-18 07:48:53 +00:00
|
|
|
result.selectedUserList.length > 0 &&
|
|
|
|
result.groupName.trim().length > 0
|
2019-10-18 04:02:43 +00:00
|
|
|
) {
|
2019-10-18 07:48:53 +00:00
|
|
|
const userSeqs: number[] = [];
|
|
|
|
result.selectedUserList.map(user => userSeqs.push(user.seq));
|
|
|
|
|
|
|
|
this.store.dispatch(
|
|
|
|
SyncStore.createGroupAndBuddy({
|
|
|
|
groupName: result.groupName,
|
|
|
|
trgtUserSeq: userSeqs
|
|
|
|
})
|
|
|
|
);
|
2019-10-18 04:02:43 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-08 00:18:40 +00:00
|
|
|
}
|
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) {
|
2019-10-11 08:52:00 +00:00
|
|
|
this.logger.debug('onSelectBuddy', buddy);
|
2019-10-16 06:44:16 +00:00
|
|
|
this.store.dispatch(ChatStore.openRoom({ userSeqList: [buddy.seq] }));
|
2019-09-25 08:26:19 +00:00
|
|
|
}
|
2019-10-07 07:29:38 +00:00
|
|
|
|
2019-10-11 09:24:57 +00:00
|
|
|
getStatusBulkInfo(buddy: UserInfo) {
|
|
|
|
return this.store.pipe(
|
|
|
|
select(
|
|
|
|
AppStore.MessengerSelector.StatusSelector.selectEntitiesStatusBulkInfo
|
|
|
|
),
|
|
|
|
map(statusBulkInfo =>
|
|
|
|
!!statusBulkInfo ? statusBulkInfo[buddy.seq] : undefined
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-10-07 07:29:38 +00:00
|
|
|
onKeyDownEnterOrganizationTenantSearch(params: {
|
|
|
|
companyCode: string;
|
|
|
|
searchWord: string;
|
|
|
|
}) {
|
2019-10-08 08:57:57 +00:00
|
|
|
this.store.dispatch(
|
|
|
|
QueryStore.deptUser({
|
|
|
|
divCd: 'GRP',
|
|
|
|
companyCode: params.companyCode,
|
|
|
|
searchRange: DeptSearchType.All,
|
|
|
|
search: params.searchWord,
|
|
|
|
senderCompanyCode: params.companyCode,
|
|
|
|
senderEmployeeType: this.loginRes.userInfo.employeeType
|
|
|
|
})
|
|
|
|
);
|
2019-10-07 07:29:38 +00:00
|
|
|
}
|
2019-10-15 02:07:26 +00:00
|
|
|
|
2019-10-15 09:20:50 +00:00
|
|
|
onClickProfileContextMenu(
|
|
|
|
menuType: string,
|
|
|
|
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN
|
|
|
|
) {
|
|
|
|
this.logger.debug(
|
|
|
|
'onClickProfileContextMenu',
|
|
|
|
'menuType',
|
|
|
|
menuType,
|
|
|
|
'userInfo',
|
|
|
|
userInfo
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-10-15 07:39:58 +00:00
|
|
|
onContextMenuProfile(
|
|
|
|
event: MouseEvent,
|
|
|
|
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN
|
|
|
|
) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
this.profileContextMenuPosition.x = event.clientX + 'px';
|
|
|
|
this.profileContextMenuPosition.y = event.clientY + 'px';
|
2019-10-16 01:20:49 +00:00
|
|
|
this.profileContextMenuTrigger.menu.focusFirstItem('mouse');
|
|
|
|
this.profileContextMenuTrigger.menuData = { userInfo };
|
|
|
|
this.profileContextMenuTrigger.openMenu();
|
2019-10-15 02:07:26 +00:00
|
|
|
}
|
2019-10-15 02:50:59 +00:00
|
|
|
|
2019-10-16 06:36:18 +00:00
|
|
|
async onClickGroupContextMenu(menuType: string, group: GroupDetailData) {
|
2019-10-15 09:20:50 +00:00
|
|
|
this.logger.debug(
|
|
|
|
'onClickGroupContextMenu',
|
|
|
|
'menuType',
|
|
|
|
menuType,
|
|
|
|
'group',
|
|
|
|
group
|
|
|
|
);
|
2019-10-16 05:53:53 +00:00
|
|
|
switch (menuType) {
|
|
|
|
case 'CHAT':
|
|
|
|
this.store.dispatch(
|
|
|
|
ChatStore.openRoom({ userSeqList: group.userSeqs })
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'SEND_NOTE':
|
|
|
|
break;
|
|
|
|
case 'RENAME':
|
2019-10-16 06:36:18 +00:00
|
|
|
{
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
EditGroupDialogComponent,
|
|
|
|
EditGroupDialogData,
|
|
|
|
EditGroupDialogResult
|
|
|
|
>(EditGroupDialogComponent, {
|
|
|
|
width: '220px',
|
|
|
|
data: {
|
|
|
|
title: 'Logout',
|
|
|
|
message: 'Logout ?'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-10-16 05:53:53 +00:00
|
|
|
break;
|
|
|
|
case 'EDIT_MEMBER':
|
2019-10-16 06:36:18 +00:00
|
|
|
{
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
EditGroupMemberDialogComponent,
|
|
|
|
EditGroupMemberDialogData,
|
|
|
|
EditGroupMemberDialogResult
|
|
|
|
>(EditGroupMemberDialogComponent, {
|
|
|
|
width: '220px',
|
|
|
|
data: {
|
|
|
|
title: 'Logout',
|
|
|
|
message: 'Logout ?'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'DELETE':
|
|
|
|
{
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
DeleteGroupDialogComponent,
|
|
|
|
DeleteGroupDialogData,
|
|
|
|
DeleteGroupDialogResult
|
|
|
|
>(DeleteGroupDialogComponent, {
|
|
|
|
width: '220px',
|
|
|
|
data: {
|
|
|
|
title: 'Logout',
|
|
|
|
message: 'Logout ?'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-10-16 05:53:53 +00:00
|
|
|
break;
|
2019-10-16 06:36:18 +00:00
|
|
|
case 'EDIT_MEMBER':
|
|
|
|
{
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
EditGroupMemberDialogComponent,
|
|
|
|
EditGroupMemberDialogData,
|
|
|
|
EditGroupMemberDialogResult
|
|
|
|
>(EditGroupMemberDialogComponent, {
|
|
|
|
width: '220px',
|
|
|
|
data: {
|
|
|
|
title: 'Logout',
|
|
|
|
message: 'Logout ?'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-10-16 05:53:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-10-15 09:20:50 +00:00
|
|
|
}
|
|
|
|
|
2019-10-15 02:50:59 +00:00
|
|
|
onMoreGroup(params: { event: MouseEvent; group: GroupDetailData }) {
|
2019-10-15 09:20:50 +00:00
|
|
|
params.event.preventDefault();
|
|
|
|
params.event.stopPropagation();
|
|
|
|
|
2019-10-15 02:50:59 +00:00
|
|
|
this.groupContextMenuPosition.x = params.event.clientX + 'px';
|
|
|
|
this.groupContextMenuPosition.y = params.event.clientY + 'px';
|
2019-10-16 01:20:49 +00:00
|
|
|
this.groupContextMenuTrigger.menu.focusFirstItem('mouse');
|
|
|
|
this.groupContextMenuTrigger.menuData = { group: params.group };
|
|
|
|
this.groupContextMenuTrigger.openMenu();
|
2019-10-15 02:50:59 +00:00
|
|
|
}
|
2019-09-23 05:23:24 +00:00
|
|
|
}
|