mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-07-20 10:11:54 +00:00

by converting the relevant selection boxes to combogrids. This is done to reduce confusion for how/why to select a node, and doing it this way it is moved closer to the selection of the actual value we want. It still restricts the nodes when selecting a specific one. Show it only when there is more than one node according to the in-memory PVE.data.ResourceStore info, as for single-node setups there isn't any other node one could scan anyway. Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
Ext.define('PVE.form.ComboBoxSetStoreNode', {
|
|
extend: 'Proxmox.form.ComboGrid',
|
|
config: {
|
|
apiBaseUrl: '/api2/json/nodes/',
|
|
apiSuffix: '',
|
|
},
|
|
|
|
showNodeSelector: false,
|
|
|
|
setNodeName: function(value) {
|
|
let me = this;
|
|
value ||= Proxmox.NodeName;
|
|
|
|
me.getStore().getProxy().setUrl(`${me.apiBaseUrl}${value}${me.apiSuffix}`);
|
|
me.clearValue();
|
|
},
|
|
|
|
nodeChange: function(_field, value) {
|
|
let me = this;
|
|
// disable autoSelect if there is already a selection or we have the picker open
|
|
if (me.getValue() || me.isExpanded) {
|
|
let autoSelect = me.autoSelect;
|
|
me.autoSelect = false;
|
|
me.store.on('afterload', function() {
|
|
me.autoSelect = autoSelect;
|
|
}, { single: true });
|
|
}
|
|
me.setNodeName(value);
|
|
me.fireEvent('nodechanged', value);
|
|
},
|
|
|
|
initComponent: function() {
|
|
let me = this;
|
|
|
|
if (me.showNodeSelector && PVE.data.ResourceStore.getNodes().length > 1) {
|
|
me.errorHeight = 140;
|
|
Ext.apply(me.listConfig ?? {}, {
|
|
tbar: {
|
|
xtype: 'toolbar',
|
|
items: [
|
|
{
|
|
xtype: "pveStorageScanNodeSelector",
|
|
autoSelect: false,
|
|
fieldLabel: gettext('Node to scan'),
|
|
listeners: {
|
|
change: (field, value) => me.nodeChange(field, value),
|
|
},
|
|
},
|
|
],
|
|
},
|
|
emptyText: me.listConfig?.emptyText ?? gettext('Nothing found'),
|
|
});
|
|
}
|
|
|
|
me.callParent();
|
|
},
|
|
});
|