2019-11-06 04:48:06 +00:00
|
|
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
|
|
|
import { ucapAnimations } from '../animations';
|
2019-11-06 07:24:51 +00:00
|
|
|
import { Info, FileEventJson } from '@ucap-webmessenger/protocol-event';
|
|
|
|
import { FileViewerType } from '../types/file-viewer.type';
|
|
|
|
import { FileType } from '@ucap-webmessenger/protocol-file';
|
|
|
|
import { DeviceType } from '@ucap-webmessenger/core';
|
2019-11-06 04:48:06 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'ucap-file-viewer',
|
|
|
|
templateUrl: './file-viewer.component.html',
|
|
|
|
styleUrls: ['./file-viewer.component.scss'],
|
|
|
|
animations: ucapAnimations
|
|
|
|
})
|
|
|
|
export class FileViewerComponent implements OnInit {
|
2019-11-06 07:24:51 +00:00
|
|
|
@Input()
|
|
|
|
fileInfo: FileEventJson;
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
downloadUrl: string;
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
userSeq: number;
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
deviceType: DeviceType;
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
token: string;
|
|
|
|
|
2019-11-06 04:48:06 +00:00
|
|
|
@Output()
|
|
|
|
closed = new EventEmitter<void>();
|
|
|
|
|
2019-11-06 07:24:51 +00:00
|
|
|
FileViewerType = FileViewerType;
|
|
|
|
|
2019-11-06 04:48:06 +00:00
|
|
|
constructor() {}
|
2019-11-06 07:24:51 +00:00
|
|
|
|
2019-11-06 04:48:06 +00:00
|
|
|
ngOnInit() {}
|
2019-11-06 07:24:51 +00:00
|
|
|
|
|
|
|
detectFileViewerType(fileInfo: FileEventJson): FileViewerType {
|
|
|
|
switch (fileInfo.fileType) {
|
|
|
|
case FileType.Image:
|
|
|
|
return FileViewerType.Image;
|
|
|
|
case FileType.Sound:
|
|
|
|
return FileViewerType.Sound;
|
|
|
|
case FileType.Video:
|
|
|
|
return FileViewerType.Video;
|
|
|
|
default:
|
|
|
|
return FileViewerType.Binary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosedViewer(): void {
|
|
|
|
this.closed.emit();
|
|
|
|
}
|
2019-11-06 04:48:06 +00:00
|
|
|
}
|