[PATCH] [Kimchi] Disable vm statistics/screenshots in edit guest

- 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@linux.vnet.ibm.com> --- ui/js/src/kimchi.guest_edit_main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js index 9099f39..507ae75 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.vmTimeout = window.setTimeout("kimchi.listVmsAuto();", 5000); + }); $('#guest-edit-window a[data-toggle="tab"]').on('show.bs.tab', function(tab) { tab.target; // newly activated tab -- 2.7.4

Patch works good. One suggestion below: On 07/27/2016 09:49 PM, 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@linux.vnet.ibm.com> --- ui/js/src/kimchi.guest_edit_main.js | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js index 9099f39..507ae75 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.vmTimeout = window.setTimeout("kimchi.listVmsAuto();", 5000); + });
Problem with the hardcoded '5000' here is that if someone changes the timeout in kimchi.guest_main.js there's a fair chance that it will be left with the old value here in this file. My suggestion is to create a new function like kimchi.setVmTimeout inside kimchi.guest_main.js with this statement: kimchi.vmTimeout = window.setTimeout("kimchi.listVmsAuto();", 5000); And use this function every time you need to set kimchi.vmTimeout (at this moment, 3 times in guest_main.js and now one time in guest_edit_main with your patch). If someone changes the timeout, everyone is updated with the new value. Daniel
$('#guest-edit-window a[data-toggle="tab"]').on('show.bs.tab', function(tab) { tab.target; // newly activated tab
participants (2)
-
Daniel Henrique Barboza
-
Jose Ricardo Ziviani