diff --git a/app/sovran_systemsos_web/static/js/features.js b/app/sovran_systemsos_web/static/js/features.js index 5e239bf..4e3c2b4 100644 --- a/app/sovran_systemsos_web/static/js/features.js +++ b/app/sovran_systemsos_web/static/js/features.js @@ -222,116 +222,59 @@ function openPortRequirementsModal(featureName, ports, onContinue) { var continueBtn = onContinue ? '' : ''; + var rows = ports.map(function(p) { + return '' + escHtml(p.port) + '' + + '' + escHtml(p.protocol) + '' + + '' + escHtml(p.description) + ''; + }).join(""); - // Show loading state while fetching port status - $portReqBody.innerHTML = - '

Checking port status for ' + escHtml(featureName) + '

' + - '

Detecting which ports are open on this machine…

'; + function renderPortRequirements(internalIp) { + var ipLine = internalIp + ? '

Forward each port below to this machine\'s internal IP: ' + escHtml(internalIp) + '

' + : "

Forward each port below to this machine's internal LAN IP in your router's port forwarding settings.

"; + + $portReqBody.innerHTML = + '

Port Forwarding Required

' + + '

For ' + escHtml(featureName) + " to work with clients outside your local network, " + + "you must configure port forwarding in your router's admin panel.

" + + ipLine + + '' + + '' + + '' + rows + '' + + '
Port(s)ProtocolPurpose
' + + "

How to verify: Router-side forwarding cannot be checked from inside your network. " + + "To confirm ports are forwarded correctly, test from a device on a different network (e.g. a phone on mobile data) " + + "or check your router's port forwarding page.

" + + '

ℹ Search "how to set up port forwarding on [your router model]" for step-by-step instructions.

' + + '
' + + '' + + continueBtn + + '
'; + + document.getElementById("port-req-dismiss-btn").addEventListener("click", function() { + closePortRequirementsModal(); + }); + + if (onContinue) { + document.getElementById("port-req-continue-btn").addEventListener("click", function() { + closePortRequirementsModal(); + onContinue(); + }); + } + } $portReqModal.classList.add("open"); + renderPortRequirements(null); - // Fetch live port status from local system commands (no external calls) - fetch("/api/ports/status", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ ports: ports }), - }) + fetch("/api/network") .then(function(r) { return r.json(); }) .then(function(data) { + if (!$portReqModal.classList.contains("open")) return; var internalIp = (data.internal_ip && data.internal_ip !== "unavailable") ? data.internal_ip : null; - var portStatuses = {}; - (data.ports || []).forEach(function(p) { - portStatuses[p.port + "/" + p.protocol] = p.status; - }); - - var rows = ports.map(function(p) { - var key = p.port + "/" + p.protocol; - var status = portStatuses[key] || "unknown"; - var statusHtml; - if (status === "listening") { - statusHtml = '🟢 Listening'; - } else if (status === "firewall_open") { - statusHtml = '🟡 Open (idle)'; - } else if (status === "closed") { - statusHtml = '🔴 Closed'; - } else { - statusHtml = '⚪ Unknown'; - } - return '' + - '' + escHtml(p.port) + '' + - '' + escHtml(p.protocol) + '' + - '' + escHtml(p.description) + '' + - '' + statusHtml + '' + - ''; - }).join(""); - - var ipLine = internalIp - ? '

Forward each port below to this machine\'s internal IP: ' + escHtml(internalIp) + '

' - : "

Forward each port below to this machine's internal LAN IP in your router's port forwarding settings.

"; - - $portReqBody.innerHTML = - '

Port Forwarding Required

' + - '

For ' + escHtml(featureName) + " to work with clients outside your local network, " + - "you must configure port forwarding in your router's admin panel.

" + - ipLine + - '' + - '' + - '' + rows + '' + - '
Port(s)ProtocolPurposeStatus
' + - "

How to verify: Router-side forwarding cannot be checked from inside your network. " + - "To confirm ports are forwarded correctly, test from a device on a different network (e.g. a phone on mobile data) " + - "or check your router's port forwarding page.

" + - '

ℹ Search "how to set up port forwarding on [your router model]" for step-by-step instructions.

' + - '
' + - '' + - continueBtn + - '
'; - - document.getElementById("port-req-dismiss-btn").addEventListener("click", function() { - closePortRequirementsModal(); - }); - - if (onContinue) { - document.getElementById("port-req-continue-btn").addEventListener("click", function() { - closePortRequirementsModal(); - onContinue(); - }); - } + renderPortRequirements(internalIp); }) - .catch(function() { - // Fallback: show static table without status column if fetch fails - var rows = ports.map(function(p) { - return '' + escHtml(p.port) + '' + - '' + escHtml(p.protocol) + '' + - '' + escHtml(p.description) + ''; - }).join(""); - - $portReqBody.innerHTML = - '

Port Forwarding Required

' + - '

For ' + escHtml(featureName) + ' to work with clients outside your local network, ' + - 'you must configure port forwarding in your router\'s admin panel and forward each port below to this machine\'s internal LAN IP.

' + - '' + - '' + - '' + rows + '' + - '
Port(s)ProtocolPurpose
' + - '

ℹ Search "how to set up port forwarding on [your router model]" for step-by-step instructions.

' + - '
' + - '' + - continueBtn + - '
'; - - document.getElementById("port-req-dismiss-btn").addEventListener("click", function() { - closePortRequirementsModal(); - }); - - if (onContinue) { - document.getElementById("port-req-continue-btn").addEventListener("click", function() { - closePortRequirementsModal(); - onContinue(); - }); - } - }); + .catch(function() {}); } function closePortRequirementsModal() {