]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
window/SafeDestroy: add taskDone and apiCallDone callbacks
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 4 Jun 2021 09:44:05 +0000 (11:44 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 8 Jul 2021 12:07:19 +0000 (14:07 +0200)
like in edit window, so we can reacto to a successful task/api call

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/window/SafeDestroy.js

index b269f2d642dfdc0ffa469d058579e8a96789e22b..ead0e04e019fc11c417b134a03d711e73d390589 100644 (file)
@@ -17,6 +17,14 @@ Ext.define('Proxmox.window.SafeDestroy', {
 
     additionalItems: [],
 
+    // gets called if we have a progress bar or taskview and it detected that
+    // the task finished. function(success)
+    taskDone: Ext.emptyFn,
+
+    // gets called when the api call is finished, right at the beginning
+    // function(success, response, options)
+    apiCallDone: Ext.emptyFn,
+
     config: {
        item: {
            id: undefined,
@@ -66,6 +74,7 @@ Ext.define('Proxmox.window.SafeDestroy', {
                        method: 'DELETE',
                        waitMsgTarget: view,
                        failure: function(response, opts) {
+                           view.apiCallDone(false, response, opts);
                            view.close();
                            Ext.Msg.alert('Error', response.htmlStatus);
                        },
@@ -73,6 +82,8 @@ Ext.define('Proxmox.window.SafeDestroy', {
                            const hasProgressBar = !!(view.showProgress &&
                                response.result.data);
 
+                           view.apiCallDone(true, response, options);
+
                            if (hasProgressBar) {
                                // stay around so we can trigger our close events
                                // when background action is completed
@@ -81,6 +92,7 @@ Ext.define('Proxmox.window.SafeDestroy', {
                                const upid = response.result.data;
                                const win = Ext.create('Proxmox.window.TaskProgress', {
                                    upid: upid,
+                                   taskDone: view.taskDone,
                                    listeners: {
                                        destroy: function() {
                                            view.close();