Move address info into a tile.

pull/893/head
Lokraan 6 years ago
parent 38f77d7019
commit 4c3ee49eb3
  1. 45
      apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex
  2. 42
      apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex
  3. 6
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex

@ -0,0 +1,45 @@
<div class="tile">
<div class="row">
<!-- rank -->
<div class="col-2 col-md-1 d-flex justify-content-center align-items-center">
<!-- incremented number by order in the list -->
<span>
<%= @index %>
</span>
</div>
<div class="col-10 col-md-11">
<div class="row">
<div class="col-md-7 d-flex flex-column mt-3 mt-md-0">
<%= @address |> BlockScoutWeb.AddressView.address_partial_selector(nil, nil) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<!-- number of txns for this address -->
<span class="mr-4 mb-2">
<span data-test="transaction_count">
<%= transaction_count(@address) %>
</span> <%= gettext "Transactions sent" %>
<% if validator?(@address) do %>
<span data-test="validation_count">
<%= validation_count(@address) %>
</span> <%= gettext "Validations" %>
<% end %>
</span>
</div>
<!-- balance and percentage -->
<div class="col-md-5 d-flex flex-column text-md-right mt-3 mt-md-0">
<!-- address coin balance -->
<span class="tile-title" data-test="address_balance"><%= balance(@address) %></span>
<div class="d-flex flex-column flex-md-row justify-content-md-end">
<!-- USD value of the balance -->
<span
data-wei-value="<%= if @address.fetched_coin_balance, do: @address.fetched_coin_balance.value %>"
data-usd-exchange-rate="<%= @exchange_rate.usd_value %>">
</span>
<!-- percentage of coins from total supply -->
<span class="ml-0 ml-md-2">(<%= balance_percentage(@address) %>)</span>
</div>
</div>
</div>
</div>
</div>
</div>

@ -10,47 +10,11 @@
<span data-selector="top-addresses-list"> <span data-selector="top-addresses-list">
<%= for {address, index} <- Enum.with_index(@addresses, 1) do %> <%= for {address, index} <- Enum.with_index(@addresses, 1) do %>
<div class="tile"> <%= render "_tile.html",
<div class="row"> address: address, index: index, exchange_rate: @exchange_rate,
<!-- rank --> validation_count: validation_count(address) %>
<div class="col-2 col-md-1 d-flex justify-content-center align-items-center">
<!-- incremented number by order in the list -->
<span><%= index %></span>
</div>
<div class="col-10 col-md-11">
<div class="row">
<div class="col-md-7 d-flex flex-column mt-3 mt-md-0">
<%= address |> BlockScoutWeb.AddressView.address_partial_selector(nil, nil) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<!-- number of txns for this address -->
<span>
<span data-test="transaction_count"><%= transaction_count(address) %></span>
<%= gettext "Transactions sent" %>
</span>
</div>
<!-- balance and percentage -->
<div class="col-md-5 d-flex flex-column text-md-right mt-3 mt-md-0">
<!-- address coin balance -->
<span class="tile-title" data-test="address_balance"><%= balance(address) %></span>
<div class="d-flex flex-column flex-md-row justify-content-md-end">
<!-- USD value of the balance -->
<span
data-wei-value="<%= if address.fetched_coin_balance, do: address.fetched_coin_balance.value %>"
data-usd-exchange-rate="<%= @exchange_rate.usd_value %>">
</span>
<!-- percentage of coins from total supply -->
<span class="ml-0 ml-md-2">(<%= balance_percentage(address) %>)</span>
</div>
</div>
</div>
</div>
</div>
</div>
<% end %> <% end %>
</span> </span>
</div> </div>
</div> </div>
</section> </section>

@ -116,6 +116,8 @@ defmodule BlockScoutWeb.AddressView do
def validator?(val) when val > 0, do: true def validator?(val) when val > 0, do: true
def validator?(%Address{} = address), do: Chain.address_to_validation_count(address)
def validator?(_), do: false def validator?(_), do: false
def hash(%Address{hash: hash}) do def hash(%Address{hash: hash}) do
@ -163,6 +165,10 @@ defmodule BlockScoutWeb.AddressView do
Chain.total_transactions_sent_by_address(address) Chain.total_transactions_sent_by_address(address)
end end
def validation_count(%Address{} = address) do
Chain.address_to_validation_count(address)
end
def trimmed_hash(%Hash{} = hash) do def trimmed_hash(%Hash{} = hash) do
string_hash = to_string(hash) string_hash = to_string(hash)
"#{String.slice(string_hash, 0..5)}#{String.slice(string_hash, -6..-1)}" "#{String.slice(string_hash, 0..5)}#{String.slice(string_hash, -6..-1)}"

Loading…
Cancel
Save