noti popup 에 사용자 정보 표시.

This commit is contained in:
leejinho 2020-03-23 16:34:27 +09:00
parent 8d5127c261
commit 23ae97caab
4 changed files with 252 additions and 138 deletions

View File

@ -1,7 +1,6 @@
import { delGroupSuccess, buddy2 } from './../store/messenger/sync/actions';
import { Injectable, Inject } from '@angular/core';
import { tap, withLatestFrom, take } from 'rxjs/operators';
import { tap, withLatestFrom } from 'rxjs/operators';
import { Store, select } from '@ngrx/store';
@ -95,7 +94,11 @@ import {
NotificationType,
WindowState
} from '@ucap-webmessenger/native';
import { StringUtil, DialogService } from '@ucap-webmessenger/ui';
import {
StringUtil,
DialogService,
TranslateService as UcapTranslateService
} from '@ucap-webmessenger/ui';
import {
UmgProtocolService,
SSVC_TYPE_UMG_NOTI,
@ -110,10 +113,10 @@ import {
import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type';
import { environment } from '../../environments/environment';
import { NotificationMethod } from '@ucap-webmessenger/core';
import { NotificationMethod, LocaleCode } from '@ucap-webmessenger/core';
import { Dictionary } from '@ngrx/entity';
import { MessageType } from '@ucap-webmessenger/api-message';
import { LogoutInfo, KEY_LOGOUT_INFO } from '@app/types';
import { LogoutInfo, KEY_LOGOUT_INFO, KEY_VER_INFO } from '@app/types';
import { TranslateService } from '@ngx-translate/core';
import { deleteMessageSuccess } from '@app/store/messenger/message';
import { ServerErrorCode } from '@ucap-webmessenger/protocol';
@ -131,6 +134,10 @@ import {
} from '@ucap-webmessenger/ui-settings';
import clone from 'clone';
import { ElectronBrowserWindowChannel } from '@ucap-webmessenger/electron-core';
import { UserInfo, RoomUserData } from '@ucap-webmessenger/protocol-sync';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { QueryProtocolService } from '@ucap-webmessenger/protocol-query';
import { UserInfoListState } from '@app/store/messenger/room';
@Injectable()
export class AppNotificationService {
@ -141,8 +148,10 @@ export class AppNotificationService {
private roomProtocolService: RoomProtocolService,
private groupProtocolService: GroupProtocolService,
private buddyProtocolService: BuddyProtocolService,
private queryProtocolService: QueryProtocolService,
private statusProtocolService: StatusProtocolService,
private translateService: TranslateService,
private ucapTranslateService: UcapTranslateService,
private optionProtocolService: OptionProtocolService,
private umgProtocolService: UmgProtocolService,
private localStorageService: LocalStorageService,
@ -205,14 +214,44 @@ export class AppNotificationService {
this.store.pipe(
select((state: any) => state.messenger.room.roomInfo as RoomInfo)
),
this.store.pipe(
select(
(state: any) =>
state.messenger.room.userInfoList.entities as Dictionary<
UserInfoListState
>
)
),
this.store.pipe(
select(
(state: any) =>
state.messenger.sync.room.entities as Dictionary<RoomInfo>
)
),
this.store.pipe(
select(
(state: any) =>
state.messenger.sync.buddy2.entities as Dictionary<UserInfo>
)
),
this.store.pipe(
select(
(state: any) =>
state.messenger.sync.roomUserShort.entities as Dictionary<
RoomUserData
>
)
)
),
tap(([notiOrRes, curRoomInfo, roomList]) => {
tap(
([
notiOrRes,
curRoomInfo,
curRoomUserInfo,
roomList,
buddyList,
roomUserShorts
]) => {
switch (notiOrRes.SSVC_TYPE) {
case SSVC_TYPE_EVENT_SEND_RES:
case SSVC_TYPE_EVENT_SEND_NOTI:
@ -308,6 +347,76 @@ export class AppNotificationService {
appUserInfo.settings.notification
.alertExposureTime * 1000
};
// Sender Info setting
// STEP 1 >> In buddy group.
let senderInfo: any = buddyList[noti.SENDER_SEQ];
// STEP 2 >> In Current Room Users.
if (!senderInfo) {
senderInfo = curRoomUserInfo[noti.SENDER_SEQ];
}
// STEP 3 >> In All Room Users.
if (!senderInfo) {
for (const key in roomUserShorts) {
if (key === undefined) {
continue;
}
if (roomUserShorts.hasOwnProperty(key)) {
const element = roomUserShorts[key];
const filteredUserInfos = element.userInfos.filter(
info => info.seq === noti.SENDER_SEQ
);
if (
!!filteredUserInfos &&
filteredUserInfos.length > 0
) {
senderInfo = filteredUserInfos[0];
break;
}
}
}
}
// Sender Info setting.
if (!!senderInfo) {
// name set
let name = senderInfo.name;
let grade = senderInfo.grade;
switch (
this.ucapTranslateService.currentLang.toUpperCase()
) {
case LocaleCode.English:
name = senderInfo.nameEn;
grade = senderInfo.gradeEn;
break;
case LocaleCode.Chinese:
name = senderInfo.nameCn;
grade = senderInfo.gradeCn;
break;
}
notiReq.title = this.translateService.instant(
'notification.titleChatEventArrivedByUser',
{
userInfo: !!grade ? `${name} ${grade}` : name
}
);
// Image set.
if (!!senderInfo.profileImageFile) {
const sessionVerinfo = this.sessionStorageService.get<
VersionInfo2Response
>(KEY_VER_INFO);
notiReq.image = `${sessionVerinfo.profileRoot}${senderInfo.profileImageFile}`;
}
}
// express noti popup
this.nativeService.notify(notiReq);
}
}
@ -359,7 +468,8 @@ export class AppNotificationService {
default:
break;
}
})
}
)
)
.subscribe();
this.infoProtocolService.notification$

View File

@ -383,7 +383,9 @@
"label": "Update"
},
"notification": {
"titleChatEventArrivedByUser": "A Message of chat from {{userInfo}}.",
"titleChatEventArrived": "A message of chat has arrived.",
"titleMessageArrivedByUser": "A Message from {{userInfo}}.",
"titleMessageArrived": "A message has arrived."
},
"common": {

View File

@ -383,7 +383,9 @@
"label": "업데이트"
},
"notification": {
"titleChatEventArrivedByUser": "{{userInfo}} 님의 메세지.",
"titleChatEventArrived": "메세지가 도착했습니다.",
"titleMessageArrivedByUser": "{{userInfo}} 님의 쪽지.",
"titleMessageArrived": "쪽지가 도착했습니다."
},
"common": {

View File

@ -22,7 +22,7 @@ export interface UserSeqRequest extends ProtocolRequest {
// 기관코드(s)
companyCode: string;
// 상세정보여부(s)
isDetail: boolean;
detailType: string;
// 발신자회사코드(s)
senderCompanyCode: string;
// 발신자임직원유형(s)
@ -51,7 +51,7 @@ export const encodeUserSeq: ProtocolEncoder<UserSeqRequest> = (
{ type: PacketBodyValue.String, value: req.divCd },
{ type: PacketBodyValue.String, value: req.loginIds.join(',') },
{ type: PacketBodyValue.String, value: req.companyCode },
{ type: PacketBodyValue.String, value: req.isDetail ? 'Y' : 'N' },
{ type: PacketBodyValue.String, value: req.detailType },
{ type: PacketBodyValue.String, value: req.senderCompanyCode },
{ type: PacketBodyValue.String, value: req.senderEmployeeType }
);