From 568ff48268a7d3e4d140e1146869726b431c1a0a Mon Sep 17 00:00:00 2001 From: Richard Park Date: Wed, 13 Nov 2019 15:28:33 +0900 Subject: [PATCH] progress bar of file down is modified --- .../ucap-webmessenger-electron/src/index.ts | 3 +- package-lock.json | 9 ++ .../dialogs/file-viewer.dialog.component.html | 7 +- .../dialogs/file-viewer.dialog.component.ts | 36 +++--- .../components/messages.component.ts | 1 - .../store/account/authentication/effects.ts | 37 +++--- .../src/lib/utils/file.util.ts | 107 ++++++++++++++++++ .../lib/services/browser-native.service.ts | 37 +++--- .../src/lib/translate/browser-loader.ts | 20 ++-- .../lib/services/electron-native.service.ts | 32 +++--- .../src/lib/translate/electron-loader.ts | 20 ++-- .../src/lib/services/native.service.ts | 7 +- .../src/lib/services/protocol.service.ts | 8 +- .../lib/components/file-viewer.component.html | 10 +- .../lib/components/file-viewer.component.ts | 9 +- .../file-viewer/binary-viewer.component.html | 5 + .../file-viewer/binary-viewer.component.ts | 10 +- .../document-viewer.component.html | 5 + .../file-viewer/document-viewer.component.ts | 12 +- .../file-viewer/image-viewer.component.html | 103 ++++++++++++++--- .../file-viewer/image-viewer.component.ts | 14 ++- .../file-viewer/sound-viewer.component.html | 5 + .../file-viewer/sound-viewer.component.ts | 11 +- .../file-viewer/video-viewer.component.html | 51 +++++++-- .../file-viewer/video-viewer.component.ts | 11 +- 25 files changed, 422 insertions(+), 148 deletions(-) diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts index 3e6f4e12..c0edd838 100644 --- a/electron-projects/ucap-webmessenger-electron/src/index.ts +++ b/electron-projects/ucap-webmessenger-electron/src/index.ts @@ -241,8 +241,9 @@ ipcMain.on( try { const buffer: Buffer = args[0]; const fileName: string = args[1]; + const mimeType: string = args[2]; let savePath: string = path.join( - !!args[2] ? args[2] : DefaultFolder.downloads(), + !!args[3] ? args[3] : DefaultFolder.downloads(), fileName ); savePath = await FileUtil.uniqueFileName(savePath); diff --git a/package-lock.json b/package-lock.json index 1cf3217b..c7ce56cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2789,6 +2789,15 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, + "angular-split": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/angular-split/-/angular-split-3.0.2.tgz", + "integrity": "sha512-km59k1kEgVlplo2t4t5Ob43Vx16qVXWXsl5gbsdQtqrOW7341So4CFUmCjcZgfk1swu9RBaCdSQEqzNWOe/89w==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, "ansi-align": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz", diff --git a/projects/ucap-webmessenger-app/src/app/layouts/common/dialogs/file-viewer.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/common/dialogs/file-viewer.dialog.component.html index ff5c6c5e..0092f806 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/common/dialogs/file-viewer.dialog.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/common/dialogs/file-viewer.dialog.component.html @@ -1,11 +1,6 @@ - diff --git a/projects/ucap-webmessenger-app/src/app/layouts/common/dialogs/file-viewer.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/common/dialogs/file-viewer.dialog.component.ts index 82da29c2..4075c0aa 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/common/dialogs/file-viewer.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/common/dialogs/file-viewer.dialog.component.ts @@ -3,7 +3,7 @@ import { OnInit, OnDestroy, Inject, - EventEmitter + EventEmitter, } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; @@ -15,7 +15,7 @@ import { take, map, finalize, tap } from 'rxjs/operators'; import { SnackBarService } from '@ucap-webmessenger/ui'; import { FileDownloadItem, - CommonApiService + CommonApiService, } from '@ucap-webmessenger/api-common'; export interface FileViewerDialogData { @@ -31,7 +31,7 @@ export interface FileViewerDialogResult {} @Component({ selector: 'app-layout-common-file-viewer', templateUrl: './file-viewer.dialog.component.html', - styleUrls: ['./file-viewer.dialog.component.scss'] + styleUrls: ['./file-viewer.dialog.component.scss'], }) export class FileViewerDialogComponent implements OnInit, OnDestroy { fileInfo: FileEventJson; @@ -40,8 +40,6 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy { deviceType: DeviceType; token: string; - fileDownloadItem: FileDownloadItem; - fileDownloadUrl: string; constructor( @@ -66,7 +64,7 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy { userSeq: this.userSeq, deviceType: this.deviceType, token: this.token, - attachmentsSeq: this.fileInfo.attachmentSeq + attachmentsSeq: this.fileInfo.attachmentSeq, }, this.downloadUrl ); @@ -76,8 +74,7 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy { ngOnDestroy(): void {} - onDownload(): void { - this.fileDownloadItem = new FileDownloadItem(); + onDownload(fileDownloadItem: FileDownloadItem): void { this.commonApiService .fileTalkDownload( { @@ -85,37 +82,36 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy { deviceType: this.deviceType, token: this.token, attachmentsSeq: this.fileInfo.attachmentSeq, - fileDownloadItem: this.fileDownloadItem + fileDownloadItem, }, this.downloadUrl ) .pipe( take(1), map(async rawBlob => { - const blob = rawBlob.slice( - 0, - rawBlob.size, - MimeUtil.getMimeFromExtension(this.fileInfo.fileExt) - ); + const mimeType = MimeUtil.getMimeFromExtension(this.fileInfo.fileExt); + const blob = rawBlob.slice(0, rawBlob.size, mimeType); FileUtil.fromBlobToBuffer(blob) .then(buffer => { this.nativeService - .saveFile(buffer, this.fileInfo.fileName) - .pipe(take(1)) - .subscribe(result => { + .saveFile(buffer, this.fileInfo.fileName, mimeType) + .then(result => { if (!!result) { this.snackBarService.open( `파일이 경로[${result}]에 저장되었습니다.`, '', { duration: 3000, - verticalPosition: 'bottom' + verticalPosition: 'bottom', } ); } else { this.snackBarService.open('파일 저장에 실패하였습니다.'); } + }) + .catch(reason => { + this.snackBarService.open('파일 저장에 실패하였습니다.'); }); }) .catch(reason => { @@ -123,7 +119,9 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy { }); }), finalize(() => { - this.fileDownloadItem = undefined; + setTimeout(() => { + fileDownloadItem.downloadingProgress$ = undefined; + }, 1000); }) ) .subscribe(); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index b6dfa404..8f23ba54 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -485,7 +485,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { } async onFileViewer(fileInfo: FileEventJson) { - this.logger.debug('onFileViewer', fileInfo); const result = await this.dialogService.open< FileViewerDialogComponent, FileViewerDialogData, diff --git a/projects/ucap-webmessenger-app/src/app/store/account/authentication/effects.ts b/projects/ucap-webmessenger-app/src/app/store/account/authentication/effects.ts index d7a9eb0b..d33291f4 100644 --- a/projects/ucap-webmessenger-app/src/app/store/account/authentication/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/account/authentication/effects.ts @@ -1,7 +1,7 @@ import { Injectable, Inject } from '@angular/core'; import { Router } from '@angular/router'; -import { of } from 'rxjs'; +import { of, Observable } from 'rxjs'; import { catchError, exhaustMap, map, tap, switchMap } from 'rxjs/operators'; import { Actions, ofType, createEffect } from '@ngrx/effects'; @@ -86,19 +86,28 @@ export class Effects { () => this.actions$.pipe( ofType(webLoginSuccess), - switchMap(params => - this.nativeService.checkForUpdates().pipe( - map((update: boolean) => { - if (!update) { - this.appAuthenticationService.login( - params.loginInfo, - params.rememberMe - ); - this.router.navigate(['/messenger']); - } - }), - catchError(error => of(error)) - ) + switchMap( + params => + new Observable(subscriber => { + this.nativeService + .checkForUpdates() + .then((update: boolean) => { + if (!update) { + this.appAuthenticationService.login( + params.loginInfo, + params.rememberMe + ); + this.router.navigate(['/messenger']); + } + subscriber.next(); + }) + .catch(reason => { + subscriber.error(reason); + }) + .finally(() => { + subscriber.complete(); + }); + }) ) ), { dispatch: false } diff --git a/projects/ucap-webmessenger-core/src/lib/utils/file.util.ts b/projects/ucap-webmessenger-core/src/lib/utils/file.util.ts index 387f3cef..eb5e78b5 100644 --- a/projects/ucap-webmessenger-core/src/lib/utils/file.util.ts +++ b/projects/ucap-webmessenger-core/src/lib/utils/file.util.ts @@ -69,6 +69,113 @@ export class FileUtil { a.remove(); } + static save( + buffer: Buffer, + fileName: string, + mimeType: string + ): Promise { + return new Promise((resolve, reject) => { + const defaultMime = 'application/octet-stream'; + const mime = !!mimeType ? mimeType : defaultMime; + const blob = new Blob([buffer], { type: mime }); + + if (navigator.msSaveBlob) { + // IE10+ : (has Blob, but not a[download] or URL) + navigator.msSaveBlob(blob, fileName); + resolve(fileName); + return; + } + + const download = (url: string, mode: boolean = false) => { + const anchor = document.createElement('a'); + + if ('download' in anchor) { + // html5 A[download] + anchor.href = url; + anchor.setAttribute('download', fileName); + anchor.className = 'download-js-link'; + anchor.innerHTML = 'downloading...'; + anchor.style.display = 'none'; + document.body.appendChild(anchor); + + setTimeout(() => { + anchor.click(); + document.body.removeChild(anchor); + resolve(fileName); + if (mode) { + setTimeout(() => { + window.URL.revokeObjectURL(anchor.href); + }, 250); + } + }, 66); + return; + } + + // handle non-a[download] safari as best we can: + if ( + /(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test( + navigator.userAgent + ) + ) { + url = url.replace(/^data:([\w\/\-\+]+)/, defaultMime); + if (!window.open(url)) { + // popup blocked, offer direct download: + if ( + confirm( + 'Displaying New Document\n\nUse Save As... to download, then click back to return to this page.' + ) + ) { + location.href = url; + } + } + resolve(fileName); + return; + } + + // do iframe dataURL download (old ch+FF): + const f = document.createElement('iframe'); + document.body.appendChild(f); + + if (!mode) { + // force a mime that will download: + url = 'data:' + url.replace(/^data:([\w\/\-\+]+)/, defaultMime); + } + f.src = url; + setTimeout(() => { + document.body.removeChild(f); + }, 333); + }; + + if (window.URL) { + download(window.URL.createObjectURL(blob), true); + } else { + if ( + typeof blob === 'string' || + (blob as any).constructor === this.toString + ) { + try { + download( + 'data:' + mime + ';base64,' + window.btoa((blob as any) as string) + ); + } catch (e) { + download( + 'data:' + + mime + + ';base64,' + + encodeURIComponent((blob as any) as string) + ); + } + } else { + const fileReader = new FileReader(); + fileReader.onload = () => { + download(fileReader.result as string); + }; + fileReader.readAsDataURL(blob); + } + } + }); + } + static thumbnail(file: File): Promise { return new Promise((resolve, reject) => { const fileReader = new FileReader(); diff --git a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts index b33c5e7a..42a40760 100644 --- a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts +++ b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts @@ -12,6 +12,7 @@ import { TranslateLoader } from '@ngx-translate/core'; import { TranslateLoaderService } from '../translate/browser-loader'; import { NotificationService } from '../notification/notification.service'; import { Injectable } from '@angular/core'; +import { FileUtil } from '@ucap-webmessenger/core'; @Injectable({ providedIn: 'root', @@ -34,34 +35,35 @@ export class BrowserNativeService extends NativeService { } closeAllNotify(): void {} - checkForUpdates(): Observable { - return new Observable(subscriber => { - try { - subscriber.next(false); - } catch (error) { - subscriber.error(error); - } finally { - subscriber.complete(); - } + checkForUpdates(): Promise { + return new Promise((resolve, reject) => { + resolve(false); }); } showImageViewer(): void {} - readFile(path: string): Observable { - return this.httpClient.get(path, { responseType: 'arraybuffer' }).pipe( - map(arrayBuffer => { - return Buffer.from(arrayBuffer); - }) - ); + readFile(path: string): Promise { + return new Promise((resolve, reject) => { + resolve(null); + }); } saveFile( buffer: Buffer, fileName: string, + mimeType: string, path?: string - ): Observable { - return this.httpClient.post(path, buffer, {}); + ): Promise { + return new Promise((resolve, reject) => { + try { + FileUtil.save(buffer, fileName, mimeType).then(fn => { + resolve(fn); + }); + } catch (error) { + reject(error); + } + }); } windowStateChanged(): Observable { @@ -85,7 +87,6 @@ export class BrowserNativeService extends NativeService { idleStateChanged(): Observable { return new Observable(subscriber => { try { - subscriber.next(WindowIdle.Active); } catch (error) { subscriber.error(error); } finally { diff --git a/projects/ucap-webmessenger-native-browser/src/lib/translate/browser-loader.ts b/projects/ucap-webmessenger-native-browser/src/lib/translate/browser-loader.ts index 0024d8a9..6ca66160 100644 --- a/projects/ucap-webmessenger-native-browser/src/lib/translate/browser-loader.ts +++ b/projects/ucap-webmessenger-native-browser/src/lib/translate/browser-loader.ts @@ -1,7 +1,6 @@ import { TranslateLoader } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { NativeService } from '@ucap-webmessenger/native'; -import { take, map } from 'rxjs/operators'; import { Injectable } from '@angular/core'; @Injectable({ @@ -18,13 +17,18 @@ export class TranslateLoaderService implements TranslateLoader { * Gets the translations from the server */ public getTranslation(lang: string): Observable { - return this.nativeService - .readFile(`${this.prefix}${lang}.${this.suffix}`) - .pipe( - take(1), - map(buffer => { - return JSON.parse(buffer.toString('utf-8')); + return new Observable(subscriber => { + this.nativeService + .readFile(`${this.prefix}${lang}.${this.suffix}`) + .then(buffer => { + subscriber.next(JSON.parse(buffer.toString('utf-8'))); }) - ); + .catch(reason => { + subscriber.error(reason); + }) + .finally(() => { + subscriber.complete(); + }); + }); } } diff --git a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts index 9836473a..a1fe7ca5 100644 --- a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts +++ b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts @@ -47,14 +47,12 @@ export class ElectronNativeService implements NativeService { this.ipcRenderer.send(NotificationChannel.CloseAllNotify); } - checkForUpdates(): Observable { - return new Observable(subscriber => { + checkForUpdates(): Promise { + return new Promise((resolve, reject) => { try { - subscriber.next(this.ipcRenderer.sendSync(UpdaterChannel.Check)); + resolve(this.ipcRenderer.sendSync(UpdaterChannel.Check)); } catch (error) { - subscriber.error(error); - } finally { - subscriber.complete(); + reject(error); } }); } @@ -63,14 +61,12 @@ export class ElectronNativeService implements NativeService { this.ipcRenderer.send(FileChannel.ShowImageViewer); } - readFile(path: string): Observable { - return new Observable(subscriber => { + readFile(path: string): Promise { + return new Promise((resolve, reject) => { try { - subscriber.next(this.ipcRenderer.sendSync(FileChannel.ReadFile, path)); + resolve(this.ipcRenderer.sendSync(FileChannel.ReadFile, path)); } catch (error) { - subscriber.error(error); - } finally { - subscriber.complete(); + reject(error); } }); } @@ -78,22 +74,22 @@ export class ElectronNativeService implements NativeService { saveFile( buffer: Buffer, fileName: string, + mimeType: string, path?: string - ): Observable { - return new Observable(subscriber => { + ): Promise { + return new Promise((resolve, reject) => { try { - subscriber.next( + resolve( this.ipcRenderer.sendSync( FileChannel.SaveFile, buffer, fileName, + mimeType, path ) ); } catch (error) { - subscriber.error(error); - } finally { - subscriber.complete(); + reject(error); } }); } diff --git a/projects/ucap-webmessenger-native-electron/src/lib/translate/electron-loader.ts b/projects/ucap-webmessenger-native-electron/src/lib/translate/electron-loader.ts index 1195ae26..6ca66160 100644 --- a/projects/ucap-webmessenger-native-electron/src/lib/translate/electron-loader.ts +++ b/projects/ucap-webmessenger-native-electron/src/lib/translate/electron-loader.ts @@ -1,7 +1,6 @@ import { TranslateLoader } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { NativeService } from '@ucap-webmessenger/native'; -import { take, map } from 'rxjs/operators'; import { Injectable } from '@angular/core'; @Injectable({ @@ -18,13 +17,18 @@ export class TranslateLoaderService implements TranslateLoader { * Gets the translations from the server */ public getTranslation(lang: string): Observable { - return this.nativeService - .readFile(`${this.prefix}${lang}.${this.suffix}`) - .pipe( - take(1), - map(buf => { - return JSON.parse(buf.toString()); + return new Observable(subscriber => { + this.nativeService + .readFile(`${this.prefix}${lang}.${this.suffix}`) + .then(buffer => { + subscriber.next(JSON.parse(buffer.toString('utf-8'))); }) - ); + .catch(reason => { + subscriber.error(reason); + }) + .finally(() => { + subscriber.complete(); + }); + }); } } diff --git a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts index cdfac5de..af261391 100644 --- a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts +++ b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts @@ -11,16 +11,17 @@ export abstract class NativeService { abstract notify(noti: NotificationRequest): void; abstract closeAllNotify(): void; - abstract checkForUpdates(): Observable; + abstract checkForUpdates(): Promise; abstract showImageViewer(): void; abstract saveFile( buffer: Buffer, fileName: string, + mimeType: string, path?: string - ): Observable; - abstract readFile(path: string): Observable; + ): Promise; + abstract readFile(path: string): Promise; abstract windowStateChanged(): Observable; abstract windowClose(): void; diff --git a/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts b/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts index 925a3769..3341ff6d 100644 --- a/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts +++ b/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts @@ -191,12 +191,18 @@ export class ProtocolService { responseSubject = new Subject().pipe( finalize(() => { + this.logger.debug( + 'ProtocolService::pendingRequests.finalize', + requestId + ); + if (this.pendingRequests.has(requestId)) { this.pendingRequests.delete(requestId); } this.logger.debug( 'ProtocolService::pendingRequests.size', - this.pendingRequests.size + this.pendingRequests.size, + this.pendingRequests ); }) ) as Subject; diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer.component.html b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer.component.html index 6c7d3d74..caced57b 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer.component.html +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer.component.html @@ -6,35 +6,35 @@ *ngSwitchCase="FileViewerType.Document" [fileInfo]="fileInfo" [fileDownloadUrl]="fileDownloadUrl" - (download)="onDownload()" + (download)="onDownload($event)" (closed)="onClosedViewer()" > diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer.component.ts b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer.component.ts index 54c0140a..74aa88a1 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer.component.ts +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer.component.ts @@ -3,12 +3,13 @@ import { ucapAnimations } from '../animations'; import { FileEventJson } from '@ucap-webmessenger/protocol-event'; import { FileViewerType } from '../types/file-viewer.type'; import { FileType } from '@ucap-webmessenger/protocol-file'; +import { FileDownloadItem } from '@ucap-webmessenger/api-common'; @Component({ selector: 'ucap-file-viewer', templateUrl: './file-viewer.component.html', styleUrls: ['./file-viewer.component.scss'], - animations: ucapAnimations + animations: ucapAnimations, }) export class FileViewerComponent implements OnInit { @Input() @@ -18,7 +19,7 @@ export class FileViewerComponent implements OnInit { fileDownloadUrl: string; @Output() - download = new EventEmitter(); + download = new EventEmitter(); @Output() closed = new EventEmitter(); @@ -44,8 +45,8 @@ export class FileViewerComponent implements OnInit { return FileViewerType.Binary; } } - onDownload(): void { - this.download.emit(); + onDownload(fileDownloadItem: FileDownloadItem): void { + this.download.emit(fileDownloadItem); } onClosedViewer(): void { diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/binary-viewer.component.html b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/binary-viewer.component.html index db060695..32a33be9 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/binary-viewer.component.html +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/binary-viewer.component.html @@ -24,6 +24,11 @@ Close +
(); + download = new EventEmitter(); @Output() closed = new EventEmitter(); + fileDownloadItem: FileDownloadItem; + constructor() {} ngOnInit() {} onClickDownload(): void { - this.download.emit(); + this.fileDownloadItem = new FileDownloadItem(); + this.download.emit(this.fileDownloadItem); } onClickClose(): void { diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/document-viewer.component.html b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/document-viewer.component.html index 0f1561d1..b9df4234 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/document-viewer.component.html +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/document-viewer.component.html @@ -15,4 +15,9 @@ >delete +
diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/document-viewer.component.ts b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/document-viewer.component.ts index 2b411d6a..eefa6939 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/document-viewer.component.ts +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/document-viewer.component.ts @@ -2,12 +2,13 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { ucapAnimations } from '../../animations'; import { FileEventJson } from '@ucap-webmessenger/protocol-event'; import { DeviceType } from '@ucap-webmessenger/core'; +import { FileDownloadItem } from '@ucap-webmessenger/api-common'; @Component({ selector: 'ucap-document-viewer', templateUrl: './document-viewer.component.html', styleUrls: ['./document-viewer.component.scss'], - animations: ucapAnimations + animations: ucapAnimations, }) export class DocumentViewerComponent implements OnInit { @Input() @@ -17,16 +18,21 @@ export class DocumentViewerComponent implements OnInit { fileDownloadUrl: string; @Output() - download = new EventEmitter(); + download = new EventEmitter(); @Output() closed = new EventEmitter(); + fileDownloadItem: FileDownloadItem; + constructor() {} ngOnInit() {} - onClickDownload(): void {} + onClickDownload(): void { + this.fileDownloadItem = new FileDownloadItem(); + this.download.emit(this.fileDownloadItem); + } onClickClose(): void { this.closed.emit(); diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.html b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.html index 262a90e7..343a55d6 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.html +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.html @@ -1,11 +1,22 @@
- + - + - + + {{ fileInfo.fileName }} @@ -18,9 +29,20 @@ > - - + + +
(); @Output() - download = new EventEmitter(); + download = new EventEmitter(); + + fileDownloadItem: FileDownloadItem; constructor() {} ngOnInit() {} onClickDownload(): void { - this.download.emit(); + this.fileDownloadItem = new FileDownloadItem(); + this.download.emit(this.fileDownloadItem); } onClickClose(): void { diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/sound-viewer.component.html b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/sound-viewer.component.html index 6d3a0430..1d791071 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/sound-viewer.component.html +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/sound-viewer.component.html @@ -22,6 +22,11 @@ Close +
(); + download = new EventEmitter(); @Output() closed = new EventEmitter(); @@ -41,6 +42,7 @@ export class SoundViewerComponent implements OnInit { currentTime = 0; volume = 0.1; loading = false; + fileDownloadItem: FileDownloadItem; constructor() {} @@ -90,7 +92,8 @@ export class SoundViewerComponent implements OnInit { } onClickDownload(): void { - this.download.emit(); + this.fileDownloadItem = new FileDownloadItem(); + this.download.emit(this.fileDownloadItem); } onClickClose(): void { diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/video-viewer.component.html b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/video-viewer.component.html index 43b5bf3e..9a3f9778 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/video-viewer.component.html +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/video-viewer.component.html @@ -1,8 +1,18 @@
- + @@ -23,9 +33,20 @@ (click)="onClickDownload()" > - - + + @@ -33,16 +54,30 @@ mat-icon-button color="warn" class="ucap-image-viewer-action btn-close" - matTooltip="뷰어닫기" + matTooltip="뷰어닫기" (click)="onClickClose()" > - + +
(); + download = new EventEmitter(); @Output() closed = new EventEmitter(); @@ -41,6 +42,7 @@ export class VideoViewerComponent implements OnInit { currentTime = 0; volume = 0.1; loading = false; + fileDownloadItem: FileDownloadItem; constructor() {} @@ -90,7 +92,8 @@ export class VideoViewerComponent implements OnInit { } onClickDownload(): void { - this.download.emit(); + this.fileDownloadItem = new FileDownloadItem(); + this.download.emit(this.fileDownloadItem); } onClickClose(): void {