feat: separate admin view into own events and all users' events
Some checks failed
lint.yml / feat: separate admin view into own events and all users' events (pull_request) Failing after 0s
Some checks failed
lint.yml / feat: separate admin view into own events and all users' events (pull_request) Failing after 0s
Admin sees two tables: "Events" (own wallet events) and "All Users' Events" (events from other users' wallets, admin only). Non-admin users only see their own events table. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c1e66fbf7f
commit
ba97205592
2 changed files with 64 additions and 16 deletions
|
|
@ -11,7 +11,9 @@ window.app = Vue.createApp({
|
|||
data() {
|
||||
return {
|
||||
events: [],
|
||||
allUserEvents: [],
|
||||
pendingEvents: [],
|
||||
isAdmin: false,
|
||||
tickets: [],
|
||||
currencies: [],
|
||||
eventsTable: {
|
||||
|
|
@ -200,12 +202,12 @@ window.app = Vue.createApp({
|
|||
LNbits.utils.exportCSV(this.ticketsTable.columns, this.tickets)
|
||||
},
|
||||
getEvents() {
|
||||
// Try admin endpoint first (shows all events across all wallets)
|
||||
// Falls back to user's own events if not admin
|
||||
// Always fetch own events
|
||||
LNbits.api
|
||||
.request(
|
||||
'GET',
|
||||
'/events/api/v1/events/all'
|
||||
'/events/api/v1/events?all_wallets=true',
|
||||
this.g.user.wallets[0].inkey
|
||||
)
|
||||
.then(response => {
|
||||
this.events = response.data.map(obj => {
|
||||
|
|
@ -213,20 +215,24 @@ window.app = Vue.createApp({
|
|||
})
|
||||
this.checkCanceledEvents()
|
||||
})
|
||||
|
||||
// Admin: also fetch all users' events
|
||||
LNbits.api
|
||||
.request(
|
||||
'GET',
|
||||
'/events/api/v1/events/all'
|
||||
)
|
||||
.then(response => {
|
||||
this.isAdmin = true
|
||||
// Exclude own events (already in this.events)
|
||||
const ownWalletIds = this.g.user.wallets.map(w => w.id)
|
||||
this.allUserEvents = response.data
|
||||
.filter(obj => !ownWalletIds.includes(obj.wallet))
|
||||
.map(obj => mapEvents(obj))
|
||||
})
|
||||
.catch(() => {
|
||||
// Not admin, fall back to own events
|
||||
LNbits.api
|
||||
.request(
|
||||
'GET',
|
||||
'/events/api/v1/events?all_wallets=true',
|
||||
this.g.user.wallets[0].inkey
|
||||
)
|
||||
.then(response => {
|
||||
this.events = response.data.map(obj => {
|
||||
return mapEvents(obj)
|
||||
})
|
||||
this.checkCanceledEvents()
|
||||
})
|
||||
this.isAdmin = false
|
||||
this.allUserEvents = []
|
||||
})
|
||||
},
|
||||
getPendingEvents() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue