Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented blocks page #337

Merged
merged 41 commits into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
17fdec5
bring back blockchain.js
jbibla Jan 8, 2018
a915929
setup pageblock
jbibla Jan 8, 2018
657819e
cleaning up netmon page
jbibla Jan 9, 2018
3a580f3
improve NiDataEmpty to allow for props, improve NiListItem to show links
jbibla Jan 9, 2018
115a08e
show EmptyBlock message when no transaction data
jbibla Jan 9, 2018
aaed2b5
page block title
jbibla Jan 9, 2018
2d70348
add node count to connectivity with TODO
jbibla Jan 9, 2018
e202dc5
got monitor / blockchain stats working
jbibla Jan 9, 2018
53636cd
readded the node ip to the node object
faboweb Jan 9, 2018
057049a
removed proposal mutations as they are not used
faboweb Jan 9, 2018
3debcbd
Merge pull request #339 from cosmos/fabo/336-return-the-nodeip
jbibla Jan 9, 2018
132dea6
added user module tests and refactored
faboweb Jan 9, 2018
50d7220
added notification tests
faboweb Jan 9, 2018
b30f245
reverted change in NiSession
faboweb Jan 9, 2018
ff746e7
fixed sign in tests
faboweb Jan 10, 2018
b2d8f1c
fixed node mock being mutable
faboweb Jan 10, 2018
1e13791
added more test coverage
faboweb Jan 10, 2018
bd01cdd
fixed tests
faboweb Jan 10, 2018
c9e2f23
fixed error in bond page
faboweb Jan 10, 2018
6e8ac23
Added 'delegates' module tests
mappum Jan 11, 2018
a7e5218
Remove some unused code in delegation module
mappum Jan 11, 2018
d9c93a9
Added delegation module tests
mappum Jan 11, 2018
884a353
Add 'filters' module tests
mappum Jan 11, 2018
9f569df
Added vuex module index tests
mappum Jan 11, 2018
50ad96a
Merge pull request #347 from cosmos/matt/327-vuex-tests
jbibla Jan 11, 2018
f5bd78d
Merge branch 'develop' into fabo/325-vuex-tests
jbibla Jan 11, 2018
7cea5a5
Merge pull request #343 from cosmos/fabo/325-vuex-tests
jbibla Jan 11, 2018
8e34853
bring back blockchain.js
jbibla Jan 8, 2018
9e63f10
setup pageblock
jbibla Jan 8, 2018
62aedd8
cleaning up netmon page
jbibla Jan 9, 2018
b0c97cc
improve NiDataEmpty to allow for props, improve NiListItem to show links
jbibla Jan 9, 2018
0a1a47a
show EmptyBlock message when no transaction data
jbibla Jan 9, 2018
efd4b5f
page block title
jbibla Jan 9, 2018
2850095
add node count to connectivity with TODO
jbibla Jan 9, 2018
32172d7
got monitor / blockchain stats working
jbibla Jan 9, 2018
04f94e1
changes to main block page
jbibla Jan 9, 2018
3ecef8a
Merge branch 'jordan/29-netmon' of github.com:cosmos/cosmos-ui into j…
jbibla Jan 11, 2018
069af6a
switch from monitor to blocks
jbibla Jan 11, 2018
7333b17
not just for devMode anymore!
jbibla Jan 11, 2018
4c476a4
tendermint rpc sockets aren't working right now
jbibla Jan 12, 2018
4d156fc
fix tests
jbibla Jan 12, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/renderer/components/common/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ menu.app-menu
list-item(to="/staking" exact @click.native="close" title="Delegates")
list-item(to="/validators" exact @click.native="close" title="Validators" v-bind:class="{ 'active': isValidatorPage }")
list-item(to="/proposals" exact @click.native="close" title="Proposals" v-if="config.devMode")
list-item(to="/blockchain" exact @click.native="close" title="Monitor" v-if="config.devMode")
list-item(to="/blockchain" exact @click.native="close" title="Blocks")
connectivity
user-pane
</template>
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/components/common/NiConnectivity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
ListItem
},
computed: {
...mapGetters(['lastHeader', 'nodeIP', 'connected']),
...mapGetters(['lastHeader', 'nodeIP', 'connected', 'validators']),
blockString () {
return `${this.lastHeader.chain_id} (#${num.prettyInt(this.lastHeader.height)})`
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/renderer/components/common/NiDataEmpty.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<template lang="pug">
data-msg(icon="info_outline")
div(slot="title") N/A
div(slot="subtitle") No data available yet.
h4(v-if="title" slot="title") {{ title }}
h4(v-else slot="title") N/A

h5(v-if="subtitle" slot="subtitle") {{ subtitle }}
h5(v-else slot="subtitle") No data available yet.
</template>

<script>
import DataMsg from 'common/NiDataMsg'
export default {
name: 'ni-data-empty',
props: ['title', 'subtitle'],
components: {
DataMsg
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/renderer/components/common/NiListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export default {
background transparent
z-index z(listItem)

.ni-li-dt
.ni-li-dd
color link

&.router-link-exact-active
.ni-li-title
color bright
Expand Down
22 changes: 17 additions & 5 deletions app/src/renderer/components/monitor/PageBlock.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="pug">
page(:title="`Block ${block.header.height}`")
page(:title="pageBlockTitle")
div(slot="menu"): tool-bar
router-link(to="/blockchain")
i.material-icons arrow_back
Expand All @@ -16,7 +16,7 @@ page(:title="`Block ${block.header.height}`")

part(title='Header')
list-item(dt="Chain ID" :dd="block.header.chain_id")
list-item(dt="Time" :dd="block.header.time")
list-item(dt="Time" :dd="blockHeaderTime")
list-item(dt="Transactions" :dd="block.header.num_txs")
list-item(dt="Last Commit Hash" :dd="block.header.last_commit_hash")
list-item(dt="Validators Hash" :dd="block.header.validators_hash")
Expand All @@ -38,29 +38,41 @@ page(:title="`Block ${block.header.height}`")
:dd="p.signature.data")

part(title='Transactions')
list-item(v-for="tx in block.data.txs" :key="tx.id"
dt="Transaction" :dd="TODO")
list-item(v-if="block.header.num_txs > 0" v-for="tx in block.data.txs" :key="tx.id" dt="Transaction" :dd="TODO")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use li-transactions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably show more information at some point, but so should the information in the transactions list.

data-empty(v-if="block.header.num_txs === 0" title="Empty Block" subtitle="There were no transactions in this block.")
</template>

<script>
import { mapGetters } from 'vuex'
import moment from 'moment'
import num from 'scripts/num'
import axios from 'axios'
import DataEmpty from 'common/NiDataEmpty'
import ToolBar from 'common/NiToolBar'
import ListItem from 'common/NiListItem'
import Part from 'common/NiPart'
import Page from 'common/NiPage'
export default {
name: 'page-block',
components: {
DataEmpty,
ToolBar,
ListItem,
Part,
Page
},
computed: {
...mapGetters(['blockchain'])
...mapGetters(['blockchain']),
blockHeaderTime () {
return moment(this.block.header.time).format('MMMM Do YYYY — hh:mm:ss')
},
pageBlockTitle () {
return 'Block #' + num.prettyInt(this.block.header.height)
}
},
data: () => ({
num: num,
moment: moment,
blockUrl: '',
block_meta: {
block_id: {
Expand Down
82 changes: 13 additions & 69 deletions app/src/renderer/components/monitor/PageBlockchain.vue
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
<template lang="pug">
page(title='Blockchain')
page(title='Blocks')
div(slot="menu"): tool-bar
router-link(to="/search" exact)
i.material-icons search
.label Search
a(@click='toggleBlockchainSelect')
i.material-icons(v-if='!config.modals.blockchain.active') filter_list
i.material-icons(v-else='') close
.label Switch Blockchain

blockchain-select-modal

template(v-if="bc")
part(title='Metadata')
list-item(dt='Network' :dd='bc.status.node_info.network')
list-item(dt='App Version' :dd='version')
list-item(dt='Tendermint Version' :dd='bc.status.node_info.version')

part(title='Block')
list-item(dt='Block Height' :dd='num.prettyInt(bc.status.latest_block_height)'
:to="{ name: 'block', params: { block: bc.status.latest_block_height} }")
list-item(dt='Latest Block Time' :dd='readableDate(bc.status.latest_block_time)')
list-item(dt='Latest Block Hash' :dd='bc.status.latest_block_hash')

part(title='Nodes')
list-item(dt='Active Nodes' :dd='validators.length')
list-item(dt='Current Rate' :dd="currentRate + ' bytes/s'")
list-item(dt='Average Rate' :dd="averageRate + ' bytes/s'")

data-error(v-else)
template
part(title='Latest Block')
list-item(dt='Block Height' :dd='num.prettyInt(lastHeader.height)'
:to="{ name: 'block', params: { block: lastHeader.height} }")
list-item(dt='Latest Block Time' :dd='latestBlockTime')
list-item(dt='Latest Block Hash' :dd='status.latest_block_hash')
</template>

<script>
import moment from 'moment'
import num from 'scripts/num'
import { mapGetters } from 'vuex'
import BlockchainSelectModal from 'monitor/BlockchainSelectModal'
import ListItem from 'common/NiListItem'
import DataError from 'common/NiDataError'
import Page from 'common/NiPage'
Expand All @@ -44,57 +21,24 @@ import ToolBar from 'common/NiToolBar'
export default {
name: 'page-blockchain',
components: {
BlockchainSelectModal,
ListItem,
DataError,
Page,
Part,
ToolBar
},
computed: {
...mapGetters(['blockchain', 'config', 'validators']),
bc () { return this.blockchain },
version () {
let v
if (this.bc.blockchainName === 'venus') {
v = this.bc.abciInfo.data
} else {
v = this.bc.abciInfo.data.substring(10, this.bc.abciInfo.data.length)
}
return v
...mapGetters(['blockchain', 'validators', 'lastHeader']),
status () {
return this.blockchain.status
},
avgTxThroughput () {
return Math.round(this.bc.network.avg_tx_throughput * 1000) / 1000
},
currentRate () {
let txs = 0
// this.validators.reduce(txs, v => (txs += v.connection_status.SendMonitor.CurRate))
for (let i = 0; i < this.validators.length; i++) {
txs += this.validators[i].connection_status.SendMonitor.CurRate
}
let average = Math.round(txs / this.validators.length)
return average
},
averageRate () {
let txs = 0
for (let i = 0; i < this.validators.length; i++) {
txs += this.validators[i].connection_status.SendMonitor.AvgRate
}
let average = Math.round(txs / this.validators.length)
return average
latestBlockTime () {
return moment(this.status.latest_block_time).format('MMMM Do YYYY — hh:mm:ss')
}
},
data: () => ({
moment: moment,
num: num
}),
methods: {
readableDate (ms) {
return moment(ms / 1000000).format('HH:mm:ss.SSS')
},
toggleBlockchainSelect () {
this.$store.commit('setModalBlockchain', !this.config.modals.blockchain.active)
}
}
})
}
</script>
4 changes: 2 additions & 2 deletions app/src/renderer/components/staking/PageBond.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ page.page-bond(title="Bond Atoms")
| #[a.reserved-atoms__restart(@click="resetAlloc") &nbsp;(start over?)]

form-struct(:submit="onSubmit")
form-group(v-for='(delegate, index) in fields.delegates' key='delegate.id'
form-group(v-for='(delegate, index) in fields.delegates' :key='delegate.id'
:error="$v.fields.delegates.$each[index].$error")
Label {{ shortenLabel(delegate.delegate.description.moniker, 10) }} - {{ shortenLabel(delegate.delegate.id, 20) }} ({{ percentAtoms(delegate.atoms) }})
field-group
Expand Down Expand Up @@ -183,7 +183,7 @@ export default {
watch: {
shoppingCart (newVal) {
this.leaveIfEmpty(newVal.length)
// this.resetAlloc()
this.resetAlloc()
if (this.equalize) { this.equalAlloc }
}
},
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/components/staking/PageDelegate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default {
description: {}
}
if (this.delegates && this.$route.params.delegate) {
value = this.delegates.find(v => v.id === this.$route.params.delegate)
value = this.delegates.find(v => v.id === this.$route.params.delegate) || value
}
return value
},
Expand Down
1 change: 1 addition & 0 deletions app/src/renderer/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = function (nodeIP) {
let node = new RestClient(RELAY_SERVER)

Object.assign(node, {
nodeIP,
lcdConnected: () => node.listKeys()
.then(() => true, () => false),

Expand Down
48 changes: 48 additions & 0 deletions app/src/renderer/vuex/modules/blockchain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import axios from 'axios'

export default ({ commit, node }) => {
const state = {
urlPrefix: 'https://',
blockchainName: 'gaia-2-dev',
urlSuffix: '-node0.testnets.interblock.io',
status: {},
abciInfo: {},
topAvgTxRate: 0
}

const mutations = {
setBlockchainName (state, name) {
state.blockchainName = name
},
setTopAvgTxRate (state, value) {
state.topAvgTxRate = value
},
getStatus (state) {
let url = state.urlPrefix + state.blockchainName + state.urlSuffix
axios(url + '/status').then((res) => {
state.status = res.data.result
})
},
getAbciInfo (state) {
let url = state.urlPrefix + state.blockchainName + state.urlSuffix
axios(url + '/abci_info').then((res) => {
state.abciInfo = res.data.result
})
}
}

// function getBlocks () {
// node.rpc.subscribe({ event: 'NewBlockHeader' }, (err, event) => {
// if (err) return console.error('error subscribing to new block headers', err)
// console.log(event)
// })
// }
// getBlocks()

setTimeout(() => {
mutations.getStatus(state)
mutations.getAbciInfo(state)
}, 3000)

return { state, mutations }
}
11 changes: 5 additions & 6 deletions app/src/renderer/vuex/modules/delegation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import axios from 'axios'

export default ({ commit }) => {
let state = {
delegationActive: false,

// our delegations, maybe not yet committed
delegates: [],

Expand All @@ -10,6 +12,9 @@ export default ({ commit }) => {
}

const mutations = {
activateDelegation (state) {
state.delegationActive = true
},
addToCart (state, delegate) {
// don't add to cart if already in cart
for (let existingDelegate of state.delegates) {
Expand All @@ -25,9 +30,6 @@ export default ({ commit }) => {
removeFromCart (state, delegate) {
state.delegates = state.delegates.filter(c => c.id !== delegate)
},
reserveAtoms (state, {delegateId, value}) {
state.delegates.find(d => d.id === delegateId).reservedAtoms = value
},
setShares (state, {candidateId, value}) {
state.delegates.find(c => c.id === candidateId).atoms = value
},
Expand All @@ -45,7 +47,6 @@ export default ({ commit }) => {
let actions = {
// load committed delegations from LCD
async getBondedDelegates ({ state, dispatch }, {candidates, address}) {
// TODO move into cosmos-sdk
candidates.forEach(candidate => {
dispatch('getBondedDelegate', {address, pubkey: candidate.pub_key.data})
})
Expand Down Expand Up @@ -94,8 +95,6 @@ export default ({ commit }) => {
})
})
}

commit('activateDelegation', true)
}
}

Expand Down
5 changes: 3 additions & 2 deletions app/src/renderer/vuex/modules/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export default (opts) => ({
delegates: require('./delegates.js').default(opts),
blockchain: require('./blockchain.js').default(opts),
config: require('./config.js').default(opts),
delegates: require('./delegates.js').default(opts),
delegation: require('./delegation.js').default(opts),
filters: require('./filters.js').default(opts),
node: require('./node.js').default(opts),
notifications: require('./notifications.js').default(opts),
proposals: require('./proposals.js').default(opts),
delegation: require('./delegation.js').default(opts),
user: require('./user.js').default(opts),
validators: require('./validators.js').default(opts),
wallet: require('./wallet.js').default(opts)
Expand Down
8 changes: 5 additions & 3 deletions app/src/renderer/vuex/modules/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export default function ({ node }) {
})
})
node.rpc.subscribe({ event: 'NewBlockHeader' }, (err, event) => {
if (err) return console.error('error subscribing to headers', err)
commit('setConnected', true)
dispatch('setLastHeader', event.data.data.header)
console.log(err)
// if (err) return console.error('error subscribing to headers', err)
// commit('setConnected', true)
console.log(event)
// dispatch('setLastHeader', event.data.data.header)
})

dispatch('pollRPCConnection')
Expand Down
Loading