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

Jordan/1866 blocks #1933

Merged
merged 27 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
36a5cfd
reduce blocks cache to 100
jbibla Feb 6, 2019
cf3e5d6
improve table styles
jbibla Feb 6, 2019
300984d
added blocks as a getter
jbibla Feb 6, 2019
c729be6
made panel sort work when no sorting is needed
jbibla Feb 6, 2019
b8f979e
minor style change to licoin
jbibla Feb 6, 2019
5c30ea9
added PageBlock
jbibla Feb 6, 2019
0a7967b
updated PageNetwork to accomodate blocks
jbibla Feb 6, 2019
c0634e8
made links to explorer router links instead of links to external expl…
jbibla Feb 6, 2019
4034f50
some style improvements and standardization of time!
jbibla Feb 6, 2019
c1c6a5e
fixed lint errors
jbibla Feb 6, 2019
1d93c9e
update snapshots, fix compile errors
jbibla Feb 6, 2019
7e01ebf
fixed some tests
jbibla Feb 7, 2019
b74732e
lint
jbibla Feb 7, 2019
c472b31
all the transaction tests depend on each other, so changing an href t…
jbibla Feb 7, 2019
7bfd839
added some tests
jbibla Feb 8, 2019
bb22c1f
Merge branch 'develop' into jordan/1866-blocks
jbibla Feb 8, 2019
388b213
changelog and snaperoos
jbibla Feb 8, 2019
3c4dde5
removed unused method
jbibla Feb 8, 2019
4cd4f46
refactor how we get one block
jbibla Feb 8, 2019
7b30433
fixed blocks tests
jbibla Feb 8, 2019
b6dcd30
lint
jbibla Feb 8, 2019
3b33d7d
bump the coverage
jbibla Feb 8, 2019
cd7a88a
fixed route name, addressed _this_, moved some logic to computed prop…
jbibla Feb 11, 2019
5d21b87
tests for date function
sabau Feb 12, 2019
750be25
Merge branch 'develop' into jordan/1866-blocks
sabau Feb 12, 2019
667e4d1
fix tests for datetimes in TmLiTransactions.spec.js
sabau Feb 12, 2019
1424aec
align txs with real Date
sabau Feb 12, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [\#1894](https://github.com/cosmos/voyager/issues/1894) Added favicons for all the browsers and devices @jbibla
- [\#1865](https://github.com/cosmos/voyager/issues/1865) Added Vuex blocks module @sabau
- [\#1928](https://github.com/cosmos/voyager/issues/1928) Added Browserstack reference to README @sabau
- [\#1866](https://github.com/cosmos/voyager/issues/1866) Added blocks to network page and a page for viewing individual blocks @jbibla

### Changed

Expand Down
27 changes: 10 additions & 17 deletions app/src/renderer/components/common/TmConnectedNetwork.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
</div>
</div>
<div id="tm-connected-network__block" class="tm-connected-network__string">
<a
v-tooltip.top="'View block details on the Cosmos explorer.'"
:href="explorerLink"
>{{ blockHeight }}<i class="material-icons exit">exit_to_app</i></a
<router-link
v-tooltip.top="'Block Height'"
:to="{ name: `block`, params: { height: lastHeader.height } }"
>{{ blockHeight }}</router-link
>
</div>
</div>
Expand All @@ -38,33 +38,26 @@
<script>
import { mapGetters } from "vuex"
import num from "scripts/num"

export default {
name: `tm-connected-network`,
data: () => ({
num: num
num
}),
computed: {
...mapGetters([`lastHeader`, `nodeUrl`, `connected`]),
networkTooltip({ connected, nodeUrl } = this) {
networkTooltip({ connected, nodeUrl, lastHeader } = this) {
if (connected) {
return `You\'re connected to the ${
this.lastHeader.chain_id
lastHeader.chain_id
} testnet via node ${nodeUrl}.`
}
return `We\'re pinging nodes to try to connect you to ${
this.lastHeader.chain_id
lastHeader.chain_id
}.`
},
blockHeight() {
return `#` + num.prettyInt(this.lastHeader.height)
},
explorerLink() {
return `https://explorecosmos.network/blocks/` + this.lastHeader.height
}
},
methods: {
closeMenu() {
this.$store.commit(`setActiveMenu`, ``)
return `#` + this.num.prettyInt(this.lastHeader.height)
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions app/src/renderer/components/common/TmPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ export default {
return refresh ? { connected, refresh } : undefined
}
},
updated() {
this.$el.querySelector(`.tm-page-main`).scrollTop = 0
},
async mounted() {
Mousetrap.bind([`command+f`, `ctrl+f`], () => this.setSearch(true))
Mousetrap.bind(`esc`, () => this.setSearch(false))
Expand Down Expand Up @@ -216,6 +213,7 @@ export default {
justify-content: space-between;
align-items: center;
width: 100%;
padding: 1rem;
}

.page-profile__status-and-title {
Expand Down
154 changes: 154 additions & 0 deletions app/src/renderer/components/network/PageBlock.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<template>
<tm-page data-title="Block">
<template slot="menu-body">
<tm-balance />
<tool-bar />
</template>

<tm-data-error v-if="!connected || !block || !header" />

<template v-else>
<div class="page-profile__header page-profile__section block">
<div class="row">
<div class="page-profile__header__info">
<div class="page-profile__status-and-title">
<h2 class="page-profile__title">
Block {{ `#` + num.prettyInt(header.height) }}
</h2>
<h3 class="page-profile__subtitle">
{{ block.block_meta.block_id.hash }}
</h3>
</div>
</div>
</div>

<div class="row">
<dl class="info_dl colored_dl">
<dt>Time</dt>
<dd>{{ moment(header.time).format("MMM Do YYYY, HH:mm:ss") }}</dd>
</dl>
<dl class="info_dl colored_dl">
<dt>Proposer</dt>
<dd>{{ header.proposer_address }}</dd>
</dl>
</div>
</div>

<div class="page-profile__section block">
<div class="row">
<div class="column">
<dl class="info_dl colored_dl">
<dt>Transactions</dt>
<dd>{{ block.block.data.txs || `No Transactions` }}</dd>
</dl>
</div>
</div>
</div>

<div class="page-profile__section block">
<div class="row">
<div class="column">
<dl class="info_dl colored_dl">
<dt>Evidence</dt>
<dd>{{ block.block.evidence.evidence || `No Evidence` }}</dd>
</dl>
</div>
</div>
</div>

<div class="page-profile__section block">
<div class="row">
<div class="column">
<dl class="info_dl colored_dl">
<dt>Pre Commits</dt>
<dd v-if="!block.block.last_commit.precommits">No precommits</dd>
<table v-else class="pre-commits data-table">
<thead>
<panel-sort :properties="properties" />
</thead>
<tbody>
<tr
v-for="(precommit, index) in block.block.last_commit
.precommits"
:key="index"
class="block data-table__row"
>
<td>{{ precommit.validator_address }}</td>
<td>
{{
moment(precommit.timestamp).format(
Copy link
Contributor

Choose a reason for hiding this comment

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

same as up, would be nicer to have the formatting logic coded only once

Copy link
Contributor

Choose a reason for hiding this comment

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

👀

"MMM Do YYYY, HH:mm:ss"
)
}}
</td>
<td>{{ precommit.round }}</td>
</tr>
</tbody>
</table>
</dl>
</div>
</div>
</div>
</template>
</tm-page>
</template>

<script>
import moment from "moment"
import axios from "axios"
import { mapGetters } from "vuex"
import num from "scripts/num"
import PanelSort from "staking/PanelSort"
import ToolBar from "common/ToolBar"
import TmBalance from "common/TmBalance"
import TmDataError from "common/TmDataError"
import TmPage from "common/TmPage"
export default {
name: `page-block`,
components: {
PanelSort,
TmBalance,
ToolBar,
TmDataError,
TmPage
},
data: () => ({
num,
moment,
header: null,
block: null
}),
computed: {
...mapGetters([`connected`, `blocks`]),
properties() {
return [
{
title: `Proposer`
},
{
title: `Time`
},
{
title: `Round`
}
]
}
},
watch: {
$route: `getBlock`
},
async mounted() {
await this.getBlock()
},
methods: {
async getBlock() {
const url =
`http://localhost:8080/` + `blocks/` + this.$route.params.height
const block = await axios.get(url)
this.header = block.data.block.header
this.block = block.data
}
}
}
</script>
<style></style>
72 changes: 60 additions & 12 deletions app/src/renderer/components/network/PageNetwork.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
class="page-profile__status"
/>
<h2 class="page-profile__title">{{ lastHeader.chain_id }}</h2>
<h3 v-if="config.devMode">
Proposer: {{ lastHeader.proposer_address }}
</h3>
</div>
</div>
</div>
<div class="row">
<dl class="info_dl colored_dl">
<dt>Height</dt>
<dd>{{ lastHeader.height }}</dd>
<dt>Block Height</dt>
<dd>{{ `#` + num.prettyInt(lastHeader.height) }}</dd>
</dl>
<dl class="info_dl colored_dl">
<dt>Last Block</dt>
Expand Down Expand Up @@ -61,14 +58,36 @@
</div>
</div>
</div>
<table class="blocks data-table">
<thead>
<panel-sort :properties="properties" />
</thead>
<tbody>
<tr
v-for="block in blocks"
:key="block.header.height"
class="block data-table__row"
>
<td>
<router-link
:to="{ name: `block`, params: { height: block.header.height } }"
>{{ `#` + num.prettyInt(block.header.height) }}</router-link
>
</td>
<td>{{ block.header.num_txs }}</td>
<td>{{ block.header.proposer_address }}</td>
</tr>
</tbody>
</table>
</template>
</tm-page>
</template>

<script>
import moment from "moment"
import { mapGetters } from "vuex"
import TmBtn from "common/TmBtn"
import num from "scripts/num"
import PanelSort from "staking/PanelSort"
import ToolBar from "common/ToolBar"
import TmBalance from "common/TmBalance"
import TmDataError from "common/TmDataError"
Expand All @@ -77,19 +96,22 @@ export default {
name: `page-network`,
components: {
TmBalance,
TmBtn,
PanelSort,
ToolBar,
TmDataError,
TmPage
},
data: () => ({
num
}),
computed: {
...mapGetters([
`connected`,
`lastHeader`,
`delegates`,
`config`,
`pool`,
`bondDenom`
`bondDenom`,
`blocks`
]),
status() {
const color = this.connected ? `green` : `red`
Expand All @@ -101,12 +123,38 @@ export default {
lastBlock() {
moment.relativeTimeThreshold(`ss`, 1)
return moment(this.lastHeader.time).fromNow()
},
properties() {
return [
{
title: `Block Number`,
value: `block_number`,
tooltip: `Block Number`,
class: `blockNumber`
},
{
title: `Transactions`,
value: `transactions`,
tooltip: `Number of transactions per block`,
class: `transactions`
},
{
title: `Proposer`,
value: `proposer`,
tooltip: `Validator responsible for block proposals`,
class: `proposer`
}
]
}
}
}
</script>
<style>
.network .page-profile__header__info {
padding: 2rem;
<style scoped>
.block td {
padding: 1rem;
}

.blocks.data-table th {
padding: 0.5rem 1rem;
}
</style>
10 changes: 6 additions & 4 deletions app/src/renderer/components/staking/PanelSort.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
<th
v-for="property in properties"
:key="property.value"
:class="property.class"
class="sort-by"
:class="{ 'sort-by': sort }"
class="panel-sort-table-header"
>
<a
v-tooltip.top="property.tooltip"
v-if="sort"
class="sort-by-link"
@click="orderBy(property.value)"
>{{ property.title }}</a
>
<span v-else>{{ property.title }}</span>
</th>
</tr>
</template>
Expand All @@ -22,7 +24,7 @@ export default {
props: {
sort: {
type: Object,
required: true
default: null
},
properties: {
type: Array,
Expand Down Expand Up @@ -61,7 +63,7 @@ export default {
padding: 1rem;
}

.sort-by {
.panel-sort-table-header {
font-size: var(--sm);
}

Expand Down
Loading