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

M #~: Performance improvement in role dt (#4759)

This commit is contained in:
Sergio Betanzos 2020-05-19 16:01:43 +02:00 committed by GitHub
parent f9f4644b2a
commit f78313bef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -197,6 +197,7 @@ define(function(require) {
function _roleHTML(role_index) {
var that = this;
var role = this.element.TEMPLATE.BODY.roles[role_index];
var promises = [];
var roleVms = [];
if (role.nodes) {
@ -209,34 +210,37 @@ define(function(require) {
var gname = vm_info ? vm_info.VM.GNAME : "";
var ips = "", actions = "";
OpenNebulaVM.show({
data : { id: id },
timeout: true,
success: function (_, data) {
if (data.VM && data.VM.ID === id) {
ips = OpenNebulaVM.ipsStr(data.VM);
function successCallback (data) {
if (data.VM && data.VM.ID === id) {
ips = OpenNebulaVM.ipsStr(data.VM);
if (OpenNebulaVM.isVNCSupported(data.VM)) {
actions += OpenNebulaVM.buttonVnc(id);
}
else if (OpenNebulaVM.isSPICESupported(data.VM)) {
actions += OpenNebulaVM.buttonSpice(id);
}
var wFile = OpenNebulaVM.isWFileSupported(data.VM);
actions += wFile ? OpenNebulaVM.buttonWFile(id, wFile) : "";
var rdp = OpenNebulaVM.isRDPSupported(data.VM);
actions += rdp ? OpenNebulaVM.buttonRDP(rdp.IP, data.VM) : "";
if (OpenNebulaVM.isVNCSupported(data.VM)) {
actions += OpenNebulaVM.buttonVnc(id);
}
else if (OpenNebulaVM.isSPICESupported(data.VM)) {
actions += OpenNebulaVM.buttonSpice(id);
}
var wFile = OpenNebulaVM.isWFileSupported(data.VM);
actions += wFile ? OpenNebulaVM.buttonWFile(id, wFile) : "";
roleVms[index] = rowInfoRoleVm(id, name, uname, gname, ips, actions);
that.serviceroleVMsDataTable.updateView(null, roleVms, true);
var rdp = OpenNebulaVM.isRDPSupported(data.VM);
actions += rdp ? OpenNebulaVM.buttonRDP(rdp.IP, data.VM) : "";
}
});
});
roleVms[index] = rowInfoRoleVm(id, name, uname, gname, ips, actions);
}
promises.push(promiseVmInfo(id, successCallback))
})
}
$.when.apply($, promises).then(function() {
if (that.serviceroleVMsDataTable) {
that.serviceroleVMsDataTable.updateView(null, roleVms, true);
}
});
return TemplateRoleInfo({
'role': role,
@ -267,6 +271,15 @@ define(function(require) {
];
}
function promiseVmInfo(id, success) {
return $.ajax({
url: "vm/" + id,
type: "GET",
dataType: "json",
success: success
})
}
function _roleSetup(context, role_index) {
if(this.servicePanel) {
var role = this.element.TEMPLATE.BODY.roles[role_index];