Avoids spawning a progress window for tasks that do complete more
quickly than the background delay.

Currently, the remove task is only asynchronous (i.e. using POST) when
it's for an unused disk, but this might change in the future (e.g. for
hot-unplug).

When adding a disk, a background delay of 5 seconds is already used.

Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---
 www/manager6/qemu/HardwareView.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/www/manager6/qemu/HardwareView.js 
b/www/manager6/qemu/HardwareView.js
index 672a7e1a..6dcba071 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -486,17 +486,19 @@ Ext.define('PVE.qemu.HardwareView', {
                return msg;
            },
            handler: function(btn, e, rec) {
+               let params = { 'delete': rec.data.key };
+               if (btn.RESTMethod === 'POST') {
+                   params.background_delay = 5;
+               }
                Proxmox.Utils.API2Request({
                    url: '/api2/extjs/' + baseurl,
                    waitMsgTarget: me,
                    method: btn.RESTMethod,
-                   params: {
-                       'delete': rec.data.key,
-                   },
+                   params: params,
                    callback: () => me.reload(),
                    failure: response => Ext.Msg.alert('Error', 
response.htmlStatus),
                    success: function(response, options) {
-                       if (btn.RESTMethod === 'POST') {
+                       if (btn.RESTMethod === 'POST' && response.result.data 
!== null) {
                            Ext.create('Proxmox.window.TaskProgress', {
                                autoShow: true,
                                upid: response.result.data,
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to