[pve-devel] [PATCH manager 4/6] gui: add MDevSelector
Dominik Csapak
d.csapak at proxmox.com
Fri Nov 16 16:29:54 CET 2018
this is used to select a mediated device type
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/form/MDevSelector.js | 102 ++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+)
create mode 100644 www/manager6/form/MDevSelector.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index ea5b00b2..a7d150b0 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..4317ec28
--- /dev/null
+++ b/www/manager6/form/MDevSelector.js
@@ -0,0 +1,102 @@
+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.setProxy({
+ type: 'proxmox',
+ url: '/api2/json/nodes/' + me.nodename + '/scan/mdev',
+ extraParams: {
+ pciid: me.pciid
+ }
+ });
+ },
+
+
+ setNodename: function(nodename) {
+ var me = this;
+
+ if (!nodename || (me.nodename === nodename)) {
+ return;
+ }
+
+ me.nodename = nodename;
+
+ me.setProxy({
+ type: 'proxmox',
+ url: '/api2/json/nodes/' + me.nodename + '/scan/mdev',
+ extraParms: {
+ pciid: me.pciid
+ }
+ });
+ },
+
+ setProxy: function(proxy) {
+ var me = this;
+ me.store.setProxy(proxy);
+ 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