diff --git a/src/ui/add_torrent.js b/src/ui/add_torrent.js index f4c9610..f8928e1 100644 --- a/src/ui/add_torrent.js +++ b/src/ui/add_torrent.js @@ -18,7 +18,7 @@ import moment from 'moment'; import ToggleContainer from './toggle_container'; import TorrentOptions from './torrent_options'; import ws_send from '../socket'; -import date from '../date'; +import DateDisplay from './date'; class AddTorrent extends Component { constructor() { @@ -199,7 +199,7 @@ class AddTorrent extends Component { const details = { "comment": d => d, - "creation date": d => date(moment(new Date(d * 1000))), + "creation date": d => , "created by": d => d }; diff --git a/src/ui/date.js b/src/ui/date.js new file mode 100644 index 0000000..7f6a082 --- /dev/null +++ b/src/ui/date.js @@ -0,0 +1,16 @@ +import React, { Component } from 'react'; +import formatDate from '../date'; + +export default class DateDisplay extends Component { + componentDidMount() { + setInterval(() => this.forceUpdate(), this.interval); + } + + componentWillUnmount() { + clearInterval(this.interval); + } + + render() { + return {formatDate(this.props.when)}; + } +} diff --git a/src/ui/server.js b/src/ui/server.js index 84fe088..f60af19 100644 --- a/src/ui/server.js +++ b/src/ui/server.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import moment from 'moment'; import { formatBitrate, formatAmount } from '../bitrate'; import { ws_disconnect } from '../socket'; -import date from '../date'; +import DateDisplay from './date'; import Throttle from './throttle'; import { updateResource } from '../actions/resources'; @@ -25,76 +25,65 @@ const ratio = (up, down) => { ); }; -class Server extends Component { - componentDidMount() { - this.interval = setInterval(this.forceUpdate, 1000); - } - - componentWillUnmount() { - clearInterval(this.interval); - } - - render() { - const { server, dispatch } = this.props; - if (!server.id) { - return null; - } - return ( -
-

- Synapse - -

-
-
Running since
-
{date(moment(server.started))}
-
Current network use
-
- {`${ - formatBitrate(server.rate_up) - } up, ${ - formatBitrate(server.rate_down) - } down`} -
-
Global download throttle
-
- dispatch(updateResource({ - id: server.id, - throttle_down - }))} - /> -
-
Global upload throttle
-
- dispatch(updateResource({ - id: server.id, - throttle_up - }))} - /> -
-
Lifetime ratio
- {ratio(server.transferred_up, server.transferred_down)} -
Session ratio
- {ratio(server.ses_transferred_up, server.ses_transferred_down)} -
-
- ); +function Server({ server, dispatch }) { + if (!server.id) { + return null; } + return ( +
+

+ Synapse + +

+
+
Running since
+
+
Current network use
+
+ {`${ + formatBitrate(server.rate_up) + } up, ${ + formatBitrate(server.rate_down) + } down`} +
+
Global download throttle
+
+ dispatch(updateResource({ + id: server.id, + throttle_down + }))} + /> +
+
Global upload throttle
+
+ dispatch(updateResource({ + id: server.id, + throttle_up + }))} + /> +
+
Lifetime ratio
+ {ratio(server.transferred_up, server.transferred_down)} +
Session ratio
+ {ratio(server.ses_transferred_up, server.ses_transferred_down)} +
+
+ ); } export default connect(state => ({ server: state.server }))(Server); diff --git a/src/ui/torrent_details.js b/src/ui/torrent_details.js index 61518be..08caa6d 100644 --- a/src/ui/torrent_details.js +++ b/src/ui/torrent_details.js @@ -15,7 +15,7 @@ import { import moment from 'moment'; import TorrentOptions from './torrent_options'; import ws_send from '../socket'; -import date from '../date'; +import DateDisplay from './date'; import selectTorrent, { EXCLUSIVE, UNION, @@ -148,7 +148,7 @@ class Torrent extends Component {
Downloading to
{torrent.path}
Created
-
{date(moment(torrent.created))}
+
URL
{tracker.url}
Last report
-
{date(moment(tracker.last_report))}
+
{tracker.error &&
Error
} {tracker.error &&
{tracker.error}
}