Add Fava settings UI and fix race conditions in toolbar buttons
- Add Fava URL, ledger slug, and timeout settings to super admin Settings dialog - Reinitialize Fava client when settings are updated via services.py - Add settingsLoaded flag to prevent race conditions where wrong toolbar buttons appeared before isSuperUser was determined - Remove premature Vue mount() call from permissions.js that caused "Cannot read properties of undefined (reading 'user')" error 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5eb007b936
commit
cb9bc2d658
4 changed files with 83 additions and 10 deletions
|
|
@ -17,13 +17,14 @@
|
|||
<p class="q-mb-none">Track expenses, receivables, and balances for the collective</p>
|
||||
</div>
|
||||
<div class="col-auto q-gutter-xs">
|
||||
<q-btn v-if="!isSuperUser" flat round icon="account_balance_wallet" @click="showUserWalletDialog">
|
||||
<!-- Wait for settings to load before showing role-specific buttons to prevent race conditions -->
|
||||
<q-btn v-if="settingsLoaded && !isSuperUser" flat round icon="account_balance_wallet" @click="showUserWalletDialog">
|
||||
<q-tooltip>Configure Your Wallet</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn v-if="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-btn>
|
||||
<q-btn v-if="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-btn>
|
||||
</div>
|
||||
|
|
@ -32,7 +33,7 @@
|
|||
</q-card>
|
||||
|
||||
<!-- Setup Warning -->
|
||||
<q-banner v-if="!castleWalletConfigured && isSuperUser" class="bg-warning text-white" rounded>
|
||||
<q-banner v-if="settingsLoaded && !castleWalletConfigured && isSuperUser" class="bg-warning text-white" rounded>
|
||||
<template v-slot:avatar>
|
||||
<q-icon name="warning" color="white"></q-icon>
|
||||
</template>
|
||||
|
|
@ -44,7 +45,7 @@
|
|||
</template>
|
||||
</q-banner>
|
||||
|
||||
<q-banner v-if="!castleWalletConfigured && !isSuperUser" class="bg-info text-white" rounded>
|
||||
<q-banner v-if="settingsLoaded && !castleWalletConfigured && !isSuperUser" class="bg-info text-white" rounded>
|
||||
<template v-slot:avatar>
|
||||
<q-icon name="info" color="white"></q-icon>
|
||||
</template>
|
||||
|
|
@ -53,7 +54,7 @@
|
|||
</div>
|
||||
</q-banner>
|
||||
|
||||
<q-banner v-if="castleWalletConfigured && !userWalletConfigured && !isSuperUser" class="bg-orange text-white" rounded>
|
||||
<q-banner v-if="settingsLoaded && castleWalletConfigured && !userWalletConfigured && !isSuperUser" class="bg-orange text-white" rounded>
|
||||
<template v-slot:avatar>
|
||||
<q-icon name="account_balance_wallet" color="white"></q-icon>
|
||||
</template>
|
||||
|
|
@ -1122,10 +1123,46 @@
|
|||
:disable="!isSuperUser"
|
||||
></q-select>
|
||||
|
||||
<div class="text-caption text-grey">
|
||||
<div class="text-caption text-grey q-mb-md">
|
||||
Select the wallet that will be used for Castle operations and transactions.
|
||||
</div>
|
||||
|
||||
<q-separator class="q-my-md"></q-separator>
|
||||
|
||||
<div class="text-subtitle2 q-mb-sm">Fava/Beancount Integration</div>
|
||||
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model="settingsDialog.favaUrl"
|
||||
label="Fava URL *"
|
||||
hint="Base URL of the Fava server (e.g., http://localhost:3333)"
|
||||
:readonly="!isSuperUser"
|
||||
:disable="!isSuperUser"
|
||||
></q-input>
|
||||
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model="settingsDialog.favaLedgerSlug"
|
||||
label="Ledger Slug"
|
||||
hint="Ledger identifier in Fava URL (e.g., castle-ledger)"
|
||||
:readonly="!isSuperUser"
|
||||
:disable="!isSuperUser"
|
||||
></q-input>
|
||||
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
type="number"
|
||||
step="0.5"
|
||||
v-model.number="settingsDialog.favaTimeout"
|
||||
label="Timeout (seconds)"
|
||||
hint="Request timeout for Fava API calls"
|
||||
:readonly="!isSuperUser"
|
||||
:disable="!isSuperUser"
|
||||
></q-input>
|
||||
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
v-if="isSuperUser"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue