all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v4 manager 2/4] ui: storage: get content types from resources
Date: Wed, 18 Nov 2020 11:04:18 +0100	[thread overview]
Message-ID: <20201118100420.21167-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20201118100420.21167-1-f.ebner@proxmox.com>

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





  parent reply	other threads:[~2020-11-18 10:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 10:04 [pve-devel] [PATCH-SERIES v4 manager] split up content view/add prune window Fabian Ebner
2020-11-18 10:04 ` [pve-devel] [PATCH v4 manager 1/4] cluster resources: include content type for storages Fabian Ebner
2020-11-18 10:04 ` Fabian Ebner [this message]
2020-11-18 10:04 ` [pve-devel] [PATCH v4 manager 3/4] ui: make remaining content views not stateful Fabian Ebner
2020-11-18 10:04 ` [pve-devel] [PATCH v4 manager 4/4] ui: storage backup view: add prune window Fabian Ebner
2020-11-23  6:08   ` Thomas Lamprecht
2020-11-23  6:09 ` [pve-devel] partially-applied: [PATCH-SERIES v4 manager] split up content view/add " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201118100420.21167-3-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal