// Settings: what the hub is configured to do. Values live in the hub's .env. import { el } from '../ui.js'; import { get } from '../api.js'; import { num } from '../fmt.js'; export async function mount(root) { const intro = el('p.muted', {}, 'These come from the hub’s .env file.'); const page = el('div.page', {}, el('h1', {}, 'Settings'), intro); root.append(page); try { const [i, dns] = await Promise.all([get('/api/info'), get('/api/dns/status')]); intro.textContent = `These come from ${i.env_file} on the hub (${i.install_mode} install). Edit that file, then restart the hub to apply: ${i.install_mode === 'docker' ? 'docker restart network-monitor' : 'sudo systemctl restart network-monitor (macOS: sudo launchctl kickstart -k system/dev.neilbantoc.network-monitor)'}. Deploy new code with ${i.update_command}.`; const row = (k, v, env) => [el('dt', {}, k), el('dd', {}, v, env ? el('span.muted.small.mono', {}, ` ${env}`) : null)]; const list = (xs) => (xs.length ? xs.join(', ') : 'none'); page.append( el('h2', {}, 'AdGuard Home'), el('dl.kv', {}, ...row('Status', dns.ok ? el('span.chip.ok', {}, `Connected · ${dns.version}`) : el('span.chip.danger', {}, dns.configured ? 'Not reachable' : 'Not set up')), ...(dns.url ? row('Address', dns.url, 'ADGUARD_URL') : []), ...(dns.ok ? [] : row('Problem', dns.message))), el('h2', {}, 'Probes'), el('dl.kv', {}, ...row('Report every', `${i.probe_interval} s`, 'PROBE_INTERVAL'), ...row('LAN DNS servers', list(i.lan_dns_servers), 'LAN_DNS_SERVERS'), ...row('Public DNS servers', list(i.dns_servers), 'DNS_SERVERS'), ...row('DNS test name', i.dns_query_name, 'DNS_QUERY_NAME'), ...row('Internet HTTP checks', list(i.wan_http_urls), 'WAN_HTTP_URLS'), ...row('VPS', i.vps_url || 'none', 'VPS_URL'), ...row('Throughput test', i.throughput_every ? `${num(i.throughput_bytes / 1e6)} MB from each peer every ${i.throughput_every} reports` : 'off', 'THROUGHPUT_EVERY, THROUGHPUT_BYTES')), el('h2', {}, 'Thresholds and storage'), el('dl.kv', {}, ...row('Slow on the LAN', `over ${i.thresholds.lan_ms} ms`, 'SLOW_LAN_MS'), ...row('Slow to the internet', `over ${i.thresholds.wan_ms} ms`, 'SLOW_WAN_MS'), ...row('Slow DNS', `over ${i.thresholds.dns_ms} ms`, 'SLOW_DNS_MS'), ...row('Keep measurements', `${i.retention_days} days`, 'RETENTION_DAYS'), ...row('Password', i.password ? 'On' : 'Off: anyone on the network can open this page', 'UI_PASSWORD'), ...row('Version', i.version)), ); } catch (err) { page.append(el('div.callout.error', {}, err.message)); } }