[pve-devel] [PATCH v4 manager 2/4] ui: storage: get content types from resources

Fabian Ebner f.ebner at proxmox.com
Wed Nov 18 11:04:18 CET 2020


to avoid waiting for a status API call.

Signed-off-by: Fabian Ebner <f.ebner at 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






More information about the pve-devel mailing list