From 65678a1521fe4a3907fec6fc6173726148e6b22e Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Thu, 8 Feb 2018 23:52:06 +0100 Subject: [PATCH] huge usability improvements --- package.json | 1 + src/components/Board.js | 62 ++++++++++++++++++++++++++----------- src/components/BoardForm.js | 2 -- src/components/BoardPage.js | 3 +- src/components/Boards.js | 20 ++++++------ src/components/Post.js | 33 ++++++++++++++++---- src/containers/Board.js | 6 ++-- src/containers/Boards.js | 5 ++- src/containers/WithBoard.js | 2 +- src/containers/WithStats.js | 44 ++++++++++++++++++++++++++ src/index.js | 10 +++--- src/orbitdb/index.js | 30 ++++++++---------- src/reducers/boards.js | 4 +-- src/sagas/boards.js | 14 ++++++--- src/utils/ipfs.js | 41 ++++++++++++++++++++++++ yarn.lock | 4 +++ 16 files changed, 212 insertions(+), 69 deletions(-) create mode 100644 src/containers/WithStats.js diff --git a/package.json b/package.json index f5beaee..9d53487 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "private": true, "dependencies": { "ipfs": "^0.27.7", + "moment": "^2.20.1", "orbit-db": "^0.19.4", "orbit-db-discussion-board": "https://github.com/fazo96/orbit-db-discussion-board.git", "react": "^16.2.0", diff --git a/src/components/Board.js b/src/components/Board.js index fd6c1f3..ff5a9c0 100644 --- a/src/components/Board.js +++ b/src/components/Board.js @@ -1,12 +1,23 @@ import React from 'react' import Post from './Post' -import { Divider, Icon, Grid, Segment, Header, List, Button, Card } from 'semantic-ui-react' +import { Divider, Icon, Grid, Header, List, Button, Card } from 'semantic-ui-react' import { Link } from 'react-router-dom' import { shortenAddress } from '../utils/orbitdb'; +import moment from 'moment' -export default function Board({ address, posts, metadata, replicating }) { +export default function Board({ address, posts, metadata, replicating, stats, replicationInfo, lastReplicated }) { const { email, website, title } = metadata || {} - const url = window.location.href + const peerCount = (stats.peers || []).length + const online = peerCount > 0 + const writeable = stats.access ? (stats.access.writeable ? 'Yes' : 'No') : '?' + let replicationMessage = lastReplicated ? ('Last Activity at ' + moment(lastReplicated).format('H:mm')) : 'No Activity' + if (replicating) { + if (replicationInfo && replicationInfo.max !== undefined) { + replicationMessage = 'Progress: ' + (replicationInfo.progress || 0) + '/' + replicationInfo.max + } else { + replicationMessage = 'Initializing Transfer' + } + } return
@@ -18,19 +29,41 @@ export default function Board({ address, posts, metadata, replicating }) { - Board Address + Address - {address} + {address} - + - Users - ? + Size + {stats.opLogLength || 0} Entries + + + + {online ? 'Online' : 'Offline'} + {online ? peerCount + ' Connections' : 'No Connections'} + + + + + + {replicating ? 'Downloading' : 'Download'} + {replicationMessage} + + + + + + Write Access + {writeable} + + + @@ -38,13 +71,6 @@ export default function Board({ address, posts, metadata, replicating }) { {Object.values(posts || {}).length} - - - - Replication - {replicating ? 'Receiving Content...' : 'Idle'} - - @@ -61,13 +87,13 @@ export default function Board({ address, posts, metadata, replicating }) {
- - -
diff --git a/src/components/BoardForm.js b/src/components/BoardForm.js index 3c0d4d6..8fd4778 100644 --- a/src/components/BoardForm.js +++ b/src/components/BoardForm.js @@ -1,7 +1,5 @@ import React, { Component } from 'react' -import { Redirect } from 'react-router-dom' import { Container, Card, Form, Button } from 'semantic-ui-react' -import { shortenAddress } from '../utils/orbitdb' export default class BoardForm extends Component { constructor(props){ diff --git a/src/components/BoardPage.js b/src/components/BoardPage.js index 5cdb210..18518db 100644 --- a/src/components/BoardPage.js +++ b/src/components/BoardPage.js @@ -2,11 +2,12 @@ import React from 'react' import { Switch, Route } from 'react-router-dom' import Board from '../containers/Board' import PostEditor from '../containers/PostEditor' +import WithStats from '../containers/WithStats' function BoardPage({ match, address, posts, metadata }) { return - + } diff --git a/src/components/Boards.js b/src/components/Boards.js index aba680d..33e6814 100644 --- a/src/components/Boards.js +++ b/src/components/Boards.js @@ -3,7 +3,7 @@ import { List, Icon, Segment, Divider, Grid, Header, Button, Card } from 'semant import { Link } from 'react-router-dom' import BoardsItem from './BoardsItem' -export default function Boards({ boards, createBoard }) { +export default function Boards({ stats, boards, createBoard }) { return
@@ -13,43 +13,43 @@ export default function Boards({ boards, createBoard }) { - + - Boards - {Object.keys(boards).length} + Seeding + {Object.keys(boards).length} Boards Connected Peers - ? + {stats.peers.length} Used Space - ? + Not Supported Yet - + IPFS ID - ? + {stats.id} OrbitDB Public Key - ? + {stats.pubKey}
-