diff --git a/package-lock.json b/package-lock.json
index a9a94ee7..bade9cfb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2323,6 +2323,12 @@
"@types/webpack": "*"
}
},
+ "@types/file-saver": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.1.tgz",
+ "integrity": "sha512-g1QUuhYVVAamfCifK7oB7G3aIl4BbOyzDOqVyUfEr4tfBKrXfeH+M+Tg7HKCXSrbzxYdhyCP7z9WbKo0R2hBCw==",
+ "dev": true
+ },
"@types/filesize": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@types/filesize/-/filesize-4.2.0.tgz",
@@ -6594,6 +6600,12 @@
}
}
},
+ "file-saver": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.2.tgz",
+ "integrity": "sha512-Wz3c3XQ5xroCxd1G8b7yL0Ehkf0TC9oYC6buPFkNnU9EnaPlifeAFCyCh+iewXTyFRcg0a6j3J7FmJsIhlhBdw==",
+ "dev": true
+ },
"fileset": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/fileset/-/fileset-2.0.3.tgz",
diff --git a/package.json b/package.json
index 503b7bd1..61d69f6a 100644
--- a/package.json
+++ b/package.json
@@ -48,6 +48,7 @@
"@types/electron-devtools-installer": "^2.2.0",
"@types/extract-text-webpack-plugin": "^3.0.4",
"@types/fs-extra": "^8.0.0",
+ "@types/file-saver": "^2.0.1",
"@types/filesize": "^4.1.0",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
@@ -75,6 +76,7 @@
"electron-store": "^4.0.0",
"electron-updater": "^4.1.2",
"electron-window-state": "^5.0.3",
+ "file-saver": "^2.0.2",
"fs-extra": "^8.1.0",
"filesize": "^4.1.2",
"hammerjs": "^2.0.8",
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 8b644891..35db1b48 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
@@ -4,5 +4,6 @@
[userSeq]="userSeq"
[deviceType]="deviceType"
[token]="token"
+ (download)="onDownload($event)"
(closed)="onClosedViewer()"
>
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 cac29042..cdbe1ac4 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
@@ -10,6 +10,7 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { NGXLogger } from 'ngx-logger';
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
import { DeviceType } from '@ucap-webmessenger/core';
+import * as FileSaver from 'file-saver';
export interface FileViewerDialogData {
fileInfo: FileEventJson;
@@ -52,6 +53,10 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {}
+ onDownload(blob: Blob): void {
+ FileSaver.saveAs(blob, this.fileInfo.fileName);
+ }
+
onClosedViewer(): void {
this.dialogRef.close();
}
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 0d22febe..f985506c 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
@@ -9,6 +9,7 @@
[userSeq]="userSeq"
[deviceType]="deviceType"
[token]="token"
+ (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 3862f5d7..9824ba4e 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
@@ -27,6 +27,9 @@ export class FileViewerComponent implements OnInit {
@Input()
token: string;
+ @Output()
+ download = new EventEmitter();
+
@Output()
closed = new EventEmitter();
@@ -48,6 +51,9 @@ export class FileViewerComponent implements OnInit {
return FileViewerType.Binary;
}
}
+ onDownload(blob: Blob): void {
+ this.download.emit(blob);
+ }
onClosedViewer(): void {
this.closed.emit();
diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/binary-viewer.component.ts b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/binary-viewer.component.ts
index 81a0cfa3..d9710c38 100644
--- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/binary-viewer.component.ts
+++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/binary-viewer.component.ts
@@ -25,9 +25,19 @@ export class BinaryViewerComponent implements OnInit {
@Input()
token: string;
+ @Output()
+ download = new EventEmitter();
+
@Output()
closed = new EventEmitter();
constructor() {}
+
ngOnInit() {}
+
+ onClickDownload(): void {}
+
+ onClickClose(): void {
+ this.closed.emit();
+ }
}
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 44926295..1ac09a5a 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
@@ -25,9 +25,19 @@ export class DocumentViewerComponent implements OnInit {
@Input()
token: string;
+ @Output()
+ download = new EventEmitter();
+
@Output()
closed = new EventEmitter();
constructor() {}
+
ngOnInit() {}
+
+ onClickDownload(): void {}
+
+ 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 7c1801a2..3f7f9d71 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,5 +1,5 @@
-