Skip to content

Commit

Permalink
chore: rename to ngx-uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Dec 25, 2016
1 parent 0f40e97 commit 5df0ffd
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 76 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# ng2-uploader
# ngx-uploader

For demos please see [demos page](http://ng2-uploader.com).
For demos please see [demos page](http://ngx-uploader.com).

## Angular2 File Uploader

### Installation

```
npm install ng2-uploader --save
npm install ngx-uploader --save
```

### API Docs

[http://docs.ng2-uploader.com](http://docs.ng2-uploader.com)
[http://docs.ngx-uploader.com](http://docs.ngx-uploader.com)

### Available parameters

|Parameter | Example Value
|--- |--- |
| url | http://api.ng2-uploader.com:10050 |
| url | http://api.ngx-uploader.com:10050 |
| filterExtensions | true/false |
| allowedExtensions | ['image/png', 'image/jpg'] or ['jpg', 'png'] |
| calculateSpeed | true/false |
Expand All @@ -34,31 +34,31 @@ npm install ng2-uploader --save

#### Examples

1. [Basic Example](https://github.com/jkuri/ng2-uploader#basic-example)
2. [Advanced Example](https://github.com/jkuri/ng2-uploader#advanced-example)
1. [Basic Example](https://github.com/jkuri/ngx-uploader#basic-example)
2. [Advanced Example](https://github.com/jkuri/ngx-uploader#advanced-example)

#### Backend Examples

1. [NodeJS using HapiJS](https://github.com/jkuri/ng2-uploader#backend-example-using-hapijs)
2. [NodeJS using express](https://github.com/jkuri/ng2-uploader#backend-example-using-express)
3. [PHP (Plain)](https://github.com/jkuri/ng2-uploader#backend-example-using-plain-php)
1. [NodeJS using HapiJS](https://github.com/jkuri/ngx-uploader#backend-example-using-hapijs)
2. [NodeJS using express](https://github.com/jkuri/ngx-uploader#backend-example-using-express)
3. [PHP (Plain)](https://github.com/jkuri/ngx-uploader#backend-example-using-plain-php)

### Basic Example

````ts
// app.module.ts
import { Ng2UploaderModule } from 'ng2-uploader';
import { NgUploaderModule } from 'ngx-uploader';
...
@NgModule({
...
imports: [
Ng2UploaderModule
NgUploaderModule
],
...
})
// app.component.ts
import { Component } from '@angular/core';
import { Ng2UploaderOptions } from 'ng2-uploader';
import { NgUploaderOptions } from 'ngx-uploader';

@Component({
selector: 'demo-app',
Expand All @@ -67,7 +67,7 @@ import { Ng2UploaderOptions } from 'ng2-uploader';
export class DemoApp {
uploadFile: any;
hasBaseDropZoneOver: boolean = false;
options: Ng2UploaderOptions = {
options: NgUploaderOptions = {
url: 'http://localhost:10050/upload'
};
sizeLimit = 2000000;
Expand Down Expand Up @@ -123,22 +123,22 @@ This example show how to use available options and progress.

```ts
import { Component, OnInit, NgZone } from '@angular/core';
import { Ng2UploaderOptions } from 'ng2-uploader';
import { NgUploaderOptions } from 'ngx-uploader';

@Component({
selector: 'app-component',
templateUrl: 'app.component.html'
})
export class AppDemoComponent implements OnInit {
private zone: NgZone;
private options: Ng2UploaderOptions;
private options: NgUploaderOptions;
private progress: number = 0;
private response: any = {};

ngOnInit() {
this.zone = new NgZone({ enableLongStackTrace: false });
this.options = {
url: 'http://api.ng2-uploader.com:10050/upload',
url: 'http://api.ngx-uploader.com:10050/upload',
filterExtensions: true,
allowedExtensions: ['image/png', 'image/jpg'],
calculateSpeed: true,
Expand Down Expand Up @@ -267,7 +267,7 @@ app.post('/upload', upload.any(), (req, res) => {
});

app.listen(10050, () => {
console.log('ng2-uploader server running on port 10050.');
console.log('ngx-uploader server running on port 10050.');
});
````

Expand Down Expand Up @@ -319,7 +319,7 @@ else {

### Demos

For more information, examples and usage examples please see [demos](http://ng2-uploader.com)
For more information, examples and usage examples please see [demos](http://ngx-uploader.com)

#### LICENCE

Expand Down
25 changes: 0 additions & 25 deletions gulpfile.js

This file was deleted.

6 changes: 3 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { NgFileSelectDirective } from './src/directives/ng-file-select';

export * from './src/directives/ng-file-drop';
export * from './src/directives/ng-file-select';
export * from './src/services/ng2-uploader';
export * from './src/services/ngx-uploader';

export { Ng2UploaderOptions, UploadedFile, UploadRejected } from './src/classes';
export { NgUploaderOptions, UploadedFile, UploadRejected } from './src/classes';

export { Ng2UploaderModule } from './src/module/ng2-uploader.module';
export { NgUploaderModule } from './src/module/ngx-uploader.module';

export const UPLOAD_DIRECTIVES: any[] = [
NgFileSelectDirective,
Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-uploader",
"description": "Angular2 File Uploader",
"name": "ngx-uploader",
"description": "Angular File Uploader",
"version": "2.0.0",
"license": "MIT",
"main": "index.js",
Expand All @@ -15,12 +15,11 @@
},
"repository": {
"type": "git",
"url": "https://github.com/jkuri/ng2-uploader.git"
"url": "https://github.com/jkuri/ngx-uploader.git"
},
"keywords": [
"ng2",
"ngx",
"angular",
"angular2",
"file",
"upload",
"uploader"
Expand Down
2 changes: 1 addition & 1 deletion src/classes/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './ng2-uploader-options.class';
export * from './ng-uploader-options.class';
export * from './uploaded-file.class';
export * from './upload-rejected.class';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface INg2UploaderOptions {
export interface INgUploaderOptions {
url: string;
cors?: boolean;
withCredentials?: boolean;
Expand All @@ -20,7 +20,7 @@ export interface INg2UploaderOptions {
allowedExtensions?: string[];
}

export class Ng2UploaderOptions implements INg2UploaderOptions {
export class NgUploaderOptions implements INgUploaderOptions {
url: string;
cors?: boolean;
withCredentials?: boolean;
Expand All @@ -41,7 +41,7 @@ export class Ng2UploaderOptions implements INg2UploaderOptions {
filterExtensions?: boolean;
allowedExtensions?: string[];

constructor(obj: INg2UploaderOptions) {
constructor(obj: INgUploaderOptions) {
this.url = obj.url != null ? obj.url : '';
this.cors = obj.cors != null ? obj.cors : true;
this.withCredentials = obj.withCredentials != null ? obj.withCredentials : this.withCredentials;
Expand Down
10 changes: 5 additions & 5 deletions src/directives/ng-file-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
OnChanges,
OnInit
} from '@angular/core';
import { Ng2UploaderService } from '../services/ng2-uploader';
import { INg2UploaderOptions, Ng2UploaderOptions, UploadedFile, UploadRejected } from '../classes';
import { NgUploaderService } from '../services/ngx-uploader';
import { INgUploaderOptions, NgUploaderOptions, UploadedFile, UploadRejected } from '../classes';

@Directive({
selector: '[ngFileDrop]'
})
export class NgFileDropDirective implements OnChanges, OnInit {
@Input() options: Ng2UploaderOptions;
@Input() options: NgUploaderOptions;
@Input() events: EventEmitter<any>;
@Output() onUpload: EventEmitter<any> = new EventEmitter();
@Output() onPreviewData: EventEmitter<any> = new EventEmitter();
Expand All @@ -28,7 +28,7 @@ export class NgFileDropDirective implements OnChanges, OnInit {

constructor(
@Inject(ElementRef) public el: ElementRef,
@Inject(Ng2UploaderService) public uploader: Ng2UploaderService) { }
@Inject(NgUploaderService) public uploader: NgUploaderService) { }

ngOnInit() {
this.uploader._emitter.subscribe((data: any) => {
Expand Down Expand Up @@ -64,7 +64,7 @@ export class NgFileDropDirective implements OnChanges, OnInit {
return;
}

this.options = new Ng2UploaderOptions(this.options);
this.options = new NgUploaderOptions(this.options);
this.uploader.setOptions(this.options);
}

Expand Down
10 changes: 5 additions & 5 deletions src/directives/ng-file-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
Inject,
OnChanges
} from '@angular/core';
import { Ng2UploaderService } from '../services/ng2-uploader';
import { INg2UploaderOptions, Ng2UploaderOptions, UploadedFile, UploadRejected } from '../classes';
import { NgUploaderService } from '../services/ngx-uploader';
import { INgUploaderOptions, NgUploaderOptions, UploadedFile, UploadRejected } from '../classes';

@Directive({
selector: '[ngFileSelect]'
})
export class NgFileSelectDirective implements OnChanges {
@Input() options: Ng2UploaderOptions;
@Input() options: NgUploaderOptions;
@Input() events: EventEmitter<any>;
@Output() onUpload: EventEmitter<any> = new EventEmitter();
@Output() onPreviewData: EventEmitter<any> = new EventEmitter();
Expand All @@ -26,14 +26,14 @@ export class NgFileSelectDirective implements OnChanges {

constructor(
@Inject(ElementRef) public el: ElementRef,
@Inject(Ng2UploaderService) public uploader: Ng2UploaderService) { }
@Inject(NgUploaderService) public uploader: NgUploaderService) { }

ngOnChanges() {
if (!this.options) {
return;
}

this.uploader.setOptions(new Ng2UploaderOptions(this.options));
this.uploader.setOptions(new NgUploaderOptions(this.options));

this.uploader._emitter.subscribe((data: any) => {
this.onUpload.emit(data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { NgModule } from '@angular/core';
import { NgFileDropDirective } from './../directives/ng-file-drop';
import { NgFileSelectDirective } from './../directives/ng-file-select';
import { Ng2UploaderServiceProvider } from './../services/ng2-uploader';
import { NgUploaderServiceProvider } from './../services/ngx-uploader';

@NgModule({
declarations: [
NgFileDropDirective,
NgFileSelectDirective
],
providers: [
Ng2UploaderServiceProvider
NgUploaderServiceProvider
],
exports: [
NgFileDropDirective,
NgFileSelectDirective
]
})
export class Ng2UploaderModule{}
export class NgUploaderModule {}

12 changes: 6 additions & 6 deletions src/services/ng2-uploader.ts → src/services/ngx-uploader.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { EventEmitter, Injectable, OnChanges, Provider } from '@angular/core';
import { Ng2UploaderOptions } from '../classes/ng2-uploader-options.class';
import { NgUploaderOptions } from '../classes/ng-uploader-options.class';
import { UploadedFile } from '../classes/uploaded-file.class';
import { UploadRejected } from '../classes/upload-rejected.class';

@Injectable()
export class Ng2UploaderService {
export class NgUploaderService {
_queue: any[];
_emitter: EventEmitter<any>;
_previewEmitter: EventEmitter<any>;
_beforeEmitter: EventEmitter<any>;
opts: Ng2UploaderOptions;
opts: NgUploaderOptions;

constructor() {
this._queue = [];
Expand All @@ -18,7 +18,7 @@ export class Ng2UploaderService {
this._beforeEmitter = new EventEmitter<any>();
}

setOptions(opts: Ng2UploaderOptions) {
setOptions(opts: NgUploaderOptions) {
this.opts = opts;
}

Expand Down Expand Up @@ -184,6 +184,6 @@ export class Ng2UploaderService {
}
}

export const Ng2UploaderServiceProvider: Provider = {
provide: Ng2UploaderService, useClass: Ng2UploaderService
export const NgUploaderServiceProvider: Provider = {
provide: NgUploaderService, useClass: NgUploaderService
};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
],
"files": [
"index.ts",
"ng2-uploader.ts"
"ngx-uploader.ts"
],
"angularCompilerOptions": {
"genDir": "aot",
Expand Down

0 comments on commit 5df0ffd

Please sign in to comment.