load pagination votes
This commit is contained in:
parent
880999ff9b
commit
f23cb8b440
@ -110,7 +110,7 @@ const proposalInfo = ref();
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td v-if="statusMap?.[item?.status] === 'VOTING'" class="w-40">
|
<td v-if="statusMap?.[item?.status] === 'VOTING'" class="w-40">
|
||||||
<div class="" v-show="item?.voterStatus === 'No With Veto'">
|
<div class="">
|
||||||
<label
|
<label
|
||||||
for="vote"
|
for="vote"
|
||||||
class="btn btn-xs btn-primary rounded-sm"
|
class="btn btn-xs btn-primary rounded-sm"
|
||||||
|
@ -66,7 +66,7 @@ export const DEFAULT: RequestRegistry = {
|
|||||||
adapter,
|
adapter,
|
||||||
},
|
},
|
||||||
gov_proposals_votes: {
|
gov_proposals_votes: {
|
||||||
url: '/cosmos/gov/v1beta1/proposals/{proposal_id}/votes?pagination.key={next_key}',
|
url: '/cosmos/gov/v1beta1/proposals/{proposal_id}/votes',
|
||||||
adapter,
|
adapter,
|
||||||
},
|
},
|
||||||
gov_proposals_votes_voter: {
|
gov_proposals_votes_voter: {
|
||||||
|
@ -116,11 +116,11 @@ export class CosmosRestClient extends BaseRestClient<RequestRegistry> {
|
|||||||
async getGovProposalTally(proposal_id: string) {
|
async getGovProposalTally(proposal_id: string) {
|
||||||
return this.request(this.registry.gov_proposals_tally, { proposal_id });
|
return this.request(this.registry.gov_proposals_tally, { proposal_id });
|
||||||
}
|
}
|
||||||
async getGovProposalVotes(proposal_id: string, next_key?: string) {
|
async getGovProposalVotes(proposal_id: string, page?: PageRequest) {
|
||||||
return this.request(this.registry.gov_proposals_votes, {
|
if(!page) page = new PageRequest()
|
||||||
proposal_id,
|
page.reverse = true
|
||||||
next_key,
|
const query =`?proposal_status={status}&${page.toQueryString()}`;
|
||||||
});
|
return this.request(this.registry.gov_proposals_votes, { proposal_id }, query);
|
||||||
}
|
}
|
||||||
async getGovProposalVotesVoter(proposal_id: string, voter: string) {
|
async getGovProposalVotesVoter(proposal_id: string, voter: string) {
|
||||||
return this.request(this.registry.gov_proposals_votes_voter, {
|
return this.request(this.registry.gov_proposals_votes_voter, {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { computed } from '@vue/reactivity';
|
||||||
import ObjectElement from '@/components/dynamic/ObjectElement.vue';
|
import ObjectElement from '@/components/dynamic/ObjectElement.vue';
|
||||||
import {
|
import {
|
||||||
useBaseStore,
|
useBaseStore,
|
||||||
@ -7,15 +8,16 @@ import {
|
|||||||
useStakingStore,
|
useStakingStore,
|
||||||
useTxDialog,
|
useTxDialog,
|
||||||
} from '@/stores';
|
} from '@/stores';
|
||||||
import type {
|
import {
|
||||||
GovProposal,
|
PageRequest,
|
||||||
GovVote,
|
type GovProposal,
|
||||||
PaginatedProposalDeposit,
|
type GovVote,
|
||||||
Pagination,
|
type PaginatedProposalDeposit,
|
||||||
|
type Pagination,
|
||||||
} from '@/types';
|
} from '@/types';
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive } from 'vue';
|
||||||
import Countdown from '@/components/Countdown.vue';
|
import Countdown from '@/components/Countdown.vue';
|
||||||
import { computed } from '@vue/reactivity';
|
import PaginationBar from '@/components/PaginationBar.vue'
|
||||||
|
|
||||||
const props = defineProps(['proposal_id', 'chain']);
|
const props = defineProps(['proposal_id', 'chain']);
|
||||||
const proposal = ref({} as GovProposal);
|
const proposal = ref({} as GovProposal);
|
||||||
@ -53,27 +55,14 @@ const deposit = ref({} as PaginatedProposalDeposit);
|
|||||||
store.fetchProposalDeposits(props.proposal_id).then((x) => (deposit.value = x));
|
store.fetchProposalDeposits(props.proposal_id).then((x) => (deposit.value = x));
|
||||||
|
|
||||||
const votes = ref({} as GovVote[]);
|
const votes = ref({} as GovVote[]);
|
||||||
const votePage = ref({} as Pagination);
|
const pageRequest = ref(new PageRequest())
|
||||||
const loading = ref(false);
|
const pageResponse = ref({} as Pagination)
|
||||||
|
|
||||||
store.fetchProposalVotes(props.proposal_id).then((x) => {
|
store.fetchProposalVotes(props.proposal_id).then((x) => {
|
||||||
votes.value = x.votes;
|
votes.value = x.votes;
|
||||||
votePage.value = x.pagination;
|
pageResponse.value = x.pagination;
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadMore() {
|
|
||||||
if (votePage.value.next_key) {
|
|
||||||
loading.value = true;
|
|
||||||
store
|
|
||||||
.fetchProposalVotes(props.proposal_id, votePage.value.next_key)
|
|
||||||
.then((x) => {
|
|
||||||
votes.value = votes.value.concat(x.votes);
|
|
||||||
votePage.value = x.pagination;
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function shortTime(v: string) {
|
function shortTime(v: string) {
|
||||||
if (v) {
|
if (v) {
|
||||||
return format.toDay(v, 'from');
|
return format.toDay(v, 'from');
|
||||||
@ -159,6 +148,16 @@ const processList = computed(() => {
|
|||||||
{ name: 'Abstain', value: abstain.value, class: 'bg-warning' },
|
{ name: 'Abstain', value: abstain.value, class: 'bg-warning' },
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function pageload(p: number) {
|
||||||
|
pageRequest.value.setPage(p)
|
||||||
|
store
|
||||||
|
.fetchProposalVotes(props.proposal_id, pageRequest.value)
|
||||||
|
.then((x) => {
|
||||||
|
votes.value = x.votes;
|
||||||
|
pageResponse.value = x.pagination;
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -338,15 +337,7 @@ const processList = computed(() => {
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<PaginationBar :limit="pageRequest.limit" :total="pageResponse.total" :callback="pageload"/>
|
||||||
<button
|
|
||||||
@click="loadMore()"
|
|
||||||
v-if="votePage.next_key"
|
|
||||||
:disabled="loading"
|
|
||||||
class="btn btn-outline btn-primary w-full mt-4"
|
|
||||||
>
|
|
||||||
Load more
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user