[pve-devel] [RFC manager 1/2] NodeSelector: add disallowedNodes configuration property
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Nov 17 15:00:39 CET 2016
This can be used to mask out some nodes from the node selector.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
this will be used in the next patch
www/manager6/form/NodeSelector.js | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/www/manager6/form/NodeSelector.js b/www/manager6/form/NodeSelector.js
index 7193b97..fcdda77 100644
--- a/www/manager6/form/NodeSelector.js
+++ b/www/manager6/form/NodeSelector.js
@@ -7,6 +7,9 @@ Ext.define('PVE.form.NodeSelector', {
selectCurNode: false,
+ // do not allow those nodes (array)
+ disallowedNodes: undefined,
+
// only allow those nodes (array)
allowedNodes: undefined,
// set default value to empty array, else it inits it with
@@ -96,6 +99,29 @@ Ext.define('PVE.form.NodeSelector', {
}
me.callParent();
- me.getStore().load();
+ me.getStore().load({
+ callback: function(records) {
+ var disallowedRecords = [];
+
+ Ext.Array.each(me.disallowedNodes, function(node) {
+ var rec = me.store.findRecord(me.valueField, node);
+ if (rec) {
+ disallowedRecords.push(rec);
+ }
+ });
+
+ me.store.remove(disallowedRecords);
+
+ // ensure that there is still a valid default selection
+ var rec = me.store.first();
+ if (rec && rec.data) {
+ var def = rec.data[me.valueField];
+ me.setValue(def, true);
+ } else {
+ me.setValue('', true);
+ }
+ }
+ });
+
}
});
--
2.1.4
More information about the pve-devel
mailing list