From 14103b84e4d34bd13dfe35bd3c222c60d82019d0 Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Fri, 25 Aug 2017 16:59:56 -0400 Subject: [PATCH] - convert "Node Info" and "Mempool Info" in index to be nice tables - minor cleanup --- views/includes/blocks-list.pug | 6 ++--- views/includes/getinfo-table.pug | 36 +++++++++++++++++++++++++ views/includes/getmempoolinfo-table.pug | 30 +++++++++++++++++++++ views/index.pug | 8 +++--- 4 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 views/includes/getinfo-table.pug create mode 100644 views/includes/getmempoolinfo-table.pug diff --git a/views/includes/blocks-list.pug b/views/includes/blocks-list.pug index ebb71c7..7ef2135 100644 --- a/views/includes/blocks-list.pug +++ b/views/includes/blocks-list.pug @@ -13,8 +13,8 @@ table(class="table table-striped") tr th #{blockIndex + blockOffset + 1} td - a(href=("/block-height/" + block.height)) #{block.height} + a(href=("/block-height/" + block.height)) #{block.height.toLocaleString()} td #{moment.utc(new Date(parseInt(block.time) * 1000)).format("Y-MM-DD HH:mm:ss")} td #{moment.utc(new Date(parseInt(block.time) * 1000)).fromNow(true)} - td #{block.tx.length.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")} - td #{block.size.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")} \ No newline at end of file + td #{block.tx.length.toLocaleString()} + td #{block.size.toLocaleString()} \ No newline at end of file diff --git a/views/includes/getinfo-table.pug b/views/includes/getinfo-table.pug new file mode 100644 index 0000000..a9fb9ea --- /dev/null +++ b/views/includes/getinfo-table.pug @@ -0,0 +1,36 @@ +if (false) + pre + code #{JSON.stringify(getinfo, null, 4)} + +if (true) + table(class="table") + tr + th(class="table-active properties-header") Version + td #{getinfo.version} + tr + th(class="table-active properties-header") Protocol Version + td #{getinfo.protocolversion} + tr + th(class="table-active properties-header") Connections + td #{getinfo.connections.toLocaleString()} + tr + th(class="table-active properties-header") Block Count + td #{getinfo.blocks.toLocaleString()} + tr + th(class="table-active properties-header") Testnet? + td #{getinfo.testnet} + tr + th(class="table-active properties-header") Errors + td #{getinfo.errors} + tr + - var scales = [ {val:1000000000000000, name:"quadrillion"}, {val:1000000000000, name:"trillion"}, {val:1000000000, name:"billion"}, {val:1000000, name:"million"} ]; + - var scaleDone = false; + th(class="table-active properties-header") Difficulty + td + span #{getinfo.difficulty.toLocaleString()} + each item in scales + if (!scaleDone) + - var fraction = Math.floor(getinfo.difficulty / item.val); + if (fraction >= 1) + - scaleDone = true; + span(class="text-muted") (#{fraction} #{item.name}) \ No newline at end of file diff --git a/views/includes/getmempoolinfo-table.pug b/views/includes/getmempoolinfo-table.pug new file mode 100644 index 0000000..23d3734 --- /dev/null +++ b/views/includes/getmempoolinfo-table.pug @@ -0,0 +1,30 @@ +if (false) + pre + code #{JSON.stringify(getmempoolinfo, null, 4)} + +if (true) + table(class="table") + tr + th(class="table-active properties-header") Transaction Count + td #{getmempoolinfo.size.toLocaleString()} + tr + - var scales = [ {val:1000000000, name:"GB"}, {val:1000000, name:"MB"}, {val:1000, name:"kB"} ]; + - var scaleDone = false; + th(class="table-active properties-header") Size + td + span #{getmempoolinfo.bytes.toLocaleString()} bytes + each item in scales + if (!scaleDone) + - var fraction = Math.floor(getmempoolinfo.bytes / item.val); + if (fraction >= 1) + - scaleDone = true; + span(class="text-muted") (#{fraction} #{item.name}) + tr + th(class="table-active properties-header") Total Memory Usage + td #{getmempoolinfo.usage.toLocaleString()} + tr + th(class="table-active properties-header") Max Size + td #{getmempoolinfo.maxmempool.toLocaleString()} + tr + th(class="table-active properties-header") Min Fee + td #{getmempoolinfo.mempoolminfee.toLocaleString()} \ No newline at end of file diff --git a/views/index.pug b/views/index.pug index e8c51ad..7533bf4 100644 --- a/views/index.pug +++ b/views/index.pug @@ -35,10 +35,10 @@ block content div(id="tab-getinfo", class="tab-pane", role="tabpanel") h3 Node Info - pre - code #{JSON.stringify(getinfo, null, 4)} + + include includes/getinfo-table.pug div(id="tab-getmempoolinfo", class="tab-pane", role="tabpanel") h3 Mempool Info - pre - code #{JSON.stringify(getmempoolinfo, null, 4)} \ No newline at end of file + + include includes/getmempoolinfo-table.pug \ No newline at end of file