Adds user settings for the Castle extension

Adds functionality to configure the Castle extension, including a wallet ID.

This allows administrators to customize the extension's behavior by specifying a dedicated wallet for castle operations.
This commit is contained in:
padreug 2025-10-22 13:55:52 +02:00
parent ceabf96f79
commit 29983cedb7
7 changed files with 199 additions and 2 deletions

View file

@ -11,6 +11,8 @@ window.app = Vue.createApp({
transactions: [],
accounts: [],
currencies: [],
settings: null,
isAdmin: false,
expenseDialog: {
show: false,
description: '',
@ -25,6 +27,11 @@ window.app = Vue.createApp({
show: false,
amount: null,
loading: false
},
settingsDialog: {
show: false,
castleWalletId: '',
loading: false
}
}
},
@ -95,6 +102,47 @@ window.app = Vue.createApp({
LNbits.utils.notifyApiError(error)
}
},
async loadSettings() {
try {
const response = await LNbits.api.request(
'GET',
'/castle/api/v1/settings',
this.g.user.wallets[0].adminkey
)
this.settings = response.data
this.isAdmin = true
} catch (error) {
// Not admin or settings not available
this.isAdmin = false
}
},
showSettingsDialog() {
this.settingsDialog.castleWalletId = this.settings?.castle_wallet_id || ''
this.settingsDialog.show = true
},
async submitSettings() {
this.settingsDialog.loading = true
try {
await LNbits.api.request(
'PUT',
'/castle/api/v1/settings',
this.g.user.wallets[0].adminkey,
{
castle_wallet_id: this.settingsDialog.castleWalletId
}
)
this.$q.notify({
type: 'positive',
message: 'Settings updated successfully'
})
this.settingsDialog.show = false
await this.loadSettings()
} catch (error) {
LNbits.utils.notifyApiError(error)
} finally {
this.settingsDialog.loading = false
}
},
async submitExpense() {
this.expenseDialog.loading = true
try {
@ -188,5 +236,6 @@ window.app = Vue.createApp({
await this.loadTransactions()
await this.loadAccounts()
await this.loadCurrencies()
await this.loadSettings()
}
})