improve governance

This commit is contained in:
liangping 2022-11-06 17:35:44 +08:00
parent 37d0ec4aa3
commit 8aafe3c5f6
5 changed files with 247 additions and 191 deletions

View File

@ -22,3 +22,28 @@
.progress { .progress {
border-radius: 3px; border-radius: 3px;
} }
.scale {
width: 100%;
height: 3em;
position: relative;
/* margin: 30px; // */
}
.box {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
padding-top: 0.5em;
/* opacity: 0.7; /**/
background: transparent;
}
.overlay {
z-index: 9;
width: 2px;
border-right-color: green;
border-right-width: 2px;
border-right-style: dotted;
}

View File

@ -138,6 +138,7 @@
:max="totalPower? 100 * (totalPower/prop.tally.total) :100" :max="totalPower? 100 * (totalPower/prop.tally.total) :100"
height="2rem" height="2rem"
show-progress show-progress
class="font-small-1"
> >
<b-progress-bar <b-progress-bar
:id="'vote-yes'+prop.id" :id="'vote-yes'+prop.id"
@ -148,14 +149,14 @@
/> />
<b-progress-bar <b-progress-bar
:id="'vote-no'+prop.id" :id="'vote-no'+prop.id"
variant="warning" variant="danger"
:value="percent(prop.tally.no)" :value="percent(prop.tally.no)"
:label="`${percent(prop.tally.no).toFixed()}%`" :label="`${percent(prop.tally.no).toFixed()}%`"
show-progress show-progress
/> />
<b-progress-bar <b-progress-bar
:id="'vote-veto'+prop.id" :id="'vote-veto'+prop.id"
variant="danger" class="bg-danger bg-darken-4"
:value="percent(prop.tally.veto)" :value="percent(prop.tally.veto)"
:label="`${percent(prop.tally.veto).toFixed()}%`" :label="`${percent(prop.tally.veto).toFixed()}%`"
show-progress show-progress
@ -171,7 +172,7 @@
</div> </div>
<div <div
class="box overlay" class="box overlay"
:style="`width:${scaleWidth(prop.tally)}%`" :style="`left:${scaleWidth(prop.tally)}%;`"
/> />
</div> </div>
<b-tooltip <b-tooltip
@ -195,7 +196,10 @@
{{ percent(prop.tally.abstain) }}% voters voted Abstain {{ percent(prop.tally.abstain) }}% voters voted Abstain
</b-tooltip> </b-tooltip>
</b-col> </b-col>
<b-col cols="4"> <b-col
cols="4"
style="padding-top: 0.5em"
>
<b-button <b-button
v-b-modal.operation-modal v-b-modal.operation-modal
variant="primary" variant="primary"
@ -794,28 +798,4 @@ export default {
.addzone :hover { .addzone :hover {
border: 2px dashed #7367F0; border: 2px dashed #7367F0;
} }
.scale {
width: 100%;
height: 3em;
position: relative;
/* margin: 30px; // */
}
.box {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
padding-top: 0.5em;
/* opacity: 0.7; */
background: transparent;
}
.overlay {
z-index: 9;
border-right-color: green;
border-right-width: 2px;
border-right-style: dotted;
background: transparent;
}
</style> </style>

View File

@ -10,6 +10,7 @@
<proposal-summary-component <proposal-summary-component
:p="p" :p="p"
:total-power="totalPower" :total-power="totalPower"
:tally-param="tallyParam"
/> />
</b-col> </b-col>
</b-row> </b-row>
@ -68,9 +69,13 @@ export default {
operationModalType: '', operationModalType: '',
next: '', next: '',
totalPower: 0, totalPower: 0,
tallyParam: null,
} }
}, },
mounted() { mounted() {
this.$http.getGovernanceParameterTallying().then(res => {
this.tallyParam = res
})
this.getList() this.getList()
}, },
methods: { methods: {

View File

@ -112,6 +112,9 @@
</b-card-title> </b-card-title>
</b-card-header> </b-card-header>
<b-card-body> <b-card-body>
<div>
<div class="scale">
<div class="box">
<b-progress <b-progress
:max="totalPower && proposal.status ===2? 100 * (totalPower/proposal.tally.total) :100" :max="totalPower && proposal.status ===2? 100 * (totalPower/proposal.tally.total) :100"
height="2rem" height="2rem"
@ -127,14 +130,14 @@
/> />
<b-progress-bar <b-progress-bar
:id="'vote-no'+proposal.id" :id="'vote-no'+proposal.id"
variant="warning" variant="danger"
:value="percent(proposal.tally.no)" :value="percent(proposal.tally.no)"
:label="`${percent(proposal.tally.no).toFixed()}%`" :label="`${percent(proposal.tally.no).toFixed()}%`"
show-progress show-progress
/> />
<b-progress-bar <b-progress-bar
:id="'vote-veto'+proposal.id" :id="'vote-veto'+proposal.id"
variant="danger" class="bg-danger bg-darken-4"
:value="percent(proposal.tally.veto)" :value="percent(proposal.tally.veto)"
:label="`${percent(proposal.tally.veto).toFixed()}%`" :label="`${percent(proposal.tally.veto).toFixed()}%`"
show-progress show-progress
@ -167,6 +170,14 @@
> >
{{ percent(proposal.tally.abstain) }}% voted Abstain {{ percent(proposal.tally.abstain) }}% voted Abstain
</b-tooltip> </b-tooltip>
<div
v-if="tallyParam"
class="box overlay"
:style="`left:${scaleWidth(proposal)}%;`"
/>
</div>
</div>
<b-table <b-table
v-if="votes.votes && votes.votes.length > 0" v-if="votes.votes && votes.votes.length > 0"
stacked="sm" stacked="sm"
@ -188,7 +199,7 @@
<feather-icon icon="PlusIcon" /> <feather-icon icon="PlusIcon" />
Load More Votes Load More Votes
</div> </div>
</b-card-body> </div></b-card-body>
</b-card> </b-card>
<b-card <b-card
v-if="proposal.total_deposit" v-if="proposal.total_deposit"
@ -290,6 +301,7 @@ export default {
}, },
data() { data() {
return { return {
tallyParam: null,
latest: {}, latest: {},
next: null, next: null,
proposal: new Proposal(), proposal: new Proposal(),
@ -357,6 +369,9 @@ export default {
}, },
}, },
created() { created() {
this.$http.getGovernanceParameterTallying().then(res => {
this.tallyParam = res
})
const pid = this.$route.params.proposalid const pid = this.$route.params.proposalid
if (this.$route.query.from) { if (this.$route.query.from) {
this.from = this.$route.query.from this.from = this.$route.query.from
@ -392,6 +407,15 @@ export default {
}) })
}, },
methods: { methods: {
scaleWidth(p) {
if (this.tallyParam) {
if (p.status === 2) {
return Number(this.tallyParam.quorum) * Number(this.tallyParam.threshold) * 100
}
return Number(this.tallyParam.threshold) * 100
}
return 50
},
percent: v => percent(v), percent: v => percent(v),
formatDate: v => dayjs(v).format('YYYY-MM-DD HH:mm'), formatDate: v => dayjs(v).format('YYYY-MM-DD HH:mm'),
formatToken: v => tokenFormatter(v, {}), formatToken: v => tokenFormatter(v, {}),

View File

@ -63,7 +63,9 @@
</h6> </h6>
</div> </div>
</div> </div>
<div>
<div class="scale">
<div class="box">
<b-progress <b-progress
:max="totalPower && p.status === 2? 100 * (totalPower/p.tally.total) :100" :max="totalPower && p.status === 2? 100 * (totalPower/p.tally.total) :100"
height="2rem" height="2rem"
@ -79,14 +81,14 @@
/> />
<b-progress-bar <b-progress-bar
:id="'vote-no'+p.id" :id="'vote-no'+p.id"
variant="warning" variant="danger"
:value="percent(p.tally.no)" :value="percent(p.tally.no)"
:label="`${percent(p.tally.no).toFixed()}%`" :label="`${percent(p.tally.no).toFixed()}%`"
show-progress show-progress
/> />
<b-progress-bar <b-progress-bar
:id="'vote-veto'+p.id" :id="'vote-veto'+p.id"
variant="danger" class="bg-danger bg-darken-4"
:value="percent(p.tally.veto)" :value="percent(p.tally.veto)"
:label="`${percent(p.tally.veto).toFixed()}%`" :label="`${percent(p.tally.veto).toFixed()}%`"
show-progress show-progress
@ -99,6 +101,12 @@
show-progress show-progress
/> />
</b-progress> </b-progress>
<div
v-if="tallyParam"
class="box overlay"
:style="`left:${scaleWidth(p)}%;`"
/>
</div>
<b-tooltip <b-tooltip
:target="'vote-yes'+p.id" :target="'vote-yes'+p.id"
> >
@ -119,6 +127,7 @@
> >
{{ percent(p.tally.abstain) }}% voted Abstain {{ percent(p.tally.abstain) }}% voted Abstain
</b-tooltip> </b-tooltip>
</div>
<b-card-footer class="pb-0"> <b-card-footer class="pb-0">
<router-link <router-link
v-ripple.400="'rgba(113, 102, 240, 0.15)'" v-ripple.400="'rgba(113, 102, 240, 0.15)'"
@ -152,7 +161,7 @@
{{ $t('btn_vote') }} {{ $t('btn_vote') }}
</b-button> </b-button>
</b-card-footer> </b-card-footer>
</b-card> </div></b-card>
</template> </template>
<script> <script>
@ -191,8 +200,21 @@ export default {
type: Number, type: Number,
default: 0, default: 0,
}, },
tallyParam: {
type: Object,
default: null,
},
}, },
methods: { methods: {
scaleWidth(p) {
if (this.tallyParam) {
if (p.status === 2) {
return Number(this.tallyParam.quorum) * Number(this.tallyParam.threshold) * 100
}
return Number(this.tallyParam.threshold) * 100
}
return 50
},
selectProposal(modal, pid, title) { selectProposal(modal, pid, title) {
this.$parent.operationModalType = modal this.$parent.operationModalType = modal
this.$parent.selectedProposalId = Number(pid) this.$parent.selectedProposalId = Number(pid)