프로필 > 프로필이미지 원본보기 기능 추가.

This commit is contained in:
leejinho 2020-03-17 15:19:43 +09:00
parent 73f330aa70
commit f1f1ae307e
12 changed files with 150 additions and 22 deletions

View File

@ -1,6 +1,8 @@
<ucap-file-viewer <ucap-file-viewer
[fileInfo]="fileInfo" [fileInfo]="fileInfo"
[fileDownloadUrl]="fileDownloadUrl" [fileDownloadUrl]="fileDownloadUrl"
[imageOnly]="imageOnly"
[imageOnlyData]="imageOnlyData"
(download)="onDownload($event)" (download)="onDownload($event)"
(closed)="onClosedViewer()" (closed)="onClosedViewer()"
></ucap-file-viewer> ></ucap-file-viewer>

View File

@ -7,6 +7,7 @@ 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';
export interface FileViewerDialogData { export interface FileViewerDialogData {
fileInfo: FileEventJson; fileInfo: FileEventJson;
@ -14,6 +15,8 @@ export interface FileViewerDialogData {
userSeq: number; userSeq: number;
deviceType: DeviceType; deviceType: DeviceType;
token: string; token: string;
imageOnly?: boolean;
imageOnlyData?: ImageOnlyDataInfo;
} }
export interface FileViewerDialogResult {} export interface FileViewerDialogResult {}
@ -32,6 +35,9 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
fileDownloadUrl: string; fileDownloadUrl: string;
imageOnly = false;
imageOnlyData: ImageOnlyDataInfo;
constructor( constructor(
public dialogRef: MatDialogRef< public dialogRef: MatDialogRef<
FileViewerDialogData, FileViewerDialogData,
@ -47,7 +53,17 @@ 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;
}
ngOnInit() {
if (!!this.data.imageOnly) {
this.imageOnly = this.data.imageOnly;
this.imageOnlyData = this.data.imageOnlyData;
}
if (!!this.imageOnly) {
this.fileDownloadUrl = this.imageOnlyData.imageUrl;
} else {
this.fileDownloadUrl = this.commonApiService.urlForFileTalkDownload( this.fileDownloadUrl = this.commonApiService.urlForFileTalkDownload(
{ {
userSeq: this.userSeq, userSeq: this.userSeq,
@ -58,8 +74,7 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
this.downloadUrl this.downloadUrl
); );
} }
}
ngOnInit() {}
ngOnDestroy(): void {} ngOnDestroy(): void {}

View File

@ -9,6 +9,7 @@
[openProfileOptions]="data.openProfileOptions" [openProfileOptions]="data.openProfileOptions"
[useBuddyToggleButton]="useBuddyToggleButton" [useBuddyToggleButton]="useBuddyToggleButton"
[authInfo]="authInfo" [authInfo]="authInfo"
(profileImageView)="onClickProfileImageView()"
(openChat)="onClickChat($event)" (openChat)="onClickChat($event)"
(sendMessage)="onClickSendMessage($event)" (sendMessage)="onClickSendMessage($event)"
(sendCall)="onClickSendClickToCall($event)" (sendCall)="onClickSendClickToCall($event)"

View File

@ -24,7 +24,8 @@ import {
SnackBarService, SnackBarService,
AlertDialogComponent, AlertDialogComponent,
AlertDialogResult, AlertDialogResult,
AlertDialogData AlertDialogData,
ImageOnlyDataInfo
} from '@ucap-webmessenger/ui'; } from '@ucap-webmessenger/ui';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
@ -56,6 +57,13 @@ import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
import { environment } from '../../../../../environments/environment'; import { environment } from '../../../../../environments/environment';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { UserInfoUpdateType } from '@ucap-webmessenger/protocol-info'; import { UserInfoUpdateType } from '@ucap-webmessenger/protocol-info';
import {
FileViewerDialogComponent,
FileViewerDialogData,
FileViewerDialogResult
} from '@app/layouts/common/dialogs/file-viewer.dialog.component';
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
import { FileType } from '@ucap-webmessenger/protocol-file';
export interface ProfileDialogData { export interface ProfileDialogData {
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN; userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
@ -451,6 +459,43 @@ export class ProfileDialogComponent implements OnInit, OnDestroy {
); );
} }
onClickProfileImageView() {
if (!this.loginRes || !this.loginRes.userInfo.profileImageFile) {
return;
}
const imageOnlyData: ImageOnlyDataInfo = {
imageUrl: this.userInfo.profileImageFile,
imageRootUrl: this.sessionVerinfo.profileRoot,
defaultImage: 'assets/images/img_nophoto_50.png',
fileName: this.userInfo.name
};
this.dialogService.open<
FileViewerDialogComponent,
FileViewerDialogData,
FileViewerDialogResult
>(FileViewerDialogComponent, {
position: {
top: '50px'
},
maxWidth: '100vw',
maxHeight: '100vh',
height: 'calc(100% - 50px)',
width: '100%',
panelClass: 'app-dialog-full',
data: {
imageOnly: true,
imageOnlyData,
fileInfo: {},
downloadUrl: this.sessionVerinfo.downloadUrl,
deviceType: this.environmentsInfo.deviceType,
token: this.loginRes.tokenString,
userSeq: this.loginRes.userSeq
}
});
}
onUpdateIntro(intro: string) { onUpdateIntro(intro: string) {
this.store.dispatch( this.store.dispatch(
AuthenticationStore.infoUser({ AuthenticationStore.infoUser({

View File

@ -1,7 +1,11 @@
<mat-card class="example-card profile mat-elevation-z"> <mat-card class="example-card profile mat-elevation-z">
<mat-card-header> <mat-card-header>
<div class="profile-img"> <div class="profile-img">
<div class="profile-img-mask"> <div
class="profile-img-mask"
(click)="onClickProfileImageView()"
style="cursor: pointer;"
>
<img <img
ucapImage ucapImage
[base]="profileImageRoot" [base]="profileImageRoot"

View File

@ -45,6 +45,8 @@ export class ProfileComponent implements OnInit {
@Input() @Input()
authInfo: AuthResponse; authInfo: AuthResponse;
@Output()
profileImageView = new EventEmitter<void>();
@Output() @Output()
openChat = new EventEmitter<UserInfoSS>(); openChat = new EventEmitter<UserInfoSS>();
@Output() @Output()
@ -86,6 +88,10 @@ export class ProfileComponent implements OnInit {
ngOnInit() {} ngOnInit() {}
onClickProfileImageView() {
this.profileImageView.emit();
}
onClickOpenChat() { onClickOpenChat() {
this.openChat.emit(this.userInfo); this.openChat.emit(this.userInfo);
} }

View File

@ -13,6 +13,8 @@
*ngSwitchCase="FileViewerType.Image" *ngSwitchCase="FileViewerType.Image"
[fileInfo]="fileInfo" [fileInfo]="fileInfo"
[fileDownloadUrl]="fileDownloadUrl" [fileDownloadUrl]="fileDownloadUrl"
[imageOnly]="imageOnly"
[imageOnlyData]="imageOnlyData"
(download)="onDownload($event)" (download)="onDownload($event)"
(closed)="onClosedViewer()" (closed)="onClosedViewer()"
></ucap-image-viewer> ></ucap-image-viewer>

View File

@ -4,6 +4,7 @@ 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 { FileDownloadItem } from '@ucap-webmessenger/api'; import { FileDownloadItem } from '@ucap-webmessenger/api';
import { ImageOnlyDataInfo } from '../models/image-only-data-info';
@Component({ @Component({
selector: 'ucap-file-viewer', selector: 'ucap-file-viewer',
@ -18,6 +19,11 @@ export class FileViewerComponent implements OnInit {
@Input() @Input()
fileDownloadUrl: string; fileDownloadUrl: string;
@Input()
imageOnly = false;
@Input()
imageOnlyData?: ImageOnlyDataInfo;
@Output() @Output()
download = new EventEmitter<FileDownloadItem>(); download = new EventEmitter<FileDownloadItem>();
@ -31,6 +37,10 @@ export class FileViewerComponent implements OnInit {
ngOnInit() {} ngOnInit() {}
detectFileViewerType(fileInfo: FileEventJson): FileViewerType { detectFileViewerType(fileInfo: FileEventJson): FileViewerType {
if (!!this.imageOnly) {
return FileViewerType.Image;
}
switch (fileInfo.fileType) { switch (fileInfo.fileType) {
case FileType.Image: case FileType.Image:
return FileViewerType.Image; return FileViewerType.Image;

View File

@ -17,10 +17,21 @@
<circle cx="8.5" cy="8.5" r="1.5" /> <circle cx="8.5" cy="8.5" r="1.5" />
<path d="M20.4 14.5L16 10 4 20" /> <path d="M20.4 14.5L16 10 4 20" />
</svg> </svg>
<span class="ucap-image-viewer-title">{{ fileInfo.fileName }}</span> <span class="ucap-image-viewer-title">
<ng-container
*ngIf="imageOnly; then imageOnlyName; else defaultName"
></ng-container>
<ng-template #imageOnlyName>
{{ imageOnlyData.fileName }}
</ng-template>
<ng-template #defaultName>
{{ fileInfo.fileName }}
</ng-template>
</span>
<span class="ucap-image-viewer-spacer"></span> <span class="ucap-image-viewer-spacer"></span>
<button <button
*ngIf="!imageOnly"
mat-icon-button mat-icon-button
class="ucap-image-viewer-action" class="ucap-image-viewer-action"
matTooltip="{{ 'common.messages.zoomReset' | translate }}" matTooltip="{{ 'common.messages.zoomReset' | translate }}"
@ -47,6 +58,7 @@
</svg> </svg>
</button> </button>
<button <button
*ngIf="!imageOnly"
mat-icon-button mat-icon-button
class="ucap-image-viewer-action" class="ucap-image-viewer-action"
matTooltip="{{ 'common.messages.zoomOut' | translate }}" matTooltip="{{ 'common.messages.zoomOut' | translate }}"
@ -72,6 +84,7 @@
</svg> </svg>
</button> </button>
<button <button
*ngIf="!imageOnly"
mat-icon-button mat-icon-button
class="ucap-image-viewer-action" class="ucap-image-viewer-action"
matTooltip="{{ 'common.messages.zoomIn' | translate }}" matTooltip="{{ 'common.messages.zoomIn' | translate }}"
@ -98,6 +111,7 @@
</svg> </svg>
</button> </button>
<button <button
*ngIf="!imageOnly"
mat-icon-button mat-icon-button
class="ucap-image-viewer-action" class="ucap-image-viewer-action"
matTooltip="{{ 'common.file.download' | translate }}" matTooltip="{{ 'common.file.download' | translate }}"
@ -166,6 +180,20 @@
fxFlexFill fxFlexFill
fxLayoutAlign="center center" fxLayoutAlign="center center"
> >
<ng-container
*ngIf="imageOnly; then imageOnlyImg; else defaultImg"
></ng-container>
<ng-template #imageOnlyImg>
<img
ucapImage
[base]="imageOnlyData.imageRootUrl"
[path]="imageOnlyData.imageUrl"
[default]="imageOnlyData.defaultImage"
style="cursor: pointer; width: auto;"
(click)="onClickClose()"
/>
</ng-template>
<ng-template #defaultImg>
<img <img
#downloadImage #downloadImage
*ngIf="fileDownloadUrl" *ngIf="fileDownloadUrl"
@ -174,6 +202,7 @@
[style.height]="imageHeight + 'px'" [style.height]="imageHeight + 'px'"
(load)="onLoadFileDownloadUrl(downloadImage)" (load)="onLoadFileDownloadUrl(downloadImage)"
/> />
</ng-template>
</div> </div>
</div> </div>
</div> </div>

View File

@ -13,6 +13,7 @@ import {
import { ucapAnimations } from '../../animations'; import { ucapAnimations } from '../../animations';
import { FileEventJson } from '@ucap-webmessenger/protocol-event'; import { FileEventJson } from '@ucap-webmessenger/protocol-event';
import { FileDownloadItem } from '@ucap-webmessenger/api'; import { FileDownloadItem } from '@ucap-webmessenger/api';
import { ImageOnlyDataInfo } from '../../models/image-only-data-info';
@Component({ @Component({
selector: 'ucap-image-viewer', selector: 'ucap-image-viewer',
@ -28,6 +29,11 @@ export class ImageViewerComponent implements OnInit {
@Input() @Input()
fileDownloadUrl: string; fileDownloadUrl: string;
@Input()
imageOnly = false;
@Input()
imageOnlyData?: ImageOnlyDataInfo;
@Output() @Output()
closed = new EventEmitter<void>(); closed = new EventEmitter<void>();

View File

@ -0,0 +1,6 @@
export interface ImageOnlyDataInfo {
imageUrl: string;
imageRootUrl: string;
defaultImage: string;
fileName: string;
}

View File

@ -30,6 +30,8 @@ export * from './lib/directives/click-outside.directive';
export * from './lib/directives/file-upload-for.directive'; export * from './lib/directives/file-upload-for.directive';
export * from './lib/directives/image.directive'; export * from './lib/directives/image.directive';
export * from './lib/models/image-only-data-info';
export * from './lib/services/bottom-sheet.service'; export * from './lib/services/bottom-sheet.service';
export * from './lib/services/clipboard.service'; export * from './lib/services/clipboard.service';
export * from './lib/services/dialog.service'; export * from './lib/services/dialog.service';