Add API_URL var to link to api instance

pull/2376/head
saneery 5 years ago
parent b7732d88cd
commit 7f02b77ff6
  1. 3
      apps/block_scout_web/config/config.exs
  2. 8
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  3. 14
      apps/block_scout_web/lib/block_scout_web/views/layout_view.ex

@ -29,7 +29,8 @@ config :block_scout_web,
"Bloxy" => "https://bloxy.info/"
},
other_networks: System.get_env("SUPPORTED_CHAINS"),
webapp_url: System.get_env("WEBAPP_URL")
webapp_url: System.get_env("WEBAPP_URL"),
api_url: System.get_env("API_URL")
config :block_scout_web, BlockScoutWeb.Counters.BlocksIndexedCounter, enabled: true

@ -68,7 +68,7 @@
<% end %>
</li>
<% end %>
<%= if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter)[:enabled] do %>
<%= if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter)[:enabled] or Application.get_env(:block_scout_web, :api_url) do %>
<li class="nav-item dropdown">
<a href="#" role="button" id="navbarAPIsDropdown" class="nav-link topnav-nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="nav-link-icon">
@ -80,17 +80,17 @@
<%= link(
gettext("GraphQL"),
class: "dropdown-item #{tab_status("graphiql", @conn.request_path)}",
to: "/graphiql"
to: api_url() <> "/graphiql"
) %>
<%= link(
gettext("RPC"),
class: "dropdown-item #{tab_status("api_docs", @conn.request_path)}",
to: api_docs_path(@conn, :index)
to: api_url() <> api_docs_path(@conn, :index)
) %>
<%= link(
gettext("Eth RPC"),
class: "dropdown-item #{tab_status("api_docs", @conn.request_path)}",
to: api_docs_path(@conn, :eth_rpc)
to: api_url() <> api_docs_path(@conn, :eth_rpc)
) %>
</div>
</li>

@ -229,13 +229,23 @@ defmodule BlockScoutWeb.LayoutView do
end
end
defp webapp_url(conn) do
def webapp_url(conn) do
:block_scout_web
|> Application.get_env(:webapp_url)
|> validate_url()
|> case do
:error -> chain_path(conn, :show)
url -> url
{:ok, url} -> url
end
end
def api_url do
:block_scout_web
|> Application.get_env(:api_url)
|> validate_url()
|> case do
:error -> ""
{:ok, url} -> url
end
end

Loading…
Cancel
Save