From dcd26824f92a7089a6d621849840f0bcc536d33a Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sun, 5 Dec 2021 12:20:29 +0800 Subject: [PATCH] improve UX --- src/views/StakingRewardComponent.vue | 13 ++++++- src/views/Uptime.vue | 7 ++-- src/views/UptimeMyChainBlocks.vue | 4 +++ src/views/WalletAccountDetail.vue | 4 +-- src/views/WalletAccounts.vue | 51 +++++++++++++++++++--------- 5 files changed, 56 insertions(+), 23 deletions(-) diff --git a/src/views/StakingRewardComponent.vue b/src/views/StakingRewardComponent.vue index ad085254..fcdc08fd 100644 --- a/src/views/StakingRewardComponent.vue +++ b/src/views/StakingRewardComponent.vue @@ -75,6 +75,16 @@ + + + Withdraw Commission + + import { - BCard, BCardHeader, BCardTitle, BCardBody, BMediaBody, BMedia, BMediaAside, BAvatar, + BCard, BCardHeader, BCardTitle, BCardBody, BMediaBody, BMedia, BMediaAside, BAvatar, BButton, } from 'bootstrap-vue' import OperationWithdrawCommissionComponent from './OperationWithdrawCommissionComponent.vue' export default { components: { + BButton, BCard, BCardHeader, BCardTitle, diff --git a/src/views/Uptime.vue b/src/views/Uptime.vue index 9f91bfed..e3c11b6f 100644 --- a/src/views/Uptime.vue +++ b/src/views/Uptime.vue @@ -111,11 +111,10 @@ export default { if (cached) { this.validators = cached - } else { - this.$http.getValidatorList().then(res => { - this.validators = res - }) } + this.$http.getValidatorList().then(res => { + this.validators = res + }) this.initBlocks() }, beforeDestroy() { diff --git a/src/views/UptimeMyChainBlocks.vue b/src/views/UptimeMyChainBlocks.vue index 148bcd15..2c64fe5f 100644 --- a/src/views/UptimeMyChainBlocks.vue +++ b/src/views/UptimeMyChainBlocks.vue @@ -13,6 +13,10 @@ + Your node is out of active validator set Delegate @@ -141,7 +141,7 @@ size="sm" > Withdraw Rewards diff --git a/src/views/WalletAccounts.vue b/src/views/WalletAccounts.vue index f2bd373c..537d973f 100644 --- a/src/views/WalletAccounts.vue +++ b/src/views/WalletAccounts.vue @@ -191,22 +191,22 @@
- {{ formatDenom(b.denom) }} + {{ formatAmount(b.amount, b.denom) }} {{ formatDenom(b.denom) }} + {{ currency }}{{ formatCurrency(b.amount, b.denom) }} +
+
+ {{ currency }}{{ formatPrice(b.denom) }} {{ formatChanges(b.denom) }}
-
- {{ formatAmount(b.amount, b.denom) }} - {{ currency }}{{ formatCurrency(b.amount, b.denom) }} -
- {{ formatDenom(b.denom) }} + {{ formatAmount(b.amount, b.denom) }} {{ formatDenom(b.denom) }} + {{ currency }}{{ formatCurrency(b.amount, b.denom) }} +
+
+ {{ currency }}{{ formatPrice(b.denom) }} {{ formatChanges(b.denom) }}
-
- {{ formatAmount(b.amount, b.denom) }} - {{ currency }}{{ formatCurrency(b.amount, b.denom) }} -
@@ -515,8 +515,16 @@ export default { }) this.$http.getStakingDelegations(add.addr, chains[add.chain]).then(res => { if (res.delegation_responses) { - const delegation = res.delegation_responses.map(x => x.balance) - this.$set(this.delegations, add.addr, delegation) + const delegation = res.delegation_responses.map(x => x.balance).reduce((t, c) => { + const t1 = t + if (t1[c.denom]) { + t1[c.denom] += Number(c.amount) + } else { + t1[c.denom] = Number(c.amount) + } + return t1 + }, {}) + this.$set(this.delegations, add.addr, Object.keys(delegation).map(x => ({ amount: String(delegation[x]), denom: x }))) } }).catch(() => {}) }) @@ -536,10 +544,12 @@ export default { this.$bvModal.hide('add-account') }, formatDenom(v) { + if (!v) return '' const denom = (v.startsWith('ibc') ? this.ibcDenom[v] : v) return formatTokenDenom(denom) }, formatAmount(v, denom = 'uatom') { + if (!v) return '' return formatTokenAmount(v, 2, denom) }, formatAddr(v) { @@ -577,6 +587,15 @@ export default { const price = this.getChanges(denom) return price === 0 ? '' : `${parseFloat(price.toFixed(2))}%` }, + formatPrice(denom) { + const d2 = this.formatDenom(denom) + const quote = this.$store.state.chains.quotes[d2] + if (quote) { + const price = quote[this.currency2] + return price + } + return 0 + }, formatBalance(v) { let total = 0 const balance = this.balances[v]