From 5b267936620bcd7901b39c4d8cbd2b4698428b6a Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Sat, 4 Feb 2017 21:23:58 +0530 Subject: [PATCH 1/3] Create operator.ts Contains required rxjs operators' import --- src/file-upload/rxjs/operator.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/file-upload/rxjs/operator.ts diff --git a/src/file-upload/rxjs/operator.ts b/src/file-upload/rxjs/operator.ts new file mode 100644 index 00000000..da13df4d --- /dev/null +++ b/src/file-upload/rxjs/operator.ts @@ -0,0 +1,6 @@ +import 'rxjs/add/operator/catch'; +import 'rxjs/add/operator/debounceTime'; +import 'rxjs/add/operator/distinctUntilChanged'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/toPromise'; From f72aa05e4ecdce35c3dcac533e21ee1fe89fd723 Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Sat, 4 Feb 2017 21:38:38 +0530 Subject: [PATCH 2/3] Update file-item.class.ts --- src/file-upload/file-item.class.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/file-upload/file-item.class.ts b/src/file-upload/file-item.class.ts index 17fe274f..e84e0e26 100644 --- a/src/file-upload/file-item.class.ts +++ b/src/file-upload/file-item.class.ts @@ -1,7 +1,14 @@ import { FileLikeObject } from './file-like-object.class'; import { FileUploader, ParsedResponseHeaders, FileUploaderOptions } from './file-uploader.class'; +import {Observable} from "rxjs/Rx"; + export class FileItem { + public observer:any; + /** + * Observable for subscribing the server result + */ + public resObservable:Observable; public file:FileLikeObject; public _file:File; public alias:string; @@ -36,6 +43,7 @@ export class FileItem { this.alias = uploader.options.itemAlias || 'file'; } this.url = uploader.options.url; + this.resObservable=new Observable.create(observer=>{this.observer=observer}); } public upload():void { From 36ebe449b0df12a18494fcbc90601b296bacd9e2 Mon Sep 17 00:00:00 2001 From: Ravinder Payal Date: Sat, 4 Feb 2017 21:42:14 +0530 Subject: [PATCH 3/3] Update file-uploader.class.ts added (line:280) response pusher (observer.next) for pushing the reponse to subscriber --- src/file-upload/file-uploader.class.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/file-upload/file-uploader.class.ts b/src/file-upload/file-uploader.class.ts index 5f17770f..568ad418 100644 --- a/src/file-upload/file-uploader.class.ts +++ b/src/file-upload/file-uploader.class.ts @@ -96,7 +96,6 @@ export class FileUploader { if (!options) { options = this.options; } - let temp = new FileLikeObject(some); if (this._isValidFile(temp, arrayOfFilters, options)) { let fileItem = new FileItem(this, some, options); @@ -278,6 +277,7 @@ export class FileUploader { } this.onCompleteAll(); this.progress = this._getTotalProgress(); + this.item.observer.next(response); this._render(); } @@ -328,7 +328,8 @@ export class FileUploader { let gist = this._isSuccessCode(xhr.status) ? 'Success' : 'Error'; let method = '_on' + gist + 'Item'; (this as any)[method](item, response, xhr.status, headers); - this._onCompleteItem(item, response, xhr.status, headers); + this._ + (item, response, xhr.status, headers); }; xhr.onerror = () => { let headers = this._parseHeaders(xhr.getAllResponseHeaders());