Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Jan 12, 2017
1 parent e5aa0c3 commit b5bffcb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 4 additions & 6 deletions src/classes/ng-uploader-options.class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type Method = 'POST' | 'GET' | 'PATCH' | 'PUT';

export interface INgUploaderOptions {
url: string;
cors?: boolean;
Expand All @@ -9,7 +7,7 @@ export interface INgUploaderOptions {
data?: any;
autoUpload?: boolean;
multipart?: any;
method?: Method;
method?: string;
customHeaders?: any;
encodeHeaders?: boolean;
authTokenPrefix?: string;
Expand All @@ -31,7 +29,7 @@ export class NgUploaderOptions implements INgUploaderOptions {
data?: any;
autoUpload?: boolean;
multipart?: any;
method?: Method;
method?: string;
customHeaders?: any;
encodeHeaders?: boolean;
authTokenPrefix?: string;
Expand All @@ -44,7 +42,7 @@ export class NgUploaderOptions implements INgUploaderOptions {
allowedExtensions?: string[];

constructor(obj: INgUploaderOptions) {
function use<T>(source: T|undefined, defaultValue: T): T {
function use<T>(source: T, defaultValue: T): T {
return obj && source !== undefined ? source : defaultValue;
}

Expand All @@ -56,7 +54,7 @@ export class NgUploaderOptions implements INgUploaderOptions {
this.data = use(obj.data, {});
this.autoUpload = use(obj.autoUpload, true);
this.multipart = use(obj.multipart, false);
this.method = use(obj.method, <Method>'POST');
this.method = use(obj.method, 'POST');
this.customHeaders = use(obj.customHeaders, {});
this.encodeHeaders = use(obj.encodeHeaders, false);
this.authTokenPrefix = use(obj.authTokenPrefix, 'Bearer');
Expand Down
5 changes: 3 additions & 2 deletions src/directives/ng-file-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ export class NgFileDropDirective implements OnChanges, OnInit {

if (this.options.filterExtensions && this.options.allowedExtensions && this.files && this.files.length) {
this.files = this.files.filter(f => {
if (this.options.allowedExtensions.indexOf(f.type) !== -1) {
let allowedExtensions = this.options.allowedExtensions || [];
if (allowedExtensions.indexOf(f.type) !== -1) {
return true;
}

let ext: string = f.name.split('.').pop();
if (this.options.allowedExtensions.indexOf(ext) !== -1 ) {
if (allowedExtensions.indexOf(ext) !== -1 ) {
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions src/directives/ng-file-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ export class NgFileSelectDirective implements OnChanges {

if (this.options.filterExtensions && this.options.allowedExtensions && this.files && this.files.length) {
this.files = [].filter.call(this.files, (f: any) => {
if (this.options.allowedExtensions.indexOf(f.type) !== -1) {
let allowedExtensions = this.options.allowedExtensions || [];
if (allowedExtensions.indexOf(f.type) !== -1) {
return true;
}

let ext: string = f.name.split('.').pop();
if (this.options.allowedExtensions.indexOf(ext) !== -1 ) {
if (allowedExtensions.indexOf(ext) !== -1 ) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/ngx-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export class NgUploaderService {
}
};

xhr.open(this.opts.method, this.opts.url, true);
xhr.withCredentials = this.opts.withCredentials;
xhr.open(<string>this.opts.method, this.opts.url, true);
xhr.withCredentials = <boolean>this.opts.withCredentials;

if (this.opts.customHeaders) {
Object.keys(this.opts.customHeaders).forEach((key) => {
Expand Down

0 comments on commit b5bffcb

Please sign in to comment.