From 0122454f5473f96a94eb527154de28210f51e356 Mon Sep 17 00:00:00 2001 From: Ryan Arthur Date: Thu, 19 Jul 2018 14:55:17 -0400 Subject: [PATCH] Implement new design style to the transactions section of the block details page --- .../address_transaction/_transaction.html.eex | 1 + .../templates/block/overview.html.eex | 44 ++-- .../block_transaction/_transaction.html.eex | 38 ++++ .../block_transaction/index.html.eex | 204 +++--------------- .../templates/chain/_blocks.html.eex | 2 +- 5 files changed, 87 insertions(+), 202 deletions(-) create mode 100644 apps/explorer_web/lib/explorer_web/templates/block_transaction/_transaction.html.eex diff --git a/apps/explorer_web/lib/explorer_web/templates/address_transaction/_transaction.html.eex b/apps/explorer_web/lib/explorer_web/templates/address_transaction/_transaction.html.eex index 213874f705..fd560391d7 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address_transaction/_transaction.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address_transaction/_transaction.html.eex @@ -18,6 +18,7 @@ <% end %> → + <%= if @address.hash == ExplorerWeb.TransactionView.to_address_hash(@transaction) do %> <%= render ExplorerWeb.AddressView, "_responsive_hash.html", address_hash: ExplorerWeb.TransactionView.to_address_hash(@transaction), contract: ExplorerWeb.AddressView.contract?(@transaction.to_address) %> <% else %> diff --git a/apps/explorer_web/lib/explorer_web/templates/block/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/block/overview.html.eex index d6cd32c15a..04e46c808f 100644 --- a/apps/explorer_web/lib/explorer_web/templates/block/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/block/overview.html.eex @@ -11,9 +11,6 @@ <%= gettext "%{count} Transactions", count: @block_transaction_count %> - - 10 Contracts - <%= Cldr.Unit.new(:byte, @block.size) |> Cldr.Unit.to_string! %> @@ -28,7 +25,7 @@
<%= gettext "Hash" %>
-
<%= @block.hash %>
+
<%= to_string(@block.hash) %>
@@ -43,26 +40,25 @@ - +
-
<%= gettext "Gas Used" %>
+
<%= gettext "Difficulty" %>
- <%= @block.gas_used |> Cldr.Number.to_string! %> (<%= (@block.gas_used / @block.gas_limit) |> Cldr.Number.to_string!(format: "#.#%") %>) + <%= @block.difficulty |> Cldr.Number.to_string! %>
- +
-
<%= gettext "Gas Limit" %>
-
<%= @block.gas_limit |> Cldr.Number.to_string! %>
+
<%= gettext "Total Difficulty" %>
+
<%= @block.total_difficulty |> Cldr.Number.to_string! %>
-
+
<%= gettext "Nonce" %>
-
<%= @block.nonce %>
+
<%= to_string(@block.nonce) %>
- @@ -74,24 +70,26 @@

<%= gettext "Miner" %>

-

Lester McTester

+ +

<%= link @block.miner, class: "text-white", to: address_path(ExplorerWeb.Endpoint, :show, @locale, @block.miner) %>

- - <%= link @block.miner, to: address_path(ExplorerWeb.Endpoint, :show, @locale, @block.miner) %> - +
- +
-

<%= gettext "Difficulty" %>

+

<%= gettext "Gas Used" %>

- -

<%= @block.difficulty |> Cldr.Number.to_string! %>

- - <%= @block.total_difficulty |> Cldr.Number.to_string! %> + +

+ <%= @block.gas_used |> Cldr.Number.to_string! %> + (<%= (@block.gas_used / @block.gas_limit) |> Cldr.Number.to_string!(format: "#.#%") %>) +

+ + <%= @block.gas_limit |> Cldr.Number.to_string! %> <%= gettext "Gas Limit" %>
diff --git a/apps/explorer_web/lib/explorer_web/templates/block_transaction/_transaction.html.eex b/apps/explorer_web/lib/explorer_web/templates/block_transaction/_transaction.html.eex new file mode 100644 index 0000000000..10877834cc --- /dev/null +++ b/apps/explorer_web/lib/explorer_web/templates/block_transaction/_transaction.html.eex @@ -0,0 +1,38 @@ +
+
+
+ + <%= ExplorerWeb.TransactionView.transaction_display_type(@transaction) %> + +
+ <%= ExplorerWeb.TransactionView.formatted_status(@transaction) %> +
+
+
+ <%= render ExplorerWeb.TransactionView, "_link.html", locale: @locale, transaction_hash: @transaction.hash %> + + <%= render ExplorerWeb.AddressView, "_link.html", address_hash: @transaction.from_address_hash, contract: ExplorerWeb.AddressView.contract?(@transaction.from_address), locale: @locale %> + + → + + <%= render ExplorerWeb.AddressView, "_link.html", address_hash: ExplorerWeb.TransactionView.to_address_hash(@transaction), contract: ExplorerWeb.AddressView.contract?(@transaction.to_address), locale: @locale %> + + + + + + <%= link( + gettext("Block #%{number}", number: to_string(@transaction.block.number)), + to: block_path(ExplorerWeb.Endpoint, :show, @locale, @transaction.block) + ) %> + + +
+
+ + <%= ExplorerWeb.TransactionView.value(@transaction, include_label: false) %> <%= gettext "Ether" %> + + <%= ExplorerWeb.TransactionView.formatted_fee(@transaction, denomination: :ether) %> <%= gettext "Fee" %> +
+
+
diff --git a/apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex index 5b0f21daa0..2079e5bdc0 100644 --- a/apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex @@ -2,128 +2,12 @@ <%= render ExplorerWeb.BlockView, "overview.html", assigns %> - - -
-
-

<%= gettext("Block Details") %>

-

<%= @block.number %>

- -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- <%= gettext "Timestamp" %> - - (<%= formatted_timestamp(@block) %>) -
- <%= gettext "Transaction" %> - - <%= gettext "%{count} transactions in this block", count: @block_transaction_count %> -
- <%= gettext "Hash" %> - - <%= @block.hash %> -
- <%= gettext "Parent Hash" %> - - <%= link( - @block.parent_hash, - to: block_path(@conn, :show, @conn.assigns.locale, @block.number - 1) - ) %> -
- <%= gettext "Miner" %> - - <%= @block.miner %> -
- <%= gettext "Difficulty" %> - - <%= @block.difficulty |> Cldr.Number.to_string! %> -
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
- <%= gettext "Total Difficulty" %> - - <%= @block.total_difficulty |> Cldr.Number.to_string! %> -
- <%= gettext "Size" %> - - <%= Cldr.Unit.new(:byte, @block.size) |> Cldr.Unit.to_string! %> -
- <%= gettext "Gas Used" %> - - <%= @block.gas_used |> Cldr.Number.to_string! %> (<%= (@block.gas_used / @block.gas_limit) |> Cldr.Number.to_string!(format: "#.#%") %>) -
- <%= gettext "Gas Limit" %> - - <%= @block.gas_limit |> Cldr.Number.to_string! %> -
- <%= gettext "Nonce" %> - - <%= @block.nonce %> -
-
-
-
-
-
-
-
<%= if Enum.count(@transactions) > 0 do %> - - - - - - - - - - - - - - - <%= for transaction <- @transactions do %> - - - - - - - - - - - <% end %> - -
- <%= gettext "Status" %> - <%= gettext "Hash" %><%= gettext "Block" %><%= gettext "Age" %><%= gettext "From" %><%= gettext "To" %><%= gettext "Value" %>
-
-
- <%= render ExplorerWeb.TransactionView, "_link.html", locale: @locale, transaction_hash: transaction.hash %> - - <%= link( - transaction.block, - to: block_path(@conn, :show, @conn.assigns.locale, transaction.block) - ) %> - - <%= render ExplorerWeb.AddressView, "_link.html", address_hash: transaction.from_address_hash, contract: ExplorerWeb.AddressView.contract?(transaction.from_address), locale: @locale %> - - <%= cond do %> - <% transaction.to_address_hash != nil -> %> - <%= render ExplorerWeb.AddressView, "_link.html", address_hash: transaction.to_address_hash, contract: ExplorerWeb.AddressView.contract?(transaction.to_address), locale: @locale %> - <% transaction.created_contract_address_hash != nil -> %> - - <%= link( - "Contract Creation", - class: "transaction__link", - "data-address-hash": transaction.created_contract_address_hash, - to: address_path(@conn, :show, @conn.assigns.locale, transaction.created_contract_address_hash), - title: transaction.created_contract_address_hash - ) %> - <% true -> %> - <% end %> - - <%= ExplorerWeb.TransactionView.value(transaction) %> -
+

<%= gettext "Transactions" %>

+ + <%= for transaction <- @transactions do %> + <%= render "_transaction.html", locale: @locale, transaction: transaction %> + <% end %> + <% else %> -

<%= gettext "There are no Transactions" %>

+
+ <%= gettext "There are no transactions for this address." %> +
<% end %>
diff --git a/apps/explorer_web/lib/explorer_web/templates/chain/_blocks.html.eex b/apps/explorer_web/lib/explorer_web/templates/chain/_blocks.html.eex index d8f5346434..73d5f02dee 100644 --- a/apps/explorer_web/lib/explorer_web/templates/chain/_blocks.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/chain/_blocks.html.eex @@ -12,7 +12,7 @@ <%= link(block, to: block_path(@conn, :show, @conn.assigns.locale, block), class: "tile-title") %>
<%= block.transactions |> Enum.count %> Transactions - +
Validated by