feat(admin): Owner column on All Users' Events card
Some checks failed
lint.yml / feat(admin): Owner column on All Users' Events card (pull_request) Failing after 0s
Some checks failed
lint.yml / feat(admin): Owner column on All Users' Events card (pull_request) Failing after 0s
Adds the event's wallet owner (user_id) as the first column of the admin-only All Users' Events table so cross-tenant rows are attributable at a glance. Server-side join: GET /events/all now resolves each event.wallet -> wallet.user and stamps the result on the response as wallet_user_id. Frontend gets a dedicated allUsersEventsTable.columns definition so the user's own-events table stays unchanged. Follow-up #22 covers letting the admin actually edit those events once attributed.
This commit is contained in:
parent
66d263ef14
commit
3606fd9a0a
3 changed files with 62 additions and 4 deletions
|
|
@ -14,6 +14,51 @@ window.PageEvents = {
|
|||
settings: {
|
||||
auto_approve: false
|
||||
},
|
||||
allUsersEventsTable: {
|
||||
// Shown on the admin All Users' Events card. Includes the
|
||||
// wallet owner (`wallet_user_id` resolved server-side) so
|
||||
// cross-tenant rows are attributable to a user.
|
||||
columns: [
|
||||
{
|
||||
name: 'wallet_user_id',
|
||||
align: 'left',
|
||||
label: 'Owner',
|
||||
field: 'wallet_user_id'
|
||||
},
|
||||
{name: 'id', align: 'left', label: 'ID', field: 'id'},
|
||||
{name: 'name', align: 'left', label: 'Name', field: 'name'},
|
||||
{
|
||||
name: 'event_start_date',
|
||||
align: 'left',
|
||||
label: 'Start date',
|
||||
field: 'event_start_date'
|
||||
},
|
||||
{
|
||||
name: 'event_end_date',
|
||||
align: 'left',
|
||||
label: 'End date',
|
||||
field: 'event_end_date'
|
||||
},
|
||||
{
|
||||
name: 'closing_date',
|
||||
align: 'left',
|
||||
label: 'Ticket close',
|
||||
field: 'closing_date'
|
||||
},
|
||||
{
|
||||
name: 'canceled',
|
||||
align: 'left',
|
||||
label: 'Canceled',
|
||||
field: row => {
|
||||
if (row.extra && row.extra.conditional && row.canceled) {
|
||||
return 'Yes'
|
||||
}
|
||||
return 'No'
|
||||
}
|
||||
},
|
||||
{name: 'status', align: 'left', label: 'Status', field: 'status'}
|
||||
]
|
||||
},
|
||||
eventsTable: {
|
||||
columns: [
|
||||
{name: 'id', align: 'left', label: 'ID', field: 'id'},
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@
|
|||
flat
|
||||
:rows="allUserEvents"
|
||||
row-key="id"
|
||||
:columns="eventsTable.columns"
|
||||
:columns="allUsersEventsTable.columns"
|
||||
:pagination="{rowsPerPage: 10}"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
|
|
|
|||
19
views_api.py
19
views_api.py
|
|
@ -101,9 +101,22 @@ async def api_events_public() -> list[Event]:
|
|||
@events_api_router.get("/all")
|
||||
async def api_events_all(
|
||||
admin: Account = Depends(check_admin),
|
||||
) -> list[Event]:
|
||||
"""All events across all wallets. LNbits admin only."""
|
||||
return await get_all_events()
|
||||
) -> list[dict]:
|
||||
"""All events across all wallets, with each row's wallet owner
|
||||
resolved to a user_id. LNbits admin only.
|
||||
|
||||
Returns dicts (not strict `Event` rows) so the response can carry
|
||||
the synthetic `wallet_user_id` column the admin UI uses to attribute
|
||||
each cross-tenant event to a user.
|
||||
"""
|
||||
events = await get_all_events()
|
||||
enriched: list[dict] = []
|
||||
for event in events:
|
||||
wallet = await get_wallet(event.wallet)
|
||||
row = event.dict()
|
||||
row["wallet_user_id"] = wallet.user if wallet else None
|
||||
enriched.append(row)
|
||||
return enriched
|
||||
|
||||
|
||||
@events_api_router.get("/pending")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue