1
0
Fork 0
forked from aiolabs/libra

Adds super user and config setup

Adds super user role to restrict settings changes.

Improves the settings screen to only allow super users to make modifications.

Adds a warning banner if the Castle wallet is not configured.

Changes admin key to inkey for fetching settings.
This fixes an issue where settings weren't accessible.

Adds a validation to require the Castle wallet ID when updating settings.
This commit is contained in:
padreug 2025-10-22 14:45:18 +02:00
commit 31344607c6
3 changed files with 106 additions and 16 deletions

View file

@ -16,15 +16,37 @@
<h5 class="q-my-none">🏰 Castle Accounting</h5>
<p class="q-mb-none">Track expenses, receivables, and balances for the collective</p>
</div>
<div class="col-auto" v-if="isAdmin">
<div class="col-auto" v-if="isSuperUser">
<q-btn flat round icon="settings" @click="showSettingsDialog">
<q-tooltip>Settings</q-tooltip>
<q-tooltip>Settings (Super User Only)</q-tooltip>
</q-btn>
</div>
</div>
</q-card-section>
</q-card>
<!-- Setup Warning -->
<q-banner v-if="!castleWalletConfigured && isSuperUser" class="bg-warning text-white" rounded>
<template v-slot:avatar>
<q-icon name="warning" color="white"></q-icon>
</template>
<div>
<strong>Setup Required:</strong> Castle Wallet ID must be configured before the extension can function.
</div>
<template v-slot:action>
<q-btn flat color="white" label="Configure Now" @click="showSettingsDialog"></q-btn>
</template>
</q-banner>
<q-banner v-if="!castleWalletConfigured && !isSuperUser" class="bg-info text-white" rounded>
<template v-slot:avatar>
<q-icon name="info" color="white"></q-icon>
</template>
<div>
<strong>Setup Required:</strong> This extension requires configuration by the super user before it can be used.
</div>
</q-banner>
<!-- User Balance Card -->
<q-card>
<q-card-section>
@ -66,8 +88,15 @@
<q-card-section>
<h6 class="q-my-none q-mb-md">Quick Actions</h6>
<div class="row q-gutter-sm">
<q-btn color="primary" @click="expenseDialog.show = true">
<q-btn
color="primary"
@click="expenseDialog.show = true"
:disable="!castleWalletConfigured"
>
Add Expense
<q-tooltip v-if="!castleWalletConfigured">
Castle wallet must be configured first
</q-tooltip>
</q-btn>
<q-btn color="secondary" @click="loadTransactions">
View Transactions
@ -248,12 +277,22 @@
<q-form @submit="submitSettings" class="q-gutter-md">
<div class="text-h6 q-mb-md">Castle Settings</div>
<q-banner v-if="!isSuperUser" class="bg-warning text-dark q-mb-md" dense rounded>
<template v-slot:avatar>
<q-icon name="lock" color="orange"></q-icon>
</template>
<div class="text-caption">
<strong>Super User Only:</strong> Only the super user can modify these settings.
</div>
</q-banner>
<q-input
filled
dense
v-model.trim="settingsDialog.castleWalletId"
label="Castle Wallet ID *"
placeholder="The wallet ID that represents the Castle"
:readonly="!isSuperUser"
></q-input>
<div class="text-caption text-grey">
@ -261,10 +300,18 @@
</div>
<div class="row q-mt-lg">
<q-btn unelevated color="primary" type="submit" :loading="settingsDialog.loading">
<q-btn
v-if="isSuperUser"
unelevated
color="primary"
type="submit"
:loading="settingsDialog.loading"
>
Save Settings
</q-btn>
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Cancel</q-btn>
<q-btn v-close-popup flat color="grey" :class="isSuperUser ? 'q-ml-auto' : ''">
{% raw %}{{ isSuperUser ? 'Cancel' : 'Close' }}{% endraw %}
</q-btn>
</div>
</q-form>
</q-card>