feat(downloading): download speed

This commit is contained in:
Alexey Kasyanchuk
2018-06-26 18:53:44 +03:00
parent ec861e1f0a
commit c321286d6c
2 changed files with 19 additions and 14 deletions

View File

@ -167,9 +167,9 @@ export default class Torrent extends Component {
super(props) super(props)
if(props.download) if(props.download)
{ {
const { progress, downloaded, speed } = props.download const { progress, downloaded, downloadSpeed } = props.download
this.state.downloadProgress = { this.state.downloadProgress = {
progress, downloaded, speed progress, downloaded, downloadSpeed
} }
} }
} }
@ -268,15 +268,6 @@ export default class Torrent extends Component {
formatBytes(torrent.size, 1) + ' (' + torrent.files + ' files)' formatBytes(torrent.size, 1) + ' (' + torrent.files + ' files)'
} }
</div> </div>
{
this.state.downloading
&&
<LinearProgress
style={{width: '44%', marginLeft: 20}}
mode="determinate"
value={this.state.downloadProgress && (this.state.downloadProgress.progress ? this.state.downloadProgress.progress : 0) * 100}
/>
}
</div> </div>
{ {
torrent.path && torrent.path.length > 0 torrent.path && torrent.path.length > 0
@ -311,6 +302,20 @@ export default class Torrent extends Component {
}} }}
/> />
<div className='row center pad0-5 fs0-85 text-nowrap' style={{color: torrentRating >= 50 ? '#00E676' : '#FF3D00', width: '190px'}}>{__('Torrent rating')}: {torrentRating}%</div> <div className='row center pad0-5 fs0-85 text-nowrap' style={{color: torrentRating >= 50 ? '#00E676' : '#FF3D00', width: '190px'}}>{__('Torrent rating')}: {torrentRating}%</div>
</div>
}
{
this.state.downloading
&&
<div className='row w100p inline text-nowrap' style={{maxWidth: 580}}>
<div style={{marginRight: 5, color: 'rgb(0, 188, 212)'}}>{__('downloading')}: </div>
<LinearProgress
style={{height: '5px', width: '44%', marginTop: 2}}
mode="determinate"
value={this.state.downloadProgress && (this.state.downloadProgress.progress ? this.state.downloadProgress.progress : 0) * 100}
/>
<div className='pad0-75' style={{marginLeft: 20}} style={{color: 'rgb(0, 188, 212)'}}>{this.state.downloadProgress && (this.state.downloadProgress.progress * 100).toFixed(1)}%</div>
<div style={{marginLeft: 5, color: 'rgb(0, 188, 212)'}}>{this.state.downloadProgress && formatBytes(this.state.downloadProgress.downloadSpeed || 0, 0)}/s</div>
</div> </div>
} }
</div> </div>

View File

@ -606,7 +606,7 @@ module.exports = async ({
send('downloadProgress', torrent.infoHash, { send('downloadProgress', torrent.infoHash, {
received: bytes, received: bytes,
downloaded: torrent.downloaded, downloaded: torrent.downloaded,
speed: torrent.downloadSpeed, downloadSpeed: torrent.downloadSpeed,
progress: torrent.progress, progress: torrent.progress,
timeRemaining: torrent.timeRemaining timeRemaining: torrent.timeRemaining
}) })
@ -648,7 +648,7 @@ module.exports = async ({
received: torrent.received, received: torrent.received,
downloaded: torrent.downloaded, downloaded: torrent.downloaded,
progress: torrent.progress, progress: torrent.progress,
speed: torrent.downloadSpeed downloadSpeed: torrent.downloadSpeed
}))) })))
}) })