(logs)
| 12088 | }); |
| 12089 | } |
| 12090 | } catch (error) { |
| 12091 | console.error('Error loading config:', error); |
| 12092 | } |
| 12093 | } |
| 12094 | |
| 12095 | // ============================================================================ |
| 12096 | // SCAN INTENSITY (Light / Medium / High — controls nmap loudness) |
| 12097 | // ============================================================================ |
| 12098 | |
| 12099 | async function loadScanIntensity() { |
| 12100 | const select = document.getElementById('scan-intensity-select'); |
| 12101 | const badge = document.getElementById('scan-intensity-current'); |
| 12102 | if (!select) return; |
| 12103 | try { |
| 12104 | const data = await fetchAPI('/api/config/scan-intensity'); |
| 12105 | const current = (data && data.current) ? data.current : 'high'; |
| 12106 | select.value = current; |
| 12107 | if (badge) { |
| 12108 | const labels = { light: 'Light', medium: 'Medium', high: 'Viking Rage' }; |
| 12109 | badge.textContent = labels[current] || current; |
| 12110 | badge.className = 'text-xs px-2 py-0.5 rounded ' + ( |
| 12111 | current === 'high' ? 'bg-red-700 text-red-200' : |
| 12112 | current === 'medium' ? 'bg-yellow-700 text-yellow-200' : |
| 12113 | 'bg-green-700 text-green-200' |
| 12114 | ); |
| 12115 | } |
| 12116 | } catch (e) { |
| 12117 | console.error('Failed to load scan intensity:', e); |
| 12118 | } |
| 12119 | } |
| 12120 | |
| 12121 | async function onScanIntensityChanged(selectEl) { |
| 12122 | const value = selectEl.value; |
| 12123 | const status = document.getElementById('scan-intensity-status'); |
| 12124 | try { |
| 12125 | const res = await fetch('/api/config/scan-intensity', { |
| 12126 | method: 'POST', |
| 12127 | headers: { 'Content-Type': 'application/json' }, |
| 12128 | body: JSON.stringify({ intensity: value }) |
| 12129 | }); |
| 12130 | const data = await res.json(); |
| 12131 | if (!res.ok || data.error) throw new Error(data.error || `HTTP ${res.status}`); |
| 12132 | if (status) { |
| 12133 | status.textContent = `Saved: ${data.label}`; |
| 12134 | status.className = 'text-xs mt-2 text-green-400'; |
| 12135 | status.classList.remove('hidden'); |
| 12136 | setTimeout(() => status.classList.add('hidden'), 3000); |
| 12137 | } |
| 12138 | loadScanIntensity(); |
| 12139 | } catch (e) { |
| 12140 | console.error('Failed to set scan intensity:', e); |
| 12141 | if (status) { |
| 12142 | status.textContent = `Error: ${e.message}`; |
| 12143 | status.className = 'text-xs mt-2 text-red-400'; |
| 12144 | status.classList.remove('hidden'); |
| 12145 | } |
| 12146 | } |
| 12147 | } |
no test coverage detected