From cd46ac01f4e303959a00a852eee3af16f27c85cf Mon Sep 17 00:00:00 2001 From: Leszek Stachowski Date: Tue, 19 Dec 2023 13:23:18 +0100 Subject: [PATCH 1/2] Stats: sunset "Overview" and "Mento" tabs --- apps/block_scout_web/assets/js/pages/stats.js | 9 --- .../controllers/stats_controller.ex | 37 ++++++++++- .../_notification_mento-reserve.html.eex | 5 ++ .../stats/_notification_mento.html.eex | 5 ++ .../stats/_notification_overview.html.eex | 5 ++ .../templates/stats/_tabs.html.eex | 22 +++++++ .../templates/stats/iframe.html.eex | 18 ++++++ .../templates/stats/index.html.eex | 62 ------------------- .../templates/stats/notification.html.eex | 16 +++++ .../lib/block_scout_web/web_router.ex | 11 +++- apps/block_scout_web/priv/gettext/default.pot | 51 ++++++++++++--- .../priv/gettext/en/LC_MESSAGES/default.po | 51 ++++++++++++--- 12 files changed, 199 insertions(+), 93 deletions(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_mento-reserve.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_mento.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_overview.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/stats/_tabs.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/stats/iframe.html.eex delete mode 100644 apps/block_scout_web/lib/block_scout_web/templates/stats/index.html.eex create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/stats/notification.html.eex diff --git a/apps/block_scout_web/assets/js/pages/stats.js b/apps/block_scout_web/assets/js/pages/stats.js index 28a23b69f735..5340c2b79e4b 100644 --- a/apps/block_scout_web/assets/js/pages/stats.js +++ b/apps/block_scout_web/assets/js/pages/stats.js @@ -1,14 +1,5 @@ import $ from 'jquery' -$('.stats-link').on('click', function () { - if ($(this).hasClass('stats-link-no-selection')) { - return - } - - $('ul#topnav .selected').removeClass('selected') - $(this).addClass('selected') -}) - $(window).on('load resize', function () { const width = $(window).width() if (width < 768) { diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/stats_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/stats_controller.ex index dfe560b7e7f9..185e159fc9e7 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/stats_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/stats_controller.ex @@ -2,8 +2,43 @@ defmodule BlockScoutWeb.StatsController do use BlockScoutWeb, :controller def index(conn, _params) do + conn + |> redirect(to: "/stats/overview") + end + + def overview(conn, _params) do + conn + |> put_status(200) + |> render("notification.html", active: "overview") + end + + def addresses(conn, _params) do + conn + |> put_status(200) + |> render("iframe.html", active: "addresses") + end + + def mento(conn, _params) do + conn + |> put_status(200) + |> render("notification.html", active: "mento") + end + + def mento_reserve(conn, _params) do + conn + |> put_status(200) + |> render("notification.html", active: "mento-reserve") + end + + def transactions(conn, _params) do + conn + |> put_status(200) + |> render("iframe.html", active: "transactions") + end + + def epochs(conn, _params) do conn |> put_status(200) - |> render("index.html", token: nil) + |> render("iframe.html", active: "epoch") end end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_mento-reserve.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_mento-reserve.html.eex new file mode 100644 index 000000000000..1c99daeb3d27 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_mento-reserve.html.eex @@ -0,0 +1,5 @@ +

+ <%= gettext "Looking for Mento reserve stats?" %> +

+<%= gettext "You can find them at" %> +<%= gettext "reserve.mento.org" %>. diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_mento.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_mento.html.eex new file mode 100644 index 000000000000..d94f58af1290 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_mento.html.eex @@ -0,0 +1,5 @@ +

+ <%= gettext "Looking for Mento statistics?" %> +

+<%= gettext "You can find them at " %> +<%= gettext "dune.com/mento-labs-eng" %>. diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_overview.html.eex new file mode 100644 index 000000000000..43b651e9db8c --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/stats/_notification_overview.html.eex @@ -0,0 +1,5 @@ +

+ <%= gettext "Looking for blockchain statistics?" %> +

+<%= gettext "You can find them at" %> +<%= gettext "dune.com/celo/celo-blockchain-overview" %>. diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stats/_tabs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stats/_tabs.html.eex new file mode 100644 index 000000000000..2ffb84afc3b7 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/stats/_tabs.html.eex @@ -0,0 +1,22 @@ + diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stats/iframe.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stats/iframe.html.eex new file mode 100644 index 000000000000..de8f26b5e99e --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/stats/iframe.html.eex @@ -0,0 +1,18 @@ +<% stats_enabled = Application.get_env(:block_scout_web, :stats_enabled) %> +<% stats_report_url = Application.get_env(:block_scout_web, :stats_report_url) %> +<%= render BlockScoutWeb.StatsView, "_tabs.html", active: assigns[:active], conn: @conn %> + +
+
+
+
+ <%= if stats_enabled do %> +
+ +
+ <% end %> +
+
+
+ +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stats/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stats/index.html.eex deleted file mode 100644 index dafad2bed6b1..000000000000 --- a/apps/block_scout_web/lib/block_scout_web/templates/stats/index.html.eex +++ /dev/null @@ -1,62 +0,0 @@ -<% stats_enabled = Application.get_env(:block_scout_web, :stats_enabled) %> -<% stats_report_url = Application.get_env(:block_scout_web, :stats_report_url) %> -<% -{:ok, urls} = stats_report_url |> Jason.decode() -%{"overview" => overview_url, "addresses" => addresses_url, "cStables" => cstables_url, "transactions" => transactions_url, "epoch" => epoch_url} = urls -%> - - -
-
- -
-
- <%= if stats_enabled do %> - -
- -
- <% end %> -
-
-
- -
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stats/notification.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stats/notification.html.eex new file mode 100644 index 000000000000..47c72e58a9b8 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/stats/notification.html.eex @@ -0,0 +1,16 @@ +<%= render BlockScoutWeb.StatsView, "_tabs.html", active: assigns[:active], conn: @conn %> + +
+
+
+
+
+
+ <%= render BlockScoutWeb.StatsView, "_notification_#{assigns[:active]}.html", active: assigns[:active] %> +
+
+
+
+
+ +
diff --git a/apps/block_scout_web/lib/block_scout_web/web_router.ex b/apps/block_scout_web/lib/block_scout_web/web_router.ex index 2fc37c96a02e..48cacf61519c 100644 --- a/apps/block_scout_web/lib/block_scout_web/web_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/web_router.ex @@ -525,7 +525,16 @@ defmodule BlockScoutWeb.WebRouter do get("/token-counters", Tokens.TokenController, :token_counters) - get("/stats", StatsController, :index) + + scope "/stats" do + get("/", StatsController, :index, as: :stats_index) + get("/overview", StatsController, :overview, as: :stats_overview) + get("/addresses", StatsController, :addresses, as: :stats_addresses) + get("/mento", StatsController, :mento, as: :stats_mento) + get("/mento-reserve", StatsController, :mento_reserve, as: :stats_mento_reserve) + get("/transactions", StatsController, :transactions, as: :stats_transactions) + get("/epoch-rewards", StatsController, :epochs, as: :stats_epoch_rewards) + end get("/visualize/sol2uml", VisualizeSol2umlController, :index) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 268b33cd9b34..eb4713fdeaa9 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -266,7 +266,7 @@ msgid "Address*" msgstr "" #: lib/block_scout_web/templates/address/index.html.eex:4 -#: lib/block_scout_web/templates/stats/index.html.eex:17 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:7 #, elixir-autogen, elixir-format msgid "Addresses" msgstr "" @@ -2838,7 +2838,7 @@ msgstr "" #: lib/block_scout_web/templates/block/overview.html.eex:120 #: lib/block_scout_web/templates/chain/show.html.eex:210 #: lib/block_scout_web/templates/layout/_topnav.html.eex:46 -#: lib/block_scout_web/templates/stats/index.html.eex:37 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:16 #: lib/block_scout_web/views/address_view.ex:433 #, elixir-autogen, elixir-format msgid "Transactions" @@ -3496,7 +3496,7 @@ msgstr "" msgid "Epoch Blocks" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:42 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:19 #, elixir-autogen, elixir-format msgid "Epoch Rewards" msgstr "" @@ -3574,12 +3574,12 @@ msgstr "" msgid "Locked CELO Balance" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:22 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:10 #, elixir-autogen, elixir-format msgid "Mento" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:32 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:13 #, elixir-autogen, elixir-format msgid "Mento Reserve" msgstr "" @@ -3609,7 +3609,7 @@ msgstr "" msgid "Online" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:12 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:4 #, elixir-autogen, elixir-format msgid "Overview" msgstr "" @@ -3890,12 +3890,43 @@ msgstr "" msgid "There are no unsigned blocks for this address." msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:30 +#: lib/block_scout_web/templates/stats/_notification_mento-reserve.html.eex:5 #, elixir-autogen, elixir-format -msgid "Looking for Mento reserve stats? You can find them at " +msgid "reserve.mento.org" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:30 +#: lib/block_scout_web/templates/stats/_notification_mento-reserve.html.eex:2 #, elixir-autogen, elixir-format -msgid "reserve.mento.org" +msgid "Looking for Mento reserve stats?" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_mento.html.eex:2 +#, elixir-autogen, elixir-format +msgid "Looking for Mento statistics?" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_overview.html.eex:2 +#, elixir-autogen, elixir-format +msgid "Looking for blockchain statistics?" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_mento-reserve.html.eex:4 +#: lib/block_scout_web/templates/stats/_notification_overview.html.eex:4 +#, elixir-autogen, elixir-format +msgid "You can find them at" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_mento.html.eex:4 +#, elixir-autogen, elixir-format +msgid "You can find them at " +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_overview.html.eex:5 +#, elixir-autogen, elixir-format +msgid "dune.com/celo/celo-blockchain-overview" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_mento.html.eex:5 +#, elixir-autogen, elixir-format +msgid "dune.com/mento-labs-eng" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 248cea3a41a9..e5f259419e46 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -266,7 +266,7 @@ msgid "Address*" msgstr "" #: lib/block_scout_web/templates/address/index.html.eex:4 -#: lib/block_scout_web/templates/stats/index.html.eex:17 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:7 #, elixir-autogen, elixir-format msgid "Addresses" msgstr "" @@ -2838,7 +2838,7 @@ msgstr "" #: lib/block_scout_web/templates/block/overview.html.eex:120 #: lib/block_scout_web/templates/chain/show.html.eex:210 #: lib/block_scout_web/templates/layout/_topnav.html.eex:46 -#: lib/block_scout_web/templates/stats/index.html.eex:37 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:16 #: lib/block_scout_web/views/address_view.ex:433 #, elixir-autogen, elixir-format msgid "Transactions" @@ -3496,7 +3496,7 @@ msgstr "" msgid "Epoch Blocks" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:42 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:19 #, elixir-autogen, elixir-format msgid "Epoch Rewards" msgstr "" @@ -3574,12 +3574,12 @@ msgstr "" msgid "Locked CELO Balance" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:22 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:10 #, elixir-autogen, elixir-format msgid "Mento" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:32 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:13 #, elixir-autogen, elixir-format msgid "Mento Reserve" msgstr "" @@ -3609,7 +3609,7 @@ msgstr "" msgid "Online" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:12 +#: lib/block_scout_web/templates/stats/_tabs.html.eex:4 #, elixir-autogen, elixir-format msgid "Overview" msgstr "" @@ -3890,12 +3890,43 @@ msgstr "" msgid "There are no unsigned blocks for this address." msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:30 +#: reserve.html.eex:5 #, elixir-autogen, elixir-format -msgid "Looking for Mento reserve stats? You can find them at " +msgid "reserve.mento.org" msgstr "" -#: lib/block_scout_web/templates/stats/index.html.eex:30 +#: reserve.html.eex:2 +#, elixir-autogen, elixir-format, fuzzy +msgid "Looking for Mento reserve stats?" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_mento.html.eex:2 #, elixir-autogen, elixir-format -msgid "reserve.mento.org" +msgid "Looking for Mento statistics?" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_overview.html.eex:2 +#, elixir-autogen, elixir-format +msgid "Looking for blockchain statistics?" +msgstr "" + +#: reserve.html.eex:4 +#: lib/block_scout_web/templates/stats/_notification_overview.html.eex:4 +#, elixir-autogen, elixir-format +msgid "You can find them at" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_mento.html.eex:4 +#, elixir-autogen, elixir-format +msgid "You can find them at " +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_overview.html.eex:5 +#, elixir-autogen, elixir-format +msgid "dune.com/celo/celo-blockchain-overview" +msgstr "" + +#: lib/block_scout_web/templates/stats/_notification_mento.html.eex:5 +#, elixir-autogen, elixir-format +msgid "dune.com/mento-labs-eng" msgstr "" From 3440b26dece64c0d6f3daf2c6c542f88b36bcd5d Mon Sep 17 00:00:00 2001 From: Leszek Stachowski Date: Tue, 19 Dec 2023 13:39:30 +0100 Subject: [PATCH 2/2] mix format --- apps/block_scout_web/lib/block_scout_web/web_router.ex | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/web_router.ex b/apps/block_scout_web/lib/block_scout_web/web_router.ex index 48cacf61519c..434e7061adb6 100644 --- a/apps/block_scout_web/lib/block_scout_web/web_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/web_router.ex @@ -525,7 +525,6 @@ defmodule BlockScoutWeb.WebRouter do get("/token-counters", Tokens.TokenController, :token_counters) - scope "/stats" do get("/", StatsController, :index, as: :stats_index) get("/overview", StatsController, :overview, as: :stats_overview)