diff --git a/client/source/sass/objects/_torrent-details-panel.scss b/client/source/sass/objects/_torrent-details-panel.scss new file mode 100644 index 00000000..1cc1c649 --- /dev/null +++ b/client/source/sass/objects/_torrent-details-panel.scss @@ -0,0 +1,51 @@ +.torrent-details { + background: $torrent-details--background; + box-shadow: -1px 0 0 $torrent-details--border; + height: 100%; + width: 40%; + overflow: auto; + padding: $spacing-unit; + position: absolute; + right: 0; + top: 0; + transform: translateX(0); + transition: transform 0.5s; + z-index: 2; + + &.torrent-details-enter { + transform: translateX(100%); + } + + &.torrent-details-enter-active { + transform: translateX(0); + } + + &.torrent-details-leave { + transform: translateX(100%); + } + + &__transfer-data { + + .transfer-data { + display: inline-block; + margin-right: 10px; + + &:last-child { + margin-right: 0; + } + } + + .icon { + height: 12px; + width: 12px; + } + } + + &__table { + width: 100%; + + thead { + text-align: left; + } + } +} diff --git a/client/source/scripts/components/torrent-list/TorrentDetails.js b/client/source/scripts/components/torrent-list/TorrentDetails.js new file mode 100644 index 00000000..269567be --- /dev/null +++ b/client/source/scripts/components/torrent-list/TorrentDetails.js @@ -0,0 +1,241 @@ +import _ from 'lodash'; +import classNames from 'classnames'; +import {connect} from 'react-redux'; +import React from 'react'; +import CSSTransitionGroup from 'react-addons-css-transition-group'; + +import format from '../../util/formatData'; +import Icon from '../icons/Icon'; +import clientSelector from '../../selectors/clientSelector'; + +const methodsToBind = [ + 'getSidePanel', + 'getEta', + 'getRatio' +]; + +class TorrentDetails extends React.Component { + + constructor() { + super(); + + this.state = { + selectedTorrentHash: null + }; + + methodsToBind.forEach((method) => { + this[method] = this[method].bind(this); + }); + } + + componentWillReceiveProps(nextProps) { + if (nextProps.visible === true) { + let nextHash = nextProps.selectedTorrents[0]; + if (this.state.selectedTorrentHash !== nextHash) { + this.setState({ + selectedTorrentHash: nextHash, + selectedTorrent: _.find(nextProps.torrents, torrent => { + return torrent.hash === nextHash; + }) + }); + } + } + } + + shouldComponentUpdate(nextProps) { + if (nextProps.visible === true || (nextProps.visible !== this.props.visible)) { + return true; + } else { + return false; + } + } + + getPeerList() { + let torrentDetails = this.props.torrentDetails[ + this.state.selectedTorrentHash + ]; + + let peerList = null; + let peerCount = 0; + + if (torrentDetails) { + peerList = torrentDetails.map(function(peer, index) { + let downloadRate = format.data(peer.downloadRate, '/s'); + let uploadRate = format.data(peer.uploadRate, '/s'); + return ( +
| Peers {peerCount} | +DL | +UL | +
|---|