diff --git a/samples/nodejs/.bowerrc b/samples/nodejs/.bowerrc new file mode 100644 index 0000000..9c9ea40 --- /dev/null +++ b/samples/nodejs/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "public/bower_components" +} \ No newline at end of file diff --git a/samples/nodejs/.gitignore b/samples/nodejs/.gitignore new file mode 100644 index 0000000..252b543 --- /dev/null +++ b/samples/nodejs/.gitignore @@ -0,0 +1,22 @@ +# phpstorm project files +.idea/* + +# netbeans project files +nbproject + +# zend studio for eclipse project files +.buildpath +.project +.settings + +# windows thumbnail cache +Thumbs.db + +# build +/build/* + +# node +/node_modules/* + +# bower +/public/bower_components/* \ No newline at end of file diff --git a/samples/nodejs/app.js b/samples/nodejs/app.js new file mode 100644 index 0000000..b0acf57 --- /dev/null +++ b/samples/nodejs/app.js @@ -0,0 +1,36 @@ +var express = require('express') + , app = express() + , bodyParser = require('body-parser') + , server = require('http').Server(app) + , multer = require('multer') + , storage = multer.diskStorage({ + destination: function (req, file, cb) { + cb(null, 'temp/') + }, + filename: function (req, file, cb) { + cb(null, req.body.flowIdentifier); + } + }) + , multerUpload = multer({ storage: storage }) + , uploadFile = multerUpload.single('file'); + +app.use(express.static(__dirname + '/public')); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded()); +app.use(function(req, res, next) { + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Methods', 'GET, POST'); + next(); +}); + +app.get('/', function(req, res) { + res.sendFile('index.html'); +}); + + app.post('/upload', uploadFile, function(req, res) { + res.status(200).send(); + }); + +server.listen(process.env.PORT || 3000, function(){ + console.log('running sample'); +}); \ No newline at end of file diff --git a/samples/nodejs/bower.json b/samples/nodejs/bower.json new file mode 100644 index 0000000..5ea0ca1 --- /dev/null +++ b/samples/nodejs/bower.json @@ -0,0 +1,21 @@ +{ + "name": "ng-flow-sample", + "version": "0.0.1", + "ignore": [ + "**/.*", + "test", + "samples", + "build", + "*.md", + "karma.conf.js", + "LICENSE", + "Gruntfile.js", + "package.json", + "bower.json" + ], + "dependencies": { + "angular": "~1", + "flow.js": "~2", + "ng-flow": "~2" + } +} diff --git a/samples/nodejs/package.json b/samples/nodejs/package.json new file mode 100644 index 0000000..99d534a --- /dev/null +++ b/samples/nodejs/package.json @@ -0,0 +1,15 @@ +{ + "name": "ng-flow-sample", + "author": "Emerson Jose ", + "description":"sample ng-flow with nodejs", + "version": "0.0.1", + "scripts": { + "start": "node app.js" + }, + "license": "MIT", + "dependencies": { + "body-parser": "~1.0.0", + "express": "~4.9.8", + "multer": "*" + } +} diff --git a/samples/nodejs/public/css/main.css b/samples/nodejs/public/css/main.css new file mode 100644 index 0000000..59366e3 --- /dev/null +++ b/samples/nodejs/public/css/main.css @@ -0,0 +1,50 @@ + +.drop { + padding: 15px; + border: 2px #f1f1f1 dashed; + border-radius: 5px; + line-height: 34px; +} +.drop.drag-over { + background: #5CB85C; + color: #fff +} +.transfer-box { + margin-bottom: 5px; +} +.transfer-box .progress { + margin-bottom: 0; +} + +.thumbnail { + line-height: 20px; + margin-bottom: 5px; + overflow: hidden; + word-break: normal; +} +.thumbnail img { + max-width: 200px; + max-height: 150px; +} + +.gallery-box { + width: 200px; + padding: 5px; + margin: 7px; + float: left; + min-height: 200px; + border: 1px solid #ddd; + overflow: hidden; +} +.gallery-box .progress { + margin-bottom: 0; +} +.gallery-box .thumbnail { + height: 188px; + width: 188px; +} +.gallery-box .title { + height: 22px; + overflow: hidden; + display: block; +} diff --git a/samples/nodejs/public/index.html b/samples/nodejs/public/index.html new file mode 100644 index 0000000..6fc1fc3 --- /dev/null +++ b/samples/nodejs/public/index.html @@ -0,0 +1,58 @@ + + + + + + ng-flow sample + + + + + + + + + + +
+

flow nodejs example

+ +
+
+
+
+
+ Upload file + Upload folder + OR + Drag And Drop your file here +
+
+
+ +
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/samples/nodejs/public/scripts/app.js b/samples/nodejs/public/scripts/app.js new file mode 100644 index 0000000..d9ab142 --- /dev/null +++ b/samples/nodejs/public/scripts/app.js @@ -0,0 +1,26 @@ +'use strict'; + +var app = angular.module('ng-flow-sample', ['flow']); + +app.config(['flowFactoryProvider', function (flowFactoryProvider) { + flowFactoryProvider.defaults = { + target: 'http://localhost:3000/upload', + permanentErrors: [404, 500, 501], + chunkRetryInterval: 5000, + simultaneousUploads: 4, + testChunks: false, + generateUniqueIdentifier: function(file) { + var getFileExt = function(fileName) { + var fileExt = fileName.split("."); + + if ( fileExt.length === 1 || ( fileExt[0] === "" && fileExt.length === 2 )) { + return ""; + } + + return fileExt.pop(); + }; + + return Date.now() + '.'+ getFileExt(file.name); + } + }; +}]); diff --git a/samples/nodejs/temp/flow.png b/samples/nodejs/temp/flow.png new file mode 100644 index 0000000..1b00d2a Binary files /dev/null and b/samples/nodejs/temp/flow.png differ