diff --git a/package.json b/package.json index f9875160..3ff2175c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-uploader", - "version": "3.1.3", + "version": "3.2.0", "main": "bundles/ngx-uploader.umd.js", "module": "index.js", "esnext": "index.js", diff --git a/src/components/app-home/app-home.component.html b/src/components/app-home/app-home.component.html index 8252482c..7bf3683e 100644 --- a/src/components/app-home/app-home.component.html +++ b/src/components/app-home/app-home.component.html @@ -58,9 +58,15 @@

Drag & Drop

-
-
-
+
+
+
+
+
+
+
+ +
diff --git a/src/ngx-uploader/classes/ngx-uploader.class.ts b/src/ngx-uploader/classes/ngx-uploader.class.ts index e9819b46..bc9437d7 100644 --- a/src/ngx-uploader/classes/ngx-uploader.class.ts +++ b/src/ngx-uploader/classes/ngx-uploader.class.ts @@ -2,10 +2,8 @@ import { EventEmitter } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { Subscription } from 'rxjs/Subscription'; import { Subscriber } from 'rxjs/Subscriber'; -import 'rxjs/add/observable/merge'; import 'rxjs/add/observable/from'; -import 'rxjs/add/operator/mergeAll'; -import 'rxjs/add/operator/combineLatest'; +import 'rxjs/add/operator/merge'; export enum UploadStatus { Queue, @@ -125,19 +123,18 @@ export class NgUploaderService { break; case 'uploadAll': const concurrency = event.concurrency > 0 ? event.concurrency : Number.POSITIVE_INFINITY; - - const subscriber = Subscriber.create((data: UploadOutput) => { - this.serviceEvents.emit(data); - }); - this.uploads = this.uploads.concat(this.files.map(file => { - return { file: file, sub: null }; + return { file: file, sub: { instance: null } }; })); - const subscription = Observable.from(this.files.map(file => this.uploadFile(file, event))) - .mergeAll(concurrency) - .combineLatest(data => data) - .subscribe(subscriber); + Observable.from(this.files.map(file => this.uploadFile(file, event))) + .merge(concurrency) + .subscribe((uploadInstance: Observable) => { + const index = this.uploads.findIndex(u => u.sub.instance === null); + this.uploads[index].sub.instance = uploadInstance.subscribe((data: UploadOutput) => { + this.serviceEvents.emit(data); + }); + }); break; case 'cancel': const id = event.id || null; diff --git a/src/styles/app.sass b/src/styles/app.sass index ca34cbe9..9b5aa413 100644 --- a/src/styles/app.sass +++ b/src/styles/app.sass @@ -158,3 +158,15 @@ html, body, .hero .centered display: flex align-items: center + +.upload-file + + .button + background: $white + border: none + color: $black + outline: none + padding: 10px 20px + border-radius: 4px + display: block + font-size: 14px