renamed endpoints and stripped out some dead code

This commit is contained in:
benarc 2024-06-03 14:12:39 +01:00
parent b2e6f4f0cf
commit 43c00b0c7e
3 changed files with 30 additions and 53 deletions

View file

@ -22,8 +22,8 @@
<q-btn flat color="grey" @click="exportCSV">Export to CSV</q-btn>
</div>
</div>
<q-table dense flat :data="temps" row-key="id" :columns="tempsTable.columns"
:pagination.sync="tempsTable.pagination">
<q-table dense flat :data="myex" row-key="id" :columns="myexTable.columns"
:pagination.sync="myexTable.pagination">
<myextension v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
@ -175,8 +175,8 @@
return {
invoiceAmount: 10,
qrValue: 'lnurlpay',
temps: [],
tempsTable: {
myex: [],
myexTable: {
columns: [
{ name: 'id', align: 'left', label: 'ID', field: 'id' },
{ name: 'name', align: 'left', label: 'Name', field: 'name' },
@ -194,15 +194,8 @@
},
formDialog: {
show: false,
data: {
withdrawpin: 878787,
tip_options: [],
withdrawbtwn: 10
},
advanced: {
tips: false,
otc: false
}
data: {},
advanced: {}
},
urlDialog: {
show: false,
@ -218,11 +211,7 @@
methods: {
closeFormDialog() {
this.formDialog.show = false
this.formDialog.data = {
withdrawpin: 878787,
tip_options: [],
withdrawbtwn: 10
}
this.formDialog.data = {}
},
getMyExtensions: function () {
var self = this
@ -230,11 +219,11 @@
LNbits.api
.request(
'GET',
'/myextension/api/v1/temps?all_wallets=true',
'/myextension/api/v1/myex?all_wallets=true',
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.temps = response.data.map(function (obj) {
self.myex = response.data.map(function (obj) {
return mapMyExtension(obj)
})
})
@ -258,7 +247,7 @@
}
},
updateMyExtensionForm(tempId) {
const myextension = _.findWhere(this.temps, { id: tempId })
const myextension = _.findWhere(this.myex, { id: tempId })
this.formDialog.data = {
...myextension
}
@ -272,9 +261,9 @@
},
createMyExtension(wallet, data) {
LNbits.api
.request('POST', '/myextension/api/v1/temps', wallet.adminkey, data)
.request('POST', '/myextension/api/v1/myex', wallet.adminkey, data)
.then(response => {
this.temps.push(mapMyExtension(response.data))
this.myex.push(mapMyExtension(response.data))
this.closeFormDialog()
})
.catch(error => {
@ -285,15 +274,15 @@
LNbits.api
.request(
'PUT',
`/myextension/api/v1/temps/${data.id}`,
`/myextension/api/v1/myex/${data.id}`,
wallet.adminkey,
data
)
.then(response => {
this.temps = _.reject(this.temps, obj => {
this.myex = _.reject(this.myex, obj => {
return obj.id == data.id
})
this.temps.push(mapMyExtension(response.data))
this.myex.push(mapMyExtension(response.data))
this.closeFormDialog()
})
.catch(error => {
@ -302,7 +291,7 @@
},
deleteMyExtension: function (tempId) {
var self = this
var myextension = _.findWhere(this.temps, { id: tempId })
var myextension = _.findWhere(this.myex, { id: tempId })
LNbits.utils
.confirmDialog('Are you sure you want to delete this MyExtension?')
@ -310,11 +299,11 @@
LNbits.api
.request(
'DELETE',
'/myextension/api/v1/temps/' + tempId,
'/myextension/api/v1/myex/' + tempId,
_.findWhere(self.g.user.wallets, { id: myextension.wallet }).adminkey
)
.then(function (response) {
self.temps = _.reject(self.temps, function (obj) {
self.myex = _.reject(self.myex, function (obj) {
return obj.id == tempId
})
})
@ -324,20 +313,15 @@
})
},
exportCSV: function () {
LNbits.utils.exportCSV(this.tempsTable.columns, this.temps)
LNbits.utils.exportCSV(this.myexTable.columns, this.myex)
},
itemsArray(tempId) {
const myextension = _.findWhere(this.temps, { id: tempId })
const myextension = _.findWhere(this.myex, { id: tempId })
return [...myextension.itemsMap.values()]
},
itemFormatPrice(price, id) {
const myextension = id.split(':')[0]
const currency = _.findWhere(this.temps, { id: myextension }).currency
return LNbits.utils.formatCurrency(Number(price).toFixed(2), currency)
},
openformDialog(id) {
const [tempId, itemId] = id.split(':')
const myextension = _.findWhere(this.temps, { id: tempId })
const myextension = _.findWhere(this.myex, { id: tempId })
if (itemId) {
const item = myextension.itemsMap.get(id)
this.formDialog.data = {
@ -352,15 +336,10 @@
},
closeformDialog() {
this.formDialog.show = false
this.formDialog.data = {
title: '',
image: '',
price: '',
disabled: false
}
this.formDialog.data = {}
},
openUrlDialog(id) {
this.urlDialog.data = _.findWhere(this.temps, { id })
this.urlDialog.data = _.findWhere(this.myex, { id })
this.qrValue = this.urlDialog.data.lnurlpay
console.log(this.urlDialog.data.id)
this.connectWebocket(this.urlDialog.data.id)

View file

@ -12,7 +12,7 @@ from lnbits.settings import settings
from . import myextension_ext, myextension_renderer
from .crud import get_myextension
temps = Jinja2Templates(directory="temps")
myex = Jinja2Templates(directory="myex")
#######################################

View file

@ -37,7 +37,7 @@ from .models import CreateMyExtensionData
## Get all the records belonging to the user
@myextension_ext.get("/api/v1/temps", status_code=HTTPStatus.OK)
@myextension_ext.get("/api/v1/myex", status_code=HTTPStatus.OK)
async def api_myextensions(
req: Request,
all_wallets: bool = Query(False),
@ -55,7 +55,7 @@ async def api_myextensions(
## Get a single record
@myextension_ext.get("/api/v1/temps/{myextension_id}", status_code=HTTPStatus.OK)
@myextension_ext.get("/api/v1/myex/{myextension_id}", status_code=HTTPStatus.OK)
async def api_myextension(
req: Request, myextension_id: str, WalletTypeInfo=Depends(get_key_type)
):
@ -70,7 +70,7 @@ async def api_myextension(
## update a record
@myextension_ext.put("/api/v1/temps/{myextension_id}")
@myextension_ext.put("/api/v1/myex/{myextension_id}")
async def api_myextension_update(
req: Request,
data: CreateMyExtensionData,
@ -97,7 +97,7 @@ async def api_myextension_update(
## Create a new record
@myextension_ext.post("/api/v1/temps", status_code=HTTPStatus.CREATED)
@myextension_ext.post("/api/v1/myex", status_code=HTTPStatus.CREATED)
async def api_myextension_create(
req: Request,
data: CreateMyExtensionData,
@ -112,7 +112,7 @@ async def api_myextension_create(
## Delete a record
@myextension_ext.delete("/api/v1/temps/{myextension_id}")
@myextension_ext.delete("/api/v1/myex/{myextension_id}")
async def api_myextension_delete(
myextension_id: str, wallet: WalletTypeInfo = Depends(require_admin_key)
):
@ -138,7 +138,7 @@ async def api_myextension_delete(
@myextension_ext.post(
"/api/v1/temps/payment/{myextension_id}", status_code=HTTPStatus.CREATED
"/api/v1/myex/payment/{myextension_id}", status_code=HTTPStatus.CREATED
)
async def api_tpos_create_invoice(
myextension_id: str, amount: int = Query(..., ge=1), memo: str = ""
@ -159,8 +159,6 @@ async def api_tpos_create_invoice(
memo=f"{memo} to {myextension.name}" if memo else f"{myextension.name}",
extra={
"tag": "myextension",
"tipAmount": tipAmount,
"tempId": tempId,
"amount": amount,
},
)