add a modal fo the validator info

gsf-validator-metadata
Gustavo Santos Ferreira 6 years ago
parent ebf0aa6860
commit add2b2c213
  1. 41
      apps/block_scout_web/lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex
  2. 14
      apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex
  3. 28
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex

@ -0,0 +1,41 @@
<div class="modal fade" id="validatorModal" tabindex="-1" role="dialog" aria-labelledby="validatorModalLabel" aria-hidden="true">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="validatorModalLabel"><%= gettext"Validator Data" %></h2>
</div>
<div class="modal-body">
<h1 class="text-center"><%= @address_name %></h1>
<div class="row mt-2">
<div class="col-sm-4 text-right text-muted"><%= gettext"License ID" %></div>
<div class="col-sm-8">
<%= @validator_metadata["license_id"] %>
</div>
</div>
<div class="row mt-2">
<div class="col-sm-4 text-right text-muted"><%= gettext"Address" %></div>
<div class="col-sm-8">
<%= @validator_metadata["address"] %>,
<%= @validator_metadata["state"] %>,
<%= @validator_metadata["zipcode"] %>
</div>
</div>
<div class="row mt-2">
<div class="col-sm-4 text-right text-muted"><%= gettext"License Expires" %></div>
<div class="col-sm-8">
<%= format_datetime_string(@validator_metadata["expiration_date"]) %>
</div>
</div>
<div class="row mt-2">
<div class="col-sm-4 text-right text-muted"><%= gettext"Validator Creation Date" %></div>
<div class="col-sm-8">
<%= format_datetime_string(@validator_metadata["created_date"]) %>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal"><%= gettext "Close" %></button>
</div>
</div>
</div>
</div>

@ -14,6 +14,13 @@
<i class="fas fa-qrcode"></i> <i class="fas fa-qrcode"></i>
</button> </button>
</span> </span>
<%= if validator_metadata = primary_validator_metadata(@address) do %>
<span data-toggle="modal" data-target="#validatorModal">
<button type="button" class="icon-link" data-toggle="tooltip" data-placement="top" title="<%= gettext("Validator Info") %>" aria-label="<%= gettext("Show Validator Info") %>">
<i class="fas fa-address-card"></i>
</button>
</span>
<% end %>
</div> </div>
<h1 class="card-title"><%= address_title(@address) %> <%= gettext "Details" %> </h1> <h1 class="card-title"><%= address_title(@address) %> <%= gettext "Details" %> </h1>
<h3 class="<%= if BlockScoutWeb.AddressView.contract?(@address) do %>contract-address<% end %>" data-test="address_detail_hash"><%= @address.hash %></h3> <h3 class="<%= if BlockScoutWeb.AddressView.contract?(@address) do %>contract-address<% end %>" data-test="address_detail_hash"><%= @address.hash %></h3>
@ -65,7 +72,7 @@
</div> </div>
</section> </section>
<!-- Modal --> <!-- Modal QR -->
<div class="modal fade" id="qrModal" tabindex="-1" role="dialog" aria-labelledby="qrModalLabel" aria-hidden="true"> <div class="modal fade" id="qrModal" tabindex="-1" role="dialog" aria-labelledby="qrModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm" role="document"> <div class="modal-dialog modal-sm" role="document">
<div class="modal-content"> <div class="modal-content">
@ -84,3 +91,8 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Modal Validator -->
<%= if validator_metadata do %>
<%= render BlockScoutWeb.AddressView, "_validator_metadata_modal.html", address_name: address_name, validator_metadata: validator_metadata %>
<% end %>

@ -148,6 +148,34 @@ defmodule BlockScoutWeb.AddressView do
def primary_name(%Address{names: _}), do: nil def primary_name(%Address{names: _}), do: nil
def primary_validator_metadata(%Address{names: [_ | _] = address_names}) do
case Enum.find(address_names, &(&1.primary == true)) do
%Address.Name{
metadata:
metadata = %{
"license_id" => _,
"address" => _,
"state" => _,
"zipcode" => _,
"expiration_date" => _,
"created_date" => _
}
} ->
metadata
_ ->
nil
end
end
def primary_validator_metadata(%Address{names: _}), do: nil
def format_datetime_string(unix_date) do
unix_date
|> DateTime.from_unix!()
|> Timex.format!("{M}-{D}-{YYYY}")
end
def qr_code(%Address{hash: hash}) do def qr_code(%Address{hash: hash}) do
hash hash
|> to_string() |> to_string()

Loading…
Cancel
Save