working, also fixed the button
This commit is contained in:
@@ -36,7 +36,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-1" style="max-width: 30px">
|
<div class="col-1" style="max-width: 30px">
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="g.wallet.currency"
|
v-if="update.currency"
|
||||||
@click="swapBalancePriority"
|
@click="swapBalancePriority"
|
||||||
style="height: 50px"
|
style="height: 50px"
|
||||||
class="q-mt-lg"
|
class="q-mt-lg"
|
||||||
@@ -48,10 +48,14 @@
|
|||||||
<div class="col-11">
|
<div class="col-11">
|
||||||
<div
|
<div
|
||||||
class="column"
|
class="column"
|
||||||
|
:class="{
|
||||||
|
'q-pt-sm': update.currency,
|
||||||
|
'q-pt-lg': !update.currency
|
||||||
|
}"
|
||||||
v-if="!isPrioritySwapped"
|
v-if="!isPrioritySwapped"
|
||||||
style="height: 100px"
|
style="height: 90px"
|
||||||
>
|
>
|
||||||
<div class="col-7" :class="{'q-pt-lg': !g.wallet.currency && !fiatTracking}">
|
<div class="col-7" >
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<div class="text-h3 q-my-none text-no-wrap">
|
<div class="text-h3 q-my-none text-no-wrap">
|
||||||
@@ -70,7 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<div v-if="g.wallet.currency && fiatTracking">
|
<div v-if="update.currency">
|
||||||
<span
|
<span
|
||||||
class="text-h5 text-italic"
|
class="text-h5 text-italic"
|
||||||
v-text="formattedFiatAmount"
|
v-text="formattedFiatAmount"
|
||||||
@@ -82,14 +86,18 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="column"
|
class="column"
|
||||||
v-if="isPrioritySwapped && fiatTracking"
|
v-if="isPrioritySwapped"
|
||||||
|
:class="{
|
||||||
|
'q-pt-sm': update.currency,
|
||||||
|
'q-pt-lg': !update.currency
|
||||||
|
}"
|
||||||
style="height: 100px"
|
style="height: 100px"
|
||||||
>
|
>
|
||||||
<div class="col-7">
|
<div class="col-7">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<div
|
<div
|
||||||
v-if="g.wallet.currency"
|
v-if="update.currency"
|
||||||
class="text-h3 q-my-none text-no-wrap"
|
class="text-h3 q-my-none text-no-wrap"
|
||||||
>
|
>
|
||||||
<strong
|
<strong
|
||||||
@@ -117,7 +125,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="absolute-right q-pa-md" v-if="$q.screen.gt.md && g.wallet.currency && fiatTracking">
|
<div class="absolute-right q-pa-md" v-if="$q.screen.gt.md && update.currency">
|
||||||
<div class="text-bold text-italic">
|
<div class="text-bold text-italic">
|
||||||
BTC Price
|
BTC Price
|
||||||
</div>
|
</div>
|
||||||
@@ -143,6 +151,7 @@
|
|||||||
</q-card-section>
|
</q-card-section>
|
||||||
<div class="row q-pb-md q-px-md q-col-gutter-md gt-sm">
|
<div class="row q-pb-md q-px-md q-col-gutter-md gt-sm">
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
color="primary"
|
color="primary"
|
||||||
@@ -172,7 +181,7 @@
|
|||||||
:callback="updateBalanceCallback"
|
:callback="updateBalanceCallback"
|
||||||
:small_btn="false"
|
:small_btn="false"
|
||||||
></lnbits-update-balance>
|
></lnbits-update-balance>
|
||||||
</div>
|
</div></div>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
<q-card
|
<q-card
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ window.app.component('lnbits-dynamic-chips', {
|
|||||||
window.app.component('lnbits-update-balance', {
|
window.app.component('lnbits-update-balance', {
|
||||||
template: '#lnbits-update-balance',
|
template: '#lnbits-update-balance',
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
props: ['wallet_id', 'credit-value'],
|
props: ['wallet_id', 'credit-value', 'small_btn'],
|
||||||
computed: {
|
computed: {
|
||||||
denomination() {
|
denomination() {
|
||||||
return LNBITS_DENOMINATION
|
return LNBITS_DENOMINATION
|
||||||
|
|||||||
+21
-14
@@ -62,7 +62,9 @@ window.app = Vue.createApp({
|
|||||||
isPrioritySwapped: false,
|
isPrioritySwapped: false,
|
||||||
fiatTracking: false,
|
fiatTracking: false,
|
||||||
formattedFiatAmount: 0,
|
formattedFiatAmount: 0,
|
||||||
exchangeRate: 0
|
exchangeRate: 0,
|
||||||
|
formattedExchange: null,
|
||||||
|
ignoreWatcher: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -73,14 +75,6 @@ window.app = Vue.createApp({
|
|||||||
return LNbits.utils.formatSat(this.balance || this.g.wallet.sat)
|
return LNbits.utils.formatSat(this.balance || this.g.wallet.sat)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formattedExchange() {
|
|
||||||
if (this.fiatTracking) {
|
|
||||||
return LNbits.utils.formatCurrency(
|
|
||||||
this.exchangeRate,
|
|
||||||
this.g.wallet.currency
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
canPay() {
|
canPay() {
|
||||||
if (!this.parse.invoice) return false
|
if (!this.parse.invoice) return false
|
||||||
return this.parse.invoice.sat <= this.balance
|
return this.parse.invoice.sat <= this.balance
|
||||||
@@ -101,10 +95,15 @@ window.app = Vue.createApp({
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatFiatAmount(amount, currency) {
|
formatFiatAmount(amount, currency) {
|
||||||
|
this.update.currency = currency
|
||||||
this.formattedFiatAmount = LNbits.utils.formatCurrency(
|
this.formattedFiatAmount = LNbits.utils.formatCurrency(
|
||||||
amount.toFixed(2),
|
amount.toFixed(2),
|
||||||
currency
|
currency
|
||||||
)
|
)
|
||||||
|
this.formattedExchange = LNbits.utils.formatCurrency(
|
||||||
|
this.exchangeRate,
|
||||||
|
currency
|
||||||
|
)
|
||||||
},
|
},
|
||||||
msatoshiFormat(value) {
|
msatoshiFormat(value) {
|
||||||
return LNbits.utils.formatSat(value / 1000)
|
return LNbits.utils.formatSat(value / 1000)
|
||||||
@@ -548,16 +547,19 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateFiatBalance(currency) {
|
updateFiatBalance(currency) {
|
||||||
|
// set rate from local storage to avoid clunky api calls
|
||||||
this.exchangeRate = this.$q.localStorage.getItem('lnbits.exchangeRate')
|
this.exchangeRate = this.$q.localStorage.getItem('lnbits.exchangeRate')
|
||||||
this.fiatBalance =
|
this.fiatBalance =
|
||||||
(this.exchangeRate / 100000000) * (this.g.wallet.sat)
|
(this.exchangeRate / 100000000) * (this.balance || this.g.wallet.sat)
|
||||||
|
this.formatFiatAmount(this.fiatBalance, currency)
|
||||||
|
// make api call
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request('GET', `/api/v1/rate/` + currency, null)
|
.request('GET', `/api/v1/rate/` + currency, null)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.fiatBalance =
|
this.fiatBalance =
|
||||||
(response.data.rate / 100000000) *
|
(response.data.price / 100000000) *
|
||||||
(this.g.wallet.sat)
|
(this.balance || this.g.wallet.sat)
|
||||||
this.exchangeRate = response.data.rate.toFixed(2)
|
this.exchangeRate = response.data.price.toFixed(2)
|
||||||
this.fiatTracking = true
|
this.fiatTracking = true
|
||||||
this.formatFiatAmount(this.fiatBalance, currency)
|
this.formatFiatAmount(this.fiatBalance, currency)
|
||||||
this.$q.localStorage.set('lnbits.exchangeRate', this.exchangeRate)
|
this.$q.localStorage.set('lnbits.exchangeRate', this.exchangeRate)
|
||||||
@@ -675,7 +677,7 @@ window.app = Vue.createApp({
|
|||||||
},
|
},
|
||||||
handleFiatTracking() {
|
handleFiatTracking() {
|
||||||
if (this.fiatTracking === false) {
|
if (this.fiatTracking === false) {
|
||||||
this.updateWallet({ currency: ''})
|
this.update.currency = ''
|
||||||
this.$q.localStorage.setItem(
|
this.$q.localStorage.setItem(
|
||||||
'lnbits.isPrioritySwapped',
|
'lnbits.isPrioritySwapped',
|
||||||
false
|
false
|
||||||
@@ -695,7 +697,11 @@ window.app = Vue.createApp({
|
|||||||
if (this.$q.screen.lt.md) {
|
if (this.$q.screen.lt.md) {
|
||||||
this.mobileSimple = true
|
this.mobileSimple = true
|
||||||
}
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
this.ignoreWatcher = false
|
||||||
|
}, 3000)
|
||||||
if(this.g.wallet.currency){
|
if(this.g.wallet.currency){
|
||||||
|
this.fiatTracking = true
|
||||||
this.updateFiatBalance(this.g.wallet.currency)
|
this.updateFiatBalance(this.g.wallet.currency)
|
||||||
}
|
}
|
||||||
this.update.name = this.g.wallet.name
|
this.update.name = this.g.wallet.name
|
||||||
@@ -711,6 +717,7 @@ window.app = Vue.createApp({
|
|||||||
this.fetchBalance()
|
this.fetchBalance()
|
||||||
},
|
},
|
||||||
'update.currency'(newValue) {
|
'update.currency'(newValue) {
|
||||||
|
if (this.ignoreWatcher) return
|
||||||
this.updateWallet({ currency: newValue })
|
this.updateWallet({ currency: newValue })
|
||||||
this.updateFiatBalance(newValue)
|
this.updateFiatBalance(newValue)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -506,7 +506,31 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="lnbits-update-balance">
|
<template id="lnbits-update-balance">
|
||||||
<q-btn v-if="admin" :label="$t('credit_debit')" color="secondary" size="sm">
|
<q-btn v-if="admin && small_btn" flat round color="primary" size="sm" icon="add">
|
||||||
|
<q-popup-edit class="bg-accent text-white" v-slot="scope" v-model="credit">
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
:label="$t('credit_label', {denomination: denomination})"
|
||||||
|
v-model="scope.value"
|
||||||
|
dense
|
||||||
|
autofocus
|
||||||
|
@keyup.enter="scope.set"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon name="edit" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</q-popup-edit>
|
||||||
|
<q-tooltip v-text="$t('credit_hint')"></q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
|
||||||
|
<q-btn
|
||||||
|
v-if="admin && !small_btn"
|
||||||
|
color="primary"
|
||||||
|
:label="$t('credit_debit')"
|
||||||
|
class="float-right q-mt-sm"
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
<q-popup-edit class="bg-accent text-white" v-slot="scope" v-model="credit">
|
<q-popup-edit class="bg-accent text-white" v-slot="scope" v-model="credit">
|
||||||
<q-input
|
<q-input
|
||||||
filled
|
filled
|
||||||
|
|||||||
Reference in New Issue
Block a user