Removed ability to update charge, as caused too many issues

This commit is contained in:
Ben Arc 2021-04-08 01:01:10 +01:00
parent 2d8f85f77c
commit b7090d963b
3 changed files with 13 additions and 89 deletions

View file

@ -21,7 +21,6 @@ async def create_charge(user: str, description: str = None, onchainwallet: Optio
wallet = await get_watch_wallet(onchainwallet) wallet = await get_watch_wallet(onchainwallet)
onchainaddress = await get_derive_address(onchainwallet, int(wallet[4]) + 1) onchainaddress = await get_derive_address(onchainwallet, int(wallet[4]) + 1)
await update_watch_wallet(wallet_id=onchainwallet, address_no=int(wallet[4]) + 1) await update_watch_wallet(wallet_id=onchainwallet, address_no=int(wallet[4]) + 1)
print(onchainaddress)
else: else:
onchainaddress = None onchainaddress = None
if lnbitswallet: if lnbitswallet:

View file

@ -17,12 +17,16 @@
<div class="col"> <div class="col">
<h5 class="text-subtitle1 q-my-none">Charges</h5> <h5 class="text-subtitle1 q-my-none">Charges</h5>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<q-input borderless dense debounce="300" v-model="filter" placeholder="Search"> <q-input borderless dense debounce="300" v-model="filter" placeholder="Search">
<template v-slot:append> <template v-slot:append>
<q-icon name="search"></q-icon> <q-icon name="search"></q-icon>
</template> </template>
</q-input> </q-input>
<q-btn flat color="grey" @click="exportchargeCSV"
>Export to CSV</q-btn
>
</div> </div>
</div> </div>
@ -109,18 +113,6 @@
<q-tooltip> <q-tooltip>
Processing Processing
</q-tooltip> </q-tooltip>
</q-btn>
<q-btn
flat
dense
size="xs"
@click="openUpdateDialog(props.row.id)"
icon="edit"
color="light-blue"
>
<q-tooltip>
Edit charge
</q-tooltip>
</q-btn> </q-btn>
<q-btn <q-btn
flat flat
@ -271,14 +263,6 @@
</div> </div>
<div class="row q-mt-lg"> <div class="row q-mt-lg">
<q-btn <q-btn
v-if="formDialogCharge.data.id"
unelevated
color="deep-purple"
type="submit"
>Update Paylink</q-btn
>
<q-btn
v-else
unelevated unelevated
color="deep-purple" color="deep-purple"
:disable=" :disable="
@ -422,7 +406,9 @@
data: { data: {
onchain: false, onchain: false,
lnbits:false, lnbits:false,
description: "" description: "",
time: null,
amount: null,
} }
}, },
qrCodeDialog: { qrCodeDialog: {
@ -475,22 +461,6 @@
self.current = linkId self.current = linkId
self.Addresses.show = true self.Addresses.show = true
}, },
openUpdateDialog: function (linkId) {
var link = _.findWhere(this.walletLinks, {id: linkId})
this.formDialog.data = _.clone(link._data)
this.formDialog.show = true
},
sendFormData: function () {
var wallet = this.g.user.wallets[0]
var data = _.omit(this.formDialog.data, 'wallet')
if (data.id) {
this.updateWalletLink(wallet, data)
} else {
this.createWalletLink(wallet, data)
}
},
getCharges: function () { getCharges: function () {
var self = this var self = this
var getAddressBalance = this.getAddressBalance var getAddressBalance = this.getAddressBalance
@ -514,30 +484,7 @@
var data = this.formDialogCharge.data var data = this.formDialogCharge.data
data.amount = parseInt(data.amount) data.amount = parseInt(data.amount)
data.time = parseInt(data.time) data.time = parseInt(data.time)
if (data.id) {
this.updateCharge(wallet, data)
} else {
this.createCharge(wallet, data) this.createCharge(wallet, data)
}
},
updateCharge: function (wallet, data) {
var self = this
LNbits.api
.request(
'PUT',
'/satspay/api/v1/charge/' + data.id,
wallet.adminkey, data)
.then(function (response) {
self.Charge = _.reject(self.Charge, function (obj) {
return obj.id === data.id
})
self.Charge.push(mapCharge(response.data))
self.formDialogPayLink.show = false
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
}, },
timerCount: function () { timerCount: function () {
self = this self = this
@ -573,31 +520,9 @@
}) })
}, },
deleteCharge: function (linkId) {
var self = this
var link = _.findWhere(this.Charge, {id: linkId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this pay link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/satspay/api/v1/charge/' + linkId,
self.g.user.wallets[0].inkey
)
.then(function (response) {
self.Charge = _.reject(self.Charge, function (obj) {
return obj.id === linkId
})})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
deleteChargeLink: function (chargeId) { deleteChargeLink: function (chargeId) {
var self = this var self = this
var link = _.findWhere(this.chargeLinks, {id: chargeId}) var link = _.findWhere(this.ChargeLinks, {id: chargeId})
LNbits.utils LNbits.utils
.confirmDialog('Are you sure you want to delete this pay link?') .confirmDialog('Are you sure you want to delete this pay link?')
.onOk(function () { .onOk(function () {
@ -608,7 +533,7 @@
self.g.user.wallets[0].adminkey self.g.user.wallets[0].adminkey
) )
.then(function (response) { .then(function (response) {
self.chargeLinks = _.reject(self.chargeLinks, function (obj) { self.ChargeLinks = _.reject(self.ChargeLinks, function (obj) {
return obj.id === chargeId return obj.id === chargeId
})}) })})
.catch(function (error) { .catch(function (error) {
@ -616,8 +541,9 @@
}) })
}) })
}, },
exportCSV: function () { exportchargeCSV: function () {
LNbits.utils.exportCSV(this.ChargesTable.columns, this.chargeLinks) var self = this
LNbits.utils.exportCSV(self.ChargesTable.columns, this.ChargeLinks)
}, },
}, },

View file

@ -36,7 +36,6 @@ from .crud import (
} }
) )
async def api_charge_create_or_update(charge_id=None): async def api_charge_create_or_update(charge_id=None):
if not charge_id: if not charge_id:
charge = await create_charge(user=g.wallet.user, **g.data) charge = await create_charge(user=g.wallet.user, **g.data)
return jsonify(charge._asdict()), HTTPStatus.CREATED return jsonify(charge._asdict()), HTTPStatus.CREATED