Refactor MyExtension to DCA Admin: Update extension name and description in config.json, remove legacy MyExtension CRUD operations and related API endpoints, and adjust router tags. Clean up unused files and methods to streamline the codebase for DCA administration functionality.

Refactor DCA Admin page endpoints: Update description, remove unused CRUD operations and API endpoints related to MyExtension, and streamline the code for improved clarity and functionality.

Remove QR Code dialog from MyExtension index.html: streamline the UI by eliminating unused dialog components, enhancing code clarity and maintainability.
This commit is contained in:
padreug 2025-06-20 21:51:38 +02:00
parent edca91579c
commit 75dd03b15a
13 changed files with 32 additions and 971 deletions

View file

@ -119,32 +119,7 @@ window.app = Vue.createApp({
currencyOptions: [
{ label: 'GTQ', value: 'GTQ' },
{ label: 'USD', value: 'USD' }
],
// Legacy data (keep for backward compatibility)
invoiceAmount: 10,
qrValue: 'lnurlpay',
myex: [],
myexTable: {
columns: [
{ name: 'id', align: 'left', label: 'ID', field: 'id' },
{ name: 'name', align: 'left', label: 'Name', field: 'name' },
{ name: 'wallet', align: 'left', label: 'Wallet', field: 'wallet' },
{ name: 'total', align: 'left', label: 'Total sent/received', field: 'total' }
],
pagination: {
rowsPerPage: 10
}
},
formDialog: {
show: false,
data: {},
advanced: {}
},
urlDialog: {
show: false,
data: {}
}
]
}
},
@ -666,194 +641,6 @@ window.app = Vue.createApp({
}
},
// Legacy Methods (keep for backward compatibility)
async closeFormDialog() {
this.formDialog.show = false
this.formDialog.data = {}
},
async getMyExtensions() {
await LNbits.api
.request(
'GET',
'/myextension/api/v1/myex',
this.g.user.wallets[0].inkey
)
.then(response => {
this.myex = response.data
})
.catch(err => {
LNbits.utils.notifyApiError(err)
})
},
async sendMyExtensionData() {
const data = {
name: this.formDialog.data.name,
lnurlwithdrawamount: this.formDialog.data.lnurlwithdrawamount,
lnurlpayamount: this.formDialog.data.lnurlpayamount
}
const wallet = _.findWhere(this.g.user.wallets, {
id: this.formDialog.data.wallet
})
if (this.formDialog.data.id) {
data.id = this.formDialog.data.id
data.total = this.formDialog.data.total
await this.updateMyExtension(wallet, data)
} else {
await this.createMyExtension(wallet, data)
}
},
async updateMyExtensionForm(tempId) {
const myextension = _.findWhere(this.myex, { id: tempId })
this.formDialog.data = {
...myextension
}
if (this.formDialog.data.tip_wallet != '') {
this.formDialog.advanced.tips = true
}
if (this.formDialog.data.withdrawlimit >= 1) {
this.formDialog.advanced.otc = true
}
this.formDialog.show = true
},
async createMyExtension(wallet, data) {
data.wallet = wallet.id
await LNbits.api
.request('POST', '/myextension/api/v1/myex', wallet.adminkey, data)
.then(response => {
this.myex.push(response.data)
this.closeFormDialog()
})
.catch(error => {
LNbits.utils.notifyApiError(error)
})
},
async updateMyExtension(wallet, data) {
data.wallet = wallet.id
await LNbits.api
.request(
'PUT',
`/myextension/api/v1/myex/${data.id}`,
wallet.adminkey,
data
)
.then(response => {
this.myex = _.reject(this.myex, obj => obj.id == data.id)
this.myex.push(response.data)
this.closeFormDialog()
})
.catch(error => {
LNbits.utils.notifyApiError(error)
})
},
async deleteMyExtension(tempId) {
var myextension = _.findWhere(this.myex, { id: tempId })
const wallet = _.findWhere(this.g.user.wallets, {
id: myextension.wallet
})
await LNbits.utils
.confirmDialog('Are you sure you want to delete this MyExtension?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/myextension/api/v1/myex/' + tempId,
wallet.adminkey
)
.then(() => {
this.myex = _.reject(this.myex, function (obj) {
return obj.id === myextension.id
})
})
.catch(error => {
LNbits.utils.notifyApiError(error)
})
})
},
async exportCSV() {
await LNbits.utils.exportCSV(this.myexTable.columns, this.myex)
},
async itemsArray(tempId) {
const myextension = _.findWhere(this.myex, { id: tempId })
return [...myextension.itemsMap.values()]
},
async openformDialog(id) {
const [tempId, itemId] = id.split(':')
const myextension = _.findWhere(this.myex, { id: tempId })
if (itemId) {
const item = myextension.itemsMap.get(id)
this.formDialog.data = {
...item,
myextension: tempId
}
} else {
this.formDialog.data.myextension = tempId
}
this.formDialog.data.currency = myextension.currency
this.formDialog.show = true
},
async openUrlDialog(tempid) {
this.urlDialog.data = _.findWhere(this.myex, { id: tempid })
this.qrValue = this.urlDialog.data.lnurlpay
// Connecting to our websocket fired in tasks.py
this.connectWebocket(this.urlDialog.data.id)
this.urlDialog.show = true
},
async closeformDialog() {
this.formDialog.show = false
this.formDialog.data = {}
},
async createInvoice(tempid) {
///////////////////////////////////////////////////
///Simple call to the api to create an invoice/////
///////////////////////////////////////////////////
myex = _.findWhere(this.myex, { id: tempid })
const wallet = _.findWhere(this.g.user.wallets, { id: myex.wallet })
const data = {
myextension_id: tempid,
amount: this.invoiceAmount,
memo: 'MyExtension - ' + myex.name
}
await LNbits.api
.request('POST', `/myextension/api/v1/myex/payment`, wallet.inkey, data)
.then(response => {
this.qrValue = response.data.payment_request
this.connectWebocket(wallet.inkey)
})
.catch(error => {
LNbits.utils.notifyApiError(error)
})
},
connectWebocket(myextension_id) {
//////////////////////////////////////////////////
///wait for pay action to happen and do a thing////
///////////////////////////////////////////////////
if (location.protocol !== 'http:') {
localUrl =
'wss://' +
document.domain +
':' +
location.port +
'/api/v1/ws/' +
myextension_id
} else {
localUrl =
'ws://' +
document.domain +
':' +
location.port +
'/api/v1/ws/' +
myextension_id
}
this.connection = new WebSocket(localUrl)
this.connection.onmessage = () => {
this.urlDialog.show = false
}
}
},
///////////////////////////////////////////////////
//////LIFECYCLE FUNCTIONS RUNNING ON PAGE LOAD/////
@ -866,9 +653,6 @@ window.app = Vue.createApp({
this.getDeposits(),
this.getLamassuTransactions()
])
// Legacy data loading
await this.getMyExtensions()
},
computed: {