format and bundle

This commit is contained in:
Arc 2024-12-18 23:28:42 +00:00
parent fb5659de2a
commit 5997fd74fa
5 changed files with 58 additions and 57 deletions

View File

@ -684,13 +684,13 @@ async def m029_create_audit_table(db: Connection):
); );
""" """
) )
async def m030_add_currency_to_wallet(db: Connection): async def m030_add_currency_to_wallet(db: Connection):
""" """
Setting currency to default is heavy, so easier just to add a trigger. Setting currency to default is heavy, so easier just to add a trigger.
""" """
await db.execute( await db.execute(
""" """
CREATE TRIGGER IF NOT EXISTS set_default_currency CREATE TRIGGER IF NOT EXISTS set_default_currency
AFTER INSERT ON wallets AFTER INSERT ON wallets
@ -702,4 +702,4 @@ async def m030_add_currency_to_wallet(db: Connection):
WHERE id = NEW.id; WHERE id = NEW.id;
END; END;
""" """
) )

View File

@ -55,7 +55,7 @@
v-if="!isPrioritySwapped" v-if="!isPrioritySwapped"
style="height: 90px" style="height: 90px"
> >
<div class="col-7" > <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">
@ -100,9 +100,7 @@
v-if="update.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 v-text="formattedFiatAmount"></strong>
v-text="formattedFiatAmount"
></strong>
</div> </div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
@ -125,10 +123,11 @@
</div> </div>
</div> </div>
<div class="absolute-right q-pa-md" v-if="$q.screen.gt.md && update.currency"> <div
<div class="text-bold text-italic"> class="absolute-right q-pa-md"
BTC Price v-if="$q.screen.gt.md && update.currency"
</div> >
<div class="text-bold text-italic">BTC Price</div>
<span <span
class="text-bold text-italic" class="text-bold text-italic"
v-text="formattedExchange" v-text="formattedExchange"
@ -150,8 +149,7 @@
</div> </div>
</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">
<div class="col">
<q-btn <q-btn
unelevated unelevated
color="primary" color="primary"
@ -166,24 +164,21 @@
@click="showReceiveDialog" @click="showReceiveDialog"
:label="$t('create_invoice')" :label="$t('create_invoice')"
></q-btn> ></q-btn>
<q-btn <q-btn unelevated color="secondary" icon="qr_code_scanner">
unelevated
color="secondary"
icon="qr_code_scanner"
>
<q-tooltip <q-tooltip
><span v-text="$t('camera_tooltip')"></span ><span v-text="$t('camera_tooltip')"></span
></q-tooltip> ></q-tooltip>
</q-btn> </q-btn>
<lnbits-update-balance <lnbits-update-balance
v-if="$q.screen.gt.md" v-if="$q.screen.gt.md"
:wallet_id="this.g.wallet.id" :wallet_id="this.g.wallet.id"
:callback="updateBalanceCallback" :callback="updateBalanceCallback"
:small_btn="false" :small_btn="false"
></lnbits-update-balance> ></lnbits-update-balance>
</div></div> </div>
</div>
</q-card> </q-card>
<q-card <q-card
:style=" :style="
$q.screen.lt.md $q.screen.lt.md
@ -302,18 +297,18 @@
v-model="fiatTracking" v-model="fiatTracking"
color="primary" color="primary"
@update:model-value="handleFiatTracking" @update:model-value="handleFiatTracking"
></q-toggle> ></q-toggle>
</div> </div>
<div class="col"> <div class="col">
<q-select <q-select
filled filled
dense dense
v-model="update.currency" v-model="update.currency"
type="text" type="text"
:label="!fiatTracking ? 'Disabled' : $t('currency')" :label="!fiatTracking ? 'Disabled' : $t('currency')"
:options="receive.units.filter((u) => u !== 'sat')" :options="receive.units.filter((u) => u !== 'sat')"
:disable="!fiatTracking" :disable="!fiatTracking"
></q-select> ></q-select>
</div> </div>
</div> </div>
</div> </div>

File diff suppressed because one or more lines are too long

View File

@ -101,9 +101,9 @@ window.app = Vue.createApp({
currency currency
) )
this.formattedExchange = LNbits.utils.formatCurrency( this.formattedExchange = LNbits.utils.formatCurrency(
this.exchangeRate, this.exchangeRate,
currency currency
) )
}, },
msatoshiFormat(value) { msatoshiFormat(value) {
return LNbits.utils.formatSat(value / 1000) return LNbits.utils.formatSat(value / 1000)
@ -554,15 +554,15 @@ window.app = Vue.createApp({
this.formatFiatAmount(this.fiatBalance, currency) this.formatFiatAmount(this.fiatBalance, currency)
// make api call // 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.price / 100000000) * (response.data.price / 100000000) *
(this.balance || this.g.wallet.sat) (this.balance || this.g.wallet.sat)
this.exchangeRate = response.data.price.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)
}) })
.catch(e => console.error(e)) .catch(e => console.error(e))
}, },
@ -678,10 +678,7 @@ window.app = Vue.createApp({
handleFiatTracking() { handleFiatTracking() {
if (this.fiatTracking === false) { if (this.fiatTracking === false) {
this.update.currency = '' this.update.currency = ''
this.$q.localStorage.setItem( this.$q.localStorage.setItem('lnbits.isPrioritySwapped', false)
'lnbits.isPrioritySwapped',
false
)
this.$q.localStorage.remove(`lnbits.exchangeRate`) this.$q.localStorage.remove(`lnbits.exchangeRate`)
} }
} }
@ -700,7 +697,7 @@ window.app = Vue.createApp({
setTimeout(() => { setTimeout(() => {
this.ignoreWatcher = false this.ignoreWatcher = false
}, 3000) }, 3000)
if(this.g.wallet.currency){ if (this.g.wallet.currency) {
this.fiatTracking = true this.fiatTracking = true
this.updateFiatBalance(this.g.wallet.currency) this.updateFiatBalance(this.g.wallet.currency)
} }
@ -718,7 +715,7 @@ window.app = Vue.createApp({
}, },
'update.currency'(newValue) { 'update.currency'(newValue) {
if (this.ignoreWatcher) return if (this.ignoreWatcher) return
this.updateWallet({ currency: newValue }) this.updateWallet({currency: newValue})
this.updateFiatBalance(newValue) this.updateFiatBalance(newValue)
} }
}, },
@ -729,8 +726,10 @@ window.app = Vue.createApp({
this.$q.localStorage.set('lnbits.disclaimerShown', true) this.$q.localStorage.set('lnbits.disclaimerShown', true)
} }
// check blanace priority // check blanace priority
if (this.$q.localStorage.getItem('lnbits.isPrioritySwapped')){ if (this.$q.localStorage.getItem('lnbits.isPrioritySwapped')) {
this.isPrioritySwapped = this.$q.localStorage.getItem('lnbits.isPrioritySwapped') this.isPrioritySwapped = this.$q.localStorage.getItem(
'lnbits.isPrioritySwapped'
)
} else { } else {
this.isPrioritySwapped = false this.isPrioritySwapped = false
this.$q.localStorage.setItem('lnbits.isPrioritySwapped', false) this.$q.localStorage.setItem('lnbits.isPrioritySwapped', false)

View File

@ -506,7 +506,14 @@
</template> </template>
<template id="lnbits-update-balance"> <template id="lnbits-update-balance">
<q-btn v-if="admin && small_btn" flat round color="primary" size="sm" icon="add"> <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-popup-edit class="bg-accent text-white" v-slot="scope" v-model="credit">
<q-input <q-input
filled filled
@ -523,14 +530,14 @@
</q-popup-edit> </q-popup-edit>
<q-tooltip v-text="$t('credit_hint')"></q-tooltip> <q-tooltip v-text="$t('credit_hint')"></q-tooltip>
</q-btn> </q-btn>
<q-btn <q-btn
v-if="admin && !small_btn" v-if="admin && !small_btn"
color="primary" color="primary"
:label="$t('credit_debit')" :label="$t('credit_debit')"
class="float-right q-mt-sm" class="float-right q-mt-sm"
size="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