├── .gitignore
├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── demo
├── .vscode
│ └── settings.json
├── package.json
├── src
│ ├── app
│ │ ├── app.html
│ │ ├── app.module.ts
│ │ ├── app.routes.ts
│ │ ├── app.ts
│ │ └── home
│ │ │ ├── home.css
│ │ │ ├── home.html
│ │ │ └── home.ts
│ ├── custom-typings.d.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.browser.ts
│ ├── polyfills.browser.ts
│ ├── test.module.ts
│ └── vendor.browser.ts
├── tsconfig.json
└── webpack.config.js
├── index.ts
├── package-lock.json
├── package.json
├── src
├── fancy-image-uploader.component.ts
├── fancy-image-uploader.module.ts
├── file-uploader.ts
├── interfaces.ts
├── template.ts
├── uploaded-file.ts
└── utils.ts
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 |
4 | # dependencies
5 | /node_modules
6 | /demo/node_modules
7 |
8 | # IDEs and editors
9 | /.idea
10 |
11 | # misc
12 | /connect.lock
13 | /coverage/*
14 | /libpeerconnection.log
15 | npm-debug.log
16 | testem.log
17 | /dist
18 |
19 | # e2e
20 | /e2e/*.js
21 | /e2e/*.map
22 |
23 | #System Files
24 | .DS_Store
25 | Thumbs.db
26 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | // The number of spaces a tab is equal to.
4 | "editor.tabSize": 2,
5 | // When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
6 | "editor.detectIndentation": false,
7 | "typescript.tsdk": "node_modules\\typescript\\lib"
8 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 ogix
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Fancy Image Uploader [](https://badge.fury.io/js/ng2-fancy-image-uploader) 
2 |
3 | Angular2 component that uploads selected or dropped image asynchronously with preview.
4 |
5 | ### Demo
6 | See demo here: [demo](https://ogix.github.io/fancy-image-uploader-demo)
7 |
8 | ### Install
9 | ```
10 | npm install ng2-fancy-image-uploader --save
11 | ```
12 | ### Usage
13 |
14 | Add image uploader module to your module's ```imports```
15 |
16 | ```js
17 | import { NgModule } from '@angular/core';
18 | import { BrowserModule } from '@angular/platform-browser';
19 | import { AppComponent } from './app';
20 |
21 | import { FancyImageUploaderModule } from 'ng2-fancy-image-uploader';
22 |
23 | @NgModule({
24 | imports: [BrowserModule, FancyImageUploaderModule],
25 | declarations: [AppComponent],
26 | bootstrap: [AppComponent]
27 | })
28 | export class AppModule {}
29 | ```
30 |
31 | Use it in your component
32 |
33 | ```js
34 | import { Component } from '@angular/core';
35 | import { FancyImageUploaderOptions, UploadedFile } from 'ng2-fancy-image-uploader';
36 |
37 | @Component({
38 | selector: 'example-app',
39 | template: ''
40 | })
41 | export class AppComponent {
42 | options: FancyImageUploaderOptions = {
43 | thumbnailHeight: 150,
44 | thumbnailWidth: 150,
45 | uploadUrl: 'http://some-server.com/upload',
46 | allowedImageTypes: ['image/png', 'image/jpeg'],
47 | maxImageSize: 3
48 | };
49 |
50 | onUpload(file: UploadedFile) {
51 | console.log(file.response);
52 | }
53 | }
54 |
55 | ```
56 |
57 | ### License
58 |
59 | [MIT](https://tldrlegal.com/license/mit-license) © [Olegas Gončarovas](https://github.com/ogix)
60 |
--------------------------------------------------------------------------------
/demo/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | // The number of spaces a tab is equal to.
4 | "editor.tabSize": 2,
5 | // When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
6 | "editor.detectIndentation": false,
7 | "typescript.tsdk": "node_modules\\typescript\\lib"
8 | }
--------------------------------------------------------------------------------
/demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ng2-fancy-image-uploader-demo",
3 | "version": "1.0.0",
4 | "description": "Demo project for ng2-fancy-image-uploader",
5 | "scripts": {
6 | "tsc": "tsc",
7 | "build": "webpack --colors --progress --display-error-details --display-cached",
8 | "watch": "npm run build -- --watch",
9 | "server": "webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 3000 --content-base src",
10 | "start": "npm run server"
11 | },
12 | "license": "MIT",
13 | "devDependencies": {
14 | "@types/core-js": "^0.9.32",
15 | "@types/node": "^6.0.38",
16 | "angular2-template-loader": "^0.5.0",
17 | "awesome-typescript-loader": "^2.2.3",
18 | "css-loader": "^0.23.1",
19 | "raw-loader": "^0.5.1",
20 | "to-string-loader": "^1.1.4",
21 | "typescript": "^2.0.2",
22 | "webpack": "2.1.0-beta.22",
23 | "webpack-dev-server": "^1.14.0",
24 | "webpack-merge": "^0.8.4"
25 | },
26 | "dependencies": {
27 | "@angular/common": "2.0.0-rc.6",
28 | "@angular/compiler": "2.0.0-rc.6",
29 | "@angular/core": "2.0.0-rc.6",
30 | "@angular/forms": "2.0.0-rc.6",
31 | "@angular/http": "2.0.0-rc.6",
32 | "@angular/platform-browser": "2.0.0-rc.6",
33 | "@angular/platform-browser-dynamic": "2.0.0-rc.6",
34 | "@angular/platform-server": "2.0.0-rc.6",
35 | "@angular/router": "3.0.0-rc.2",
36 | "core-js": "^2.4.0",
37 | "ie-shim": "^0.1.0",
38 | "ng2-fancy-image-uploader": "^1.0.2",
39 | "rxjs": "5.0.0-beta.11",
40 | "zone.js": "~0.6.17"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/demo/src/app/app.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demo/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import {NgModule} from '@angular/core'
2 | import {RouterModule} from "@angular/router";
3 | import {rootRouterConfig} from "./app.routes";
4 | import {AppComponent} from "./app";
5 | import {FormsModule} from "@angular/forms";
6 | import {BrowserModule} from "@angular/platform-browser";
7 | import {HttpModule} from "@angular/http";
8 | import {Home} from './home/home';
9 | import {LocationStrategy, HashLocationStrategy} from '@angular/common';
10 | import {FancyImageUploaderModule} from 'ng2-fancy-image-uploader';
11 |
12 | @NgModule({
13 | declarations: [AppComponent, Home],
14 | imports : [BrowserModule, FormsModule, HttpModule, FancyImageUploaderModule, RouterModule.forRoot(rootRouterConfig)],
15 | providers : [{provide: LocationStrategy, useClass: HashLocationStrategy}],
16 | bootstrap : [AppComponent]
17 | })
18 | export class AppModule {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/demo/src/app/app.routes.ts:
--------------------------------------------------------------------------------
1 | import {Routes} from '@angular/router';
2 | import {Home} from './home/home';
3 |
4 | export const rootRouterConfig: Routes = [
5 | {path: '', redirectTo: 'home', pathMatch: 'full'},
6 | {path: 'home', component: Home}
7 | ];
8 |
9 |
--------------------------------------------------------------------------------
/demo/src/app/app.ts:
--------------------------------------------------------------------------------
1 | import {Component} from '@angular/core';
2 |
3 | @Component({
4 | selector : 'app',
5 | templateUrl: './app.html',
6 | })
7 | export class AppComponent {
8 | }
9 |
--------------------------------------------------------------------------------
/demo/src/app/home/home.css:
--------------------------------------------------------------------------------
1 | .header-wrapper {
2 | padding-top: 30px;
3 | }
--------------------------------------------------------------------------------
/demo/src/app/home/home.html:
--------------------------------------------------------------------------------
1 |