[pve-devel] [PATCH manager v3 1/2] Hide the Edit window when we start a background task

Emmanuel Kasper e.kasper at proxmox.com
Tue Jan 3 15:39:48 CET 2017


We closed the Edit window too early, so listeners set to
the 'close' event would reload the underlying grid before the action
successfully completed on the server side.
---
 www/manager6/window/Edit.js | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/www/manager6/window/Edit.js b/www/manager6/window/Edit.js
index e61672e..0ac5120 100644
--- a/www/manager6/window/Edit.js
+++ b/www/manager6/window/Edit.js
@@ -111,14 +111,26 @@ Ext.define('PVE.window.Edit', {
 		Ext.Msg.alert(gettext('Error'), response.htmlStatus);
 	    },
 	    success: function(response, options) {
-		me.close();
-		if ((me.backgroundDelay || me.showProgress) && 
-		    response.result.data) {
+		var hasProgressBar = (me.backgroundDelay || me.showProgress) &&
+		    response.result.data ? true : false;
+
+		if (hasProgressBar) {
+		    // stay around so we can trigger our close events
+		    // when background action is completed
+		    me.hide();
+
 		    var upid = response.result.data;
 		    var win = Ext.create('PVE.window.TaskProgress', { 
-			upid: upid
+			upid: upid,
+			listeners: {
+			    destroy: function () {
+				me.close();
+			    }
+			}
 		    });
 		    win.show();
+		} else {
+		    me.close();
 		}
 	    }
 	});
-- 
2.1.4




More information about the pve-devel mailing list