diff --git a/lnbits/core/templates/core/wallet.html b/lnbits/core/templates/core/wallet.html index b1c7d43e0..8d1653a27 100644 --- a/lnbits/core/templates/core/wallet.html +++ b/lnbits/core/templates/core/wallet.html @@ -55,6 +55,13 @@ +
+ +
@@ -214,13 +221,13 @@ {{ props.row.fsat }}
- {{ props.row.extra.wallet_fiat_currency }} {{ - props.row.extra.wallet_fiat_amount }} + {{ formatFiat(props.row.extra.wallet_fiat_currency, + props.row.extra.wallet_fiat_amount) }}
- {{ props.row.extra.fiat_currency }} {{ - props.row.extra.fiat_amount }} + {{ formatFiat(props.row.extra.fiat_currency, + props.row.extra.fiat_amount) }}
diff --git a/lnbits/static/js/wallet.js b/lnbits/static/js/wallet.js index a80505fcf..2ca50f5ab 100644 --- a/lnbits/static/js/wallet.js +++ b/lnbits/static/js/wallet.js @@ -241,6 +241,7 @@ new Vue({ location: window.location }, balance: 0, + fiatBalance: 0, credit: 0, update: { name: null, @@ -256,6 +257,14 @@ new Vue({ return LNbits.utils.formatSat(this.balance || this.g.wallet.sat) } }, + formattedFiatBalance() { + if (this.fiatBalance) { + return LNbits.utils.formatCurrency( + this.fiatBalance.toFixed(2), + this.g.wallet.currency + ) + } + }, filteredPayments: function () { var q = this.paymentsTable.filter if (!q || q === '') return this.payments @@ -797,6 +806,24 @@ new Vue({ this.balance ]) }) + if (this.g.wallet.currency) { + this.updateFiatBalance() + } + }, + updateFiatBalance() { + if (!this.g.wallet.currency) return 0 + LNbits.api + .request('POST', `/api/v1/conversion`, null, { + amount: this.balance || this.g.wallet.sat, + to: this.g.wallet.currency + }) + .then(response => { + this.fiatBalance = response.data[this.g.wallet.currency] + }) + .catch(e => console.error(e)) + }, + formatFiat(currency, amount) { + return LNbits.utils.formatCurrency(amount, currency) }, exportCSV: function () { // status is important for export but it is not in paymentsTable