Applied to master. Thanks!
On 07/28/2016 10:40 AM, Jose Ricardo Ziviani wrote:
- When Edit Guest modal window is opened, Kimchi continues to make
requests to get all VM' statistics and screenshots, that affects
necessary and heavy requests like PCI queries. This commit
disable those poolings when the modal window is opened and
re-enable when the modal is closed.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
v2:
- wrapped the setTimeout in a function to avoid duplication of
hardcoded magic numbers
ui/js/src/kimchi.guest_edit_main.js | 5 +++++
ui/js/src/kimchi.guest_main.js | 11 +++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index 9099f39..c4f39c4 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -20,6 +20,11 @@ kimchi.guest_edit_main = function() {
var formTargetId;
var guestEditForm = $('#form-guest-edit-general');
var saveButton = $('#guest-edit-button-save');
+ clearTimeout(kimchi.vmTimeout);
+
+ $('#modalWindow').on('hidden.bs.modal', function() {
+ kimchi.setListVMAutoTimeout();
+ });
$('#guest-edit-window
a[data-toggle="tab"]').on('show.bs.tab', function(tab) {
tab.target; // newly activated tab
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index ab26fa4..9c1aa54 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -900,8 +900,7 @@ kimchi.listVmsAuto = function() {
$('#guests-root-container > .wok-mask').fadeOut(300,
function() {});
}
}
-
- kimchi.vmTimeout = window.setTimeout("kimchi.listVmsAuto();",
5000);
+ kimchi.setListVMAutoTimeout();
},
function(errorResponse, textStatus, errorThrown) {
if (errorResponse.responseJSON &&
errorResponse.responseJSON.reason) {
@@ -910,11 +909,11 @@ kimchi.listVmsAuto = function() {
$('#guests-root-container >
.wok-mask').addClass('hidden');
});
}
- kimchi.vmTimeout = window.setTimeout("kimchi.listVmsAuto();",
5000);
+ kimchi.setListVMAutoTimeout();
});
} else {
clearTimeout(kimchi.vmTimeout);
- kimchi.vmTimeout = window.setTimeout("kimchi.listVmsAuto();", 5000);
+ kimchi.setListVMAutoTimeout();
}
};
@@ -924,3 +923,7 @@ kimchi.editTemplate = function(guestTemplate, oldPopStat) {
}
return guestTemplate;
};
+
+kimchi.setListVMAutoTimeout = function() {
+ kimchi.vmTimeout = window.setTimeout("kimchi.listVmsAuto();", 5000);
+}