Skip to content

Commit 6d25648

Browse files
committed
Hide vote buttons for non-registered nodes
1 parent 3bf70bd commit 6d25648

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

src/pages/Index.vue

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,22 @@
122122
<div class="row q-pb-md q-col-gutter-xl">
123123
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
124124
<q-banner inline-actions class="bg-vdark text-vgrey q-mb-sm">
125-
<div class="text-italic">
126-
List of nodes on the network.
127-
<q-btn flat round size="sm" color="vgreen" icon="fas fa-question" class="">
128-
<q-tooltip content-class="bg-vgreen text-vdark" content-style="font-size: 16px" :offset="[10, 10]">List of the nodes is automatically updated every 5 minutes</q-tooltip>
129-
</q-btn>
125+
<div class="row">
126+
<div class="col">
127+
<div class="text-italic">
128+
List of nodes on the network.
129+
<q-btn flat round size="sm" color="vgreen" icon="fas fa-question" class="">
130+
<q-tooltip content-class="bg-vgreen text-vdark" content-style="font-size: 16px" :offset="[10, 10]">List of the nodes is automatically updated every 5 minutes</q-tooltip>
131+
</q-btn>
132+
</div>
133+
<div class="text-italic text-caption">*You are required to vote for 21 nodes per day to activate the distribution of VTX.</div>
134+
</div>
135+
<div class="col">
136+
<div class="col bg-blue-grey">Running nodes: {{ running_nodes }}</div>
137+
<div class="col bg-blue-grey">Registered nodes: {{ registered_nodes }}</div>
138+
</div>
130139
</div>
131-
<div class="text-italic text-caption">*You are required to vote for 21 nodes per day to activate the distribution of VTX.</div>
140+
132141
<template v-slot:action>
133142
<q-btn size="md" outline color="vgreen" label="Rules" class="q-mx-xs" v-on:click="rulesDialog=true" />
134143
<q-btn size="md" outline color="vgreen" icon="fas fa-sync-alt" class="q-mx-xs" v-on:click=refresh />
@@ -142,9 +151,9 @@
142151
<q-item-label class="code text-vgreen" caption> {{ node.account }} </q-item-label>
143152
</q-item-section>
144153
<q-item-section side center>
145-
<q-item-label class="code text-vgreen" caption> {{ node.balance }} </q-item-label>
154+
<q-item-label class="code text-vgreen" caption> {{ node.balance }}</q-item-label>
146155
</q-item-section>
147-
<q-item-section avatar v-if="identity.account_name && node.account != identity.account_name && node.account != 'No account found'">
156+
<q-item-section avatar v-if="identity.account_name && node.vote && node.account != identity.account_name">
148157
<q-btn outline color="vgreen" v-on:click="addToVote(node)" v-if="!voting_list.includes(node) ">Vote</q-btn>
149158
<q-btn color="vgreen" class="text-vdark" v-on:click="addToVote(node)" v-if="voting_list.includes(node)">Vote</q-btn>
150159
</q-item-section>
@@ -436,6 +445,9 @@ export default {
436445
rulesDialog: false,
437446
isPwd: true,
438447
isPrvt: true,
448+
running_nodes: 0,
449+
registered_nodes: 0,
450+
registered_nodes_names: [],
439451
privateState: 'none',
440452
geoData: 'test'
441453
}
@@ -477,7 +489,6 @@ export default {
477489
try {
478490
const eos = new EosWrapper()
479491
const result = await eos.getTable('vdexdposvote', 'vdexdposvote', 'producers')
480-
481492
let nodeStats = result.find(row => row.owner === accountName)
482493
if (nodeStats) {
483494
this.identity.account_registered = true
@@ -517,6 +528,20 @@ export default {
517528
this.errorDialog = true
518529
}
519530
},
531+
async getRegisteredNodes () {
532+
try {
533+
const eos = new EosWrapper()
534+
const result = await eos.getTable('vdexdposvote', 'vdexdposvote', 'producers')
535+
this.registered_nodes = result.length
536+
var self = this
537+
result.forEach(function (item) {
538+
self.registered_nodes_names.push(item.owner)
539+
})
540+
} catch (error) {
541+
this.errorMessage = error
542+
this.errorDialog = true
543+
}
544+
},
520545
refresher () {
521546
if (this.identity.account_name) {
522547
this.getBalance()
@@ -666,6 +691,8 @@ export default {
666691
}
667692
},
668693
refresh () {
694+
this.running_nodes = 0
695+
this.registered_nodes = 0
669696
this.nodes = []
670697
this.voting_list = []
671698
this.getListOfNodes()
@@ -764,6 +791,8 @@ export default {
764791
async getListOfNodes () {
765792
await this.getNodes()
766793
const eos = new EosWrapper()
794+
this.running_nodes = this.nodes.length
795+
this.getRegisteredNodes()
767796
for (var id in this.nodes) {
768797
// this.getAccountByKey(id, this.nodes[id].key)
769798
this.getAccountName(id, this.nodes[id].key, eos)
@@ -774,7 +803,7 @@ export default {
774803
this.$http.get(process.env.NODES_API + '/getConnectedNodes').then((result) => {
775804
for (var key in result.data) {
776805
if (result.data[key].includes('EOS')) {
777-
this.nodes.push({ id: key, key: result.data[key].trim(), account: '' })
806+
this.nodes.push({ id: key, key: result.data[key].trim(), account: '', vote: true })
778807
}
779808
}
780809
this.nodes = utils.getUnique(this.nodes, 'key')
@@ -794,9 +823,15 @@ export default {
794823
let balance = await eos.getBalance(name)
795824
this.nodes[id].account = name
796825
this.nodes[id].balance = balance[0] ? balance[0] : '0 VTX'
826+
if (this.registered_nodes_names.includes(name)) {
827+
this.nodes[id].vote = true
828+
} else {
829+
this.nodes[id].vote = false
830+
}
797831
} else {
798832
this.nodes[id].account = 'No account found'
799833
this.nodes[id].balance = ''
834+
this.nodes[id].vote = false
800835
}
801836
} catch (error) {
802837
this.errorMessage = error

0 commit comments

Comments
 (0)