From f4c18541e2b41543cf0a835db6d7fcaaa632b677 Mon Sep 17 00:00:00 2001 From: nikitosing Date: Thu, 8 Jul 2021 14:51:09 +0700 Subject: [PATCH 1/2] Add live reload on the token holders page --- CHANGELOG.md | 1 + .../assets/js/lib/async_listing_load.js | 2 +- .../assets/js/pages/token_counters.js | 31 +++++++++++++++++-- .../templates/tokens/holder/index.html.eex | 7 ++++- apps/block_scout_web/priv/gettext/default.pot | 29 ++++++++--------- .../priv/gettext/en/LC_MESSAGES/default.po | 29 ++++++++--------- 6 files changed, 66 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a5066706..1296ce8a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#4353](https://github.com/blockscout/blockscout/pull/4353) - Added live-reload on the token holders page ### Fixes diff --git a/apps/block_scout_web/assets/js/lib/async_listing_load.js b/apps/block_scout_web/assets/js/lib/async_listing_load.js index de8a6d324b..1789c08e3f 100644 --- a/apps/block_scout_web/assets/js/lib/async_listing_load.js +++ b/apps/block_scout_web/assets/js/lib/async_listing_load.js @@ -307,7 +307,7 @@ export function refreshPage (store) { loadPage(store, store.getState().currentPagePath) } -function loadPage (store, path) { +export function loadPage (store, path) { store.dispatch({ type: 'START_REQUEST', path }) $.getJSON(path, merge({ type: 'JSON' }, store.getState().additionalParams)) .done(response => store.dispatch(Object.assign({ type: 'ITEMS_FETCHED' }, humps.camelizeKeys(response)))) diff --git a/apps/block_scout_web/assets/js/pages/token_counters.js b/apps/block_scout_web/assets/js/pages/token_counters.js index 8bfc337a39..e60e04418e 100644 --- a/apps/block_scout_web/assets/js/pages/token_counters.js +++ b/apps/block_scout_web/assets/js/pages/token_counters.js @@ -1,8 +1,9 @@ import $ from 'jquery' import omit from 'lodash/omit' import humps from 'humps' +import { subscribeChannel } from '../socket' import { createStore, connectElements } from '../lib/redux_helpers.js' -import '../lib/async_listing_load' +import { createAsyncLoadStore, loadPage } from '../lib/async_listing_load' import '../app' import { openQrModal @@ -21,8 +22,6 @@ export function reducer (state = initialState, action) { return Object.assign({}, state, omit(action, 'type')) } case 'CHANNEL_DISCONNECTED': { - if (state.beyondPageOne) return state - return Object.assign({}, state, { channelDisconnected: true }) @@ -86,11 +85,37 @@ function loadCounters (store) { const $tokenPage = $('[token-page]') if ($tokenPage.length) { + updateCounters() +} + +function updateCounters () { const store = createStore(reducer) connectElements({ store, elements }) loadCounters(store) } +if ($('[data-page="token-holders-list"]').length) { + const asyncElements = { + '[data-selector="channel-disconnected-message"]': { + render ($el, state) { + if (state.channelDisconnected) $el.show() + } + } + } + + const store = createAsyncLoadStore(reducer, initialState, null) + connectElements({ store, asyncElements }) + + const addressHash = $('[data-page="token-details"]')[0].dataset.pageAddressHash + const tokensChannel = subscribeChannel(`tokens:${addressHash}`) + tokensChannel.onError(() => store.dispatch({ type: 'CHANNEL_DISCONNECTED' })) + tokensChannel.on('token_transfer', (_msg) => { + const uri = new URL(window.location) + loadPage(store, uri.pathname + uri.search) + updateCounters() + }) +} + $('.btn-qr-icon').click(_event => { openQrModal() }) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex index fcd080e6e7..caec14a4f4 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex @@ -7,11 +7,16 @@ conn: @conn ) %> -
+
<%= render OverviewView, "_tabs.html", assigns %>
+

<%= gettext "Token Holders" %>

diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 84c3d2530a..40c20f5f71 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -116,6 +116,17 @@ msgstr "" msgid "- We're indexing this chain right now. Some of the counts may be inaccurate." msgstr "" +#, elixir-format +#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 +msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\r\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\r\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\r\n" +msgstr "" + +#, elixir-format +#: +#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 +msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\r\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

" +msgstr "" + #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:73 msgid "A string with the name of the action to be invoked." @@ -542,6 +553,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:4 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:13 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:4 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:17 msgid "Connection Lost" msgstr "" @@ -1808,7 +1820,7 @@ msgstr "" #: lib/block_scout_web/templates/chain/show.html.eex:182 #: lib/block_scout_web/templates/pending_transaction/index.html.eex:21 #: lib/block_scout_web/templates/stakes/_table.html.eex:49 -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:22 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:23 #: lib/block_scout_web/templates/tokens/inventory/index.html.eex:22 #: lib/block_scout_web/templates/tokens/transfer/index.html.eex:21 @@ -2025,7 +2037,7 @@ msgid "There are no blocks." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:32 msgid "There are no holders for this Token." msgstr "" @@ -2209,7 +2221,7 @@ msgid "Token Details" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:15 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:20 #: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:9 #: lib/block_scout_web/views/tokens/overview_view.ex:42 msgid "Token Holders" @@ -2794,14 +2806,3 @@ msgstr "" #: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:18 msgid "validator" msgstr "" - -#, elixir-format -#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 -msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\n" -msgstr "" - -#, elixir-format -#: -#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 -msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

" -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 84c3d2530a..40c20f5f71 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 @@ -116,6 +116,17 @@ msgstr "" msgid "- We're indexing this chain right now. Some of the counts may be inaccurate." msgstr "" +#, elixir-format +#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 +msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\r\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\r\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\r\n" +msgstr "" + +#, elixir-format +#: +#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 +msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\r\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

" +msgstr "" + #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:73 msgid "A string with the name of the action to be invoked." @@ -542,6 +553,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:4 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:13 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:4 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:17 msgid "Connection Lost" msgstr "" @@ -1808,7 +1820,7 @@ msgstr "" #: lib/block_scout_web/templates/chain/show.html.eex:182 #: lib/block_scout_web/templates/pending_transaction/index.html.eex:21 #: lib/block_scout_web/templates/stakes/_table.html.eex:49 -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:22 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:23 #: lib/block_scout_web/templates/tokens/inventory/index.html.eex:22 #: lib/block_scout_web/templates/tokens/transfer/index.html.eex:21 @@ -2025,7 +2037,7 @@ msgid "There are no blocks." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:32 msgid "There are no holders for this Token." msgstr "" @@ -2209,7 +2221,7 @@ msgid "Token Details" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:15 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:20 #: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:9 #: lib/block_scout_web/views/tokens/overview_view.ex:42 msgid "Token Holders" @@ -2794,14 +2806,3 @@ msgstr "" #: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:18 msgid "validator" msgstr "" - -#, elixir-format -#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 -msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\n" -msgstr "" - -#, elixir-format -#: -#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 -msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

" -msgstr "" From 0ccdd14928677617962df223e32862e4cbf9eb63 Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Mon, 19 Jul 2021 09:54:35 +0300 Subject: [PATCH 2/2] Fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 22 +++++++++---------- .../priv/gettext/en/LC_MESSAGES/default.po | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 40c20f5f71..fa50ed8fed 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -116,17 +116,6 @@ msgstr "" msgid "- We're indexing this chain right now. Some of the counts may be inaccurate." msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 -msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\r\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\r\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\r\n" -msgstr "" - -#, elixir-format -#: -#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 -msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\r\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

" -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:73 msgid "A string with the name of the action to be invoked." @@ -2806,3 +2795,14 @@ msgstr "" #: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:18 msgid "validator" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 +msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\n" +msgstr "" + +#, elixir-format +#: +#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 +msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

" +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 40c20f5f71..e0e9d7581d 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 @@ -116,17 +116,6 @@ msgstr "" msgid "- We're indexing this chain right now. Some of the counts may be inaccurate." msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 -msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\r\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\r\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\r\n" -msgstr "" - -#, elixir-format -#: -#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 -msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\r\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

" -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:73 msgid "A string with the name of the action to be invoked." @@ -2806,3 +2795,14 @@ msgstr "" #: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:18 msgid "validator" msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 +msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\n" +msgstr "" + +#, elixir-format, fuzzy +#: +#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 +msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

" +msgstr ""