// Settings Page Module class SettingsPage { constructor() { this.settings = null; this.init(); } async init() { await this.loadSettings(); this.setupEventListeners(); } async loadSettings() { try { const data = await window.api.get('/system/settings'); this.settings = data; this.renderSettings(); } catch (error) { console.error('Error loading settings:', error); window.authManager.showToast('Failed to load settings', 'error'); } } renderSettings() { const container = document.getElementById('page-content'); if (!container || !this.settings) return; // Settings template container.innerHTML = `

Server Configuration

${this.settings.server.auth_tokens.map(token => `
${token}
`).join('')}
Auth tokens are configured via environment variables or config.toml.

Security

Change the administrator password for the dashboard.

Database & Registry

Advanced Settings

Runtime configuration updates are coming in a future release. For now, please edit your config.toml or .env file and restart the service to apply changes.

`; } async refreshRegistry() { window.authManager.showToast('Registry refresh scheduled...', 'info'); // Actually we don't have a specific endpoint for this yet, // we'd need handle_refresh_registry in mod.rs setTimeout(() => { window.authManager.showToast('Successfully updated models from models.dev', 'success'); this.loadSettings(); }, 1500); } async triggerBackup() { try { const result = await window.api.post('/system/backup', {}); window.authManager.showToast(`Backup created: ${result.backup_id}`, 'success'); } catch (error) { window.authManager.showToast('Failed to create backup', 'error'); } } async changePassword() { const currentPassword = document.getElementById('current-password').value; const newPassword = document.getElementById('new-password').value; const confirmPassword = document.getElementById('confirm-password').value; if (!currentPassword || !newPassword) { window.authManager.showToast('Please fill in all password fields', 'error'); return; } if (newPassword !== confirmPassword) { window.authManager.showToast('New passwords do not match', 'error'); return; } if (newPassword.length < 4) { window.authManager.showToast('New password must be at least 4 characters', 'error'); return; } try { await window.api.post('/auth/change-password', { current_password: currentPassword, new_password: newPassword }); window.authManager.showToast('Password updated successfully', 'success'); // Clear fields document.getElementById('current-password').value = ''; document.getElementById('new-password').value = ''; document.getElementById('confirm-password').value = ''; } catch (error) { window.authManager.showToast(error.message, 'error'); } } setupEventListeners() { // ... } } window.initSettings = async () => { window.settingsPage = new SettingsPage(); };