diff --git a/lnbits/core/models/wallets.py b/lnbits/core/models/wallets.py index 329a4f237..a67c7066a 100644 --- a/lnbits/core/models/wallets.py +++ b/lnbits/core/models/wallets.py @@ -33,8 +33,8 @@ class Wallet(BaseModel): updated_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc)) currency: Optional[str] = None balance_msat: int = Field(default=0, no_database=True) - icon: str - color: str + icon: str = "flash_on" + color: str = "primary" @property def balance(self) -> int: diff --git a/lnbits/core/templates/core/wallet.html b/lnbits/core/templates/core/wallet.html index 746b07f22..eb584dc01 100644 --- a/lnbits/core/templates/core/wallet.html +++ b/lnbits/core/templates/core/wallet.html @@ -36,50 +36,54 @@ >
+ - - + :color=" + wallet && wallet.id === wallets.id + ? wallet.color + : wallets.color + " + > +
- + {{LNBITS_DENOMINATION}}
@@ -102,7 +106,7 @@ {{LNBITS_DENOMINATION}} @@ -110,7 +114,7 @@
-
+
@@ -200,15 +204,16 @@
- - - + size="lg" + :icon="wallet.icon" + :text-color="$q.dark.isActive ? 'black' : 'grey-3'" + :color=" + wallet && wallet.id === wallet.id + ? wallet.color + : wallet.color + " + > +
{{ SITE_TITLE }} Wallet: @@ -223,7 +228,7 @@ diff --git a/lnbits/core/views/wallet_api.py b/lnbits/core/views/wallet_api.py index e0f663b2c..50c36d266 100644 --- a/lnbits/core/views/wallet_api.py +++ b/lnbits/core/views/wallet_api.py @@ -40,7 +40,7 @@ async def api_wallet(key_info: WalletTypeInfo = Depends(require_invoice_key)): return res -@wallet_router.put("/{new_name}") +@wallet_router.put("/") async def api_update_wallet_name( new_name: str, key_info: WalletTypeInfo = Depends(require_admin_key) ): @@ -59,6 +59,8 @@ async def api_update_wallet_name( @wallet_router.patch("") async def api_update_wallet( name: Optional[str] = Body(None), + icon: Optional[str] = Body(None), + color: Optional[str] = Body(None), currency: Optional[str] = Body(None), key_info: WalletTypeInfo = Depends(require_admin_key), ) -> Wallet: @@ -66,6 +68,8 @@ async def api_update_wallet( if not wallet: raise HTTPException(status_code=HTTPStatus.NOT_FOUND, detail="Wallet not found") wallet.name = name or wallet.name + wallet.icon = icon or wallet.icon + wallet.color = color or wallet.color wallet.currency = currency if currency is not None else wallet.currency await update_wallet(wallet) return wallet diff --git a/lnbits/static/js/wallet.js b/lnbits/static/js/wallet.js index 656a5234e..b35c9007d 100644 --- a/lnbits/static/js/wallet.js +++ b/lnbits/static/js/wallet.js @@ -211,6 +211,12 @@ window.app = Vue.createApp({ console.log(this.icon.data) this.updateWallet(this.icon.data) }, + getWallet(wallet) { + console.log(wallet) + console.log(this.g.wallet) + this.wallet = LNbits.map.wallet(wallet) + console.log(this.g.wallet) + }, createInvoice() { this.receive.status = 'loading' if (LNBITS_DENOMINATION != 'sats') { @@ -566,13 +572,15 @@ window.app = Vue.createApp({ updateWallet(data) { LNbits.api .request('PATCH', '/api/v1/wallet', this.g.wallet.adminkey, data) - .then(_ => { + .then(response => { + console.log(response.data) + this.wallet = LNbits.map.wallet(response.data) Quasar.Notify.create({ message: `Wallet updated.`, type: 'positive', timeout: 3500 }) - window.location.reload() + // window.location.reload() }) .catch(err => { LNbits.utils.notifyApiError(err) @@ -709,7 +717,24 @@ window.app = Vue.createApp({ dismissPaymentMsg() LNbits.utils.notifyApiError(err) }) + }, + walletColorAlpha(color){ + console.log(LNbits.utils.getPaletteColor(color)) + console.log(LNbits.utils.hexAlpha(LNbits.utils.getPaletteColor(color),0.3)) + return LNbits.utils.hexAlpha(LNbits.utils.getPaletteColor(color),0.3) + }, + incoming(wallet){ + // listen to incoming payments + LNbits.events.onInvoicePaid(wallet, data => { + console.log('Payment received:', data.payment.payment_hash) + console.log('Wallet balance:', data.wallet_balance) + console.log('Wallet ID:', wallet) + this.onPaymentReceived(data.payment.payment_hash) + this.balance = data.wallet_balance + eventReaction(data.payment.amount) + }) } + }, created() { const urlParams = new URLSearchParams(window.location.search) @@ -726,7 +751,6 @@ window.app = Vue.createApp({ this.update.currency = this.g.wallet.currency this.receive.units = ['sat', ...window.currencies] this.updateFiatBalance() - console.log('Wallet:', this.wallet) }, watch: { updatePayments() { @@ -744,15 +768,7 @@ window.app = Vue.createApp({ this.disclaimerDialog.show = true this.$q.localStorage.set('lnbits.disclaimerShown', true) } - // listen to incoming payments - LNbits.events.onInvoicePaid(this.g.wallet, data => { - console.log('Payment received:', data.payment.payment_hash) - console.log('Wallet balance:', data.wallet_balance) - console.log('Wallet ID:', this.g.wallet) - this.onPaymentReceived(data.payment.payment_hash) - this.balance = data.wallet_balance - eventReaction(data.payment.amount) - }) + this.incoming(this.g.wallet) } }) diff --git a/lnbits/templates/components.vue b/lnbits/templates/components.vue index 71b44cc7a..70504aa52 100644 --- a/lnbits/templates/components.vue +++ b/lnbits/templates/components.vue @@ -15,21 +15,20 @@ > - - + size="lg" + :icon="wallet.icon" + :text-color="$q.dark.isActive ? 'black' : 'grey-3'" + :class="activeWallet && activeWallet.id === wallet.id + ? '' + : 'disabled' + " + :color=" + activeWallet && activeWallet.id === wallet.id + ? wallet.color + : wallet.color + " + > +