Browse Source

feat: add Ethereum status

develop
Ezerous 4 years ago
parent
commit
fda31302dc
  1. 2
      packages/concordia-app/package.json
  2. 2
      packages/concordia-app/src/components/ClearDatabasesModal/index.jsx
  3. 13
      packages/concordia-app/src/components/Status/StatusKeyRow.jsx
  4. 24
      packages/concordia-app/src/components/Status/StatusSegment.jsx
  5. 22
      packages/concordia-app/src/components/Status/StatusValueRow.jsx
  6. 0
      packages/concordia-app/src/components/Status/styles.css
  7. 29
      packages/concordia-app/src/layouts/MainLayout/MainLayoutEthereumStatus/index.jsx
  8. 76
      packages/concordia-app/src/layouts/MainLayout/MainLayoutIPFSStatus/index.jsx
  9. 2
      packages/concordia-app/src/layouts/MainLayout/index.jsx

2
packages/concordia-app/package.json

@ -25,7 +25,7 @@
},
"dependencies": {
"@ezerous/breeze": "~0.7.0",
"@ezerous/drizzle": "~0.4.2",
"@ezerous/drizzle": "~0.4.3",
"@ezerous/eth-identity-provider": "~0.1.2",
"@reduxjs/toolkit": "~1.4.0",
"@welldone-software/why-did-you-render": "~6.0.5",

2
packages/concordia-app/src/components/ClearDatabasesModal/index.jsx

@ -23,7 +23,7 @@ const ClearDatabasesModal = (props) => {
useEffect(() => {
if (user.hasSignedUp && confirmationInput === user.username) {
setUserConfirmed(true);
} else if (!user.hasSignedUp && confirmationInput === 'Concordia') {
} else if (!user.hasSignedUp && confirmationInput.toLowerCase() === 'concordia') {
setUserConfirmed(true);
} else {
setUserConfirmed(false);

13
packages/concordia-app/src/components/Status/StatusKeyRow.jsx

@ -0,0 +1,13 @@
import React from 'react';
import { Table } from 'semantic-ui-react';
const StatusKeyRow = (props) => {
const { value } = props;
return (
<Table.Row>
<Table.Cell className="status-key">{value}</Table.Cell>
</Table.Row>
);
};
export default StatusKeyRow;

24
packages/concordia-app/src/components/Status/StatusSegment.jsx

@ -0,0 +1,24 @@
import React from 'react';
import {
Header, Image, Segment, Table,
} from 'semantic-ui-react';
import './styles.css';
const StatusKeyRow = (props) => {
const { headerTitle, headerImage, children } = props;
return (
<Segment padded>
<Header textAlign="center">
<Image src={headerImage} size="small" />
{headerTitle}
</Header>
<Table className="status-table" compact textAlign="center" columns={1}>
<Table.Body>
{children}
</Table.Body>
</Table>
</Segment>
);
};
export default StatusKeyRow;

22
packages/concordia-app/src/components/Status/StatusValueRow.jsx

@ -0,0 +1,22 @@
import React from 'react';
import { Table } from 'semantic-ui-react';
import { CopyToClipboard } from 'react-copy-to-clipboard';
const StatusValueRow = (props) => {
const { value } = props;
return (value) ? (
<Table.Row className="status-value">
<Table.Cell>
<CopyToClipboard text={value}>
<span>{value}</span>
</CopyToClipboard>
</Table.Cell>
</Table.Row>
) : (
<Table.Row>
<Table.Cell>-</Table.Cell>
</Table.Row>
);
};
export default StatusValueRow;

0
packages/concordia-app/src/layouts/MainLayout/MainLayoutIPFSStatus/styles.css → packages/concordia-app/src/components/Status/styles.css

29
packages/concordia-app/src/layouts/MainLayout/MainLayoutEthereumStatus/index.jsx

@ -0,0 +1,29 @@
import React from 'react';
import { useSelector } from 'react-redux';
import StatusSegment from '../../../components/Status/StatusSegment';
import StatusKeyRow from '../../../components/Status/StatusKeyRow';
import StatusValueRow from '../../../components/Status/StatusValueRow';
import ethereumLogo from '../../../assets/images/ethereum_logo.svg';
const MainLayoutEthereumStatus = () => {
const userAddress = useSelector((state) => state.user.address);
const blockNumber = useSelector((state) => state.currentBlock.number);
const blockHash = useSelector((state) => state.currentBlock.hash);
return (
<StatusSegment
headerTitle="Ethereum Status"
headerImage={ethereumLogo}
>
<StatusKeyRow value="User Address" />
<StatusValueRow value={userAddress} />
<StatusKeyRow value="Block Number" />
<StatusValueRow value={blockNumber} />
<StatusKeyRow value="Block Hash" />
<StatusValueRow value={blockHash} />
</StatusSegment>
);
};
export default MainLayoutEthereumStatus;

76
packages/concordia-app/src/layouts/MainLayout/MainLayoutIPFSStatus/index.jsx

@ -1,12 +1,9 @@
import React, { useMemo } from 'react';
import { useSelector } from 'react-redux';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import {
Header, Image, Segment, Table,
} from 'semantic-ui-react';
import StatusSegment from '../../../components/Status/StatusSegment';
import StatusKeyRow from '../../../components/Status/StatusKeyRow';
import StatusValueRow from '../../../components/Status/StatusValueRow';
import ipfsLogo from '../../../assets/images/ipfs_logo.svg';
import './styles.css';
const MainLayoutIPFSStatus = () => {
const ipfsId = useSelector((state) => state.ipfs.id);
@ -14,71 +11,28 @@ const MainLayoutIPFSStatus = () => {
const bootstrapPeerIds = useSelector((state) => state.ipfs.bootstrapPeers);
const peers = useMemo(() => peerIds
.map((peerId) => (
<Table.Row className="status-value">
<Table.Cell>
<CopyToClipboard text={peerId}>
<span>{peerId}</span>
</CopyToClipboard>
</Table.Cell>
</Table.Row>
<StatusValueRow value={peerId} key={peerId} />
)), [peerIds]);
const bootstrapPeers = useMemo(() => bootstrapPeerIds
.map((bootstrapPeerId) => (
<Table.Row className="status-value">
<Table.Cell>
<CopyToClipboard text={bootstrapPeerId}>
<span>{bootstrapPeerId}</span>
</CopyToClipboard>
</Table.Cell>
</Table.Row>
<StatusValueRow value={bootstrapPeerId} key={bootstrapPeerId} />
)), [bootstrapPeerIds]);
return (
<Segment padded>
<Header textAlign="center">
<Image src={ipfsLogo} size="small" />
IPFS Status
</Header>
<Table className="status-table" compact textAlign="center" columns={1}>
<Table.Body>
<Table.Row>
<Table.Cell className="status-key">Peer ID</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell
className="status-value"
<StatusSegment
headerTitle="IPFS Status"
headerImage={ipfsLogo}
>
<CopyToClipboard text={ipfsId}>
<span>{ipfsId}</span>
</CopyToClipboard>
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell className="status-key">Peers</Table.Cell>
</Table.Row>
{peers.length === 0
? (
<Table.Row>
<Table.Cell>-</Table.Cell>
</Table.Row>
) : null}
<StatusKeyRow value="Peer ID" />
<StatusValueRow value={ipfsId} />
<StatusKeyRow value="Peers" />
{peers.length === 0 ? (<StatusValueRow />) : null}
{peers}
<Table.Row>
<Table.Cell className="status-key">Bootstrap Peers</Table.Cell>
</Table.Row>
{bootstrapPeers.length === 0
? (
<Table.Row>
<Table.Cell>-</Table.Cell>
</Table.Row>
) : null}
<StatusKeyRow value="Bootstrap Peers" />
{bootstrapPeers.length === 0 ? (<StatusValueRow />) : null}
{bootstrapPeers}
</Table.Body>
</Table>
</Segment>
</StatusSegment>
);
};

2
packages/concordia-app/src/layouts/MainLayout/index.jsx

@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Grid } from 'semantic-ui-react';
import MainLayoutMenu from './MainLayoutMenu';
import MainLayoutEthereumStatus from './MainLayoutEthereumStatus';
import MainLayoutIPFSStatus from './MainLayoutIPFSStatus';
import './styles.css';
@ -17,6 +18,7 @@ const MainLayout = (props) => {
{children}
</Grid.Column>
<Grid.Column width={4}>
<MainLayoutEthereumStatus />
<MainLayoutIPFSStatus />
</Grid.Column>
</Grid>

Loading…
Cancel
Save