From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C1F2E64972 for ; Mon, 20 Jul 2020 18:02:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B560D1050D for ; Mon, 20 Jul 2020 18:01:32 +0200 (CEST) Received: from mailpro.odiso.net (mailpro.odiso.net [89.248.211.110]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 73C15104E7 for ; Mon, 20 Jul 2020 18:01:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mailpro.odiso.net (Postfix) with ESMTP id 541161C4C09B; Mon, 20 Jul 2020 18:01:30 +0200 (CEST) Received: from mailpro.odiso.net ([127.0.0.1]) by localhost (mailpro.odiso.net [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id IVJdQfit8-bT; Mon, 20 Jul 2020 18:01:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mailpro.odiso.net (Postfix) with ESMTP id 3B4A01C4C079; Mon, 20 Jul 2020 18:01:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at mailpro.odiso.com Received: from mailpro.odiso.net ([127.0.0.1]) by localhost (mailpro.odiso.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lZWbzJeWfP4y; Mon, 20 Jul 2020 18:01:30 +0200 (CEST) Received: from pve.fritz.box (unknown [213.211.148.86]) by mailpro.odiso.net (Postfix) with ESMTPSA id 079ED1C4C17D; Mon, 20 Jul 2020 18:01:30 +0200 (CEST) From: Alexandre Derumier To: pve-devel@pve.proxmox.com Date: Mon, 20 Jul 2020 18:01:18 +0200 Message-Id: <20200720160121.7180-3-aderumier@odiso.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200720160121.7180-1-aderumier@odiso.com> References: <20200720160121.7180-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v3 pve-manager 2/5] add sdn subnets X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jul 2020 16:02:02 -0000 Signed-off-by: Alexandre Derumier --- www/manager6/Makefile | 2 + www/manager6/dc/Config.js | 8 +++ www/manager6/sdn/SubnetEdit.js | 95 +++++++++++++++++++++++++++++ www/manager6/sdn/SubnetView.js | 107 +++++++++++++++++++++++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 www/manager6/sdn/SubnetEdit.js create mode 100644 www/manager6/sdn/SubnetView.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index a5e908bb..48924674 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -207,6 +207,8 @@ JSSRC=3D \ sdn/StatusView.js \ sdn/VnetEdit.js \ sdn/VnetView.js \ + sdn/SubnetEdit.js \ + sdn/SubnetView.js \ sdn/ZoneContentView.js \ sdn/ZoneView.js \ sdn/controllers/Base.js \ diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js index 905c3dc0..610b38db 100644 --- a/www/manager6/dc/Config.js +++ b/www/manager6/dc/Config.js @@ -176,6 +176,14 @@ Ext.define('PVE.dc.Config', { hidden: true, iconCls: 'fa fa-network-wired', itemId: 'sdnvnet' + }, + { + xtype: 'pveSDNSubnetView', + groups: ['sdn'], + title: gettext('Subnets'), + hidden: true, + iconCls: 'fa fa-network-wired', + itemId: 'sdnsubnet' }); } =20 diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit= .js new file mode 100644 index 00000000..e165ff73 --- /dev/null +++ b/www/manager6/sdn/SubnetEdit.js @@ -0,0 +1,95 @@ +Ext.define('PVE.sdn.SubnetInputPanel', { + extend: 'Proxmox.panel.InputPanel', + mixins: ['Proxmox.Mixin.CBind'], + + onGetValues: function(values) { + let me =3D this; + + if (me.isCreate) { + values.type =3D 'subnet'; + values.subnet =3D values.cidr; + delete values.cidr; + } + + if (!values.gateway) { + delete values.gateway; + } + if (!values.snat) { + delete values.snat; + } + + return values; + }, + + items: [ + { + xtype: 'pmxDisplayEditField', + name: 'cidr', + cbind: { + editable: '{isCreate}', + }, + flex: 1, + allowBlank: false, + fieldLabel: gettext('Subnet'), + }, + { + xtype: 'textfield', + name: 'gateway', + vtype: 'IP64Address', + fieldLabel: gettext('Gateway'), + allowBlank: true, + }, + { + xtype: 'proxmoxcheckbox', + name: 'snat', + uncheckedValue: 0, + checked: false, + fieldLabel: 'SNAT' + }, + ] +}); + +Ext.define('PVE.sdn.SubnetEdit', { + extend: 'Proxmox.window.Edit', + + subject: gettext('Subnet'), + + subnet: undefined, + + width: 350, + + initComponent: function() { + var me =3D this; + + me.isCreate =3D me.subnet =3D=3D=3D undefined; + + if (me.isCreate) { + me.url =3D '/api2/extjs/cluster/sdn/subnets'; + me.method =3D 'POST'; + } else { + me.url =3D '/api2/extjs/cluster/sdn/subnets/' + me.subnet; + me.method =3D 'PUT'; + } + + let ipanel =3D Ext.create('PVE.sdn.SubnetInputPanel', { + isCreate: me.isCreate, + }); + + Ext.apply(me, { + items: [ + ipanel, + ], + }); + + me.callParent(); + + if (!me.isCreate) { + me.load({ + success: function(response, options) { + let values =3D response.result.data; + ipanel.setValues(values); + }, + }); + } + }, +}); diff --git a/www/manager6/sdn/SubnetView.js b/www/manager6/sdn/SubnetView= .js new file mode 100644 index 00000000..e5cc03b7 --- /dev/null +++ b/www/manager6/sdn/SubnetView.js @@ -0,0 +1,107 @@ +Ext.define('PVE.sdn.SubnetView', { + extend: 'Ext.grid.GridPanel', + alias: 'widget.pveSDNSubnetView', + + stateful: true, + stateId: 'grid-sdn-subnet', + + initComponent : function() { + let me =3D this; + + let store =3D new Ext.data.Store({ + model: 'pve-sdn-subnet', + proxy: { + type: 'proxmox', + url: "/api2/json/cluster/sdn/subnets" + }, + sorters: { + property: 'subnet', + order: 'DESC' + } + }); + let reload =3D () =3D> store.load(); + + let sm =3D Ext.create('Ext.selection.RowModel', {}); + + let run_editor =3D function() { + let rec =3D sm.getSelection()[0]; + + let win =3D Ext.create('PVE.sdn.SubnetEdit',{ + autoShow: true, + subnet: rec.data.subnet, + }); + win.on('destroy', reload); + }; + + let edit_btn =3D new Proxmox.button.Button({ + text: gettext('Edit'), + disabled: true, + selModel: sm, + handler: run_editor, + }); + + let remove_btn =3D Ext.create('Proxmox.button.StdRemoveButton', { + selModel: sm, + baseurl: '/cluster/sdn/subnets/', + callback: reload + }); + + Ext.apply(me, { + store: store, + reloadStore: reload, + selModel: sm, + viewConfig: { + trackOver: false + }, + tbar: [ + { + text: gettext('Create'), + handler: function() { + let win =3D Ext.create('PVE.sdn.SubnetEdit', { + autoShow: true, + type: 'subnet', + }); + win.on('destroy', reload); + } + }, + remove_btn, + edit_btn, + ], + columns: [ + { + header: 'ID', + flex: 2, + dataIndex: 'cidr' + }, + { + header: gettext('Gateway'), + flex: 1, + dataIndex: 'gateway', + }, + { + header: gettext('Snat'), + flex: 1, + dataIndex: 'snat', + } + ], + listeners: { + activate: reload, + itemdblclick: run_editor + } + }); + + me.callParent(); + } +}, function() { + + Ext.define('pve-sdn-subnet', { + extend: 'Ext.data.Model', + fields: [ + 'cidr', + 'gateway', + 'snat', + ], + idProperty: 'subnet' + }); + +}); --=20 2.20.1