[pve-devel] [PATCH manager 2/2] ui: add network selector widget
Tim Marx
t.marx at proxmox.com
Fri May 31 13:41:50 CEST 2019
Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/form/NetworkSelector.js | 77 ++++++++++++++++++++++++++++++++++++
2 files changed, 78 insertions(+)
create mode 100644 www/manager6/form/NetworkSelector.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 2f25a83f..422dd463 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -38,6 +38,7 @@ JSSRC= \
form/ViewSelector.js \
form/NodeSelector.js \
form/FileSelector.js \
+ form/NetworkSelector.js \
form/StorageSelector.js \
form/DiskStorageSelector.js \
form/BridgeSelector.js \
diff --git a/www/manager6/form/NetworkSelector.js b/www/manager6/form/NetworkSelector.js
new file mode 100644
index 00000000..d73f5fe6
--- /dev/null
+++ b/www/manager6/form/NetworkSelector.js
@@ -0,0 +1,77 @@
+Ext.define('PVE.form.NetworkSelectorController', {
+ extend: 'Ext.app.ViewController',
+ alias: 'controller.networkSelectorController',
+
+ init: function (view) {
+ var me = this;
+
+ if (!view.nodename) {
+ throw "missing custom view config: nodename";
+ }
+ view.getStore().getProxy().setUrl('/api2/json/nodes/'+ view.nodename + '/network');
+ },
+ initViewModel: function(vm) {
+ var view = this.getView();
+ vm.set('nodename', view.nodename);
+ }
+});
+
+Ext.define('PVE.form.NetworkSelector', {
+ extend: 'Proxmox.form.ComboGrid',
+ alias: 'widget.pveNetworkSelector',
+
+ nodename: undefined,
+ controller: 'networkSelectorController',
+ viewmodel: {
+ data: {
+ nodename: undefined
+ }
+ },
+ // set default value to empty array, else it inits it with
+ // null and after the store load it is an empty array,
+ // triggering dirtychange
+ value: [],
+ valueField: 'cidr',
+ displayField: 'cidr',
+ store: {
+ autoLoad: true,
+ fields: [ 'active', 'address', 'cidr', 'comments', 'iface', 'slaves', 'type' ],
+ proxy: {
+ type: 'proxmox'
+ },
+ sorters: [
+ {
+ property : 'iface',
+ direction: 'ASC'
+ }
+ ],
+ filters: [
+ function(item) {
+ return item.data.cidr;
+ }
+ ]
+ },
+ listConfig: {
+ columns: [
+ {
+ header: gettext('Interface'),
+ sortable: true,
+ width: 70,
+ dataIndex: 'iface'
+ },
+ {
+ header: gettext('CIDR'),
+ dataIndex: 'cidr',
+ sortable: true,
+ hideable: false,
+ flex: 1
+ },
+ {
+ header: gettext('Comment'),
+ sortable: true,
+ width: 100,
+ dataIndex: 'comments'
+ }
+ ]
+ }
+});
--
2.11.0
More information about the pve-devel
mailing list