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