Database & Migrations: - Add application_logs table migration for hybrid cloud logging - Add companies table migration and restructure vendor relationships Logging System: - Implement hybrid logging system (database + file) - Add log_service for centralized log management - Create admin logs page with filtering and viewing capabilities - Add init_log_settings.py script for log configuration - Enhance core logging with database integration Marketplace Integration: - Add marketplace admin page with product management - Create marketplace vendor page with product listings - Implement marketplace.js for both admin and vendor interfaces - Add marketplace integration documentation Admin Enhancements: - Add imports management page and functionality - Create settings page for admin configuration - Add vendor themes management page - Enhance vendor detail and edit pages - Improve code quality dashboard and violation details - Add logs viewing and management - Update icons guide and shared icon system Architecture & Documentation: - Document frontend structure and component architecture - Document models structure and relationships - Add vendor-in-token architecture documentation - Add vendor RBAC (role-based access control) documentation - Document marketplace integration patterns - Update architecture patterns documentation Infrastructure: - Add platform static files structure (css, img, js) - Move architecture_scan.py to proper models location - Update model imports and registrations - Enhance exception handling - Update dependency injection patterns UI/UX: - Improve vendor edit interface - Update admin user interface - Enhance page templates documentation - Add vendor marketplace interface
113 lines
3.7 KiB
JavaScript
113 lines
3.7 KiB
JavaScript
// static/admin/js/settings.js
|
|
|
|
const settingsLog = window.LogConfig?.loggers?.settings || console;
|
|
|
|
function adminSettings() {
|
|
// Get base data
|
|
const baseData = typeof data === 'function' ? data() : {};
|
|
|
|
return {
|
|
// Inherit base layout functionality from init-alpine.js
|
|
...baseData,
|
|
|
|
// Settings-specific state
|
|
currentPage: 'settings',
|
|
loading: true,
|
|
saving: false,
|
|
error: null,
|
|
successMessage: null,
|
|
activeTab: 'logging',
|
|
logSettings: {
|
|
log_level: 'INFO',
|
|
log_file_max_size_mb: 10,
|
|
log_file_backup_count: 5,
|
|
db_log_retention_days: 30,
|
|
file_logging_enabled: true,
|
|
db_logging_enabled: true
|
|
},
|
|
|
|
async init() {
|
|
try {
|
|
settingsLog.info('=== SETTINGS PAGE INITIALIZING ===');
|
|
await this.loadLogSettings();
|
|
} catch (error) {
|
|
console.error('[Settings] Init failed:', error);
|
|
this.error = 'Failed to initialize settings page';
|
|
}
|
|
},
|
|
|
|
async refresh() {
|
|
this.error = null;
|
|
this.successMessage = null;
|
|
await this.loadLogSettings();
|
|
},
|
|
|
|
async loadLogSettings() {
|
|
this.loading = true;
|
|
this.error = null;
|
|
|
|
try {
|
|
const data = await apiClient.get('/admin/logs/settings');
|
|
this.logSettings = data;
|
|
settingsLog.info('Log settings loaded:', this.logSettings);
|
|
} catch (error) {
|
|
settingsLog.error('Failed to load log settings:', error);
|
|
this.error = error.response?.data?.detail || 'Failed to load log settings';
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
},
|
|
|
|
async saveLogSettings() {
|
|
this.saving = true;
|
|
this.error = null;
|
|
this.successMessage = null;
|
|
|
|
try {
|
|
const data = await apiClient.put('/admin/logs/settings', this.logSettings);
|
|
this.successMessage = data.message || 'Log settings saved successfully';
|
|
|
|
// Auto-hide success message after 5 seconds
|
|
setTimeout(() => {
|
|
this.successMessage = null;
|
|
}, 5000);
|
|
|
|
settingsLog.info('Log settings saved successfully');
|
|
} catch (error) {
|
|
settingsLog.error('Failed to save log settings:', error);
|
|
this.error = error.response?.data?.detail || 'Failed to save log settings';
|
|
} finally {
|
|
this.saving = false;
|
|
}
|
|
},
|
|
|
|
async cleanupOldLogs() {
|
|
if (!confirm(`This will delete all logs older than ${this.logSettings.db_log_retention_days} days. Continue?`)) {
|
|
return;
|
|
}
|
|
|
|
this.error = null;
|
|
this.successMessage = null;
|
|
|
|
try {
|
|
const data = await apiClient.delete(
|
|
`/admin/logs/database/cleanup?retention_days=${this.logSettings.db_log_retention_days}&confirm=true`
|
|
);
|
|
this.successMessage = data.message || 'Old logs cleaned up successfully';
|
|
|
|
// Auto-hide success message after 5 seconds
|
|
setTimeout(() => {
|
|
this.successMessage = null;
|
|
}, 5000);
|
|
|
|
settingsLog.info('Old logs cleaned up successfully');
|
|
} catch (error) {
|
|
settingsLog.error('Failed to cleanup logs:', error);
|
|
this.error = error.response?.data?.detail || 'Failed to cleanup old logs';
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
settingsLog.info('Settings module loaded');
|