From 5d78d1f770de5f442ee11bf0f98ffa61546c5a21 Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Sat, 7 Jul 2018 13:24:14 -0400 Subject: [PATCH] tweak block-details content: - button-links for previous/next blocks instead of showing the hashes in the table - don't show block-hash or height in the summary table (since it's in the H1 title already) - add "age" description for the age below the timestamp for clarity - include "Total Fees" and "Average Fee" in the summary table - include "Miner" entry even if unidentified, for consistency --- views/block.pug | 19 ++++++-- views/includes/block-content.pug | 74 +++++++++++++++++++------------- 2 files changed, 60 insertions(+), 33 deletions(-) diff --git a/views/block.pug b/views/block.pug index 8c1068b..792dd19 100644 --- a/views/block.pug +++ b/views/block.pug @@ -4,10 +4,21 @@ block headContent title Block #{blockHash} block content - h1(class="h2") Block - small(style="width: 100%;", class="monospace") ##{result.getblock.height.toLocaleString()} - br - small(style="width: 100%;", class="monospace word-wrap") #{result.getblock.hash} + div(class="row") + div(class="col-md-8") + h1(class="h2") Block + small(style="width: 100%;", class="monospace") ##{result.getblock.height.toLocaleString()} + br + small(style="width: 100%;", class="monospace word-wrap") #{result.getblock.hash} + + + div(class="col-md-4") + div(class="text-md-right mb-2") + if (result.getblock.height > 0) + a(href=("/block/" + result.getblock.previousblockhash), class="btn btn-primary", data-toggle="tooltip", title=("Block " + result.getblock.previousblockhash)) ◀ ##{(result.getblock.height - 1).toLocaleString()} + if (result.getblock.nextblockhash) + a(href=("/block/" + result.getblock.nextblockhash), class="btn btn-primary", data-toggle="tooltip", title=("Block " + result.getblock.nextblockhash)) ##{(result.getblock.height + 1).toLocaleString()} ▶ + hr include includes/block-content.pug \ No newline at end of file diff --git a/views/includes/block-content.pug b/views/includes/block-content.pug index 62176d5..88cde6c 100644 --- a/views/includes/block-content.pug +++ b/views/includes/block-content.pug @@ -32,32 +32,31 @@ div(class="tab-content") table(class="table") - tr - th(class="table-active properties-header") Previous Block - td(class="monospace word-wrap") - if (result.getblock.previousblockhash) - a(class="word-wrap", href=("/block/" + result.getblock.previousblockhash)) #{result.getblock.previousblockhash} - br - span(class="text-muted") (#{(result.getblock.height - 1).toLocaleString()}) - - else if (result.getblock.hash == genesisBlockHash) - span None + if (false) + tr + th(class="table-active properties-header") Previous Block + td(class="monospace word-wrap") + if (result.getblock.previousblockhash) + a(class="word-wrap", href=("/block/" + result.getblock.previousblockhash)) #{(result.getblock.height - 1).toLocaleString()} - tr - th(class="table-active properties-header") Next Block - td(class="monospace word-wrap") - if (result.getblock.nextblockhash) - a(href=("/block/" + result.getblock.nextblockhash)) #{result.getblock.nextblockhash} - br - span(class="text-muted") (#{(result.getblock.height + 1).toLocaleString()}) - else - span None - span(class="text-muted") (latest block) + else if (result.getblock.hash == genesisBlockHash) + span None - tr - th(class="table-active properties-header") Block Height - td(class="monospace") - a(href=("/block-height/" + result.getblock.height)) #{result.getblock.height.toLocaleString()} + if (false) + tr + th(class="table-active properties-header") Next Block + td(class="monospace word-wrap") + if (result.getblock.nextblockhash) + a(href=("/block/" + result.getblock.nextblockhash)) #{(result.getblock.height + 1).toLocaleString()} + else + span None + span(class="text-muted") (latest block) + + if (false) + tr + th(class="table-active properties-header") Block Height + td(class="monospace") + a(href=("/block-height/" + result.getblock.height)) #{result.getblock.height.toLocaleString()} tr th(class="table-active properties-header") Timestamp (utc) @@ -65,12 +64,24 @@ div(class="tab-content") - var timeAgo = moment.duration(moment.utc(new Date()).diff(moment.utc(new Date(parseInt(result.getblock.time) * 1000)))); td(class="monospace") #{moment.utc(new Date(result.getblock.time * 1000)).format("Y-MM-DD HH:mm:ss")} br - span(class="text-muted") (#{timeAgo.format()}) + span(class="text-muted") (age #{timeAgo.format()}) tr th(class="table-active properties-header") Transaction Count td(class="monospace") #{result.getblock.tx.length.toLocaleString()} + tr + th(class="table-active properties-header") Total Fees + td(class="monospace") + - var currencyValue = new Decimal(result.getblock.totalFees); + include ./value-display.pug + + tr + th(class="table-active properties-header") Average Fee + td(class="monospace") + - var currencyValue = new Decimal(result.getblock.totalFees).dividedBy(result.getblock.tx.length); + include ./value-display.pug + tr th(class="table-active properties-header") Size td(class="monospace") @@ -123,13 +134,18 @@ div(class="tab-content") th(class="table-active text-right") Chainwork td(class="monospace word-wrap") #{result.getblock.chainwork} - if (result.getblock.miner) - tr - th(class="table-active text-right") Miner - td(class="monospace word-wrap") #{result.getblock.miner.name} + tr + th(class="table-active text-right") Miner + td(class="monospace word-wrap") + if (result.getblock.miner) + span #{result.getblock.miner.name} if (result.getblock.miner.identifiedBy) a(href=coinConfig.miningPoolsConfigUrl, data-toggle="tooltip", title=("Identified by: " + result.getblock.miner.identifiedBy), target="_blank") i(class="fas fa-info-circle") + else + span ? + a(href=coinConfig.miningPoolsConfigUrl, data-toggle="tooltip", title=("Unable to identify (click to see config)"), target="_blank") + i(class="fas fa-info-circle") hr