84 lines
2.3 KiB
TypeScript
84 lines
2.3 KiB
TypeScript
import { Component, OnInit, OnDestroy, Inject } from '@angular/core';
|
|
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
import { NGXLogger } from 'ngx-logger';
|
|
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
|
|
import { DeviceType } from '@ucap-webmessenger/core';
|
|
import { FileDownloadItem } from '@ucap-webmessenger/api';
|
|
import { CommonApiService } from '@ucap-webmessenger/api-common';
|
|
import { AppFileService } from '@app/services/file.service';
|
|
|
|
export interface FileViewerDialogData {
|
|
fileInfo: FileEventJson;
|
|
downloadUrl: string;
|
|
userSeq: number;
|
|
deviceType: DeviceType;
|
|
token: string;
|
|
}
|
|
|
|
export interface FileViewerDialogResult {}
|
|
|
|
@Component({
|
|
selector: 'app-layout-common-file-viewer',
|
|
templateUrl: './file-viewer.dialog.component.html',
|
|
styleUrls: ['./file-viewer.dialog.component.scss']
|
|
})
|
|
export class FileViewerDialogComponent implements OnInit, OnDestroy {
|
|
fileInfo: FileEventJson;
|
|
downloadUrl: string;
|
|
userSeq: number;
|
|
deviceType: DeviceType;
|
|
token: string;
|
|
|
|
fileDownloadUrl: string;
|
|
|
|
constructor(
|
|
public dialogRef: MatDialogRef<
|
|
FileViewerDialogData,
|
|
FileViewerDialogResult
|
|
>,
|
|
@Inject(MAT_DIALOG_DATA) public data: FileViewerDialogData,
|
|
private commonApiService: CommonApiService,
|
|
private appFileService: AppFileService,
|
|
private logger: NGXLogger
|
|
) {
|
|
this.fileInfo = data.fileInfo;
|
|
this.downloadUrl = data.downloadUrl;
|
|
this.userSeq = data.userSeq;
|
|
this.deviceType = data.deviceType;
|
|
this.token = data.token;
|
|
|
|
this.fileDownloadUrl = this.commonApiService.urlForFileTalkDownload(
|
|
{
|
|
userSeq: this.userSeq,
|
|
deviceType: this.deviceType,
|
|
token: this.token,
|
|
attachmentsSeq: this.fileInfo.attachmentSeq
|
|
},
|
|
this.downloadUrl
|
|
);
|
|
}
|
|
|
|
ngOnInit() {}
|
|
|
|
ngOnDestroy(): void {}
|
|
|
|
onDownload(fileDownloadItem: FileDownloadItem): void {
|
|
this.appFileService.fileTalkDownlod({
|
|
req: {
|
|
userSeq: this.userSeq,
|
|
deviceType: this.deviceType,
|
|
token: this.token,
|
|
attachmentsSeq: this.fileInfo.attachmentSeq,
|
|
fileDownloadItem
|
|
},
|
|
fileName: this.fileInfo.fileName,
|
|
fileDownloadUrl: this.downloadUrl
|
|
});
|
|
}
|
|
|
|
onClosedViewer(): void {
|
|
this.dialogRef.close();
|
|
}
|
|
}
|