diff --git a/projects/ucap-webmessenger-api-message/src/lib/apis/event-download.ts b/projects/ucap-webmessenger-api-message/src/lib/apis/event-download.ts new file mode 100644 index 00000000..fc4fb8b0 --- /dev/null +++ b/projects/ucap-webmessenger-api-message/src/lib/apis/event-download.ts @@ -0,0 +1,40 @@ +import { DeviceType } from '@ucap-webmessenger/core'; +import { + APIRequest, + APIEncoder, + ParameterUtil, + APIFormDataEncoder +} from '@ucap-webmessenger/api'; +import { FileDownloadItem } from '../../../../ucap-webmessenger-api/src/lib/models/file-download-item'; + +export interface EventDownloadRequest extends APIRequest { + userSeq: number; + deviceType: DeviceType; + token: string; + roomSeq: string; +} + +const eventDownloadEncodeMap = { + userSeq: 'userSeq', + deviceType: 'deviceType', + token: 'tokenKey', + roomSeq: 'roomSeq' +}; + +export const encodeEventDownload: APIEncoder = ( + req: EventDownloadRequest +) => { + const extraParams: any = {}; + extraParams.roomSeq = Number(req.roomSeq); + + return ParameterUtil.encode(eventDownloadEncodeMap, req, extraParams); +}; + +export const encodeFormDataEventDownload: APIFormDataEncoder = ( + req: EventDownloadRequest +) => { + const extraParams: any = {}; + extraParams.roomSeq = Number(req.roomSeq); + + return ParameterUtil.encodeFormData(eventDownloadEncodeMap, req, extraParams); +}; diff --git a/projects/ucap-webmessenger-api-message/src/lib/config/urls.ts b/projects/ucap-webmessenger-api-message/src/lib/config/urls.ts index 10773f4d..421bcf53 100644 --- a/projects/ucap-webmessenger-api-message/src/lib/config/urls.ts +++ b/projects/ucap-webmessenger-api-message/src/lib/config/urls.ts @@ -47,4 +47,7 @@ export interface Urls { /** 공지 조회 */ retrieveNoticeList: string; + + /** Event Download */ + eventDownload: string; } 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 f43d5bc2..737d37db 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 @@ -7,7 +7,7 @@ import { HttpEventType } from '@angular/common/http'; -import { Observable } from 'rxjs'; +import { Observable, Subject } from 'rxjs'; import { map, filter } from 'rxjs/operators'; import { _MODULE_CONFIG } from '../config/token'; @@ -97,6 +97,10 @@ import { encodeRetrieveNotice, decodeRetrieveNotice } from '../apis/notice'; +import { + EventDownloadRequest, + encodeFormDataEventDownload +} from '../apis/event-download'; @Injectable({ providedIn: 'root' @@ -357,4 +361,27 @@ export class MessageApiService { }) .pipe(map(res => decodeRetrieveNotice(res))); } + + /** Event Download for Room */ + public eventDownload(req: EventDownloadRequest): Observable { + const httpReq = new HttpRequest( + 'POST', + this.urls.eventDownload, + encodeFormDataEventDownload(req), + { reportProgress: true, responseType: 'blob' } + ); + + return this.httpClient.request(httpReq).pipe( + filter(event => { + if (event instanceof HttpResponse) { + return true; + } else if (HttpEventType.DownloadProgress === event.type) { + } + return false; + }), + map((event: HttpResponse) => { + return event.body; + }) + ); + } } diff --git a/projects/ucap-webmessenger-api-message/src/public-api.ts b/projects/ucap-webmessenger-api-message/src/public-api.ts index bf19e2c9..9b5e6747 100644 --- a/projects/ucap-webmessenger-api-message/src/public-api.ts +++ b/projects/ucap-webmessenger-api-message/src/public-api.ts @@ -4,6 +4,7 @@ export * from './lib/apis/del'; export * from './lib/apis/detail'; export * from './lib/apis/edit-reservation-ex'; +export * from './lib/apis/event-download'; export * from './lib/apis/my-message'; export * from './lib/apis/notice'; export * from './lib/apis/retrieve'; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html index 39c1615b..2774fbf6 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html @@ -310,6 +310,13 @@ > {{ 'chat.searchEventByText' | translate }} +