파일 뷰어에 다른이름 저장 기능 추가.

This commit is contained in:
leejinho 2020-03-25 15:08:42 +09:00
parent d6dd914043
commit 96d9d574c1
13 changed files with 199 additions and 2 deletions

View File

@ -4,5 +4,6 @@
[imageOnly]="imageOnly" [imageOnly]="imageOnly"
[imageOnlyData]="imageOnlyData" [imageOnlyData]="imageOnlyData"
(download)="onDownload($event)" (download)="onDownload($event)"
(saveAs)="onSaveAs($event)"
(closed)="onClosedViewer()" (closed)="onClosedViewer()"
></ucap-file-viewer> ></ucap-file-viewer>

View File

@ -7,7 +7,9 @@ import { DeviceType } from '@ucap-webmessenger/core';
import { FileDownloadItem } from '@ucap-webmessenger/api'; import { FileDownloadItem } from '@ucap-webmessenger/api';
import { CommonApiService } from '@ucap-webmessenger/api-common'; import { CommonApiService } from '@ucap-webmessenger/api-common';
import { AppFileService } from '@app/services/file.service'; import { AppFileService } from '@app/services/file.service';
import { ImageOnlyDataInfo } from '@ucap-webmessenger/ui'; import { ImageOnlyDataInfo, SnackBarService } from '@ucap-webmessenger/ui';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
import { TranslateService } from '@ngx-translate/core';
export interface FileViewerDialogData { export interface FileViewerDialogData {
fileInfo: FileEventJson; fileInfo: FileEventJson;
@ -46,6 +48,9 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
@Inject(MAT_DIALOG_DATA) public data: FileViewerDialogData, @Inject(MAT_DIALOG_DATA) public data: FileViewerDialogData,
private commonApiService: CommonApiService, private commonApiService: CommonApiService,
private appFileService: AppFileService, private appFileService: AppFileService,
private translateService: TranslateService,
private snackBarService: SnackBarService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private logger: NGXLogger private logger: NGXLogger
) { ) {
this.fileInfo = data.fileInfo; this.fileInfo = data.fileInfo;
@ -91,6 +96,47 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
fileDownloadUrl: this.downloadUrl fileDownloadUrl: this.downloadUrl
}); });
} }
onSaveAs(fileDownloadItem: FileDownloadItem): void {
this.nativeService
.selectSaveFilePath(this.fileInfo.fileName)
.then(result => {
if (!result) {
return;
}
if (result.canceled) {
// this.snackBarService.open(
// this.translateService.instant('common.file.results.canceled'),
// this.translateService.instant('common.file.errors.label'),
// {
// duration: 1000
// }
// );
} else {
this.saveFile(fileDownloadItem, result.filePath);
}
})
.catch(reason => {
this.snackBarService.open(
this.translateService.instant('common.file.errors.failToSpecifyPath'),
this.translateService.instant('common.file.errors.label')
);
});
}
saveFile(fileDownloadItem: FileDownloadItem, savePath?: string) {
this.appFileService.fileTalkDownlod({
req: {
userSeq: this.userSeq,
deviceType: this.deviceType,
token: this.token,
attachmentsSeq: this.fileInfo.attachmentSeq,
fileDownloadItem
},
fileName: this.fileInfo.fileName,
savePath
});
}
onClosedViewer(): void { onClosedViewer(): void {
this.dialogRef.close(); this.dialogRef.close();

View File

@ -16,6 +16,7 @@
[imageOnly]="imageOnly" [imageOnly]="imageOnly"
[imageOnlyData]="imageOnlyData" [imageOnlyData]="imageOnlyData"
(download)="onDownload($event)" (download)="onDownload($event)"
(saveAs)="onSaveAs($event)"
(closed)="onClosedViewer()" (closed)="onClosedViewer()"
></ucap-image-viewer> ></ucap-image-viewer>
<ucap-sound-viewer <ucap-sound-viewer
@ -30,6 +31,7 @@
[fileInfo]="fileInfo" [fileInfo]="fileInfo"
[fileDownloadUrl]="fileDownloadUrl" [fileDownloadUrl]="fileDownloadUrl"
(download)="onDownload($event)" (download)="onDownload($event)"
(saveAs)="onSaveAs($event)"
(closed)="onClosedViewer()" (closed)="onClosedViewer()"
></ucap-video-viewer> ></ucap-video-viewer>
<ucap-binary-viewer <ucap-binary-viewer
@ -37,6 +39,7 @@
[fileInfo]="fileInfo" [fileInfo]="fileInfo"
[fileDownloadUrl]="fileDownloadUrl" [fileDownloadUrl]="fileDownloadUrl"
(download)="onDownload($event)" (download)="onDownload($event)"
(saveAs)="onSaveAs($event)"
(closed)="onClosedViewer()" (closed)="onClosedViewer()"
></ucap-binary-viewer> ></ucap-binary-viewer>
</div> </div>

View File

@ -26,6 +26,8 @@ export class FileViewerComponent implements OnInit {
@Output() @Output()
download = new EventEmitter<FileDownloadItem>(); download = new EventEmitter<FileDownloadItem>();
@Output()
saveAs = new EventEmitter<FileDownloadItem>();
@Output() @Output()
closed = new EventEmitter<void>(); closed = new EventEmitter<void>();
@ -58,6 +60,9 @@ export class FileViewerComponent implements OnInit {
onDownload(fileDownloadItem: FileDownloadItem): void { onDownload(fileDownloadItem: FileDownloadItem): void {
this.download.emit(fileDownloadItem); this.download.emit(fileDownloadItem);
} }
onSaveAs(fileDownloadItem: FileDownloadItem): void {
this.saveAs.emit(fileDownloadItem);
}
onClosedViewer(): void { onClosedViewer(): void {
this.closed.emit(); this.closed.emit();

View File

@ -44,6 +44,31 @@
/> />
</svg> </svg>
</button> </button>
<button
mat-icon-button
class="ucap-image-viewer-action"
matTooltip="{{ 'common.file.saveAs' | translate }}"
matTooltipPosition="below"
aria-label=""
(click)="onClickSaveAs()"
>
<!--<mat-icon>get_app</mat-icon>-->
<svg
xmlns="http://www.w3.org/2000/svg"
width="21"
height="21"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="butt"
stroke-linejoin="round"
>
<path
d="M3 15v4c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-4M17 9l-5 5-5-5M12 12.8V2.5"
/>
</svg>
</button>
<span class="stroke-bar"></span> <span class="stroke-bar"></span>
<button <button
mat-icon-button mat-icon-button
@ -94,7 +119,7 @@
<div class="guide-msg"> <div class="guide-msg">
{{ 'common.file.errors.noPreview' | translate }} {{ 'common.file.errors.noPreview' | translate }}
</div> </div>
<div> <div class="btn-group">
<button <button
colori colori
mat-raised-button mat-raised-button
@ -103,6 +128,14 @@
> >
{{ 'common.file.download' | translate }} {{ 'common.file.download' | translate }}
</button> </button>
<button
colori
mat-raised-button
aria-label=""
(click)="onClickSaveAs()"
>
{{ 'common.file.saveAs' | translate }}
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -60,5 +60,10 @@
margin: 30px; margin: 30px;
color: #ffffff; color: #ffffff;
} }
.btn-group {
button {
margin: 0 5px;
}
}
} }
} }

View File

@ -18,6 +18,8 @@ export class BinaryViewerComponent implements OnInit {
@Output() @Output()
download = new EventEmitter<FileDownloadItem>(); download = new EventEmitter<FileDownloadItem>();
@Output()
saveAs = new EventEmitter<FileDownloadItem>();
@Output() @Output()
closed = new EventEmitter<void>(); closed = new EventEmitter<void>();
@ -33,6 +35,11 @@ export class BinaryViewerComponent implements OnInit {
this.download.emit(this.fileDownloadItem); this.download.emit(this.fileDownloadItem);
} }
onClickSaveAs(): void {
this.fileDownloadItem = new FileDownloadItem();
this.saveAs.emit(this.fileDownloadItem);
}
onClickClose(): void { onClickClose(): void {
this.closed.emit(); this.closed.emit();
} }

View File

@ -136,6 +136,32 @@
/> />
</svg> </svg>
</button> </button>
<button
*ngIf="!imageOnly"
mat-icon-button
class="ucap-image-viewer-action"
matTooltip="{{ 'common.file.saveAs' | translate }}"
matTooltipPosition="below"
aria-label=""
(click)="onClickSaveAs()"
>
<!--<mat-icon>get_app</mat-icon>-->
<svg
xmlns="http://www.w3.org/2000/svg"
width="21"
height="21"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="butt"
stroke-linejoin="round"
>
<path
d="M3 15v4c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-4M17 9l-5 5-5-5M12 12.8V2.5"
/>
</svg>
</button>
<span class="stroke-bar"></span> <span class="stroke-bar"></span>
<button <button
mat-icon-button mat-icon-button

View File

@ -39,6 +39,8 @@ export class ImageViewerComponent implements OnInit {
@Output() @Output()
download = new EventEmitter<FileDownloadItem>(); download = new EventEmitter<FileDownloadItem>();
@Output()
saveAs = new EventEmitter<FileDownloadItem>();
@ViewChild('imageContainer', { static: false }) @ViewChild('imageContainer', { static: false })
imageContainer: ElementRef<HTMLElement>; imageContainer: ElementRef<HTMLElement>;
@ -73,6 +75,11 @@ export class ImageViewerComponent implements OnInit {
this.download.emit(this.fileDownloadItem); this.download.emit(this.fileDownloadItem);
} }
onClickSaveAs(): void {
this.fileDownloadItem = new FileDownloadItem();
this.saveAs.emit(this.fileDownloadItem);
}
onClickClose(): void { onClickClose(): void {
this.closed.emit(); this.closed.emit();
} }

View File

@ -28,6 +28,31 @@
/> />
</svg> </svg>
</button> </button>
<button
mat-icon-button
class="ucap-image-viewer-action"
matTooltip="{{ 'common.file.saveAs' | translate }}"
matTooltipPosition="below"
aria-label=""
(click)="onClickSaveAs()"
>
<!--<mat-icon>get_app</mat-icon>-->
<svg
xmlns="http://www.w3.org/2000/svg"
width="21"
height="21"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="butt"
stroke-linejoin="round"
>
<path
d="M3 15v4c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-4M17 9l-5 5-5-5M12 12.8V2.5"
/>
</svg>
</button>
<span class="stroke-bar"></span> <span class="stroke-bar"></span>
<button <button
mat-icon-button mat-icon-button

View File

@ -27,6 +27,8 @@ export class SoundViewerComponent implements OnInit {
@Output() @Output()
download = new EventEmitter<FileDownloadItem>(); download = new EventEmitter<FileDownloadItem>();
@Output()
saveAs = new EventEmitter<FileDownloadItem>();
@Output() @Output()
closed = new EventEmitter<void>(); closed = new EventEmitter<void>();
@ -95,6 +97,11 @@ export class SoundViewerComponent implements OnInit {
this.download.emit(this.fileDownloadItem); this.download.emit(this.fileDownloadItem);
} }
onClickSaveAs(): void {
this.fileDownloadItem = new FileDownloadItem();
this.saveAs.emit(this.fileDownloadItem);
}
onClickClose(): void { onClickClose(): void {
this.closed.emit(); this.closed.emit();
} }

View File

@ -49,6 +49,31 @@
/> />
</svg> </svg>
</button> </button>
<button
mat-icon-button
class="ucap-image-viewer-action"
matTooltip="{{ 'common.file.saveAs' | translate }}"
matTooltipPosition="below"
aria-label=""
(click)="onClickSaveAs()"
>
<!--<mat-icon>get_app</mat-icon>-->
<svg
xmlns="http://www.w3.org/2000/svg"
width="21"
height="21"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="butt"
stroke-linejoin="round"
>
<path
d="M3 15v4c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-4M17 9l-5 5-5-5M12 12.8V2.5"
/>
</svg>
</button>
<span class="stroke-bar"></span> <span class="stroke-bar"></span>
<button <button
mat-icon-button mat-icon-button

View File

@ -30,6 +30,8 @@ export class VideoViewerComponent implements OnInit {
@Output() @Output()
download = new EventEmitter<FileDownloadItem>(); download = new EventEmitter<FileDownloadItem>();
@Output()
saveAs = new EventEmitter<FileDownloadItem>();
@Output() @Output()
closed = new EventEmitter<void>(); closed = new EventEmitter<void>();
@ -116,6 +118,11 @@ export class VideoViewerComponent implements OnInit {
this.download.emit(this.fileDownloadItem); this.download.emit(this.fileDownloadItem);
} }
onClickSaveAs(): void {
this.fileDownloadItem = new FileDownloadItem();
this.saveAs.emit(this.fileDownloadItem);
}
onClickClose(): void { onClickClose(): void {
this.closed.emit(); this.closed.emit();
} }