Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Issue bleenco#117

* single quotes + style
  • Loading branch information
schwamster authored and jkuri committed Oct 23, 2016
1 parent 3df60e4 commit 1dd28c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/directives/ng-file-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Output,
HostListener
} from '@angular/core';
import {Ng2Uploader} from '../services/ng2-uploader';
import { Ng2Uploader, UploadRejected } from '../services/ng2-uploader';

@Directive({
selector: '[ngFileDrop]'
Expand All @@ -17,6 +17,7 @@ export class NgFileDropDirective {
@Output() onUpload: EventEmitter<any> = new EventEmitter();
@Output() onPreviewData: EventEmitter<any> = new EventEmitter();
@Output() onFileOver:EventEmitter<any> = new EventEmitter();
@Output() onUploadRejected: EventEmitter<UploadRejected> = new EventEmitter<UploadRejected>();

_options:any;

Expand Down Expand Up @@ -96,6 +97,8 @@ export class NgFileDropDirective {
return true;
}

this.onUploadRejected.emit({file: f, reason: UploadRejected.EXTENSION_NOT_ALLOWED});

return false;
});
}
Expand Down
5 changes: 4 additions & 1 deletion src/directives/ng-file-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Output,
HostListener
} from '@angular/core';
import { Ng2Uploader } from '../services/ng2-uploader';
import { Ng2Uploader, UploadRejected } from '../services/ng2-uploader';

@Directive({
selector: '[ngFileSelect]'
Expand All @@ -16,6 +16,7 @@ export class NgFileSelectDirective {
@Input() events: EventEmitter<any>;
@Output() onUpload: EventEmitter<any> = new EventEmitter();
@Output() onPreviewData: EventEmitter<any> = new EventEmitter();
@Output() onUploadRejected: EventEmitter<UploadRejected> = new EventEmitter<UploadRejected>();

_options:any;

Expand Down Expand Up @@ -74,6 +75,8 @@ export class NgFileSelectDirective {
return true;
}

this.onUploadRejected.emit({file: f, reason: UploadRejected.EXTENSION_NOT_ALLOWED});

return false;
});
}
Expand Down
8 changes: 8 additions & 0 deletions src/services/ng2-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ export class Ng2Uploader {
}
}

export class UploadRejected {
public static get EXTENSION_NOT_ALLOWED():string { return 'ExtensionNotAllowed'; }
public static get MAX_SIZE_EXCEEDED():string { return 'MaxSizeExceeded'; }

file: any;
reason: string;
}

function humanizeBytes(bytes: number): string {
if (bytes === 0) {
return '0 Byte';
Expand Down

0 comments on commit 1dd28c1

Please sign in to comment.