bug fixed

This commit is contained in:
richard-loafle 2020-02-14 15:30:47 +09:00
parent 831bdde860
commit 7d02dfca15
12 changed files with 144 additions and 82 deletions

View File

@ -4,4 +4,6 @@ import { Urls } from './urls';
export interface ModuleConfig extends CoreModuleConfig<Urls> { export interface ModuleConfig extends CoreModuleConfig<Urls> {
acceptableFileExtensions: string[]; acceptableFileExtensions: string[];
acceptableFileExtensionsForImage: string[];
acceptableFileExtensionsForVideo: string[];
} }

View File

@ -72,7 +72,7 @@ import {
import { _MODULE_CONFIG } from '../config/token'; import { _MODULE_CONFIG } from '../config/token';
import { ModuleConfig } from '../config/module-config'; import { ModuleConfig } from '../config/module-config';
import { Urls } from '../config/urls'; import { Urls } from '../config/urls';
import { UrlConfig, MimeUtil } from '@ucap-webmessenger/core'; import { UrlConfig, MimeUtil, FileUtil } from '@ucap-webmessenger/core';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -223,7 +223,7 @@ export class CommonApiService {
}; };
} }
public acceptableMimeForFileTalk( public checkInvalidMediaMimeForFileTalk(
files: File[] files: File[]
): Promise<{ accept: boolean; rejected: string[] }> { ): Promise<{ accept: boolean; rejected: string[] }> {
return new Promise<{ accept: boolean; rejected: string[] }>( return new Promise<{ accept: boolean; rejected: string[] }>(
@ -236,10 +236,8 @@ export class CommonApiService {
if ( if (
!file || !file ||
!info || !info ||
-1 === (-1 === info.mime.indexOf('video/') &&
this.moduleConfig.acceptableFileExtensions.indexOf( -1 === info.mime.indexOf('image/'))
info.ext.toLocaleLowerCase()
)
) { ) {
rejected.push(file.name); rejected.push(file.name);
accept = false; 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 */ /** @deprecated */
public mimeCheckForImageAndVideoFiles(files: File[]) { public mimeCheckForImageAndVideoFiles(files: File[]) {
files.forEach(file => { files.forEach(file => {

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ucapAnimations, StatusBarService } from '@ucap-webmessenger/ui'; import { ucapAnimations } from '@ucap-webmessenger/ui';
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
@Component({ @Component({
@ -9,7 +9,7 @@ import { environment } from '../../../../environments/environment';
animations: ucapAnimations animations: ucapAnimations
}) })
export class IntroComponent implements OnInit { export class IntroComponent implements OnInit {
constructor(private statusBarService: StatusBarService) {} constructor() {}
ngOnInit() {} ngOnInit() {}
@ -18,14 +18,4 @@ export class IntroComponent implements OnInit {
? environment.title ? environment.title
: 'UCapMessenger'; : 'UCapMessenger';
} }
private toggle = false;
onClickStatusBar() {
if (!this.toggle) {
this.statusBarService.open('');
} else {
this.statusBarService.dismiss();
}
this.toggle = !this.toggle;
}
} }

View File

@ -1111,49 +1111,27 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
// fileUploadItems.map(fui => fui.file) // fileUploadItems.map(fui => fui.file)
// ); // );
const checkExt = await this.commonApiService.acceptableMimeForFileTalk( const checkExt = this.commonApiService.acceptableExtensionForFileTalk(
fileUploadItems.map(fui => fui.file) 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 (!checkExt.accept) {
if (!!this.fileUploadQueue) { if (!!this.fileUploadQueue) {
this.fileUploadQueue.onUploadComplete(); 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< this.snackBarService.openFromComponent<
AlertSnackbarComponent, AlertSnackbarComponent,
AlertSnackbarData AlertSnackbarData
>(AlertSnackbarComponent, { >(AlertSnackbarComponent, {
duration: 3000, duration: 1000,
verticalPosition: 'bottom', verticalPosition: 'bottom',
horizontalPosition: 'center', horizontalPosition: 'center',
data: { data: {
html: this.translateService.instant( html: this.translateService.instant(
'common.file.errors.notAcceptableMime', 'common.file.errors.notSupporedType',
{ {
supporedType: 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; 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) { for (const fileUploadItem of fileUploadItems) {
let thumbnail: File; let thumbnail: File;
if ( if (

View File

@ -15,7 +15,7 @@
></app-layout-messenger-left-side> ></app-layout-messenger-left-side>
</mat-drawer> </mat-drawer>
<div class="chat-messages bg-accent-brightest"> <div class="chat-messages bg-accent-brightest">
<div <!-- <div
#statusbarContainer #statusbarContainer
*ngIf="false" *ngIf="false"
class="messenger-statusbar-container bg-accent-darkest" class="messenger-statusbar-container bg-accent-darkest"
@ -24,7 +24,7 @@
업데이트가 존재합니다. 업데이트가 존재합니다.
</div> </div>
<div class="messenger-statusbar-actions"></div> <div class="messenger-statusbar-actions"></div>
</div> </div> -->
<app-layout-messenger-intro <app-layout-messenger-intro
*ngIf="!(this.selectedChat$ | async)" *ngIf="!(this.selectedChat$ | async)"
></app-layout-messenger-intro> ></app-layout-messenger-intro>

View File

@ -27,8 +27,7 @@ import {
AlertDialogComponent, AlertDialogComponent,
AlertDialogResult, AlertDialogResult,
AlertDialogData, AlertDialogData,
ConfirmDialogData, ConfirmDialogData
StatusBarService
} from '@ucap-webmessenger/ui'; } from '@ucap-webmessenger/ui';
import { import {
ProfileDialogComponent, ProfileDialogComponent,
@ -99,7 +98,6 @@ export class MainPageComponent implements OnInit, OnDestroy {
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private translateService: TranslateService, private translateService: TranslateService,
private dialogService: DialogService, private dialogService: DialogService,
private statusBarService: StatusBarService,
private logger: NGXLogger private logger: NGXLogger
) { ) {
this.environmentsInfo = this.sessionStorageService.get<EnvironmentsInfo>( this.environmentsInfo = this.sessionStorageService.get<EnvironmentsInfo>(
@ -108,8 +106,6 @@ export class MainPageComponent implements OnInit, OnDestroy {
} }
ngOnInit(): void { ngOnInit(): void {
this.statusBarService.container = this.statusbarContainer;
this.selectedChat$ = this.store.pipe( this.selectedChat$ = this.store.pipe(
select(AppStore.MessengerSelector.ChatSelector.selectedRoom), select(AppStore.MessengerSelector.ChatSelector.selectedRoom),
tap(selectedRoom => { tap(selectedRoom => {

View File

@ -7,7 +7,9 @@ import {
piUrls, piUrls,
protocolUrls, protocolUrls,
messageApiUrls, messageApiUrls,
promptUrls promptUrls,
commonApiAcceptableFileExtensionsForImage,
commonApiAcceptableFileExtensionsForVideo
} from './environment.type'; } from './environment.type';
import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core'; import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core';
@ -102,7 +104,9 @@ export const environment: Environment = {
port: 8011 port: 8011
}, },
urls: commonApiUrls, urls: commonApiUrls,
acceptableFileExtensions: commonApiacceptableFileExtensions acceptableFileExtensions: commonApiacceptableFileExtensions,
acceptableFileExtensionsForImage: commonApiAcceptableFileExtensionsForImage,
acceptableFileExtensionsForVideo: commonApiAcceptableFileExtensionsForVideo
}, },
publicApiModuleConfig: { publicApiModuleConfig: {

View File

@ -7,7 +7,9 @@ import {
piUrls, piUrls,
protocolUrls, protocolUrls,
messageApiUrls, messageApiUrls,
promptUrls promptUrls,
commonApiAcceptableFileExtensionsForImage,
commonApiAcceptableFileExtensionsForVideo
} from './environment.type'; } from './environment.type';
import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core'; import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core';
@ -102,7 +104,9 @@ export const environment: Environment = {
port: 443 port: 443
}, },
urls: commonApiUrls, urls: commonApiUrls,
acceptableFileExtensions: commonApiacceptableFileExtensions acceptableFileExtensions: commonApiacceptableFileExtensions,
acceptableFileExtensionsForImage: commonApiAcceptableFileExtensionsForImage,
acceptableFileExtensionsForVideo: commonApiAcceptableFileExtensionsForVideo
}, },
publicApiModuleConfig: { publicApiModuleConfig: {

View File

@ -7,7 +7,9 @@ import {
piUrls, piUrls,
protocolUrls, protocolUrls,
messageApiUrls, messageApiUrls,
promptUrls promptUrls,
commonApiAcceptableFileExtensionsForImage,
commonApiAcceptableFileExtensionsForVideo
} from './environment.type'; } from './environment.type';
import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core'; import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core';
@ -98,7 +100,9 @@ export const environment: Environment = {
port: 8011 port: 8011
}, },
urls: commonApiUrls, urls: commonApiUrls,
acceptableFileExtensions: commonApiacceptableFileExtensions acceptableFileExtensions: commonApiacceptableFileExtensions,
acceptableFileExtensionsForImage: commonApiAcceptableFileExtensionsForImage,
acceptableFileExtensionsForVideo: commonApiAcceptableFileExtensionsForVideo
}, },
publicApiModuleConfig: { publicApiModuleConfig: {

View File

@ -7,7 +7,9 @@ import {
piUrls, piUrls,
protocolUrls, protocolUrls,
messageApiUrls, messageApiUrls,
promptUrls promptUrls,
commonApiAcceptableFileExtensionsForImage,
commonApiAcceptableFileExtensionsForVideo
} from './environment.type'; } from './environment.type';
import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core'; import { DeviceType, NotificationMethod } from '@ucap-webmessenger/core';
@ -98,7 +100,9 @@ export const environment: Environment = {
port: 8011 port: 8011
}, },
urls: commonApiUrls, urls: commonApiUrls,
acceptableFileExtensions: commonApiacceptableFileExtensions acceptableFileExtensions: commonApiacceptableFileExtensions,
acceptableFileExtensionsForImage: commonApiAcceptableFileExtensionsForImage,
acceptableFileExtensionsForVideo: commonApiAcceptableFileExtensionsForVideo
}, },
publicApiModuleConfig: { publicApiModuleConfig: {

View File

@ -194,8 +194,7 @@ export const protocolUrls: ProtocolUrls = {
base: '/' base: '/'
}; };
export const commonApiacceptableFileExtensions: string[] = [ export const commonApiAcceptableFileExtensionsForDocumnet: string[] = [
// 문서
'doc', 'doc',
'docx', 'docx',
'dot', 'dot',
@ -214,9 +213,10 @@ export const commonApiacceptableFileExtensions: string[] = [
'txt', 'txt',
'csv', 'csv',
'pdf', 'pdf',
'hwp', 'hwp'
];
// 이미지 export const commonApiAcceptableFileExtensionsForImage: string[] = [
'tif', 'tif',
'ogg', 'ogg',
'psd', 'psd',
@ -225,9 +225,9 @@ export const commonApiacceptableFileExtensions: string[] = [
'gif', 'gif',
'jpg', 'jpg',
'jpeg', 'jpeg',
'png', 'png'
];
// 압축 export const commonApiAcceptableFileExtensionsForArchive: string[] = [
'zip', 'zip',
'alz', 'alz',
'a00', 'a00',
@ -239,18 +239,18 @@ export const commonApiacceptableFileExtensions: string[] = [
'a06', 'a06',
'a07', 'a07',
'a08', 'a08',
'a09', 'a09'
];
// 오디오 export const commonApiAcceptableFileExtensionsForAudio: string[] = [
'wav', 'wav',
'mp3', 'mp3',
'm4a', 'm4a'
];
// 플래쉬 export const commonApiAcceptableFileExtensionsForFlash: string[] = [
'swf', 'swf',
'fla', 'fla'
];
// 동영상 export const commonApiAcceptableFileExtensionsForVideo: string[] = [
'avi', 'avi',
'mp4', 'mp4',
'wmv', 'wmv',
@ -261,13 +261,36 @@ export const commonApiacceptableFileExtensions: string[] = [
'webm', 'webm',
'm4v', 'm4v',
'mpg', 'mpg',
'mpeg', 'mpeg'
];
// 폴더전송 export const commonApiAcceptableFileExtensionsForFolder: string[] = [
'zdr', 'zdr',
'dat' 'dat'
]; ];
export const commonApiacceptableFileExtensions: string[] = [
// 문서
...commonApiAcceptableFileExtensionsForDocumnet,
// 이미지
...commonApiAcceptableFileExtensionsForImage,
// 압축
...commonApiAcceptableFileExtensionsForArchive,
// 오디오
...commonApiAcceptableFileExtensionsForAudio,
// 플래쉬
...commonApiAcceptableFileExtensionsForFlash,
// 동영상
...commonApiAcceptableFileExtensionsForVideo,
// 폴더전송
...commonApiAcceptableFileExtensionsForFolder
];
// export abstract class UrlConfig { // export abstract class UrlConfig {
// constructor( // constructor(
// protected useSsl: boolean, // protected useSsl: boolean,

View File

@ -56,7 +56,6 @@ import { SplashScreenService } from './services/splash-screen.service';
import { TranslateService } from './services/translate.service'; import { TranslateService } from './services/translate.service';
import { DateService } from './services/date.service'; import { DateService } from './services/date.service';
import { PaginatorIntlService } from './services/paginator-intl.service'; import { PaginatorIntlService } from './services/paginator-intl.service';
import { StatusBarService } from './services/status-bar.service';
import { ClickOutsideDirective } from './directives/click-outside.directive'; import { ClickOutsideDirective } from './directives/click-outside.directive';
import { FileUploadForDirective } from './directives/file-upload-for.directive'; import { FileUploadForDirective } from './directives/file-upload-for.directive';
@ -138,8 +137,7 @@ const SERVICES = [
SplashScreenService, SplashScreenService,
TranslateService, TranslateService,
DateService, DateService,
PaginatorIntlService, PaginatorIntlService
StatusBarService
]; ];
@NgModule({ @NgModule({