diff --git a/src/ui/ratio.js b/src/ui/ratio.js new file mode 100644 index 0000000..138d22d --- /dev/null +++ b/src/ui/ratio.js @@ -0,0 +1,20 @@ +import React, { Component } from 'react'; +import { formatAmount } from '../bitrate'; + +export default function Ratio({ up, down }) { + const ratio = up / down; + if (isNaN(ratio)) { + return 0; + } + return ( + + {`${ + ratio.toFixed(3) + } (${ + formatAmount(up) + } up, ${ + formatAmount(down) + } down)`} + + ); +} diff --git a/src/ui/server.js b/src/ui/server.js index f60af19..5a3423b 100644 --- a/src/ui/server.js +++ b/src/ui/server.js @@ -1,30 +1,13 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import moment from 'moment'; -import { formatBitrate, formatAmount } from '../bitrate'; +import { formatBitrate } from '../bitrate'; import { ws_disconnect } from '../socket'; import DateDisplay from './date'; +import Ratio from './ratio'; import Throttle from './throttle'; import { updateResource } from '../actions/resources'; -const ratio = (up, down) => { - const ratio = up / down; - if (isNaN(ratio)) { - return