Improve torrent display

This commit is contained in:
Drew DeVault 2017-08-23 08:52:08 -04:00
parent 6737b4f5b9
commit 1e1027aeb2
3 changed files with 23 additions and 8 deletions

View File

@ -25,6 +25,10 @@
} }
} }
&.pending {
background-image: linear-gradient(to right, darken($gray-lighter, 10), $gray-lighter);
}
&.seeding { &.seeding {
background-image: linear-gradient(to right, lighten($brand-info, 20), $brand-info); background-image: linear-gradient(to right, lighten($brand-info, 20), $brand-info);
} }
@ -34,7 +38,7 @@
} }
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: bottom; background-position: left bottom;
} }
.navbar { .navbar {

View File

@ -5,14 +5,13 @@ export default class Main extends Component {
render() { render() {
return ( return (
<div className="row"> <div className="row">
<div className="col-md-4">
<h3>Filter</h3>
<p>TODO</p>
</div>
<div className="col-md-8"> <div className="col-md-8">
<h3>Torrents</h3>
<TorrentTable /> <TorrentTable />
</div> </div>
<div className="col-md-4">
<h3>archlinux-2017.08.01-x86_64.iso</h3>
<p>TODO details</p>
</div>
</div> </div>
); );
} }

View File

@ -1,6 +1,18 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
function formatBitrate(bitrate) {
if (bitrate > 1000000000) {
return `${(bitrate / 1000000000).toFixed(2)} Gb/s`;
} else if (bitrate > 1000000) {
return `${(bitrate / 1000000).toFixed(2)} Mb/s`;
} else if (bitrate > 1000) {
return `${(bitrate / 1000).toFixed(2)} Kb/s`;
} else {
return `${bitrate} b/s`;
}
}
class TorrentTable extends Component { class TorrentTable extends Component {
render() { render() {
const { torrents } = this.props; const { torrents } = this.props;
@ -31,8 +43,8 @@ class TorrentTable extends Component {
{t.name} {t.name}
</a> </a>
</td> </td>
<td>{t.rate_up}</td> <td>{formatBitrate(t.rate_up)}</td>
<td>{t.rate_down}</td> <td>{formatBitrate(t.rate_down)}</td>
</tr> </tr>
)} )}
</tbody> </tbody>