From 63012460bca42877f0c14c2aa61fd729d5f91e1b Mon Sep 17 00:00:00 2001 From: sbwml Date: Fri, 6 Mar 2026 06:59:32 +0800 Subject: [PATCH] luci-app-dockerman: feat(containers): Make container port mappings clickable Signed-off-by: sbwml --- .../resources/view/dockerman/containers.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/luci-static/resources/view/dockerman/containers.js b/htdocs/luci-static/resources/view/dockerman/containers.js index bf380a4..424671d 100644 --- a/htdocs/luci-static/resources/view/dockerman/containers.js +++ b/htdocs/luci-static/resources/view/dockerman/containers.js @@ -344,12 +344,20 @@ return dm2.dv.extend({ Created: this.buildTimeString(cont?.Created) || '', Ports: (Array.isArray(cont.Ports) && cont.Ports.length > 0) ? cont.Ports.map(p => { - // const ip = p.IP || ''; const pub = p.PublicPort || ''; const priv = p.PrivatePort || ''; const type = p.Type || ''; - return `${pub ? pub + ':' : ''}${priv}/${type}`; - // return `${ip ? ip + ':' : ''}${pub} -> ${priv} (${type})`; + const displayText = `${pub ? pub + ':' : ''}${priv}/${type}`; + if (!pub) { + return displayText; + } + const host = p.IP; + if (!host || host === '0.0.0.0' || host === '::') { + const onclick = `window.open((window.location.origin.match(/^(.+):\\d+$/) && window.location.origin.match(/^(.+):\\d+$/)[1] || window.location.origin) + ':${pub}', '_blank')`; + return `${displayText}`; + } + const urlHost = host.includes(':') ? `[${host}]` : host; + return `${displayText}`; }).join('
') : '', });