[pve-devel] [PATCH manager v3 4/6] gui: add MDevSelector

Dominik Csapak d.csapak at proxmox.com
Thu Nov 22 11:35:44 CET 2018


this is used to select a mediated device type

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
chnages from v2:
* api path change
* setProxy optimized -> only 1 url generation -> less code

 www/manager6/Makefile             |  1 +
 www/manager6/form/MDevSelector.js | 91 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+)
 create mode 100644 www/manager6/form/MDevSelector.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 03fc93e0..d900ec88 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -42,6 +42,7 @@ JSSRC= 				                 	\
 	form/DiskStorageSelector.js			\
 	form/BridgeSelector.js				\
 	form/PCISelector.js				\
+	form/MDevSelector.js				\
 	form/SecurityGroupSelector.js			\
 	form/IPRefSelector.js				\
 	form/IPProtocolSelector.js			\
diff --git a/www/manager6/form/MDevSelector.js b/www/manager6/form/MDevSelector.js
new file mode 100644
index 00000000..2eabd793
--- /dev/null
+++ b/www/manager6/form/MDevSelector.js
@@ -0,0 +1,91 @@
+Ext.define('PVE.form.MDevSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    xtype: 'pveMDevSelector',
+
+    store: {
+	fields: [ 'type','available', 'description' ],
+	filterOnLoad: true,
+	sorters: [
+	    {
+		property : 'type',
+		direction: 'ASC'
+	    }
+	]
+    },
+    autoSelect: false,
+    valueField: 'type',
+    displayField: 'type',
+    listConfig: {
+	columns: [
+	    {
+		header: gettext('Type'),
+		dataIndex: 'type',
+		flex: 1
+	    },
+	    {
+		header: gettext('Available'),
+		dataIndex: 'available',
+		width: 80
+	    },
+	    {
+		header: gettext('Description'),
+		dataIndex: 'description',
+		flex: 1,
+		renderer: function(value) {
+		    if (!value) {
+			return '';
+		    }
+
+		    return value.split('\n').join('<br>');
+		}
+	    }
+	]
+    },
+
+    setPciID: function(pciid, force) {
+	var me = this;
+
+	if (!force && (!pciid || (me.pciid === pciid))) {
+	    return;
+	}
+
+	me.pciid = pciid;
+	me.updateProxy();
+    },
+
+
+    setNodename: function(nodename) {
+	var me = this;
+
+	if (!nodename || (me.nodename === nodename)) {
+	    return;
+	}
+
+	me.nodename = nodename;
+	me.updateProxy();
+    },
+
+    updateProxy: function() {
+	var me = this;
+	me.store.setProxy({
+	    type: 'proxmox',
+	    url: '/api2/json/nodes/' + me.nodename + '/scan/pci/' + me.pciid + '/mdev'
+	});
+	me.store.load();
+    },
+
+    initComponent: function() {
+	var me = this;
+
+	if (!me.nodename) {
+	    throw 'no node name specified';
+	}
+
+        me.callParent();
+
+	if (me.pciid) {
+	    me.setPciID(me.pciid, true);
+	}
+    }
+});
+
-- 
2.11.0





More information about the pve-devel mailing list