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> {
acceptableFileExtensions: string[];
acceptableFileExtensionsForImage: string[];
acceptableFileExtensionsForVideo: string[];
}

View File

@ -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 => {

View File

@ -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;
}
}

View File

@ -1111,35 +1111,47 @@ 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: 1000,
verticalPosition: 'bottom',
horizontalPosition: 'center',
data: {
html: this.translateService.instant(
'common.file.errors.notSupporedType',
{
supporedType:
checkExt.reject.length > 0 ? checkExt.reject.join(',') : ''
}
)
}
});
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,
@ -1153,7 +1165,9 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
'common.file.errors.notAcceptableMime',
{
supporedType:
checkExt.rejected.length > 0 ? checkExt.rejected.join(',') : ''
fakeMedia.rejected.length > 0
? fakeMedia.rejected.join(',')
: ''
}
)
}
@ -1161,6 +1175,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
return;
}
}
for (const fileUploadItem of fileUploadItems) {
let thumbnail: File;

View File

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

View File

@ -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<EnvironmentsInfo>(
@ -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 => {

View File

@ -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: {

View File

@ -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: {

View File

@ -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: {

View File

@ -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: {

View File

@ -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,

View File

@ -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({