refactoring
This commit is contained in:
parent
bb4cdfab26
commit
6297a0b2c3
|
@ -22,7 +22,18 @@ const fileTalkDownloadEncodeMap = {
|
||||||
attachmentsSeq: 'p_att_seq'
|
attachmentsSeq: 'p_att_seq'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const encodeFileTalkDownload: APIFormDataEncoder<
|
export const encodeFileTalkDownload: APIEncoder<FileTalkDownloadRequest> = (
|
||||||
|
req: FileTalkDownloadRequest
|
||||||
|
) => {
|
||||||
|
const extraParams: any = {};
|
||||||
|
|
||||||
|
extraParams.userSeq = String(req.userSeq);
|
||||||
|
extraParams.attachmentsSeq = String(req.attachmentsSeq);
|
||||||
|
|
||||||
|
return ParameterUtil.encode(fileTalkDownloadEncodeMap, req, extraParams);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const encodeFormDataFileTalkDownload: APIFormDataEncoder<
|
||||||
FileTalkDownloadRequest
|
FileTalkDownloadRequest
|
||||||
> = (req: FileTalkDownloadRequest) => {
|
> = (req: FileTalkDownloadRequest) => {
|
||||||
const extraParams: any = {};
|
const extraParams: any = {};
|
||||||
|
|
|
@ -19,7 +19,8 @@ import {
|
||||||
} from '../apis/file-profile-save';
|
} from '../apis/file-profile-save';
|
||||||
import {
|
import {
|
||||||
FileTalkDownloadRequest,
|
FileTalkDownloadRequest,
|
||||||
encodeFileTalkDownload
|
encodeFileTalkDownload,
|
||||||
|
encodeFormDataFileTalkDownload
|
||||||
} from '../apis/file-talk-download';
|
} from '../apis/file-talk-download';
|
||||||
import {
|
import {
|
||||||
FileTalkSaveRequest,
|
FileTalkSaveRequest,
|
||||||
|
@ -96,6 +97,24 @@ export class CommonApiService {
|
||||||
.pipe(map(res => decodeFileProfileSave(res)));
|
.pipe(map(res => decodeFileProfileSave(res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public urlForFileTalkDownload(
|
||||||
|
req: FileTalkDownloadRequest,
|
||||||
|
fileTalkDownloadUrl?: string
|
||||||
|
): string {
|
||||||
|
const httpReq = new HttpRequest(
|
||||||
|
'GET',
|
||||||
|
!!fileTalkDownloadUrl
|
||||||
|
? fileTalkDownloadUrl
|
||||||
|
: this.moduleConfig.urls.fileTalkDownload,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
params: encodeFileTalkDownload(req)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return httpReq.urlWithParams;
|
||||||
|
}
|
||||||
|
|
||||||
public fileTalkDownload(
|
public fileTalkDownload(
|
||||||
req: FileTalkDownloadRequest,
|
req: FileTalkDownloadRequest,
|
||||||
fileTalkDownloadUrl?: string
|
fileTalkDownloadUrl?: string
|
||||||
|
@ -105,7 +124,7 @@ export class CommonApiService {
|
||||||
!!fileTalkDownloadUrl
|
!!fileTalkDownloadUrl
|
||||||
? fileTalkDownloadUrl
|
? fileTalkDownloadUrl
|
||||||
: this.moduleConfig.urls.fileTalkDownload,
|
: this.moduleConfig.urls.fileTalkDownload,
|
||||||
encodeFileTalkDownload(req),
|
encodeFormDataFileTalkDownload(req),
|
||||||
{ reportProgress: true, responseType: 'blob' }
|
{ reportProgress: true, responseType: 'blob' }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ import {
|
||||||
APIRequest,
|
APIRequest,
|
||||||
APIResponse,
|
APIResponse,
|
||||||
APIEncoder,
|
APIEncoder,
|
||||||
APIDecoder
|
APIDecoder,
|
||||||
|
ParameterUtil
|
||||||
} from '@ucap-webmessenger/api';
|
} from '@ucap-webmessenger/api';
|
||||||
|
|
||||||
export interface CheckUserInfoExRequest extends APIRequest {
|
export interface CheckUserInfoExRequest extends APIRequest {
|
||||||
|
@ -15,14 +16,16 @@ export interface CheckUserInfoExResponse extends APIResponse {
|
||||||
userId?: string;
|
userId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkUserInfoExEncodeMap = {
|
||||||
|
userId: 'p_user_id',
|
||||||
|
companyCode: 'p_comp_code',
|
||||||
|
userSession: 'p_user_session'
|
||||||
|
};
|
||||||
|
|
||||||
export const encodeCheckUserInfoEx: APIEncoder<CheckUserInfoExRequest> = (
|
export const encodeCheckUserInfoEx: APIEncoder<CheckUserInfoExRequest> = (
|
||||||
req: CheckUserInfoExRequest
|
req: CheckUserInfoExRequest
|
||||||
) => {
|
) => {
|
||||||
return {
|
return ParameterUtil.encode(checkUserInfoExEncodeMap, req);
|
||||||
p_user_id: req.userId,
|
|
||||||
p_comp_code: req.companyCode,
|
|
||||||
p_user_session: req.userSession
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const decodeCheckUserInfoEx: APIDecoder<CheckUserInfoExResponse> = (
|
export const decodeCheckUserInfoEx: APIDecoder<CheckUserInfoExResponse> = (
|
||||||
|
|
|
@ -3,7 +3,8 @@ import {
|
||||||
APIRequest,
|
APIRequest,
|
||||||
APIResponse,
|
APIResponse,
|
||||||
APIEncoder,
|
APIEncoder,
|
||||||
APIDecoder
|
APIDecoder,
|
||||||
|
ParameterUtil
|
||||||
} from '@ucap-webmessenger/api';
|
} from '@ucap-webmessenger/api';
|
||||||
import { Company } from '../models/company';
|
import { Company } from '../models/company';
|
||||||
|
|
||||||
|
@ -19,16 +20,22 @@ export interface CompanyListResponse extends APIResponse {
|
||||||
companyList?: Company[];
|
companyList?: Company[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const companyListEncodeMap = {
|
||||||
|
userSeq: 'p_user_seq',
|
||||||
|
appType: 'p_app_type',
|
||||||
|
deviceType: 'p_device_type',
|
||||||
|
token: 'p_token',
|
||||||
|
companyGroupCode: 'p_comp_group_code'
|
||||||
|
};
|
||||||
|
|
||||||
export const encodeCompanyList: APIEncoder<CompanyListRequest> = (
|
export const encodeCompanyList: APIEncoder<CompanyListRequest> = (
|
||||||
req: CompanyListRequest
|
req: CompanyListRequest
|
||||||
) => {
|
) => {
|
||||||
return {
|
const extraParams: any = {};
|
||||||
p_user_seq: String(req.userSeq),
|
|
||||||
p_app_type: req.appType,
|
extraParams.userSeq = String(req.userSeq);
|
||||||
p_device_type: req.deviceType,
|
|
||||||
p_token: req.token,
|
return ParameterUtil.encode(companyListEncodeMap, req, extraParams);
|
||||||
p_comp_group_code: req.companyGroupCode
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const decodeCompanyList: APIDecoder<CompanyListResponse> = (
|
export const decodeCompanyList: APIDecoder<CompanyListResponse> = (
|
||||||
|
|
|
@ -3,7 +3,8 @@ import {
|
||||||
APIRequest,
|
APIRequest,
|
||||||
APIResponse,
|
APIResponse,
|
||||||
APIEncoder,
|
APIEncoder,
|
||||||
APIDecoder
|
APIDecoder,
|
||||||
|
ParameterUtil
|
||||||
} from '@ucap-webmessenger/api';
|
} from '@ucap-webmessenger/api';
|
||||||
|
|
||||||
export interface TokenUpdateRequest extends APIRequest {
|
export interface TokenUpdateRequest extends APIRequest {
|
||||||
|
@ -17,16 +18,22 @@ export interface TokenUpdateRequest extends APIRequest {
|
||||||
// tslint:disable-next-line: no-empty-interface
|
// tslint:disable-next-line: no-empty-interface
|
||||||
export interface TokenUpdateResponse extends APIResponse {}
|
export interface TokenUpdateResponse extends APIResponse {}
|
||||||
|
|
||||||
|
const tokenUpdateEncodeMap = {
|
||||||
|
userSeq: 'p_user_seq',
|
||||||
|
deviceType: 'p_device_type',
|
||||||
|
token: 'p_token',
|
||||||
|
mobilePid: 'p_mobile_pid',
|
||||||
|
pushType: 'p_push_type'
|
||||||
|
};
|
||||||
|
|
||||||
export const encodeTokenUpdate: APIEncoder<TokenUpdateRequest> = (
|
export const encodeTokenUpdate: APIEncoder<TokenUpdateRequest> = (
|
||||||
req: TokenUpdateRequest
|
req: TokenUpdateRequest
|
||||||
) => {
|
) => {
|
||||||
return {
|
const extraParams: any = {};
|
||||||
p_user_seq: String(req.userSeq),
|
|
||||||
p_device_type: req.deviceType,
|
extraParams.userSeq = String(req.userSeq);
|
||||||
p_token: req.token,
|
|
||||||
p_mobile_pid: req.mobilePid,
|
return ParameterUtil.encode(tokenUpdateEncodeMap, req, extraParams);
|
||||||
p_push_type: req.pushType
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const decodeTokenUpdate: APIDecoder<TokenUpdateResponse> = (
|
export const decodeTokenUpdate: APIDecoder<TokenUpdateResponse> = (
|
||||||
|
|
|
@ -3,7 +3,8 @@ import {
|
||||||
APIRequest,
|
APIRequest,
|
||||||
APIResponse,
|
APIResponse,
|
||||||
APIEncoder,
|
APIEncoder,
|
||||||
APIDecoder
|
APIDecoder,
|
||||||
|
ParameterUtil
|
||||||
} from '@ucap-webmessenger/api';
|
} from '@ucap-webmessenger/api';
|
||||||
|
|
||||||
export interface UrlInfoRequest extends APIRequest {
|
export interface UrlInfoRequest extends APIRequest {
|
||||||
|
@ -25,12 +26,14 @@ export interface UrlInfoResponse extends APIResponse {
|
||||||
synapViewUrl?: string;
|
synapViewUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const urlInfoEncodeMap = {
|
||||||
|
deviceType: 'p_device_type'
|
||||||
|
};
|
||||||
|
|
||||||
export const encodeUrlInfo: APIEncoder<UrlInfoRequest> = (
|
export const encodeUrlInfo: APIEncoder<UrlInfoRequest> = (
|
||||||
req: UrlInfoRequest
|
req: UrlInfoRequest
|
||||||
) => {
|
) => {
|
||||||
return {
|
return ParameterUtil.encode(urlInfoEncodeMap, req);
|
||||||
p_device_type: req.deviceType
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const decodeUrlInfo: APIDecoder<UrlInfoResponse> = (res: any) => {
|
export const decodeUrlInfo: APIDecoder<UrlInfoResponse> = (res: any) => {
|
||||||
|
|
|
@ -12,13 +12,7 @@ export interface APIResponse {
|
||||||
errorMessage: string;
|
errorMessage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type APIEncoder<REQ> = (
|
export type APIEncoder<REQ> = (req: REQ) => HttpParams;
|
||||||
req: REQ
|
|
||||||
) =>
|
|
||||||
| HttpParams
|
|
||||||
| {
|
|
||||||
[param: string]: string | string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type APIFormDataEncoder<REQ> = (req: REQ) => FormData;
|
export type APIFormDataEncoder<REQ> = (req: REQ) => FormData;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export type Parameter = {
|
import { HttpParams } from '@angular/common/http';
|
||||||
[param: string]: string | string[];
|
|
||||||
} | null;
|
export type Parameter = HttpParams | null;
|
||||||
|
|
||||||
export class ParameterUtil {
|
export class ParameterUtil {
|
||||||
public static encode(
|
public static encode(
|
||||||
|
@ -8,7 +8,7 @@ export class ParameterUtil {
|
||||||
param: {},
|
param: {},
|
||||||
extraParam?: {}
|
extraParam?: {}
|
||||||
): Parameter {
|
): Parameter {
|
||||||
const parameter: Parameter = {};
|
let parameter: HttpParams = new HttpParams();
|
||||||
|
|
||||||
Object.keys(parameterMap).map(key => {
|
Object.keys(parameterMap).map(key => {
|
||||||
if (!param.hasOwnProperty(key)) {
|
if (!param.hasOwnProperty(key)) {
|
||||||
|
@ -23,11 +23,15 @@ export class ParameterUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!v) {
|
if (!!v) {
|
||||||
parameter[parameterMap[key]] = v;
|
if (parameter.has(parameterMap[key])) {
|
||||||
|
parameter = parameter.append(parameterMap[key], v);
|
||||||
|
} else {
|
||||||
|
parameter = parameter.set(parameterMap[key], v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return 0 === Object.keys(parameter).length ? null : parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static encodeFormData(
|
public static encodeFormData(
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { HttpParams } from '@angular/common/http';
|
||||||
|
|
||||||
export class UrlUtil {
|
export class UrlUtil {
|
||||||
public static format(href: string, param: Parameter): string {
|
public static format(href: string, param: Parameter): string {
|
||||||
const params = new HttpParams({ fromObject: param }).toString();
|
const params = param.toString();
|
||||||
|
|
||||||
if (params.length === 0) {
|
if (params.length === 0) {
|
||||||
return href;
|
return href;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { CommonModule } from '@angular/common';
|
||||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||||
|
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||||
|
|
||||||
import { UCapUiModule } from '@ucap-webmessenger/ui';
|
import { UCapUiModule } from '@ucap-webmessenger/ui';
|
||||||
|
@ -16,6 +17,7 @@ import { DIALOGS } from './dialogs';
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FlexLayoutModule,
|
FlexLayoutModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
|
MatProgressBarModule,
|
||||||
MatToolbarModule,
|
MatToolbarModule,
|
||||||
UCapUiModule
|
UCapUiModule
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
<mat-progress-bar
|
||||||
|
*ngIf="fileDownloadItem && fileDownloadItem.downloadingProgress$"
|
||||||
|
mode="determinate"
|
||||||
|
[value]="fileDownloadItem.downloadingProgress$ | async"
|
||||||
|
></mat-progress-bar>
|
||||||
<ucap-file-viewer
|
<ucap-file-viewer
|
||||||
[fileInfo]="fileInfo"
|
[fileInfo]="fileInfo"
|
||||||
[downloadUrl]="downloadUrl"
|
[fileDownloadUrl]="fileDownloadUrl"
|
||||||
[userSeq]="userSeq"
|
(download)="onDownload()"
|
||||||
[deviceType]="deviceType"
|
|
||||||
[token]="token"
|
|
||||||
(download)="onDownload($event)"
|
|
||||||
(closed)="onClosedViewer()"
|
(closed)="onClosedViewer()"
|
||||||
></ucap-file-viewer>
|
></ucap-file-viewer>
|
||||||
|
|
|
@ -9,10 +9,14 @@ import {
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
|
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
|
||||||
import { DeviceType, FileUtil } from '@ucap-webmessenger/core';
|
import { DeviceType, FileUtil, MimeUtil } from '@ucap-webmessenger/core';
|
||||||
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
||||||
import { take } from 'rxjs/operators';
|
import { take, map, finalize, tap } from 'rxjs/operators';
|
||||||
import { SnackBarService } from '@ucap-webmessenger/ui';
|
import { SnackBarService } from '@ucap-webmessenger/ui';
|
||||||
|
import {
|
||||||
|
FileDownloadItem,
|
||||||
|
CommonApiService
|
||||||
|
} from '@ucap-webmessenger/api-common';
|
||||||
|
|
||||||
export interface FileViewerDialogData {
|
export interface FileViewerDialogData {
|
||||||
fileInfo: FileEventJson;
|
fileInfo: FileEventJson;
|
||||||
|
@ -36,6 +40,10 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
|
||||||
deviceType: DeviceType;
|
deviceType: DeviceType;
|
||||||
token: string;
|
token: string;
|
||||||
|
|
||||||
|
fileDownloadItem: FileDownloadItem;
|
||||||
|
|
||||||
|
fileDownloadUrl: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<
|
public dialogRef: MatDialogRef<
|
||||||
FileViewerDialogData,
|
FileViewerDialogData,
|
||||||
|
@ -44,6 +52,7 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
|
||||||
@Inject(MAT_DIALOG_DATA) public data: FileViewerDialogData,
|
@Inject(MAT_DIALOG_DATA) public data: FileViewerDialogData,
|
||||||
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
||||||
private snackBarService: SnackBarService,
|
private snackBarService: SnackBarService,
|
||||||
|
private commonApiService: CommonApiService,
|
||||||
private logger: NGXLogger
|
private logger: NGXLogger
|
||||||
) {
|
) {
|
||||||
this.fileInfo = data.fileInfo;
|
this.fileInfo = data.fileInfo;
|
||||||
|
@ -51,13 +60,44 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
|
||||||
this.userSeq = data.userSeq;
|
this.userSeq = data.userSeq;
|
||||||
this.deviceType = data.deviceType;
|
this.deviceType = data.deviceType;
|
||||||
this.token = data.token;
|
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() {}
|
ngOnInit() {}
|
||||||
|
|
||||||
ngOnDestroy(): void {}
|
ngOnDestroy(): void {}
|
||||||
|
|
||||||
onDownload(blob: Blob): void {
|
onDownload(): void {
|
||||||
|
this.fileDownloadItem = new FileDownloadItem();
|
||||||
|
this.commonApiService
|
||||||
|
.fileTalkDownload(
|
||||||
|
{
|
||||||
|
userSeq: this.userSeq,
|
||||||
|
deviceType: this.deviceType,
|
||||||
|
token: this.token,
|
||||||
|
attachmentsSeq: this.fileInfo.attachmentSeq,
|
||||||
|
fileDownloadItem: this.fileDownloadItem
|
||||||
|
},
|
||||||
|
this.downloadUrl
|
||||||
|
)
|
||||||
|
.pipe(
|
||||||
|
take(1),
|
||||||
|
map(async rawBlob => {
|
||||||
|
const blob = rawBlob.slice(
|
||||||
|
0,
|
||||||
|
rawBlob.size,
|
||||||
|
MimeUtil.getMimeFromExtension(this.fileInfo.fileExt)
|
||||||
|
);
|
||||||
|
|
||||||
FileUtil.fromBlobToBuffer(blob)
|
FileUtil.fromBlobToBuffer(blob)
|
||||||
.then(buffer => {
|
.then(buffer => {
|
||||||
this.nativeService
|
this.nativeService
|
||||||
|
@ -81,6 +121,12 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
|
||||||
.catch(reason => {
|
.catch(reason => {
|
||||||
this.logger.error('download', reason);
|
this.logger.error('download', reason);
|
||||||
});
|
});
|
||||||
|
}),
|
||||||
|
finalize(() => {
|
||||||
|
this.fileDownloadItem = undefined;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosedViewer(): void {
|
onClosedViewer(): void {
|
||||||
|
|
|
@ -5,51 +5,36 @@
|
||||||
<ucap-document-viewer
|
<ucap-document-viewer
|
||||||
*ngSwitchCase="FileViewerType.Document"
|
*ngSwitchCase="FileViewerType.Document"
|
||||||
[fileInfo]="fileInfo"
|
[fileInfo]="fileInfo"
|
||||||
[downloadUrl]="downloadUrl"
|
[fileDownloadUrl]="fileDownloadUrl"
|
||||||
[userSeq]="userSeq"
|
(download)="onDownload()"
|
||||||
[deviceType]="deviceType"
|
|
||||||
[token]="token"
|
|
||||||
(download)="onDownload($event)"
|
|
||||||
(closed)="onClosedViewer()"
|
(closed)="onClosedViewer()"
|
||||||
></ucap-document-viewer>
|
></ucap-document-viewer>
|
||||||
<ucap-image-viewer
|
<ucap-image-viewer
|
||||||
*ngSwitchCase="FileViewerType.Image"
|
*ngSwitchCase="FileViewerType.Image"
|
||||||
[fileInfo]="fileInfo"
|
[fileInfo]="fileInfo"
|
||||||
[downloadUrl]="downloadUrl"
|
[fileDownloadUrl]="fileDownloadUrl"
|
||||||
[userSeq]="userSeq"
|
(download)="onDownload()"
|
||||||
[deviceType]="deviceType"
|
|
||||||
[token]="token"
|
|
||||||
(download)="onDownload($event)"
|
|
||||||
(closed)="onClosedViewer()"
|
(closed)="onClosedViewer()"
|
||||||
></ucap-image-viewer>
|
></ucap-image-viewer>
|
||||||
<ucap-sound-viewer
|
<ucap-sound-viewer
|
||||||
*ngSwitchCase="FileViewerType.Sound"
|
*ngSwitchCase="FileViewerType.Sound"
|
||||||
[fileInfo]="fileInfo"
|
[fileInfo]="fileInfo"
|
||||||
[downloadUrl]="downloadUrl"
|
[fileDownloadUrl]="fileDownloadUrl"
|
||||||
[userSeq]="userSeq"
|
(download)="onDownload()"
|
||||||
[deviceType]="deviceType"
|
|
||||||
[token]="token"
|
|
||||||
(download)="onDownload($event)"
|
|
||||||
(closed)="onClosedViewer()"
|
(closed)="onClosedViewer()"
|
||||||
></ucap-sound-viewer>
|
></ucap-sound-viewer>
|
||||||
<ucap-video-viewer
|
<ucap-video-viewer
|
||||||
*ngSwitchCase="FileViewerType.Video"
|
*ngSwitchCase="FileViewerType.Video"
|
||||||
[fileInfo]="fileInfo"
|
[fileInfo]="fileInfo"
|
||||||
[downloadUrl]="downloadUrl"
|
[fileDownloadUrl]="fileDownloadUrl"
|
||||||
[userSeq]="userSeq"
|
(download)="onDownload()"
|
||||||
[deviceType]="deviceType"
|
|
||||||
[token]="token"
|
|
||||||
(download)="onDownload($event)"
|
|
||||||
(closed)="onClosedViewer()"
|
(closed)="onClosedViewer()"
|
||||||
></ucap-video-viewer>
|
></ucap-video-viewer>
|
||||||
<ucap-binary-viewer
|
<ucap-binary-viewer
|
||||||
*ngSwitchDefault
|
*ngSwitchDefault
|
||||||
[fileInfo]="fileInfo"
|
[fileInfo]="fileInfo"
|
||||||
[downloadUrl]="downloadUrl"
|
[fileDownloadUrl]="fileDownloadUrl"
|
||||||
[userSeq]="userSeq"
|
(download)="onDownload()"
|
||||||
[deviceType]="deviceType"
|
|
||||||
[token]="token"
|
|
||||||
(download)="onDownload($event)"
|
|
||||||
(closed)="onClosedViewer()"
|
(closed)="onClosedViewer()"
|
||||||
></ucap-binary-viewer>
|
></ucap-binary-viewer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { ucapAnimations } from '../animations';
|
import { ucapAnimations } from '../animations';
|
||||||
import { Info, FileEventJson } from '@ucap-webmessenger/protocol-event';
|
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
|
||||||
import { FileViewerType } from '../types/file-viewer.type';
|
import { FileViewerType } from '../types/file-viewer.type';
|
||||||
import { FileType } from '@ucap-webmessenger/protocol-file';
|
import { FileType } from '@ucap-webmessenger/protocol-file';
|
||||||
import { DeviceType } from '@ucap-webmessenger/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ucap-file-viewer',
|
selector: 'ucap-file-viewer',
|
||||||
|
@ -16,19 +15,10 @@ export class FileViewerComponent implements OnInit {
|
||||||
fileInfo: FileEventJson;
|
fileInfo: FileEventJson;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
downloadUrl: string;
|
fileDownloadUrl: string;
|
||||||
|
|
||||||
@Input()
|
|
||||||
userSeq: number;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
deviceType: DeviceType;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
token: string;
|
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
download = new EventEmitter<Blob>();
|
download = new EventEmitter<void>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
closed = new EventEmitter<void>();
|
closed = new EventEmitter<void>();
|
||||||
|
@ -51,8 +41,8 @@ export class FileViewerComponent implements OnInit {
|
||||||
return FileViewerType.Binary;
|
return FileViewerType.Binary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onDownload(blob: Blob): void {
|
onDownload(): void {
|
||||||
this.download.emit(blob);
|
this.download.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosedViewer(): void {
|
onClosedViewer(): void {
|
||||||
|
|
|
@ -14,19 +14,10 @@ export class BinaryViewerComponent implements OnInit {
|
||||||
fileInfo: FileEventJson;
|
fileInfo: FileEventJson;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
downloadUrl: string;
|
fileDownloadUrl: string;
|
||||||
|
|
||||||
@Input()
|
|
||||||
userSeq: number;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
deviceType: DeviceType;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
token: string;
|
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
download = new EventEmitter<Blob>();
|
download = new EventEmitter<void>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
closed = new EventEmitter<void>();
|
closed = new EventEmitter<void>();
|
||||||
|
|
|
@ -14,19 +14,10 @@ export class DocumentViewerComponent implements OnInit {
|
||||||
fileInfo: FileEventJson;
|
fileInfo: FileEventJson;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
downloadUrl: string;
|
fileDownloadUrl: string;
|
||||||
|
|
||||||
@Input()
|
|
||||||
userSeq: number;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
deviceType: DeviceType;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
token: string;
|
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
download = new EventEmitter<Blob>();
|
download = new EventEmitter<void>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
closed = new EventEmitter<void>();
|
closed = new EventEmitter<void>();
|
||||||
|
|
|
@ -51,11 +51,6 @@
|
||||||
Close
|
Close
|
||||||
</button>
|
</button>
|
||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
<mat-progress-bar
|
|
||||||
*ngIf="fileDownloadItem.downloadingProgress$ && !imageSrc"
|
|
||||||
mode="determinate"
|
|
||||||
[value]="fileDownloadItem.downloadingProgress$ | async"
|
|
||||||
></mat-progress-bar>
|
|
||||||
<div class="ucap-image-viewer-body">
|
<div class="ucap-image-viewer-body">
|
||||||
<div
|
<div
|
||||||
class="ucap-image-viewer-image-wrapper"
|
class="ucap-image-viewer-image-wrapper"
|
||||||
|
@ -64,7 +59,7 @@
|
||||||
fxFlexFill
|
fxFlexFill
|
||||||
fxLayoutAlign="center center"
|
fxLayoutAlign="center center"
|
||||||
>
|
>
|
||||||
<img *ngIf="imageSrc" [src]="imageSrc" />
|
<img *ngIf="fileDownloadUrl" [src]="fileDownloadUrl" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { ucapAnimations } from '../../animations';
|
import { ucapAnimations } from '../../animations';
|
||||||
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
|
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
|
||||||
import { DeviceType, FileUtil, MimeUtil } from '@ucap-webmessenger/core';
|
import { DeviceType } from '@ucap-webmessenger/core';
|
||||||
import {
|
import { CommonApiService } from '@ucap-webmessenger/api-common';
|
||||||
CommonApiService,
|
|
||||||
FileDownloadItem
|
|
||||||
} from '@ucap-webmessenger/api-common';
|
|
||||||
import { take, map } from 'rxjs/operators';
|
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ucap-image-viewer',
|
selector: 'ucap-image-viewer',
|
||||||
|
@ -20,63 +15,20 @@ export class ImageViewerComponent implements OnInit {
|
||||||
fileInfo: FileEventJson;
|
fileInfo: FileEventJson;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
downloadUrl: string;
|
fileDownloadUrl: string;
|
||||||
|
|
||||||
@Input()
|
|
||||||
userSeq: number;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
deviceType: DeviceType;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
token: string;
|
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
closed = new EventEmitter<void>();
|
closed = new EventEmitter<void>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
download = new EventEmitter<Blob>();
|
download = new EventEmitter<void>();
|
||||||
|
|
||||||
blob: Blob;
|
constructor() {}
|
||||||
imageSrc: string | ArrayBuffer;
|
|
||||||
|
|
||||||
fileDownloadItem: FileDownloadItem;
|
ngOnInit() {}
|
||||||
|
|
||||||
constructor(
|
|
||||||
private domSanitizer: DomSanitizer,
|
|
||||||
private commonApiService: CommonApiService
|
|
||||||
) {
|
|
||||||
this.fileDownloadItem = new FileDownloadItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.commonApiService
|
|
||||||
.fileTalkDownload(
|
|
||||||
{
|
|
||||||
userSeq: this.userSeq,
|
|
||||||
deviceType: this.deviceType,
|
|
||||||
token: this.token,
|
|
||||||
attachmentsSeq: this.fileInfo.attachmentSeq,
|
|
||||||
fileDownloadItem: this.fileDownloadItem
|
|
||||||
},
|
|
||||||
this.downloadUrl
|
|
||||||
)
|
|
||||||
.pipe(
|
|
||||||
take(1),
|
|
||||||
map(async blob => {
|
|
||||||
this.blob = blob.slice(
|
|
||||||
0,
|
|
||||||
blob.size,
|
|
||||||
MimeUtil.getMimeFromExtension(this.fileInfo.fileExt)
|
|
||||||
);
|
|
||||||
this.imageSrc = await FileUtil.fromBlobToDataUrl(this.blob);
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.subscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
onClickDownload(): void {
|
onClickDownload(): void {
|
||||||
this.download.emit(this.blob);
|
this.download.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickClose(): void {
|
onClickClose(): void {
|
||||||
|
|
|
@ -14,19 +14,10 @@ export class SoundViewerComponent implements OnInit {
|
||||||
fileInfo: FileEventJson;
|
fileInfo: FileEventJson;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
downloadUrl: string;
|
fileDownloadUrl: string;
|
||||||
|
|
||||||
@Input()
|
|
||||||
userSeq: number;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
deviceType: DeviceType;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
token: string;
|
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
download = new EventEmitter<Blob>();
|
download = new EventEmitter<void>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
closed = new EventEmitter<void>();
|
closed = new EventEmitter<void>();
|
||||||
|
|
|
@ -14,19 +14,10 @@ export class VideoViewerComponent implements OnInit {
|
||||||
fileInfo: FileEventJson;
|
fileInfo: FileEventJson;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
downloadUrl: string;
|
fileDownloadUrl: string;
|
||||||
|
|
||||||
@Input()
|
|
||||||
userSeq: number;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
deviceType: DeviceType;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
token: string;
|
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
download = new EventEmitter<Blob>();
|
download = new EventEmitter<void>();
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
closed = new EventEmitter<void>();
|
closed = new EventEmitter<void>();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user