]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
split iothrottle form
authorAlexandre Derumier <aderumier@odiso.com>
Mon, 23 Dec 2013 10:26:46 +0000 (11:26 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 14 Jan 2014 10:09:06 +0000 (11:09 +0100)
//fixme : enable/disable splitbutton

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
www/manager/Makefile
www/manager/qemu/HDEdit.js
www/manager/qemu/HDThrottle.js [new file with mode: 0644]
www/manager/qemu/HardwareView.js

index f8cc8198c72e7eef26d4ae1d899c2fbabe457df0..a4d60e4497c9ad163cbd78c7a261b9e76b711e25 100644 (file)
@@ -102,6 +102,7 @@ JSSRC=                                                      \
        qemu/HDEdit.js                                  \
        qemu/HDResize.js                                \
        qemu/HDMove.js                                  \
+       qemu/HDThrottle.js                              \
        qemu/DisplayEdit.js                             \
        qemu/KeyboardEdit.js                            \
        qemu/HardwareView.js                            \
index eb75e4e3ffd9127488dbf71e17c35ac2c1fa0ffc..a09ec66a83a5154eeaa1f6185d0152ec04c03748 100644 (file)
@@ -39,21 +39,6 @@ Ext.define('PVE.qemu.HDInputPanel', {
            delete me.drive.cache;
        }
 
-       var names = ['mbps_rd', 'mbps_wr', 'iops_rd', 'iops_wr'];
-       Ext.Array.each(names, function(name) {
-           if (values[name]) {
-               me.drive[name] = values[name];
-           } else {
-               delete me.drive[name];
-           }
-           var burst_name = name + '_max';
-           if (values[burst_name] && values[name]) {
-               me.drive[burst_name] = values[burst_name];
-           } else {
-               delete me.drive[burst_name];
-           }
-       });
-
        var params = {};
                
        params[confid] = PVE.Parser.printQemuDrive(me.drive);
@@ -96,14 +81,6 @@ Ext.define('PVE.qemu.HDInputPanel', {
        values.nobackup = (drive.backup === 'no');
        values.diskformat = drive.format || 'raw';
        values.cache = drive.cache || '';
-       values.mbps_rd = drive.mbps_rd;
-       values.mbps_wr = drive.mbps_wr;
-       values.iops_rd = drive.iops_rd;
-       values.iops_wr = drive.iops_wr;
-       values.mbps_rd_max = drive.mbps_rd_max;
-       values.mbps_wr_max = drive.mbps_wr_max;
-       values.iops_rd_max = drive.iops_rd_max;
-       values.iops_wr_max = drive.iops_wr_max;
 
        me.setValues(values);
     },
@@ -120,7 +97,6 @@ Ext.define('PVE.qemu.HDInputPanel', {
        me.drive = {};
 
        me.column1 = [];
-       me.column2 = [];
 
        if (!me.confid || me.unused) {
            me.bussel = Ext.createWidget('PVE.form.ControllerSelector', {
@@ -238,89 +214,6 @@ Ext.define('PVE.qemu.HDInputPanel', {
            });
        }
 
-       var width2 = 140;
-
-        me.mbps_rd = Ext.widget('numberfield', {
-            name: 'mbps_rd',
-            minValue: 1,
-           step: 1,
-            fieldLabel: gettext('Read limit') + ' (MB/s)',
-           labelWidth: width2,
-           emptyText: gettext('unlimited')
-        });
-        me.column2.push(me.mbps_rd);
-
-        me.mbps_rd_max = Ext.widget('numberfield', {
-            name: 'mbps_rd_max',
-            minValue: 1,
-           step: 1,
-            fieldLabel: gettext('Read max burst') + ' (MB)',
-           labelWidth: width2,
-           emptyText: gettext('default')
-        });
-        me.column2.push(me.mbps_rd_max);
-
-
-        me.mbps_wr = Ext.widget('numberfield', {
-            name: 'mbps_wr',
-            minValue: 1,
-           step: 1,
-            fieldLabel: gettext('Write limit') + ' (MB/s)',
-           labelWidth: width2,
-           emptyText: gettext('unlimited')
-        });
-        me.column2.push(me.mbps_wr);
-
-        me.mbps_wr_max = Ext.widget('numberfield', {
-            name: 'mbps_wr_max',
-            minValue: 1,
-           step: 1,
-            fieldLabel: gettext('Write max burst') + ' (MB)',
-           labelWidth: width2,
-           emptyText: gettext('default')
-        });
-        me.column2.push(me.mbps_wr_max);
-
-        me.iops_rd = Ext.widget('numberfield', {
-            name: 'iops_rd',
-            minValue: 10,
-           step: 10,
-            fieldLabel: gettext('Read limit') + ' (ops/s)',
-           labelWidth: width2,
-           emptyText: gettext('unlimited')
-        });
-        me.column2.push(me.iops_rd);
-
-        me.iops_rd_max = Ext.widget('numberfield', {
-            name: 'iops_rd_max',
-            minValue: 10,
-           step: 10,
-            fieldLabel: gettext('Read max burst') + ' (ops)',
-           labelWidth: width2,
-           emptyText: gettext('default')
-        });
-        me.column2.push(me.iops_rd_max);
-
-        me.iops_wr = Ext.widget('numberfield', {
-            name: 'iops_wr',
-            minValue: 10,
-           step: 10,
-            fieldLabel: gettext('Write limit') + ' (ops/s)',
-           labelWidth: width2,
-           emptyText: gettext('unlimited')
-        });
-        me.column2.push(me.iops_wr);
-
-        me.iops_wr_max = Ext.widget('numberfield', {
-            name: 'iops_wr_max',
-            minValue: 10,
-           step: 10,
-            fieldLabel: gettext('Write max burst') + ' (ops)',
-           labelWidth: width2,
-           emptyText: gettext('default')
-        });
-        me.column2.push(me.iops_wr_max);
-
        me.callParent();
     }
 });
diff --git a/www/manager/qemu/HDThrottle.js b/www/manager/qemu/HDThrottle.js
new file mode 100644 (file)
index 0000000..8e7026c
--- /dev/null
@@ -0,0 +1,211 @@
+// fixme: howto avoid jslint type confusion?
+/*jslint confusion: true */
+Ext.define('PVE.qemu.HDThrottleInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+    alias: 'widget.PVE.qemu.HDThrottleInputPanel',
+
+    insideWizard: false,
+
+    unused: false, // ADD usused disk imaged
+
+    vmconfig: {}, // used to select usused disks
+
+    onGetValues: function(values) {
+       var me = this;
+
+       var confid = me.confid;
+       
+        var names = ['mbps_rd', 'mbps_wr', 'iops_rd', 'iops_wr'];
+        Ext.Array.each(names, function(name) {
+            if (values[name]) {
+                me.drive[name] = values[name];
+            } else {
+                delete me.drive[name];
+            }
+            var burst_name = name + '_max';
+            if (values[burst_name] && values[name]) {
+                me.drive[burst_name] = values[burst_name];
+            } else {
+                delete me.drive[burst_name];
+            }
+        });
+
+       var params = {};
+               
+       params[confid] = PVE.Parser.printQemuDrive(me.drive);
+       
+       return params;  
+    },
+
+    setDrive: function(drive) {
+       var me = this;
+
+       me.drive = drive;
+
+       var values = {};
+
+       values.mbps_rd = drive.mbps_rd;
+       values.mbps_wr = drive.mbps_wr;
+       values.iops_rd = drive.iops_rd;
+       values.iops_wr = drive.iops_wr;
+       values.mbps_rd_max = drive.mbps_rd_max;
+       values.mbps_wr_max = drive.mbps_wr_max;
+       values.iops_rd_max = drive.iops_rd_max;
+       values.iops_wr_max = drive.iops_wr_max;
+
+       me.setValues(values);
+    },
+
+    initComponent : function() {
+       var me = this;
+
+       me.drive = {};
+
+       me.column1 = [];
+       me.column2 = [];
+
+       var width2 = 140;
+
+        me.mbps_rd = Ext.widget('numberfield', {
+            name: 'mbps_rd',
+            minValue: 1,
+            step: 1,
+            fieldLabel: gettext('Read limit') + ' (MB/s)',
+            labelWidth: width2,
+            emptyText: gettext('unlimited')
+         });
+
+        me.column1.push(me.mbps_rd);
+
+        me.mbps_rd_max = Ext.widget('numberfield', {
+            name: 'mbps_rd_max',
+            minValue: 1,
+            step: 1,
+            fieldLabel: gettext('Read max burst') + ' (MB)',
+            labelWidth: width2,
+            emptyText: gettext('default')
+        });
+
+        me.column2.push(me.mbps_rd_max);
+
+
+        me.mbps_wr = Ext.widget('numberfield', {
+            name: 'mbps_wr',
+            minValue: 1,
+            step: 1,
+            fieldLabel: gettext('Write limit') + ' (MB/s)',
+            labelWidth: width2,
+            emptyText: gettext('unlimited')
+        });
+
+        me.column1.push(me.mbps_wr);
+
+        me.mbps_wr_max = Ext.widget('numberfield', {
+            name: 'mbps_wr_max',
+            minValue: 1,
+            step: 1,
+            fieldLabel: gettext('Write max burst') + ' (MB)',
+            labelWidth: width2,
+            emptyText: gettext('default')
+        });
+
+        me.column2.push(me.mbps_wr_max);
+
+        me.iops_rd = Ext.widget('numberfield', {
+            name: 'iops_rd',
+            minValue: 10,
+            step: 10,
+            fieldLabel: gettext('Read limit') + ' (ops/s)',
+            labelWidth: width2,
+            emptyText: gettext('unlimited')
+        });
+
+        me.column1.push(me.iops_rd);
+
+        me.iops_rd_max = Ext.widget('numberfield', {
+            name: 'iops_rd_max',
+            minValue: 10,
+            step: 10,
+            fieldLabel: gettext('Read max burst') + ' (ops)',
+            labelWidth: width2,
+            emptyText: gettext('default')
+        });
+
+        me.column2.push(me.iops_rd_max);
+
+        me.iops_wr = Ext.widget('numberfield', {
+            name: 'iops_wr',
+            minValue: 10,
+            step: 10,
+            fieldLabel: gettext('Write limit') + ' (ops/s)',
+            labelWidth: width2,
+            emptyText: gettext('unlimited')
+        });
+
+        me.column1.push(me.iops_wr);
+
+        me.iops_wr_max = Ext.widget('numberfield', {
+            name: 'iops_wr_max',
+            minValue: 10,
+            step: 10,
+            fieldLabel: gettext('Write max burst') + ' (ops)',
+            labelWidth: width2,
+            emptyText: gettext('default')
+        });
+
+        me.column2.push(me.iops_wr_max);
+
+       me.callParent();
+    }
+});
+
+Ext.define('PVE.qemu.HDThrottle', {
+    extend: 'PVE.window.Edit',
+
+    isAdd: true,
+
+    initComponent : function() {
+       var me = this;
+
+       var nodename = me.pveSelNode.data.node;
+       if (!nodename) { 
+           throw "no node name specified";         
+       }
+
+       var unused = me.confid && me.confid.match(/^unused\d+$/);
+       
+       me.create = me.confid ? unused : true;
+
+       var ipanel = Ext.create('PVE.qemu.HDThrottleInputPanel', {
+           confid: me.confid,
+           nodename: nodename,
+       });
+
+       var subject;
+       if (unused) {
+           me.subject = gettext('Unused Disk');
+       } else {
+           me.subject = gettext('Hard Disk') + ' (' + me.confid + ')';
+       }
+
+       me.items = [ ipanel ];
+
+       me.callParent();
+       
+       me.load({
+           success: function(response, options) {
+               if (me.confid) {
+                   var value = response.result.data[me.confid];
+                   var drive = PVE.Parser.parseQemuDrive(me.confid, value);
+                   if (!drive) {
+                       Ext.Msg.alert(gettext('Error'), gettext('Unable to parse drive options'));
+                       me.close();
+                       return;
+                   }
+                   ipanel.setDrive(drive);
+                   me.isValid(); // trigger validation
+               }
+           }
+       });
+    }
+});
index b3dea91c17062cd3275a8827987995e795fbceb9..c1c6d1d8f49906c106ff66fcde025f830506c457 100644 (file)
@@ -212,6 +212,28 @@ Ext.define('PVE.qemu.HardwareView', {
            win.on('destroy', reload);
        };
 
+       var run_diskthrottle = function() {
+           var rec = sm.getSelection()[0];
+           if (!rec) {
+               return;
+           }
+
+           var rowdef = rows[rec.data.key];
+           if (!rowdef.editor) {
+               return;
+           }
+
+           var editor = rowdef.editor;
+            var win = Ext.create('PVE.qemu.HDThrottle', {
+               pveSelNode: me.pveSelNode,
+               confid: rec.data.key,
+               url: '/api2/extjs/' + baseurl
+           });
+
+           win.show();
+           win.on('destroy', reload);
+       };
+
        var run_resize = function() {
            var rec = sm.getSelection()[0];
            if (!rec) {
@@ -256,10 +278,15 @@ Ext.define('PVE.qemu.HardwareView', {
            win.on('destroy', reload);
        };
 
-       var edit_btn = new PVE.button.Button({
+        var diskthrottleMenu = Ext.create('Ext.menu.Item', {
+           text: 'Disk Throttle',
+           handler: run_diskthrottle
+        });
+
+        var edit_btn = Ext.create('Ext.button.Split', {
            text: gettext('Edit'),
            selModel: sm,
-           disabled: true,
+//         disabled: true,
            enableFn: function(rec) {
                if (!rec) {
                    return false;
@@ -267,8 +294,19 @@ Ext.define('PVE.qemu.HardwareView', {
                var rowdef = rows[rec.data.key];
                return !!rowdef.editor;
            },
-           handler: run_editor
-       });
+           handler: run_editor,
+
+            menu: new Ext.menu.Menu({
+                items: [
+                    {
+                       text: gettext('Edit'),
+
+                       handler: run_editor,
+                    },
+                    diskthrottleMenu
+                ]
+            })
+        });
 
        var resize_btn = new PVE.button.Button({
            text: gettext('Resize disk'),