From a32948727e62a1a90bd86754bb2c1eb75c9ee306 Mon Sep 17 00:00:00 2001 From: Zhou Date: Thu, 16 May 2019 11:28:27 +0800 Subject: [PATCH 01/27] fit on small screen --- frontend/src/views/Referendum.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/Referendum.vue b/frontend/src/views/Referendum.vue index 0de71be..d5f0471 100644 --- a/frontend/src/views/Referendum.vue +++ b/frontend/src/views/Referendum.vue @@ -164,7 +164,7 @@ :desc="prop.proposal.proposal_json.content || ''" :votes="prop.stats.staked" :staked="prop.stats.staked.total" - :style="{margin: '25px'}"> + class="prop-card"> @@ -484,6 +484,8 @@ export default { display flex flex-wrap wrap justify-content flex-start +.prop-card + margin 25px .card font-family: Roboto-Regular font-size 18px @@ -524,5 +526,9 @@ export default { display flex flex-wrap wrap justify-content flex-end - +@media only screen and (max-width 450px) + .prop-card + margin 25px 0 + .prop-list + justify-content center From 50d078569116ad737f499af98d14d487d094dad6 Mon Sep 17 00:00:00 2001 From: Zhou Date: Thu, 16 May 2019 22:18:11 +0800 Subject: [PATCH 02/27] format number --- frontend/src/components/Comment.vue | 2 +- frontend/src/components/PropCard.vue | 2 +- frontend/src/main.js | 2 + frontend/src/plugins/element.js | 5 +- frontend/src/util.js | 23 +++++ frontend/src/views/PollDetail.vue | 121 +++++++++++++++++---------- frontend/src/views/Referendum.vue | 24 ++++-- 7 files changed, 127 insertions(+), 52 deletions(-) create mode 100644 frontend/src/util.js diff --git a/frontend/src/components/Comment.vue b/frontend/src/components/Comment.vue index 759dbba..da2de4a 100644 --- a/frontend/src/components/Comment.vue +++ b/frontend/src/components/Comment.vue @@ -6,7 +6,7 @@

{{name}}

-

{{time}}

+

{{$util.dateConvert(time)}}

{{comment}}
diff --git a/frontend/src/components/PropCard.vue b/frontend/src/components/PropCard.vue index e94ac13..08519fd 100644 --- a/frontend/src/components/PropCard.vue +++ b/frontend/src/components/PropCard.vue @@ -19,7 +19,7 @@
-

{{(staked / 10000).toFixed(0)}} BOS voted

+

{{$util.toThousands((staked / 10000).toFixed(0))}} BOS voted

diff --git a/frontend/src/main.js b/frontend/src/main.js index 9add82d..a828331 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -7,9 +7,11 @@ import VueI18n from 'vue-i18n' import messages from '@/language' import '@/assets/common.styl' import axios from 'axios' +import util from '@/util.js' Vue.config.productionTip = false Vue.prototype.$axios = axios +Vue.prototype.$util = util Vue.use(VueI18n) diff --git a/frontend/src/plugins/element.js b/frontend/src/plugins/element.js index 00162b5..a5563fb 100644 --- a/frontend/src/plugins/element.js +++ b/frontend/src/plugins/element.js @@ -26,7 +26,8 @@ import { Tabs, TabPane, Table, - TableColumn + TableColumn, + Tag } from 'element-ui' import lang from 'element-ui/lib/locale/lang/en' import locale from 'element-ui/lib/locale' @@ -57,6 +58,8 @@ Vue.use(TabPane) Vue.use(Table) Vue.use(TableColumn) +Vue.use(Tag) + Vue.use(Form) Vue.use(FormItem) Vue.use(Select) diff --git a/frontend/src/util.js b/frontend/src/util.js new file mode 100644 index 0000000..adeb911 --- /dev/null +++ b/frontend/src/util.js @@ -0,0 +1,23 @@ +// date String +function dateConvert (date) { + // convert date to current time zone + const diff = new Date().getTimezoneOffset() + const newDateTime = new Date(date).getTime() + (diff * 60 * 1000) + const newDate = new Date(newDateTime) + function formatNumber (n) { + if (n < 10) { + return '0' + n + } + return n + } + return `${newDate.getFullYear()}-${formatNumber(newDate.getMonth())}-${formatNumber(newDate.getDate())} ${formatNumber(newDate.getHours())}:${formatNumber(newDate.getMinutes())}` +} + +function toThousands (num) { + return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') +} + +export default { + dateConvert, + toThousands +} diff --git a/frontend/src/views/PollDetail.vue b/frontend/src/views/PollDetail.vue index de73958..d427822 100644 --- a/frontend/src/views/PollDetail.vue +++ b/frontend/src/views/PollDetail.vue @@ -11,9 +11,13 @@

The countdown to BPs voting ends in {{CDToBP}} days

{{`${proposal.proposal.proposal_name} by ${proposal.proposal.proposer} `}} - {{proposal.proposal.expires_at}} - {{proposal.proposal.proposal_json.type || 'unknown'}} - Approved + {{$util.dateConvert(proposal.proposal.expires_at)}} + {{proposal.proposal.proposal_json.type || 'unknown'}} + Approved by accounts + Approved by BET + Approved by BPs + Disapproved by BET + Disapproved by BPs

@@ -91,7 +95,7 @@ -

{{(this.proposal.stats.staked.total / 10000).toFixed(0)}} BOS voted

+

{{$util.toThousands((this.proposal.stats.staked.total / 10000).toFixed(0))}} BOS voted

@@ -340,6 +344,69 @@ export default { return [] } }, + auditorComm () { + let comm = [] + this.votes.forEach(vote => { + if (vote.vote_json && vote.vote_json.comment) { + let comment = { + avatar: '', + name: vote.voter, + time: vote.updated_at, + comment: vote.vote_json.comment + } + let isAuditor = this.auditorsList.find(auditor => { + return Boolean(auditor.auditor_name === vote.voter) + }) + if (isAuditor) { + comm.push(comment) + } + } + }) + return comm + }, + BPComm () { + let comm = [] + this.votes.forEach(vote => { + if (vote.vote_json && vote.vote_json.comment) { + let comment = { + avatar: '', + name: vote.voter, + time: vote.updated_at, + comment: vote.vote_json.comment + } + let isBP = this.producers.find(producer => { + return Boolean(producer.owner === vote.voter) + }) + if (isBP) { + comm.push(comment) + } + } + }) + return comm + }, + otherComm () { + let comm = [] + this.votes.forEach(vote => { + if (vote.vote_json && vote.vote_json.comment) { + let comment = { + avatar: '', + name: vote.voter, + time: vote.updated_at, + comment: vote.vote_json.comment + } + let isAuditor = this.auditorsList.find(auditor => { + return Boolean(auditor.auditor_name === vote.voter) + }) + let isBP = this.producers.find(producer => { + return Boolean(producer.owner === vote.voter) + }) + if (!isAuditor && !isBP) { + comm.push(comment) + } + } + }) + return comm + }, showVoters () { return this.votes.slice(0, this.showVotersNum) }, @@ -439,8 +506,6 @@ export default { title: 'Should EOS tokens sent to eosio.ramfee and eosio.names accounts in the future be allocated to REX?', activeButton: 'desc', auditorsList: [], - auditorComm: [], - BPComm: [], CDToBP: -1, CDToAuditor: -1, voteActionParams: { @@ -450,7 +515,6 @@ export default { vote_json: '' }, myComment: '', - otherComm: [], producers: [], proposal: { approved_by_BET: false, @@ -486,36 +550,6 @@ export default { screenWidth: document.body.clientWidth } }, - watch: { - votes (newVotes, oldVotes) { - this.auditorComm = [] - this.otherComm = [] - this.BPComm = [] - newVotes.forEach(vote => { - if (vote.vote_json && vote.vote_json.comment) { - let comment = { - avatar: '', - name: vote.voter, - time: vote.updated_at, - comment: vote.vote_json.comment - } - let isAuditor = this.auditorsList.find(auditor => { - return Boolean(auditor.auditor_name === vote.voter) - }) - let isBP = this.producers.find(producer => { - return Boolean(producer.owner === vote.voter) - }) - if (isAuditor) { - this.auditorComm.push(comment) - } else if (isBP) { - this.auditorComm.push(comment) - } else { - this.otherComm.push(comment) - } - } - }) - } - }, created () { this.getProposal() }, @@ -649,7 +683,7 @@ export default { } else { this.voteActionParams.voter = this.account.name this.voteActionParams.proposal_name = this.proposalName - if (this.myComment !== '' && this.writeComment) { + if (this.myComment !== '' && (this.writeComment || this.isAuditor || this.isBP)) { this.voteActionParams.vote_json = JSON.stringify({ comment: this.myComment }) } const transactionOptions = { @@ -858,13 +892,14 @@ export default { width:800px height:500px margin:auto +#related-polls + display flex + flex-wrap wrap + justify-content center @media only screen and (max-width 840px) .main padding 0 .radio-button margin-bottom 5px - #related-polls - display flex - flex-wrap wrap - justify-content center + diff --git a/frontend/src/views/Referendum.vue b/frontend/src/views/Referendum.vue index d5f0471..05cde29 100644 --- a/frontend/src/views/Referendum.vue +++ b/frontend/src/views/Referendum.vue @@ -13,7 +13,7 @@ > - +
@@ -45,8 +45,16 @@

- - + + + + + +