Skip to content

Commit

Permalink
fix renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Vuqar committed Feb 9, 2020
1 parent 6cbf07c commit 18468a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
6 changes: 3 additions & 3 deletions projects/file-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "ngx-awesome-uploader",
"version": "8.1.1",
"version": "8.1.2",
"description": "Angular Library for uploading files with Real-Time Progress bar, File Preview, Drag && Drop and Custom Template with Multi Language support",
"peerDependencies": {
"@angular/common": "^6.0.0 || ^7.0.0 || ^8.0.0",
"@angular/core": " ^6.0.0 || ^7.0.0 || ^8.0.0"
"@angular/common": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
"@angular/core": " ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
},
"keywords": [
"ngx",
Expand Down
4 changes: 2 additions & 2 deletions projects/file-picker/src/lib/file-drop/file-drop.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, Output, EventEmitter, NgZone, OnDestroy, Renderer, TemplateRef } from '@angular/core';
import { Component, Input, Output, EventEmitter, NgZone, OnDestroy, Renderer2 } from '@angular/core';
import { timer, Subscription } from 'rxjs';

import { UploadFile } from './upload-file.model';
Expand Down Expand Up @@ -40,7 +40,7 @@ export class FileComponent implements OnDestroy {
numOfActiveReadEntries = 0;
constructor(
private zone: NgZone,
private renderer: Renderer
private renderer: Renderer2
) {
if (!this.customstyle) {
this.customstyle = 'drop-zone';
Expand Down
27 changes: 15 additions & 12 deletions projects/file-picker/src/lib/file-picker.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {FilePickerService} from './file-picker.service';
import {Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, TemplateRef} from '@angular/core';
import {Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, TemplateRef, ChangeDetectorRef} from '@angular/core';
import {SafeResourceUrl} from '@angular/platform-browser';
import {FilePreviewModel} from './file-preview.model';
import {getFileType} from './file-upload.utils';
Expand Down Expand Up @@ -96,7 +96,7 @@ export class FilePickerComponent implements OnInit, OnDestroy {
accept: string;
files: FilePreviewModel[] = [];
/** File extensions filter */
@Input() fileExtensions: String;
@Input() fileExtensions: String[];
cropper: any;
/** Cropper options. */
@Input() cropperOptions: Object;
Expand All @@ -116,7 +116,9 @@ export class FilePickerComponent implements OnInit, OnDestroy {
cropClosed$ = new Subject<FilePreviewModel>();
_onDestroy$ = new Subject<void>();
safeCropImgUrl: SafeResourceUrl;
constructor(private fileService: FilePickerService, private elementRef: ElementRef) {
constructor(private fileService: FilePickerService,
private elementRef: ElementRef
) {
}

ngOnInit() {
Expand Down Expand Up @@ -290,16 +292,17 @@ export class FilePickerComponent implements OnInit, OnDestroy {
onUploadSuccess(fileItem: FilePreviewModel): void {
this.uploadSuccess.next(fileItem);
}
/** Validates file extension */
isValidExtension(file: File, fileName: string): boolean {
if (!this.fileExtensions) {return true; }
const extension = fileName.split('.').pop();
if (this.fileExtensions && (!this.fileExtensions.toLowerCase().includes(extension.toLowerCase()))) {
this.validationError.next({file: file, error: FileValidationTypes.extensions});
return false;
}
return true;
/** Validates file extension */
isValidExtension(file: File, fileName: string): boolean {
if (!this.fileExtensions) {return true; }
const extension = fileName.split('.').pop();
const fileExtensions = this.fileExtensions.map(ext => ext.toLowerCase());
if (fileExtensions.indexOf(extension.toLowerCase()) === -1) {
this.validationError.next({file: file, error: FileValidationTypes.extensions});
return false;
}
return true;
}
/** Validates selected file size and total file size */
isValidSize(file: File, size: number): boolean {
/** Validating selected file size */
Expand Down

0 comments on commit 18468a2

Please sign in to comment.