diff --git a/client/components/ProgressBar.js b/client/components/ProgressBar.js
index ee25037..bcad106 100644
--- a/client/components/ProgressBar.js
+++ b/client/components/ProgressBar.js
@@ -9,8 +9,11 @@ export default class ProgressBar extends React.Component {
render() {
const failed = this.props.value < 0;
+ const inProgress = this.props.value < 1 && this.props.value > 0;
const classes = classnames('progress-bar', {
- 'progress-bar-failed': failed
+ 'progress-bar-failed': failed,
+ 'progress-bar-in-progress': inProgress,
+ 'progress-bar-small': this.props.small
})
const formatted = formatProgress(this.props.value)
@@ -18,17 +21,23 @@ export default class ProgressBar extends React.Component {
return
+ : Done
}
}
}
ProgressBar.propTypes = {
- value: React.PropTypes.number.isRequired
+ value: React.PropTypes.number.isRequired,
+ small: React.PropTypes.boolean
+}
+
+ProgressBar.defaultProps = {
+ small: false
}
diff --git a/client/components/UploadPage.js b/client/components/UploadPage.js
index 0397435..0999192 100644
--- a/client/components/UploadPage.js
+++ b/client/components/UploadPage.js
@@ -1,5 +1,6 @@
import Spinner from './Spinner'
import DropZone from './DropZone'
+import ProgressBar from './ProgressBar'
import React from 'react'
import Tempalink from './Tempalink'
import UploadActions from '../actions/UploadActions'
@@ -59,17 +60,20 @@ export default class UploadPage extends React.Component {
case 'uploading':
+ var keys = Object.keys(this.state.peerProgress)
+ keys.reverse()
return
-
-
Send someone this link to download.
This link will work as long as this page is open.
+
+ {keys.length > 0 ?
People Downloading Your File
:
}
-
In Progress: {this.state.inProgress}
-
Completed: {this.state.completed}
+ { keys.map((key) => {
+ return
+ })}
diff --git a/client/stores/UploadStore.js b/client/stores/UploadStore.js
index ebf99fd..07f2198 100644
--- a/client/stores/UploadStore.js
+++ b/client/stores/UploadStore.js
@@ -12,9 +12,7 @@ export default alt.createStore(class UploadStore {
this.status = 'ready'
this.token = null
this.file = null
-
- this.inProgress = 0
- this.completed = 0
+ this.peerProgress = {}
}
onUploadFile(file) {
@@ -49,22 +47,24 @@ export default alt.createStore(class UploadStore {
let packet = this.file.getChunk(i)
conn.send(packet)
i++
+ this.peerProgress[peerID] = i/totalChunks
}
conn.on('open', () => {
- this.setState({ inProgress: this.inProgress + 1 })
sendNextChunk()
+ this.setState({ peerProgress: this.peerProgress })
})
conn.on('data', (data) => {
if (data === 'more') sendNextChunk()
+ this.setState({ peerProgress: this.peerProgress })
})
conn.on('close', () => {
- this.setState({
- inProgress: this.inProgress - 1,
- completed: this.completed + (i === totalChunks ? 1 : 0)
- })
+ if (this.peerProgress[peerID] < 1) {
+ this.peerProgress[peerID] = -1
+ }
+ this.setState({ peerProgress: this.peerProgress })
})
}
diff --git a/css/index.styl b/css/index.styl
index f05c192..4f68b2d 100644
--- a/css/index.styl
+++ b/css/index.styl
@@ -6,6 +6,7 @@ light-blue = #40C0CB
light-gray = #EEE
light-green = #AEE239
light-red = #E23430
+light-yellow = #FFE476
red = #C40D08
@keyframes rotate {
@@ -171,7 +172,7 @@ p {
.progress-bar {
height: 60px
overflow: hidden
- background: beige
+ background: green
.progress-bar-inner {
float: left
@@ -182,10 +183,9 @@ p {
}
.progress-bar-text {
- float: right
font: 14px/60px "Quicksand", sans-serif
color: white
- margin-right: 5px
+ text-align: center
text-transform: uppercase
}
@@ -194,9 +194,32 @@ p {
box-shadow: inset 0 1px 1px light-red, 0 1px 1px light-gray
.progress-bar-text {
- float: none
text-align: center
- margin-right: 0
+ }
+ }
+
+ &.progress-bar-in-progress {
+ background: beige
+ .progress-bar-inner {
+ background: #FFCC00
+ box-shadow: inset 0 1px 1px light-yellow
+ }
+
+ .progress-bar-text {
+ color: black
+ float: right
+ margin-right: 5px
+ }
+ }
+
+ &.progress-bar-small {
+ height: 30px
+ width: 50%
+ margin: 8px auto
+ border-radius: 5px
+
+ .progress-bar-text {
+ line-height: 30px
}
}
}