diff --git a/lnbits/extensions/boltcards/static/js/index.js b/lnbits/extensions/boltcards/static/js/index.js index 7757ffb4..ff23c4d1 100644 --- a/lnbits/extensions/boltcards/static/js/index.js +++ b/lnbits/extensions/boltcards/static/js/index.js @@ -17,6 +17,7 @@ new Vue({ toggleAdvanced: false, cards: [], hits: [], + refunds: [], cardDialog: { show: false, data: { @@ -164,6 +165,23 @@ new Vue({ console.log(self.hits) }) }, + getRefunds: function () { + var self = this + + LNbits.api + .request( + 'GET', + '/boltcards/api/v1/refunds?all_wallets=true', + this.g.user.wallets[0].inkey + ) + .then(function (response) { + self.refunds = response.data.map(function (obj) { + obj.card_name = self.cards.find(d => d.id == obj.card_id).card_name + return mapCards(obj) + }) + console.log(self.hits) + }) + }, openQrCodeDialog(cardId) { var card = _.findWhere(this.cards, {id: cardId}) @@ -177,8 +195,13 @@ new Vue({ } this.qrCodeDialog.show = true }, - generateKeys: function () { + addCardOpen: function () { this.cardDialog.show = true + var elem = this.$els.myBtn + elem.click() + }, + generateKeys: function () { + const genRanHex = size => [...Array(size)] .map(() => Math.floor(Math.random() * 16).toString(16)) @@ -307,7 +330,7 @@ new Vue({ if (this.g.user.wallets.length) { this.getCards() this.getHits() - this.getWithdraws() + this.getRefunds() } } }) diff --git a/lnbits/extensions/boltcards/templates/boltcards/index.html b/lnbits/extensions/boltcards/templates/boltcards/index.html index 4c409387..d8421754 100644 --- a/lnbits/extensions/boltcards/templates/boltcards/index.html +++ b/lnbits/extensions/boltcards/templates/boltcards/index.html @@ -5,7 +5,7 @@
- Add Card @@ -234,7 +234,7 @@ v-model="toggleAdvanced" label="Show advanced options" > -
+
Generate keys
diff --git a/lnbits/extensions/boltcards/views_api.py b/lnbits/extensions/boltcards/views_api.py index ee91cffb..cccc6a28 100644 --- a/lnbits/extensions/boltcards/views_api.py +++ b/lnbits/extensions/boltcards/views_api.py @@ -110,6 +110,22 @@ async def api_hits( ): wallet_ids = [g.wallet.id] + if all_wallets: + wallet_ids = (await get_user(g.wallet.user)).wallet_ids + + cards = await get_cards(wallet_ids) + cards_ids = [] + for card in cards: + cards_ids.append(card.id) + + return [hit.dict() for hit in await get_hits(cards_ids)] + +@boltcards_ext.get("/api/v1/refunds") +async def api_hits( + g: WalletTypeInfo = Depends(get_key_type), all_wallets: bool = Query(False) +): + wallet_ids = [g.wallet.id] + if all_wallets: wallet_ids = (await get_user(g.wallet.user)).wallet_ids