Heex + API for blocchaininfo

This commit is contained in:
nha dev 2022-05-03 19:01:29 +05:30
parent b5bd4b5bf3
commit 1cee6135d4
7 changed files with 50 additions and 30 deletions

View File

@ -155,4 +155,12 @@ defmodule ZcashExplorerWeb.PageController do
def blockchain_info(conn, _params) do
render(conn, "blockchain_info.html", page_title: "Zcash Blockchain Info")
end
def blockchain_info_api(conn, _params) do
{:ok, info} = Cachex.get(:app_cache, "metrics")
{:ok, %{"build" => build}} = Cachex.get(:app_cache, "info")
info = Map.put(info, "build", build)
json(conn, info)
end
end

View File

@ -49,7 +49,7 @@ defmodule ZcashExplorerWeb.Router do
scope "/", ZcashExplorerWeb do
pipe_through :api
get "/api/v1/blockchain-info", PageController, :blockchain_info_api
post "/api/vk/:hostname", PageController, :vk_from_zecwalletcli
end

View File

@ -9,7 +9,7 @@
<%= @address %>
</p>
<div class="px-0">
<img src='data:image/png;base64, <%= @qr %>' atl="QR code for the Zcash address <%= @address %>"/>
<img src={'data:image/png;base64, #{ @qr }'} atl={"QR code for the Zcash address #{ @address }"}/>
</div>
<div>
@ -56,11 +56,9 @@
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-span-3 md:col-span-2 lg:col-span-2 sm:col-span-3
">
<div class="bg-white px-4 py-5 shadow rounded-lg sm:px-6">
@ -71,9 +69,7 @@
<span class="block text-indigo-600 inline">Private.</span>
</h2>
</div>
</div>
</div>
</div>
</main>

View File

@ -19,12 +19,15 @@
<%= for block <- @blocks_data do %>
<tr class="hover:bg-indigo-50">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-indigo-600 hover:text-indigo-500">
<a href='/blocks/<%= block["height"] %>'>
<a href={'/blocks/#{block["height"]}'}>
<%= block["height"] %>
</td>
</a>
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm font-medium text-gray-500">
<a href='/blocks/<%= block["hash"] %>'>
<a href={'/blocks/#{block["hash"] }'}>
<%= block["hash"] %>
</a>
</td>
@ -42,6 +45,7 @@
</tr>
<% end %>
</tbody>
</table>
</div>
@ -51,13 +55,13 @@
<div class="flex-1 flex justify-between sm:justify-end">
<%= if !@disable_previous do %>
<a href='/blocks?date=<%= @previous %>' class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
<a href={'/blocks?date=#{@previous}'} class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
Previous
</a>
<% end %>
<%= if !@disable_next do %>
<a href="/blocks?date=<%= @next %>" class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
<a href={'/blocks?date=#{@next}'} class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
Next
</a>
<% end %>

View File

@ -31,7 +31,8 @@
<dt class="text-sm font-medium text-gray-500">
Miner
</dt>
<a href='/address/<%= mined_by(@block_data.tx) %>'>
<a href={'/address/#{mined_by(@block_data.tx)}'}>
<dd class="mt-1 text-sm text-indigo-600 hover:text-indigo-500 break-words">
<%= mined_by @block_data.tx %>
</dd>
@ -150,7 +151,7 @@
</dd>
</div>
</div>
</dl>
</div>
</section>
<div class="space-y-6 lg:col-start-1 lg:col-span-4">
@ -188,7 +189,8 @@
<%= @block_data.height %>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-indigo-600 hover:text-indigo-500">
<a href='/transactions/<%= transaction.txid %>'>
<a href={'/transactions/#{transaction.txid}'}>
<%= transaction.txid %>
</a>
</td>

View File

@ -83,7 +83,7 @@
Block Id
</dt>
<dd class="mt-1 text-sm text-gray-900 break-words">
<a href='/blocks/<%= @tx.blockhash %>'>
<a href={'/blocks/#{@tx.height}'}>
<%= @tx.height %>
</a>
</dd>
@ -217,7 +217,10 @@ Inputs (<%= vin_count(@tx.vin) %>)
<li class="pl-3 pr-4 py-3 flex items-center justify-between text-sm hover:bg-indigo-50">
<div class="w-0 flex-1 flex items-center">
<a href='/address/<%= input.address %>'>
<a href={'/address/#{input.address}'}>
<span class="flex-1 w-0 break-all">
<%= input.address %>
</span>
@ -263,17 +266,21 @@ Inputs (<%= vin_count(@tx.vin) %>)
Outputs (<%= vout_count(@tx.vout) %>)
<div class="py-3">
<%= if vout_count(@tx.vout) > 0 do %>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2 py-2">
<ul class="border border-gray-200 rounded-md divide-y divide-gray-200">
<%= for op <- @tx.vout do %>
<%= for address <- op.scriptPubKey.addresses do %>
<li class="pl-2 pr-4 py-3 flex items-center justify-between text-sm hover:bg-indigo-50">
<a href='/address/<%= address %>'>
<div class="w-0 flex-1 flex items-center">
<a href={'/address/#{address }'}>
<span class="flex-1 w-0 break-all">
<%= address %>
</span>
</a>
</div>
@ -303,4 +310,5 @@ Outputs (<%= vout_count(@tx.vout) %>)
</div>
</div>
</div>
</div>
</main>