Compare commits
4 Commits
v1.2.0
...
ravinderpa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36ebe449b0 | ||
|
|
f72aa05e4e | ||
|
|
5b26793662 | ||
|
|
cf12851e1d |
10
README.md
10
README.md
@@ -1,15 +1,9 @@
|
|||||||
# ng2-file-upload [](http://badge.fury.io/js/ng2-file-upload)
|
# ng2-file-upload [](http://badge.fury.io/js/ng2-file-upload) [](https://npmjs.org/ng2-file-upload)[](https://ngx-slack.herokuapp.com)
|
||||||
Easy to use Angular2 directives for files upload ([demo](http://valor-software.github.io/ng2-file-upload/))
|
Easy to use Angular2 directives for files upload ([demo](http://valor-software.github.io/ng2-file-upload/))
|
||||||
|
|
||||||
Follow me [](https://twitter.com/valorkin) to be notified about new releases.
|
|
||||||
|
|
||||||
[](https://github.com/mgechev/angular2-style-guide)
|
[](https://github.com/mgechev/angular2-style-guide)
|
||||||
[](https://travis-ci.org/valor-software/ng2-file-upload)
|
[](https://travis-ci.org/valor-software/ng2-file-upload)
|
||||||
[](https://codeclimate.com/github/valor-software/ng2-file-upload)
|
|
||||||
[](https://gitter.im/valor-software/ng2-bootstrap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
||||||
[](https://david-dm.org/valor-software/ng2-file-upload)
|
[](https://david-dm.org/valor-software/ng2-file-upload)
|
||||||
[](https://david-dm.org/valor-software/ng2-file-upload#info=devDependencies)
|
|
||||||
[](https://waffle.io/valor-software/ng2-file-upload/metrics)
|
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
import { FileLikeObject } from './file-like-object.class';
|
import { FileLikeObject } from './file-like-object.class';
|
||||||
import { FileUploader, ParsedResponseHeaders, FileUploaderOptions } from './file-uploader.class';
|
import { FileUploader, ParsedResponseHeaders, FileUploaderOptions } from './file-uploader.class';
|
||||||
|
|
||||||
|
import {Observable} from "rxjs/Rx";
|
||||||
|
|
||||||
export class FileItem {
|
export class FileItem {
|
||||||
|
public observer:any;
|
||||||
|
/**
|
||||||
|
* Observable for subscribing the server result
|
||||||
|
*/
|
||||||
|
public resObservable:Observable;
|
||||||
public file:FileLikeObject;
|
public file:FileLikeObject;
|
||||||
public _file:File;
|
public _file:File;
|
||||||
public alias:string;
|
public alias:string;
|
||||||
@@ -36,6 +43,7 @@ export class FileItem {
|
|||||||
this.alias = uploader.options.itemAlias || 'file';
|
this.alias = uploader.options.itemAlias || 'file';
|
||||||
}
|
}
|
||||||
this.url = uploader.options.url;
|
this.url = uploader.options.url;
|
||||||
|
this.resObservable=new Observable.create(observer=>{this.observer=observer});
|
||||||
}
|
}
|
||||||
|
|
||||||
public upload():void {
|
public upload():void {
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ export class FileUploader {
|
|||||||
if (!options) {
|
if (!options) {
|
||||||
options = this.options;
|
options = this.options;
|
||||||
}
|
}
|
||||||
|
|
||||||
let temp = new FileLikeObject(some);
|
let temp = new FileLikeObject(some);
|
||||||
if (this._isValidFile(temp, arrayOfFilters, options)) {
|
if (this._isValidFile(temp, arrayOfFilters, options)) {
|
||||||
let fileItem = new FileItem(this, some, options);
|
let fileItem = new FileItem(this, some, options);
|
||||||
@@ -278,6 +277,7 @@ export class FileUploader {
|
|||||||
}
|
}
|
||||||
this.onCompleteAll();
|
this.onCompleteAll();
|
||||||
this.progress = this._getTotalProgress();
|
this.progress = this._getTotalProgress();
|
||||||
|
this.item.observer.next(response);
|
||||||
this._render();
|
this._render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +328,8 @@ export class FileUploader {
|
|||||||
let gist = this._isSuccessCode(xhr.status) ? 'Success' : 'Error';
|
let gist = this._isSuccessCode(xhr.status) ? 'Success' : 'Error';
|
||||||
let method = '_on' + gist + 'Item';
|
let method = '_on' + gist + 'Item';
|
||||||
(this as any)[method](item, response, xhr.status, headers);
|
(this as any)[method](item, response, xhr.status, headers);
|
||||||
this._onCompleteItem(item, response, xhr.status, headers);
|
this._
|
||||||
|
(item, response, xhr.status, headers);
|
||||||
};
|
};
|
||||||
xhr.onerror = () => {
|
xhr.onerror = () => {
|
||||||
let headers = this._parseHeaders(xhr.getAllResponseHeaders());
|
let headers = this._parseHeaders(xhr.getAllResponseHeaders());
|
||||||
|
|||||||
6
src/file-upload/rxjs/operator.ts
Normal file
6
src/file-upload/rxjs/operator.ts
Normal file
@@ -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';
|
||||||
Reference in New Issue
Block a user