add upgrade count down

This commit is contained in:
liangping 2021-12-14 15:18:41 +08:00
parent 06fff024d7
commit 04e152c1fb
4 changed files with 37 additions and 1 deletions

View File

@ -80,6 +80,7 @@
"vue-toastification": "1.7.8", "vue-toastification": "1.7.8",
"vue-tour": "1.5.0", "vue-tour": "1.5.0",
"vue-tree-halower": "1.8.3", "vue-tree-halower": "1.8.3",
"vue2-flip-countdown": "^0.12.1",
"vue2-leaflet": "2.5.2", "vue2-leaflet": "2.5.2",
"vuedraggable": "2.24.3", "vuedraggable": "2.24.3",
"vuex": "3.6.0" "vuex": "3.6.0"

View File

@ -53,6 +53,7 @@
"proposal_content": "Content", "proposal_content": "Content",
"proposal_total_deposit": "Total Deposit", "proposal_total_deposit": "Total Deposit",
"voting_time": "Voting Time", "voting_time": "Voting Time",
"upgrade_time": "Estimated Upgrade Time:",
"btn_vote": "Vote", "btn_vote": "Vote",
"btn_deposit": "Deposit", "btn_deposit": "Deposit",

View File

@ -77,6 +77,11 @@
{{ $t('voting_time') }} {{ $t('voting_time') }}
</b-td><b-td>{{ proposal.voting_start_time }} - {{ proposal.voting_end_time }}</b-td> </b-td><b-td>{{ proposal.voting_start_time }} - {{ proposal.voting_end_time }}</b-td>
</b-tr> </b-tr>
<b-tr v-if="proposal.type === 'cosmos-sdk/SoftwareUpgradeProposal'">
<b-td>
{{ $t('upgrade_time') }}
</b-td><b-td><flip-countdown :deadline="upgradeTime" /></b-td>
</b-tr>
<b-tr> <b-tr>
<b-td> <b-td>
{{ $t('proposal_type') }} {{ $t('proposal_type') }}
@ -257,10 +262,12 @@ import {
BCard, BCardBody, BCardFooter, BButton, BTable, BTableSimple, BTr, BTd, BCardTitle, BCardHeader, BCard, BCardBody, BCardFooter, BButton, BTable, BTableSimple, BTr, BTd, BCardTitle, BCardHeader,
BProgressBar, BProgress, BTooltip, BBadge, BProgressBar, BProgress, BTooltip, BBadge,
} from 'bootstrap-vue' } from 'bootstrap-vue'
import FlipCountdown from 'vue2-flip-countdown'
// import fetch from 'node-fetch' // import fetch from 'node-fetch'
import { getCachedValidators, getStakingValidatorByAccount, tokenFormatter } from '@/libs/data/data' import { getCachedValidators, getStakingValidatorByAccount, tokenFormatter } from '@/libs/data/data'
import { Proposal, Proposer } from '@/libs/data' import { Proposal, Proposer } from '@/libs/data'
import dayjs from 'dayjs'
import ObjectFieldComponent from './ObjectFieldComponent.vue' import ObjectFieldComponent from './ObjectFieldComponent.vue'
import OperationVoteComponent from './OperationVoteComponent.vue' import OperationVoteComponent from './OperationVoteComponent.vue'
import OperationGovDepositComponent from './OperationGovDepositComponent.vue' import OperationGovDepositComponent from './OperationGovDepositComponent.vue'
@ -285,9 +292,11 @@ export default {
ObjectFieldComponent, ObjectFieldComponent,
OperationVoteComponent, OperationVoteComponent,
OperationGovDepositComponent, OperationGovDepositComponent,
FlipCountdown,
}, },
data() { data() {
return { return {
latest: {},
next: null, next: null,
proposal: new Proposal(), proposal: new Proposal(),
proposer: new Proposer(), proposer: new Proposer(),
@ -335,10 +344,28 @@ export default {
], ],
} }
}, },
computed: {
upgradeTime() {
if (this.proposal.type === 'cosmos-sdk/SoftwareUpgradeProposal') {
if (Number(this.proposal?.contents.plan.height || 0) > 0 && this.latest) {
const blocks = Number(this.proposal.contents.plan.height) - Number(this.latest.block?.header?.height || 0)
if (blocks > 0) {
const endtime = dayjs().add(blocks * 6, 'second').format('YYYY-MM-DD HH:mm:ss')
return endtime
}
}
return dayjs(this.proposal.contents.plan.time).format('YYYY-MM-DD HH:mm:ss')
}
return '0001-01-01 00:00:00'
},
},
created() { created() {
const pid = this.$route.params.proposalid const pid = this.$route.params.proposalid
this.$http.getLatestBlock().then(res => {
this.latest = res
})
this.$http.getGovernance(pid).then(p => { this.$http.getGovernance(pid).then(p => {
if (p.status === 2) { if (p.status === 2) {
this.$http.getGovernanceTally(pid, 0).then(t => p.updateTally(t)) this.$http.getGovernanceTally(pid, 0).then(t => p.updateTally(t))

View File

@ -11896,6 +11896,13 @@ vue-tree-halower@1.8.3:
dependencies: dependencies:
vue "^2.4.4" vue "^2.4.4"
vue2-flip-countdown@^0.12.1:
version "0.12.1"
resolved "https://registry.yarnpkg.com/vue2-flip-countdown/-/vue2-flip-countdown-0.12.1.tgz#67d115634df1fbcf789be07e2674b1a6aefb4e7f"
integrity sha512-kS3A86VMUjsG2FGnqv/AO4UTLKAAwutqh1dOTPfjSRiUfsgLO+9gmhLSeo+qSBoQYpCxccq44G/IsoRef8kywQ==
dependencies:
uuid "^3.3.2"
vue2-leaflet@2.5.2: vue2-leaflet@2.5.2:
version "2.5.2" version "2.5.2"
resolved "https://registry.npmjs.org/vue2-leaflet/-/vue2-leaflet-2.5.2.tgz" resolved "https://registry.npmjs.org/vue2-leaflet/-/vue2-leaflet-2.5.2.tgz"