diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/organization.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/organization.component.ts index 37427654..fd88af46 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/organization.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/organization.component.ts @@ -439,6 +439,10 @@ export class OrganizationComponent /** 전체 체크여부 */ getCheckedAllUser() { + if (!this.loginRes) { + return false; + } + const compareList: UserInfoSS[] = this.isShowSearch ? this.searchUserInfos : this.selectedDepartmentUserInfoList; diff --git a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts index bd44be2a..927a7459 100644 --- a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts @@ -116,6 +116,19 @@ import { LogoutInfo, KEY_LOGOUT_INFO } from '@app/types'; import { TranslateService } from '@ngx-translate/core'; import { deleteMessageSuccess } from '@app/store/messenger/message'; import { ServerErrorCode } from '@ucap-webmessenger/protocol'; +import { + OptionProtocolService, + SSVC_TYPE_OPTION_REG_UPD_RES, + RegUpdateResponse, + RegUpdateNotification +} from '@ucap-webmessenger/protocol-option'; +import { + GeneralSetting, + Settings, + NotificationSetting, + ChatSetting +} from '@ucap-webmessenger/ui-settings'; +import clone from 'clone'; @Injectable() export class AppNotificationService { @@ -128,6 +141,7 @@ export class AppNotificationService { private buddyProtocolService: BuddyProtocolService, private statusProtocolService: StatusProtocolService, private translateService: TranslateService, + private optionProtocolService: OptionProtocolService, private umgProtocolService: UmgProtocolService, private localStorageService: LocalStorageService, private sessionStorageService: SessionStorageService, @@ -643,6 +657,56 @@ export class AppNotificationService { }) ) .subscribe(); + this.optionProtocolService.notification$ + .pipe( + tap(notiOrRes => { + switch (notiOrRes.SSVC_TYPE) { + case SSVC_TYPE_OPTION_REG_UPD_RES: + { + const noti = notiOrRes as RegUpdateNotification; + this.logger.debug( + 'Notification::optionProtocolService::RegUpdateNotification', + noti + ); + + const appUserInfo: AppUserInfo = this.localStorageService.encGet< + AppUserInfo + >(KEY_APP_USER_INFO, environment.customConfig.appKey); + + const modifiedSettings: Settings = clone(appUserInfo.settings); + modifiedSettings.notification.method = noti.notificationMethod; + modifiedSettings.notification.method = noti.notificationMethod0; + modifiedSettings.notification.receiveForMobile = + noti.mobileNotification; + modifiedSettings.notification.use = noti.receiveNotification; + modifiedSettings.notification.alertExposureTime = + noti.notificationExposureTime; + + modifiedSettings.chat.fontFamily = noti.fontFamily; + modifiedSettings.chat.fontSize = noti.fontSize; + + modifiedSettings.presence.absenceTime = noti.absenceTime; + + modifiedSettings.general.timezone = noti.timeZone; + modifiedSettings.general.locale = noti.menuLanguage; + modifiedSettings.general.hrInfoLocale = + noti.hrInformationLanguage; + + appUserInfo.settings = modifiedSettings; + + this.localStorageService.encSet( + KEY_APP_USER_INFO, + appUserInfo, + environment.customConfig.appKey + ); + } + break; + default: + break; + } + }) + ) + .subscribe(); this.umgProtocolService.notification$ .pipe( tap(notiOrRes => { diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/protocols/reg-update.ts b/projects/ucap-webmessenger-protocol-option/src/lib/protocols/reg-update.ts index e4160f89..41c5238e 100644 --- a/projects/ucap-webmessenger-protocol-option/src/lib/protocols/reg-update.ts +++ b/projects/ucap-webmessenger-protocol-option/src/lib/protocols/reg-update.ts @@ -8,7 +8,8 @@ import { ProtocolDecoder, ProtocolMessage, PacketBodyValue, - decodeProtocolMessage + decodeProtocolMessage, + ProtocolNotification } from '@ucap-webmessenger/protocol'; export interface RegUpdateRequest extends ProtocolRequest { @@ -70,6 +71,10 @@ export interface RegUpdateResponse extends ProtocolResponse { translationKey?: string; } +export interface RegUpdateNotification + extends RegUpdateResponse, + ProtocolNotification {} + export const encodeRegUpdate: ProtocolEncoder = ( req: RegUpdateRequest ) => { @@ -151,3 +156,24 @@ export const decodeRegUpdate: ProtocolDecoder = ( translationKey: message.bodyList[13] } as RegUpdateResponse); }; + +export const decodeRegUpdateNotification: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return decodeProtocolMessage(message, { + notificationMethod: message.bodyList[0] as NotificationMethod, + mobileNotification: message.bodyList[1] === 1 ? true : false, + fontFamily: message.bodyList[2], + fontSize: message.bodyList[3], + receiveNotification: message.bodyList[4] === 1 ? true : false, + notificationMethod0: message.bodyList[5], + notificationExposureTime: message.bodyList[6], + timeZone: message.bodyList[7], + timeZoneValue: message.bodyList[8], + absenceTime: message.bodyList[9], + menuLanguage: message.bodyList[10], + hrInformationLanguage: message.bodyList[11], + deviceType: message.bodyList[12], + translationKey: message.bodyList[13] + } as RegUpdateResponse); +}; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/services/option-protocol.service.ts b/projects/ucap-webmessenger-protocol-option/src/lib/services/option-protocol.service.ts index bcba489d..e49c27e4 100644 --- a/projects/ucap-webmessenger-protocol-option/src/lib/services/option-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-option/src/lib/services/option-protocol.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { take, map } from 'rxjs/operators'; +import { Observable, Subject } from 'rxjs'; +import { take, map, share, filter, tap } from 'rxjs/operators'; import { ProtocolService } from '@ucap-webmessenger/protocol'; import { @@ -11,7 +11,8 @@ import { SSVC_TYPE_OPTION_REG_VIEW_REQ, SSVC_TYPE_OPTION_REG_UPD_REQ, SSVC_TYPE_OPTION_CALL_VIEW_REQ, - SSVC_TYPE_OPTION_CALL_UPD_REQ + SSVC_TYPE_OPTION_CALL_UPD_REQ, + SSVC_TYPE_OPTION_REG_UPD_RES } from '../types/service'; import { encodeView, @@ -35,7 +36,9 @@ import { RegUpdateRequest, RegUpdateResponse, encodeRegUpdate, - decodeRegUpdate + decodeRegUpdate, + decodeRegUpdateNotification, + RegUpdateNotification } from '../protocols/reg-update'; import { CallViewRequest, @@ -50,11 +53,38 @@ import { decodeCallUpdate } from '../protocols/call-update'; +type Notifications = RegUpdateNotification; + @Injectable({ providedIn: 'root' }) export class OptionProtocolService { - constructor(private protocolService: ProtocolService) {} + private notificationSubject: Subject; + public notification$: Observable; + + constructor(private protocolService: ProtocolService) { + this.notificationSubject = new Subject(); + this.notification$ = this.notificationSubject.asObservable().pipe(share()); + + this.protocolService.serverMessage + .pipe( + filter(message => message.serviceType === SVC_TYPE_OPTION), + tap(message => { + switch (message.subServiceType) { + case SSVC_TYPE_OPTION_REG_UPD_RES: + { + this.notificationSubject.next( + decodeRegUpdateNotification(message) + ); + } + break; + default: + break; + } + }) + ) + .subscribe(); + } public view(req: ViewRequest): Observable { return this.protocolService