(() => { function looksLikeIdrac(node) { const blob = `${node?.name || ""} ${node?.sub_type || ""} ${node?.ip || ""}`; return !!node?.is_idrac || /idrac|bmc/i.test(blob); } function openRdpPopout(node = {}) { const rdpIps = Array.isArray(node.rdp_ips) ? node.rdp_ips.filter(Boolean) : []; const host = (node.host || node.rdp_host || rdpIps[0] || node.ip || "").trim(); if (!host && !node.allowEmpty) { alert("No RDP / OS IP resolved yet — enter the Windows OS address in the RDP popout."); } const q = new URLSearchParams({ host: host || "", name: node.name || host || "RDP session", model: node.model || "", st: node.service_tag || "", id: node.id != null ? String(node.id) : "", os_hostname: node.os_hostname || "", idrac_ip: node.idrac_ip || (looksLikeIdrac(node) ? node.ip || "" : ""), }); if (rdpIps.length) q.set("rdp_ips", rdpIps.join(",")); if (looksLikeIdrac(node) || node.is_windows) q.set("windows", "1"); const w = 780; const h = 760; const left = Math.max(0, Math.round((window.screen.width - w) / 2)); const top = Math.max(0, Math.round((window.screen.height - h) / 2)); const features = [ "popup=yes", `width=${w}`, `height=${h}`, `left=${left}`, `top=${top}`, "resizable=yes", "scrollbars=yes", ].join(","); const win = window.open(`/rdp-popout.html?${q.toString()}`, `ome-rdp-${node.id || host || "x"}`, features); if (!win) { alert("Popout blocked — allow popups for this site, or open RDP from Quick Connect again."); return null; } try { win.focus(); } catch (_) {} return win; } window.cockpitRdp = { open: openRdpPopout, looksLikeIdrac, }; })();