From c5fb1df147be8d3639d007ebbdaff29aed702bfc Mon Sep 17 00:00:00 2001 From: leejinho Date: Fri, 15 Nov 2019 17:55:05 +0900 Subject: [PATCH] =?UTF-8?q?Alert=20and=20confirm=20=EC=A0=81=EC=9A=A9=20al?= =?UTF-8?q?ert=20:=201.=20=ED=8C=8C=EC=9D=BC=EC=A0=84=EC=86=A1=20=ED=99=95?= =?UTF-8?q?=EC=9E=A5=EC=9E=90=20=EC=98=A4=EB=A5=98.=202.=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EC=A0=84=EC=86=A1=EC=8B=9C=20HTTP=20error=20confirm:?= =?UTF-8?q?=201.=20=EB=8C=80=ED=99=94=EB=B0=A9=20=EB=82=98=EA=B0=80?= =?UTF-8?q?=EA=B8=B0=20=EC=A0=84.=20ext:=201.=20=EC=83=88=EA=B7=B8?= =?UTF-8?q?=EB=A3=B9=EC=B6=94=EA=B0=80=20=ED=8C=9D=EC=97=85=20:=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=EB=AA=85=20valid=20=EC=97=90=20=EC=9D=98?= =?UTF-8?q?=ED=95=9C=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1=ED=99=94=20?= =?UTF-8?q?=EB=B9=84=ED=99=9C=EC=84=B1=ED=99=94=20=EC=97=AC=EB=B6=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/lib/services/common-api.service.ts | 56 +++++++++++-------- .../left-sidenav/chat.component.html | 13 +++-- .../components/left-sidenav/chat.component.ts | 50 ++++++++++++----- .../components/messages.component.ts | 12 ++++ .../chat/create-chat.dialog.component.html | 7 ++- .../chat/create-chat.dialog.component.ts | 17 +++++- .../chat/edit-chat-room.dialog.component.html | 2 +- .../directives/file-upload-for.directive.ts | 44 +++++++++++---- 8 files changed, 143 insertions(+), 58 deletions(-) diff --git a/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts b/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts index ba8e48b6..53c6a91b 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/services/common-api.service.ts @@ -3,7 +3,7 @@ import { HttpClient, HttpEventType, HttpResponse, - HttpRequest, + HttpRequest } from '@angular/common/http'; import { Observable, Subject } from 'rxjs'; @@ -13,60 +13,60 @@ import { FileProfileSaveRequest, FileProfileSaveResponse, encodeFileProfileSave, - decodeFileProfileSave, + decodeFileProfileSave } from '../apis/file-profile-save'; import { FileTalkDownloadRequest, encodeFileTalkDownload, - encodeFormDataFileTalkDownload, + encodeFormDataFileTalkDownload } from '../apis/file-talk-download'; import { FileTalkSaveRequest, FileTalkSaveResponse, encodeFileTalkSave, - decodeFileTalkSave, + decodeFileTalkSave } from '../apis/file-talk-save'; import { FileTalkShareRequest, FileTalkShareResponse, encodeFileTalkShare, - decodeFileTalkShare, + decodeFileTalkShare } from '../apis/file-talk-share'; import { MassTalkDownloadRequest, MassTalkDownloadResponse, encodeMassTalkDownload, - decodeMassTalkDownload, + decodeMassTalkDownload } from '../apis/mass-talk-download'; import { MassTalkSaveRequest, MassTalkSaveResponse, encodeMassTalkSave, - decodeMassTalkSave, + decodeMassTalkSave } from '../apis/mass-talk-save'; import { TransMassTalkDownloadRequest, TransMassTalkDownloadResponse, encodeTransMassTalkDownload, - decodeTransMassTalkDownload, + decodeTransMassTalkDownload } from '../apis/trans-mass-talk-download'; import { TransMassTalkSaveRequest, TransMassTalkSaveResponse, encodeTransMassTalkSave, - decodeTransMassTalkSave, + decodeTransMassTalkSave } from '../apis/trans-mass-talk-save'; import { TranslationReqRequest, TranslationReqResponse, encodeTranslationReq, - decodeTranslationReq, + decodeTranslationReq } from '../apis/translation-req'; import { TranslationSaveRequest, TranslationSaveResponse, encodeTranslationSave, - decodeTranslationSave, + decodeTranslationSave } from '../apis/translation-save'; import { _MODULE_CONFIG } from '../config/token'; @@ -75,7 +75,7 @@ import { Urls } from '../config/urls'; import { UrlConfig } from '@ucap-webmessenger/core'; @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class CommonApiService { readonly urls: Urls; @@ -99,7 +99,7 @@ export class CommonApiService { !!fileProfileSaveUrl ? fileProfileSaveUrl : this.urls.fileProfileSave, {}, { - params: encodeFileProfileSave(req), + params: encodeFileProfileSave(req) } ) .pipe(map(res => decodeFileProfileSave(res))); @@ -114,7 +114,7 @@ export class CommonApiService { !!fileTalkDownloadUrl ? fileTalkDownloadUrl : this.urls.fileTalkDownload, {}, { - params: encodeFileTalkDownload(req), + params: encodeFileTalkDownload(req) } ); @@ -186,7 +186,11 @@ export class CommonApiService { ); } - public acceptableExtensionForFileTalk(extensions: string[]): boolean { + public acceptableExtensionForFileTalk( + extensions: string[] + ): { accept: boolean; reject: string[] } { + let accept = true; + const reject: string[] = []; for (const extension of extensions) { if ( -1 === @@ -194,10 +198,14 @@ export class CommonApiService { extension.toLowerCase() ) ) { - return false; + reject.push(extension); + accept = false; } } - return true; + return { + accept, + reject + }; } public fileTalkShare( @@ -208,7 +216,7 @@ export class CommonApiService { this.urls.fileTalkShare, {}, { - params: encodeFileTalkShare(req), + params: encodeFileTalkShare(req) } ) .pipe(map(res => decodeFileTalkShare(res))); @@ -223,7 +231,7 @@ export class CommonApiService { {}, { params: encodeMassTalkDownload(req), - responseType: 'text' as 'json', + responseType: 'text' as 'json' } ) .pipe(map(res => decodeMassTalkDownload(res))); @@ -238,7 +246,7 @@ export class CommonApiService { {}, { params: encodeMassTalkSave(req), - responseType: 'text' as 'json', + responseType: 'text' as 'json' } ) .pipe(map(res => decodeMassTalkSave(res))); @@ -252,7 +260,7 @@ export class CommonApiService { this.urls.transMassTalkDownload, {}, { - params: encodeTransMassTalkDownload(req), + params: encodeTransMassTalkDownload(req) } ) .pipe(map(res => decodeTransMassTalkDownload(res))); @@ -266,7 +274,7 @@ export class CommonApiService { this.urls.transMassTalkSave, {}, { - params: encodeTransMassTalkSave(req), + params: encodeTransMassTalkSave(req) } ) .pipe(map(res => decodeTransMassTalkSave(res))); @@ -280,7 +288,7 @@ export class CommonApiService { this.urls.translationReq, {}, { - params: encodeTranslationReq(req), + params: encodeTranslationReq(req) } ) .pipe(map(res => decodeTranslationReq(res))); @@ -294,7 +302,7 @@ export class CommonApiService { this.urls.translationSave, {}, { - params: encodeTranslationSave(req), + params: encodeTranslationSave(req) } ) .pipe(map(res => decodeTranslationSave(res))); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html index a4d6f0c0..0ca48cca 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html @@ -57,7 +57,7 @@ [roomInfo]="room" [roomUserInfo]="getRoomUserList(room)" [sessionVerinfo]="sessionVerinfo" - (click)="onSelectedRoom(room)" + (click)="onClickContextMenu('SELECT_ROOM', room)" (contextmenu)="onContextMenuChat($event, room)" > @@ -86,7 +86,7 @@ [roomInfo]="room" [roomUserInfo]="getRoomUserList(room)" [sessionVerinfo]="sessionVerinfo" - (click)="onSelectedRoom(room)" + (click)="onClickContextMenu('SELECT_ROOM', room)" (contextmenu)="onContextMenuChat($event, room)" > @@ -121,13 +121,16 @@ (ucapClickOutside)="chatContextMenuTrigger.closeMenu()" > - - - diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts index ace5fe9c..fc21419a 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts @@ -1,6 +1,12 @@ import { exit } from './../../../../store/messenger/room/actions'; import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; -import { ucapAnimations } from '@ucap-webmessenger/ui'; +import { + ucapAnimations, + DialogService, + ConfirmDialogComponent, + ConfirmDialogResult, + ConfirmDialogData +} from '@ucap-webmessenger/ui'; import { NGXLogger } from 'ngx-logger'; import { Store, select } from '@ngrx/store'; import { Subscription, combineLatest, Observable } from 'rxjs'; @@ -54,6 +60,7 @@ export class ChatComponent implements OnInit, OnDestroy { private store: Store, private formBuilder: FormBuilder, private logger: NGXLogger, + private dialogService: DialogService, private sessionStorageService: SessionStorageService ) { this.sessionVerinfo = this.sessionStorageService.get( @@ -194,18 +201,35 @@ export class ChatComponent implements OnInit, OnDestroy { this.chatContextMenuTrigger.openMenu(); } - onSelectedRoom(roomInfo: RoomInfo) { - this.store.dispatch(ChatStore.selectedRoom({ roomSeq: roomInfo.roomSeq })); - } - onClickToggleAlarm(roomInfo: RoomInfo) { - this.store.dispatch(RoomStore.updateOnlyAlarm({ roomInfo })); - } - onClickExit(roomInfo: RoomInfo) { - this.store.dispatch( - RoomStore.exit({ - roomSeq: roomInfo.roomSeq - }) - ); + async onClickContextMenu(type: string, roomInfo: RoomInfo) { + switch (type) { + case 'SELECT_ROOM': + this.store.dispatch( + ChatStore.selectedRoom({ roomSeq: roomInfo.roomSeq }) + ); + break; + case 'TOGGLE_ALARM': + this.store.dispatch(RoomStore.updateOnlyAlarm({ roomInfo })); + break; + case 'EXIT_ROOM': + { + const result = await this.dialogService.open< + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult + >(ConfirmDialogComponent, { + data: { + title: 'Exit Room', + html: `대화방을 나가시겠습니까?
나가기를 하면 대화내용 및 대화방 정보가 삭제됩니다.` + } + }); + + if (!!result && !!result.choice && result.choice) { + this.store.dispatch(RoomStore.exit({ roomSeq: roomInfo.roomSeq })); + } + } + break; + } } getRoomUserList(roomInfo: RoomInfo): (RoomUserInfo | UserInfoShort)[] { diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index d31e1cce..3ee12b66 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -607,6 +607,18 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { }, error => { this.logger.debug('onFileSelected error', error); + this.fileUploadQueue.onUploadComplete(); + + this.dialogService.open< + AlertDialogComponent, + AlertDialogData, + AlertDialogResult + >(AlertDialogComponent, { + data: { + title: 'Alert', + html: `파일전송에 실패하였습니다.
계속 문제 발생 시 관리자에게 문의하세요.` + } + }); }, () => { this.fileUploadQueue.onUploadComplete(); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html index 6314130b..397b1021 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html @@ -168,7 +168,12 @@ > No - diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts index b39c00b5..bffd96c6 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts @@ -62,7 +62,8 @@ export interface CreateChatDialogData { | UserInfoSS | UserInfoF | UserInfoDN - | RoomUserInfo)[]; + | RoomUserInfo + )[]; } export interface CreateChatDialogResult { @@ -72,7 +73,8 @@ export interface CreateChatDialogResult { | UserInfoSS | UserInfoF | UserInfoDN - | RoomUserInfo)[]; + | RoomUserInfo + )[]; selectedRoom?: RoomInfo; groupName?: string; oldGroup?: GroupDetailData; @@ -132,7 +134,8 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { | UserInfoSS | UserInfoF | UserInfoDN - | RoomUserInfo)[] = []; + | RoomUserInfo + )[] = []; isShowSelectedUserList = true; selectedRoom: RoomInfo; @@ -449,6 +452,14 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy { ); } + getBtnValid() { + if (this.data.type === UserSelectDialogType.NewGroup) { + return this.inputForm.invalid; + } else { + return false; + } + } + /** 팝업의 선택 이벤트 전달. */ onClickChoice(choice: boolean): void { this.dialogRef.close({ diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/edit-chat-room.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/edit-chat-room.dialog.component.html index 1ca26aff..5b3325d3 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/edit-chat-room.dialog.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/edit-chat-room.dialog.component.html @@ -5,7 +5,7 @@
- + (AlertDialogComponent, { + data: { + title: 'Alert', + html: `지원하지 않는 파일형식입니다.${ + checkExt.reject.length > 0 + ? '
(' + checkExt.reject.join(',') + ')' + : '' + }` + } + }); + return; }