add height

This commit is contained in:
liangping 2021-11-13 20:33:19 +08:00
parent d618eae534
commit 9c2bd64458

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="px-0"> <div class="px-0">
<b-card> <b-card>
<b-card-title class="text-uppercase"> <b-card-title class="d-flex justify-content-between">
{{ chain }} <span class="text-uppercase"> {{ chain }} </span><small class="text-right"> Height: {{ height }} </small>
</b-card-title> </b-card-title>
<b-alert <b-alert
variant="danger" variant="danger"
@ -90,6 +90,7 @@ export default {
blocks: Array.from('0'.repeat(50)).map(x => ({ sigs: {}, height: Number(x) })), blocks: Array.from('0'.repeat(50)).map(x => ({ sigs: {}, height: Number(x) })),
syncing: false, syncing: false,
latestTime: '', latestTime: '',
height: '-',
} }
}, },
computed: { computed: {
@ -113,6 +114,7 @@ export default {
initBlocks() { initBlocks() {
this.$http.getLatestBlock(this.config).then(d => { this.$http.getLatestBlock(this.config).then(d => {
const { height } = d.block.last_commit const { height } = d.block.last_commit
this.height = height
if (timeIn(d.block.header.time, 3, 'm')) { if (timeIn(d.block.header.time, 3, 'm')) {
this.syncing = true this.syncing = true
} else { } else {
@ -167,6 +169,7 @@ export default {
res.block.last_commit.signatures.forEach(x => { res.block.last_commit.signatures.forEach(x => {
if (x.validator_address) sigs[x.validator_address] = 'bg-success' if (x.validator_address) sigs[x.validator_address] = 'bg-success'
}) })
this.height = res.block.last_commit.height
const block = this.blocks.find(b => b[1] === res.block.last_commit.height) const block = this.blocks.find(b => b[1] === res.block.last_commit.height)
if (typeof block === 'undefined') { // mei if (typeof block === 'undefined') { // mei
// this.$set(block, 0, typeof sigs !== 'undefined') // this.$set(block, 0, typeof sigs !== 'undefined')