Changes related to LiveView Update

This commit is contained in:
nha dev 2022-04-11 18:22:11 +05:30
parent b710eeec99
commit 518a6b2a26
19 changed files with 51 additions and 31 deletions

View File

@ -32,5 +32,6 @@ let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("
let liveSocket = new LiveSocket("/live", Socket, { hooks: Hooks, params: { _csrf_token: csrfToken } }) let liveSocket = new LiveSocket("/live", Socket, { hooks: Hooks, params: { _csrf_token: csrfToken } })
liveSocket.connect() liveSocket.connect()
window.liveSocket = liveSocket window.liveSocket = liveSocket
liveSocket.enableDebug()

View File

@ -29,7 +29,6 @@ defmodule ZcashExplorerWeb do
def view do def view do
quote do quote do
import Phoenix.LiveView.Helpers
use Phoenix.View, use Phoenix.View,
root: "lib/zcash_explorer_web/templates", root: "lib/zcash_explorer_web/templates",
@ -39,6 +38,8 @@ defmodule ZcashExplorerWeb do
import Phoenix.Controller, import Phoenix.Controller,
only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1] only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
import Phoenix.LiveView.Helpers
# Include shared imports and aliases for views # Include shared imports and aliases for views
unquote(view_helpers()) unquote(view_helpers())
end end
@ -61,6 +62,23 @@ defmodule ZcashExplorerWeb do
end end
end end
def live_view do
quote do
use Phoenix.LiveView,
layout: {ZcashExplorerWeb.LayoutView, "live.html"}
unquote(view_helpers())
end
end
def live_component do
quote do
use Phoenix.LiveComponent
unquote(view_helpers())
end
end
defp view_helpers do defp view_helpers do
quote do quote do
# Use all HTML functionality (forms, tags, etc) # Use all HTML functionality (forms, tags, etc)

View File

@ -1,5 +1,6 @@
defmodule ZcashExplorerWeb.BlockCountLive do defmodule ZcashExplorerWeb.BlockCountLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do

View File

@ -1,6 +1,7 @@
defmodule ZcashExplorerWeb.BlockChainInfoLive do defmodule ZcashExplorerWeb.BlockChainInfoLive do
use Phoenix.LiveView
use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.BlockChainSizeLive do defmodule ZcashExplorerWeb.BlockChainSizeLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.DifficultyLive do defmodule ZcashExplorerWeb.DifficultyLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.MempoolInfoLive do defmodule ZcashExplorerWeb.MempoolInfoLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.NetworkSolpsLive do defmodule ZcashExplorerWeb.NetworkSolpsLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.NodesLive do defmodule ZcashExplorerWeb.NodesLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.PriceLive do defmodule ZcashExplorerWeb.PriceLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.RawMempoolLive do defmodule ZcashExplorerWeb.RawMempoolLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.RecentBlocksLive do defmodule ZcashExplorerWeb.RecentBlocksLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.RecentTransactionsLive do defmodule ZcashExplorerWeb.RecentTransactionsLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(assigns) do def render(assigns) do
~L""" ~L"""

View File

@ -1,6 +1,6 @@
defmodule ZcashExplorerWeb.VkLive do defmodule ZcashExplorerWeb.VkLive do
use Phoenix.LiveView use ZcashExplorerWeb, :live_view
import Phoenix.LiveView.Helpers
@impl true @impl true
def render(%{message: %{"txs" => []}} = assigns) do def render(%{message: %{"txs" => []}} = assigns) do
~L""" ~L"""

View File

@ -6,7 +6,7 @@
<div class="flex items-center px-2 lg:px-0 xl:w-64"> <div class="flex items-center px-2 lg:px-0 xl:w-64">
<a href="/"> <a href="/">
<div class="flex-shrink-0"> <div class="flex-shrink-0">
<img class="h-8 w-auto" src="<%= Routes.static_path(@conn, "/images/zcash-icon-white.svg") %>" alt="Block Explorer"> <img class="h-8 w-auto" src={"#{ Routes.static_path(@conn, "/images/zcash-icon-white.svg")}"} alt="Block Explorer">
</div> </div>
</a> </a>
<a href="/"> <a href="/">
@ -78,8 +78,6 @@ Heroicon name: outline/x" x-state:on="Menu open" x-state:off="Menu closed" class
</div> </div>
</div> </div>
</div> </div>
</div>
<div x-description="Mobile menu, show/hide based on menu state." class="lg:hidden" id="mobile-menu" x-show="open"> <div x-description="Mobile menu, show/hide based on menu state." class="lg:hidden" id="mobile-menu" x-show="open">
<div class="px-2 pt-2 pb-3"> <div class="px-2 pt-2 pb-3">

View File

@ -0,0 +1 @@
<%= @inner_content %>

View File

@ -5,9 +5,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<%= live_title_tag assigns[:page_title] || " " %> <%= live_title_tag assigns[:page_title] || " " %>
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/> <link rel="stylesheet" href={"#{Routes.static_path(@conn, "/css/app.css")}"}/>
<%= csrf_meta_tag() %> <%= csrf_meta_tag() %>
<script defer type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script> <script defer type="text/javascript" src={"#{Routes.static_path(@conn, "/js/app.js")}"}></script>
</head> </head>
<body> <body>
<%= @inner_content %> <%= @inner_content %>