luci-app-dockerman: feat(containers): Make container port mappings clickable
Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
@@ -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 `<a href="javascript:void(0);" onclick="${onclick}">${displayText}</a>`;
|
||||
}
|
||||
const urlHost = host.includes(':') ? `[${host}]` : host;
|
||||
return `<a href="http://${urlHost}:${pub}" target="_blank">${displayText}</a>`;
|
||||
}).join('<br/>')
|
||||
: '',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user