Add account sync button to super user toolbar

Wires the existing POST /api/v1/admin/accounts/sync endpoint into the
Castle index toolbar (sync icon between permissions and settings).
Surfaces sync stats (added/reactivated/deactivated/virtual_parents/errors)
via a Quasar notification and refreshes the accounts list on success.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-05-05 08:51:16 +02:00
commit 9c577c740c
2 changed files with 30 additions and 0 deletions

View file

@ -34,6 +34,7 @@ window.app = Vue.createApp({
settingsLoaded: false, // Flag to prevent race conditions on toolbar buttons
castleWalletConfigured: false,
userWalletConfigured: false,
syncingAccounts: false,
currentExchangeRate: null, // BTC/EUR rate (sats per EUR)
expenseDialog: {
show: false,
@ -539,6 +540,32 @@ window.app = Vue.createApp({
this.userWalletConfigured = false
}
},
async syncAccounts() {
this.syncingAccounts = true
try {
const {data} = await LNbits.api.request(
'POST',
'/castle/api/v1/admin/accounts/sync',
this.g.user.wallets[0].adminkey
)
const errors = (data?.errors || []).length
const message = `Synced: ${data?.accounts_added ?? 0} added, ` +
`${data?.accounts_reactivated ?? 0} reactivated, ` +
`${data?.accounts_deactivated ?? 0} deactivated, ` +
`${data?.virtual_parents_created ?? 0} virtual parents` +
(errors ? `, ${errors} errors` : '')
this.$q.notify({
type: errors ? 'warning' : 'positive',
message,
timeout: errors ? 8000 : 4000
})
await this.loadAccounts()
} catch (error) {
LNbits.utils.notifyApiError(error)
} finally {
this.syncingAccounts = false
}
},
showSettingsDialog() {
this.settingsDialog.castleWalletId = this.settings?.castle_wallet_id || ''
this.settingsDialog.favaUrl = this.settings?.fava_url || 'http://localhost:3333'