diff --git a/frontend/assets/js/app.js b/frontend/assets/js/app.js index 4c4aa17..b3279e1 100644 --- a/frontend/assets/js/app.js +++ b/frontend/assets/js/app.js @@ -32,6 +32,22 @@ let copyBuffer = null; let editingNodeId = null; let editingShapeId = null; +const DOC_TYPE_ICONS = { + deployment: { icon: 'fa-server', color: '#06b6d4' }, + attack: { icon: 'fa-bolt', color: '#ef4444' }, + 'incident-report': { icon: 'fa-exclamation-triangle', color: '#f59e0b' }, + remediation: { icon: 'fa-wrench', color: '#22c55e' }, + exercise: { icon: 'fa-dumbbell', color: '#3b82f6' } +}; + +const DOC_TYPE_LABELS = { + deployment: 'Deployment', + attack: 'Attack', + 'incident-report': 'Incident Report', + remediation: 'Remediation', + exercise: 'Exercise' +}; + // ==================== AUTH / SESSION ==================== let currentUser = null; let currentRole = null; @@ -1036,10 +1052,25 @@ function esc(s) { async function loadRegistrationSetting() { try { const res = await apiFetch('registration'); - document.getElementById('registrationToggle').checked = res.registration_enabled === true; + const toggle = document.getElementById('registrationToggle'); + if (toggle) toggle.checked = res.registration_enabled === true; } catch (e) {} } +async function saveRegistrationSetting() { + const toggle = document.getElementById('registrationToggle'); + if (!toggle) return; + const enabled = toggle.checked; + try { + await apiFetch('registration', { + method: 'POST', + body: JSON.stringify({ registration_enabled: enabled }) + }); + } catch (e) { + alert('Failed to update registration setting'); + } +} + async function loadUsers() { const list = document.getElementById('userList'); try { @@ -1090,21 +1121,6 @@ document.getElementById('settingsModal').addEventListener('show.bs.modal', () => document.getElementById('registrationToggle').addEventListener('change', saveRegistrationSetting); // ==================== DOCUMENTS ==================== -const DOC_TYPE_ICONS = { - deployment: { icon: 'fa-server', color: '#06b6d4' }, - attack: { icon: 'fa-bolt', color: '#ef4444' }, - 'incident-report': { icon: 'fa-exclamation-triangle', color: '#f59e0b' }, - remediation: { icon: 'fa-wrench', color: '#22c55e' }, - exercise: { icon: 'fa-dumbbell', color: '#3b82f6' } -}; - -const DOC_TYPE_LABELS = { - deployment: 'Deployment', - attack: 'Attack', - 'incident-report': 'Incident Report', - remediation: 'Remediation', - exercise: 'Exercise' -}; async function loadDocuments() { try {