1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

M #~: fix show vm list sunstone

Signed-off-by: Jorge Lobo <jlobo@opennebula.io>
This commit is contained in:
Jorge Lobo 2020-12-16 16:48:04 +01:00 committed by Tino Vázquez
parent 4cdc45ff14
commit 8bd0ee82c6

View File

@ -789,7 +789,7 @@ define(function(require) {
}
// Return the IP or several IPs of a VM
function ipsStr(element, divider, groupStrFunction = groupByIpsStr) {
function ipsStr(element, divider, groupStrFunction) {
var divider = divider || "<br>";
var nics = getNICs(element);
var ips = [];
@ -811,14 +811,14 @@ define(function(require) {
// infoextended: alias will be group by nic
return Config.isExtendedVmInfo
? groupStrFuntion(element, nics)
? (groupStrFunction !== null && typeof groupStrFunction === "function"? groupStrFunction(element, nics) : groupByIpsStr(element, nics))
: (ips.length == 0 && nics && nics.length > 0)
? $.map(nics, function(nic) {
if (nic["IP"]) {
return nic["IP"];
}
else{
var ipv6 = ""
var ipv6 = "";
if (nic["IP6_ULA"]){
ipv6 += nic["IP6_ULA"];
}
@ -835,12 +835,12 @@ define(function(require) {
// Return a dropdown with all the
function ipsDropdown(element, divider) {
var ipsStr = this.ipsStr(element,divider,groupByIpsDropdown);
var ips = ipsStr.split('<br>');
var ips = ipsStr.split("<br>");
var html = "";
// If its generated by groupByIpsDropdown
if (~ipsStr.indexOf("li")){
ips = []
ips = [];
$.each($.parseHTML(ipsStr), function( index ) {
ips.push($( this ).text());
});
@ -860,11 +860,11 @@ define(function(require) {
// Format the other IPs inside a dropdown
if (ips.length){
html += '<ul class="dropdown menu ips-dropdown" style=" 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;">';
html += "<ul class=\"dropdown menu ips-dropdown\" style=\" 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+="<li><a style=\"color:gray\">" + value + "</a></li>";
});
html+='</ul></li></ul>';
html+="</ul></li></ul>";
}
return html;
@ -873,39 +873,39 @@ define(function(require) {
function groupByIpsDropdown(element = {}, nics = []) {
// Show the first IP two times for the dropdown.
var copy_nics = Object.assign([], nics)
var copy_nics = Object.assign([], nics);
var first_nic = Object.assign({}, nics[0]);
delete first_nic["ALIAS_IDS"];
copy_nics.unshift(first_nic);
return copy_nics.reduce(function(column, nic) {
identation = '&nbsp;&nbsp;&nbsp;&nbsp;';
var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + '&#10;&#13;' + identation + nic.IP6_GLOBAL;
var nicSection = $("<li/>").append($("<a/>").css("color", "gray").html(nic.NIC_ID + ": " + ip));
identation = "&nbsp;&nbsp;&nbsp;&nbsp;";
var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + "&#10;&#13;" + identation + nic.IP6_GLOBAL;
var nicSection = nic.NIC_ID ? $("<li/>").append($("<a/>").css("color", "gray").html(nic.NIC_ID + ": " + ip)) : $("<li/>").append("<li>").html("-") ;
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 });
var alias = templateAlias.find(function(alias) { return alias.NIC_ID === aliasId; });
if (alias) {
var alias_ip = alias.IP ? alias.IP : alias.IP6_ULA + '&#10;&#13;' + identation + '> ' + alias.IP6_GLOBAL;
var alias_ip = alias.IP ? alias.IP : alias.IP6_ULA + "&#10;&#13;" + identation + "> " + alias.IP6_GLOBAL;
nicSection.append($("<li/>").append($("<a/>").css({
"color": "gray",
"font-style": "italic",
}).html(identation + '> ' + alias_ip))) }
}).html(identation + "> " + alias_ip))); }
});
}
return column.append(nicSection);
}, $("<div/>")).html()
}, $("<div/>")).html();
};
function groupByIpsStr(element = {}, nics = []) {
identation = '&nbsp;&nbsp;&nbsp;&nbsp;';
identation = "&nbsp;&nbsp;&nbsp;&nbsp;";
return nics.reduce(function(column, nic) {
var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + '<br>' + identation + nic.IP6_GLOBAL;
var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + "<br>" + identation + nic.IP6_GLOBAL;
var nicSection = $("<p>").css("margin-bottom", 0).html(nic.NIC_ID + ": " + ip);
if (nic.ALIAS_IDS) {
@ -913,19 +913,19 @@ define(function(require) {
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 });
var alias = templateAlias.find(function(alias) { return alias.NIC_ID === aliasId; });
if (alias) {
var alias_ip = alias.IP ? alias.IP : alias.IP6_ULA + '<br>' + identation + '> ' + alias.IP6_GLOBAL;
var alias_ip = alias.IP ? alias.IP : alias.IP6_ULA + "<br>" + identation + "> " + alias.IP6_GLOBAL;
nicSection.append($("<p/>").css({
"margin-bottom": 0,
"font-style": "italic",
}).html(identation + '> ' + alias_ip)) }
}).html(identation + "> " + alias_ip)); }
});
}
return column.append(nicSection);
}, $("<div/>")).html()
}, $("<div/>")).html();
};
// Return the Alias or several Aliases of a VM
@ -1033,19 +1033,19 @@ define(function(require) {
}
function buttonVnc(id = "") {
return '<button class="vnc remote_vm" data-id="' + id + '">\
<i class="fas fa-desktop"></i></button>';
return "<button class=\"vnc remote_vm\" data-id=\"" + id + "\">\
<i class=\"fas fa-desktop\"></i></button>";
}
function buttonSpice(id = "") {
return '<button class="spice remote_vm" data-id="' + id + '">\
<i class="fas fa-desktop"></i></button>';
return "<button class=\"spice remote_vm\" data-id=\"" + id + "\">\
<i class=\"fas fa-desktop\"></i></button>";
}
function buttonWFile(id = "", data = {}) {
return '<button class="w_file remote_vm" data-id="' + id + '"\
data-type="' + data.type + '" data-port="' + data.port + '" data-hostname="' + data.hostname + '">\
<i class="fas fa-external-link-square-alt"></i></button>';
return "<button class=\"w_file remote_vm\" data-id=\"" + id + "\"\
data-type=\"" + data.type + "\" data-port=\"" + data.port + "\" data-hostname=\"" + data.hostname + "\">\
<i class=\"fas fa-external-link-square-alt\"></i></button>";
}
function buttonRDP(ip = "", vm = {}) {
@ -1059,10 +1059,10 @@ define(function(require) {
(propUpperCase === "PASSWORD") && (password = context[prop]);
}
}
var button = '<button class="rdp remote_vm" data-name="' + vm.NAME + '" data-ip="' + ip + '"';
username && (button += ' data-username="' + username + '"');
password && (button += ' data-password="' + password + '"');
button += '><i class="fab fa-windows"></i></button>';
var button = "<button class=\"rdp remote_vm\" data-name=\"" + vm.NAME + "\" data-ip=\"" + ip + "\"";
username && (button += " data-username=\"" + username + "\"");
password && (button += " data-password=\"" + password + "\"");
button += "><i class=\"fab fa-windows\"></i></button>";
return button;
}