From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dcsapak@zita.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 531BA60BE5
 for <pve-devel@lists.proxmox.com>; Fri, 14 Aug 2020 10:34:27 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 4244320053
 for <pve-devel@lists.proxmox.com>; Fri, 14 Aug 2020 10:33:57 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id B58CD2004B
 for <pve-devel@lists.proxmox.com>; Fri, 14 Aug 2020 10:33:56 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7BD9D430C8
 for <pve-devel@lists.proxmox.com>; Fri, 14 Aug 2020 10:33:56 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri, 14 Aug 2020 10:33:52 +0200
Message-Id: <20200814083352.9557-1-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.050 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery
 methods
 NO_DNS_FOR_FROM         0.379 Envelope sender has no MX or A DNS records
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_NONE                0.001 SPF: sender does not publish an SPF Record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [data.name]
Subject: [pve-devel] [PATCH widget-toolkit] fix #2933: correct behaviour of
 initgpt button
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 14 Aug 2020 08:34:27 -0000

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@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