Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d2da3809d | ||
|
|
4fef496698 | ||
|
|
c1b3b5dc19 | ||
|
|
003f1eb0d2 | ||
|
|
0d1fd54f45 | ||
|
|
b886f7846b | ||
|
|
b50116313b | ||
|
|
04152e2809 | ||
|
|
cdc76cced0 | ||
|
|
0e7e397f7d | ||
|
|
48128becdd | ||
|
|
6f42e303f9 | ||
|
|
e9d356b1ce | ||
|
|
22307d266f | ||
|
|
e068511917 | ||
|
|
8133246439 | ||
|
|
db77e89235 | ||
|
|
ec1e5ae556 | ||
|
|
9a00e47318 | ||
|
|
97cf9c2a94 | ||
|
|
efb086d6b4 | ||
|
|
c7793b7a50 | ||
|
|
4f13f2e356 | ||
|
|
897c8131c8 | ||
|
|
ccdfc664be | ||
|
|
0daff86ec6 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,6 +8,7 @@ npm-debug.log
|
|||||||
|
|
||||||
# WebStorm
|
# WebStorm
|
||||||
.idea
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
||||||
# ignore build and dist for now
|
# ignore build and dist for now
|
||||||
/bundles
|
/bundles
|
||||||
@@ -19,6 +20,7 @@ npm-debug.log
|
|||||||
# ignore incline compiling
|
# ignore incline compiling
|
||||||
/demo/**/*.js
|
/demo/**/*.js
|
||||||
/demo/**/*.d.ts
|
/demo/**/*.d.ts
|
||||||
|
!/demo/custom-typings.d.ts
|
||||||
/demo/**/*.js.map
|
/demo/**/*.js.map
|
||||||
/components/**/*.js
|
/components/**/*.js
|
||||||
/components/**/*.d.ts
|
/components/**/*.d.ts
|
||||||
|
|||||||
29
.ng2-config.js
Normal file
29
.ng2-config.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
'use strict';
|
||||||
|
var pkg = require('./package.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
// metadata
|
||||||
|
title: pkg.description,
|
||||||
|
baseUrl: '/',
|
||||||
|
// root folder name
|
||||||
|
src: 'demo',
|
||||||
|
dist: 'demo-build',
|
||||||
|
htmlIndexes: ['index.html'],
|
||||||
|
// karma bundle src
|
||||||
|
spec: './spec-bundle.js',
|
||||||
|
// webpack entry
|
||||||
|
entry: {
|
||||||
|
polyfills: './demo/polyfills.ts',
|
||||||
|
vendor: './demo/vendor.ts',
|
||||||
|
main: './demo/index.ts'
|
||||||
|
},
|
||||||
|
commonChunks: {
|
||||||
|
name: ['polyfills', 'vendor'].reverse()
|
||||||
|
},
|
||||||
|
// webpack alias
|
||||||
|
alias: {},
|
||||||
|
copy: [
|
||||||
|
{from: 'demo/favicon.ico', to: 'favicon.ico'},
|
||||||
|
{from: 'demo/assets', to: 'assets'}
|
||||||
|
]
|
||||||
|
};
|
||||||
@@ -2,12 +2,14 @@ language: node_js
|
|||||||
node_js:
|
node_js:
|
||||||
- "6"
|
- "6"
|
||||||
|
|
||||||
|
before_install: npm i -g npm@latest
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- npm run flow.install:typings
|
- npm run flow.install:typings
|
||||||
- npm test
|
- npm test
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- ./node_modules/.bin/codecov
|
- ./node_modules/.bin/codecov -f coverage/coverage-final.json
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
# sauce labs tunel connector (read more https://docs.travis-ci.com/user/sauce-connect/ )
|
# sauce labs tunel connector (read more https://docs.travis-ci.com/user/sauce-connect/ )
|
||||||
|
|||||||
17
CHANGELOG.md
17
CHANGELOG.md
@@ -1,3 +1,20 @@
|
|||||||
|
<a name="1.1.0"></a>
|
||||||
|
# [1.1.0](https://github.com/valor-software/ng2-file-upload/compare/v1.0.3...v1.1.0) (2016-09-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **uploader:** Add the ability to upload files via PUT instead of POST ([#239](https://github.com/valor-software/ng2-file-upload/issues/239)) ([e068511](https://github.com/valor-software/ng2-file-upload/commit/e068511))
|
||||||
|
* **zone.js:** error in Safari, Added Typings ([#221](https://github.com/valor-software/ng2-file-upload/issues/221)) ([db77e89](https://github.com/valor-software/ng2-file-upload/commit/db77e89))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **multipart:** Create disableMultipart option in FileUploader ([#224](https://github.com/valor-software/ng2-file-upload/issues/224)) ([22307d2](https://github.com/valor-software/ng2-file-upload/commit/22307d2))
|
||||||
|
* **package:** updated to typescript 2 ([4fef496](https://github.com/valor-software/ng2-file-upload/commit/4fef496))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="1.0.3"></a>
|
<a name="1.0.3"></a>
|
||||||
## [1.0.3](https://github.com/valor-software/ng2-file-upload/compare/v1.0.2...v1.0.3) (2016-05-12)
|
## [1.0.3](https://github.com/valor-software/ng2-file-upload/compare/v1.0.2...v1.0.3) (2016-05-12)
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,12 @@ Follow me [ - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)
|
- `uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)
|
||||||
|
|
||||||
Parameters that supported by this object:
|
Parameters supported by this object:
|
||||||
|
|
||||||
1. `url` - URL of File Uploader's route
|
1. `url` - URL of File Uploader's route
|
||||||
2. `authToken` - Auth token that will be applied as 'Authorization' header during file send.
|
2. `authToken` - Auth token that will be applied as 'Authorization' header during file send.
|
||||||
|
3. `disableMultipart` - If 'true', disable using a multipart form for file upload and instead stream the file. Some APIs (e.g. Amazon S3) may expect the file to be streamed rather than sent via a form. Defaults to false.
|
||||||
|
4. `itemAlias` - item alias (form name redefenition)
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
import {Component} from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import {it, inject, beforeEachProviders} from '@angular/core/testing';
|
import { inject, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import {ComponentFixture} from '@angular/compiler/testing';
|
|
||||||
import {FileUploader} from './file-uploader.class';
|
import { FileUploader } from './file-uploader.class';
|
||||||
import {FileSelectDirective} from './file-select.directive';
|
import { FileUploadModule } from './file-upload.module';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'container',
|
selector: 'container',
|
||||||
template: `<input type="file" ng2FileSelect [uploader]="uploader" />`,
|
template: `<input type="file" ng2FileSelect [uploader]="uploader" />`
|
||||||
directives: [FileSelectDirective]
|
|
||||||
})
|
})
|
||||||
export class ContainerComponent {
|
export class ContainerComponent {
|
||||||
public uploader:FileUploader = new FileUploader({url: 'localhost:3000'});
|
public uploader:FileUploader = new FileUploader({url: 'localhost:3000'});
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Directive: FileSelectDirective', () => {
|
describe('Directive: FileSelectDirective', () => {
|
||||||
beforeEachProviders(() => [
|
|
||||||
ContainerComponent
|
beforeEach(() => {
|
||||||
]);
|
TestBed.configureTestingModule({
|
||||||
|
imports: [FileUploadModule],
|
||||||
|
declarations: [ContainerComponent],
|
||||||
|
providers: [ContainerComponent]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should be fine', inject([ContainerComponent], (fixture:ComponentFixture<ContainerComponent>) => {
|
it('should be fine', inject([ContainerComponent], (fixture:ComponentFixture<ContainerComponent>) => {
|
||||||
expect(fixture).not.toBeNull();
|
expect(fixture).not.toBeNull();
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import { FileUploader } from './file-uploader.class';
|
|||||||
export class FileDropDirective {
|
export class FileDropDirective {
|
||||||
@Input() public uploader:FileUploader;
|
@Input() public uploader:FileUploader;
|
||||||
@Output() public fileOver:EventEmitter<any> = new EventEmitter();
|
@Output() public fileOver:EventEmitter<any> = new EventEmitter();
|
||||||
@Output() public onFileDrop:EventEmitter<File[]> = new EventEmitter();
|
@Output() public onFileDrop:EventEmitter<File[]> = new EventEmitter<File[]>();
|
||||||
|
|
||||||
private element:ElementRef;
|
private element:ElementRef;
|
||||||
|
|
||||||
public constructor(element:ElementRef) {
|
public constructor(element:ElementRef) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
}
|
}
|
||||||
@@ -80,12 +81,13 @@ export class FileDropDirective {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
_addOverClass(item:any):any {
|
|
||||||
item.addOverClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
_removeOverClass(item:any):any {
|
/*
|
||||||
item.removeOverClass();
|
_addOverClass(item:any):any {
|
||||||
}*/
|
item.addOverClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
_removeOverClass(item:any):any {
|
||||||
|
item.removeOverClass();
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
import {NgZone} from '@angular/core';
|
import { FileLikeObject } from './file-like-object.class';
|
||||||
|
import { FileUploader, ParsedResponseHeaders, FileUploaderOptions } from './file-uploader.class';
|
||||||
import {FileLikeObject} from './file-like-object.class';
|
|
||||||
import {FileUploader} from './file-uploader.class';
|
|
||||||
|
|
||||||
export class FileItem {
|
export class FileItem {
|
||||||
public file:FileLikeObject;
|
public file:FileLikeObject;
|
||||||
public _file:File;
|
public _file:File;
|
||||||
public alias:string = 'file';
|
public alias:string;
|
||||||
public url:string = '/';
|
public url:string = '/';
|
||||||
public method:string = 'POST';
|
public method:string;
|
||||||
public headers:any = [];
|
public headers:any = [];
|
||||||
public withCredentials:boolean = true;
|
public withCredentials:boolean = true;
|
||||||
public formData:any = [];
|
public formData:any = [];
|
||||||
@@ -20,28 +18,32 @@ export class FileItem {
|
|||||||
public isError:boolean = false;
|
public isError:boolean = false;
|
||||||
public progress:number = 0;
|
public progress:number = 0;
|
||||||
public index:number = void 0;
|
public index:number = void 0;
|
||||||
private _zone:NgZone;
|
public _xhr:XMLHttpRequest;
|
||||||
|
public _form:any;
|
||||||
|
|
||||||
private uploader:FileUploader;
|
private uploader:FileUploader;
|
||||||
private some:any;
|
private some:File;
|
||||||
private options:any;
|
private options:FileUploaderOptions;
|
||||||
|
|
||||||
public constructor(uploader:FileUploader, some:any, options:any) {
|
public constructor(uploader:FileUploader, some:File, options:FileUploaderOptions) {
|
||||||
this.uploader = uploader;
|
this.uploader = uploader;
|
||||||
this.some = some;
|
this.some = some;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.file = new FileLikeObject(some);
|
this.file = new FileLikeObject(some);
|
||||||
this._file = some;
|
this._file = some;
|
||||||
|
if (uploader.options) {
|
||||||
|
this.method = uploader.options.method || 'POST';
|
||||||
|
this.alias = uploader.options.itemAlias || 'file';
|
||||||
|
}
|
||||||
this.url = uploader.options.url;
|
this.url = uploader.options.url;
|
||||||
this._zone = new NgZone({ enableLongStackTrace: false });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public upload():void {
|
public upload():void {
|
||||||
try {
|
try {
|
||||||
this.uploader.uploadItem(this);
|
this.uploader.uploadItem(this);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.uploader._onCompleteItem(this, '', 0, []);
|
this.uploader._onCompleteItem(this, '', 0, {});
|
||||||
this.uploader._onErrorItem(this, '', 0, []);
|
this.uploader._onErrorItem(this, '', 0, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,20 +67,20 @@ export class FileItem {
|
|||||||
return {progress};
|
return {progress};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onSuccess(response:any, status:any, headers:any):any {
|
public onSuccess(response:string, status:number, headers:ParsedResponseHeaders):any {
|
||||||
return {response,status,headers};
|
return {response, status, headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onError(response:any, status:any, headers:any):any {
|
public onError(response:string, status:number, headers:ParsedResponseHeaders):any {
|
||||||
return {response,status,headers};
|
return {response, status, headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCancel(response:any, status:any, headers:any):any {
|
public onCancel(response:string, status:number, headers:ParsedResponseHeaders):any {
|
||||||
return {response,status,headers};
|
return {response, status, headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onComplete(response:any, status:any, headers:any):any {
|
public onComplete(response:string, status:number, headers:ParsedResponseHeaders):any {
|
||||||
return {response,status,headers};
|
return {response, status, headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onBeforeUpload():void {
|
public _onBeforeUpload():void {
|
||||||
@@ -97,13 +99,11 @@ export class FileItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public _onProgress(progress:number):void {
|
public _onProgress(progress:number):void {
|
||||||
this._zone.run(() => {
|
this.progress = progress;
|
||||||
this.progress = progress;
|
|
||||||
});
|
|
||||||
this.onProgress(progress);
|
this.onProgress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onSuccess(response:any, status:any, headers:any):void {
|
public _onSuccess(response:string, status:number, headers:ParsedResponseHeaders):void {
|
||||||
this.isReady = false;
|
this.isReady = false;
|
||||||
this.isUploading = false;
|
this.isUploading = false;
|
||||||
this.isUploaded = true;
|
this.isUploaded = true;
|
||||||
@@ -115,7 +115,7 @@ export class FileItem {
|
|||||||
this.onSuccess(response, status, headers);
|
this.onSuccess(response, status, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onError(response:any, status:any, headers:any):void {
|
public _onError(response:string, status:number, headers:ParsedResponseHeaders):void {
|
||||||
this.isReady = false;
|
this.isReady = false;
|
||||||
this.isUploading = false;
|
this.isUploading = false;
|
||||||
this.isUploaded = true;
|
this.isUploaded = true;
|
||||||
@@ -127,7 +127,7 @@ export class FileItem {
|
|||||||
this.onError(response, status, headers);
|
this.onError(response, status, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onCancel(response:any, status:any, headers:any):void {
|
public _onCancel(response:string, status:number, headers:ParsedResponseHeaders):void {
|
||||||
this.isReady = false;
|
this.isReady = false;
|
||||||
this.isUploading = false;
|
this.isUploading = false;
|
||||||
this.isUploaded = false;
|
this.isUploaded = false;
|
||||||
@@ -139,7 +139,7 @@ export class FileItem {
|
|||||||
this.onCancel(response, status, headers);
|
this.onCancel(response, status, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onComplete(response:any, status:any, headers:any):void {
|
public _onComplete(response:string, status:number, headers:ParsedResponseHeaders):void {
|
||||||
this.onComplete(response, status, headers);
|
this.onComplete(response, status, headers);
|
||||||
|
|
||||||
if (this.uploader.options.removeAfterUpload) {
|
if (this.uploader.options.removeAfterUpload) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export class FileLikeObject {
|
|||||||
this.name = path.slice(path.lastIndexOf('/') + path.lastIndexOf('\\') + 2);
|
this.name = path.slice(path.lastIndexOf('/') + path.lastIndexOf('\\') + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _createFromObject(object:{size: number, type: string, name: string}):void {
|
public _createFromObject(object:{size:number, type:string, name:string}):void {
|
||||||
// this.lastModifiedDate = copy(object.lastModifiedDate);
|
// this.lastModifiedDate = copy(object.lastModifiedDate);
|
||||||
this.size = object.size;
|
this.size = object.size;
|
||||||
this.type = object.type;
|
this.type = object.type;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Directive, ElementRef, Input, HostListener } from '@angular/core';
|
import { Directive, ElementRef, Input, HostListener } from '@angular/core';
|
||||||
|
|
||||||
import {FileUploader} from './file-uploader.class';
|
import { FileUploader } from './file-uploader.class';
|
||||||
|
|
||||||
// todo: filters
|
// todo: filters
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ export class FileSelectDirective {
|
|||||||
@Input() public uploader:FileUploader;
|
@Input() public uploader:FileUploader;
|
||||||
|
|
||||||
private element:ElementRef;
|
private element:ElementRef;
|
||||||
|
|
||||||
public constructor(element:ElementRef) {
|
public constructor(element:ElementRef) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
}
|
}
|
||||||
|
|||||||
13
components/file-upload/file-upload.module.ts
Normal file
13
components/file-upload/file-upload.module.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
|
import { FileDropDirective } from './file-drop.directive';
|
||||||
|
import { FileSelectDirective } from './file-select.directive';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [CommonModule],
|
||||||
|
declarations: [FileDropDirective, FileSelectDirective],
|
||||||
|
exports: [FileDropDirective, FileSelectDirective]
|
||||||
|
})
|
||||||
|
export class FileUploadModule {
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import {FileLikeObject} from './file-like-object.class';
|
import { FileLikeObject } from './file-like-object.class';
|
||||||
import {FileItem} from './file-item.class';
|
import { FileItem } from './file-item.class';
|
||||||
import {FileType} from './file-type.class';
|
import { FileType } from './file-type.class';
|
||||||
|
|
||||||
function isFile(value:any):boolean {
|
function isFile(value:any):boolean {
|
||||||
return (File && value instanceof File);
|
return (File && value instanceof File);
|
||||||
@@ -11,24 +11,32 @@ export interface Headers {
|
|||||||
value:string;
|
value:string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ParsedResponseHeaders = {[headerFieldName:string]:string};
|
||||||
|
|
||||||
|
export type FilterFunction = {name:string, fn:(item?:FileLikeObject, options?:FileUploaderOptions)=>boolean};
|
||||||
|
|
||||||
export interface FileUploaderOptions {
|
export interface FileUploaderOptions {
|
||||||
allowedMimeType?:Array<string>;
|
allowedMimeType?:Array<string>;
|
||||||
allowedFileType?:Array<string>;
|
allowedFileType?:Array<string>;
|
||||||
autoUpload?:boolean;
|
autoUpload?:boolean;
|
||||||
isHTML5?:boolean;
|
isHTML5?:boolean;
|
||||||
filters?:Array<any>;
|
filters?:Array<FilterFunction>;
|
||||||
headers?:Array<Headers>;
|
headers?:Array<Headers>;
|
||||||
|
method?:string;
|
||||||
|
authToken?:string;
|
||||||
maxFileSize?:number;
|
maxFileSize?:number;
|
||||||
queueLimit?:number;
|
queueLimit?:number;
|
||||||
removeAfterUpload?:boolean;
|
removeAfterUpload?:boolean;
|
||||||
url?:string;
|
url?:string;
|
||||||
|
disableMultipart?:boolean;
|
||||||
|
itemAlias?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FileUploader {
|
export class FileUploader {
|
||||||
|
|
||||||
public authToken:string;
|
public authToken:string;
|
||||||
public isUploading:boolean = false;
|
public isUploading:boolean = false;
|
||||||
public queue:Array<any> = [];
|
public queue:Array<FileItem> = [];
|
||||||
public progress:number = 0;
|
public progress:number = 0;
|
||||||
public _nextIndex:number = 0;
|
public _nextIndex:number = 0;
|
||||||
public autoUpload:any;
|
public autoUpload:any;
|
||||||
@@ -37,16 +45,17 @@ export class FileUploader {
|
|||||||
autoUpload: false,
|
autoUpload: false,
|
||||||
isHTML5: true,
|
isHTML5: true,
|
||||||
filters: [],
|
filters: [],
|
||||||
removeAfterUpload: false
|
removeAfterUpload: false,
|
||||||
|
disableMultipart: false
|
||||||
};
|
};
|
||||||
|
|
||||||
private _failFilterIndex:number;
|
private _failFilterIndex:number;
|
||||||
|
|
||||||
public constructor(options:any) {
|
public constructor(options:FileUploaderOptions) {
|
||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setOptions(options:any):void {
|
public setOptions(options:FileUploaderOptions):void {
|
||||||
this.options = Object.assign(this.options, options);
|
this.options = Object.assign(this.options, options);
|
||||||
|
|
||||||
this.authToken = options.authToken;
|
this.authToken = options.authToken;
|
||||||
@@ -68,15 +77,15 @@ export class FileUploader {
|
|||||||
// this.options.filters.unshift({name: 'folder', fn: this._folderFilter});
|
// this.options.filters.unshift({name: 'folder', fn: this._folderFilter});
|
||||||
}
|
}
|
||||||
|
|
||||||
public addToQueue(files:any[], options?:any, filters?:any):void {
|
public addToQueue(files:File[], options?:FileUploaderOptions, filters?:FilterFunction[]|string):void {
|
||||||
let list:any[] = [];
|
let list:File[] = [];
|
||||||
for (let file of files) {
|
for (let file of files) {
|
||||||
list.push(file);
|
list.push(file);
|
||||||
}
|
}
|
||||||
let arrayOfFilters = this._getFilters(filters);
|
let arrayOfFilters = this._getFilters(filters);
|
||||||
let count = this.queue.length;
|
let count = this.queue.length;
|
||||||
let addedFileItems:any[] = [];
|
let addedFileItems:FileItem[] = [];
|
||||||
list.map((some:any) => {
|
list.map((some:File) => {
|
||||||
if (!options) {
|
if (!options) {
|
||||||
options = this.options;
|
options = this.options;
|
||||||
}
|
}
|
||||||
@@ -102,7 +111,7 @@ export class FileUploader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeFromQueue(value:any):void {
|
public removeFromQueue(value:FileItem):void {
|
||||||
let index = this.getIndexOfItem(value);
|
let index = this.getIndexOfItem(value);
|
||||||
let item = this.queue[index];
|
let item = this.queue[index];
|
||||||
if (item.isUploading) {
|
if (item.isUploading) {
|
||||||
@@ -131,27 +140,27 @@ export class FileUploader {
|
|||||||
(this as any)[transport](item);
|
(this as any)[transport](item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public cancelItem(value:any):void {
|
public cancelItem(value:FileItem):void {
|
||||||
let index = this.getIndexOfItem(value);
|
let index = this.getIndexOfItem(value);
|
||||||
let item = this.queue[index];
|
let item = this.queue[index];
|
||||||
let prop = this.options.isHTML5 ? '_xhr' : '_form';
|
let prop = this.options.isHTML5 ? item._xhr : item._form;
|
||||||
if (item && item.isUploading) {
|
if (item && item.isUploading) {
|
||||||
item[prop].abort();
|
prop.abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public uploadAll():void {
|
public uploadAll():void {
|
||||||
let items = this.getNotUploadedItems().filter((item:any) => !item.isUploading);
|
let items = this.getNotUploadedItems().filter((item:FileItem) => !item.isUploading);
|
||||||
if (!items.length) {
|
if (!items.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
items.map((item:any) => item._prepareToUploading());
|
items.map((item:FileItem) => item._prepareToUploading());
|
||||||
items[0].upload();
|
items[0].upload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public cancelAll():void {
|
public cancelAll():void {
|
||||||
let items = this.getNotUploadedItems();
|
let items = this.getNotUploadedItems();
|
||||||
items.map((item:any) => item.cancel());
|
items.map((item:FileItem) => item.cancel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public isFile(value:any):boolean {
|
public isFile(value:any):boolean {
|
||||||
@@ -167,12 +176,12 @@ export class FileUploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getNotUploadedItems():Array<any> {
|
public getNotUploadedItems():Array<any> {
|
||||||
return this.queue.filter((item:any) => !item.isUploaded);
|
return this.queue.filter((item:FileItem) => !item.isUploaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getReadyItems():Array<any> {
|
public getReadyItems():Array<any> {
|
||||||
return this.queue
|
return this.queue
|
||||||
.filter((item:any) => (item.isReady && !item.isUploading))
|
.filter((item:FileItem) => (item.isReady && !item.isUploading))
|
||||||
.sort((item1:any, item2:any) => item1.index - item2.index);
|
.sort((item1:any, item2:any) => item1.index - item2.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,23 +198,23 @@ export class FileUploader {
|
|||||||
return {fileItems};
|
return {fileItems};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onBuildItemForm(fileItem:any, form:any):any {
|
public onBuildItemForm(fileItem:FileItem, form:any):any {
|
||||||
return {fileItem, form};
|
return {fileItem, form};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onAfterAddingFile(fileItem:any):any {
|
public onAfterAddingFile(fileItem:FileItem):any {
|
||||||
return {fileItem};
|
return {fileItem};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onWhenAddingFileFailed(item:any, filter:any, options:any):any {
|
public onWhenAddingFileFailed(item:FileLikeObject, filter:any, options:any):any {
|
||||||
return {item, filter, options};
|
return {item, filter, options};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onBeforeUploadItem(fileItem:any):any {
|
public onBeforeUploadItem(fileItem:FileItem):any {
|
||||||
return {fileItem};
|
return {fileItem};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onProgressItem(fileItem:any, progress:any):any {
|
public onProgressItem(fileItem:FileItem, progress:any):any {
|
||||||
return {fileItem, progress};
|
return {fileItem, progress};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,19 +222,19 @@ export class FileUploader {
|
|||||||
return {progress};
|
return {progress};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onSuccessItem(item:any, response:any, status:any, headers:any):any {
|
public onSuccessItem(item:FileItem, response:string, status:number, headers:ParsedResponseHeaders):any {
|
||||||
return {item, response, status, headers};
|
return {item, response, status, headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onErrorItem(item:any, response:any, status:any, headers:any):any {
|
public onErrorItem(item:FileItem, response:string, status:number, headers:ParsedResponseHeaders):any {
|
||||||
return {item, response, status, headers};
|
return {item, response, status, headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCancelItem(item:any, response:any, status:any, headers:any):any {
|
public onCancelItem(item:FileItem, response:string, status:number, headers:ParsedResponseHeaders):any {
|
||||||
return {item, response, status, headers};
|
return {item, response, status, headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCompleteItem(item:any, response:any, status:any, headers:any):any {
|
public onCompleteItem(item:FileItem, response:string, status:number, headers:ParsedResponseHeaders):any {
|
||||||
return {item, response, status, headers};
|
return {item, response, status, headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,25 +242,25 @@ export class FileUploader {
|
|||||||
return void 0;
|
return void 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public _mimeTypeFilter(item:any):boolean {
|
public _mimeTypeFilter(item:FileLikeObject):boolean {
|
||||||
return !(this.options.allowedMimeType && this.options.allowedMimeType.indexOf(item.type) === -1);
|
return !(this.options.allowedMimeType && this.options.allowedMimeType.indexOf(item.type) === -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _fileSizeFilter(item:any):boolean {
|
public _fileSizeFilter(item:FileLikeObject):boolean {
|
||||||
return !(this.options.maxFileSize && item.size > this.options.maxFileSize);
|
return !(this.options.maxFileSize && item.size > this.options.maxFileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _fileTypeFilter(item:any):boolean {
|
public _fileTypeFilter(item:FileLikeObject):boolean {
|
||||||
return !(this.options.allowedFileType &&
|
return !(this.options.allowedFileType &&
|
||||||
this.options.allowedFileType.indexOf(FileType.getMimeClass(item)) === -1);
|
this.options.allowedFileType.indexOf(FileType.getMimeClass(item)) === -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onErrorItem(item:any, response:any, status:any, headers:any):void {
|
public _onErrorItem(item:FileItem, response:string, status:number, headers:ParsedResponseHeaders):void {
|
||||||
item._onError(response, status, headers);
|
item._onError(response, status, headers);
|
||||||
this.onErrorItem(item, response, status, headers);
|
this.onErrorItem(item, response, status, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onCompleteItem(item:any, response:any, status:any, headers:any):void {
|
public _onCompleteItem(item:FileItem, response:string, status:number, headers:ParsedResponseHeaders):void {
|
||||||
item._onComplete(response, status, headers);
|
item._onComplete(response, status, headers);
|
||||||
this.onCompleteItem(item, response, status, headers);
|
this.onCompleteItem(item, response, status, headers);
|
||||||
let nextItem = this.getReadyItems()[0];
|
let nextItem = this.getReadyItems()[0];
|
||||||
@@ -265,8 +274,8 @@ export class FileUploader {
|
|||||||
this._render();
|
this._render();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _headersGetter(parsedHeaders:any):any {
|
protected _headersGetter(parsedHeaders:ParsedResponseHeaders):any {
|
||||||
return (name:any) => {
|
return (name:any):any => {
|
||||||
if (name) {
|
if (name) {
|
||||||
return parsedHeaders[name.toLowerCase()] || void 0;
|
return parsedHeaders[name.toLowerCase()] || void 0;
|
||||||
}
|
}
|
||||||
@@ -274,9 +283,9 @@ export class FileUploader {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _xhrTransport(item:any):any {
|
protected _xhrTransport(item:FileItem):any {
|
||||||
let xhr = item._xhr = new XMLHttpRequest();
|
let xhr = item._xhr = new XMLHttpRequest();
|
||||||
let form = new FormData();
|
let sendable:any;
|
||||||
this._onBeforeUploadItem(item);
|
this._onBeforeUploadItem(item);
|
||||||
// todo
|
// todo
|
||||||
/*item.formData.map(obj => {
|
/*item.formData.map(obj => {
|
||||||
@@ -287,9 +296,15 @@ export class FileUploader {
|
|||||||
if (typeof item._file.size !== 'number') {
|
if (typeof item._file.size !== 'number') {
|
||||||
throw new TypeError('The file specified is no longer valid');
|
throw new TypeError('The file specified is no longer valid');
|
||||||
}
|
}
|
||||||
this._onBuildItemForm(item, form);
|
if (!this.options.disableMultipart) {
|
||||||
|
sendable = new FormData();
|
||||||
|
this._onBuildItemForm(item, sendable);
|
||||||
|
|
||||||
|
sendable.append(item.alias, item._file, item.file.name);
|
||||||
|
} else {
|
||||||
|
sendable = item._file;
|
||||||
|
}
|
||||||
|
|
||||||
form.append(item.alias, item._file, item.file.name);
|
|
||||||
xhr.upload.onprogress = (event:any) => {
|
xhr.upload.onprogress = (event:any) => {
|
||||||
let progress = Math.round(event.lengthComputable ? event.loaded * 100 / event.total : 0);
|
let progress = Math.round(event.lengthComputable ? event.loaded * 100 / event.total : 0);
|
||||||
this._onProgressItem(item, progress);
|
this._onProgressItem(item, progress);
|
||||||
@@ -328,7 +343,7 @@ export class FileUploader {
|
|||||||
if (this.authToken) {
|
if (this.authToken) {
|
||||||
xhr.setRequestHeader('Authorization', this.authToken);
|
xhr.setRequestHeader('Authorization', this.authToken);
|
||||||
}
|
}
|
||||||
xhr.send(form);
|
xhr.send(sendable);
|
||||||
this._render();
|
this._render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +358,7 @@ export class FileUploader {
|
|||||||
return Math.round(uploaded * ratio + current);
|
return Math.round(uploaded * ratio + current);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getFilters(filters:any):any {
|
private _getFilters(filters:FilterFunction[]|string):FilterFunction[] {
|
||||||
if (!filters) {
|
if (!filters) {
|
||||||
return this.options.filters;
|
return this.options.filters;
|
||||||
}
|
}
|
||||||
@@ -363,7 +378,7 @@ export class FileUploader {
|
|||||||
// todo: ?
|
// todo: ?
|
||||||
}
|
}
|
||||||
|
|
||||||
// private _folderFilter(item:any):boolean {
|
// private _folderFilter(item:FileItem):boolean {
|
||||||
// return !!(item.size || item.type);
|
// return !!(item.size || item.type);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -371,20 +386,20 @@ export class FileUploader {
|
|||||||
return this.options.queueLimit === undefined || this.queue.length < this.options.queueLimit;
|
return this.options.queueLimit === undefined || this.queue.length < this.options.queueLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _isValidFile(file:any, filters:any, options:any):boolean {
|
private _isValidFile(file:FileLikeObject, filters:FilterFunction[], options:FileUploaderOptions):boolean {
|
||||||
this._failFilterIndex = -1;
|
this._failFilterIndex = -1;
|
||||||
return !filters.length ? true : filters.every((filter:any) => {
|
return !filters.length ? true : filters.every((filter:FilterFunction) => {
|
||||||
this._failFilterIndex++;
|
this._failFilterIndex++;
|
||||||
return filter.fn.call(this, file, options);
|
return filter.fn.call(this, file, options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _isSuccessCode(status:any):boolean {
|
private _isSuccessCode(status:number):boolean {
|
||||||
return (status >= 200 && status < 300) || status === 304;
|
return (status >= 200 && status < 300) || status === 304;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
private _transformResponse(response:any, headers:any):any {
|
private _transformResponse(response:string, headers:ParsedResponseHeaders):string {
|
||||||
// todo: ?
|
// todo: ?
|
||||||
/*var headersGetter = this._headersGetter(headers);
|
/*var headersGetter = this._headersGetter(headers);
|
||||||
forEach($http.defaults.transformResponse, (transformFn) => {
|
forEach($http.defaults.transformResponse, (transformFn) => {
|
||||||
@@ -394,7 +409,7 @@ export class FileUploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* tslint:enable */
|
/* tslint:enable */
|
||||||
private _parseHeaders(headers:any):any {
|
private _parseHeaders(headers:string):ParsedResponseHeaders {
|
||||||
let parsed:any = {};
|
let parsed:any = {};
|
||||||
let key:any;
|
let key:any;
|
||||||
let val:any;
|
let val:any;
|
||||||
@@ -413,15 +428,15 @@ export class FileUploader {
|
|||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private _iframeTransport(item:any) {
|
/*private _iframeTransport(item:FileItem) {
|
||||||
// todo: implement it later
|
// todo: implement it later
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
private _onWhenAddingFileFailed(item:any, filter:any, options:any):void {
|
private _onWhenAddingFileFailed(item:FileLikeObject, filter:any, options:any):void {
|
||||||
this.onWhenAddingFileFailed(item, filter, options);
|
this.onWhenAddingFileFailed(item, filter, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onAfterAddingFile(item:any):void {
|
private _onAfterAddingFile(item:FileItem):void {
|
||||||
this.onAfterAddingFile(item);
|
this.onAfterAddingFile(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,17 +444,17 @@ export class FileUploader {
|
|||||||
this.onAfterAddingAll(items);
|
this.onAfterAddingAll(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onBeforeUploadItem(item:any):void {
|
private _onBeforeUploadItem(item:FileItem):void {
|
||||||
item._onBeforeUpload();
|
item._onBeforeUpload();
|
||||||
this.onBeforeUploadItem(item);
|
this.onBeforeUploadItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onBuildItemForm(item:any, form:any):void {
|
private _onBuildItemForm(item:FileItem, form:any):void {
|
||||||
item._onBuildForm(form);
|
item._onBuildForm(form);
|
||||||
this.onBuildItemForm(item, form);
|
this.onBuildItemForm(item, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onProgressItem(item:any, progress:any):void {
|
private _onProgressItem(item:FileItem, progress:any):void {
|
||||||
let total = this._getTotalProgress(progress);
|
let total = this._getTotalProgress(progress);
|
||||||
this.progress = total;
|
this.progress = total;
|
||||||
item._onProgress(progress);
|
item._onProgress(progress);
|
||||||
@@ -449,13 +464,13 @@ export class FileUploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
private _onSuccessItem(item:any, response:any, status:any, headers:any):void {
|
private _onSuccessItem(item:FileItem, response:string, status:number, headers:ParsedResponseHeaders):void {
|
||||||
item._onSuccess(response, status, headers);
|
item._onSuccess(response, status, headers);
|
||||||
this.onSuccessItem(item, response, status, headers);
|
this.onSuccessItem(item, response, status, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tslint:enable */
|
/* tslint:enable */
|
||||||
private _onCancelItem(item:any, response:any, status:any, headers:any):void {
|
private _onCancelItem(item:FileItem, response:string, status:number, headers:ParsedResponseHeaders):void {
|
||||||
item._onCancel(response, status, headers);
|
item._onCancel(response, status, headers);
|
||||||
this.onCancelItem(item, response, status, headers);
|
this.onCancelItem(item, response, status, headers);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
### Usage
|
### Usage
|
||||||
```typescript
|
```typescript
|
||||||
import {FileSelectDirective, FileDropDirective, FileUploader} from 'ng2-file-upload/ng2-file-upload';
|
import { FileSelectDirective, FileDropDirective, FileUploader } from 'ng2-file-upload/ng2-file-upload';
|
||||||
```
|
```
|
||||||
|
|
||||||
### Annotations
|
### Annotations
|
||||||
@@ -20,10 +20,11 @@ import {FileSelectDirective, FileDropDirective, FileUploader} from 'ng2-file-upl
|
|||||||
|
|
||||||
- `uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)
|
- `uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)
|
||||||
|
|
||||||
Parameters that supported by this object:
|
Parameters supported by this object:
|
||||||
|
|
||||||
1. `url` - URL of File Uploader's route
|
1. `url` - URL of File Uploader's route
|
||||||
2. `authToken` - auth token that will be applied as 'Authorization' header during file send.
|
2. `authToken` - auth token that will be applied as 'Authorization' header during file send.
|
||||||
|
3. `disableMultipart` - If 'true', disable using a multipart form for file upload and instead stream the file. Some APIs (e.g. Amazon S3) may expect the file to be streamed rather than sent via a form. Defaults to false.
|
||||||
|
|
||||||
## FileDrop API
|
## FileDrop API
|
||||||
|
|
||||||
|
|||||||
34
demo/app.component.ts
Normal file
34
demo/app.component.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
let gettingStarted = require('./getting-started.md');
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app',
|
||||||
|
template: `
|
||||||
|
<main class="bd-pageheader">
|
||||||
|
<div class="container">
|
||||||
|
<h1>ng2-file-upload</h1>
|
||||||
|
<p>The Angular2 File Upload directives</p>
|
||||||
|
<a class="btn btn-primary" href="https://github.com/valor-software/ng2-file-upload">View on GitHub</a>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-1"><iframe src="https://ghbtns.com/github-btn.html?user=valor-software&repo=ng2-file-upload&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div>
|
||||||
|
<div class="col-lg-1"><iframe src="https://ghbtns.com/github-btn.html?user=valor-software&repo=ng2-file-upload&type=fork&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<section id="getting-started">${gettingStarted}</section>
|
||||||
|
|
||||||
|
<file-upload-section class="col-md-12"></file-upload-section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="footer">
|
||||||
|
<div class="container">
|
||||||
|
<p class="text-muted text-center"><a href="https://github.com/valor-software/ng2-file-upload">ng2-file-upload</a> is maintained by <a href="https://github.com/valor-software">valor-software</a>.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
export class DemoComponent {
|
||||||
|
}
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
import {Component} from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import {CORE_DIRECTIVES} from '@angular/common';
|
|
||||||
|
|
||||||
import {TAB_DIRECTIVES} from 'ng2-bootstrap/ng2-bootstrap';
|
|
||||||
import {SimpleDemoComponent} from './file-upload/simple-demo';
|
|
||||||
|
|
||||||
let name = 'File Upload';
|
|
||||||
let doc = require('../../components/file-upload/readme.md');
|
let doc = require('../../components/file-upload/readme.md');
|
||||||
|
|
||||||
let tabDesc:Array<any> = [
|
let tabDesc:Array<any> = [
|
||||||
@@ -16,13 +11,16 @@ let tabDesc:Array<any> = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
let tabsContent:string = ``;
|
@Component({
|
||||||
tabDesc.forEach((desc:any) => {
|
selector: 'file-upload-section',
|
||||||
tabsContent += `
|
template: `
|
||||||
<tab heading="${desc.heading}" (select)="select($event)">
|
<section [id]="name.toLowerCase()">
|
||||||
|
<div class="row">
|
||||||
|
<tabset>
|
||||||
|
<tab *ngFor="let desc of tabs" heading="{{desc.heading}}" (select)="select($event)">
|
||||||
<div class="card card-block panel panel-default panel-body">
|
<div class="card card-block panel panel-default panel-body">
|
||||||
|
|
||||||
<${desc.heading.toLowerCase()}-demo *ngIf="currentHeading === '${desc.heading}'"></${desc.heading.toLowerCase()}-demo>
|
<simple-demo></simple-demo>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@@ -30,48 +28,38 @@ tabDesc.forEach((desc:any) => {
|
|||||||
<tabset>
|
<tabset>
|
||||||
<tab heading="Markup">
|
<tab heading="Markup">
|
||||||
<div class="card card-block panel panel-default panel-body">
|
<div class="card card-block panel panel-default panel-body">
|
||||||
<pre class="language-html"><code class="language-html" ng-non-bindable>${desc.html}</code></pre>
|
<pre class="language-html"><code class="language-html" ng-non-bindable [innerHTML]="desc.html"></code></pre>
|
||||||
</div>
|
</div>
|
||||||
</tab>
|
</tab>
|
||||||
<tab heading="TypeScript">
|
<tab heading="TypeScript">
|
||||||
<div class="card card-block panel panel-default panel-body">
|
<div class="card card-block panel panel-default panel-body">
|
||||||
<pre class="language-typescript"><code class="language-typescript" ng-non-bindable>${desc.ts}</code></pre>
|
<pre class="language-typescript"><code class="language-typescript" ng-non-bindable [innerHTML]="desc.ts"></code></pre>
|
||||||
</div>
|
</div>
|
||||||
</tab>
|
</tab>
|
||||||
<tab heading="Backend Demo">
|
<tab heading="Backend Demo">
|
||||||
<div class="card card-block panel panel-default panel-body">
|
<div class="card card-block panel panel-default panel-body">
|
||||||
<pre class="language-javascript"><code class="language-javascript" ng-non-bindable>${desc.js}</code></pre>
|
<pre class="language-javascript"><code class="language-javascript" ng-non-bindable [innerHTML]="desc.js"></code></pre>
|
||||||
</div>
|
</div>
|
||||||
</tab>
|
</tab>
|
||||||
</tabset>
|
</tabset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</tab>
|
</tab>
|
||||||
`;
|
|
||||||
});
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'file-upload-section',
|
|
||||||
template: `
|
|
||||||
<section id="${name.toLowerCase()}">
|
|
||||||
<div class="row">
|
|
||||||
<tabset>
|
|
||||||
|
|
||||||
${tabsContent}
|
|
||||||
|
|
||||||
</tabset>
|
</tabset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h2>API</h2>
|
<h2>API</h2>
|
||||||
<div class="card card-block panel panel-default panel-body">${doc}</div>
|
<div class="card card-block panel panel-default panel-body" [innerHTML]="doc"></div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
`,
|
`
|
||||||
directives: [SimpleDemoComponent, TAB_DIRECTIVES, CORE_DIRECTIVES]
|
|
||||||
})
|
})
|
||||||
export class FileUploadSectionComponent {
|
export class FileUploadSectionComponent {
|
||||||
|
public name:string = 'File Upload';
|
||||||
public currentHeading:string = 'Simple';
|
public currentHeading:string = 'Simple';
|
||||||
|
public doc:string = doc;
|
||||||
|
public tabs:any = tabDesc;
|
||||||
|
|
||||||
public select(e:any):void {
|
public select(e:any):void {
|
||||||
if (e.heading) {
|
if (e.heading) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {Component} from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass, NgStyle} from '@angular/common';
|
import { FileUploader } from '../../../ng2-file-upload';
|
||||||
import {FILE_UPLOAD_DIRECTIVES, FileUploader} from '../../../ng2-file-upload';
|
|
||||||
|
|
||||||
// webpack html imports
|
// webpack html imports
|
||||||
let template = require('./simple-demo.html');
|
let template = require('./simple-demo.html');
|
||||||
@@ -10,8 +9,7 @@ const URL = 'https://evening-anchorage-3159.herokuapp.com/api/';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'simple-demo',
|
selector: 'simple-demo',
|
||||||
template: template,
|
template: template
|
||||||
directives: [FILE_UPLOAD_DIRECTIVES, NgClass, NgStyle, CORE_DIRECTIVES, FORM_DIRECTIVES]
|
|
||||||
})
|
})
|
||||||
export class SimpleDemoComponent {
|
export class SimpleDemoComponent {
|
||||||
public uploader:FileUploader = new FileUploader({url: URL});
|
public uploader:FileUploader = new FileUploader({url: URL});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Component, ElementRef, Renderer, Input, HostListener, HostBinding, OnInit} from '@angular/core';
|
import { Component, ElementRef, Renderer, Input, HostListener, HostBinding, OnInit } from '@angular/core';
|
||||||
import {FileUploader, FileUploaderOptions} from '../../../../ng2-file-upload';
|
import { FileUploader, FileUploaderOptions } from '../../../../ng2-file-upload';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'demo-file-upload',
|
selector: 'demo-file-upload',
|
||||||
|
|||||||
1
demo/custom-typings.d.ts
vendored
Normal file
1
demo/custom-typings.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
declare const ENV:string;
|
||||||
@@ -1,44 +1,4 @@
|
|||||||
import {bootstrap} from '@angular/platform-browser-dynamic';
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
import {Component} from '@angular/core';
|
import { NgFileUploadDemo } from './ng2-file-upload-demo.module';
|
||||||
import {NgClass} from '@angular/common';
|
|
||||||
|
|
||||||
import {FileUploadSectionComponent} from './components/file-upload-section';
|
platformBrowserDynamic().bootstrapModule(NgFileUploadDemo);
|
||||||
|
|
||||||
let gettingStarted = require('./getting-started.md');
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app',
|
|
||||||
template: `
|
|
||||||
<main class="bd-pageheader">
|
|
||||||
<div class="container">
|
|
||||||
<h1>ng2-file-upload</h1>
|
|
||||||
<p>The Angular2 File Upload directives</p>
|
|
||||||
<a class="btn btn-primary" href="https://github.com/valor-software/ng2-file-upload">View on GitHub</a>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-1"><iframe src="https://ghbtns.com/github-btn.html?user=valor-software&repo=ng2-file-upload&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div>
|
|
||||||
<div class="col-lg-1"><iframe src="https://ghbtns.com/github-btn.html?user=valor-software&repo=ng2-file-upload&type=fork&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<section id="getting-started">${gettingStarted}</section>
|
|
||||||
|
|
||||||
<file-upload-section class="col-md-12"></file-upload-section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<footer class="footer">
|
|
||||||
<div class="container">
|
|
||||||
<p class="text-muted text-center"><a href="https://github.com/valor-software/ng2-file-upload">ng2-file-upload</a> is maintained by <a href="https://github.com/valor-software">valor-software</a>.</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
`,
|
|
||||||
directives: [
|
|
||||||
NgClass,
|
|
||||||
FileUploadSectionComponent
|
|
||||||
]
|
|
||||||
})
|
|
||||||
export class DemoComponent {
|
|
||||||
}
|
|
||||||
|
|
||||||
bootstrap(DemoComponent);
|
|
||||||
|
|||||||
18
demo/ng2-file-upload-demo.module.ts
Normal file
18
demo/ng2-file-upload-demo.module.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
import { Ng2BootstrapModule } from 'ng2-bootstrap/ng2-bootstrap';
|
||||||
|
import { FileUploadModule } from '../components/file-upload/file-upload.module';
|
||||||
|
import { DemoComponent } from './app.component.ts';
|
||||||
|
import { FileUploadSectionComponent } from './components/file-upload-section';
|
||||||
|
import { SimpleDemoComponent } from './components/file-upload/simple-demo';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [BrowserModule, CommonModule, FileUploadModule, Ng2BootstrapModule, FormsModule],
|
||||||
|
declarations: [DemoComponent, FileUploadSectionComponent, SimpleDemoComponent],
|
||||||
|
bootstrap: [DemoComponent]
|
||||||
|
})
|
||||||
|
export class NgFileUploadDemo {
|
||||||
|
}
|
||||||
28
demo/polyfills.ts
Normal file
28
demo/polyfills.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// Polyfills
|
||||||
|
// (these modules are what are in 'angular2/bundles/angular2-polyfills' so don't use that here)
|
||||||
|
|
||||||
|
// import 'ie-shim'; // Internet Explorer
|
||||||
|
// import 'es6-shim';
|
||||||
|
// import 'es6-promise';
|
||||||
|
// import 'es7-reflect-metadata';
|
||||||
|
|
||||||
|
// Prefer CoreJS over the polyfills above
|
||||||
|
import 'core-js/es6';
|
||||||
|
import 'core-js/es7/reflect';
|
||||||
|
require('zone.js/dist/zone');
|
||||||
|
require('reflect-metadata');
|
||||||
|
|
||||||
|
// Typescript emit helpers polyfill
|
||||||
|
import 'ts-helpers';
|
||||||
|
|
||||||
|
if ('production' === ENV) {
|
||||||
|
// Production
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Development
|
||||||
|
|
||||||
|
(Error as any).stackTraceLimit = Infinity;
|
||||||
|
|
||||||
|
require('zone.js/dist/long-stack-trace-zone');
|
||||||
|
|
||||||
|
}
|
||||||
23
demo/vendor.ts
Normal file
23
demo/vendor.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// For vendors for example jQuery, Lodash, angular2-jwt just import them here unless you plan on
|
||||||
|
// chunking vendors files for async loading. You would need to import the async loaded vendors
|
||||||
|
// at the entry point of the async loaded file. Also see custom-typings.d.ts as you also need to
|
||||||
|
// run `typings install x` where `x` is your module
|
||||||
|
|
||||||
|
// Angular 2
|
||||||
|
import '@angular/common';
|
||||||
|
import '@angular/core';
|
||||||
|
import '@angular/forms';
|
||||||
|
import '@angular/platform-browser';
|
||||||
|
import '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
|
// RxJS
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
import 'rxjs/add/operator/mergeMap';
|
||||||
|
|
||||||
|
if ('production' === ENV) {
|
||||||
|
// Production
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Development
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,17 +2,20 @@
|
|||||||
|
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const tslint = require('gulp-tslint');
|
const tslint = require('gulp-tslint');
|
||||||
const paths = gulp.paths;
|
const gitignore = require('gitignore-to-glob')();
|
||||||
|
|
||||||
|
gitignore.push('**/*.ts');
|
||||||
|
|
||||||
gulp.task('tslint', () =>
|
gulp.task('tslint', () =>
|
||||||
gulp
|
gulp
|
||||||
.src(paths.tssrc)
|
.src(gitignore)
|
||||||
.pipe(tslint())
|
.pipe(tslint({
|
||||||
.pipe(tslint.report('prose', {
|
formatter: 'verbose',
|
||||||
emitError: true,
|
emitError: true,
|
||||||
summarizeFailureOutput: true,
|
summarizeFailureOutput: true,
|
||||||
reportLimit: 50
|
reportLimit: 50
|
||||||
}))
|
}))
|
||||||
|
.pipe(tslint.report())
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task('lint', ['tslint']);
|
gulp.task('lint', ['tslint']);
|
||||||
|
|||||||
@@ -2,15 +2,6 @@
|
|||||||
|
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
|
|
||||||
gulp.paths = {
|
|
||||||
tssrc: [
|
|
||||||
'**/*.ts',
|
|
||||||
'!**/*.d.ts',
|
|
||||||
'!node_modules/**/*',
|
|
||||||
'!bundles/**/*',
|
|
||||||
'!typings/**/*']
|
|
||||||
};
|
|
||||||
|
|
||||||
require('require-dir')('./gulp-tasks');
|
require('require-dir')('./gulp-tasks');
|
||||||
|
|
||||||
gulp.task('default', () => {
|
gulp.task('default', () => {
|
||||||
|
|||||||
100
karma.conf.js
100
karma.conf.js
@@ -1,101 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
const config = require('./.ng2-config');
|
||||||
const cwd = process.cwd();
|
|
||||||
|
|
||||||
module.exports = config => {
|
module.exports = require('ng2-webpack-config').karma(config);
|
||||||
config.set({
|
|
||||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
|
||||||
basePath: '',
|
|
||||||
|
|
||||||
// frameworks to use
|
|
||||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
|
||||||
frameworks: ['jasmine'],
|
|
||||||
|
|
||||||
// list of files / patterns to load in the browser
|
|
||||||
files: [
|
|
||||||
{pattern: 'test.bundle.js', watched: false}
|
|
||||||
],
|
|
||||||
|
|
||||||
// list of files to exclude
|
|
||||||
exclude: [],
|
|
||||||
|
|
||||||
// preprocess matching files before serving them to the browser
|
|
||||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
|
||||||
preprocessors: {
|
|
||||||
'test.bundle.js': ['coverage', 'webpack', 'sourcemap']
|
|
||||||
},
|
|
||||||
|
|
||||||
webpack: {
|
|
||||||
resolve: {
|
|
||||||
root: [path.resolve(cwd)],
|
|
||||||
modulesDirectories: ['node_modules', 'demo', 'components', 'test', '.'],
|
|
||||||
extensions: ['', '.ts', '.js', '.css']
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
loaders: [
|
|
||||||
{test: /\.ts$/, loader: 'ts-loader', exclude: [/node_modules/]}
|
|
||||||
],
|
|
||||||
postLoaders: [
|
|
||||||
// instrument only testing sources with Istanbul
|
|
||||||
{
|
|
||||||
test: /\.(js|ts)$/,
|
|
||||||
include: root('components'),
|
|
||||||
loader: 'istanbul-instrumenter-loader',
|
|
||||||
exclude: [
|
|
||||||
/\.e2e\.ts$/,
|
|
||||||
/node_modules/
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
stats: {
|
|
||||||
colors: true,
|
|
||||||
reasons: true
|
|
||||||
},
|
|
||||||
watch: true,
|
|
||||||
debug: true
|
|
||||||
},
|
|
||||||
|
|
||||||
coverageReporter: {
|
|
||||||
dir: 'coverage/',
|
|
||||||
reporters: [
|
|
||||||
{type: 'text'},
|
|
||||||
{type: 'json'},
|
|
||||||
{type: 'html'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
webpackServer: {noInfo: true},
|
|
||||||
|
|
||||||
// test results reporter to use
|
|
||||||
// possible values: 'dots', 'progress'
|
|
||||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
||||||
reporters: ['spec', 'coverage'],
|
|
||||||
|
|
||||||
// web server port
|
|
||||||
port: 9876,
|
|
||||||
|
|
||||||
// enable / disable colors in the output (reporters and logs)
|
|
||||||
colors: true,
|
|
||||||
|
|
||||||
// level of logging
|
|
||||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR ||
|
|
||||||
// config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
||||||
logLevel: config.LOG_INFO,
|
|
||||||
|
|
||||||
// enable / disable watching file and executing tests whenever any file changes
|
|
||||||
autoWatch: false,
|
|
||||||
|
|
||||||
// start these browsers
|
|
||||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
|
||||||
browsers: ['PhantomJS'],
|
|
||||||
|
|
||||||
// Continuous Integration mode
|
|
||||||
// if true, Karma captures browsers, runs the tests and exits
|
|
||||||
singleRun: true
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function root(partialPath) {
|
|
||||||
return path.join(__dirname, partialPath);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,13 +2,4 @@ export * from './components/file-upload/file-select.directive';
|
|||||||
export * from './components/file-upload/file-drop.directive';
|
export * from './components/file-upload/file-drop.directive';
|
||||||
export * from './components/file-upload/file-uploader.class';
|
export * from './components/file-upload/file-uploader.class';
|
||||||
|
|
||||||
import {FileSelectDirective} from './components/file-upload/file-select.directive';
|
export { FileUploadModule } from './components/file-upload/file-upload.module';
|
||||||
import {FileDropDirective} from './components/file-upload/file-drop.directive';
|
|
||||||
|
|
||||||
export const FILE_UPLOAD_DIRECTIVES:[any] = [FileSelectDirective, FileDropDirective];
|
|
||||||
|
|
||||||
export default {
|
|
||||||
directives: [
|
|
||||||
FILE_UPLOAD_DIRECTIVES
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|||||||
111
package.json
111
package.json
@@ -1,21 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "ng2-file-upload",
|
"name": "ng2-file-upload",
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"description": "angular2 file upload directives",
|
"description": "angular2 file upload directives",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"flow.install:typings": "./node_modules/.bin/typings install",
|
"flow.compile": "npm run flow.compile:common && npm run flow.compile:system",
|
||||||
"flow.compile": "npm run flow.install:typings && npm run flow.compile:common && npm run flow.compile:system ",
|
"flow.compile:common": "./node_modules/.bin/tsc -p tsconfig.publish.json",
|
||||||
"flow.compile:common": "./node_modules/.bin/tsc",
|
|
||||||
"flow.compile:system": "./.config/bundle-system.js",
|
"flow.compile:system": "./.config/bundle-system.js",
|
||||||
"flow.copy:src": "./node_modules/.bin/cpy ng2-file-upload.ts \"components/*.ts\" ts --parents",
|
"flow.copy:src": "./node_modules/.bin/cpy ng2-file-upload.ts \"components/*.ts\" ts --parents",
|
||||||
"flow.clean": "./node_modules/.bin/del bundles coverage demo-build typings \"components/**/*.+(js|d.ts|js.map)\" dist \"ng2-file-upload.+(js|d.ts|js.map)\"",
|
"flow.clean": "./node_modules/.bin/del bundles coverage demo-build \"components/**/*.+(js|d.ts|js.map)\" dist \"ng2-file-upload.+(js|d.ts|js.map)\"",
|
||||||
"flow.deploy:gh-pages": "npm run flow.build:prod && ./node_modules/.bin/gh-pages -d demo-build",
|
"flow.deploy:gh-pages": "npm run flow.build:prod && ./node_modules/.bin/gh-pages -d demo-build",
|
||||||
"flow.eslint": "./node_modules/.bin/eslint --ignore-path .gitignore --ext js --fix . .config",
|
"flow.eslint": "./node_modules/.bin/eslint --ignore-path .gitignore --ext js --fix . .config",
|
||||||
"flow.tslint": "./node_modules/.bin/gulp lint",
|
"flow.tslint": "./node_modules/.bin/gulp lint",
|
||||||
"flow.lint": "npm run flow.eslint && npm run flow.tslint",
|
"flow.lint": "npm run flow.eslint && npm run flow.tslint",
|
||||||
"flow.changelog": "./node_modules/.bin/conventional-changelog -i CHANGELOG.md -s -p angular -v",
|
"flow.changelog": "./node_modules/.bin/conventional-changelog -i CHANGELOG.md -s -p angular -v",
|
||||||
"flow.github-release": "./node_modules/.bin/conventional-github-releaser -p angular",
|
"flow.github-release": "./node_modules/.bin/conventional-github-releaser -p angular",
|
||||||
"flow.build:prod": "NODE_ENV=production ./node_modules/.bin/webpack --progress --color",
|
"flow.build:prod": "NODE_ENV=production ./node_modules/.bin/webpack --progress --color --display-error-details --display-cached",
|
||||||
"flow.build:dev": "./node_modules/.bin/webpack --progress --color",
|
"flow.build:dev": "./node_modules/.bin/webpack --progress --color",
|
||||||
"flow.serve:dev": "./node_modules/.bin/webpack-dev-server --hot --inline --colors --display-error-details --display-cached",
|
"flow.serve:dev": "./node_modules/.bin/webpack-dev-server --hot --inline --colors --display-error-details --display-cached",
|
||||||
"flow.serve:prod": "NODE_ENV=production ./node_modules/.bin/webpack-dev-server --hot --inline --colors --display-error-details --display-cached",
|
"flow.serve:prod": "NODE_ENV=production ./node_modules/.bin/webpack-dev-server --hot --inline --colors --display-error-details --display-cached",
|
||||||
@@ -24,9 +23,10 @@
|
|||||||
"start": "npm run flow.serve:dev",
|
"start": "npm run flow.serve:dev",
|
||||||
"pretest": "npm run flow.lint",
|
"pretest": "npm run flow.lint",
|
||||||
"test": "NODE_ENV=test ./node_modules/.bin/karma start",
|
"test": "NODE_ENV=test ./node_modules/.bin/karma start",
|
||||||
|
"test:watch": "NODE_ENV=test ./node_modules/.bin/karma start --auto-watch --no-single-run",
|
||||||
"preversion": "npm test",
|
"preversion": "npm test",
|
||||||
"version": "npm run flow.changelog && git add -A",
|
"version": "npm run flow.changelog && git add -A",
|
||||||
"postversion": "git push origin master && git push --tags"
|
"postversion": "git push origin development && git push --tags"
|
||||||
},
|
},
|
||||||
"main": "ng2-file-upload.js",
|
"main": "ng2-file-upload.js",
|
||||||
"typings": "ng2-file-upload.d.ts",
|
"typings": "ng2-file-upload.d.ts",
|
||||||
@@ -34,7 +34,9 @@
|
|||||||
"angular2",
|
"angular2",
|
||||||
"bootstrap",
|
"bootstrap",
|
||||||
"angularjs",
|
"angularjs",
|
||||||
"twitter-bootstrap"
|
"twitter-bootstrap",
|
||||||
|
"file-upload",
|
||||||
|
"angular-file-upload"
|
||||||
],
|
],
|
||||||
"author": "Vyacheslav Chub <vyacheslav.chub@valor-software.com>",
|
"author": "Vyacheslav Chub <vyacheslav.chub@valor-software.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -48,68 +50,51 @@
|
|||||||
"homepage": "https://github.com/valor-software/ng2-file-upload#readme",
|
"homepage": "https://github.com/valor-software/ng2-file-upload#readme",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/common": "^2.0.0-rc.1",
|
"@angular/common": "2.0.0",
|
||||||
"@angular/core": "^2.0.0-rc.1"
|
"@angular/compiler": "2.0.0",
|
||||||
|
"@angular/core": "2.0.0",
|
||||||
|
"@angular/forms": "2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular/common": "^2.0.0-rc.1",
|
"@angular/common": "2.0.0",
|
||||||
"@angular/compiler": "^2.0.0-rc.1",
|
"@angular/compiler": "2.0.0",
|
||||||
"@angular/core": "^2.0.0-rc.1",
|
"@angular/core": "2.0.0",
|
||||||
"@angular/platform-browser": "^2.0.0-rc.1",
|
"@angular/forms": "2.0.0",
|
||||||
"@angular/platform-browser-dynamic": "^2.0.0-rc.1",
|
"@angular/platform-browser": "2.0.0",
|
||||||
"async": "1.5.2",
|
"@angular/platform-browser-dynamic": "2.0.0",
|
||||||
"bootstrap": "3.3.6",
|
"@types/jasmine": "2.2.34",
|
||||||
|
"@types/node": "6.0.39",
|
||||||
|
"@types/webpack": "1.12.34",
|
||||||
|
"async": "2.0.1",
|
||||||
|
"bootstrap": "3.3.7",
|
||||||
"codecov": "1.0.1",
|
"codecov": "1.0.1",
|
||||||
"compression-webpack-plugin": "0.3.1",
|
|
||||||
"conventional-changelog-cli": "1.2.0",
|
"conventional-changelog-cli": "1.2.0",
|
||||||
"conventional-github-releaser": "1.1.2",
|
"conventional-github-releaser": "1.1.3",
|
||||||
"copy-webpack-plugin": "2.1.3",
|
"cpy-cli": "1.0.1",
|
||||||
"cpy-cli": "1.0.0",
|
|
||||||
"del-cli": "0.2.0",
|
"del-cli": "0.2.0",
|
||||||
"es6-promise": "3.1.2",
|
"es6-promise": "3.3.1",
|
||||||
"es6-shim": "0.35.0",
|
"es6-shim": "0.35.1",
|
||||||
"es7-reflect-metadata": "1.6.0",
|
"es7-reflect-metadata": "1.6.0",
|
||||||
"eslint-config-valorsoft": "0.0.11",
|
"eslint-config-valorsoft": "0.1.0",
|
||||||
"exports-loader": "0.6.3",
|
|
||||||
"file-loader": "0.8.5",
|
|
||||||
"gh-pages": "0.11.0",
|
"gh-pages": "0.11.0",
|
||||||
|
"gitignore-to-glob": "0.2.1",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
"gulp-size": "2.1.0",
|
"gulp-size": "2.1.0",
|
||||||
"gulp-tslint": "5.0.0",
|
"gulp-tslint": "6.1.1",
|
||||||
"html-loader": "0.4.3",
|
"lite-server": "2.2.2",
|
||||||
"html-webpack-plugin": "2.16.1",
|
"marked": "0.3.6",
|
||||||
"istanbul-instrumenter-loader": "0.2.0",
|
"ng2-bootstrap": "1.1.5",
|
||||||
"jasmine": "2.4.1",
|
"ng2-webpack-config": "0.0.5",
|
||||||
"karma": "0.13.22",
|
|
||||||
"karma-chrome-launcher": "1.0.1",
|
|
||||||
"karma-coverage": "1.0.0",
|
|
||||||
"karma-jasmine": "1.0.2",
|
|
||||||
"karma-phantomjs-launcher": "1.0.0",
|
|
||||||
"karma-sourcemap-loader": "0.3.7",
|
|
||||||
"karma-spec-reporter": "0.0.26",
|
|
||||||
"karma-webpack": "1.7.0",
|
|
||||||
"lite-server": "2.2.0",
|
|
||||||
"markdown-loader": "0.1.7",
|
|
||||||
"marked": "0.3.5",
|
|
||||||
"ng2-bootstrap": "1.0.16",
|
|
||||||
"phantomjs-polyfill": "0.0.2",
|
|
||||||
"phantomjs-prebuilt": "2.1.7",
|
|
||||||
"pre-commit": "1.1.3",
|
"pre-commit": "1.1.3",
|
||||||
"prismjs": "1.4.1",
|
"prismjs": "1.5.1",
|
||||||
"prismjs-loader": "0.0.3",
|
"prismjs-loader": "0.0.3",
|
||||||
"raw-loader": "0.5.1",
|
"reflect-metadata": "0.1.8",
|
||||||
"reflect-metadata": "0.1.2",
|
|
||||||
"require-dir": "0.3.0",
|
"require-dir": "0.3.0",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.12",
|
||||||
"source-map-loader": "0.1.5",
|
"systemjs-builder": "0.15.31",
|
||||||
"systemjs-builder": "0.15.16",
|
"tslint-config-valorsoft": "1.1.1",
|
||||||
"ts-loader": "0.8.2",
|
"typescript": "2.0.2",
|
||||||
"tslint-config-valorsoft": "1.0.3",
|
"zone.js": "0.6.25"
|
||||||
"typescript": "1.8.10",
|
|
||||||
"typings": "0.8.1",
|
|
||||||
"webpack": "1.13.0",
|
|
||||||
"webpack-dev-server": "1.14.1",
|
|
||||||
"zone.js": "0.6.12"
|
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
@@ -121,6 +106,16 @@
|
|||||||
"name": "Dmitriy Shekhovtsov",
|
"name": "Dmitriy Shekhovtsov",
|
||||||
"email": "valorkin@gmail.com",
|
"email": "valorkin@gmail.com",
|
||||||
"url": "https://github.com/valorkin"
|
"url": "https://github.com/valorkin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Adrian Faciu",
|
||||||
|
"email": "adrian.faciu@gmail.com",
|
||||||
|
"url": "https://github.com/adrianfaciu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Oleksandr Telnov",
|
||||||
|
"email": "otelnov@gmail.com",
|
||||||
|
"url": "https://github.com/otelnov"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
5
protractor.conf.js
Normal file
5
protractor.conf.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const config = require('./.ng2-config');
|
||||||
|
|
||||||
|
module.exports.config = require('ng2-webpack-config').protractor(config);
|
||||||
65
spec-bundle.js
Normal file
65
spec-bundle.js
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/* eslint no-var: 0, vars-on-top: 0 */
|
||||||
|
/**
|
||||||
|
* @author: @AngularClass
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When testing with webpack and ES6, we have to do some extra
|
||||||
|
* things to get testing to work right. Because we are gonna write tests
|
||||||
|
* in ES6 too, we have to compile those as well. That's handled in
|
||||||
|
* karma.conf.js with the karma-webpack plugin. This is the entry
|
||||||
|
* file for webpack test. Just like webpack will create a bundle.js
|
||||||
|
* file for our client, when we run test, it will compile and bundle them
|
||||||
|
* all here! Crazy huh. So we need to do some setup
|
||||||
|
*/
|
||||||
|
'use strict';
|
||||||
|
Error.stackTraceLimit = Infinity;
|
||||||
|
|
||||||
|
require('core-js');
|
||||||
|
|
||||||
|
// Typescript emit helpers polyfill
|
||||||
|
require('ts-helpers');
|
||||||
|
|
||||||
|
require('zone.js/dist/zone');
|
||||||
|
require('zone.js/dist/long-stack-trace-zone');
|
||||||
|
require('zone.js/dist/async-test');
|
||||||
|
require('zone.js/dist/fake-async-test');
|
||||||
|
require('zone.js/dist/sync-test');
|
||||||
|
require('zone.js/dist/proxy');
|
||||||
|
require('zone.js/dist/jasmine-patch');
|
||||||
|
|
||||||
|
// RxJS
|
||||||
|
require('rxjs/Rx');
|
||||||
|
|
||||||
|
var testing = require('@angular/core/testing');
|
||||||
|
var browser = require('@angular/platform-browser-dynamic/testing');
|
||||||
|
|
||||||
|
testing.TestBed.initTestEnvironment(
|
||||||
|
browser.BrowserDynamicTestingModule,
|
||||||
|
browser.platformBrowserDynamicTesting()
|
||||||
|
);
|
||||||
|
|
||||||
|
Object.assign(global, testing);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ok, this is kinda crazy. We can use the the context method on
|
||||||
|
* require that webpack created in order to tell webpack
|
||||||
|
* what files we actually want to require or import.
|
||||||
|
* Below, context will be an function/object with file names as keys.
|
||||||
|
* using that regex we are saying look in ./src/app and ./test then find
|
||||||
|
* any file that ends with spec.js and get its path. By passing in true
|
||||||
|
* we say do this recursively
|
||||||
|
*/
|
||||||
|
var testContext = require.context('./components', true, /\.spec\.ts/);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get all the files, for each file, call the context function
|
||||||
|
* that will require the file and load it up here. Context will
|
||||||
|
* loop and require those spec files here
|
||||||
|
*/
|
||||||
|
function requireAll(requireContext) {
|
||||||
|
return requireContext.keys().map(requireContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
// requires and returns all modules that match
|
||||||
|
requireAll(testContext);
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
/* eslint vars-on-top:0 no-var:0 */
|
|
||||||
// @AngularClass
|
|
||||||
/*
|
|
||||||
* When testing with webpack and ES6, we have to do some extra
|
|
||||||
* things get testing to work right. Because we are gonna write test
|
|
||||||
* in ES6 to, we have to compile those as well. That's handled in
|
|
||||||
* karma.conf.js with the karma-webpack plugin. This is the entry
|
|
||||||
* file for webpack test. Just like webpack will create a bundle.js
|
|
||||||
* file for our client, when we run test, it well compile and bundle them
|
|
||||||
* all here! Crazy huh. So we need to do some setup
|
|
||||||
*/
|
|
||||||
Error.stackTraceLimit = Infinity;
|
|
||||||
require('phantomjs-polyfill');
|
|
||||||
require('es6-promise');
|
|
||||||
require('es6-shim');
|
|
||||||
require('es7-reflect-metadata/dist/browser');
|
|
||||||
|
|
||||||
// require('zone.js');
|
|
||||||
require('zone.js/dist/zone.js');
|
|
||||||
require('zone.js/dist/long-stack-trace-zone.js');
|
|
||||||
require('zone.js/dist/jasmine-patch.js');
|
|
||||||
require('zone.js/dist/async-test.js');
|
|
||||||
|
|
||||||
var testing = require('@angular/core/testing');
|
|
||||||
var browser = require('@angular/platform-browser-dynamic/testing');
|
|
||||||
|
|
||||||
testing.setBaseTestProviders(
|
|
||||||
browser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
|
||||||
browser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Ok, this is kinda crazy. We can use the the context method on
|
|
||||||
require that webpack created in order to tell webpack
|
|
||||||
what files we actually want to require or import.
|
|
||||||
Below, context will be an function/object with file names as keys.
|
|
||||||
using that regex we are saying look in ./src/app and ./test then find
|
|
||||||
any file that ends with spec.js and get its path. By passing in true
|
|
||||||
we say do this recursively
|
|
||||||
*/
|
|
||||||
var testContext = require.context('./components', true, /\.spec\.ts/);
|
|
||||||
|
|
||||||
// get all the files, for each file, call the context function
|
|
||||||
// that will require the file and load it up here. Context will
|
|
||||||
// loop and require those spec files here
|
|
||||||
testContext.keys().forEach(testContext);
|
|
||||||
@@ -2,21 +2,34 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"moduleResolution": "node",
|
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"removeComments": false,
|
"removeComments": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"noImplicitAny": true,
|
|
||||||
"listFiles": false,
|
"listFiles": false,
|
||||||
"noLib": false
|
"noLib": false,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"stripInternal": true,
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"es6"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"jasmine",
|
||||||
|
"node",
|
||||||
|
"webpack"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules",
|
||||||
|
"bundles",
|
||||||
|
"dist"
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"./typings/browser.d.ts",
|
"./ng2-file-upload.ts",
|
||||||
"./ng2-file-upload.ts"
|
"./demo/custom-typings.d.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
33
tsconfig.publish.json
Normal file
33
tsconfig.publish.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"sourceMap": false,
|
||||||
|
"noEmitHelpers": false,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"declaration": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"stripInternal": true,
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"es6"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"jasmine",
|
||||||
|
"node",
|
||||||
|
"webpack"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"bundles",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"./demo/custom-typings.d.ts",
|
||||||
|
"./ng2-file-upload.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
{
|
{
|
||||||
"extends": "tslint-config-valorsoft",
|
"extends": "tslint-config-valorsoft",
|
||||||
"rulesDirectory": "./node_modules/codelyzer"
|
"rulesDirectory": "./node_modules/codelyzer",
|
||||||
|
"rules": {
|
||||||
|
"component-selector-name": [false, ""],
|
||||||
|
"only-arrow-functions": false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
typings.json
12
typings.json
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"moment": "registry:npm/moment#2.10.5+20160211003958",
|
|
||||||
"webpack": "registry:npm/webpack#1.12.9+20160219013405"
|
|
||||||
},
|
|
||||||
"devDependencies": {},
|
|
||||||
"ambientDependencies": {
|
|
||||||
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
|
|
||||||
"jasmine": "registry:dt/jasmine#2.2.0+20160317120654",
|
|
||||||
"require": "registry:dt/require#2.1.20+20160316155526"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
/* eslint global-require: 0 */
|
/* eslint no-process-env: 0, global-require:0 */
|
||||||
|
/**
|
||||||
|
* @author: @AngularClass
|
||||||
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const marked = require('marked');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const reqPrism = require('prismjs');
|
const reqPrism = require('prismjs');
|
||||||
const CompressionPlugin = require('compression-webpack-plugin');
|
const marked = require('marked');
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
||||||
|
|
||||||
// marked renderer hack
|
|
||||||
marked.Renderer.prototype.code = function renderCode(code, lang) {
|
marked.Renderer.prototype.code = function renderCode(code, lang) {
|
||||||
const out = this.options.highlight(code, lang);
|
const out = this.options.highlight(code, lang);
|
||||||
const classMap = this.options.langPrefix + lang;
|
const classMap = this.options.langPrefix + lang;
|
||||||
@@ -20,159 +17,35 @@ marked.Renderer.prototype.code = function renderCode(code, lang) {
|
|||||||
return `<pre class="${classMap}"><code class="${classMap}">${out}\n</code></pre>\n`;
|
return `<pre class="${classMap}"><code class="${classMap}">${out}\n</code></pre>\n`;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*eslint no-process-env:0, camelcase:0*/
|
// Look in ./config folder for webpack.dev.js
|
||||||
const isProduction = (process.env.NODE_ENV || 'development') === 'production';
|
const conf = getWebpackConfig(process.env.NODE_ENV, require('./.ng2-config'));
|
||||||
const devtool = process.env.NODE_ENV === 'test' ? 'inline-source-map' : 'source-map';
|
|
||||||
const dest = 'demo-build';
|
|
||||||
const absDest = root(dest);
|
|
||||||
|
|
||||||
const config = {
|
conf.markdownLoader = {
|
||||||
// isProduction ? 'source-map' : 'evale',
|
langPrefix: 'language-',
|
||||||
devtool,
|
highlight(code, lang) {
|
||||||
debug: false,
|
const language = !lang || lang === 'html' ? 'markup' : lang;
|
||||||
|
const Prism = global.Prism || reqPrism;
|
||||||
|
|
||||||
verbose: true,
|
if (!Prism.languages[language]) {
|
||||||
displayErrorDetails: true,
|
require(`prismjs/components/prism-${language}.js`);
|
||||||
context: __dirname,
|
|
||||||
stats: {
|
|
||||||
colors: true,
|
|
||||||
reasons: true
|
|
||||||
},
|
|
||||||
|
|
||||||
resolve: {
|
|
||||||
cache: false,
|
|
||||||
root: __dirname,
|
|
||||||
extensions: ['', '.ts', '.js', '.json']
|
|
||||||
},
|
|
||||||
|
|
||||||
entry: {
|
|
||||||
angular2: [
|
|
||||||
// Angular 2 Deps
|
|
||||||
'es6-shim',
|
|
||||||
'es6-promise',
|
|
||||||
'zone.js',
|
|
||||||
'reflect-metadata',
|
|
||||||
'@angular/common',
|
|
||||||
'@angular/core'
|
|
||||||
],
|
|
||||||
'angular2-bootstrap': ['ng2-file-upload'],
|
|
||||||
'angular2-bootstrap-demo': 'demo'
|
|
||||||
},
|
|
||||||
|
|
||||||
output: {
|
|
||||||
path: absDest,
|
|
||||||
filename: '[name].js',
|
|
||||||
sourceMapFilename: '[name].js.map',
|
|
||||||
chunkFilename: '[id].chunk.js'
|
|
||||||
},
|
|
||||||
|
|
||||||
// our Development Server configs
|
|
||||||
devServer: {
|
|
||||||
inline: true,
|
|
||||||
colors: true,
|
|
||||||
historyApiFallback: true,
|
|
||||||
contentBase: dest,
|
|
||||||
//publicPath: dest,
|
|
||||||
outputPath: dest,
|
|
||||||
watchOptions: {aggregateTimeout: 300, poll: 1000}
|
|
||||||
},
|
|
||||||
|
|
||||||
markdownLoader: {
|
|
||||||
langPrefix: 'language-',
|
|
||||||
highlight(code, lang) {
|
|
||||||
const language = !lang || lang === 'html' ? 'markup' : lang;
|
|
||||||
const Prism = global.Prism || reqPrism;
|
|
||||||
|
|
||||||
if (!Prism.languages[language]) {
|
|
||||||
require(`prismjs/components/prism-${language}.js`);
|
|
||||||
}
|
|
||||||
return Prism.highlight(code, Prism.languages[language]);
|
|
||||||
}
|
}
|
||||||
},
|
return Prism.highlight(code, Prism.languages[language]);
|
||||||
module: {
|
|
||||||
loaders: [
|
|
||||||
// support markdown
|
|
||||||
{test: /\.md$/, loader: 'html?minimize=false!markdown'},
|
|
||||||
// Support for *.json files.
|
|
||||||
{test: /\.json$/, loader: 'json'},
|
|
||||||
// Support for CSS as raw text
|
|
||||||
{test: /\.css$/, loader: 'raw'},
|
|
||||||
// support for .html as raw text
|
|
||||||
{test: /\.html$/, loader: 'raw'},
|
|
||||||
// Support for .ts files.
|
|
||||||
{
|
|
||||||
test: /\.ts$/,
|
|
||||||
loader: 'ts',
|
|
||||||
query: {
|
|
||||||
compilerOptions: {
|
|
||||||
removeComments: true,
|
|
||||||
noEmitHelpers: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
exclude: [/\.(spec|e2e)\.ts$/]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
noParse: [
|
|
||||||
/rtts_assert\/src\/rtts_assert/,
|
|
||||||
/reflect-metadata/,
|
|
||||||
/zone\.js\/dist\/zone-microtask/
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
plugins: [
|
|
||||||
//new Clean([dest]),
|
|
||||||
new webpack.optimize.DedupePlugin(),
|
|
||||||
new webpack.optimize.OccurenceOrderPlugin(true),
|
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
|
||||||
name: 'angular2',
|
|
||||||
minChunks: Infinity,
|
|
||||||
filename: 'angular2.js'
|
|
||||||
}),
|
|
||||||
// static assets
|
|
||||||
new CopyWebpackPlugin([{from: 'demo/favicon.ico', to: 'favicon.ico'}]),
|
|
||||||
new CopyWebpackPlugin([{from: 'demo/assets', to: 'assets'}]),
|
|
||||||
// generating html
|
|
||||||
new HtmlWebpackPlugin({template: 'demo/index.html'})
|
|
||||||
],
|
|
||||||
pushPlugins() {
|
|
||||||
if (!isProduction) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const plugins = [
|
|
||||||
//production only
|
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
|
||||||
beautify: false,
|
|
||||||
mangle: false,
|
|
||||||
comments: false,
|
|
||||||
compress: {
|
|
||||||
screw_ie8: true
|
|
||||||
//warnings: false,
|
|
||||||
//drop_debugger: false
|
|
||||||
}
|
|
||||||
//verbose: true,
|
|
||||||
//beautify: false,
|
|
||||||
//quote_style: 3
|
|
||||||
}),
|
|
||||||
new CompressionPlugin({
|
|
||||||
asset: '{file}.gz',
|
|
||||||
algorithm: 'gzip',
|
|
||||||
regExp: /\.js$|\.html|\.css|.map$/,
|
|
||||||
threshold: 10240,
|
|
||||||
minRatio: 0.8
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
this
|
|
||||||
.plugins
|
|
||||||
.push
|
|
||||||
.apply(plugins);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
config.pushPlugins();
|
module.exports = conf;
|
||||||
|
|
||||||
module.exports = config;
|
function getWebpackConfig(env, config) {
|
||||||
|
switch (env) {
|
||||||
function root(partialPath) {
|
case 'prod':
|
||||||
return path.join(__dirname, partialPath);
|
case 'production':
|
||||||
|
return require('ng2-webpack-config').webpack.prod(config);
|
||||||
|
case 'test':
|
||||||
|
case 'testing':
|
||||||
|
return require('ng2-webpack-config').webpack.test(config);
|
||||||
|
case 'dev':
|
||||||
|
case 'development':
|
||||||
|
default:
|
||||||
|
return require('ng2-webpack-config').webpack.dev(config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user