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> <q-btn flat color="grey" @click="exportCSV">Export to CSV</q-btn>
</div> </div>
</div> </div>
<q-table dense flat :data="temps" row-key="id" :columns="tempsTable.columns" <q-table dense flat :data="myex" row-key="id" :columns="myexTable.columns"
:pagination.sync="tempsTable.pagination"> :pagination.sync="myexTable.pagination">
<myextension v-slot:header="props"> <myextension v-slot:header="props">
<q-tr :props="props"> <q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props"> <q-th v-for="col in props.cols" :key="col.name" :props="props">
@ -175,8 +175,8 @@
return { return {
invoiceAmount: 10, invoiceAmount: 10,
qrValue: 'lnurlpay', qrValue: 'lnurlpay',
temps: [], myex: [],
tempsTable: { myexTable: {
columns: [ columns: [
{ name: 'id', align: 'left', label: 'ID', field: 'id' }, { name: 'id', align: 'left', label: 'ID', field: 'id' },
{ name: 'name', align: 'left', label: 'Name', field: 'name' }, { name: 'name', align: 'left', label: 'Name', field: 'name' },
@ -194,15 +194,8 @@
}, },
formDialog: { formDialog: {
show: false, show: false,
data: { data: {},
withdrawpin: 878787, advanced: {}
tip_options: [],
withdrawbtwn: 10
},
advanced: {
tips: false,
otc: false
}
}, },
urlDialog: { urlDialog: {
show: false, show: false,
@ -218,11 +211,7 @@
methods: { methods: {
closeFormDialog() { closeFormDialog() {
this.formDialog.show = false this.formDialog.show = false
this.formDialog.data = { this.formDialog.data = {}
withdrawpin: 878787,
tip_options: [],
withdrawbtwn: 10
}
}, },
getMyExtensions: function () { getMyExtensions: function () {
var self = this var self = this
@ -230,11 +219,11 @@
LNbits.api LNbits.api
.request( .request(
'GET', 'GET',
'/myextension/api/v1/temps?all_wallets=true', '/myextension/api/v1/myex?all_wallets=true',
this.g.user.wallets[0].inkey this.g.user.wallets[0].inkey
) )
.then(function (response) { .then(function (response) {
self.temps = response.data.map(function (obj) { self.myex = response.data.map(function (obj) {
return mapMyExtension(obj) return mapMyExtension(obj)
}) })
}) })
@ -258,7 +247,7 @@
} }
}, },
updateMyExtensionForm(tempId) { updateMyExtensionForm(tempId) {
const myextension = _.findWhere(this.temps, { id: tempId }) const myextension = _.findWhere(this.myex, { id: tempId })
this.formDialog.data = { this.formDialog.data = {
...myextension ...myextension
} }
@ -272,9 +261,9 @@
}, },
createMyExtension(wallet, data) { createMyExtension(wallet, data) {
LNbits.api LNbits.api
.request('POST', '/myextension/api/v1/temps', wallet.adminkey, data) .request('POST', '/myextension/api/v1/myex', wallet.adminkey, data)
.then(response => { .then(response => {
this.temps.push(mapMyExtension(response.data)) this.myex.push(mapMyExtension(response.data))
this.closeFormDialog() this.closeFormDialog()
}) })
.catch(error => { .catch(error => {
@ -285,15 +274,15 @@
LNbits.api LNbits.api
.request( .request(
'PUT', 'PUT',
`/myextension/api/v1/temps/${data.id}`, `/myextension/api/v1/myex/${data.id}`,
wallet.adminkey, wallet.adminkey,
data data
) )
.then(response => { .then(response => {
this.temps = _.reject(this.temps, obj => { this.myex = _.reject(this.myex, obj => {
return obj.id == data.id return obj.id == data.id
}) })
this.temps.push(mapMyExtension(response.data)) this.myex.push(mapMyExtension(response.data))
this.closeFormDialog() this.closeFormDialog()
}) })
.catch(error => { .catch(error => {
@ -302,7 +291,7 @@
}, },
deleteMyExtension: function (tempId) { deleteMyExtension: function (tempId) {
var self = this var self = this
var myextension = _.findWhere(this.temps, { id: tempId }) var myextension = _.findWhere(this.myex, { id: tempId })
LNbits.utils LNbits.utils
.confirmDialog('Are you sure you want to delete this MyExtension?') .confirmDialog('Are you sure you want to delete this MyExtension?')
@ -310,11 +299,11 @@
LNbits.api LNbits.api
.request( .request(
'DELETE', 'DELETE',
'/myextension/api/v1/temps/' + tempId, '/myextension/api/v1/myex/' + tempId,
_.findWhere(self.g.user.wallets, { id: myextension.wallet }).adminkey _.findWhere(self.g.user.wallets, { id: myextension.wallet }).adminkey
) )
.then(function (response) { .then(function (response) {
self.temps = _.reject(self.temps, function (obj) { self.myex = _.reject(self.myex, function (obj) {
return obj.id == tempId return obj.id == tempId
}) })
}) })
@ -324,20 +313,15 @@
}) })
}, },
exportCSV: function () { exportCSV: function () {
LNbits.utils.exportCSV(this.tempsTable.columns, this.temps) LNbits.utils.exportCSV(this.myexTable.columns, this.myex)
}, },
itemsArray(tempId) { itemsArray(tempId) {
const myextension = _.findWhere(this.temps, { id: tempId }) const myextension = _.findWhere(this.myex, { id: tempId })
return [...myextension.itemsMap.values()] 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) { openformDialog(id) {
const [tempId, itemId] = id.split(':') const [tempId, itemId] = id.split(':')
const myextension = _.findWhere(this.temps, { id: tempId }) const myextension = _.findWhere(this.myex, { id: tempId })
if (itemId) { if (itemId) {
const item = myextension.itemsMap.get(id) const item = myextension.itemsMap.get(id)
this.formDialog.data = { this.formDialog.data = {
@ -352,15 +336,10 @@
}, },
closeformDialog() { closeformDialog() {
this.formDialog.show = false this.formDialog.show = false
this.formDialog.data = { this.formDialog.data = {}
title: '',
image: '',
price: '',
disabled: false
}
}, },
openUrlDialog(id) { openUrlDialog(id) {
this.urlDialog.data = _.findWhere(this.temps, { id }) this.urlDialog.data = _.findWhere(this.myex, { id })
this.qrValue = this.urlDialog.data.lnurlpay this.qrValue = this.urlDialog.data.lnurlpay
console.log(this.urlDialog.data.id) console.log(this.urlDialog.data.id)
this.connectWebocket(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 . import myextension_ext, myextension_renderer
from .crud import get_myextension 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 ## 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( async def api_myextensions(
req: Request, req: Request,
all_wallets: bool = Query(False), all_wallets: bool = Query(False),
@ -55,7 +55,7 @@ async def api_myextensions(
## Get a single record ## 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( async def api_myextension(
req: Request, myextension_id: str, WalletTypeInfo=Depends(get_key_type) req: Request, myextension_id: str, WalletTypeInfo=Depends(get_key_type)
): ):
@ -70,7 +70,7 @@ async def api_myextension(
## update a record ## update a record
@myextension_ext.put("/api/v1/temps/{myextension_id}") @myextension_ext.put("/api/v1/myex/{myextension_id}")
async def api_myextension_update( async def api_myextension_update(
req: Request, req: Request,
data: CreateMyExtensionData, data: CreateMyExtensionData,
@ -97,7 +97,7 @@ async def api_myextension_update(
## Create a new record ## 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( async def api_myextension_create(
req: Request, req: Request,
data: CreateMyExtensionData, data: CreateMyExtensionData,
@ -112,7 +112,7 @@ async def api_myextension_create(
## Delete a record ## Delete a record
@myextension_ext.delete("/api/v1/temps/{myextension_id}") @myextension_ext.delete("/api/v1/myex/{myextension_id}")
async def api_myextension_delete( async def api_myextension_delete(
myextension_id: str, wallet: WalletTypeInfo = Depends(require_admin_key) myextension_id: str, wallet: WalletTypeInfo = Depends(require_admin_key)
): ):
@ -138,7 +138,7 @@ async def api_myextension_delete(
@myextension_ext.post( @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( async def api_tpos_create_invoice(
myextension_id: str, amount: int = Query(..., ge=1), memo: str = "" 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}", memo=f"{memo} to {myextension.name}" if memo else f"{myextension.name}",
extra={ extra={
"tag": "myextension", "tag": "myextension",
"tipAmount": tipAmount,
"tempId": tempId,
"amount": amount, "amount": amount,
}, },
) )