improve display of accounts
This commit is contained in:
parent
b2d7640240
commit
6bd333a41c
@ -363,7 +363,7 @@ export function numberWithCommas(x) {
|
|||||||
return parts.join('.')
|
return parts.join('.')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatTokenAmount(tokenAmount, fraction = 2, tokenDenom = 'uatom') {
|
export function formatTokenAmount(tokenAmount, fraction = 2, tokenDenom = 'uatom', format = true) {
|
||||||
const denom = tokenDenom.denom_trace ? tokenDenom.denom_trace.base_denom : tokenDenom
|
const denom = tokenDenom.denom_trace ? tokenDenom.denom_trace.base_denom : tokenDenom
|
||||||
let amount = 0
|
let amount = 0
|
||||||
|
|
||||||
@ -378,7 +378,8 @@ export function formatTokenAmount(tokenAmount, fraction = 2, tokenDenom = 'uatom
|
|||||||
})
|
})
|
||||||
amount = Number(Number(tokenAmount)) / (10 ** exp)
|
amount = Number(Number(tokenAmount)) / (10 ** exp)
|
||||||
if (amount > 10) {
|
if (amount > 10) {
|
||||||
return numberWithCommas(parseFloat(amount.toFixed(fraction)))
|
if (format) { return numberWithCommas(parseFloat(amount.toFixed(fraction))) }
|
||||||
|
return parseFloat(amount.toFixed(fraction))
|
||||||
}
|
}
|
||||||
return parseFloat(amount.toFixed(fraction))
|
return parseFloat(amount.toFixed(fraction))
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<b-card
|
<b-card
|
||||||
v-if="calculateTotal > 0"
|
|
||||||
border-variant="primary"
|
border-variant="primary"
|
||||||
>
|
>
|
||||||
<b-row class="mx-0 d-flex align-items-center">
|
<b-row class="mx-0 d-flex align-items-center">
|
||||||
@ -31,14 +30,14 @@
|
|||||||
HKD (港幣)
|
HKD (港幣)
|
||||||
</b-dropdown-item>
|
</b-dropdown-item>
|
||||||
<b-dropdown-item @click="setCurrency('sgd')">
|
<b-dropdown-item @click="setCurrency('sgd')">
|
||||||
SGD
|
SGD (新加坡元)
|
||||||
</b-dropdown-item>
|
</b-dropdown-item>
|
||||||
<b-dropdown-item @click="setCurrency('krw')">
|
<b-dropdown-item @click="setCurrency('krw')">
|
||||||
KRW (대한민국원)
|
KRW (대한민국원)
|
||||||
</b-dropdown-item>
|
</b-dropdown-item>
|
||||||
</b-dropdown>
|
</b-dropdown>
|
||||||
<h2 class="mt-1 mb-0">
|
<h2 class="mt-1 mb-0">
|
||||||
{{ currency }}{{ calculateTotal }}
|
{{ currency }}{{ (calculateTotal) }}
|
||||||
</h2>
|
</h2>
|
||||||
<small
|
<small
|
||||||
v-if="calculateTotalChange > 0"
|
v-if="calculateTotalChange > 0"
|
||||||
@ -278,7 +277,7 @@ import FeatherIcon from '@/@core/components/feather-icon/FeatherIcon.vue'
|
|||||||
import {
|
import {
|
||||||
chartColors,
|
chartColors,
|
||||||
formatNumber,
|
formatNumber,
|
||||||
formatTokenAmount, formatTokenDenom, getLocalAccounts, getLocalChains, getUserCurrency, getUserCurrencySign, setUserCurrency,
|
formatTokenAmount, formatTokenDenom, getLocalAccounts, getLocalChains, getUserCurrency, getUserCurrencySign, numberWithCommas, setUserCurrency,
|
||||||
} from '@/libs/utils'
|
} from '@/libs/utils'
|
||||||
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
|
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
|
||||||
import AppCollapse from '@core/components/app-collapse/AppCollapse.vue'
|
import AppCollapse from '@core/components/app-collapse/AppCollapse.vue'
|
||||||
@ -405,7 +404,7 @@ export default {
|
|||||||
total += subtotal
|
total += subtotal
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return parseFloat(total.toFixed(2))
|
return numberWithCommas(parseFloat(total.toFixed(2)))
|
||||||
},
|
},
|
||||||
calculateTotalChange() {
|
calculateTotalChange() {
|
||||||
const v = Object.values(this.balances)
|
const v = Object.values(this.balances)
|
||||||
@ -423,7 +422,7 @@ export default {
|
|||||||
total += subtotal
|
total += subtotal
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return parseFloat(total.toFixed(2))
|
return numberWithCommas(parseFloat(total.toFixed(2)))
|
||||||
},
|
},
|
||||||
calculateByDenom() {
|
calculateByDenom() {
|
||||||
const v = Object.values(this.balances)
|
const v = Object.values(this.balances)
|
||||||
@ -566,16 +565,16 @@ export default {
|
|||||||
const denom = (v.startsWith('ibc') ? this.ibcDenom[v] : v)
|
const denom = (v.startsWith('ibc') ? this.ibcDenom[v] : v)
|
||||||
return formatTokenDenom(denom)
|
return formatTokenDenom(denom)
|
||||||
},
|
},
|
||||||
formatAmount(v, denom = 'uatom') {
|
formatAmount(v, denom = 'uatom', format = true) {
|
||||||
if (!v) return ''
|
if (!v) return ''
|
||||||
const denom2 = (denom.startsWith('ibc') ? this.ibcDenom[denom] : denom)
|
const denom2 = (denom.startsWith('ibc') ? this.ibcDenom[denom] : denom)
|
||||||
return formatTokenAmount(v, 2, denom2)
|
return formatTokenAmount(v, 2, denom2, format)
|
||||||
},
|
},
|
||||||
formatAddr(v) {
|
formatAddr(v) {
|
||||||
return v.substring(0, 10).concat('...', v.substring(v.length - 10))
|
return v.substring(0, 10).concat('...', v.substring(v.length - 10))
|
||||||
},
|
},
|
||||||
formatCurrency(amount, denom) {
|
formatCurrency(amount, denom) {
|
||||||
const qty = this.formatAmount(amount, denom)
|
const qty = this.formatAmount(amount, denom, false)
|
||||||
const d2 = this.formatDenom(denom)
|
const d2 = this.formatDenom(denom)
|
||||||
const quote = this.$store.state.chains.quotes[d2]
|
const quote = this.$store.state.chains.quotes[d2]
|
||||||
if (quote) {
|
if (quote) {
|
||||||
@ -627,7 +626,7 @@ export default {
|
|||||||
const ret = delegations.map(x => this.formatCurrency(x.amount, x.denom)).reduce((t, c) => t + c, 0)
|
const ret = delegations.map(x => this.formatCurrency(x.amount, x.denom)).reduce((t, c) => t + c, 0)
|
||||||
total += ret
|
total += ret
|
||||||
}
|
}
|
||||||
return parseFloat(total.toFixed(2))
|
return numberWithCommas(parseFloat(total.toFixed(2)))
|
||||||
},
|
},
|
||||||
formatBalanceChanges(v) {
|
formatBalanceChanges(v) {
|
||||||
let total = 0
|
let total = 0
|
||||||
|
@ -25,20 +25,20 @@
|
|||||||
value="pingKMS"
|
value="pingKMS"
|
||||||
class="d-none d-md-block"
|
class="d-none d-md-block"
|
||||||
>
|
>
|
||||||
Ping KMS
|
Ping Signer
|
||||||
</b-form-radio>
|
</b-form-radio>
|
||||||
<b-form-radio
|
<b-form-radio
|
||||||
name="wallet"
|
name="wallet"
|
||||||
value="ledgerUSB"
|
value="ledgerUSB"
|
||||||
>
|
>
|
||||||
<small>Ledger(USB)</small>
|
Ledger (USB)
|
||||||
</b-form-radio>
|
</b-form-radio>
|
||||||
<b-form-radio
|
<b-form-radio
|
||||||
name="wallet"
|
name="wallet"
|
||||||
value="ledgerBle"
|
value="ledgerBle"
|
||||||
class="mr-0"
|
class="mr-0"
|
||||||
>
|
>
|
||||||
<small>Ledger(Bluetooth)</small>
|
Ledger (Bluetooth)
|
||||||
</b-form-radio>
|
</b-form-radio>
|
||||||
</b-form-radio-group>
|
</b-form-radio-group>
|
||||||
<small class="text-danger">{{ errors[0] }}</small>
|
<small class="text-danger">{{ errors[0] }}</small>
|
||||||
|
Loading…
Reference in New Issue
Block a user