Adds super user balance overview

Implements functionality for super users to view a breakdown of outstanding balances for all users.

This includes:
- Adding an API endpoint to fetch all user balances.
- Updating the frontend to display these balances in a table, accessible only to super users.
- Modifying the balance calculation for the current user to reflect the total owed by or to the castle for super users.

This provides super users with a comprehensive view of the castle's financial position.
This commit is contained in:
padreug 2025-10-22 15:24:50 +02:00
parent cb7e4ee555
commit b7e4e05469
4 changed files with 117 additions and 4 deletions

View file

@ -8,6 +8,7 @@ window.app = Vue.createApp({
data() {
return {
balance: null,
allUserBalances: [],
transactions: [],
accounts: [],
currencies: [],
@ -71,10 +72,27 @@ window.app = Vue.createApp({
this.g.user.wallets[0].inkey
)
this.balance = response.data
// If super user, also load all user balances
if (this.isSuperUser) {
await this.loadAllUserBalances()
}
} catch (error) {
LNbits.utils.notifyApiError(error)
}
},
async loadAllUserBalances() {
try {
const response = await LNbits.api.request(
'GET',
'/castle/api/v1/balances/all',
this.g.user.wallets[0].adminkey
)
this.allUserBalances = response.data
} catch (error) {
console.error('Error loading all user balances:', error)
}
},
async loadTransactions() {
try {
const response = await LNbits.api.request(