diff --git a/projects/ucap-webmessenger-api-common/src/lib/config/module-config.ts b/projects/ucap-webmessenger-api-common/src/lib/config/module-config.ts index c51a89c0..4197f28e 100644 --- a/projects/ucap-webmessenger-api-common/src/lib/config/module-config.ts +++ b/projects/ucap-webmessenger-api-common/src/lib/config/module-config.ts @@ -4,4 +4,6 @@ import { Urls } from './urls'; export interface ModuleConfig extends CoreModuleConfig { acceptableFileExtensions: string[]; + acceptableFileExtensionsForImage: string[]; + acceptableFileExtensionsForVideo: string[]; } 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 a3339c6b..380f8adf 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 @@ -72,7 +72,7 @@ import { import { _MODULE_CONFIG } from '../config/token'; import { ModuleConfig } from '../config/module-config'; import { Urls } from '../config/urls'; -import { UrlConfig, MimeUtil } from '@ucap-webmessenger/core'; +import { UrlConfig, MimeUtil, FileUtil } from '@ucap-webmessenger/core'; @Injectable({ providedIn: 'root' @@ -223,7 +223,7 @@ export class CommonApiService { }; } - public acceptableMimeForFileTalk( + public checkInvalidMediaMimeForFileTalk( files: File[] ): Promise<{ accept: boolean; rejected: string[] }> { return new Promise<{ accept: boolean; rejected: string[] }>( @@ -236,10 +236,8 @@ export class CommonApiService { if ( !file || !info || - -1 === - this.moduleConfig.acceptableFileExtensions.indexOf( - info.ext.toLocaleLowerCase() - ) + (-1 === info.mime.indexOf('video/') && + -1 === info.mime.indexOf('image/')) ) { rejected.push(file.name); accept = false; @@ -253,6 +251,30 @@ export class CommonApiService { ); } + mediaFiles(files: File[]): File[] { + const filtered: File[] = []; + + for (const file of files) { + const extension = FileUtil.getExtension(file.name).toLocaleLowerCase(); + if ( + !!file && + -1 !== + this.moduleConfig.acceptableFileExtensionsForImage.indexOf(extension) + ) { + filtered.push(file); + } + if ( + !!file && + -1 !== + this.moduleConfig.acceptableFileExtensionsForVideo.indexOf(extension) + ) { + filtered.push(file); + } + } + + return 0 < filtered.length ? filtered : undefined; + } + /** @deprecated */ public mimeCheckForImageAndVideoFiles(files: File[]) { files.forEach(file => { diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/intro.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/intro.component.ts index 64a6f991..3bbdb0ac 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/intro.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/intro.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { ucapAnimations, StatusBarService } from '@ucap-webmessenger/ui'; +import { ucapAnimations } from '@ucap-webmessenger/ui'; import { environment } from '../../../../environments/environment'; @Component({ @@ -9,7 +9,7 @@ import { environment } from '../../../../environments/environment'; animations: ucapAnimations }) export class IntroComponent implements OnInit { - constructor(private statusBarService: StatusBarService) {} + constructor() {} ngOnInit() {} @@ -18,14 +18,4 @@ export class IntroComponent implements OnInit { ? environment.title : 'UCapMessenger'; } - - private toggle = false; - onClickStatusBar() { - if (!this.toggle) { - this.statusBarService.open(''); - } else { - this.statusBarService.dismiss(); - } - this.toggle = !this.toggle; - } } 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 0c47f8b3..7170d259 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 @@ -1111,49 +1111,27 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { // fileUploadItems.map(fui => fui.file) // ); - const checkExt = await this.commonApiService.acceptableMimeForFileTalk( - fileUploadItems.map(fui => fui.file) + const checkExt = this.commonApiService.acceptableExtensionForFileTalk( + fileUploadItems.map(fui => FileUtil.getExtension(fui.file.name)) ); - - // const checkExt = this.commonApiService.acceptableExtensionForFileTalk( - // fileUploadItems.map(fui => FileUtil.getExtension(fui.file.name)) - // ); if (!checkExt.accept) { if (!!this.fileUploadQueue) { this.fileUploadQueue.onUploadComplete(); } - // this.snackBarService.openFromComponent< - // AlertSnackbarComponent, - // AlertSnackbarData - // >(AlertSnackbarComponent, { - // duration: 1000, - // verticalPosition: 'bottom', - // horizontalPosition: 'center', - // data: { - // html: this.translateService.instant( - // 'common.file.errors.notSupporedType', - // { - // supporedType: - // checkExt.reject.length > 0 ? checkExt.reject.join(',') : '' - // } - // ) - // } - // }); - this.snackBarService.openFromComponent< AlertSnackbarComponent, AlertSnackbarData >(AlertSnackbarComponent, { - duration: 3000, + duration: 1000, verticalPosition: 'bottom', horizontalPosition: 'center', data: { html: this.translateService.instant( - 'common.file.errors.notAcceptableMime', + 'common.file.errors.notSupporedType', { supporedType: - checkExt.rejected.length > 0 ? checkExt.rejected.join(',') : '' + checkExt.reject.length > 0 ? checkExt.reject.join(',') : '' } ) } @@ -1162,6 +1140,43 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { return; } + const mediaFiles = this.commonApiService.mediaFiles( + fileUploadItems.map(fui => fui.file) + ); + + if (!!mediaFiles) { + const fakeMedia = await this.commonApiService.checkInvalidMediaMimeForFileTalk( + fileUploadItems.map(fui => fui.file) + ); + if (!fakeMedia.accept) { + if (!!this.fileUploadQueue) { + this.fileUploadQueue.onUploadComplete(); + } + + this.snackBarService.openFromComponent< + AlertSnackbarComponent, + AlertSnackbarData + >(AlertSnackbarComponent, { + duration: 3000, + verticalPosition: 'bottom', + horizontalPosition: 'center', + data: { + html: this.translateService.instant( + 'common.file.errors.notAcceptableMime', + { + supporedType: + fakeMedia.rejected.length > 0 + ? fakeMedia.rejected.join(',') + : '' + } + ) + } + }); + + return; + } + } + for (const fileUploadItem of fileUploadItems) { let thumbnail: File; if ( diff --git a/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.html b/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.html index ccdb8c00..7ede2f3c 100644 --- a/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.html +++ b/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.html @@ -15,7 +15,7 @@ >
-
-
+
--> diff --git a/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.ts b/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.ts index aed0b7cd..62ddb646 100644 --- a/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.ts +++ b/projects/ucap-webmessenger-app/src/app/pages/messenger/components/main.page.component.ts @@ -27,8 +27,7 @@ import { AlertDialogComponent, AlertDialogResult, AlertDialogData, - ConfirmDialogData, - StatusBarService + ConfirmDialogData } from '@ucap-webmessenger/ui'; import { ProfileDialogComponent, @@ -99,7 +98,6 @@ export class MainPageComponent implements OnInit, OnDestroy { private sessionStorageService: SessionStorageService, private translateService: TranslateService, private dialogService: DialogService, - private statusBarService: StatusBarService, private logger: NGXLogger ) { this.environmentsInfo = this.sessionStorageService.get( @@ -108,8 +106,6 @@ export class MainPageComponent implements OnInit, OnDestroy { } ngOnInit(): void { - this.statusBarService.container = this.statusbarContainer; - this.selectedChat$ = this.store.pipe( select(AppStore.MessengerSelector.ChatSelector.selectedRoom), tap(selectedRoom => { diff --git a/projects/ucap-webmessenger-app/src/environments/environment.daesang.dev.ts b/projects/ucap-webmessenger-app/src/environments/environment.daesang.dev.ts index 385d0223..a2becfdf 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.daesang.dev.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.daesang.dev.ts @@ -7,7 +7,9 @@ import { piUrls, protocolUrls, messageApiUrls, - promptUrls + promptUrls, + commonApiAcceptableFileExtensionsForImage, + commonApiAcceptableFileExtensionsForVideo } from './environment.type'; import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core'; @@ -102,7 +104,9 @@ export const environment: Environment = { port: 8011 }, urls: commonApiUrls, - acceptableFileExtensions: commonApiacceptableFileExtensions + acceptableFileExtensions: commonApiacceptableFileExtensions, + acceptableFileExtensionsForImage: commonApiAcceptableFileExtensionsForImage, + acceptableFileExtensionsForVideo: commonApiAcceptableFileExtensionsForVideo }, publicApiModuleConfig: { diff --git a/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts b/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts index d0e5ff2e..91d4af5b 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts @@ -7,7 +7,9 @@ import { piUrls, protocolUrls, messageApiUrls, - promptUrls + promptUrls, + commonApiAcceptableFileExtensionsForImage, + commonApiAcceptableFileExtensionsForVideo } from './environment.type'; import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core'; @@ -102,7 +104,9 @@ export const environment: Environment = { port: 443 }, urls: commonApiUrls, - acceptableFileExtensions: commonApiacceptableFileExtensions + acceptableFileExtensions: commonApiacceptableFileExtensions, + acceptableFileExtensionsForImage: commonApiAcceptableFileExtensionsForImage, + acceptableFileExtensionsForVideo: commonApiAcceptableFileExtensionsForVideo }, publicApiModuleConfig: { diff --git a/projects/ucap-webmessenger-app/src/environments/environment.dev.ts b/projects/ucap-webmessenger-app/src/environments/environment.dev.ts index a2b77597..7bf13d35 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.dev.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.dev.ts @@ -7,7 +7,9 @@ import { piUrls, protocolUrls, messageApiUrls, - promptUrls + promptUrls, + commonApiAcceptableFileExtensionsForImage, + commonApiAcceptableFileExtensionsForVideo } from './environment.type'; import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core'; @@ -98,7 +100,9 @@ export const environment: Environment = { port: 8011 }, urls: commonApiUrls, - acceptableFileExtensions: commonApiacceptableFileExtensions + acceptableFileExtensions: commonApiacceptableFileExtensions, + acceptableFileExtensionsForImage: commonApiAcceptableFileExtensionsForImage, + acceptableFileExtensionsForVideo: commonApiAcceptableFileExtensionsForVideo }, publicApiModuleConfig: { diff --git a/projects/ucap-webmessenger-app/src/environments/environment.prod.ts b/projects/ucap-webmessenger-app/src/environments/environment.prod.ts index f28adb51..2021e052 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.prod.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.prod.ts @@ -7,7 +7,9 @@ import { piUrls, protocolUrls, messageApiUrls, - promptUrls + promptUrls, + commonApiAcceptableFileExtensionsForImage, + commonApiAcceptableFileExtensionsForVideo } from './environment.type'; import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core'; @@ -98,7 +100,9 @@ export const environment: Environment = { port: 8011 }, urls: commonApiUrls, - acceptableFileExtensions: commonApiacceptableFileExtensions + acceptableFileExtensions: commonApiacceptableFileExtensions, + acceptableFileExtensionsForImage: commonApiAcceptableFileExtensionsForImage, + acceptableFileExtensionsForVideo: commonApiAcceptableFileExtensionsForVideo }, publicApiModuleConfig: { diff --git a/projects/ucap-webmessenger-app/src/environments/environment.type.ts b/projects/ucap-webmessenger-app/src/environments/environment.type.ts index 376b2888..a7e6abac 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.type.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.type.ts @@ -194,8 +194,7 @@ export const protocolUrls: ProtocolUrls = { base: '/' }; -export const commonApiacceptableFileExtensions: string[] = [ - // 문서 +export const commonApiAcceptableFileExtensionsForDocumnet: string[] = [ 'doc', 'docx', 'dot', @@ -214,9 +213,10 @@ export const commonApiacceptableFileExtensions: string[] = [ 'txt', 'csv', 'pdf', - 'hwp', + 'hwp' +]; - // 이미지 +export const commonApiAcceptableFileExtensionsForImage: string[] = [ 'tif', 'ogg', 'psd', @@ -225,9 +225,9 @@ export const commonApiacceptableFileExtensions: string[] = [ 'gif', 'jpg', 'jpeg', - 'png', - - // 압축 + 'png' +]; +export const commonApiAcceptableFileExtensionsForArchive: string[] = [ 'zip', 'alz', 'a00', @@ -239,18 +239,18 @@ export const commonApiacceptableFileExtensions: string[] = [ 'a06', 'a07', 'a08', - 'a09', - - // 오디오 + 'a09' +]; +export const commonApiAcceptableFileExtensionsForAudio: string[] = [ 'wav', 'mp3', - 'm4a', - - // 플래쉬 + 'm4a' +]; +export const commonApiAcceptableFileExtensionsForFlash: string[] = [ 'swf', - 'fla', - - // 동영상 + 'fla' +]; +export const commonApiAcceptableFileExtensionsForVideo: string[] = [ 'avi', 'mp4', 'wmv', @@ -261,13 +261,36 @@ export const commonApiacceptableFileExtensions: string[] = [ 'webm', 'm4v', 'mpg', - 'mpeg', - - // 폴더전송 + 'mpeg' +]; +export const commonApiAcceptableFileExtensionsForFolder: string[] = [ 'zdr', 'dat' ]; +export const commonApiacceptableFileExtensions: string[] = [ + // 문서 + ...commonApiAcceptableFileExtensionsForDocumnet, + + // 이미지 + ...commonApiAcceptableFileExtensionsForImage, + + // 압축 + ...commonApiAcceptableFileExtensionsForArchive, + + // 오디오 + ...commonApiAcceptableFileExtensionsForAudio, + + // 플래쉬 + ...commonApiAcceptableFileExtensionsForFlash, + + // 동영상 + ...commonApiAcceptableFileExtensionsForVideo, + + // 폴더전송 + ...commonApiAcceptableFileExtensionsForFolder +]; + // export abstract class UrlConfig { // constructor( // protected useSsl: boolean, diff --git a/projects/ucap-webmessenger-ui/src/lib/ucap-ui.module.ts b/projects/ucap-webmessenger-ui/src/lib/ucap-ui.module.ts index aa3bc3a4..ce0d2ea4 100644 --- a/projects/ucap-webmessenger-ui/src/lib/ucap-ui.module.ts +++ b/projects/ucap-webmessenger-ui/src/lib/ucap-ui.module.ts @@ -56,7 +56,6 @@ import { SplashScreenService } from './services/splash-screen.service'; import { TranslateService } from './services/translate.service'; import { DateService } from './services/date.service'; import { PaginatorIntlService } from './services/paginator-intl.service'; -import { StatusBarService } from './services/status-bar.service'; import { ClickOutsideDirective } from './directives/click-outside.directive'; import { FileUploadForDirective } from './directives/file-upload-for.directive'; @@ -138,8 +137,7 @@ const SERVICES = [ SplashScreenService, TranslateService, DateService, - PaginatorIntlService, - StatusBarService + PaginatorIntlService ]; @NgModule({