From 8bd0ee82c6ba64ebe5822791da1b04270d7a1625 Mon Sep 17 00:00:00 2001 From: Jorge Lobo Date: Wed, 16 Dec 2020 16:48:04 +0100 Subject: [PATCH] M #~: fix show vm list sunstone Signed-off-by: Jorge Lobo --- src/sunstone/public/app/opennebula/vm.js | 66 ++++++++++++------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index 77098b3d62..186a3138e2 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -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 || "
"; 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('
'); + var ips = ipsStr.split("
"); 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 += '"; } 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 = '    '; - var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + ' ' + identation + nic.IP6_GLOBAL; - var nicSection = $("
  • ").append($("").css("color", "gray").html(nic.NIC_ID + ": " + ip)); + identation = "    "; + var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + " " + identation + nic.IP6_GLOBAL; + var nicSection = nic.NIC_ID ? $("
  • ").append($("").css("color", "gray").html(nic.NIC_ID + ": " + ip)) : $("
  • ").append("
  • ").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 + ' ' + identation + '> ' + alias.IP6_GLOBAL; + var alias_ip = alias.IP ? alias.IP : alias.IP6_ULA + " " + identation + "> " + alias.IP6_GLOBAL; nicSection.append($("
  • ").append($("").css({ "color": "gray", "font-style": "italic", - }).html(identation + '> ' + alias_ip))) } + }).html(identation + "> " + alias_ip))); } }); } return column.append(nicSection); - }, $("
    ")).html() + }, $("
    ")).html(); }; function groupByIpsStr(element = {}, nics = []) { - identation = '    '; + identation = "    "; return nics.reduce(function(column, nic) { - var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + '
    ' + identation + nic.IP6_GLOBAL; + var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + "
    " + identation + nic.IP6_GLOBAL; var nicSection = $("

    ").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 + '
    ' + identation + '> ' + alias.IP6_GLOBAL; + var alias_ip = alias.IP ? alias.IP : alias.IP6_ULA + "
    " + identation + "> " + alias.IP6_GLOBAL; nicSection.append($("

    ").css({ "margin-bottom": 0, "font-style": "italic", - }).html(identation + '> ' + alias_ip)) } + }).html(identation + "> " + alias_ip)); } }); } return column.append(nicSection); - }, $("

    ")).html() + }, $("
    ")).html(); }; // Return the Alias or several Aliases of a VM @@ -1033,19 +1033,19 @@ define(function(require) { } function buttonVnc(id = "") { - return ''; + return ""; } function buttonSpice(id = "") { - return ''; + return ""; } function buttonWFile(id = "", data = {}) { - return ''; + return ""; } function buttonRDP(ip = "", vm = {}) { @@ -1059,10 +1059,10 @@ define(function(require) { (propUpperCase === "PASSWORD") && (password = context[prop]); } } - var button = '"; return button; }