Skip to content

Commit

Permalink
udpate node list url
Browse files Browse the repository at this point in the history
  • Loading branch information
MickWang committed Aug 1, 2019
1 parent d2dfedb commit 88a1046
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<span class="label font-medium-black">{{$t('nodeMgmt.inAuthorization')}}: </span>
<span class="font-medium">{{authorizationInfo.inAuthorization}} ONT</span>
<a-tooltip placement="top" :title="$t('nodeMgmt.refresh')">
<span class="refresh-icon" @click="handleRefresh"><a-icon type="reload" /></span>
<span class="common-icon refresh-icon" @click="handleRefresh"></span>
</a-tooltip>
</div>
<div>
Expand Down
25 changes: 19 additions & 6 deletions src/renderer/components/Node/NodeAuthorize/NodeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
font-size:18px;
cursor: pointer;
}
.node-name {
/* color: #227EEC !important; */
}
.node-name:hover {
color: #227EEC !important;
}
</style>
<template>
<div>
Expand Down Expand Up @@ -82,7 +88,7 @@
<a-icon type="info-circle-o" class="proportion-info-icon" @click="showProportionTip"/>
</p>
</div>
<a slot="name" slot-scope="text, record" :class="record.status ===2 ? 'node-consensus' : 'node-candidate' "
<a slot="name" slot-scope="text, record" class="node-name" :class="record.status ===2 ? 'node-consensus' : 'node-candidate' "
@click="handleNodeDetail(record)">

<a-tooltip placement="top" :title="$t('nodeMgmt.consensusNode')">
Expand Down Expand Up @@ -159,10 +165,16 @@ export default {
//loop to fetch data
// this.$store.dispatch('showLoadingModals');
this.requesting = true;
this.$store.dispatch('fetchAllSortedNodeList').then(res => {
this.pagination.total = res.length;
this.fetchList()
})
const net = localStorage.getItem('net')
if(net === 'TEST_NET') {
this.$store.dispatch('fetchAllSortedNodeList').then(res => {
this.pagination.total = res.length;
this.fetchList()
})
} else {
this.fetchList()
}
this.$store.dispatch('fetchBlockCountdown')
this.intervalId = setInterval(()=>{
// this.$store.dispatch('fetchNodeList')
Expand Down Expand Up @@ -199,11 +211,12 @@ export default {
},
fetchList() {
this.requesting = true;
this.$store.dispatch('fetchNodeList', {
this.$store.dispatch('fetchNodeListNew', {
pageSize: this.pagination.pageSize,
pageNum: this.pagination.current - 1
}).then(res => {
this.requesting = false;
this.pagination.total = res;
})
},
showProportionTip() {
Expand Down
43 changes: 41 additions & 2 deletions src/renderer/store/modules/NodeAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,50 @@ const actions = {

commit('UPDATE_NODE_LIST', {list});
dispatch('hideLoadingModals')
return list;
return list.length;
} catch(err) {
console.log(err)
dispatch('hideLoadingModals')
return [];
return 0;
}
},

async fetchNodeListNew({commit, dispatch}, {pageSize, pageNum}) {
const net = localStorage.getItem('net')
if(net === 'TEST_NET') {
return dispatch('fetchNodeList', {pageSize, pageNum})
} else {
try {
const url = 'https://explorer.ont.io/v2/nodes/current-stakes'
const res = await axios.get(url)
console.log(res)
if(res.data.code === 0 && res.data.result) {
const result = res.data.result;
const total = result.length;
const list = result.slice(pageNum * pageSize, (pageNum + 1) * pageSize).map(item => {
item.rank = item.node_rank;
item.nodeProportion = item.node_proportion;
item.currentStake = numeral(item.current_stake).format('0,0');
item.process = item.progress;
item.maxAuthorize = item.max_authorize;
item.maxAuthorizeStr = numeral(item.max_authorize).format('0,0')
item.totalPos = item.total_pos;
item.initPos = item.init_pos;
item.pk = item.public_key;
item.detailUrl = item.detail_url;
item.totalPosStr = numeral(item.totalPos).format('0,0')
return item;
})
commit('UPDATE_NODE_LIST', {list})
return total;
} else {
return 0;
}
}catch(err) {
console.log(err)
dispatch('hideLoadingModals')
return 0;
}
}
},
async fetchBlockCountdown({commit}) {
Expand Down

0 comments on commit 88a1046

Please sign in to comment.