1. 빈확장자 파일업로드시 오류처리.
2. 지원하지 않는 파일입니다. <br/> (ext..) 의 줄바꿈 처리.
This commit is contained in:
leejinho 2020-02-10 09:33:41 +09:00
parent 928e77d54c
commit b0b5ed2209
5 changed files with 68 additions and 40 deletions

View File

@ -207,12 +207,13 @@ export class CommonApiService {
const reject: string[] = []; const reject: string[] = [];
for (const extension of extensions) { for (const extension of extensions) {
if ( if (
!extension ||
-1 === -1 ===
this.moduleConfig.acceptableFileExtensions.indexOf( this.moduleConfig.acceptableFileExtensions.indexOf(
extension.toLowerCase() extension.toLowerCase()
) )
) { ) {
reject.push(extension); reject.push(!!extension ? extension : 'empty-ext');
accept = false; accept = false;
} }
} }

View File

@ -22,7 +22,9 @@ import {
AlertDialogData, AlertDialogData,
AlertDialogResult, AlertDialogResult,
FileUploadQueueComponent, FileUploadQueueComponent,
StringUtil StringUtil,
AlertSnackbarComponent,
AlertSnackbarData
} from '@ucap-webmessenger/ui'; } from '@ucap-webmessenger/ui';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
@ -1107,18 +1109,23 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
this.fileUploadQueue.onUploadComplete(); this.fileUploadQueue.onUploadComplete();
} }
this.snackBarService.open( this.snackBarService.openFromComponent<
this.translateService.instant('common.file.errors.notSupporedType', { AlertSnackbarComponent,
supporedType: AlertSnackbarData
checkExt.reject.length > 0 ? checkExt.reject.join(',') : '' >(AlertSnackbarComponent, {
}),
'',
{
duration: 1000, duration: 1000,
verticalPosition: 'bottom', verticalPosition: 'bottom',
horizontalPosition: 'center' horizontalPosition: 'center',
data: {
html: this.translateService.instant(
'common.file.errors.notSupporedType',
{
supporedType:
checkExt.reject.length > 0 ? checkExt.reject.join(',') : ''
} }
); )
}
});
return; return;
} }

View File

@ -18,7 +18,9 @@ import {
AlertDialogResult, AlertDialogResult,
AlertDialogComponent, AlertDialogComponent,
AlertDialogData, AlertDialogData,
SnackBarService SnackBarService,
AlertSnackbarComponent,
AlertSnackbarData
} from '@ucap-webmessenger/ui'; } from '@ucap-webmessenger/ui';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
@ -250,18 +252,23 @@ export class WriteComponent implements OnInit, OnDestroy, AfterViewInit {
); );
if (!checkExt.accept) { if (!checkExt.accept) {
this.ngZone.run(() => { this.ngZone.run(() => {
this.snackBarService.open( this.snackBarService.openFromComponent<
this.translateService.instant('common.file.errors.notSupporedType', { AlertSnackbarComponent,
supporedType: AlertSnackbarData
checkExt.reject.length > 0 ? checkExt.reject.join(',') : '' >(AlertSnackbarComponent, {
}),
'',
{
duration: 1000, duration: 1000,
verticalPosition: 'bottom', verticalPosition: 'bottom',
horizontalPosition: 'center' horizontalPosition: 'center',
data: {
html: this.translateService.instant(
'common.file.errors.notSupporedType',
{
supporedType:
checkExt.reject.length > 0 ? checkExt.reject.join(',') : ''
} }
); )
}
});
}); });
return valid; return valid;
} }

View File

@ -20,6 +20,10 @@ import {
} from '../dialogs/alert.dialog.component'; } from '../dialogs/alert.dialog.component';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { SnackBarService } from '../services/snack-bar.service'; import { SnackBarService } from '../services/snack-bar.service';
import {
AlertSnackbarComponent,
AlertSnackbarData
} from '../snackbars/alert.snackbar.component';
@Directive({ @Directive({
selector: 'input[ucapFileUploadFor], div[ucapFileUploadFor]' selector: 'input[ucapFileUploadFor], div[ucapFileUploadFor]'
@ -121,18 +125,23 @@ export class FileUploadForDirective implements AfterViewInit {
this.elementRef.nativeElement.value = ''; this.elementRef.nativeElement.value = '';
this.dragOver = false; this.dragOver = false;
this.snackBarService.open( this.snackBarService.openFromComponent<
this.translateService.instant('common.file.errors.notSupporedType', { AlertSnackbarComponent,
supporedType: AlertSnackbarData
checkExt.reject.length > 0 ? checkExt.reject.join(',') : '' >(AlertSnackbarComponent, {
}),
'',
{
duration: 1000, duration: 1000,
verticalPosition: 'bottom', verticalPosition: 'bottom',
horizontalPosition: 'center' horizontalPosition: 'center',
data: {
html: this.translateService.instant(
'common.file.errors.notSupporedType',
{
supporedType:
checkExt.reject.length > 0 ? checkExt.reject.join(',') : ''
} }
); )
}
});
return; return;
} }

View File

@ -5,7 +5,11 @@
fxFlexAlign="center" fxFlexAlign="center"
class="mat-simple-snackbar-action ng-star-inserted" class="mat-simple-snackbar-action ng-star-inserted"
> >
<button mat-stroked-button (click)="onClickConfirm()"> <button
*ngIf="!!data.buttonText"
mat-stroked-button
(click)="onClickConfirm()"
>
<ng-container <ng-container
*ngIf="data.buttonText; then buttonText; else default" *ngIf="data.buttonText; then buttonText; else default"
></ng-container> ></ng-container>