parent
f5dd228551
commit
06057e36ef
@ -0,0 +1,45 @@ |
||||
.pagination { |
||||
display: block; |
||||
|
||||
&-list { |
||||
list-style: none; |
||||
margin: 0; |
||||
padding: 0; |
||||
white-space: nowrap; |
||||
} |
||||
|
||||
li { |
||||
display: inline-block; |
||||
margin: 0; |
||||
margin-right: explorer-size(-3); |
||||
&:first-of-type, &:last-of-type { display: none; } |
||||
&:last-of-type { margin-right: 0; } |
||||
} |
||||
|
||||
&-link { |
||||
@include explorer-typography("body1"); |
||||
display: block; |
||||
line-height: 1; |
||||
color: lighten(explorer-color("gray", "300"), 10); |
||||
text-decoration: none; |
||||
padding: explorer-size(-3) explorer-size(-3) + explorer-size(-5); |
||||
border: 1px solid lighten(explorer-color("gray", "300"), 10); |
||||
border-radius: explorer-size(-5); |
||||
|
||||
&:hover, |
||||
&.is-current { |
||||
border-color: explorer-color("blue", "500"); |
||||
background: explorer-color("blue", "500"); |
||||
color: explorer-color("white"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@media (min-width: $explorer-breakpoint-sm) { |
||||
.pagination { |
||||
li { |
||||
&:first-of-type { display: inline-block; } |
||||
&:last-of-type { display: inline-block; } |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,34 @@ |
||||
<section class="container__section"> |
||||
<div class="blocks__headline"> |
||||
<h1 class="blocks__headline-title"><%= gettext("Showing #%{start_block} to #%{end_block}", start_block: List.last(@blocks.entries).number, end_block: List.first(@blocks.entries).number) %></h1> |
||||
<div class="blocks__pagination"><%= pagination_links @conn, @blocks, ["en"], view_style: :bulma, first: true, distance: 1, previous: Phoenix.HTML.raw("‹"), next: Phoenix.HTML.raw("›"), path: &block_path/4 %></div> |
||||
</div> |
||||
<div class="blocks"> |
||||
<div class="blocks__container"> |
||||
<table class="blocks__table"> |
||||
<thead class="blocks__header"> |
||||
<tr> |
||||
<th class="blocks__column-header"><%= gettext "Height" %></th> |
||||
<th class="blocks__column-header"><%= gettext "Age" %></th> |
||||
<th class="blocks__column-header"><%= gettext "Transactions" %></th> |
||||
<th class="blocks__column-header blocks__column-header--optional"><%= gettext "Gas Used" %></th> |
||||
<th class="blocks__column-header blocks__column-header--optional"><%= gettext "Gas Limit" %></th> |
||||
<th class="blocks__column-header blocks__column-header--optional"><%= gettext "Gas Price" %></th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<%= for block <- @blocks do %> |
||||
<tr class="blocks__row"> |
||||
<td class="blocks__column blocks__column--height"><%= link(block.number, to: block_path(@conn, :show, @conn.assigns.locale, block.number), class: "blocks__link") %></td> |
||||
<td class="transactions__column transactions__column--age"><%= block.timestamp |> Timex.from_now %></td> |
||||
<td class="blocks__column blocks__column--transactions-count"><%= gettext("%{count} transactions", count: block.transactions |> Enum.count) %></td> |
||||
<td class="blocks__column blocks__column--optional blocks__column--gas-used"><%= block.gas_used |> Cldr.Number.to_string! %> (<%= block.gas_used / block.gas_limit |> Cldr.Number.to_string!(format: "#.#%") %>)</td> |
||||
<td class="blocks__column blocks__column--optional blocks__column--gas-limit"><%= block.gas_limit |> Cldr.Number.to_string! %></td> |
||||
<td class="blocks__column blocks__column--optional blocks__column--gas-price"><%= block.transactions |> Enum.map(fn(transaction) -> Decimal.to_float(Decimal.div(Decimal.new(transaction.gas_price), Decimal.new(1_000_000_000))) end) |> Math.Enum.mean || 0 |> Cldr.Number.to_string! %> Gwei</td> |
||||
</tr> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
</section> |
@ -1,4 +1,5 @@ |
||||
defmodule ExplorerWeb.BlockView do |
||||
use ExplorerWeb, :view |
||||
import Scrivener.HTML |
||||
@dialyzer :no_match |
||||
end |
||||
|
@ -1,4 +1,4 @@ |
||||
defmodule ExplorerWeb.PageView do |
||||
defmodule ExplorerWeb.ChainView do |
||||
use ExplorerWeb, :view |
||||
@dialyzer :no_match |
||||
end |
@ -1,11 +1,19 @@ |
||||
defmodule ExplorerWeb.BlockControllerTest do |
||||
use ExplorerWeb.ConnCase |
||||
|
||||
describe "GET show/3" do |
||||
describe "GET show/2" do |
||||
test "returns a block", %{conn: conn} do |
||||
block = insert(:block, number: 3) |
||||
conn = get(conn, "/en/blocks/3") |
||||
assert conn.assigns.block.id == block.id |
||||
end |
||||
end |
||||
|
||||
describe "GET index/2" do |
||||
test "returns all blocks", %{conn: conn} do |
||||
block_ids = insert_list(4, :block) |> Enum.map(fn (block) -> block.number end) |> Enum.reverse |
||||
conn = get(conn, "/en/blocks") |
||||
assert conn.assigns.blocks |> Enum.map(fn (block) -> block.number end) == block_ids |
||||
end |
||||
end |
||||
end |
||||
|
@ -1,3 +1,3 @@ |
||||
defmodule ExplorerWeb.PageViewTest do |
||||
defmodule ExplorerWeb.ChainViewTest do |
||||
use ExplorerWeb.ConnCase, async: true |
||||
end |
Loading…
Reference in new issue