From 697aa2ac0730f51853f932cc87441ba21e43325e Mon Sep 17 00:00:00 2001 From: leejinho Date: Thu, 28 Nov 2019 17:30:43 +0900 Subject: [PATCH] =?UTF-8?q?=EC=AA=BD=EC=A7=80=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20::=20=EC=83=81=EC=84=B8=EB=B3=B4=EA=B8=B0,?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C,=20=EC=9D=BD=EC=9D=8C=ED=99=95=EC=9D=B8,?= =?UTF-8?q?=20=EB=B0=9C=EC=86=A1=EC=B7=A8=EC=86=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/lib/models/detail-content.ts | 2 + .../src/lib/services/message-api.service.ts | 25 +- .../left-sidenav/message.component.ts | 104 ++++- .../message-detail.dialog.component.html | 248 +++++++--- .../message-detail.dialog.component.scss | 9 + .../message-detail.dialog.component.ts | 441 ++++++++++++++++-- .../messenger/messenger.layout.module.ts | 4 +- .../src/environments/environment.dev.ts | 2 +- 8 files changed, 691 insertions(+), 144 deletions(-) diff --git a/projects/ucap-webmessenger-api-message/src/lib/models/detail-content.ts b/projects/ucap-webmessenger-api-message/src/lib/models/detail-content.ts index 1fc4f3d7..d6601a1a 100644 --- a/projects/ucap-webmessenger-api-message/src/lib/models/detail-content.ts +++ b/projects/ucap-webmessenger-api-message/src/lib/models/detail-content.ts @@ -18,4 +18,6 @@ export interface DetailContent { thumbnailNm?: string; thumbnailSeq?: number; thumbnailUrl?: string; + + imageSrc?: any; } diff --git a/projects/ucap-webmessenger-api-message/src/lib/services/message-api.service.ts b/projects/ucap-webmessenger-api-message/src/lib/services/message-api.service.ts index 874d0742..deaecc71 100644 --- a/projects/ucap-webmessenger-api-message/src/lib/services/message-api.service.ts +++ b/projects/ucap-webmessenger-api-message/src/lib/services/message-api.service.ts @@ -3,7 +3,8 @@ import { HttpClient, HttpHeaders, HttpRequest, - HttpResponse + HttpResponse, + HttpEventType } from '@angular/common/http'; import { Observable } from 'rxjs'; @@ -215,6 +216,7 @@ export class MessageApiService { encodeRetrieveResourceFile(req), { headers: this.headers, + reportProgress: true, responseType: 'blob' } ); @@ -222,6 +224,7 @@ export class MessageApiService { filter(event => { if (event instanceof HttpResponse) { return true; + } else if (HttpEventType.DownloadProgress === event.type) { } return false; }), @@ -229,26 +232,6 @@ export class MessageApiService { return event.body; }) ); - // return this.httpClient - // .post( - // this.urls.retrieveResourceFile, - // encodeRetrieveResourceFile(req), - // { - // headers: this.headers - // } - // ) - // .pipe(map(res => decodeRetrieveResourceFile(res))); - } - public urlForFileMessageDownload(req: RetrieveResourceFileRequest): string { - const httpReq = new HttpRequest( - 'POST', - this.urls.retrieveResourceFile, - encodeRetrieveResourceFile(req), - { - headers: this.headers - } - ); - return httpReq.urlWithParams; } /** del */ diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/message.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/message.component.ts index 06de155e..fcca0d21 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/message.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/message.component.ts @@ -29,7 +29,10 @@ import { MessageList, RetrieveSearchRequest, MessageSearchType, - DetailRequest + DetailRequest, + MessageDetailInfo, + DelRequest, + CancelReservationRequest } from '@ucap-webmessenger/api-message'; import { DeviceType } from '@ucap-webmessenger/core'; import { MessageStatusCode } from '@ucap-webmessenger/api'; @@ -75,7 +78,8 @@ export class MessageBoxComponent messageReservationListSubscription: Subscription; messageSearchListSubscription: Subscription; - defaultPageSize = 100; // default + currentTabIndex = 0; + defaultPageSize = 1000; // default recieveCurrentPage = 0; // start index is 0. sendCurrentPage = 0; // start index is 0. reservationCurrentPage = 0; // start index is 0. @@ -146,31 +150,30 @@ export class MessageBoxComponent } onSelectedIndexChange(value: number) { + this.currentTabIndex = value; + let type: MessageType; switch (value) { case 0: - { - // Recieve - this.getRetrieveMessage(MessageType.Receive, this.recieveCurrentPage); - } + // Recieve + type = MessageType.Receive; + this.recieveCurrentPage = 0; break; case 1: - { - // Send - this.getRetrieveMessage(MessageType.Send, this.sendCurrentPage); - } + // Send + type = MessageType.Send; + this.sendCurrentPage = 0; break; case 2: - { - // Reservation - this.getRetrieveMessage( - MessageType.Reservation, - this.reservationCurrentPage - ); - } + // Reservation + type = MessageType.Reservation; + this.reservationCurrentPage = 0; break; } + + this.getRetrieveMessage(type, 0); } + /** 쪽지 검색 관련 */ onChangeSelection(event: MatSelectChange) { this.searchCurrentPage = 0; this.getSearchMessage( @@ -233,12 +236,12 @@ export class MessageBoxComponent ) .subscribe(); } - onClickSearchCancel() { this.isSearch = false; this.getRetrieveMessage(MessageType.Receive, this.recieveCurrentPage); } + /** 쪽지 타입별 조회 */ getRetrieveMessage(type: MessageType, trgtPageIndex: number) { switch (type) { case MessageType.Receive: @@ -322,6 +325,7 @@ export class MessageBoxComponent } } + /** 쪽지 상세보기 */ onClickDetail(message: MessageList) { this.messageApiService .detailMessage({ @@ -352,8 +356,18 @@ export class MessageBoxComponent } }); - // if (!!result && !!result.choice && result.choice) { - // } + if (!!result) { + switch (result.returnType) { + case 'DEL': + // 단건 삭제. + this.doMessageDelete([result.messageInfo]); + break; + case 'CANCEL_RESERVATION': + // 단건 발송취소(예약) + this.doMessageCancelReservation(result.messageInfo); + break; + } + } } else { } }), @@ -361,4 +375,54 @@ export class MessageBoxComponent ) .subscribe(); } + + /** 쪽지(수신,발신) 삭제 */ + doMessageDelete(messageInfo: MessageDetailInfo[]): void { + const msgList: { msgId: number }[] = []; + messageInfo.forEach(info => msgList.push({ msgId: info.msgId })); + this.messageApiService + .deleteMessage({ + userSeq: this.loginRes.userSeq, + deviceType: DeviceType.PC, + tokenKey: this.loginRes.tokenString, + type: messageInfo[0].type, + msgList + } as DelRequest) + .pipe( + map(async res => { + if (res.responseCode === MessageStatusCode.Success) { + } else { + this.logger.error('message delete Error!'); + } + // 현재탭 재조회. + this.onSelectedIndexChange(this.currentTabIndex); + }), + catchError(error => of(this.logger.error(error))) + ) + .subscribe(); + } + + /** 쪽지(예약) 삭제 */ + doMessageCancelReservation(messageInfo: MessageDetailInfo): void { + this.messageApiService + .cancelReservationMessage({ + userSeq: this.loginRes.userSeq, + deviceType: DeviceType.PC, + tokenKey: this.loginRes.tokenString, + type: messageInfo.type, + msgId: messageInfo.msgId + } as CancelReservationRequest) + .pipe( + map(async res => { + if (res.responseCode === MessageStatusCode.Success) { + } else { + this.logger.error('message(reservation) cancel Error!'); + } + // 현재탭 재조회. + this.onSelectedIndexChange(this.currentTabIndex); + }), + catchError(error => of(this.logger.error(error))) + ) + .subscribe(); + } } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.html index 1b983152..5b99d12d 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.html @@ -9,74 +9,204 @@ -
-
- {{ messageInfo.title }} - - - -
-
-
    -
  • - 보낸사람 +
    +
    + {{ messageInfo.title }} + +
  • -
  • - 받은시간 - {{ - messageInfo.regDate - | dateToStringFormat: 'YYYY.MM.dd (KS) a/p HH:mm' - }} -
  • -
-
-
-
    -
  • -
    {{
    -              cont.resContent
    -            }}
    - -
  • -
-
-
-
-
- 기간이 만료된 파일입니다 - -
- + +
+
    -
  • -
    - - {{ file.resContent }} - {{ file.resSize | ucapBytes }} - -
    +
  • + 보낸사람 + 받는사람 + {{ getSendReceiverNames() }} +
  • +
  • + 받은시간 + {{ + messageInfo.regDate + | dateToStringFormat: 'YYYY.MM.dd (KS) a/p HH:mm' + }}
+ +
+
    +
  • +
    {{
    +                  cont.resContent
    +                }}
    + +
  • +
+
+
+
+
+
+ 기간이 만료된 파일입니다 + +
+ +
    +
  • +
    + + {{ file.resContent }} + {{ file.resSize | ucapBytes }} + + + +
    +
  • +
+
+
-
+ + + + + + 읽은 사람 {{ getReadUserCount(true) }} + + + + + {{ user.userName }} + {{ + user.readDate | dateToStringFormat: 'YYYY-MM-DD HH:mm:ss' + }} + + + + + + + 읽지 않은 사람 {{ getReadUserCount(true) }} + +
    +
    + 전체선택 + + +
    + + + + {{ user.userName }} + + + +
    + +
    +
+
+
+
+
- + + + + + + + + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.scss b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.scss index 25e3cb70..b2381d03 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.scss +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.scss @@ -16,3 +16,12 @@ ::ng-deep .mat-mini-fab .mat-button-wrapper { padding: 0; } + +.contents { + height: 380px; + + .thumbnail { + max-width: 250px; + max-height: 250px; + } +} diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.ts index 22560805..8b1e1fb3 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-detail.dialog.component.ts @@ -3,7 +3,8 @@ import { MatDialogRef, MAT_DIALOG_DATA, MatSelectionList, - MatSelectionListChange + MatSelectionListChange, + MatDrawer } from '@angular/material'; import { Observable, combineLatest, of } from 'rxjs'; import { Store, select } from '@ngrx/store'; @@ -16,23 +17,29 @@ import { DialogService, ConfirmDialogComponent, ConfirmDialogData, - ConfirmDialogResult + ConfirmDialogResult, + SnackBarService, + AlertDialogComponent, + AlertDialogResult, + AlertDialogData } from '@ucap-webmessenger/ui'; import { GroupDetailData, UserInfo } from '@ucap-webmessenger/protocol-sync'; import { DetailResponse, MessageType, - MessageList, DetailContent, DetailReceiver, ContentType, MessageDetailInfo, MessageApiService, - RetrieveResourceFileRequest + RetrieveResourceFileRequest, + CancelRequest } from '@ucap-webmessenger/api-message'; -import { DeviceType } from '@ucap-webmessenger/core'; +import { DeviceType, MimeUtil, FileUtil } from '@ucap-webmessenger/core'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { NGXLogger } from 'ngx-logger'; +import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native'; +import { MessageStatusCode } from '@ucap-webmessenger/api'; export interface MessageDetailDialogData { detail: DetailResponse; @@ -40,7 +47,15 @@ export interface MessageDetailDialogData { } // tslint:disable-next-line: no-empty-interface -export interface MessageDetailDialogResult {} +export interface MessageDetailDialogResult { + returnType: string; + messageInfo?: MessageDetailInfo; + cancelUserSeqs?: number[]; +} + +export interface DownloadQueueForMessage extends DetailContent { + downloadType: string; +} @Component({ selector: 'app-layout-messenger-message-detail', @@ -59,13 +74,22 @@ export class MessageDetailDialogComponent implements OnInit { MessageType = MessageType; ContentType = ContentType; + downloadProgress = false; + downloadQueue: DownloadQueueForMessage[] = []; + downloadFail: DownloadQueueForMessage[] = []; + + @ViewChild('rightDrawer', { static: true }) rightDrawer: MatDrawer; + @ViewChild('unReadUsers', { static: false }) unReadUsers: MatSelectionList; + constructor( public dialogRef: MatDialogRef< MessageDetailDialogData, MessageDetailDialogResult >, @Inject(MAT_DIALOG_DATA) public data: MessageDetailDialogData, + @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, private messageApiService: MessageApiService, + private snackBarService: SnackBarService, private logger: NGXLogger, private store: Store, private dialogService: DialogService @@ -91,52 +115,385 @@ export class MessageDetailDialogComponent implements OnInit { }); } - this.receivers = this.messageDetail.recvList; + // contents 내 이미지 Thumnail 파일 정보 수집. + this.getThumbImage(); + + this.receivers = this.messageDetail.recvList.sort((a, b) => + a.userName < b.userName ? -1 : a.userName > b.userName ? 1 : 0 + ); } - getThumbImage(content: DetailContent): string { - console.log( - JSON.stringify({ + getSendReceiverNames(): string { + if (this.messageInfo.type === MessageType.Receive) { + return this.messageInfo.sendUserName; + } else { + return this.receivers.map(user => user.userName).join(','); + } + } + + getReadUserCount(readYn: boolean): number { + return this.receivers.filter(user => user.readYn === readYn).length; + } + + getFileStatusIcon(file: DetailContent) { + const downloading = + this.downloadQueue.filter(dq => dq.resSeq === file.resSeq).length > 0; + const error = + this.downloadFail.filter(df => df.resSeq === file.resSeq).length > 0; + + if (error) { + return 'mdi-window-close'; + } else if (downloading) { + return ['mdi-spin', 'mdi-loading']; + } else { + return 'mdi-attachment'; + } + } + + getThumbImage(): void { + this.contents.forEach(content => { + if (content.resType === ContentType.Image) { + this.messageApiService + .retrieveResourceFile({ + userSeq: this.data.loginRes.userSeq, + deviceType: DeviceType.PC, + tokenKey: this.data.loginRes.tokenString, + type: this.messageInfo.type, + msgId: this.messageInfo.msgId, + resUrl: content.thumbnailUrl + } as RetrieveResourceFileRequest) + .pipe( + take(1), + map(async rawBlob => { + const reader = new FileReader(); + reader.readAsDataURL(rawBlob); + reader.onloadend = () => { + content.imageSrc = reader.result; + }; + }) + ) + .subscribe(); + } + }); + } + + // /** + // * @deprecated + // */ + // downloadAttachFile(attachFile: DetailContent): void { + // this.messageApiService + // .retrieveResourceFile({ + // userSeq: this.data.loginRes.userSeq, + // deviceType: DeviceType.PC, + // tokenKey: this.data.loginRes.tokenString, + // type: this.messageInfo.type, + // msgId: this.messageInfo.msgId, + // resUrl: attachFile.resUrl + // } as RetrieveResourceFileRequest) + // .pipe( + // take(1), + // map(async rawBlob => { + // const mimeType = MimeUtil.getMimeFromExtension( + // FileUtil.getExtension(attachFile.resContent) + // ); + // const blob = rawBlob.slice(0, rawBlob.size, mimeType); + + // FileUtil.fromBlobToBuffer(blob) + // .then(buffer => { + // this.nativeService + // .saveFile(buffer, attachFile.resContent, mimeType) + // .then(result => { + // if (!!result) { + // if (this.downloadFail.length > 0) { + // this.downloadFail = this.downloadFail.filter( + // df => df.resSeq !== attachFile.resSeq + // ); + // } + + // this.snackBarService.open( + // `파일이 경로[${result}]에 저장되었습니다.`, + // '', + // { + // duration: 3000, + // verticalPosition: 'bottom' + // } + // ); + // } else { + // this.snackBarService.open('파일 저장에 실패하였습니다.'); + // } + // }) + // .catch(reason => { + // this.snackBarService.open('파일 저장에 실패하였습니다.'); + // }); + // }) + // .catch(reason => { + // this.logger.error('download', reason); + // }); + // }) + // ) + // .subscribe(); + // } + downloadAttachFileSingle(attachFile: DetailContent): void { + if (!this.downloadProgress) { + this.downloadProgress = true; + this.downloadQueue = [{ ...attachFile, downloadType: 'SINGLE' }]; + this.downloadFail = []; + if (!!this.downloadQueue && this.downloadQueue.length > 0) { + this.downloadAttachFileByQueue(); + } + } else { + if ( + this.downloadQueue.filter(dq => dq.resSeq === attachFile.resSeq) + .length === 0 + ) { + this.downloadQueue.push({ ...attachFile, downloadType: 'SINGLE' }); + } + } + } + downloadAttachFileAll(): void { + if (!this.downloadProgress) { + this.downloadProgress = true; + this.downloadQueue = []; + this.downloadFail = []; + this.attachFile.forEach(file => + this.downloadQueue.push({ ...file, downloadType: '' }) + ); + if (!!this.downloadQueue && this.downloadQueue.length > 0) { + this.downloadAttachFileByQueue(); + } + } else { + this.dialogService.open< + AlertDialogComponent, + AlertDialogData, + AlertDialogResult + >(AlertDialogComponent, { + data: { + title: '', + html: `다운로드가 진행중입니다.` + } + }); + } + } + downloadAttachFileByQueue(): void { + const attachFile = this.downloadQueue[0]; + this.messageApiService + .retrieveResourceFile({ userSeq: this.data.loginRes.userSeq, deviceType: DeviceType.PC, tokenKey: this.data.loginRes.tokenString, type: this.messageInfo.type, msgId: this.messageInfo.msgId, - resUrl: content.thumbnailUrl - }) - ); - if (content.resType === ContentType.Image) { - // // return this.messageApiService.urlForFileMessageDownload({ - // // userSeq: this.data.loginRes.userSeq, - // // deviceType: DeviceType.PC, - // // tokenKey: this.data.loginRes.tokenString, - // // type: this.messageInfo.type, - // // msgId: this.messageInfo.msgId, - // // resUrl: content.thumbnailUrl - // // } as RetrieveResourceFileRequest); - // this.messageApiService - // .retrieveResourceFile({ - // userSeq: this.data.loginRes.userSeq, - // deviceType: DeviceType.PC, - // tokenKey: this.data.loginRes.tokenString, - // type: this.messageInfo.type, - // msgId: this.messageInfo.msgId, - // resUrl: content.thumbnailUrl - // } as RetrieveResourceFileRequest) - // .pipe( - // take(1), - // map(async rawBlob => { - // console.log(rawBlob); - // return URL.createObjectURL(rawBlob); - // }) - // ) - // .subscribe(); - } else { - return ''; + resUrl: attachFile.resUrl + } as RetrieveResourceFileRequest) + .pipe( + take(1), + map(async rawBlob => { + const mimeType = MimeUtil.getMimeFromExtension( + FileUtil.getExtension(attachFile.resContent) + ); + const blob = rawBlob.slice(0, rawBlob.size, mimeType); + + FileUtil.fromBlobToBuffer(blob) + .then(buffer => { + this.nativeService + .saveFile(buffer, attachFile.resContent, mimeType) + .then(result => { + if (!!result) { + if ( + !!attachFile.downloadType && + attachFile.downloadType === 'SINGLE' + ) { + attachFile.downloadType = result; + } + + if (this.downloadQueue.length > 1) { + this.downloadQueue = this.downloadQueue.slice(1); + } else { + this.downloadQueue = []; + } + } else { + throw new Error('response Error'); + } + }) + .catch(reason => { + this.downloadFail.push(this.downloadQueue[0]); + + if (this.downloadQueue.length > 1) { + this.downloadQueue = this.downloadQueue.slice(1); + } else { + this.downloadQueue = []; + } + }); + }) + .catch(reason => { + this.downloadFail.push(this.downloadQueue[0]); + + if (this.downloadQueue.length > 1) { + this.downloadQueue = this.downloadQueue.slice(1); + } else { + this.downloadQueue = []; + } + }) + .finally(() => { + if (this.downloadQueue.length > 0) { + // 재귀 + this.downloadAttachFileByQueue(); + } else { + if (this.downloadFail.length > 0) { + // 일부 혹은 전부 실패. + let errMsg = ''; + if ( + !!attachFile.downloadType && + attachFile.downloadType === 'SINGLE' + ) { + // single :: fail + errMsg = '파일 저장에 실패하였습니다.'; + } else { + // all + errMsg = '일부 저장중 오류가 발생하였습니다.'; + } + this.snackBarService.open(errMsg, '확인', { + duration: 8000, + verticalPosition: 'bottom' + }); + } else { + // 성공종료. + if ( + !!attachFile.downloadType && + attachFile.downloadType.length > 0 + ) { + // single :: success + this.snackBarService.open( + `파일이 경로[${attachFile.downloadType}]에 저장되었습니다.`, + '', + { + duration: 3000, + verticalPosition: 'bottom' + } + ); + } else { + // all + this.snackBarService.open('모두 저장하였습니다.', '', { + duration: 3000, + verticalPosition: 'bottom' + }); + } + } + this.downloadProgress = false; + } + }); + }) + ) + .subscribe(); + } + + async onClickMessageMenu(menuType: string) { + switch (menuType) { + case 'MESSAGE_READ': + { + this.rightDrawer.open(); + } + break; + case 'MESSAGE_CANCEL': + { + const result = await this.dialogService.open< + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult + >(ConfirmDialogComponent, { + data: { + title: '발송취소', + html: `예약발송을 취소 하시겠습니까?
취소하면 목록에서도 영구 삭제됩니다.` + } + }); + + if (!!result && !!result.choice && result.choice) { + this.dialogRef.close({ + returnType: 'CANCEL_RESERVATION', + messageInfo: this.messageInfo + }); + } + } + break; + case 'MESSAGE_DEL': + { + const result = await this.dialogService.open< + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult + >(ConfirmDialogComponent, { + data: { + title: '삭제', + message: '선택한 쪽지를 삭제하시겠습니까?' + } + }); + + if (!!result && !!result.choice && result.choice) { + this.dialogRef.close({ + returnType: 'DEL', + messageInfo: this.messageInfo + }); + } + } + break; + } + } + + async cancelSendMessageForUsers() { + if ( + !!this.unReadUsers && + this.unReadUsers.selectedOptions.selected.length > 0 + ) { + const result = await this.dialogService.open< + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult + >(ConfirmDialogComponent, { + data: { + title: '발송 취소', + message: + '발송 취소를 하시면 받는 사람의 쪽지함에서 쪽지가 삭제됩니다.' + } + }); + + if (!!result && !!result.choice && result.choice) { + const cancelUserSeqs: number[] = []; + const recvUserList: { userSeq: number }[] = []; + this.unReadUsers.selectedOptions.selected.forEach(selected => { + cancelUserSeqs.push(selected.value); + recvUserList.push({ userSeq: selected.value }); + }); + + this.messageApiService + .cancelMessage({ + userSeq: this.data.loginRes.userSeq, + deviceType: DeviceType.PC, + tokenKey: this.data.loginRes.tokenString, + type: this.messageInfo.type, + msgId: this.messageInfo.msgId, + recvUserList + } as CancelRequest) + .pipe( + map(async res => { + if (res.responseCode === MessageStatusCode.Success) { + this.receivers = this.receivers.filter( + user => cancelUserSeqs.indexOf(user.userSeq) < 0 + ); + this.rightDrawer.close(); + } else { + this.logger.error('message cancel user Error!'); + } + }), + catchError(error => of(this.logger.error(error))) + ) + .subscribe(); + } } } onClickConfirm(): void { - this.dialogRef.close({}); + this.dialogRef.close({ + returnType: 'CLOSE' + }); } } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts index 2c5422fc..beb584df 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts @@ -28,7 +28,8 @@ import { MatPaginatorModule, MatRippleModule, MatSortModule, - MatTooltipModule + MatTooltipModule, + MatSidenavModule } from '@angular/material'; import { MatListModule } from '@angular/material/list'; import { MatChipsModule } from '@angular/material/chips'; @@ -83,6 +84,7 @@ import { DIALOGS } from './dialogs'; MatPaginatorModule, MatRippleModule, MatTooltipModule, + MatSidenavModule, PerfectScrollbarModule, diff --git a/projects/ucap-webmessenger-app/src/environments/environment.dev.ts b/projects/ucap-webmessenger-app/src/environments/environment.dev.ts index 1eee7899..5dfc4a26 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.dev.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.dev.ts @@ -45,7 +45,7 @@ export const environment: Environment = { hostConfig: { protocol: 'http', domain: '27.122.224.170', - port: 9097 + port: 9098 }, urls: messageApiUrls },