forked from aiolabs/libra
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:
parent
9a1893c546
commit
9c577c740c
2 changed files with 30 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ window.app = Vue.createApp({
|
||||||
settingsLoaded: false, // Flag to prevent race conditions on toolbar buttons
|
settingsLoaded: false, // Flag to prevent race conditions on toolbar buttons
|
||||||
castleWalletConfigured: false,
|
castleWalletConfigured: false,
|
||||||
userWalletConfigured: false,
|
userWalletConfigured: false,
|
||||||
|
syncingAccounts: false,
|
||||||
currentExchangeRate: null, // BTC/EUR rate (sats per EUR)
|
currentExchangeRate: null, // BTC/EUR rate (sats per EUR)
|
||||||
expenseDialog: {
|
expenseDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
|
|
@ -539,6 +540,32 @@ window.app = Vue.createApp({
|
||||||
this.userWalletConfigured = false
|
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() {
|
showSettingsDialog() {
|
||||||
this.settingsDialog.castleWalletId = this.settings?.castle_wallet_id || ''
|
this.settingsDialog.castleWalletId = this.settings?.castle_wallet_id || ''
|
||||||
this.settingsDialog.favaUrl = this.settings?.fava_url || 'http://localhost:3333'
|
this.settingsDialog.favaUrl = this.settings?.fava_url || 'http://localhost:3333'
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@
|
||||||
<q-btn v-if="settingsLoaded && isSuperUser" flat round icon="admin_panel_settings" :href="'/castle/permissions'">
|
<q-btn v-if="settingsLoaded && isSuperUser" flat round icon="admin_panel_settings" :href="'/castle/permissions'">
|
||||||
<q-tooltip>Manage Permissions (Admin)</q-tooltip>
|
<q-tooltip>Manage Permissions (Admin)</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
|
<q-btn v-if="settingsLoaded && isSuperUser" flat round icon="sync" :loading="syncingAccounts" @click="syncAccounts">
|
||||||
|
<q-tooltip>Sync Accounts from Beancount</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
<q-btn v-if="settingsLoaded && isSuperUser" flat round icon="settings" @click="showSettingsDialog">
|
<q-btn v-if="settingsLoaded && isSuperUser" flat round icon="settings" @click="showSettingsDialog">
|
||||||
<q-tooltip>Castle Settings (Super User Only)</q-tooltip>
|
<q-tooltip>Castle Settings (Super User Only)</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue