import React from 'react'; import Page from './page'; import formatBytes from './format-bytes' import {List, ListItem} from 'material-ui/List'; import Subheader from 'material-ui/Subheader'; import Divider from 'material-ui/Divider'; import {Tabs, Tab} from 'material-ui/Tabs'; import ActionInfo from 'material-ui/svg-icons/action/info'; import RaisedButton from 'material-ui/RaisedButton'; import FontIcon from 'material-ui/FontIcon'; import FileFolder from 'material-ui/svg-icons/file/folder'; import NoImage from './images/no-image-icon.png' var moment = require('moment'); let buildFilesTree = (filesList) => { let rootTree = { __sizeBT: 0 }; filesList.forEach((file) => { let pathTree = file.path.split('/'); let currentItem = rootTree; pathTree.forEach((pathItem) => { if(!(pathItem in currentItem)) { currentItem[pathItem] = { __sizeBT: 0 } } currentItem = currentItem[pathItem] currentItem.__sizeBT += file.size; }) rootTree.__sizeBT += file.size; }); return rootTree; } const treeToTorrentFiles = (tree) => { let arr = []; for(let file in tree) { if(file == '__sizeBT') continue; arr.push( 1 ? : null} />); } return arr; } const TorrentFiles = (props) => { let tree = buildFilesTree(props.torrent.filesList); return ( Content of the torrent: {treeToTorrentFiles(tree)} ); }; const TorrentInformation = (props) => { let torrent = props.torrent; return ( Information about torrent } backgroundColor={blue500} />} rightIcon={} primaryText="Torrent Name" secondaryText={{torrent.name}} /> } backgroundColor={yellow600} />} rightIcon={} primaryText="Torrent Size" secondaryText={formatBytes(torrent.size)} /> } backgroundColor={yellow600} />} rightIcon={} primaryText="Torrent contains files" secondaryText={torrent.files} onClick={() => { if(!props.parent) return props.parent.setState({ value: 'files' }) }} /> } backgroundColor={yellow600} />} rightIcon={} primaryText="Indexed/Added torrent date" secondaryText={moment(torrent.added).format('MMMM Do YYYY, h:mm:ss')} /> } backgroundColor={yellow600} />} rightIcon={} primaryText="Content type" secondaryText={torrent.contentType || 'unknown'} /> } backgroundColor={yellow600} />} rightIcon={} primaryText="Category" secondaryText={torrent.contentCategory || 'unknown'} /> ); } export default class TorrentPage extends Page { constructor(props) { super(props); this.state = { value: 'info', }; this.setTitle('Information about torrent'); } handleChange = (value) => { if(value == 'main') { window.router('/'); return; } this.setState({ value: value, }); }; componentDidMount() { window.torrentSocket.emit('torrent', this.props.hash, {files: true}, window.customLoader((data) => { if(data) { this.torrent = data this.setTitle('Download ' + this.torrent.name); this.forceUpdate(); } })); } render() { return (
{ this.torrent ?
} />
BTIH:
{this.torrent.hash}
{ this.torrent.seeders || this.torrent.leechers || this.torrent.completed ?
seeders: {this.torrent.seeders}
leechers: {this.torrent.leechers}
completed: {this.torrent.completed}
: null }
: null }
Donation to support project (bitcoin): 1Ega5zeCSMPgyDn6fEMMiuGoqNNpS53ipK
); } }