public inbox for pve-devel@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 manager 01/14] config panel: allow new nodes to be added later
Date: Wed,  2 Sep 2020 13:03:24 +0200	[thread overview]
Message-ID: <20200902110337.25004-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20200902110337.25004-1-f.ebner@proxmox.com>

in preparation for dynamically loading nodes for content-type-specific views.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 www/manager6/panel/ConfigPanel.js | 93 +++++++++++++++++--------------
 1 file changed, 50 insertions(+), 43 deletions(-)

diff --git a/www/manager6/panel/ConfigPanel.js b/www/manager6/panel/ConfigPanel.js
index 4356c24e..fabf9108 100644
--- a/www/manager6/panel/ConfigPanel.js
+++ b/www/manager6/panel/ConfigPanel.js
@@ -227,48 +227,7 @@ Ext.define('PVE.panel.Config', {
 	    }
 	});
 	var root = me.store.getRoot();
-	me.items.forEach(function(item){
-	    var treeitem = Ext.create('Ext.data.TreeModel',{
-		id: item.itemId,
-		text: item.title,
-		iconCls: item.iconCls,
-		leaf: true,
-		expanded: item.expandedOnInit
-	    });
-	    item.header = false;
-	    if (me.savedItems[item.itemId] !== undefined) {
-		throw "itemId already exists, please use another";
-	    }
-	    me.savedItems[item.itemId] = item;
-
-	    var group;
-	    var curnode = root;
-
-	    // get/create the group items
-	    while (Ext.isArray(item.groups) && item.groups.length > 0) {
-		group = item.groups.shift();
-
-		var child = curnode.findChild('id', group);
-		if (child === null) {
-		    // did not find the group item
-		    // so add it where we are
-		    break;
-		}
-		curnode = child;
-	    }
-
-	    // insert the item
-
-	    // lets see if it already exists
-	    var node = curnode.findChild('id', item.itemId);
-
-	    if (node === null) {
-		curnode.appendChild(treeitem);
-	    } else {
-		// should not happen!
-		throw "id already exists";
-	    }
-	});
+	me.insertNodes(me.items);
 
 	delete me.items;
 	me.defaults = me.defaults || {};
@@ -310,5 +269,53 @@ Ext.define('PVE.panel.Config', {
 	if (stateid) {
 	    me.mon(me.sp, 'statechange', statechange);
 	}
-    }
+    },
+
+    insertNodes: function(items) {
+	var me = this;
+	var root = me.store.getRoot();
+
+	items.forEach(function(item) {
+	    var treeitem = Ext.create('Ext.data.TreeModel',{
+		id: item.itemId,
+		text: item.title,
+		iconCls: item.iconCls,
+		leaf: true,
+		expanded: item.expandedOnInit
+	    });
+	    item.header = false;
+	    if (me.savedItems[item.itemId] !== undefined) {
+		throw "itemId already exists, please use another";
+	    }
+	    me.savedItems[item.itemId] = item;
+
+	    var group;
+	    var curnode = root;
+
+	    // get/create the group items
+	    while (Ext.isArray(item.groups) && item.groups.length > 0) {
+		group = item.groups.shift();
+
+		var child = curnode.findChild('id', group);
+		if (child === null) {
+		    // did not find the group item
+		    // so add it where we are
+		    break;
+		}
+		curnode = child;
+	    }
+
+	    // insert the item
+
+	    // lets see if it already exists
+	    var node = curnode.findChild('id', item.itemId);
+
+	    if (node === null) {
+		curnode.appendChild(treeitem);
+	    } else {
+		// should not happen!
+		throw "id already exists";
+	    }
+	});
+    },
 });
-- 
2.20.1





  reply	other threads:[~2020-09-02 11:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 11:03 [pve-devel] [PATCH-SERIES/RFC manager 00/14] split up content view into a view for each type Fabian Ebner
2020-09-02 11:03 ` Fabian Ebner [this message]
2020-09-02 11:03 ` [pve-devel] [PATCH manager 02/14] storage panel/browser: use insertNodes function Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 03/14] use separate view for each content type Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 04/14] remove the now unneccessary grouping Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 05/14] content view: allow specifying title bar elements for init Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 06/14] turn nodename, storage, sm into object variables Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 07/14] add upload button conditionally Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 08/14] create and use template view Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 09/14] create and use backup view Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 10/14] get rid of unneccessary enableFns Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 11/14] create ImageView and use it for VM and CT images Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 12/14] simplify reload call Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [RFC manager 13/14] content view: allow specifying which columns to show on init Fabian Ebner
2020-09-02 11:03 ` [pve-devel] [PATCH manager 14/14] backup view: add prune window Fabian Ebner

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=20200902110337.25004-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal