Implement dynamic admin configuration system for NocoDB settings
All checks were successful
Build And Push Image / docker (push) Successful in 3m15s
All checks were successful
Build And Push Image / docker (push) Successful in 3m15s
- Add new admin-config utility for persistent configuration management - Replace hardcoded runtime config with dynamic configuration retrieval - Enable admin panel to save and apply NocoDB settings immediately - Add dynamic table ID resolution with fallback to defaults - Update configuration endpoints to use new persistence system
This commit is contained in:
@@ -28,17 +28,9 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
console.log('[api/admin/nocodb-config.get] Admin access confirmed for:', session.user.email);
|
||||
|
||||
// Get current runtime configuration
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
const nocodbConfig = runtimeConfig.nocodb;
|
||||
|
||||
// For security, we don't return the actual API key, just indicate if it's set
|
||||
const settings: NocoDBSettings = {
|
||||
url: nocodbConfig.url || 'https://database.monacousa.org',
|
||||
apiKey: nocodbConfig.token ? '••••••••••••••••' : '', // Masked for security
|
||||
baseId: nocodbConfig.baseId || '',
|
||||
tableId: 'members-table-id' // This would come from database in real implementation
|
||||
};
|
||||
// Get current configuration using the new admin config system
|
||||
const { getCurrentConfig } = await import('~/server/utils/admin-config');
|
||||
const settings = await getCurrentConfig();
|
||||
|
||||
console.log('[api/admin/nocodb-config.get] ✅ Settings retrieved successfully');
|
||||
|
||||
|
||||
@@ -53,21 +53,15 @@ export default defineEventHandler(async (event) => {
|
||||
console.log('[api/admin/nocodb-config.post] Table ID:', body.tableId);
|
||||
console.log('[api/admin/nocodb-config.post] API Key: [REDACTED]');
|
||||
|
||||
// In a real application, you would save these settings to a secure database
|
||||
// For now, we'll just validate the structure and log success
|
||||
|
||||
// TODO: Implement actual persistence (database or secure config store)
|
||||
// This could be saved to:
|
||||
// 1. A separate admin_settings table in the database
|
||||
// 2. Environment variable overrides
|
||||
// 3. A secure configuration service
|
||||
|
||||
// For demonstration, we'll simulate success
|
||||
// Save configuration using the new admin config system
|
||||
const { saveAdminConfig } = await import('~/server/utils/admin-config');
|
||||
await saveAdminConfig(body, session.user.email);
|
||||
|
||||
console.log('[api/admin/nocodb-config.post] ✅ Configuration saved successfully');
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'NocoDB configuration saved successfully'
|
||||
message: 'NocoDB configuration saved successfully and will be applied immediately'
|
||||
};
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
@@ -28,7 +28,7 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
console.log('[api/admin/nocodb-test.post] Admin access confirmed for:', session.user.email);
|
||||
|
||||
// Get request body
|
||||
// Get request body - this contains the settings to test
|
||||
const body = await readBody(event) as NocoDBSettings;
|
||||
|
||||
// Validate required fields
|
||||
|
||||
Reference in New Issue
Block a user