Skip to content

Commit

Permalink
views: style invalidated transactions on block page. (#663)
Browse files Browse the repository at this point in the history
This styles invalidated transactions on the block and transactions pages.

Create an invalidated-tx CSS style to gray out and change background color
of regular transaction table data, including the coinbase, on a block's page.
On the blocks list page, indicate invalidated blocks.  When not in lite mode,
get the Valid and MainChain status from PG.
Also change maxExplorerRows to 400 (from 2000).
  • Loading branch information
chappjc committed Sep 5, 2018
1 parent 40e118b commit 8d924bf
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion explorer/explorer.go
Expand Up @@ -31,7 +31,7 @@ import (
)

const (
maxExplorerRows = 2000
maxExplorerRows = 400
minExplorerRows = 20
defaultAddressRows int64 = 20
MaxAddressRows int64 = 1000
Expand Down
11 changes: 11 additions & 0 deletions explorer/explorerroutes.go
Expand Up @@ -128,6 +128,17 @@ func (exp *explorerUI) Blocks(w http.ResponseWriter, r *http.Request) {
return
}

if !exp.liteMode {
for _, s := range summaries {
blockStatus, err := exp.explorerSource.BlockStatus(s.Hash)
if err != nil && err != sql.ErrNoRows {
log.Warnf("Unable to retrieve chain status for block %s: %v", s.Hash, err)
}
s.Valid = blockStatus.IsValid
s.MainChain = blockStatus.IsMainchain
}
}

str, err := exp.templates.execTemplateToString("explorer", struct {
Data []*BlockBasic
BestBlock int
Expand Down
7 changes: 7 additions & 0 deletions public/css/main.css
Expand Up @@ -594,6 +594,13 @@ body.darkBG .progress {
color: red;
font-size: 14pt;
}
.invalidated-tx {
background-color: rgba(151, 125, 163, 0.3);
opacity: 0.5;
}
.grayed {
opacity: 0.5;
}

/*Typography*/
.fs14-decimal .dot,
Expand Down
17 changes: 14 additions & 3 deletions views/block.tmpl
Expand Up @@ -6,6 +6,7 @@
{{ template "navbar" . }}
<div class="container main" data-controller="main">
{{with .Data}}
{{$Invalidated := and (gt .Confirmations 1) (not .Valid) }}
<div class="row justify-content-between">
<div class="col-md-7 col-sm-6">
<h4 class="mb-2">
Expand Down Expand Up @@ -37,7 +38,17 @@
<table class="">
{{if .MainChain}}<tr>
<td class="text-right pr-2 lh1rem vam nowrap" title="Stakeholder (PoS) approved?">APPROVED</td>
<td class="lh1rem">{{ if gt .Confirmations 1 }}{{.Valid}}{{else}}pending{{end}}</td>
<td class="lh1rem">
{{ if gt .Confirmations 1 }}
{{if $Invalidated}}
<span class="attention" title="Regular (non-stake) transactions invalidated.">{{.Valid}}</span>
{{else}}
<span title="All transactions valid.">{{.Valid}}</span>
{{end}}
{{else}}
pending
{{end}}
</td>
</tr>{{end}}
<tr>
<td class="text-right pr-2 lh1rem vam nowrap xs-w117">BLOCK HASH</td>
Expand Down Expand Up @@ -174,7 +185,7 @@
<th class="text-right">Total DCR</th>
<th>Size</th>
</thead>
<tbody>
<tbody {{if $Invalidated}}class="invalidated-tx" title="Regular transactions invalidated."{{end}}>
<tr>
<td class="break-word">
{{if $.Data.Nonce}}
Expand Down Expand Up @@ -353,7 +364,7 @@
<th class="text-right">Fee</th>
<th>Size</th>
</thead>
<tbody>
<tbody {{if $Invalidated}}class="invalidated-tx" title="Regular transactions invalidated."{{end}}>
{{range .Tx}}
{{if eq .Coinbase false}}
<tr>
Expand Down
4 changes: 2 additions & 2 deletions views/explorer.tmpl
Expand Up @@ -52,8 +52,8 @@
<tbody>
{{range .Data}}
<tr id="{{ .Height }}">
<td><a href="/block/{{.Height}}" class="fs16 height">{{ .Height }}</a></td>
<td>{{.Transactions}}</td>
<td><a href="/block/{{.Height}}" class="fs16 height">{{if not .Valid}}<span class="attention">&#9888;</span>{{end}}{{ .Height }}</a></td>
<td {{if not .Valid}}class="grayed" title="Regular transactions invalidated by stakeholders."{{end}}>{{.Transactions}}</td>
<td>{{.Voters}}</td>
<td>{{.FreshStake}}</td>
<td>{{.Revocations}}</td>
Expand Down

0 comments on commit 8d924bf

Please sign in to comment.