M #~: Fix roles table in flow service (#4746)

This commit is contained in:
Sergio Betanzos authored and GitHub committed 2020-05-18 13:20:57 +02:00
1 parent ec252e2aaf
commit c3ff6e6d45
5 files changed
+35 -81

No files matched your search

+1 -5
View File
@@ -805,11 +805,7 @@ define(function(require) {
});
}
// infoextended: alias will be group by nic
return (
config.system_config &&
config.system_config.get_extended_vm_info &&
config.system_config.get_extended_vm_info === "true"
)
return Config.isExtendedVmInfo
? groupStrFuntion(element, nics)
: (ips.length == 0 && nics && nics.length > 0)
? $.map(nics, function(nic) {
+2 -1
View File
@@ -181,7 +181,8 @@ define(function(require) {
"min":_config["user_config"]["threshold_min"],
"low":_config["user_config"]["threshold_low"],
"high":_config["user_config"]["threshold_high"]
}
},
"isExtendedVmInfo": _config["system_config"] && _config["system_config"]["get_extended_vm_info"] && _config["system_config"]["get_extended_vm_info"] === "true",
};
return Config;
@@ -86,18 +86,7 @@ define(function(require) {
}
var _actions = {
"Service.show" : {
type: "single",
call: OpenNebulaResource.show,
callback: function(request, response) {
Sunstone.runAction("VM.list")
Sunstone.getDataTable(TAB_ID).updateElement(request, response);
if (Sunstone.rightInfoVisible($('#' + TAB_ID))) {
Sunstone.insertPanels(TAB_ID, response);
}
},
error: Notifier.onError
},
"Service.show" : _commonActions.show(),
"Service.refresh" : _commonActions.refresh(),
"Service.delete" : _commonActions.del(),
"Service.chown": _commonActions.multipleAction('chown'),
@@ -90,10 +90,6 @@ define(function(require) {
function _html() {
var roleList = [];
if (!OpenNebulaAction.cache("VM")) {
Sunstone.runAction("VM.list");
}
var roles = this.element.TEMPLATE.BODY.roles;
if (roles && roles.length) {
$.each(roles, function(){
@@ -200,49 +196,25 @@ define(function(require) {
function _roleHTML(role_index) {
var that = this;
if (!OpenNebulaAction.cache("VM")) {
Sunstone.runAction("VM.list");
}
that.cache = OpenNebulaAction.cache("VM");
var role = this.element.TEMPLATE.BODY.roles[role_index];
var vms = [];
var roleVms = [];
if (role.nodes) {
$.each(role.nodes, function(){
var vm_info = this.vm_info;
$.each(role.nodes, function(index, node){
var vm_info = node.vm_info;
var info = [];
if (this.scale_up) {
info.push("<i class='fas fa-arrow-up'/>");
} else if (this.disposed) {
info.push("<i class='fas fa-arrow-down'/>");
} else {
info.push("");
}
if (!that.element.TEMPLATE.BODY.ready_status_gate) {
info.push("");
}
var id = vm_info ? vm_info.VM.ID : this.deploy_id;
var id = vm_info ? vm_info.VM.ID : node.deploy_id;
var name = vm_info ? vm_info.VM.NAME : "";
var uname = vm_info ? vm_info.VM.UNAME : "";
var gname = vm_info ? vm_info.VM.GNAME : "";
var ips = "", actions = "";
if (that.cache && that.cache.data && Array.isArray(that.cache.data)) {
$.each(that.cache.data, function(_, data){
OpenNebulaVM.show({
data : { id: id },
timeout: true,
success: function (_, data) {
if (data.VM && data.VM.ID === id) {
(that.element.TEMPLATE.BODY.ready_status_gate &&
vm_info.VM.USER_TEMPLATE &&
vm_info.VM.USER_TEMPLATE.READY &&
vm_info.VM.USER_TEMPLATE.READY == "YES")
? info.push('<span class="has-tip" title="'+Locale.tr("The VM is ready")+'"><i class="fas fa-check"/></span>')
: info.push('<span class="has-tip" title="'+Locale.tr("Waiting for the VM to be ready")+'"><i class="fas fa-clock-o"/></span>');
ips = OpenNebulaVM.ipsStr(data.VM);
if (OpenNebulaVM.isVNCSupported(data.VM)) {
@@ -253,30 +225,16 @@ define(function(require) {
}
var wFile = OpenNebulaVM.isWFileSupported(data.VM);
if (wFile) {
actions += OpenNebulaVM.buttonWFile(id, wFile);
}
actions += wFile ? OpenNebulaVM.buttonWFile(id, wFile) : "";
var rdp = OpenNebulaVM.isRDPSupported(data.VM);
if (rdp) {
actions += OpenNebulaVM.buttonRDP(rdp.IP, data.VM);
}
actions += rdp ? OpenNebulaVM.buttonRDP(rdp.IP, data.VM) : "";
}
})
}
var rowInfo = [
'<input class="check_item" style="vertical-align: inherit;" type="checkbox" '+
'id="vm_' + id + '" name="selected_items" value="' + id + '"/>',
'<a href="/#vms-tab/' + id + '">'+ id +'</a>',
name,
uname,
gname,
ips,
actions,
];
vms.push(info.concat(rowInfo))
roleVms[index] = rowInfoRoleVm(id, name, uname, gname, ips, actions);
that.serviceroleVMsDataTable.updateView(null, roleVms, true);
}
});
});
}
@@ -290,12 +248,25 @@ define(function(require) {
Locale.tr("Owner"),
Locale.tr("Group"),
Locale.tr("IPs"),
"" // VNC and RDP
"" // Remote actions
],
'vms': vms
'vms': roleVms
});
}
function rowInfoRoleVm(id, name = "", uname = "", gname = "", ips = "", actions = "") {
return [
'<input class="check_item" style="vertical-align: inherit;" type="checkbox" '+
'id="vm_' + id + '" name="selected_items" value="' + id + '"/>',
'<a href="/#vms-tab/' + id + '">'+ id +'</a>',
name,
uname,
gname,
ips,
actions
];
}
function _roleSetup(context, role_index) {
if(this.servicePanel) {
var role = this.element.TEMPLATE.BODY.roles[role_index];
@@ -311,8 +282,7 @@ define(function(require) {
"bSortClasses" : false,
"bDeferRender": true,
"aoColumnDefs": [
{"bSortable": false, "aTargets": [0,1,"check",7,8]},
{"bVisible": false, "aTargets": [0,1]}
{"bSortable": false, "aTargets": ["check", 5, 6]}
]
}
});
@@ -50,8 +50,6 @@
<table id="datatable_vms_{{panelId}}_{{role.name}}" class="dataTable hover ">
<thead>
<tr>
<th></th>
<th></th>
<th class="check">
<input type="checkbox" class="check_all" value=""></input>
</th>