Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from uniprank/development
Browse files Browse the repository at this point in the history
Get nevest version 0.1.9 from development with fixed issue (#2)
  • Loading branch information
Denfie authored Feb 26, 2017
2 parents a4a9663 + f03c42e commit bae3de9
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 215 deletions.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<GitHub issues are ONLY for BUG reports and FEATURE requests>
<Questions or support can be send to StackOverflow>
<PLEASE DO FOLLOW and fill the issue template below. Don't skip or remove any section>

## Issue Overview
<Please explain the issue overview here, short but concise and to-the-point>

## Issue Description
<Please explain the issue in details>

## Reproducables
<Please explain the way to reproduce your issue, or even better with Plunker link>

## Information
| | |
|--------------------- |--------------------------------- |
| **Operating System** | Windows/OSX/Ubuntu/orYourOSHere |
| **Node version** | 4.x/5.x/orYourNodeVersionHere |
| **NPM Version** | 2.x/3.x/orYourNPMVersionHere |
| **Environment** | Browser/Mobile/WebWorker |
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ gulp.task('docs', () => {
ignoreCompilerErrors: true,
experimentalDecorators: true,
emitDecoratorMetadata: true,
target: 'ES5',
target: 'ES6',
moduleResolution: 'node',
preserveConstEnums: true,
stripInternal: true,
suppressExcessPropertyErrors: true,
suppressImplicitAnyIndexErrors: true,
module: 'commonjs',
module: 'es6',
ignoreCompilerErrors: true,
noLib: true
}));
Expand Down
52 changes: 19 additions & 33 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions module/source/fileFilter.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ export enum filterType {
}

export class FileFilter {
public get name(): string {
return this._name;
}

public get type(): filterType | null {
return this._type;
}

private _name: string = '';
private _regex: RegExp | null = null;
private _regCheck: string | null = null;
Expand All @@ -27,15 +35,6 @@ export class FileFilter {
}
throw new Error('FilterData is not defined.');
}

public get name(): string {
return this._name;
}

public get type(): filterType | null {
return this._type;
}

public validate(_file: FileManager): boolean {
let _valid = false;
switch (this._type) {
Expand Down
132 changes: 66 additions & 66 deletions module/source/fileManager.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import { FileManagerOptions } from '../interface/fileManagerOptions.interface';

const FileManagerOptionsDefault: FileManagerOptions = {};

const speedObject: any = {
total: 0,
loaded: 0,
percent: 0,
speed: 0,
speedToText: '0 bytes'
};

export class FileObject {
lastModifiedDate: Date | null;
size: number | null;
Expand Down Expand Up @@ -36,69 +44,9 @@ export class FileObject {
}
}

const speedObject: any = {
total: 0,
loaded: 0,
percent: 0,
speed: 0,
speedToText: '0 bytes'
};

export class FileManager {
public options: FileManagerOptions;

private _id: string;
private _protocol: any;
private _uploader: Transfer;
private _fileElement: any;
private _file: FileObject;
private _speedDefault: any;

private _progress$: BehaviorSubject<number> = new BehaviorSubject(0);
private _speed$: BehaviorSubject<any> = new BehaviorSubject(speedObject);
private _isUploading: boolean;
private _isUploaded: boolean;
private _isSuccess: boolean;
private _isCancel: boolean;
private _isError: boolean;
private _imageLoad: boolean;
private _fileActive: boolean;

/**
* Creates an instance of FileManager.
*
* @param {*} _file
* @param {Transfer} [_uploader]
* @param {FileManagerOptions} [_options]
*
* @memberOf FileManager
*/
constructor (_file: any, _options?: FileManagerOptions, _uploader?: Transfer) {
this.options = Object.assign({}, FileManagerOptionsDefault, _options);
this._speedDefault = {

};

this._id = Utils.uniqueID();

this._isUploading = false;
this._isUploaded = false;
this._isSuccess = false;
this._isCancel = false;
this._isError = false;

let isInput = Utils.isElement(_file);
let file = isInput ? new FileObject(_file.files[0]) : new FileObject(_file);

this._file = file;
this._fileElement = isInput ? _file.files[0] : _file;
this._fileActive = false;

if (typeof _uploader !== 'undefined') {
this.bindUploader(_uploader);
}
}


public set protocol(_protocol: any) {
this._protocol = _protocol;
}
Expand Down Expand Up @@ -155,13 +103,65 @@ export class FileManager {
return this._isError;
}

private _id: string;
private _protocol: any;
private _uploader: Transfer;
private _fileElement: any;
private _file: FileObject;
private _speedDefault: any;

private _progress$: BehaviorSubject<number> = new BehaviorSubject(0);
private _speed$: BehaviorSubject<any> = new BehaviorSubject(speedObject);
private _isUploading: boolean;
private _isUploaded: boolean;
private _isSuccess: boolean;
private _isCancel: boolean;
private _isError: boolean;
private _imageLoad: boolean;
private _fileActive: boolean;

/**
* Bind uploader to FileManager
* Creates an instance of FileManager.
*
* @param {Transfer} _uploader
* @param {*} _file
* @param {Transfer} [_uploader]
* @param {FileManagerOptions} [_options]
*
* @memberOf FileManager
*/
constructor (_file: any, _options?: FileManagerOptions, _uploader?: Transfer) {
this.options = Object.assign({}, FileManagerOptionsDefault, _options);
this._speedDefault = {

};

this._id = Utils.uniqueID();

this._isUploading = false;
this._isUploaded = false;
this._isSuccess = false;
this._isCancel = false;
this._isError = false;

let isInput = Utils.isElement(_file);
let file = isInput ? new FileObject(_file.files[0]) : new FileObject(_file);

this._file = file;
this._fileElement = isInput ? _file.files[0] : _file;
this._fileActive = false;

if (typeof _uploader !== 'undefined') {
this.bindUploader(_uploader);
}
}

/**
* Bind uploader to FileManager
*
* @param {Transfer} _uploader
*
* @memberOf FileManager
*/
public bindUploader (_uploader: Transfer): void {
if (this._uploader instanceof Transfer) {
this._uploader.removeFile(this);
Expand All @@ -173,9 +173,9 @@ export class FileManager {

/**
* Bind options to FileManager
*
*
* @param {FileManagerOptions} _options
*
*
* @memberOf FileManager
*/
public bindOptions (_options: FileManagerOptions): void {
Expand Down Expand Up @@ -248,7 +248,7 @@ export class FileManager {
* @memberOf FileManager
*/
public remove (): void {
let _uploader;
let _uploader: any;

try {
_uploader = this.getUploader();
Expand Down
30 changes: 15 additions & 15 deletions module/source/protocol.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ export abstract class Protocol {
_error: EventEmitter<any>;
_abort: EventEmitter<any>;

public set connection(obj: any) {
let {
_file,
_connection
} = obj;
if (!this.isConnected(_file)) {
this._connections.push({
id: _file.id,
connection: _connection
});
}
}

private _id: string;
private _connections: any[];

Expand All @@ -41,19 +54,6 @@ export abstract class Protocol {
this._connections = [];
}

public set connection(obj: any) {
let {
_file,
_connection
} = obj;
if (!this.isConnected(_file)) {
this._connections.push({
id: _file.id,
connection: _connection
});
}
}

/**
* Call uploader method _onCompleteFile.
*
Expand Down Expand Up @@ -126,7 +126,7 @@ export abstract class Protocol {
}

public removeConnection(_file: FileManager): void {
let _request = null;
let _request: any | null = null;
for (let _key in this._connections) {
if ( this._connections.hasOwnProperty( _key ) ) {
_request = this._connections[_key];
Expand Down Expand Up @@ -170,7 +170,7 @@ export class ProtocolXHR extends Protocol {
*/
public run (_file: FileManager): void {
let _xhr: XMLHttpRequest;
let sendable;
let sendable: any;
let uploader: Transfer = _file.getUploader();

let _formData = Utils.extendValue(uploader.options.formData, _file.options.formData);
Expand Down
Loading

0 comments on commit bae3de9

Please sign in to comment.