From 8da8046e1024f51dd245e03fdd87f16ffa568efc Mon Sep 17 00:00:00 2001
From: Marston Ng
Date: Fri, 10 Jun 2016 22:13:11 +0800
Subject: [PATCH] Adopted changes in v0.3.0 to basic example
---
examples/basic/client.js | 78 +++++++++++++++++++++++--------------
examples/basic/package.json | 1 +
2 files changed, 49 insertions(+), 30 deletions(-)
diff --git a/examples/basic/client.js b/examples/basic/client.js
index 9252902..80a5a79 100644
--- a/examples/basic/client.js
+++ b/examples/basic/client.js
@@ -1,6 +1,7 @@
var React = require('react');
var ReactDOM = require('react-dom');
var FileUploader = require('../../lib');
+var _ = require('lodash');
var MyComponent = React.createClass({
getInitialState: function() {
@@ -30,7 +31,7 @@ var MyComponent = React.createClass({
//}
},
- onFileDrop: function(target, files) {
+ onFileDrop: function({ target }, files) {
let node = ReactDOM.findDOMNode(this.refs.uploadPanel);
if (target != node) {
return false;
@@ -51,6 +52,20 @@ var MyComponent = React.createClass({
this.closePanel();
},
+ onFileProgress: function(file) {
+ var files = this.state.files;
+
+ files.map(function(_file) {
+ if (_file.id === file.id) {
+ _file = file;
+ }
+ });
+
+ this.setState({
+ files: files
+ });
+},
+
onFileUpdate: function(file) {
var files = this.state.files;
@@ -106,36 +121,39 @@ var MyComponent = React.createClass({
}
-
+
Upload List
- {
- this.state.files.map(function(file, index) {
- return (
-
-
- { file.name }
- -
- { file.id }
- { file.type }
- { file.size / 1000 / 1000 } MB
- { file.progress }%
-
- {_this._getStatusString(file.status)}
-
- { file.error }
-
-
-
- )
- })
- }
-
+
+ {
+ this.state.files.map(function(file, index) {
+ return (
+
+
+ { file.name }
+ -
+ { file.id }
+ { file.type }
+ { file.size / 1000 / 1000 } MB
+ { file.progress }%
+
+ {_this._getStatusString(file.status)}
+
+ { file.error }
+
+
+
+ )
+ })
+ }
+
+
);
}
diff --git a/examples/basic/package.json b/examples/basic/package.json
index b5caea0..dbfed66 100644
--- a/examples/basic/package.json
+++ b/examples/basic/package.json
@@ -7,6 +7,7 @@
"connect-multiparty": "^2.0.0",
"express": "^4.13.3",
"forever": "^0.15.1",
+ "lodash": "^4.13.1",
"react": "^0.14.3",
"react-dom": "^0.14.3"
},