|
@ -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}> |
|
|
> |
|
|
<span>{peerId}</span> |
|
|
<CopyToClipboard text={peerId}> |
|
|
</CopyToClipboard> |
|
|
<span>{peerId}</span> |
|
|
</Table.Cell> |
|
|
</CopyToClipboard> |
|
|
</Table.Row> |
|
|
</List.Item> |
|
|
|
|
|
|
|
|
|
|
|
)), [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> |
|
|
{peers} |
|
|
</Table.Row> |
|
|
</Transition.Group> |
|
|
) : null} |
|
|
</Table.Cell> |
|
|
{peers} |
|
|
|
|
|
<Table.Row> |
|
|
|
|
|
<Table.Cell className="stat-key">Bootstrap Peers</Table.Cell> |
|
|
</Table.Row> |
|
|
</Table.Row> |
|
|
|
|
|
{bootstrapPeers.length === 0 |
|
|
|
|
|
? ( |
|
|
|
|
|
<Table.Row> |
|
|
|
|
|
<Table.Cell>-</Table.Cell> |
|
|
|
|
|
</Table.Row> |
|
|
|
|
|
) : null} |
|
|
|
|
|
{bootstrapPeers} |
|
|
</Table.Body> |
|
|
</Table.Body> |
|
|
</Table> |
|
|
</Table> |
|
|
</Segment> |
|
|
</Segment> |
|
|