[pve-devel] [PATCH widget-toolkit] fix #2933: correct behaviour of initgpt button

Dominik Csapak d.csapak at proxmox.com
Fri Aug 14 10:33:52 CEST 2020


fixes 4 issues:
* use correct /api2/ext url to get the 'success' parameter
* check 'used' property for 'unused' (pbs vs pve)
* use 'name' instead of 'devpath' for id
  (name always contains the correct id for the product,
  e.g. /dev/sdd for pve and sdd for pbs)
* add a reload in taskDone to reload the list of disks when the inti is done

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/grid/DiskList.js | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/grid/DiskList.js b/src/grid/DiskList.js
index 03d6725..2985cc4 100644
--- a/src/grid/DiskList.js
+++ b/src/grid/DiskList.js
@@ -73,10 +73,10 @@ Ext.define('Proxmox.DiskList', {
 
 	    let rec = selection[0];
 	    Proxmox.Utils.API2Request({
-		url: `${view.baseurl}/initgpt`,
+		url: `${view.exturl}/initgpt`,
 		waitMsgTarget: view,
 		method: 'POST',
-		params: { disk: rec.data.devpath },
+		params: { disk: rec.data.name },
 		failure: function(response, options) {
 		    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
 		},
@@ -84,6 +84,9 @@ Ext.define('Proxmox.DiskList', {
 		    var upid = response.result.data;
 		    var win = Ext.create('Proxmox.window.TaskProgress', {
 		        upid: upid,
+			taskDone: function() {
+			    me.reload()
+			}
 		    });
 		    win.show();
 		},
@@ -95,6 +98,7 @@ Ext.define('Proxmox.DiskList', {
 
 	    let nodename = view.nodename || 'localhost';
 	    view.baseurl = `/api2/json/nodes/${nodename}/disks`;
+	    view.exturl = `/api2/extjs/nodes/${nodename}/disks`;
 	    view.getStore().getProxy().setUrl(`${view.baseurl}/list`);
 	    view.getStore().load();
 	},
@@ -129,7 +133,7 @@ Ext.define('Proxmox.DiskList', {
 	    text: gettext('Initialize Disk with GPT'),
 	    disabled: true,
 	    enableFn: function(rec) {
-		if (!rec || rec.data.used) {
+		if (!rec || (rec.data.used && rec.data.used !== 'unused')) {
 		    return false;
 		} else {
 		    return true;
-- 
2.20.1






More information about the pve-devel mailing list