From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 2D2F31FF13A for ; Wed, 13 May 2026 17:15:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 21D7B153BF; Wed, 13 May 2026 17:14:55 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v2 7/9] ui: sdn: fabrics: add redistribution grid component Date: Wed, 13 May 2026 17:13:57 +0200 Message-ID: <20260513151411.383388-8-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260513151411.383388-1-s.hanreich@proxmox.com> References: <20260513151411.383388-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778685254830 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.604 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: ZI4OWQTPDKUL6RWXDZERWTJMONKTE2YZ X-Message-ID-Hash: ZI4OWQTPDKUL6RWXDZERWTJMONKTE2YZ X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This component can be used to configure the redistribution settings for fabrics that utilize FRR. Since the redistribution settings are basically the same for each protocol, except for the allowed source protocols, implement a generic component where it is possible to override the possible source protocols. Signed-off-by: Stefan Hanreich --- www/manager6/Makefile | 1 + .../sdn/fabrics/RedistributionGrid.js | 189 ++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 www/manager6/sdn/fabrics/RedistributionGrid.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 8411dea6d..b4ae1b3b5 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -338,6 +338,7 @@ JSSRC= \ sdn/fabrics/InterfacePanel.js \ sdn/fabrics/NodeEdit.js \ sdn/fabrics/FabricEdit.js \ + sdn/fabrics/RedistributionGrid.js \ sdn/fabrics/openfabric/InterfacePanel.js \ sdn/fabrics/openfabric/NodeEdit.js \ sdn/fabrics/openfabric/FabricEdit.js \ diff --git a/www/manager6/sdn/fabrics/RedistributionGrid.js b/www/manager6/sdn/fabrics/RedistributionGrid.js new file mode 100644 index 000000000..940fea00a --- /dev/null +++ b/www/manager6/sdn/fabrics/RedistributionGrid.js @@ -0,0 +1,189 @@ +Ext.define('PVE.sdn.Fabric.OspfRedistribution', { + extend: 'Ext.data.Model', + fields: ['source'], +}); + +Ext.define('PVE.sdn.Fabric.RedistributionGrid', { + alias: 'widget.pveSDNRedistributionGrid', + extend: 'Ext.grid.Panel', + mixins: ['Ext.form.field.Field'], + + config: { + sources: [], + additionalColumns: [], + }, + + store: { + model: 'PVE.sdn.Fabric.OspfRedistribution', + listeners: { + update: 'handleUpdate', + } + }, + + tbar: [ + '->', + { + text: gettext('Add'), + handler: 'addRedistribution', + } + ], + + border: false, + + columns: [], + + controller: { + xclass: 'Ext.app.ViewController', + + addRedistribution: function() { + let me = this; + + let source = me.getView().getSources()[0][0]; + + me.getView().getStore().add({ + source, + }); + + me.handleUpdate(); + }, + + deleteRedistribution: function (table, rI, cI, item, e, rec) { + let me = this; + me.getView().getStore().remove(rec); + me.handleUpdate(); + }, + + onValueChange: function (field, value) { + let me = this; + let record = field.getWidgetRecord(); + if (!record) { + return; + } + let column = field.getWidgetColumn(); + record.set(column.dataIndex, value); + record.commit(); + me.handleUpdate(); + }, + + handleUpdate: function() { + let me = this; + me.getView().checkChange(); + }, + + control: { + field: { + change: 'onValueChange', + }, + }, + }, + + initComponent: function() { + let me = this; + + if (me.getSources().length === 0) { + throw "must define at least one redistribution source!"; + } + + me.columns = [ + { + text: gettext("Source"), + xtype: 'widgetcolumn', + dataIndex: 'source', + flex: 1, + widget: { + xtype: 'proxmoxKVComboBox', + comboItems: me.getSources(), + isFormField: false, + }, + }, + { + text: gettext("Route Map"), + xtype: 'widgetcolumn', + dataIndex: 'route-map', + flex: 1, + widget: { + xtype: 'pveSDNRouteMapSelector', + isFormField: false, + }, + }, + ...me.getAdditionalColumns(), + { + text: gettext("Action"), + xtype: 'actioncolumn', + width: 100, + items: [ + { + tooltip: gettext('Delete'), + handler: 'deleteRedistribution', + iconCls: 'fa critical fa-trash-o', + }, + ], + }, + ]; + + me.callParent(); + }, + + isEqual: function(value1, value2) { + return JSON.stringify(value1) === JSON.stringify(value2); + }, + + getValue: function() { + let me = this; + + return me.getStore().getData().items.map((record) => { + let data = {}; + + for (const [key, value] of Object.entries(record.data)) { + if (value === '' || value === undefined || value === null || key === 'id') { + continue; + } + data[key] = value; + } + + return PVE.Parser.printPropertyString(data, undefined); + }); + }, + + setValue: function(value) { + let me = this; + + me.getStore().setData(value.map((item) => PVE.Parser.parsePropertyString(item))); + me.resetOriginalValue(); + }, + + getSubmitData: function () { + let me = this; + + let name = me.getName(); + let value = me.getValue(); + + if (value.length === 0 && !me.isCreate) { + return { + delete: name, + }; + } + + return { + [name]: value, + }; + }, + + getErrors: function(value) { + let me = this; + + let errors = []; + let sourceCount = {}; + + for (const record of me.getStore().getData().items) { + sourceCount[record.data.source] ??= 0; + sourceCount[record.data.source]++; + + if (sourceCount[record.data.source] === 2) { + errors.push(`Duplicate source: ${record.data.source}`); + } + } + + return errors; + } +}); -- 2.47.3