From 5df0ffde63855b2ae5a64447eb47675520efa0fa Mon Sep 17 00:00:00 2001 From: Jan Kuri Date: Sun, 25 Dec 2016 06:40:57 +0100 Subject: [PATCH] chore: rename to ngx-uploader --- README.md | 38 +++++++++---------- gulpfile.js | 25 ------------ index.ts | 6 +-- ng2-uploader.ts => ngx-uploader.ts | 0 package.json | 9 ++--- src/classes/index.ts | 2 +- ....class.ts => ng-uploader-options.class.ts} | 6 +-- src/directives/ng-file-drop.ts | 10 ++--- src/directives/ng-file-select.ts | 10 ++--- ...oader.module.ts => ngx-uploader.module.ts} | 6 +-- .../{ng2-uploader.ts => ngx-uploader.ts} | 12 +++--- tsconfig.json | 2 +- 12 files changed, 50 insertions(+), 76 deletions(-) delete mode 100644 gulpfile.js rename ng2-uploader.ts => ngx-uploader.ts (100%) rename src/classes/{ng2-uploader-options.class.ts => ng-uploader-options.class.ts} (93%) rename src/module/{ng2-uploader.module.ts => ngx-uploader.module.ts} (72%) rename src/services/{ng2-uploader.ts => ngx-uploader.ts} (94%) diff --git a/README.md b/README.md index 9869499a..8b9c4e4b 100644 --- a/README.md +++ b/README.md @@ -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 | @@ -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', @@ -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; @@ -123,7 +123,7 @@ 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', @@ -131,14 +131,14 @@ import { Ng2UploaderOptions } from 'ng2-uploader'; }) 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, @@ -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.'); }); ```` @@ -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 diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 1b8dd1c8..00000000 --- a/gulpfile.js +++ /dev/null @@ -1,25 +0,0 @@ -const gulp = require('gulp'); -const typedoc = require('gulp-typedoc'); - -gulp.task('docs', () => { - return gulp.src([ - 'index.ts', - '!node_modules/**/*']) - .pipe(typedoc({ - name: 'ng2-uploader docs', - mode: 'file', - out: 'docs', - ignoreCompilerErrors: true, - experimentalDecorators: true, - emitDecoratorMetadata: true, - target: 'ES5', - moduleResolution: 'node', - preserveConstEnums: true, - stripInternal: true, - suppressExcessPropertyErrors: true, - suppressImplicitAnyIndexErrors: true, - module: 'commonjs', - ignoreCompilerErrors: true, - noLib: true - })); -}); diff --git a/index.ts b/index.ts index 35e1de31..645b13ac 100644 --- a/index.ts +++ b/index.ts @@ -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, diff --git a/ng2-uploader.ts b/ngx-uploader.ts similarity index 100% rename from ng2-uploader.ts rename to ngx-uploader.ts diff --git a/package.json b/package.json index 1ff5afcb..d9c9caee 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" diff --git a/src/classes/index.ts b/src/classes/index.ts index 0dd20451..31f9969c 100644 --- a/src/classes/index.ts +++ b/src/classes/index.ts @@ -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'; diff --git a/src/classes/ng2-uploader-options.class.ts b/src/classes/ng-uploader-options.class.ts similarity index 93% rename from src/classes/ng2-uploader-options.class.ts rename to src/classes/ng-uploader-options.class.ts index 2a69919b..72541554 100644 --- a/src/classes/ng2-uploader-options.class.ts +++ b/src/classes/ng-uploader-options.class.ts @@ -1,4 +1,4 @@ -export interface INg2UploaderOptions { +export interface INgUploaderOptions { url: string; cors?: boolean; withCredentials?: boolean; @@ -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; @@ -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; diff --git a/src/directives/ng-file-drop.ts b/src/directives/ng-file-drop.ts index 42208d4c..4d34a052 100644 --- a/src/directives/ng-file-drop.ts +++ b/src/directives/ng-file-drop.ts @@ -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; @Output() onUpload: EventEmitter = new EventEmitter(); @Output() onPreviewData: EventEmitter = new EventEmitter(); @@ -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) => { @@ -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); } diff --git a/src/directives/ng-file-select.ts b/src/directives/ng-file-select.ts index 2b006163..3841d094 100644 --- a/src/directives/ng-file-select.ts +++ b/src/directives/ng-file-select.ts @@ -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; @Output() onUpload: EventEmitter = new EventEmitter(); @Output() onPreviewData: EventEmitter = new EventEmitter(); @@ -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); diff --git a/src/module/ng2-uploader.module.ts b/src/module/ngx-uploader.module.ts similarity index 72% rename from src/module/ng2-uploader.module.ts rename to src/module/ngx-uploader.module.ts index 0d786aef..ef4eb808 100644 --- a/src/module/ng2-uploader.module.ts +++ b/src/module/ngx-uploader.module.ts @@ -1,7 +1,7 @@ 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: [ @@ -9,12 +9,12 @@ import { Ng2UploaderServiceProvider } from './../services/ng2-uploader'; NgFileSelectDirective ], providers: [ - Ng2UploaderServiceProvider + NgUploaderServiceProvider ], exports: [ NgFileDropDirective, NgFileSelectDirective ] }) -export class Ng2UploaderModule{} +export class NgUploaderModule {} diff --git a/src/services/ng2-uploader.ts b/src/services/ngx-uploader.ts similarity index 94% rename from src/services/ng2-uploader.ts rename to src/services/ngx-uploader.ts index 94b23cbf..7318dc7e 100644 --- a/src/services/ng2-uploader.ts +++ b/src/services/ngx-uploader.ts @@ -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; _previewEmitter: EventEmitter; _beforeEmitter: EventEmitter; - opts: Ng2UploaderOptions; + opts: NgUploaderOptions; constructor() { this._queue = []; @@ -18,7 +18,7 @@ export class Ng2UploaderService { this._beforeEmitter = new EventEmitter(); } - setOptions(opts: Ng2UploaderOptions) { + setOptions(opts: NgUploaderOptions) { this.opts = opts; } @@ -184,6 +184,6 @@ export class Ng2UploaderService { } } -export const Ng2UploaderServiceProvider: Provider = { - provide: Ng2UploaderService, useClass: Ng2UploaderService +export const NgUploaderServiceProvider: Provider = { + provide: NgUploaderService, useClass: NgUploaderService }; diff --git a/tsconfig.json b/tsconfig.json index 072af121..91664236 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,7 @@ ], "files": [ "index.ts", - "ng2-uploader.ts" + "ngx-uploader.ts" ], "angularCompilerOptions": { "genDir": "aot",