mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
M #~: Bold external IPs (#1007)
Signed-off-by: Frederick Borges <fborges@opennebula.io>
This commit is contained in:
parent
b5555cc6d4
commit
4d3414d569
@ -401,7 +401,6 @@ define(function(require) {
|
||||
"VROUTER_IP",
|
||||
"VROUTER_IP6_GLOBAL",
|
||||
"VROUTER_IP6_ULA",
|
||||
"EXTERNAL_IP",
|
||||
];
|
||||
|
||||
var EXTERNAL_NETWORK_ATTRIBUTES = [
|
||||
@ -999,7 +998,7 @@ define(function(require) {
|
||||
}, [])
|
||||
}
|
||||
|
||||
// Return the IP or several IPs of a VM
|
||||
// Return the IP or several IPs of a VM
|
||||
function ipsStr(element, options) {
|
||||
options = $.extend({
|
||||
defaultValue: '--',
|
||||
@ -1025,91 +1024,98 @@ define(function(require) {
|
||||
}).join(options.divider) || options.defaultValue
|
||||
};
|
||||
|
||||
// Return a dropdown with all the
|
||||
// Return a dropdown with all the IPs
|
||||
function ipsDropdown(element, divider) {
|
||||
var ipsHtml = this.ipsStr(element, { divider, groupStrFunction: groupByIpsDropdown });
|
||||
var ips = ipsHtml.split("<br>");
|
||||
var html = "";
|
||||
var ipsHtml = this.ipsStr(element, { divider, groupStrFunction: groupByIpsDropdown, forceGroup: true });
|
||||
var ips = [];
|
||||
|
||||
// If its generated by groupByIpsDropdown
|
||||
if (~ipsHtml.indexOf("li")){
|
||||
ips = [];
|
||||
$.each($.parseHTML(ipsHtml), function() {
|
||||
ips.push($( this ).text());
|
||||
});
|
||||
ipsHtml = "<ul style='list-style-type:none;'>" + ipsHtml + "</ul>";
|
||||
}
|
||||
|
||||
// If it has less than "numIPs" IPs
|
||||
var numIPs = 2;
|
||||
if ((ips.length < numIPs)) return ipsHtml;
|
||||
|
||||
// Take the first x
|
||||
var insideHtml = "";
|
||||
for (let i = 0; i < numIPs-1; i++) {
|
||||
insideHtml += ips.shift();
|
||||
if (i != numIPs-2){insideHtml+="<br>";}
|
||||
}
|
||||
|
||||
// Format the other IPs inside a dropdown
|
||||
if (ips.length){
|
||||
html += "<ul class=\"dropdown menu ips-dropdown\" style=\"white-space: nowrap;text-align:left;\" data-dropdown-menu><li><a style=\"padding-top:0em;padding-bottom:0em;padding-left:0em;color:gray\">"+insideHtml+"</a><ul class=\"menu\" style=\"max-height: 50em; overflow: scroll; width:250px;\">";
|
||||
$.each(ips, function(index, value){
|
||||
html+="<li><a style=\"color:gray\">" + value + "</a></li>";
|
||||
});
|
||||
html+="</ul></li></ul>";
|
||||
}
|
||||
|
||||
return html;
|
||||
$.each($.parseHTML(ipsHtml), function() {
|
||||
ips.push($( this ).text());
|
||||
});
|
||||
var firstIP = ipsHtml.split("<end_first_ip>")[0]
|
||||
ipsHtml = ipsHtml.split("<end_first_ip>")[1]
|
||||
ipsHtml =
|
||||
"<ul class=\"dropdown menu ips-dropdown\" style=\"white-space: nowrap;text-align:left;\" data-dropdown-menu>" +
|
||||
"<li>" +
|
||||
"<a style=\"padding-top:0em;padding-bottom:0em;padding-left:0em;color:gray\">"+
|
||||
firstIP +
|
||||
"</a>" +
|
||||
"<ul class=\"menu\" style=\"max-height: 50em; overflow: scroll; width:250px;\">" +
|
||||
ipsHtml +
|
||||
"</ul>" +
|
||||
"</li>" +
|
||||
"</ul>";
|
||||
return ipsHtml;
|
||||
};
|
||||
|
||||
function groupByIpsDropdown(element = {}, nics = []) {
|
||||
// Show the first IP two times for the dropdown.
|
||||
var copy_nics = Object.assign([], nics);
|
||||
function orderNICs(nics){
|
||||
// The external IPs must be first
|
||||
var external_nics = [];
|
||||
var non_external_nics = [];
|
||||
|
||||
var first_nic = Object.assign({}, nics[0]);
|
||||
nics.forEach(function(nic){
|
||||
if (nic.EXTERNAL_IP && nic.EXTERNAL_IP.toLowerCase() === "yes")
|
||||
external_nics.push(nic);
|
||||
else
|
||||
non_external_nics.push(nic);
|
||||
});
|
||||
|
||||
return external_nics.concat(non_external_nics);
|
||||
}
|
||||
|
||||
function groupByIpsDropdown(element = {}, nics = []) {
|
||||
var all_nics = orderNICs(nics);
|
||||
|
||||
// Show the first IP two times for the dropdown.
|
||||
var copy_nics = Object.assign([], all_nics);
|
||||
|
||||
var first_nic = Object.assign({}, all_nics[0]);
|
||||
delete first_nic["EXTERNAL_IP"];
|
||||
delete first_nic["ALIAS_IDS"];
|
||||
copy_nics.unshift(first_nic);
|
||||
var first = true;
|
||||
var identation = " ";
|
||||
|
||||
return copy_nics.reduce(function(column, nic) {
|
||||
if (nic.EXTERNAL_IP && String(nic.EXTERNAL_IP).toLowerCase() !== 'yes') {
|
||||
column.append($("<li/>").append(
|
||||
$("<a/>")
|
||||
.css("color", "gray")
|
||||
.html(" " + nic.NIC_ID + ": " + nic.EXTERNAL_IP)
|
||||
))
|
||||
if (first){
|
||||
if (nic.IP || (nic.IP6_ULA && nic.IP6_GLOBAL)) {
|
||||
var ip = nic.IP || nic.IP6_ULA + " " + identation + nic.IP6_GLOBAL;
|
||||
column.append(nic.NIC_ID + ": " + ip + "<end_first_ip>");
|
||||
}
|
||||
first=false;
|
||||
}
|
||||
|
||||
if (nic.IP || (nic.IP6_ULA && nic.IP6_GLOBAL)) {
|
||||
var identation = " ";
|
||||
var ip = nic.IP || nic.IP6_ULA + " " + identation + nic.IP6_GLOBAL;
|
||||
else{
|
||||
if (nic.IP || (nic.IP6_ULA && nic.IP6_GLOBAL)) {
|
||||
var ip = nic.IP || nic.IP6_ULA + " " + identation + nic.IP6_GLOBAL;
|
||||
|
||||
var nicSection = $("<a/>").css("color", "gray").html(nic.NIC_ID + ": " + ip);
|
||||
|
||||
var nicSection = nic.NIC_ID
|
||||
? $("<li/>").append($("<a/>").css("color", "gray").html(nic.NIC_ID + ": " + ip))
|
||||
: $("<li/>").append("<li>").html("-") ;
|
||||
|
||||
column.append(nicSection)
|
||||
|
||||
if (nic.ALIAS_IDS) {
|
||||
nic.ALIAS_IDS.split(",").forEach(function(aliasId) {
|
||||
var templateAlias = Array.isArray(element.TEMPLATE.NIC_ALIAS)
|
||||
? element.TEMPLATE.NIC_ALIAS
|
||||
: [element.TEMPLATE.NIC_ALIAS];
|
||||
|
||||
var alias = templateAlias.find(function(alias) {
|
||||
return alias.NIC_ID === aliasId;
|
||||
if (nic.EXTERNAL_IP && String(nic.EXTERNAL_IP).toLowerCase() === 'yes') {
|
||||
nicSection.css("font-weight", "bold");
|
||||
}
|
||||
|
||||
column.append($("<li/>").append(nicSection));
|
||||
|
||||
if (nic.ALIAS_IDS) {
|
||||
nic.ALIAS_IDS.split(",").forEach(function(aliasId) {
|
||||
var templateAlias = Array.isArray(element.TEMPLATE.NIC_ALIAS)
|
||||
? element.TEMPLATE.NIC_ALIAS
|
||||
: [element.TEMPLATE.NIC_ALIAS];
|
||||
|
||||
var alias = templateAlias.find(function(alias) {
|
||||
return alias.NIC_ID === aliasId;
|
||||
});
|
||||
|
||||
if (alias) {
|
||||
var alias_ip = alias.IP || alias.IP6_ULA + " " + identation + "> " + alias.IP6_GLOBAL;
|
||||
|
||||
column.append($("<li/>").append($("<a/>").css({
|
||||
"color": "gray",
|
||||
"font-style": "italic",
|
||||
}).html(identation + "> " + alias_ip)));
|
||||
}
|
||||
});
|
||||
|
||||
if (alias) {
|
||||
var alias_ip = alias.IP || alias.IP6_ULA + " " + identation + "> " + alias.IP6_GLOBAL;
|
||||
|
||||
column.append($("<li/>").append($("<a/>").css({
|
||||
"color": "gray",
|
||||
"font-style": "italic",
|
||||
}).html(identation + "> " + alias_ip)));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1118,21 +1124,26 @@ define(function(require) {
|
||||
};
|
||||
|
||||
function groupByIpsStr(element = {}, nics = []) {
|
||||
|
||||
var all_nics = orderNICs(nics);
|
||||
|
||||
var identation = " ";
|
||||
|
||||
return nics.reduce(function(column, nic) {
|
||||
if (nic.EXTERNAL_IP && String(nic.EXTERNAL_IP).toLowerCase() !== 'yes') {
|
||||
column.append($("<p/>")
|
||||
.css("margin-bottom", 0)
|
||||
.html(nic.NIC_ID + ": " + nic.EXTERNAL_IP)
|
||||
)
|
||||
}
|
||||
|
||||
return all_nics.reduce(function(column, nic) {
|
||||
if (nic.IP || (nic.IP6_ULA && nic.IP6_GLOBAL)) {
|
||||
var ip = nic.IP || nic.IP6_ULA + "<br>" + identation + nic.IP6_GLOBAL
|
||||
|
||||
column.append($("<p/>").css("margin-bottom", 0).html(nic.NIC_ID + ": " + ip))
|
||||
var nicSection = $("<p/>")
|
||||
.css("color", "gray")
|
||||
.css("margin-bottom", 0)
|
||||
.html(nic.NIC_ID + ": " + ip);
|
||||
|
||||
if (nic.EXTERNAL_IP && String(nic.EXTERNAL_IP).toLowerCase() === 'yes'){
|
||||
nicSection.css("font-weight","bold");
|
||||
}
|
||||
|
||||
column.append(nicSection);
|
||||
|
||||
if (nic.ALIAS_IDS) {
|
||||
nic.ALIAS_IDS.split(",").forEach(function(aliasId) {
|
||||
var templateAlias = Array.isArray(element.TEMPLATE.NIC_ALIAS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user