Enhances user balance display with username
Improves the display of user balances in the admin panel by including the username alongside the user ID. This provides a more user-friendly and easily identifiable representation of user data. The username is fetched from the user table, and if no username is set the first 16 characters of the user id is shown.
This commit is contained in:
parent
224d520d84
commit
d302023477
2 changed files with 23 additions and 4 deletions
|
|
@ -122,7 +122,7 @@
|
|||
flat
|
||||
:rows="allUserBalances"
|
||||
:columns="[
|
||||
{name: 'user', label: 'User ID', field: 'user_id', align: 'left'},
|
||||
{name: 'user', label: 'User', field: 'username', align: 'left'},
|
||||
{name: 'balance', label: 'Amount Owed', field: 'balance', align: 'right'}
|
||||
]"
|
||||
row-key="user_id"
|
||||
|
|
@ -131,7 +131,8 @@
|
|||
>
|
||||
<template v-slot:body-cell-user="props">
|
||||
<q-td :props="props">
|
||||
<div class="text-caption">{% raw %}{{ props.row.user_id.substring(0, 16) }}...{% endraw %}</div>
|
||||
<div>{% raw %}{{ props.row.username }}{% endraw %}</div>
|
||||
<div class="text-caption text-grey">{% raw %}{{ props.row.user_id.substring(0, 16) }}...{% endraw %}</div>
|
||||
</q-td>
|
||||
</template>
|
||||
<template v-slot:body-cell-balance="props">
|
||||
|
|
|
|||
22
views_api.py
22
views_api.py
|
|
@ -472,9 +472,27 @@ async def api_get_user_balance(user_id: str) -> UserBalance:
|
|||
@castle_api_router.get("/api/v1/balances/all")
|
||||
async def api_get_all_balances(
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
) -> list[UserBalance]:
|
||||
) -> list[dict]:
|
||||
"""Get all user balances (admin/super user only)"""
|
||||
return await get_all_user_balances()
|
||||
from lnbits.core.crud.users import get_user
|
||||
|
||||
balances = await get_all_user_balances()
|
||||
|
||||
# Enrich with username information
|
||||
result = []
|
||||
for balance in balances:
|
||||
user = await get_user(balance.user_id)
|
||||
username = user.username if user and user.username else balance.user_id[:16] + "..."
|
||||
|
||||
result.append({
|
||||
"user_id": balance.user_id,
|
||||
"username": username,
|
||||
"balance": balance.balance,
|
||||
"fiat_balances": balance.fiat_balances,
|
||||
"accounts": [acc.dict() for acc in balance.accounts],
|
||||
})
|
||||
|
||||
return result
|
||||
|
||||
|
||||
# ===== PAYMENT ENDPOINTS =====
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue