From df1d03433978c6e2f330f121795fc7cd7c8ed24e Mon Sep 17 00:00:00 2001 From: Ryan Arthur Date: Fri, 25 May 2018 16:06:40 -0400 Subject: [PATCH 01/16] Rename scss partials --- apps/explorer_web/assets/css/{code.scss => _code.scss} | 0 apps/explorer_web/assets/css/{tooltip.scss => _tooltip.scss} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename apps/explorer_web/assets/css/{code.scss => _code.scss} (100%) rename apps/explorer_web/assets/css/{tooltip.scss => _tooltip.scss} (100%) diff --git a/apps/explorer_web/assets/css/code.scss b/apps/explorer_web/assets/css/_code.scss similarity index 100% rename from apps/explorer_web/assets/css/code.scss rename to apps/explorer_web/assets/css/_code.scss diff --git a/apps/explorer_web/assets/css/tooltip.scss b/apps/explorer_web/assets/css/_tooltip.scss similarity index 100% rename from apps/explorer_web/assets/css/tooltip.scss rename to apps/explorer_web/assets/css/_tooltip.scss From 1777c11fd1209e95b2ef686900b5c7bda1ccab6e Mon Sep 17 00:00:00 2001 From: Ryan Arthur Date: Fri, 25 May 2018 16:08:36 -0400 Subject: [PATCH 02/16] Add markup for the qr code link and modal in the adress overview --- apps/explorer_web/assets/css/_content.scss | 4 +- apps/explorer_web/assets/css/app.scss | 5 +++ .../templates/address/overview.html.eex | 38 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/apps/explorer_web/assets/css/_content.scss b/apps/explorer_web/assets/css/_content.scss index 00e0b33e69..098d6a77ab 100644 --- a/apps/explorer_web/assets/css/_content.scss +++ b/apps/explorer_web/assets/css/_content.scss @@ -19,7 +19,7 @@ display: flex; position: fixed; width: 100%; - z-index: 10001; + z-index: 1001; } .container { @@ -32,7 +32,7 @@ } @media (max-width: 768px) { - + #content { height: 100%; } diff --git a/apps/explorer_web/assets/css/app.scss b/apps/explorer_web/assets/css/app.scss index ea2b41c577..7218895964 100644 --- a/apps/explorer_web/assets/css/app.scss +++ b/apps/explorer_web/assets/css/app.scss @@ -20,6 +20,11 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "node_modules/bootstrap/scss/reboot"; @import "node_modules/bootstrap/scss/grid"; @import "node_modules/bootstrap/scss/code"; +@import "node_modules/bootstrap/scss/modal"; +@import "node_modules/bootstrap/scss/close"; +@import "node_modules/bootstrap/scss/buttons"; +@import "node_modules/bootstrap/scss/forms"; +@import "node_modules/bootstrap/scss/input-group"; @import "node_modules/bootstrap/scss/utilities/spacing"; @import "node_modules/bootstrap/scss/utilities/sizing"; @import "node_modules/bootstrap/scss/utilities/display"; diff --git a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex index e9e3feaa00..5bc8c64f9d 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex @@ -8,6 +8,17 @@
+ + + + + + + + From 14fa5a3911f1f55008dcb22f1fd9037c52d18615 Mon Sep 17 00:00:00 2001 From: Tim Mecklem Date: Wed, 30 May 2018 11:39:40 -0400 Subject: [PATCH 05/16] Add QR code library and address QR code controller --- .../explorer_web/controllers/address_qr_code_controller.ex | 7 +++++++ apps/explorer_web/lib/explorer_web/router.ex | 2 ++ .../lib/explorer_web/templates/address/overview.html.eex | 2 +- apps/explorer_web/mix.exs | 3 ++- mix.lock | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex diff --git a/apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex new file mode 100644 index 0000000000..73331d7abb --- /dev/null +++ b/apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex @@ -0,0 +1,7 @@ +defmodule ExplorerWeb.AddressQRCodeController do + use ExplorerWeb, :controller + + def index(conn, %{"address_id" => id}) do + send_download(conn, {:binary, QRCode.to_png(id)}, "content-type": "image/png", filename: "#{id}.png") + end +end diff --git a/apps/explorer_web/lib/explorer_web/router.ex b/apps/explorer_web/lib/explorer_web/router.ex index a5e137d319..efe52f0ba7 100644 --- a/apps/explorer_web/lib/explorer_web/router.ex +++ b/apps/explorer_web/lib/explorer_web/router.ex @@ -80,6 +80,8 @@ defmodule ExplorerWeb.Router do only: [:index], as: :contract ) + + resources("/qrcode", AddressQRCodeController, only: [:index], as: :qr_code) end get("/search", ChainController, :search) diff --git a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex index 7bb248f0cf..ee5072f804 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex @@ -69,7 +69,7 @@ - qr_code + <%= img_tag(address_qr_code_path(@conn, :index, @conn.assigns.locale, @address), alt: "qr_code") %> - <%= img_tag(address_qr_code_path(@conn, :index, @conn.assigns.locale, @address), alt: "qr_code") %> + <%= img_tag(address_qr_code_path(@conn, :index, @conn.assigns.locale, @address), alt: "qr_code", class: "qr-code") %> From 2911dbaca05aff7a70bb7784a005894c6d7d00b4 Mon Sep 17 00:00:00 2001 From: Ryan Arthur Date: Thu, 31 May 2018 10:40:30 -0400 Subject: [PATCH 11/16] Move the QR code to the page header and remove the modal --- .../assets/css/components/_qr-code.scss | 5 +- .../templates/address/overview.html.eex | 53 +++++-------------- 2 files changed, 17 insertions(+), 41 deletions(-) diff --git a/apps/explorer_web/assets/css/components/_qr-code.scss b/apps/explorer_web/assets/css/components/_qr-code.scss index 5952705bba..5323908d28 100644 --- a/apps/explorer_web/assets/css/components/_qr-code.scss +++ b/apps/explorer_web/assets/css/components/_qr-code.scss @@ -1,4 +1,7 @@ .qr-code { display: block; - margin: auto; + margin-right: auto; + margin-left: auto; + width: 100%; + max-width: 60px; } diff --git a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex index 4b5793090a..bd49f9e403 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex @@ -1,6 +1,17 @@
-

<%= address_title(@address) %>

-

<%= @address %>

+
+
+
+
+ <%= img_tag(address_qr_code_path(@conn, :index, @conn.assigns.locale, @address), alt: "qr_code", class: "qr-code") %> +
+
+
+
+

<%= gettext "Address" %>

+

<%= @address %>

+
+
@@ -8,17 +19,6 @@
+ <%= gettext "QR Code" %> + + + +
<%= gettext "Balance" %> @@ -32,3 +43,30 @@ + + + From 8e46203f73e371a24b330bf0b64243e6d1cf2627 Mon Sep 17 00:00:00 2001 From: Ryan Arthur Date: Tue, 29 May 2018 15:28:13 -0400 Subject: [PATCH 03/16] Wordsmithing --- .../lib/explorer_web/templates/address/overview.html.eex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex index 5bc8c64f9d..58d3fb5884 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex @@ -10,7 +10,7 @@
- <%= gettext "QR Code" %> + <%= gettext "Copy Address" %> @@ -49,7 +49,7 @@
- <%= gettext "Balance" %> + <%= gettext "POA Balance" %> - <%= balance(@address) %>
+ <%= balance(@address) %> +
+ <%= gettext "USD Balance" %> + <%= formatted_usd(@address, @exchange_rate) %>
- <%= gettext "Copy Address" %> + <%= gettext "Overview" %> - + + +
- - - - + + + + @@ -144,10 +151,17 @@ + + + + From ea89902120970d0e446e3cdccd1fbb6a19576924 Mon Sep 17 00:00:00 2001 From: Tim Mecklem Date: Fri, 1 Jun 2018 13:49:34 -0400 Subject: [PATCH 14/16] `mix gettext.extract --merge` --- apps/explorer_web/priv/gettext/default.pot | 50 +++++++++++-------- .../priv/gettext/en/LC_MESSAGES/default.po | 50 +++++++++++-------- 2 files changed, 60 insertions(+), 40 deletions(-) diff --git a/apps/explorer_web/priv/gettext/default.pot b/apps/explorer_web/priv/gettext/default.pot index 3412f87e67..d02a3249e7 100644 --- a/apps/explorer_web/priv/gettext/default.pot +++ b/apps/explorer_web/priv/gettext/default.pot @@ -5,7 +5,7 @@ #: lib/explorer_web/templates/chain/_blocks.html.eex:8 #: lib/explorer_web/templates/chain/_transactions.html.eex:11 #: lib/explorer_web/templates/transaction/index.html.eex:36 -#: lib/explorer_web/templates/transaction/overview.html.eex:38 +#: lib/explorer_web/templates/transaction/overview.html.eex:49 msgid "Age" msgstr "" @@ -29,7 +29,7 @@ msgstr "" #: lib/explorer_web/templates/block/index.html.eex:20 #: lib/explorer_web/templates/block_transaction/index.html.eex:88 -#: lib/explorer_web/templates/transaction/overview.html.eex:145 +#: lib/explorer_web/templates/transaction/overview.html.eex:170 msgid "Gas Used" msgstr "" @@ -67,7 +67,8 @@ msgstr "" #: lib/explorer_web/templates/chain/_transactions.html.eex:10 #: lib/explorer_web/templates/pending_transaction/index.html.eex:39 #: lib/explorer_web/templates/transaction/index.html.eex:39 -#: lib/explorer_web/templates/transaction/overview.html.eex:46 +#: lib/explorer_web/templates/transaction/overview.html.eex:57 +#: lib/explorer_web/templates/transaction/overview.html.eex:65 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:33 msgid "Value" msgstr "" @@ -82,7 +83,7 @@ msgstr "" #: lib/explorer_web/templates/block/index.html.eex:21 #: lib/explorer_web/templates/block_transaction/index.html.eex:96 -#: lib/explorer_web/templates/transaction/overview.html.eex:119 +#: lib/explorer_web/templates/transaction/overview.html.eex:137 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:34 msgid "Gas Limit" msgstr "" @@ -92,7 +93,7 @@ msgid "Miner" msgstr "" #: lib/explorer_web/templates/block_transaction/index.html.eex:104 -#: lib/explorer_web/templates/transaction/overview.html.eex:87 +#: lib/explorer_web/templates/transaction/overview.html.eex:105 msgid "Nonce" msgstr "" @@ -116,11 +117,11 @@ msgstr "" msgid "Total Difficulty" msgstr "" -#: lib/explorer_web/templates/transaction/overview.html.eex:22 +#: lib/explorer_web/templates/transaction/overview.html.eex:33 msgid "Block Number" msgstr "" -#: lib/explorer_web/templates/transaction/overview.html.eex:2 +#: lib/explorer_web/templates/transaction/overview.html.eex:11 msgid "Transaction Details" msgstr "" @@ -136,15 +137,15 @@ msgid "Gas" msgstr "" #: lib/explorer_web/templates/block/index.html.eex:22 -#: lib/explorer_web/templates/transaction/overview.html.eex:127 +#: lib/explorer_web/templates/transaction/overview.html.eex:145 msgid "Gas Price" msgstr "" -#: lib/explorer_web/templates/transaction/overview.html.eex:153 +#: lib/explorer_web/templates/transaction/overview.html.eex:178 msgid "Input" msgstr "" -#: lib/explorer_web/templates/transaction/overview.html.eex:33 +#: lib/explorer_web/templates/transaction/overview.html.eex:44 msgid "%{confirmations} block confirmations" msgstr "" @@ -152,6 +153,7 @@ msgstr "" msgid "%{count} transactions in this block" msgstr "" +#: lib/explorer_web/templates/address/overview.html.eex:11 #: lib/explorer_web/templates/transaction_log/index.html.eex:29 #: lib/explorer_web/views/address_view.ex:17 msgid "Address" @@ -165,7 +167,7 @@ msgstr "" #: lib/explorer_web/templates/chain/_transactions.html.eex:8 #: lib/explorer_web/templates/pending_transaction/index.html.eex:37 #: lib/explorer_web/templates/transaction/index.html.eex:37 -#: lib/explorer_web/templates/transaction/overview.html.eex:55 +#: lib/explorer_web/templates/transaction/overview.html.eex:73 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:31 #: lib/explorer_web/views/address_internal_transaction_view.ex:9 #: lib/explorer_web/views/address_transaction_view.ex:11 @@ -189,7 +191,7 @@ msgstr "" #: lib/explorer_web/templates/chain/_transactions.html.eex:9 #: lib/explorer_web/templates/pending_transaction/index.html.eex:38 #: lib/explorer_web/templates/transaction/index.html.eex:38 -#: lib/explorer_web/templates/transaction/overview.html.eex:71 +#: lib/explorer_web/templates/transaction/overview.html.eex:89 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:32 #: lib/explorer_web/views/address_internal_transaction_view.ex:8 #: lib/explorer_web/views/address_transaction_view.ex:10 @@ -201,11 +203,12 @@ msgstr "" msgid "Transaction Hash" msgstr "" -#: lib/explorer_web/templates/transaction/overview.html.eex:13 +#: lib/explorer_web/templates/transaction/overview.html.eex:24 msgid "Transaction Status" msgstr "" -#: lib/explorer_web/templates/address/overview.html.eex:13 +#: lib/explorer_web/templates/address/overview.html.eex:24 +#: lib/explorer_web/templates/address/overview.html.eex:32 msgid "Balance" msgstr "" @@ -235,8 +238,8 @@ msgstr "" #: lib/explorer_web/templates/layout/_topnav.html.eex:31 #: lib/explorer_web/templates/pending_transaction/index.html.eex:21 #: lib/explorer_web/templates/transaction/index.html.eex:21 -#: lib/explorer_web/templates/transaction/overview.html.eex:65 -#: lib/explorer_web/templates/transaction/overview.html.eex:81 +#: lib/explorer_web/templates/transaction/overview.html.eex:83 +#: lib/explorer_web/templates/transaction/overview.html.eex:99 #: lib/explorer_web/views/transaction_view.ex:18 #: lib/explorer_web/views/transaction_view.ex:65 #: lib/explorer_web/views/transaction_view.ex:72 @@ -244,12 +247,12 @@ msgstr "" msgid "Pending" msgstr "" -#: lib/explorer_web/templates/transaction/overview.html.eex:101 +#: lib/explorer_web/templates/transaction/overview.html.eex:119 msgid "First Seen" msgstr "" #: lib/explorer_web/templates/pending_transaction/index.html.eex:36 -#: lib/explorer_web/templates/transaction/overview.html.eex:110 +#: lib/explorer_web/templates/transaction/overview.html.eex:128 msgid "Last Seen" msgstr "" @@ -326,11 +329,14 @@ msgstr "" msgid "Showing #%{number}" msgstr "" +#: lib/explorer_web/templates/address/overview.html.eex:24 #: lib/explorer_web/templates/address_internal_transaction/index.html.eex:84 #: lib/explorer_web/templates/address_transaction/index.html.eex:87 #: lib/explorer_web/templates/chain/_transactions.html.eex:10 #: lib/explorer_web/templates/pending_transaction/index.html.eex:39 #: lib/explorer_web/templates/transaction/index.html.eex:39 +#: lib/explorer_web/templates/transaction/overview.html.eex:57 +#: lib/explorer_web/templates/transaction/overview.html.eex:154 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:33 #: lib/explorer_web/views/wei_helpers.ex:71 msgid "Ether" @@ -424,11 +430,14 @@ msgstr "" msgid "Price" msgstr "" +#: lib/explorer_web/templates/address/overview.html.eex:32 +#: lib/explorer_web/templates/transaction/overview.html.eex:65 +#: lib/explorer_web/templates/transaction/overview.html.eex:162 #: lib/explorer_web/views/currency_helpers.ex:32 msgid "USD" msgstr "" -#: lib/explorer_web/templates/address/overview.html.eex:22 +#: lib/explorer_web/templates/address/overview.html.eex:40 msgid "Number of Transactions" msgstr "" @@ -477,7 +486,8 @@ msgstr "" msgid "View All" msgstr "" -#: lib/explorer_web/templates/transaction/overview.html.eex:136 +#: lib/explorer_web/templates/transaction/overview.html.eex:154 +#: lib/explorer_web/templates/transaction/overview.html.eex:162 msgid "TX Fee" msgstr "" diff --git a/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po index 7af6e5731f..91a76394ea 100644 --- a/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po @@ -17,7 +17,7 @@ msgstr "" #: lib/explorer_web/templates/chain/_blocks.html.eex:8 #: lib/explorer_web/templates/chain/_transactions.html.eex:11 #: lib/explorer_web/templates/transaction/index.html.eex:36 -#: lib/explorer_web/templates/transaction/overview.html.eex:38 +#: lib/explorer_web/templates/transaction/overview.html.eex:49 msgid "Age" msgstr "Age" @@ -41,7 +41,7 @@ msgstr "%{year} POA Network Ltd. All rights reserved" #: lib/explorer_web/templates/block/index.html.eex:20 #: lib/explorer_web/templates/block_transaction/index.html.eex:88 -#: lib/explorer_web/templates/transaction/overview.html.eex:145 +#: lib/explorer_web/templates/transaction/overview.html.eex:170 msgid "Gas Used" msgstr "Gas Used" @@ -79,7 +79,8 @@ msgstr "Transactions" #: lib/explorer_web/templates/chain/_transactions.html.eex:10 #: lib/explorer_web/templates/pending_transaction/index.html.eex:39 #: lib/explorer_web/templates/transaction/index.html.eex:39 -#: lib/explorer_web/templates/transaction/overview.html.eex:46 +#: lib/explorer_web/templates/transaction/overview.html.eex:57 +#: lib/explorer_web/templates/transaction/overview.html.eex:65 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:33 msgid "Value" msgstr "Value" @@ -94,7 +95,7 @@ msgstr "Difficulty" #: lib/explorer_web/templates/block/index.html.eex:21 #: lib/explorer_web/templates/block_transaction/index.html.eex:96 -#: lib/explorer_web/templates/transaction/overview.html.eex:119 +#: lib/explorer_web/templates/transaction/overview.html.eex:137 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:34 msgid "Gas Limit" msgstr "Gas Limit" @@ -104,7 +105,7 @@ msgid "Miner" msgstr "Validator" #: lib/explorer_web/templates/block_transaction/index.html.eex:104 -#: lib/explorer_web/templates/transaction/overview.html.eex:87 +#: lib/explorer_web/templates/transaction/overview.html.eex:105 msgid "Nonce" msgstr "Nonce" @@ -128,11 +129,11 @@ msgstr "Timestamp" msgid "Total Difficulty" msgstr "Total Difficulty" -#: lib/explorer_web/templates/transaction/overview.html.eex:22 +#: lib/explorer_web/templates/transaction/overview.html.eex:33 msgid "Block Number" msgstr "Block Height" -#: lib/explorer_web/templates/transaction/overview.html.eex:2 +#: lib/explorer_web/templates/transaction/overview.html.eex:11 msgid "Transaction Details" msgstr "Transaction Details" @@ -148,15 +149,15 @@ msgid "Gas" msgstr "Gas" #: lib/explorer_web/templates/block/index.html.eex:22 -#: lib/explorer_web/templates/transaction/overview.html.eex:127 +#: lib/explorer_web/templates/transaction/overview.html.eex:145 msgid "Gas Price" msgstr "Gas Price" -#: lib/explorer_web/templates/transaction/overview.html.eex:153 +#: lib/explorer_web/templates/transaction/overview.html.eex:178 msgid "Input" msgstr "Input" -#: lib/explorer_web/templates/transaction/overview.html.eex:33 +#: lib/explorer_web/templates/transaction/overview.html.eex:44 msgid "%{confirmations} block confirmations" msgstr "%{confirmations} block confirmations" @@ -164,6 +165,7 @@ msgstr "%{confirmations} block confirmations" msgid "%{count} transactions in this block" msgstr "%{count} transactions in this block" +#: lib/explorer_web/templates/address/overview.html.eex:11 #: lib/explorer_web/templates/transaction_log/index.html.eex:29 #: lib/explorer_web/views/address_view.ex:17 msgid "Address" @@ -177,7 +179,7 @@ msgstr "Address" #: lib/explorer_web/templates/chain/_transactions.html.eex:8 #: lib/explorer_web/templates/pending_transaction/index.html.eex:37 #: lib/explorer_web/templates/transaction/index.html.eex:37 -#: lib/explorer_web/templates/transaction/overview.html.eex:55 +#: lib/explorer_web/templates/transaction/overview.html.eex:73 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:31 #: lib/explorer_web/views/address_internal_transaction_view.ex:9 #: lib/explorer_web/views/address_transaction_view.ex:11 @@ -201,7 +203,7 @@ msgstr "Success" #: lib/explorer_web/templates/chain/_transactions.html.eex:9 #: lib/explorer_web/templates/pending_transaction/index.html.eex:38 #: lib/explorer_web/templates/transaction/index.html.eex:38 -#: lib/explorer_web/templates/transaction/overview.html.eex:71 +#: lib/explorer_web/templates/transaction/overview.html.eex:89 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:32 #: lib/explorer_web/views/address_internal_transaction_view.ex:8 #: lib/explorer_web/views/address_transaction_view.ex:10 @@ -213,11 +215,12 @@ msgstr "To" msgid "Transaction Hash" msgstr "Transaction Hash" -#: lib/explorer_web/templates/transaction/overview.html.eex:13 +#: lib/explorer_web/templates/transaction/overview.html.eex:24 msgid "Transaction Status" msgstr "Transaction Status" -#: lib/explorer_web/templates/address/overview.html.eex:13 +#: lib/explorer_web/templates/address/overview.html.eex:24 +#: lib/explorer_web/templates/address/overview.html.eex:32 msgid "Balance" msgstr "Balance" @@ -247,8 +250,8 @@ msgstr "Showing %{count} Transactions" #: lib/explorer_web/templates/layout/_topnav.html.eex:31 #: lib/explorer_web/templates/pending_transaction/index.html.eex:21 #: lib/explorer_web/templates/transaction/index.html.eex:21 -#: lib/explorer_web/templates/transaction/overview.html.eex:65 -#: lib/explorer_web/templates/transaction/overview.html.eex:81 +#: lib/explorer_web/templates/transaction/overview.html.eex:83 +#: lib/explorer_web/templates/transaction/overview.html.eex:99 #: lib/explorer_web/views/transaction_view.ex:18 #: lib/explorer_web/views/transaction_view.ex:65 #: lib/explorer_web/views/transaction_view.ex:72 @@ -256,12 +259,12 @@ msgstr "Showing %{count} Transactions" msgid "Pending" msgstr "Pending" -#: lib/explorer_web/templates/transaction/overview.html.eex:101 +#: lib/explorer_web/templates/transaction/overview.html.eex:119 msgid "First Seen" msgstr "" #: lib/explorer_web/templates/pending_transaction/index.html.eex:36 -#: lib/explorer_web/templates/transaction/overview.html.eex:110 +#: lib/explorer_web/templates/transaction/overview.html.eex:128 msgid "Last Seen" msgstr "" @@ -338,11 +341,14 @@ msgstr "" msgid "Showing #%{number}" msgstr "" +#: lib/explorer_web/templates/address/overview.html.eex:24 #: lib/explorer_web/templates/address_internal_transaction/index.html.eex:84 #: lib/explorer_web/templates/address_transaction/index.html.eex:87 #: lib/explorer_web/templates/chain/_transactions.html.eex:10 #: lib/explorer_web/templates/pending_transaction/index.html.eex:39 #: lib/explorer_web/templates/transaction/index.html.eex:39 +#: lib/explorer_web/templates/transaction/overview.html.eex:57 +#: lib/explorer_web/templates/transaction/overview.html.eex:154 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:33 #: lib/explorer_web/views/wei_helpers.ex:71 msgid "Ether" @@ -436,11 +442,14 @@ msgstr "" msgid "Price" msgstr "" +#: lib/explorer_web/templates/address/overview.html.eex:32 +#: lib/explorer_web/templates/transaction/overview.html.eex:65 +#: lib/explorer_web/templates/transaction/overview.html.eex:162 #: lib/explorer_web/views/currency_helpers.ex:32 msgid "USD" msgstr "" -#: lib/explorer_web/templates/address/overview.html.eex:22 +#: lib/explorer_web/templates/address/overview.html.eex:40 msgid "Number of Transactions" msgstr "" @@ -489,7 +498,8 @@ msgstr "" msgid "View All" msgstr "" -#: lib/explorer_web/templates/transaction/overview.html.eex:136 +#: lib/explorer_web/templates/transaction/overview.html.eex:154 +#: lib/explorer_web/templates/transaction/overview.html.eex:162 msgid "TX Fee" msgstr "" From 882f09abcd28e573b27efa156562f7628e8ced14 Mon Sep 17 00:00:00 2001 From: Tim Mecklem Date: Fri, 1 Jun 2018 14:27:35 -0400 Subject: [PATCH 15/16] Inline QR Codes Co-authored-by: Stamates --- .../controllers/address_qr_code_controller.ex | 15 --------------- .../transaction_qr_code_controller.ex | 15 --------------- apps/explorer_web/lib/explorer_web/router.ex | 3 --- .../templates/address/overview.html.eex | 2 +- .../templates/transaction/overview.html.eex | 2 +- .../lib/explorer_web/views/address_view.ex | 7 +++++++ .../explorer_web/views/transaction_view.ex | 7 +++++++ .../address_qr_code_controller_test.exs | 19 ------------------- .../transaction_qr_code_controller_test.exs | 19 ------------------- .../explorer_web/views/address_view_test.exs | 7 +++++++ .../views/transaction_view_test.exs | 7 +++++++ 11 files changed, 30 insertions(+), 73 deletions(-) delete mode 100644 apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex delete mode 100644 apps/explorer_web/lib/explorer_web/controllers/transaction_qr_code_controller.ex delete mode 100644 apps/explorer_web/test/explorer_web/controllers/address_qr_code_controller_test.exs delete mode 100644 apps/explorer_web/test/explorer_web/controllers/transaction_qr_code_controller_test.exs diff --git a/apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex deleted file mode 100644 index 5366f39c5c..0000000000 --- a/apps/explorer_web/lib/explorer_web/controllers/address_qr_code_controller.ex +++ /dev/null @@ -1,15 +0,0 @@ -defmodule ExplorerWeb.AddressQRCodeController do - use ExplorerWeb, :controller - - alias Explorer.Chain.Hash.Truncated - - def index(conn, %{"address_id" => id}) do - case Truncated.cast(id) do - {:ok, _} -> - send_download(conn, {:binary, QRCode.to_png(id)}, "content-type": "image/png", filename: "#{id}.png") - - _ -> - send_resp(conn, :not_found, "") - end - end -end diff --git a/apps/explorer_web/lib/explorer_web/controllers/transaction_qr_code_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/transaction_qr_code_controller.ex deleted file mode 100644 index 0e2cb4255f..0000000000 --- a/apps/explorer_web/lib/explorer_web/controllers/transaction_qr_code_controller.ex +++ /dev/null @@ -1,15 +0,0 @@ -defmodule ExplorerWeb.TransactionQRCodeController do - use ExplorerWeb, :controller - - alias Explorer.Chain.Hash.Full - - def index(conn, %{"transaction_id" => id}) do - case Full.cast(id) do - {:ok, _} -> - send_download(conn, {:binary, QRCode.to_png(id)}, "content-type": "image/png", filename: "#{id}.png") - - _ -> - send_resp(conn, :not_found, "") - end - end -end diff --git a/apps/explorer_web/lib/explorer_web/router.ex b/apps/explorer_web/lib/explorer_web/router.ex index e187b7a0e2..a5e137d319 100644 --- a/apps/explorer_web/lib/explorer_web/router.ex +++ b/apps/explorer_web/lib/explorer_web/router.ex @@ -62,7 +62,6 @@ defmodule ExplorerWeb.Router do ) resources("/logs", TransactionLogController, only: [:index], as: :log) - resources("/qrcode.png", TransactionQRCodeController, only: [:index], as: :qr_code) end resources "/addresses", AddressController, only: [:show] do @@ -81,8 +80,6 @@ defmodule ExplorerWeb.Router do only: [:index], as: :contract ) - - resources("/qrcode.png", AddressQRCodeController, only: [:index], as: :qr_code) end get("/search", ChainController, :search) diff --git a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex index 855bd93194..5e2923ec22 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex @@ -3,7 +3,7 @@
- <%= img_tag(address_qr_code_path(@conn, :index, @conn.assigns.locale, @address), alt: "qr_code", class: "qr-code") %> + qr_code
diff --git a/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex index 5ce3f3a3e2..9cbf7b761c 100644 --- a/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex @@ -3,7 +3,7 @@
- <%= img_tag(transaction_qr_code_path(@conn, :index, @conn.assigns.locale, @transaction), alt: "qr_code", class: "qr-code") %> + qr_code
diff --git a/apps/explorer_web/lib/explorer_web/views/address_view.ex b/apps/explorer_web/lib/explorer_web/views/address_view.ex index 6081feadb9..fe130f9c29 100644 --- a/apps/explorer_web/lib/explorer_web/views/address_view.ex +++ b/apps/explorer_web/lib/explorer_web/views/address_view.ex @@ -44,4 +44,11 @@ defmodule ExplorerWeb.AddressView do def hash(%Address{hash: hash}) do to_string(hash) end + + def qr_code(%Address{hash: hash}) do + hash + |> to_string() + |> QRCode.to_png() + |> Base.encode64() + end end diff --git a/apps/explorer_web/lib/explorer_web/views/transaction_view.ex b/apps/explorer_web/lib/explorer_web/views/transaction_view.ex index c3b79874f2..6cbb68da70 100644 --- a/apps/explorer_web/lib/explorer_web/views/transaction_view.ex +++ b/apps/explorer_web/lib/explorer_web/views/transaction_view.ex @@ -32,6 +32,13 @@ defmodule ExplorerWeb.TransactionView do end end + def qr_code(%Transaction{hash: hash}) do + hash + |> to_string() + |> QRCode.to_png() + |> Base.encode64() + end + defp fee_to_currency({fee_type, fee}, denomination: denomination) do {fee_type, format_wei_value(Wei.from(fee, :wei), denomination)} end diff --git a/apps/explorer_web/test/explorer_web/controllers/address_qr_code_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/address_qr_code_controller_test.exs deleted file mode 100644 index e57a393e84..0000000000 --- a/apps/explorer_web/test/explorer_web/controllers/address_qr_code_controller_test.exs +++ /dev/null @@ -1,19 +0,0 @@ -defmodule ExplorerWeb.AddressQRCodeControllerTest do - use ExplorerWeb.ConnCase - - import ExplorerWeb.Router.Helpers, only: [address_qr_code_path: 4] - - describe "GET index/3" do - test "with valid address hash returns a QR code", %{conn: conn} do - conn = get(conn, address_qr_code_path(conn, :index, :en, address_hash())) - - assert response(conn, 200) - end - - test "with invalid address hash returns 404", %{conn: conn} do - conn = get(conn, address_qr_code_path(conn, :index, :en, "0xhaha")) - - assert response(conn, 404) - end - end -end diff --git a/apps/explorer_web/test/explorer_web/controllers/transaction_qr_code_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/transaction_qr_code_controller_test.exs deleted file mode 100644 index 1984846234..0000000000 --- a/apps/explorer_web/test/explorer_web/controllers/transaction_qr_code_controller_test.exs +++ /dev/null @@ -1,19 +0,0 @@ -defmodule ExplorerWeb.TransactionQRCodeControllerTest do - use ExplorerWeb.ConnCase - - import ExplorerWeb.Router.Helpers, only: [transaction_qr_code_path: 4] - - describe "GET index/3" do - test "with valid `Hash.Full` returns a QR code", %{conn: conn} do - conn = get(conn, transaction_qr_code_path(conn, :index, :en, transaction_hash())) - - assert response(conn, 200) - end - - test "with invalid address hash returns 404", %{conn: conn} do - conn = get(conn, transaction_qr_code_path(conn, :index, :en, "0xhaha")) - - assert response(conn, 404) - end - end -end diff --git a/apps/explorer_web/test/explorer_web/views/address_view_test.exs b/apps/explorer_web/test/explorer_web/views/address_view_test.exs index e3c15f3f0d..2372f56eb5 100644 --- a/apps/explorer_web/test/explorer_web/views/address_view_test.exs +++ b/apps/explorer_web/test/explorer_web/views/address_view_test.exs @@ -23,4 +23,11 @@ defmodule ExplorerWeb.AddressViewTest do assert "$0.000005 USD" == AddressView.formatted_usd(address, token) end end + + describe "qr_code/1" do + test "it returns an encoded value" do + address = build(:address) + assert {:ok, _} = Base.decode64(AddressView.qr_code(address)) + end + end end diff --git a/apps/explorer_web/test/explorer_web/views/transaction_view_test.exs b/apps/explorer_web/test/explorer_web/views/transaction_view_test.exs index bfdf9d6a93..996c3cb071 100644 --- a/apps/explorer_web/test/explorer_web/views/transaction_view_test.exs +++ b/apps/explorer_web/test/explorer_web/views/transaction_view_test.exs @@ -83,4 +83,11 @@ defmodule ExplorerWeb.TransactionViewTest do assert TransactionView.formatted_status(transaction) == "Success" end end + + describe "qr_code/1" do + test "it returns an encoded value" do + transaction = build(:transaction) + assert {:ok, _} = Base.decode64(TransactionView.qr_code(transaction)) + end + end end From 6c7ae27fda741f77198963f3877f33836536d61b Mon Sep 17 00:00:00 2001 From: Tim Mecklem Date: Fri, 1 Jun 2018 14:29:10 -0400 Subject: [PATCH 16/16] Update gettext --- apps/explorer_web/priv/gettext/default.pot | 10 +++++----- .../priv/gettext/en/LC_MESSAGES/default.po | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/explorer_web/priv/gettext/default.pot b/apps/explorer_web/priv/gettext/default.pot index d02a3249e7..f8e7d4235b 100644 --- a/apps/explorer_web/priv/gettext/default.pot +++ b/apps/explorer_web/priv/gettext/default.pot @@ -179,7 +179,7 @@ msgstr "" msgid "Overview" msgstr "" -#: lib/explorer_web/views/transaction_view.ex:109 +#: lib/explorer_web/views/transaction_view.ex:116 msgid "Success" msgstr "" @@ -241,9 +241,9 @@ msgstr "" #: lib/explorer_web/templates/transaction/overview.html.eex:83 #: lib/explorer_web/templates/transaction/overview.html.eex:99 #: lib/explorer_web/views/transaction_view.ex:18 -#: lib/explorer_web/views/transaction_view.ex:65 #: lib/explorer_web/views/transaction_view.ex:72 -#: lib/explorer_web/views/transaction_view.ex:108 +#: lib/explorer_web/views/transaction_view.ex:79 +#: lib/explorer_web/views/transaction_view.ex:115 msgid "Pending" msgstr "" @@ -306,11 +306,11 @@ msgstr "" msgid "Next Page" msgstr "" -#: lib/explorer_web/views/transaction_view.ex:106 +#: lib/explorer_web/views/transaction_view.ex:113 msgid "Failed" msgstr "" -#: lib/explorer_web/views/transaction_view.ex:107 +#: lib/explorer_web/views/transaction_view.ex:114 msgid "Out of Gas" msgstr "" diff --git a/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po index 91a76394ea..96584fbac1 100644 --- a/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po @@ -191,7 +191,7 @@ msgstr "From" msgid "Overview" msgstr "Overview" -#: lib/explorer_web/views/transaction_view.ex:109 +#: lib/explorer_web/views/transaction_view.ex:116 msgid "Success" msgstr "Success" @@ -253,9 +253,9 @@ msgstr "Showing %{count} Transactions" #: lib/explorer_web/templates/transaction/overview.html.eex:83 #: lib/explorer_web/templates/transaction/overview.html.eex:99 #: lib/explorer_web/views/transaction_view.ex:18 -#: lib/explorer_web/views/transaction_view.ex:65 #: lib/explorer_web/views/transaction_view.ex:72 -#: lib/explorer_web/views/transaction_view.ex:108 +#: lib/explorer_web/views/transaction_view.ex:79 +#: lib/explorer_web/views/transaction_view.ex:115 msgid "Pending" msgstr "Pending" @@ -318,11 +318,11 @@ msgstr "" msgid "Next Page" msgstr "" -#: lib/explorer_web/views/transaction_view.ex:106 +#: lib/explorer_web/views/transaction_view.ex:113 msgid "Failed" msgstr "" -#: lib/explorer_web/views/transaction_view.ex:107 +#: lib/explorer_web/views/transaction_view.ex:114 msgid "Out of Gas" msgstr ""
- <%= gettext "Overview" %> - - - - - -
<%= gettext "POA Balance" %> @@ -50,30 +50,3 @@ - - - From 171903a4d3637bf231fbe818422458211dae1cd6 Mon Sep 17 00:00:00 2001 From: Ryan Arthur Date: Thu, 31 May 2018 15:25:00 -0400 Subject: [PATCH 12/16] Add a QR code to the transaction detail page --- .../templates/transaction/overview.html.eex | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex index 1e20a289d0..5fb6c1b6ec 100644 --- a/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex @@ -1,6 +1,17 @@
-

<%= gettext "Transaction Details" %>

-

<%= @transaction %>

+
+
+
+
+ <%= img_tag(transaction_qr_code_path(@conn, :index, @conn.assigns.locale, @transaction), alt: "qr_code", class: "qr-code") %> +
+
+
+
+

<%= gettext "Transaction Details" %>

+

<%= @transaction %>

+
+
From a1d391c988b39c856971574a11171ba29f7caee3 Mon Sep 17 00:00:00 2001 From: Tim Mecklem Date: Fri, 1 Jun 2018 13:47:40 -0400 Subject: [PATCH 13/16] Move USD values to separate row with label --- .../templates/address/overview.html.eex | 4 ++-- .../templates/transaction/overview.html.eex | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex index bd49f9e403..855bd93194 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex @@ -21,7 +21,7 @@
- <%= gettext "POA Balance" %> + <%= gettext "Ether" %> <%= gettext "Balance" %> <%= balance(@address) %> @@ -29,7 +29,7 @@
- <%= gettext "USD Balance" %> + <%= gettext "USD" %> <%= gettext "Balance" %> <%= formatted_usd(@address, @exchange_rate) %> diff --git a/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex index 5fb6c1b6ec..5ce3f3a3e2 100644 --- a/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/transaction/overview.html.eex @@ -54,10 +54,17 @@
- <%= gettext "Value" %> + <%= gettext "Ether" %> <%= gettext "Value" %>
<%= value(@transaction) %>
+
+ <%= gettext "USD" %> <%= gettext "Value" %> +
<%= formatted_usd_value(@transaction, @exchange_rate) %>
- <%= gettext "TX Fee" %> + <%= gettext "Ether" %> <%= gettext "TX Fee" %>
<%= formatted_fee(@transaction, denomination: :ether) %>
+
+ <%= gettext "USD" %> <%= gettext "TX Fee" %> +
<%= formatted_fee(@transaction, exchange_rate: @exchange_rate) %>