Skip to content

Commit

Permalink
maxSize and accept binded
Browse files Browse the repository at this point in the history
  • Loading branch information
AckerApple committed Nov 27, 2017
1 parent 68a7390 commit 4a98a89
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
9 changes: 5 additions & 4 deletions file-upload/FileUploader.class.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { FileLikeObject } from './FileLikeObject.class';
import { FileItem } from './FileItem.class';
import { EventEmitter } from '@angular/core';
export interface InvalidFileItem {
file: File;
type: string;
}
export interface Headers {
name: string;
value: string;
Expand Down Expand Up @@ -52,10 +56,7 @@ export declare class FileUploader {
isFileValid(file: File): boolean;
isFilesValid(files: File[]): boolean;
getValidFiles(files: File[]): File[];
getInvalidFiles(files: File[]): {
file: File;
type: string;
}[];
getInvalidFiles(files: File[]): InvalidFileItem[];
addToQueue(files: File[], options?: FileUploaderOptions, filters?: FilterFunction[] | string): void;
removeFromQueue(value: FileItem): void;
clearQueue(): void;
Expand Down
2 changes: 1 addition & 1 deletion file-upload/FileUploader.class.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"__symbolic":"module","version":3,"metadata":{"Headers":{"__symbolic":"interface"},"FileUploaderOptions":{"__symbolic":"interface"},"FileUploader":{"__symbolic":"class","members":{"done":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"success":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"catcher":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"},"arguments":["catch"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"setOptions":[{"__symbolic":"method"}],"isFileValid":[{"__symbolic":"method"}],"isFilesValid":[{"__symbolic":"method"}],"getValidFiles":[{"__symbolic":"method"}],"getInvalidFiles":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_acceptFilter":[{"__symbolic":"method"}],"acceptType":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"getQuedFiles":[{"__symbolic":"method"}],"getFormData":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"sendFormDataFileItem":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"getFileFilterFailName":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}],"dataUrl":[{"__symbolic":"method"}],"applyExifRotation":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Headers":{"__symbolic":"interface"},"FileUploaderOptions":{"__symbolic":"interface"},"FileUploader":{"__symbolic":"class","members":{"done":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"success":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"catcher":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"},"arguments":["catch"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"setOptions":[{"__symbolic":"method"}],"isFileValid":[{"__symbolic":"method"}],"isFilesValid":[{"__symbolic":"method"}],"getValidFiles":[{"__symbolic":"method"}],"getInvalidFiles":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_acceptFilter":[{"__symbolic":"method"}],"acceptType":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"getQuedFiles":[{"__symbolic":"method"}],"getFormData":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"sendFormDataFileItem":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"getFileFilterFailName":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}],"dataUrl":[{"__symbolic":"method"}],"applyExifRotation":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":3,"metadata":{"InvalidFileItem":{"__symbolic":"interface"},"Headers":{"__symbolic":"interface"},"FileUploaderOptions":{"__symbolic":"interface"},"FileUploader":{"__symbolic":"class","members":{"done":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"success":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"catcher":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"},"arguments":["catch"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"setOptions":[{"__symbolic":"method"}],"isFileValid":[{"__symbolic":"method"}],"isFilesValid":[{"__symbolic":"method"}],"getValidFiles":[{"__symbolic":"method"}],"getInvalidFiles":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_acceptFilter":[{"__symbolic":"method"}],"acceptType":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"getQuedFiles":[{"__symbolic":"method"}],"getFormData":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"sendFormDataFileItem":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"getFileFilterFailName":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}],"dataUrl":[{"__symbolic":"method"}],"applyExifRotation":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"InvalidFileItem":{"__symbolic":"interface"},"Headers":{"__symbolic":"interface"},"FileUploaderOptions":{"__symbolic":"interface"},"FileUploader":{"__symbolic":"class","members":{"done":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"success":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"catcher":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"},"arguments":["catch"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"setOptions":[{"__symbolic":"method"}],"isFileValid":[{"__symbolic":"method"}],"isFilesValid":[{"__symbolic":"method"}],"getValidFiles":[{"__symbolic":"method"}],"getInvalidFiles":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_acceptFilter":[{"__symbolic":"method"}],"acceptType":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"getQuedFiles":[{"__symbolic":"method"}],"getFormData":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"sendFormDataFileItem":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"getFileFilterFailName":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}],"dataUrl":[{"__symbolic":"method"}],"applyExifRotation":[{"__symbolic":"method"}]}}}}]
8 changes: 3 additions & 5 deletions file-upload/ngf.directive.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventEmitter, ElementRef } from '@angular/core';
import { FileUploader } from './FileUploader.class';
import { FileUploader, InvalidFileItem } from './FileUploader.class';
export declare class ngf {
element: ElementRef;
fileElm: any;
Expand All @@ -15,10 +15,7 @@ export declare class ngf {
ref: ngf;
refChange: EventEmitter<ngf>;
uploader: FileUploader;
lastInvalids: {
file: File;
type: string;
}[];
lastInvalids: InvalidFileItem[];
lastInvalidsChange: EventEmitter<{
file: File;
type: string;
Expand All @@ -32,6 +29,7 @@ export declare class ngf {
constructor(element: ElementRef);
ngOnDestroy(): void;
ngOnInit(): void;
ngOnChanges(changes: any): void;
paramFileElm(): any;
enableSelecting(): void;
getOptions(): any;
Expand Down
18 changes: 10 additions & 8 deletions file-upload/ngf.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var ngf = /** @class */ (function () {
this.selectable = false;
this.directiveInit = new core_1.EventEmitter();
this.refChange = new core_1.EventEmitter();
//deprecated
//deprecating (may actually stay but as a validation class?)
this.uploader = new FileUploader_class_1.FileUploader({});
this.lastInvalids = [];
this.lastInvalidsChange = new core_1.EventEmitter();
Expand All @@ -31,13 +31,6 @@ var ngf = /** @class */ (function () {
if (this.multiple) {
this.paramFileElm().setAttribute('multiple', this.multiple);
}
if (this.accept) {
this.uploader.options.accept = this.accept;
this.paramFileElm().setAttribute('accept', this.accept);
}
if (this.maxSize) {
this.uploader.options.maxFileSize = this.maxSize;
}
if (this.forceFilename) {
this.uploader.options.forceFilename = this.forceFilename;
}
Expand All @@ -50,6 +43,15 @@ var ngf = /** @class */ (function () {
_this.directiveInit.emit(_this);
}, 0);
};
ngf.prototype.ngOnChanges = function (changes) {
if (changes.accept) {
this.uploader.options.accept = changes.accept.currentValue;
this.paramFileElm().setAttribute('accept', changes.accept.currentValue || '*');
}
if (changes.maxSize) {
this.uploader.options.maxFileSize = changes.maxSize.currentValue;
}
};
ngf.prototype.paramFileElm = function () {
if (this.fileElm)
return this.fileElm; //already defined
Expand Down
Loading

0 comments on commit 4a98a89

Please sign in to comment.