On 09/26/2017 01:56 PM, Thomas Lamprecht wrote:
It seemed a bit weird that those options were in a seprate edit
window as they affect the same backend variable and may cause
confusion, an user may not be sure in what way they are related to
each other, if at all.

This allows us to share the help button, the docs must be updated so
that the moved fields are represented there.

Further we reduce the count of non common buttons from the Hardware
View.

Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com>
---
  www/manager6/Makefile              |  1 -
  www/manager6/qemu/CPUOptions.js    | 76 --------------------------------------
  www/manager6/qemu/CreateWizard.js  |  1 +
  www/manager6/qemu/HardwareView.js  | 22 -----------
  www/manager6/qemu/ProcessorEdit.js | 41 ++++++++++++++++++++
  5 files changed, 42 insertions(+), 99 deletions(-)
  delete mode 100644 www/manager6/qemu/CPUOptions.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 372e08af..935c47cb 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -149,7 +149,6 @@ JSSRC=                                                      
\
        qemu/HDMove.js                                  \
        qemu/HDThrottle.js                              \
        qemu/HDEfi.js                                   \
-       qemu/CPUOptions.js                              \
        qemu/DisplayEdit.js                             \
        qemu/KeyboardEdit.js                            \
        qemu/HardwareView.js                            \
diff --git a/www/manager6/qemu/CPUOptions.js b/www/manager6/qemu/CPUOptions.js
deleted file mode 100644
index 4ea8c35f..00000000
--- a/www/manager6/qemu/CPUOptions.js
+++ /dev/null
@@ -1,76 +0,0 @@
-Ext.define('PVE.qemu.CPUOptionsInputPanel', {
-    extend: 'PVE.panel.InputPanel',
-    alias: 'widget.PVE.qemu.CPUOptionsInputPanel',
-
-    onGetValues: function(values) {
-       var me = this;
-
-       PVE.Utils.delete_if_default(values, 'vcpus', '', 0);
-       PVE.Utils.delete_if_default(values, 'cpulimit', '0', 0);
-       PVE.Utils.delete_if_default(values, 'cpuunits', '1024', 0);
-
-       return values;
-    },
-
-    initComponent : function() {
-       var me = this;
-
-        var items = [
-            {
-                xtype: 'pveIntegerField',
-                name: 'vcpus',
-                minValue: 1,
-                maxValue: me.maxvcpus,
-                value: '',
-                fieldLabel: gettext('VCPUs'),
-                allowBlank: true,
-                emptyText: me.maxvcpus
-            },
-            {
-                xtype: 'numberfield',
-                name: 'cpulimit',
-                minValue: 0,
-                maxValue: 128,
-                value: '',
-                step: 1,
-                fieldLabel: gettext('Host CPU time'),
-                allowBlank: true,
-                emptyText: gettext('unlimited')
-            },
-           {
-                xtype: 'pveIntegerField',
-                name: 'cpuunits',
-                fieldLabel: gettext('CPU shares'),
-                minValue: 2,
-                maxValue: 262144,
-                value: '1024',
-                allowBlank: true
-            }
-       ];
-
-       me.items = items;
-
-       me.callParent();
-    }
-});
-
-Ext.define('PVE.qemu.CPUOptions', {
-    extend: 'PVE.window.Edit',
-
-    initComponent : function() {
-       var me = this;
-
-        var ipanel = Ext.create('PVE.qemu.CPUOptionsInputPanel', {
-            maxvcpus: me.maxvcpus
-        });
-       
-       Ext.apply(me, {
-           subject: gettext('CPU options'),
-           items: [ ipanel ]
-       });
-
-       me.callParent();
-
-       me.load();
-    }
-});
diff --git a/www/manager6/qemu/CreateWizard.js 
b/www/manager6/qemu/CreateWizard.js
index 954b8ef0..3d778c27 100644
--- a/www/manager6/qemu/CreateWizard.js
+++ b/www/manager6/qemu/CreateWizard.js
@@ -115,6 +115,7 @@ Ext.define('PVE.qemu.CreateWizard', {
                },
                {
                    xtype: 'pveQemuProcessorPanel',
+                   insideWizard: true,
                    title: gettext('CPU')
                },
                {
diff --git a/www/manager6/qemu/HardwareView.js 
b/www/manager6/qemu/HardwareView.js
index cbec59d2..5affc2b6 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -329,22 +329,6 @@ Ext.define('PVE.qemu.HardwareView', {
            win.on('destroy', reload);
        };
- var run_cpuoptions = function() {
-           var sockets = me.getObjectValue('sockets', 1);
-           var cores = me.getObjectValue('cores', 1);
-
-           var win = Ext.create('PVE.qemu.CPUOptions', {
-               maxvcpus: sockets * cores,
-               vmid: vmid,
-               pveSelNode: me.pveSelNode,
-               url: '/api2/extjs/' + baseurl
-           });
-
-           win.show();
-
-           win.on('destroy', reload);
-       };
-
        var run_move = function() {
            var rec = sm.getSelection()[0];
            if (!rec) {
@@ -390,11 +374,6 @@ Ext.define('PVE.qemu.HardwareView', {
            handler: run_diskthrottle
        });
- var cpuoptions_btn = new Ext.Button({
-           text: gettext('CPU options'),
-           handler: run_cpuoptions
-       });
-
        var remove_btn = new PVE.button.Button({
            text: gettext('Remove'),
            selModel: sm,
@@ -597,7 +576,6 @@ Ext.define('PVE.qemu.HardwareView', {
                resize_btn,
                move_btn,
                diskthrottle_btn,
-               cpuoptions_btn,
                revert_btn
            ],
            rows: rows,
diff --git a/www/manager6/qemu/ProcessorEdit.js 
b/www/manager6/qemu/ProcessorEdit.js
index 627d0c93..80c79236 100644
--- a/www/manager6/qemu/ProcessorEdit.js
+++ b/www/manager6/qemu/ProcessorEdit.js
@@ -2,10 +2,18 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
      extend: 'PVE.panel.InputPanel',
      alias: 'widget.pveQemuProcessorPanel',
      onlineHelp: 'qm_cpu',
+    insideWizard: false,
controller: {
        xclass: 'Ext.app.ViewController',
        control: {
+           '#': {
+               beforerender: function(view) {
+                   Ext.Array.each(this.wizardOnlyFields, function (field_ref) {
+                       view.lookup(field_ref).setHidden(view.insideWizard);
+                   });
+               }
+           },

for this, i would like we rather use the 'init' method of the viewcontroller,

this will be called after the views initcomponent and only once during the creation

beforerender will possibly called each time before it has to be rendered

not a very big issue though

            'pveIntegerField[name=sockets]': {
                change: 'setTotalCores'
            },
@@ -13,9 +21,13 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
                change: 'setTotalCores'
            }
        },
+       wizardOnlyFields: [ 'vcpus', 'cpulimit', 'cpuunits' ],
        setTotalCores: function() {
            var sockets = this.lookup('sockets').getValue();
            var cores = this.lookup('cores').getValue();
+           var vcpus_field = this.lookup('vcpus');
+           vcpus_field.setMaxValue(sockets * cores);
+           vcpus_field.validate();
        }
      },
@@ -48,6 +60,10 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
            values['delete'] = delarr;
        }
+ PVE.Utils.delete_if_default(values, 'vcpus', '', 0);
+       PVE.Utils.delete_if_default(values, 'cpulimit', '0', 0);
+       PVE.Utils.delete_if_default(values, 'cpuunits', '1024', 0);
+
        return values;
      },
@@ -86,6 +102,31 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
            name: 'cputype',
            value: '__default__',
            fieldLabel: gettext('Type')
+       },
+       {
+           xtype: 'pveIntegerField',
+           name: 'vcpus',
+           reference: 'vcpus',
+           minValue: 1,
+           fieldLabel: gettext('vCPUs'),
+           emptyText: gettext('all')
+       },
+       {
+           xtype: 'numberfield',
+           name: 'cpulimit',
+           reference: 'cpulimit',
+           minValue: 0,
+           fieldLabel: gettext('Host CPU Time'),
+           emptyText: gettext('unlimited')
+       },
+       {
+           xtype: 'pveIntegerField',
+           name: 'cpuunits',
+           reference: 'cpuunits',
+           fieldLabel: gettext('CPU shares'),
+           minValue: 2,
+           maxValue: 262144,
+           value: '1024'
        }
      ],


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to