-
-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #519 from DemocracyEarth/dapp
New Ledger Feed
- Loading branch information
Showing
34 changed files
with
410 additions
and
10,874 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
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,29 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { TAPi18n } from 'meteor/tap:i18n'; | ||
|
||
import Vote from '/imports/ui/components/Vote/Vote.jsx'; | ||
|
||
/** | ||
* @summary displays the contents of a poll | ||
*/ | ||
const Ledger = () => { | ||
return ( | ||
<div> | ||
<div className="ledger-title"> | ||
<h4>{TAPi18n.__('recent-activity')}</h4> | ||
</div> | ||
<Vote /> | ||
<div className="ledger-footer" /> | ||
</div> | ||
); | ||
}; | ||
|
||
Ledger.propTypes = { | ||
children: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node, | ||
]), | ||
}; | ||
|
||
export default Ledger; |
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,5 @@ | ||
<template name="ledger"> | ||
<div> | ||
{{> React component=Ledger}} | ||
</div> | ||
</template> |
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,12 @@ | ||
import { Template } from 'meteor/templating'; | ||
|
||
import Ledger from '/imports/ui/components/Ledger/Ledger.jsx'; | ||
|
||
import '/imports/ui/components/Ledger/ledger.html'; | ||
|
||
Template.ledger.helpers({ | ||
Ledger() { | ||
return Ledger; | ||
}, | ||
}); | ||
|
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
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,52 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { TAPi18n } from 'meteor/tap:i18n'; | ||
import parser from 'html-react-parser'; | ||
|
||
import { defaults } from '/lib/const'; | ||
import { getDescription } from '/imports/ui/components/Post/Post.jsx'; | ||
|
||
const numeral = require('numeral'); | ||
|
||
/** | ||
* @summary displays the contents of a poll | ||
*/ | ||
export default class Transaction extends Component { | ||
getVote() { | ||
const label = (this.props.quantity.toNumber() === 1) ? 'share' : 'shares'; | ||
|
||
const title = `<em>${getDescription(this.props.description).title}</em>`; | ||
|
||
switch (this.props.uintVote) { | ||
case defaults.YES: | ||
return ( | ||
<div href={this.props.uintVote} className="transaction-action transaction-action-passed"> | ||
{parser(TAPi18n.__('voted-yes').replace('{{shares}}', numeral(this.props.quantity).format('0,0')).replace('{{label}}', label).replace('{{proposal}}', title))} | ||
</div> | ||
); | ||
case defaults.NO: | ||
return ( | ||
<div href={this.props.uintVote} className="transaction-action transaction-action-rejected"> | ||
{parser(TAPi18n.__('voted-no').replace('{{shares}}', numeral(this.props.quantity).format('0,0')).replace('{{label}}', label).replace('{{proposal}}', title))} | ||
</div> | ||
); | ||
default: | ||
} | ||
return null; | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="preview-info"> | ||
{this.getVote()} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Transaction.propTypes = { | ||
uintVote: PropTypes.number, | ||
quantity: PropTypes.string, | ||
description: PropTypes.string, | ||
}; | ||
|
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,87 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import React from 'react'; | ||
|
||
import ApolloClient, { gql, InMemoryCache } from 'apollo-boost'; | ||
import { ApolloProvider } from 'react-apollo'; | ||
import { useQuery } from '@apollo/react-hooks'; | ||
|
||
import Account from '/imports/ui/components/Account/Account.jsx'; | ||
import DAO from '/imports/ui/components/DAO/DAO.jsx'; | ||
import Stamp from '/imports/ui/components/Stamp/Stamp.jsx'; | ||
import Transaction from '/imports/ui/components/Transaction/Transaction.jsx'; | ||
|
||
const client = new ApolloClient({ | ||
uri: Meteor.settings.public.graph.molochs, | ||
cache: new InMemoryCache(), | ||
}); | ||
|
||
const GET_VOTES = gql` | ||
{ | ||
votes(first: 7, orderBy:createdAt, orderDirection:desc) { | ||
id | ||
createdAt | ||
uintVote | ||
molochAddress | ||
memberAddress | ||
proposal { | ||
details | ||
id | ||
} | ||
member { | ||
shares | ||
} | ||
} | ||
} | ||
`; | ||
|
||
|
||
/** | ||
* @summary displays the contents of a poll | ||
*/ | ||
/** | ||
* @summary graph query of token | ||
* @param {string} publicAddress of the token contract | ||
* @param {string} quantity with a big number | ||
* @param {string} symbol with a ticker | ||
* @param {string} decimal numbers this token takes | ||
*/ | ||
const VoteQuery = () => { | ||
const { loading, error, data } = useQuery(GET_VOTES); | ||
|
||
console.log(data); | ||
|
||
if (loading) { | ||
return ( | ||
<div className="token"> | ||
<div className="token-ticker"> | ||
<div className="option-placeholder token-placeholder" /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
if (error) return `Error! ${error}`; | ||
|
||
return data.votes.map((vote) => { | ||
return ( | ||
<div className="event-vote"> | ||
<Account publicAddress={vote.memberAddress} width="16px" height="16px" /> | ||
<DAO publicAddress={vote.molochAddress} width="16px" height="16px" /> | ||
<Transaction uintVote={vote.uintVote} description={vote.proposal.details} quantity={vote.member.shares} /> | ||
<Stamp timestamp={vote.createdAt} format="timeSince" /> | ||
</div> | ||
); | ||
}); | ||
}; | ||
|
||
/** | ||
* @summary renders a post in the timeline | ||
*/ | ||
const Vote = () => { | ||
return ( | ||
<ApolloProvider client={client}> | ||
<VoteQuery /> | ||
</ApolloProvider> | ||
); | ||
}; | ||
|
||
export default Vote; |
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,5 @@ | ||
<template name="vote"> | ||
<div> | ||
{{> React component=Vote}} | ||
</div> | ||
</template> |
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,12 @@ | ||
import { Template } from 'meteor/templating'; | ||
|
||
import Vote from '/imports/ui/components/Vote/Vote.jsx'; | ||
|
||
import '/imports/ui/components/Vote/vote.html'; | ||
|
||
Template.vote.helpers({ | ||
Vote() { | ||
return Vote; | ||
}, | ||
}); | ||
|
Oops, something went wrong.