This repository has been archived by the owner on Jul 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f439823
commit 5772072
Showing
20 changed files
with
530 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// @flow | ||
import {map} from 'lodash/fp'; | ||
import React from 'react'; | ||
import {observer} from 'mobx-react-lite'; | ||
import NodesStore from 'v2/stores/nodes'; | ||
import Card from 'v2/components/UI/StatCard'; | ||
|
||
import useStyles from './styles'; | ||
|
||
const Cards = () => { | ||
const classes = useStyles(); | ||
const {cluster} = NodesStore; | ||
const {nodes} = cluster; | ||
const cards = [ | ||
{ | ||
title: 'Stage Duration Blocks', | ||
value: 'TODO', | ||
changes: '', | ||
period: 'since yesterday', | ||
}, | ||
{ | ||
title: 'Days Left In Stage', | ||
value: 'TODO', | ||
changes: '', | ||
period: 'since yesterday', | ||
}, | ||
{ | ||
title: 'Total SOL In Circulation', | ||
value: cluster.supply / Math.pow(2, 34).toFixed(2), | ||
changes: '', | ||
period: 'since yesterday', | ||
}, | ||
{ | ||
title: 'Total Bonded Tokens', | ||
value: 'TODO', | ||
changes: '', | ||
period: 'since yesterday', | ||
}, | ||
{ | ||
title: 'Current Network Inflation Rate', | ||
value: 'TODO', | ||
changes: '', | ||
period: 'since yesterday', | ||
}, | ||
{ | ||
title: '# of Active Validators', | ||
value: nodes.length, | ||
changes: '', | ||
period: 'since yesterday', | ||
}, | ||
{ | ||
title: '# of Inactive Validators', | ||
value: 'TODO', | ||
changes: '', | ||
period: 'since yesterday', | ||
}, | ||
{ | ||
title: 'Circulating Supply Staked', | ||
value: 'TODO', | ||
changes: '', | ||
period: 'since yesterday', | ||
}, | ||
]; | ||
|
||
const renderStats = ({ | ||
title, | ||
value, | ||
changes = null, | ||
}: { | ||
title: string, | ||
value: string | (() => React$Node), | ||
changes?: string, | ||
}) => <Card title={title} value={value} changes={changes} />; | ||
|
||
return <div className={classes.cards}>{map(renderStats)(cards)}</div>; | ||
}; | ||
|
||
export default observer(Cards); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {makeStyles} from '@material-ui/core'; | ||
|
||
export default makeStyles(() => ({ | ||
cards: { | ||
'& div:not(:last-child)': { | ||
marginBottom: 20, | ||
}, | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import {observer} from 'mobx-react-lite'; | ||
import {map} from 'lodash/fp'; | ||
import HelpLink from 'v2/components/HelpLink'; | ||
import NodesStore from 'v2/stores/nodes'; | ||
import {ReactComponent as BicycleIcon} from 'v2/assets/icons/bicycle.svg'; | ||
|
||
import useStyles from './styles'; | ||
|
||
const Ranking = () => { | ||
const classes = useStyles(); | ||
const { | ||
cluster: {nodes}, | ||
} = NodesStore; | ||
|
||
const renderNode = node => ( | ||
<li className={classes.item}> | ||
<div className={classes.name}>{node.pubkey}</div> | ||
<div className={classes.bar}> | ||
<div className={classes.icon}> | ||
<BicycleIcon /> | ||
</div> | ||
</div> | ||
</li> | ||
); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<div className={classes.header}> | ||
Top Validator Ranking | ||
<HelpLink text="" term="" /> | ||
</div> | ||
<ul className={classes.list}>{map(renderNode)(nodes)}</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
Ranking.propTypes = {}; | ||
|
||
export default observer(Ranking); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {makeStyles} from '@material-ui/core'; | ||
import getColor from 'v2/utils/getColor'; | ||
|
||
export default makeStyles(theme => ({ | ||
root: { | ||
background: getColor('grey2')(theme), | ||
padding: '17px 24px', | ||
}, | ||
list: { | ||
padding: 0, | ||
}, | ||
item: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
'&:not(:last-child)': { | ||
marginBottom: 17, | ||
}, | ||
}, | ||
name: { | ||
maxWidth: 130, | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
color: getColor('main')(theme), | ||
marginRight: 20, | ||
flexShrink: 0, | ||
'&::before': { | ||
content: '""', | ||
display: 'inline-block', | ||
verticalAlign: 'middle', | ||
width: 33, | ||
height: 33, | ||
background: getColor('main')(theme), | ||
borderRadius: '50%', | ||
marginRight: 22, | ||
}, | ||
}, | ||
bar: { | ||
flex: 1, | ||
height: 8, | ||
borderRadius: 10, | ||
background: getColor('greyW1')(theme), | ||
position: 'relative', | ||
}, | ||
icon: { | ||
position: 'absolute', | ||
top: '50%', | ||
transform: 'translateY(-50%)', | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// @flow | ||
|
||
import React from 'react'; | ||
import { | ||
Typography, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableRow, | ||
Grid, | ||
} from '@material-ui/core'; | ||
import cn from 'classnames'; | ||
import useMediaQuery from '@material-ui/core/useMediaQuery'; | ||
import {useTheme} from '@material-ui/core/styles'; | ||
import {observer} from 'mobx-react-lite'; | ||
import {Link} from 'react-router-dom'; | ||
import {map} from 'lodash/fp'; | ||
import NodesStore from 'v2/stores/nodes'; | ||
import HelpLink from '../../HelpLink'; | ||
|
||
import useStyles from './styles'; | ||
|
||
const ValidatorsTable = ({separate}: {separate: boolean}) => { | ||
const classes = useStyles(); | ||
const theme = useTheme(); | ||
const showTable = useMediaQuery(theme.breakpoints.up('md')); | ||
const { | ||
cluster: {voting = []}, | ||
} = NodesStore; | ||
|
||
const renderRow = row => { | ||
return ( | ||
<TableRow hover key={row.nodePubkey}> | ||
<TableCell>1</TableCell> | ||
<TableCell> | ||
<Link | ||
to={`/rc/validators/${row.nodePubkey}`} | ||
className={classes.name} | ||
> | ||
<span /> | ||
<div>{row.nodePubkey}</div> | ||
</Link> | ||
</TableCell> | ||
<TableCell>{row.stake}</TableCell> | ||
<TableCell>TODO</TableCell> | ||
</TableRow> | ||
); | ||
}; | ||
const renderCard = card => { | ||
return ( | ||
<div | ||
className={cn(classes.card, separate && classes.cardVertical)} | ||
key={card.nodePubkey} | ||
> | ||
<Link to={`/rc/validators/${card.nodePubkey}`} className={classes.name}> | ||
<span /> | ||
<div>{card.nodePubkey}</div> | ||
</Link> | ||
<Grid container> | ||
<Grid item xs={4} zeroMinWidth> | ||
<div className={classes.cardTitle}>Stake</div> | ||
<div>{card.stake}</div> | ||
</Grid> | ||
<Grid item xs={4} zeroMinWidth> | ||
<div className={classes.cardTitle}>Uptime</div> | ||
<div>TODO</div> | ||
</Grid> | ||
</Grid> | ||
</div> | ||
); | ||
}; | ||
return ( | ||
<div className={classes.root}> | ||
<div className={classes.header}> | ||
<Typography> | ||
Active Validators | ||
<HelpLink text="" term="" /> | ||
</Typography> | ||
<Typography variant="h5">{voting.length}</Typography> | ||
{!separate && ( | ||
<Link to="/rc/validators/all" className={classes.link}> | ||
See all > | ||
</Link> | ||
)} | ||
</div> | ||
{showTable ? ( | ||
<Table> | ||
<TableHead className={classes.head}> | ||
<TableRow> | ||
<TableCell width={100}>Ranking</TableCell> | ||
<TableCell width={230}>Name</TableCell> | ||
<TableCell>Stake</TableCell> | ||
<TableCell width={100}>Uptime</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody | ||
classes={{ | ||
root: classes.body, | ||
}} | ||
> | ||
{map(renderRow)(voting)} | ||
</TableBody> | ||
</Table> | ||
) : ( | ||
<div className={cn(classes.list, separate && classes.vertical)}> | ||
{map(renderCard)(voting)} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default observer(ValidatorsTable); |
Oops, something went wrong.