diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index 8edfc0d04f..140ffea1d3 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -667,6 +667,7 @@ define(function(require) { return MIGRATE_ACTION_STR[stateId]; }, "ipsStr": ipsStr, + "ipsDropdown": ipsDropdown, "groupByIpsStr": groupByIpsStr, "aliasStr": aliasStr, "retrieveExternalIPs": retrieveExternalIPs, @@ -760,9 +761,8 @@ define(function(require) { return ips; } - // Return the IP or several IPs of a VM - function ipsStr(element, divider) { - var divider = divider || "
"; + // Return ALL NICs of a VM + function getNICs(element){ var nics = element && element.TEMPLATE && element.TEMPLATE.NIC; var pci = element && element.TEMPLATE && element.TEMPLATE.PCI; var ips = []; @@ -803,6 +803,14 @@ define(function(require) { } }); } + + return nics; + } + + // Return the IP or several IPs of a VM + function ipsStr(element, divider, groupStrFuntion = groupByIpsStr) { + var divider = divider || "
"; + var nics = getNICs(element); // infoextended: alias will be group by nic return ( @@ -810,7 +818,7 @@ define(function(require) { config.system_config.get_extended_vm_info && config.system_config.get_extended_vm_info === "true" ) - ? groupByIpsStr(element, nics) + ? groupStrFuntion(element, nics) : (ips.length == 0 && nics && nics.length > 0) ? $.map(nics, function(nic) { if (nic["IP"]) { @@ -820,6 +828,50 @@ define(function(require) { : "--"; }; + // Return a dropdown with all the + function ipsDropdown(element, divider) { + var ipsStr = this.ipsStr(element,divider,groupByIpsDropdown); + console.log(ipsStr); + + const ips = ipsStr.split('
'); + if ((ips.length < 2) && (!~ipsStr.indexOf("li"))) return ipsStr; + var html = ''; + return html; + }; + + function groupByIpsDropdown(element = {}, nics = []) { + return nics.reduce(function(column, nic) { + var nicSection = $("
  • ").append($("").css("color", "gray").text(nic.IP)); + + if (nic.ALIAS_IDS) { + nicSection.append("*"); + + 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) { + nicSection.append($("
  • ").append($("").css({ + "color": "gray", + "font-style": "italic", + }).text("> " + alias.IP))) } + }); + } + + return column.append(nicSection); + }, $("
    ")).html() + }; + function groupByIpsStr(element = {}, nics = []) { return nics.reduce(function(column, nic) { var nicSection = $("

    ").css("margin-bottom", 0).text(nic.IP) @@ -836,7 +888,7 @@ define(function(require) { nicSection.append($("

    ").css({ "margin-bottom": 0, "font-style": "italic", - }).text(alias.IP)) } + }).text("> " + alias.IP)) } }); } diff --git a/src/sunstone/public/app/tabs/vms-tab/datatable.js b/src/sunstone/public/app/tabs/vms-tab/datatable.js index 3068ecaac3..0adcad9c4f 100644 --- a/src/sunstone/public/app/tabs/vms-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vms-tab/datatable.js @@ -173,7 +173,7 @@ define(function(require) { var that = this; TabDataTable.prototype.initialize.call(this, opts); - + //download virt-viewer file $('#' + this.dataTableId).on("click", '.w_file', function(){ var data = $(this).data(); diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js index ff65445c05..b6324b73d9 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js @@ -274,7 +274,7 @@ define(function(require) { cpuMonitoring, Humanize.size(memoryMonitoring), hostname, - OpenNebulaVM.ipsStr(element), + OpenNebulaVM.ipsDropdown(element), Humanize.prettyTimeDatatable(element.STIME), actions, TemplateUtils.htmlEncode(TemplateUtils.templateToString(element)), diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index 098b5111b9..ced6d7bece 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -694,6 +694,7 @@ define(function(require) { if (that.postUpdateView) { that.postUpdateView(); + $("ul.ips-dropdown").foundation(); } if(that.conf.searchDropdownHTML != undefined){