From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@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 DEAA260ABE
 for <pve-devel@lists.proxmox.com>; Wed, 18 Nov 2020 11:04:26 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id DCBD619B5E
 for <pve-devel@lists.proxmox.com>; Wed, 18 Nov 2020 11:04:26 +0100 (CET)
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 B05A519B49
 for <pve-devel@lists.proxmox.com>; Wed, 18 Nov 2020 11:04:25 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 79E3243958
 for <pve-devel@lists.proxmox.com>; Wed, 18 Nov 2020 11:04:25 +0100 (CET)
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Wed, 18 Nov 2020 11:04:18 +0100
Message-Id: <20201118100420.21167-3-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201118100420.21167-1-f.ebner@proxmox.com>
References: <20201118100420.21167-1-f.ebner@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.010 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 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_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH v4 manager 2/4] ui: storage: get content types
 from resources
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: Wed, 18 Nov 2020 10:04:26 -0000

to avoid waiting for a status API call.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

New in v4

Commit ed5d5403508a4713fd8a6c720ceaf11562352415 (introducing the insertNodes
function) could be reverted after this.

 www/manager6/storage/Browser.js | 144 +++++++++++++++-----------------
 1 file changed, 68 insertions(+), 76 deletions(-)

diff --git a/www/manager6/storage/Browser.js b/www/manager6/storage/Browser.js
index 81387111..64c492d8 100644
--- a/www/manager6/storage/Browser.js
+++ b/www/manager6/storage/Browser.js
@@ -38,89 +38,81 @@ Ext.define('PVE.storage.Browser', {
 	    hstateid: 'storagetab'
 	});
 
-	// call here, so there is a root for insertNodes()
-	me.callParent();
-
 	if (caps.storage['Datastore.Allocate'] ||
 	    caps.storage['Datastore.AllocateSpace'] ||
 	    caps.storage['Datastore.Audit']) {
+	    let storageInfo = PVE.data.ResourceStore.findRecord(
+		'id',
+		`storage/${nodename}/${storeid}`,
+	    );
+	    let contents = storageInfo.data.content.split(',');
 
-	    Proxmox.Utils.API2Request({
-		url: `/nodes/${nodename}/storage/${storeid}/status`,
-		method: 'GET',
-		success: function(response, opts) {
-		    var contents = response.result.data.content.split(',');
-		    var items = [];
-
-		    if (contents.includes('backup')) {
-			items.push({
-			    xtype: 'pveStorageBackupView',
-			    title: gettext('Backups'),
-			    iconCls: 'fa fa-floppy-o',
-			    itemId: 'contentBackup',
-			    hasCommentColumn: true,
-			});
-		    }
-		    if (contents.includes('images')) {
-			items.push({
-			    xtype: 'pveStorageImageView',
-			    title: gettext('VM Disks'),
-			    iconCls: 'fa fa-hdd-o',
-			    itemId: 'contentImages',
-			    content: 'images',
-			});
-		    }
-		    if (contents.includes('rootdir')) {
-			items.push({
-			    xtype: 'pveStorageImageView',
-			    title: gettext('CT Volumes'),
-			    iconCls: 'fa fa-hdd-o lxc',
-			    itemId: 'contentRootdir',
-			    content: 'rootdir',
-			});
-		    }
-		    if (contents.includes('iso')) {
-			items.push({
-			    xtype: 'pveStorageContentView',
-			    title: gettext('ISO Images'),
-			    iconCls: 'pve-itype-treelist-item-icon-cdrom',
-			    itemId: 'contentIso',
-			    content: 'iso',
-			    useUploadButton: true,
-			});
-		    }
-		    if (contents.includes('vztmpl')) {
-			items.push({
-			    xtype: 'pveStorageTemplateView',
-			    title: gettext('CT Templates'),
-			    iconCls: 'fa fa-file-o lxc',
-			    itemId: 'contentVztmpl',
-			});
-		    }
-		    if (contents.includes('snippets')) {
-			items.push({
-			    xtype: 'pveStorageContentView',
-			    title: gettext('Snippets'),
-			    iconCls: 'fa fa-file-code-o',
-			    itemId: 'contentSnippets',
-			    content: 'snippets',
-			});
-		    }
-		    me.insertNodes(items);
-		},
-	    });
+	    if (contents.includes('backup')) {
+		me.items.push({
+		    xtype: 'pveStorageBackupView',
+		    title: gettext('Backups'),
+		    iconCls: 'fa fa-floppy-o',
+		    itemId: 'contentBackup',
+		    hasCommentColumn: true,
+		});
+	    }
+	    if (contents.includes('images')) {
+		me.items.push({
+		    xtype: 'pveStorageImageView',
+		    title: gettext('VM Disks'),
+		    iconCls: 'fa fa-hdd-o',
+		    itemId: 'contentImages',
+		    content: 'images',
+		});
+	    }
+	    if (contents.includes('rootdir')) {
+		me.items.push({
+		    xtype: 'pveStorageImageView',
+		    title: gettext('CT Volumes'),
+		    iconCls: 'fa fa-hdd-o lxc',
+		    itemId: 'contentRootdir',
+		    content: 'rootdir',
+		});
+	    }
+	    if (contents.includes('iso')) {
+		me.items.push({
+		    xtype: 'pveStorageContentView',
+		    title: gettext('ISO Images'),
+		    iconCls: 'pve-itype-treelist-item-icon-cdrom',
+		    itemId: 'contentIso',
+		    content: 'iso',
+		    useUploadButton: true,
+		});
+	    }
+	    if (contents.includes('vztmpl')) {
+		me.items.push({
+		    xtype: 'pveStorageTemplateView',
+		    title: gettext('CT Templates'),
+		    iconCls: 'fa fa-file-o lxc',
+		    itemId: 'contentVztmpl',
+		});
+	    }
+	    if (contents.includes('snippets')) {
+		me.items.push({
+		    xtype: 'pveStorageContentView',
+		    title: gettext('Snippets'),
+		    iconCls: 'fa fa-file-code-o',
+		    itemId: 'contentSnippets',
+		    content: 'snippets',
+		});
+	    }
 	}
 
 	if (caps.storage['Permissions.Modify']) {
-	    me.insertNodes([
-		{
-		    xtype: 'pveACLView',
-		    title: gettext('Permissions'),
-		    iconCls: 'fa fa-unlock',
-		    itemId: 'permissions',
-		    path: '/storage/' + storeid
-		},
-	    ]);
+	    me.items.push({
+		xtype: 'pveACLView',
+		title: gettext('Permissions'),
+		iconCls: 'fa fa-unlock',
+		itemId: 'permissions',
+		path: '/storage/' + storeid
+	    });
 	}
+
+	me.callParent();
    }
 });
-- 
2.20.1