{% extends 'base.html' %} {% load static %} {% block content %}

⚙️ Settings Dashboard

Comprehensive configuration management for Open Swarm

{{ stats.total }}
Total Settings
{{ stats.configured }}
Configured
{{ stats.completion_rate }}%
Complete
Configuration Progress: {{ stats.configured }}/{{ stats.total }} settings configured
settings_groups
{% for group_id, group in settings_groups.items %}
{{ group.icon }}

{{ group.title }}

({{ group.settings|length }})
{{ group.description }}
Setting
Current Value
Environment Variable
Type
Category
{% for setting_name, setting in group.settings.items %}
{{ setting_name }}
{{ setting.description }}
{% if setting.sensitive %} 🔒 Sensitive {% endif %}
{% if setting.type == 'boolean' %} {% if setting.value %}✅ True{% else %}❌ False{% endif %} {% elif setting.type == 'list' %}
{% if setting.value %} {% for item in setting.value %} {{ item }} {% endfor %} {% else %} Empty list {% endif %}
{% elif setting.type == 'object' %}
{% elif setting.type == 'path' %}
{{ setting.value|default:"Not Set" }} {% if setting.value and setting.value != 'Not Set' %} {% endif %}
{% elif setting.type == 'error' %}
{{ setting.value }}
{% elif setting.type == 'info' %}
{{ setting.value }}
{% else %} {{ setting.value|default:"Not Set" }} {% endif %}
{% if setting.env_var %} {{ setting.env_var }} {% else %} Config file {% endif %}
{{ setting.type }}
{{ setting.category|default:"general" }}
{% endfor %}
{% endfor %}
{{ settings_groups|json_script:"swarm-settings-data" }} , <, >, & — safe even though sensitive // values are already masked server-side. Also fixes the previously-invalid JS // (a raw Python dict rendered True/None as bare identifiers). const settingsData = JSON.parse(document.getElementById("swarm-settings-data").textContent); function toggleGroup(groupId) { const content = document.getElementById(`content-${groupId}`); const header = document.querySelector(`#group-${groupId} .group-header`); content.classList.toggle('expanded'); header.classList.toggle('expanded'); } function viewObject(groupId, settingName) { const setting = settingsData[groupId].settings[settingName]; const modal = new bootstrap.Modal(document.getElementById('objectModal')); document.getElementById('objectContent').textContent = JSON.stringify(setting.value, null, 2); document.querySelector('#objectModal .modal-title').textContent = `${settingName} Configuration`; // Apply syntax highlighting if available if (window.Prism) { Prism.highlightElement(document.querySelector('#objectContent code')); } modal.show(); } function copyObjectContent() { const content = document.getElementById('objectContent').textContent; navigator.clipboard.writeText(content); showToast('Object content copied to clipboard', 'success'); } function copyEnvVar(envVar) { navigator.clipboard.writeText(envVar); showToast(`Environment variable "${envVar}" copied to clipboard`, 'success'); } function exportSettings() { const data = { timestamp: new Date().toISOString(), settings: settingsData }; const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `open-swarm-settings-${new Date().toISOString().split('T')[0]}.json`; a.click(); URL.revokeObjectURL(url); showToast('Settings exported successfully', 'success'); } function refreshSettings() { window.location.reload(); } async function viewEnvironment() { const modal = new bootstrap.Modal(document.getElementById('envModal')); const content = document.getElementById('envContent'); content.innerHTML = '
Loading environment variables...
'; modal.show(); try { const response = await fetch('/settings/environment/'); const data = await response.json(); if (data.success) { let html = `
Found ${data.count} environment variables
`; html += '
'; for (const [key, value] of Object.entries(data.environment_variables)) { html += `
${key}
${value}
`; } html += '
'; content.innerHTML = html; } else { content.innerHTML = `
Error: ${data.error}
`; } } catch (error) { content.innerHTML = `
Network error: ${error.message}
`; } } function validateConfiguration() { showToast('Configuration validation feature coming soon!', 'info'); } function checkPath(path) { showToast(`Path check feature coming soon for: ${path}`, 'info'); } function exportEnvVars() { // This would export environment variables showToast('Environment variables export feature coming soon!', 'info'); } function showToast(message, type = 'info') { // Simple toast notification const toast = document.createElement('div'); toast.className = `alert alert-${type} position-fixed`; toast.style.cssText = 'top: 20px; right: 20px; z-index: 9999; min-width: 300px;'; toast.innerHTML = ` ${message} `; document.body.appendChild(toast); setTimeout(() => { toast.remove(); }, 5000); } // Auto-expand first group on load document.addEventListener('DOMContentLoaded', function() { const firstGroup = document.querySelector('.settings-group'); if (firstGroup) { const groupId = firstGroup.id.replace('group-', ''); toggleGroup(groupId); } }); {% endblock %}