Browse Source

feat: distinguish bootstrap peers (IPFS Stats view)

develop
Ezerous 4 years ago
parent
commit
3e6346ed0b
  1. 2
      packages/concordia-app/package.json
  2. 57
      packages/concordia-app/src/layouts/MainLayout/MainLayoutIPFSStats/index.jsx
  3. 5
      packages/concordia-app/src/layouts/MainLayout/MainLayoutIPFSStats/styles.css
  4. 8
      yarn.lock

2
packages/concordia-app/package.json

@ -24,7 +24,7 @@
] ]
}, },
"dependencies": { "dependencies": {
"@ezerous/breeze": "~0.6.0", "@ezerous/breeze": "~0.7.0",
"@ezerous/drizzle": "~0.4.2", "@ezerous/drizzle": "~0.4.2",
"@ezerous/eth-identity-provider": "~0.1.2", "@ezerous/eth-identity-provider": "~0.1.2",
"@reduxjs/toolkit": "~1.4.0", "@reduxjs/toolkit": "~1.4.0",

57
packages/concordia-app/src/layouts/MainLayout/MainLayoutIPFSStats/index.jsx

@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { CopyToClipboard } from 'react-copy-to-clipboard'; import { CopyToClipboard } from 'react-copy-to-clipboard';
import { import {
Header, Image, List, Segment, Table, Transition, Header, Image, Segment, Table,
} from 'semantic-ui-react'; } from 'semantic-ui-react';
import ipfsLogo from '../../../assets/images/ipfs_logo.svg'; import ipfsLogo from '../../../assets/images/ipfs_logo.svg';
@ -11,29 +11,43 @@ import './styles.css';
const MainLayoutIPFSStats = () => { const MainLayoutIPFSStats = () => {
const ipfsId = useSelector((state) => state.ipfs.id); const ipfsId = useSelector((state) => state.ipfs.id);
const peerIds = useSelector((state) => state.ipfs.peers); const peerIds = useSelector((state) => state.ipfs.peers);
const bootstrapPeerIds = useSelector((state) => state.ipfs.bootstrapPeers);
const peers = useMemo(() => peerIds const peers = useMemo(() => peerIds
.map((peerId) => ( .map((peerId) => (
<List.Item <Table.Row className="stat-value">
key={peerId} <Table.Cell>
className="stat-value"
>
<CopyToClipboard text={peerId}> <CopyToClipboard text={peerId}>
<span>{peerId}</span> <span>{peerId}</span>
</CopyToClipboard> </CopyToClipboard>
</List.Item> </Table.Cell>
</Table.Row>
)), [peerIds]); )), [peerIds]);
const bootstrapPeers = useMemo(() => bootstrapPeerIds
.map((bootstrapPeerId) => (
<Table.Row className="stat-value">
<Table.Cell>
<CopyToClipboard text={bootstrapPeerId}>
<span>{bootstrapPeerId}</span>
</CopyToClipboard>
</Table.Cell>
</Table.Row>
)), [bootstrapPeerIds]);
return ( return (
<Segment> <Segment padded>
<Header textAlign="center"> <Header textAlign="center">
<Image src={ipfsLogo} size="tiny" /> <Image src={ipfsLogo} size="tiny" />
IPFS Stats IPFS Stats
</Header> </Header>
<Table definition> <Table compact textAlign="center" columns={1}>
<Table.Body> <Table.Body>
<Table.Row> <Table.Row>
<Table.Cell className="stat-key" textAlign="center">ID</Table.Cell> <Table.Cell className="stat-key">Peer ID</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell <Table.Cell
className="stat-value" className="stat-value"
> >
@ -43,16 +57,25 @@ const MainLayoutIPFSStats = () => {
</Table.Cell> </Table.Cell>
</Table.Row> </Table.Row>
<Table.Row> <Table.Row>
<Table.Cell className="stat-key" textAlign="center">Peers</Table.Cell> <Table.Cell className="stat-key">Peers</Table.Cell>
<Table.Cell> </Table.Row>
<Transition.Group {peers.length === 0
as={List} ? (
duration={1000} <Table.Row>
> <Table.Cell>-</Table.Cell>
</Table.Row>
) : null}
{peers} {peers}
</Transition.Group> <Table.Row>
</Table.Cell> <Table.Cell className="stat-key">Bootstrap Peers</Table.Cell>
</Table.Row>
{bootstrapPeers.length === 0
? (
<Table.Row>
<Table.Cell>-</Table.Cell>
</Table.Row> </Table.Row>
) : null}
{bootstrapPeers}
</Table.Body> </Table.Body>
</Table> </Table>
</Segment> </Segment>

5
packages/concordia-app/src/layouts/MainLayout/MainLayoutIPFSStats/styles.css

@ -1,9 +1,10 @@
.stat-key { .stat-key {
width: 13% background: rgba(0,0,0,.1);
font-weight: 700;
} }
.stat-value { .stat-value {
font-size: 0.9rem; font-size: 0.95rem;
cursor: pointer; cursor: pointer;
} }

8
yarn.lock

@ -1499,10 +1499,10 @@
"@ethersproject/properties" "^5.0.7" "@ethersproject/properties" "^5.0.7"
"@ethersproject/strings" "^5.0.8" "@ethersproject/strings" "^5.0.8"
"@ezerous/breeze@~0.6.0": "@ezerous/breeze@~0.7.0":
version "0.6.0" version "0.7.0"
resolved "https://registry.yarnpkg.com/@ezerous/breeze/-/breeze-0.6.0.tgz#95c602da137c098f8f6984b4ba85ad99d495ec55" resolved "https://registry.yarnpkg.com/@ezerous/breeze/-/breeze-0.7.0.tgz#b275dc0e92040e9fa7171d945562b716e133b4d7"
integrity sha512-8M7hg2nYvWjJcL4h3dNHglTyzx/9GbnS2HZ+3deFV1+WUdO0wIjWgssQi383ys/xygjNlNSo1nQAkUwy9cKM1g== integrity sha512-CMgrQ4b/hdl3OVGXiNpdoW3T8D1K+OAnOP3KlAtxCYW5uQZzp41xUq2MxpdVi5nj8YH6MZa8ditmSDEE7xnFFA==
dependencies: dependencies:
deepmerge "~4.2.2" deepmerge "~4.2.2"
ipfs "~0.54.2" ipfs "~0.54.2"

Loading…
Cancel
Save