summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick O'Doherty <p@trickod.com>2017-12-27 22:59:17 +0000
committerPatrick O'Doherty <p@trickod.com>2017-12-27 22:59:17 +0000
commit09792530d88b2cc1dc93f8129091a1ace6db1e10 (patch)
treea29eb22807404d02df99ca73d31820e39f72e661
parentb117cf7e1df20ee0adb232f70cced2dbd6da419e (diff)
Add total observed bandwidth to table
-rw-r--r--package.json1
-rw-r--r--src/components/RelayInformationRow.js2
-rw-r--r--src/components/RelayInformationTable.js13
3 files changed, 12 insertions, 4 deletions
diff --git a/package.json b/package.json
index 305e69e..8efe60c 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"bootstrap": "^3.3.7",
+ "lodash": "^4.17.4",
"moment": "^2.20.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
diff --git a/src/components/RelayInformationRow.js b/src/components/RelayInformationRow.js
index 37d5b6d..097fc5d 100644
--- a/src/components/RelayInformationRow.js
+++ b/src/components/RelayInformationRow.js
@@ -18,8 +18,8 @@ class RelayInformationRow extends Component {
<td>{nickname}</td>
<td><code>{fingerprint}</code></td>
<td>{or_addresses}</td>
- <td><BandwidthRate rate={observed_bandwidth} /></td>
<td><Uptime lastRestarted={last_restarted} /></td>
+ <td><BandwidthRate rate={observed_bandwidth} /></td>
<td>{(exit_probability * 100).toFixed(3)}%</td>
</tr>
)
diff --git a/src/components/RelayInformationTable.js b/src/components/RelayInformationTable.js
index 713378c..fb0c4e6 100644
--- a/src/components/RelayInformationTable.js
+++ b/src/components/RelayInformationTable.js
@@ -1,5 +1,7 @@
import React, { Component } from 'react';
import RelayInformationRow from './RelayInformationRow';
+import BandwidthRate from './BandwidthRate';
+import _ from 'lodash'
class RelayInformationTable extends Component {
constructor(props) {
@@ -12,7 +14,7 @@ class RelayInformationTable extends Component {
}
render() {
- const { error, isLoaded, relays } = this.state;
+ let { error, isLoaded, relays } = this.state;
if (error) {
return <div>Error: {error.message}</div>;
} else if (!isLoaded) {
@@ -21,6 +23,11 @@ class RelayInformationTable extends Component {
const totalExitProbabilty = relays.reduce((m, relay) => {
return m + relay.exit_probability;
}, 0);
+ const totalObservedBandwidth = relays.reduce((m, relay) => {
+ return m + relay.observed_bandwidth;
+ }, 0);
+
+ relays = _.sortBy(relays, (relay) => relay.nickname );
return (
<div>
@@ -31,8 +38,8 @@ class RelayInformationTable extends Component {
<th>Name</th>
<th>Fingerprint</th>
<th>Exit IP</th>
- <th>Bandwidth</th>
<th>Uptime</th>
+ <th>Bandwidth</th>
<th>Exit %</th>
</tr>
</thead>
@@ -44,8 +51,8 @@ class RelayInformationTable extends Component {
<td></td>
<td></td>
<td></td>
- <td></td>
<td><b>Total</b></td>
+ <td><b><BandwidthRate rate={totalObservedBandwidth}/></b></td>
<td><b>{(totalExitProbabilty * 100).toFixed(2)}%</b></td>
</tr>
</tbody>