Skip to content

Commit

Permalink
Merge branch 'master' into performance/384-final
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcorbalan committed Apr 23, 2020
2 parents 76bb1dd + 75f9459 commit 142bf91
Show file tree
Hide file tree
Showing 14 changed files with 458 additions and 298 deletions.
203 changes: 115 additions & 88 deletions src/components/Home/HomeDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
getMKRResponsiveness,
} from './helpers'
import styled from 'styled-components'
import LinkableComponent from '../common/LinkableComponent'

const CardStyled = styled(Card)`
height: ${props => props.theme.defaultCardHeight};
Expand Down Expand Up @@ -526,20 +527,28 @@ function HomeDetail(props: Props) {
<>
<PageTitle>System Statistics</PageTitle>
<TwoRowGrid style={{ marginBottom: '20px' }}>
<CardStyled>
{stakedMkr.length === 0 ? <Loading /> : <StakedMkr content="Staked MKR" component="stakedMkr" />}
</CardStyled>
<CardStyled>
<VotersVsMkr content="Number of Voters" versus="Total MKR Staked" component="votersVsMkr" />
</CardStyled>
<LinkableComponent id="STAKED_MKR">
<CardStyled>
{stakedMkr.length === 0 ? <Loading /> : <StakedMkr content="Staked MKR" component="stakedMkr" />}
</CardStyled>
</LinkableComponent>
<LinkableComponent id="NUMBER_OF_VOTERS">
<CardStyled>
<VotersVsMkr content="Number of Voters" versus="Total MKR Staked" component="votersVsMkr" />
</CardStyled>
</LinkableComponent>
</TwoRowGrid>
<TwoRowGrid style={{ marginBottom: '20px' }}>
<CardStyled>
{polls.length === 0 ? <Loading /> : <VotesVsPolls content="Total Votes" component="votesVsPolls" />}
</CardStyled>
<CardStyled>
<Gini content="Voting MKR Gini Coefficient" component="gini" />
</CardStyled>
<LinkableComponent id="TOTAL_VOTES">
<CardStyled>
{polls.length === 0 ? <Loading /> : <VotesVsPolls content="Total Votes" component="votesVsPolls" />}
</CardStyled>
</LinkableComponent>
<LinkableComponent id="VOTING_MKR_GINI">
<CardStyled>
<Gini content="Voting MKR Gini Coefficient" component="gini" />
</CardStyled>
</LinkableComponent>
</TwoRowGrid>
<PageSubTitle>Voter Behaviour</PageSubTitle>
{/*
Expand All @@ -561,94 +570,112 @@ function HomeDetail(props: Props) {
</TableCardStyled>
</TwoRowGrid>
*/}
<CardStyled style={{ marginBottom: '20px' }}>
{executivesResponsiveness.length === 0 ? (
<Loading />
) : (
<ExecutivesResponsiveness content="Votes - MKR Responsiveness" component="executivesResponsiveness" />
)}
</CardStyled>
<TwoRowGrid style={{ marginBottom: '20px' }}>
<CardStyled>
{pollsResponsiveness.length === 0 ? (
<LinkableComponent id="VOTES_MKR_RESPONSIVENESS">
<CardStyled style={{ marginBottom: '20px' }}>
{executivesResponsiveness.length === 0 ? (
<Loading />
) : (
<PollsResponsiveness content="Polls - MKR Responsiveness" component="pollsResponsiveness" />
<ExecutivesResponsiveness content="Votes - MKR Responsiveness" component="executivesResponsiveness" />
)}
</CardStyled>
<TableCardStyled style={{ padding: 0 }}>
{topVoters.length === 0 ? (
<Loading />
) : (
<HomeTable
info={homeMap.table.topVoters.info}
links={homeMap.table.topVoters.links}
content="Top Voters"
component="topVoters"
/>
)}
</TableCardStyled>
</LinkableComponent>
<TwoRowGrid style={{ marginBottom: '20px' }}>
<LinkableComponent id="POLLS_MKR_RESPONSIVENESS">
<CardStyled>
{pollsResponsiveness.length === 0 ? (
<Loading />
) : (
<PollsResponsiveness content="Polls - MKR Responsiveness" component="pollsResponsiveness" />
)}
</CardStyled>
</LinkableComponent>
<LinkableComponent id="TOP_VOTERS">
<TableCardStyled style={{ padding: 0 }}>
{topVoters.length === 0 ? (
<Loading />
) : (
<HomeTable
info={homeMap.table.topVoters.info}
links={homeMap.table.topVoters.links}
content="Top Voters"
component="topVoters"
/>
)}
</TableCardStyled>
</LinkableComponent>
</TwoRowGrid>
<PageSubTitle>Executives</PageSubTitle>
<TwoRowGrid style={{ marginBottom: '20px' }}>
<TableCardStyled style={{ padding: 0 }}>
<HomeTable
info={homeMap.table.executives.info}
links={homeMap.table.executives.links}
handleRow={getVote}
content="Top Executives"
component="executives"
/>
</TableCardStyled>
<TableCardStyled style={{ padding: 0 }}>
<HomeTable
info={homeMap.table.uncastedExecutives.info}
links={homeMap.table.uncastedExecutives.links}
handleRow={getVote}
content="Uncast Executives"
component="uncastedExecutives"
/>
</TableCardStyled>
<LinkableComponent id="TOP_EXECUTIVES">
<TableCardStyled style={{ padding: 0 }}>
<HomeTable
info={homeMap.table.executives.info}
links={homeMap.table.executives.links}
handleRow={getVote}
content="Top Executives"
component="executives"
/>
</TableCardStyled>
</LinkableComponent>
<LinkableComponent id="UNCAST_EXECUTIVES">
<TableCardStyled style={{ padding: 0 }}>
<HomeTable
info={homeMap.table.uncastedExecutives.info}
links={homeMap.table.uncastedExecutives.links}
handleRow={getVote}
content="Uncast Executives"
component="uncastedExecutives"
/>
</TableCardStyled>
</LinkableComponent>
</TwoRowGrid>
<TwoRowGrid style={{ marginBottom: '20px' }}>
<CardStyled>
<TimeTakenForExecutives content="Executive Time to Pass" component="timeTakenForExecutives" />
</CardStyled>
<CardStyled>
<MkrDistributionPerExecutive
content="MKR Distribution By Executive"
component="mkrDistributionPerExecutive"
/>
</CardStyled>
<LinkableComponent id="EXECUTIVE_TIME_TO_PASS">
<CardStyled>
<TimeTakenForExecutives content="Executive Time to Pass" component="timeTakenForExecutives" />
</CardStyled>
</LinkableComponent>
<LinkableComponent id="MKR_DISTRIBUTION_BY_EXECUTIVE">
<CardStyled>
<MkrDistributionPerExecutive
content="MKR Distribution By Executive"
component="mkrDistributionPerExecutive"
/>
</CardStyled>
</LinkableComponent>
</TwoRowGrid>
<PageSubTitle>Polls</PageSubTitle>
<TwoRowGrid style={{ marginBottom: '20px' }}>
<TableCardStyled style={{ padding: 0 }}>
{polls.length === 0 || !polls[0].participation ? (
<Loading />
) : (
<HomeTable
info={homeMap.table.votedPolls.info}
links={homeMap.table.votedPolls.links}
handleRow={getPoll}
content="Most Voted Polls"
component="votedPolls"
/>
)}
</TableCardStyled>
<TableCardStyled style={{ padding: 0 }}>
{polls.length === 0 ? (
<Loading />
) : (
<HomeTable
info={homeMap.table.polls.info}
links={homeMap.table.polls.links}
handleRow={getPoll}
content="Recent Polls"
component="polls"
/>
)}
</TableCardStyled>
<LinkableComponent id="MOST_VOTED_POLLS">
<TableCardStyled style={{ padding: 0 }}>
{polls.length === 0 || !polls[0].participation ? (
<Loading />
) : (
<HomeTable
info={homeMap.table.votedPolls.info}
links={homeMap.table.votedPolls.links}
handleRow={getPoll}
content="Most Voted Polls"
component="votedPolls"
/>
)}
</TableCardStyled>
</LinkableComponent>
<LinkableComponent id="RECENT_POLLS">
<TableCardStyled style={{ padding: 0 }}>
{polls.length === 0 ? (
<Loading />
) : (
<HomeTable
info={homeMap.table.polls.info}
links={homeMap.table.polls.links}
handleRow={getPoll}
content="Recent Polls"
component="polls"
/>
)}
</TableCardStyled>
</LinkableComponent>
</TwoRowGrid>
{isModalOpen && (
<Modal isChart={isModalChart} isOpen={isModalOpen} closeModal={() => setModalOpen(false)}>
Expand Down
21 changes: 18 additions & 3 deletions src/components/List/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Pollcolumns = () => {
Filter: SelectColumnFilter,
filter: 'includes',
accessor: row => (timeLeft(row.endDate) === 'Ended' ? 'Ended' : 'Active'),
Cell: ({ row }) => timeLeft(row.original.endDate),
Cell: ({ row }) => (row.original.fetched ? timeLeft(row.original.endDate) : <Loading />),
width: 100,
},
{
Expand Down Expand Up @@ -80,7 +80,8 @@ export const Pollcolumns = () => {
disableFilters: true,
id: 'date',
sortType: 'datetime',
Cell: ({ row }) => format(fromUnixTime(row.original.startDate), 'dd MMM yy'),
Cell: ({ row }) =>
row.original.fetched ? format(fromUnixTime(row.original.startDate), 'dd MMM yy') : <Loading />,
width: 100,
},
{
Expand All @@ -89,7 +90,7 @@ export const Pollcolumns = () => {
disableFilters: true,
separator: true,
sortType: 'datetime',
Cell: ({ row }) => format(fromUnixTime(row.original.endDate), 'dd MMM yy'),
Cell: ({ row }) => (row.original.fetched ? format(fromUnixTime(row.original.endDate), 'dd MMM yy') : <Loading />),
width: 100,
},
]
Expand Down Expand Up @@ -262,5 +263,19 @@ export const VoterHistoryColumns = () => {
<Loading />
),
},
{
Header: 'Date',
id: 'date',
separator: true,
disableFilters: true,
sortType: 'datetime',
Cell: ({ row }) => {
if (!row.original.lastParticipation) {
return <Loading />
}
return format(fromUnixTime(row.original.lastParticipation.timestamp), 'dd MMM yy')
},
width: 100,
},
]
}
Loading

0 comments on commit 142bf91

Please sign in to comment.