[pbs-devel] [PATCH widget-toolkit 1/1] window/SafeDestroy: add taskDone and apiCallDone callbacks

Dominik Csapak d.csapak at proxmox.com
Fri Jun 4 11:44:05 CEST 2021


like in edit window, so we can reacto to a successful task/api call

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/window/SafeDestroy.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
index b269f2d..ead0e04 100644
--- a/src/window/SafeDestroy.js
+++ b/src/window/SafeDestroy.js
@@ -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();
-- 
2.20.1






More information about the pbs-devel mailing list