143 lines
4.1 KiB
TypeScript
143 lines
4.1 KiB
TypeScript
|
import { Component, OnInit, Inject, ViewChild } from '@angular/core';
|
||
|
import {
|
||
|
MatDialogRef,
|
||
|
MAT_DIALOG_DATA,
|
||
|
MatSelectionList,
|
||
|
MatSelectionListChange
|
||
|
} from '@angular/material';
|
||
|
import { Observable, combineLatest, of } from 'rxjs';
|
||
|
import { Store, select } from '@ngrx/store';
|
||
|
import { map, catchError, take } from 'rxjs/operators';
|
||
|
|
||
|
import * as AppStore from '@app/store';
|
||
|
import * as SyncStore from '@app/store/messenger/sync';
|
||
|
|
||
|
import {
|
||
|
DialogService,
|
||
|
ConfirmDialogComponent,
|
||
|
ConfirmDialogData,
|
||
|
ConfirmDialogResult
|
||
|
} from '@ucap-webmessenger/ui';
|
||
|
import { GroupDetailData, UserInfo } from '@ucap-webmessenger/protocol-sync';
|
||
|
import {
|
||
|
DetailResponse,
|
||
|
MessageType,
|
||
|
MessageList,
|
||
|
DetailContent,
|
||
|
DetailReceiver,
|
||
|
ContentType,
|
||
|
MessageDetailInfo,
|
||
|
MessageApiService,
|
||
|
RetrieveResourceFileRequest
|
||
|
} from '@ucap-webmessenger/api-message';
|
||
|
import { DeviceType } from '@ucap-webmessenger/core';
|
||
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||
|
import { NGXLogger } from 'ngx-logger';
|
||
|
|
||
|
export interface MessageDetailDialogData {
|
||
|
detail: DetailResponse;
|
||
|
loginRes: LoginResponse;
|
||
|
}
|
||
|
|
||
|
// tslint:disable-next-line: no-empty-interface
|
||
|
export interface MessageDetailDialogResult {}
|
||
|
|
||
|
@Component({
|
||
|
selector: 'app-layout-messenger-message-detail',
|
||
|
templateUrl: './message-detail.dialog.component.html',
|
||
|
styleUrls: ['./message-detail.dialog.component.scss']
|
||
|
})
|
||
|
export class MessageDetailDialogComponent implements OnInit {
|
||
|
messageDetail: DetailResponse;
|
||
|
messageInfo: MessageDetailInfo;
|
||
|
contents: DetailContent[] = [];
|
||
|
attachFile: DetailContent[] = [];
|
||
|
receivers: DetailReceiver[] = [];
|
||
|
|
||
|
isExpiredAttachFile = true;
|
||
|
|
||
|
MessageType = MessageType;
|
||
|
ContentType = ContentType;
|
||
|
|
||
|
constructor(
|
||
|
public dialogRef: MatDialogRef<
|
||
|
MessageDetailDialogData,
|
||
|
MessageDetailDialogResult
|
||
|
>,
|
||
|
@Inject(MAT_DIALOG_DATA) public data: MessageDetailDialogData,
|
||
|
private messageApiService: MessageApiService,
|
||
|
private logger: NGXLogger,
|
||
|
private store: Store<any>,
|
||
|
private dialogService: DialogService
|
||
|
) {}
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
this.messageDetail = this.data.detail;
|
||
|
this.messageInfo = this.messageDetail.msgInfo;
|
||
|
|
||
|
if (
|
||
|
!!this.messageDetail.contents &&
|
||
|
this.messageDetail.contents.length > 0
|
||
|
) {
|
||
|
this.messageDetail.contents.forEach(cont => {
|
||
|
if (cont.resType !== ContentType.AttachFile) {
|
||
|
this.contents.push(cont);
|
||
|
} else if (cont.resType === ContentType.AttachFile) {
|
||
|
if (cont.activeYn) {
|
||
|
this.isExpiredAttachFile = false;
|
||
|
}
|
||
|
this.attachFile.push(cont);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
this.receivers = this.messageDetail.recvList;
|
||
|
}
|
||
|
|
||
|
getThumbImage(content: DetailContent): string {
|
||
|
console.log(
|
||
|
JSON.stringify({
|
||
|
userSeq: this.data.loginRes.userSeq,
|
||
|
deviceType: DeviceType.PC,
|
||
|
tokenKey: this.data.loginRes.tokenString,
|
||
|
type: this.messageInfo.type,
|
||
|
msgId: this.messageInfo.msgId,
|
||
|
resUrl: content.thumbnailUrl
|
||
|
})
|
||
|
);
|
||
|
if (content.resType === ContentType.Image) {
|
||
|
// // return this.messageApiService.urlForFileMessageDownload({
|
||
|
// // userSeq: this.data.loginRes.userSeq,
|
||
|
// // deviceType: DeviceType.PC,
|
||
|
// // tokenKey: this.data.loginRes.tokenString,
|
||
|
// // type: this.messageInfo.type,
|
||
|
// // msgId: this.messageInfo.msgId,
|
||
|
// // resUrl: content.thumbnailUrl
|
||
|
// // } as RetrieveResourceFileRequest);
|
||
|
// this.messageApiService
|
||
|
// .retrieveResourceFile({
|
||
|
// userSeq: this.data.loginRes.userSeq,
|
||
|
// deviceType: DeviceType.PC,
|
||
|
// tokenKey: this.data.loginRes.tokenString,
|
||
|
// type: this.messageInfo.type,
|
||
|
// msgId: this.messageInfo.msgId,
|
||
|
// resUrl: content.thumbnailUrl
|
||
|
// } as RetrieveResourceFileRequest)
|
||
|
// .pipe(
|
||
|
// take(1),
|
||
|
// map(async rawBlob => {
|
||
|
// console.log(rawBlob);
|
||
|
// return URL.createObjectURL(rawBlob);
|
||
|
// })
|
||
|
// )
|
||
|
// .subscribe();
|
||
|
} else {
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onClickConfirm(): void {
|
||
|
this.dialogRef.close({});
|
||
|
}
|
||
|
}
|