[pve-devel] [PATCH] fix bug #781: separate CPU and memory in editor

Wolfgang Link w.link at proxmox.com
Fri Oct 23 11:04:48 CEST 2015


This is necessary because CPU are not hot-plug-able and memory are hot-plug-able.
also this will be useful for the new resource window.
---
 www/manager/Makefile            |  1 +
 www/manager/lxc/ResourceEdit.js | 79 +++++++++++++++++++++++++++++++++++
 www/manager/lxc/Resources.js    | 92 ++---------------------------------------
 3 files changed, 84 insertions(+), 88 deletions(-)
 create mode 100644 www/manager/lxc/ResourceEdit.js

diff --git a/www/manager/Makefile b/www/manager/Makefile
index 129eca7..ea2e0b1 100644
--- a/www/manager/Makefile
+++ b/www/manager/Makefile
@@ -149,6 +149,7 @@ JSSRC= 				                 	\
 	lxc/CreateWizard.js				\
 	lxc/SnapshotTree.js				\
 	lxc/Snapshot.js					\
+	lxc/ResourceEdit.js				\
 	pool/StatusView.js				\
 	pool/Summary.js					\
 	pool/Config.js					\
diff --git a/www/manager/lxc/ResourceEdit.js b/www/manager/lxc/ResourceEdit.js
new file mode 100644
index 0000000..41d772c
--- /dev/null
+++ b/www/manager/lxc/ResourceEdit.js
@@ -0,0 +1,79 @@
+var labelWidth = 120;
+
+Ext.define('PVE.lxc.CPUEdit', {
+    extend: 'PVE.window.Edit',
+
+    initComponent : function() {
+	var me = this;
+
+	Ext.apply(me, {
+	    subject: gettext('CPU'),
+	    items: [
+		{
+		    xtype: 'numberfield',
+		    name: 'cpulimit',
+		    minValue: 0,
+		    value: '1',
+		    step: 1,
+		    fieldLabel: gettext('CPU limit'),
+		    labelWidth: labelWidth,
+		    allowBlank: false
+		},
+		{
+		    xtype: 'numberfield',
+		    name: 'cpuunits',
+		    fieldLabel: gettext('CPU units'),
+		    value: 1024,
+		    minValue: 8,
+		    maxValue: 500000,
+		    labelWidth: labelWidth,
+		    allowBlank: false
+		}
+	    ]
+	});
+
+	me.callParent();
+
+	me.load();
+    }
+});
+
+Ext.define('PVE.lxc.MemoryEdit', {
+    extend: 'PVE.window.Edit',
+
+    initComponent : function() {
+	var me = this;
+
+	Ext.apply(me, {
+	    subject: gettext('Memory'),
+	    items: [
+		{
+		    xtype: 'numberfield',
+		    name: 'memory',
+		    minValue: 32,
+		    maxValue: 512*1024,
+		    value: '512',
+		    step: 32,
+		    fieldLabel: gettext('Memory (MB)'),
+		    labelWidth: labelWidth,
+		    allowBlank: false
+		},
+		{
+		    xtype: 'numberfield',
+		    name: 'swap',
+		    minValue: 0,
+		    maxValue: 128*1024,
+		    value: '512',
+		    step: 32,
+		    fieldLabel: gettext('Swap (MB)'),
+		    labelWidth: labelWidth,
+		    allowBlank: false
+		}
+	    ]
+	});
+
+	me.callParent();
+
+	me.load();
+    }
+});
diff --git a/www/manager/lxc/Resources.js b/www/manager/lxc/Resources.js
index a8f1d9d..55c8321 100644
--- a/www/manager/lxc/Resources.js
+++ b/www/manager/lxc/Resources.js
@@ -1,83 +1,3 @@
-Ext.define('PVE.lxc.RessourceInputPanel', {
-    extend: 'PVE.panel.InputPanel',
-    alias: 'widget.pveLxcResourceInputPanel',
-
-    insideWizard: false,
-
-    initComponent : function() {
-	var me = this;
-
-	var labelWidth = 120;
-
-	me.column1 = [
-	    {
-		xtype: 'numberfield',
-		name: 'memory',
-		minValue: 32,
-		maxValue: 512*1024,
-		value: '512',
-		step: 32,
-		fieldLabel: gettext('Memory') + ' (MB)',
-		labelWidth: labelWidth,
-		allowBlank: false
-	    },
-	    {
-		xtype: 'numberfield',
-		name: 'swap',
-		minValue: 0,
-		maxValue: 128*1024,
-		value: '512',
-		step: 32,
-		fieldLabel: gettext('Swap') + ' (MB)',
-		labelWidth: labelWidth,
-		allowBlank: false
-	    }
-	];
-
-	me.column2 = [
-	    {
-		xtype: 'numberfield',
-		name: 'cpulimit',
-		minValue: 0,
-		value: '1',
-		step: 1,
-		fieldLabel: gettext('CPU limit'),
-		labelWidth: labelWidth,
-		allowBlank: false
-	    },
-	    {
-		xtype: 'numberfield',
-		name: 'cpuunits',
-		fieldLabel: gettext('CPU units'),
-		value: 1024,
-		minValue: 8,
-		maxValue: 500000,
-		labelWidth: labelWidth,
-		allowBlank: false
-	    }
-	];
-
-	me.callParent();
-    }
-});
-
-Ext.define('PVE.lxc.RessourceEdit', {
-    extend: 'PVE.window.Edit',
-
-    initComponent : function() {
-	var me = this;
-	
-	Ext.apply(me, {
-	    subject: gettext('Resources'),
-	    items: Ext.create('PVE.lxc.RessourceInputPanel')
-	});
-
-	me.callParent();
-
-	me.load();
-    }
-});
-
 /*jslint confusion: true */
 Ext.define('PVE.lxc.RessourceView', {
     extend: 'PVE.grid.ObjectGrid',
@@ -99,14 +19,10 @@ Ext.define('PVE.lxc.RessourceView', {
 
 	var caps = Ext.state.Manager.get('GuiCap');
 
-	var resEditor = (caps.vms['VM.Config.Memory'] || caps.vms['VM.Config.Disk'] ||
-			 caps.vms['VM.Config.CPU']) ? 'PVE.lxc.RessourceEdit' : undefined;
-
-
 	var rows = {
 	    memory: {
 		header: gettext('Memory'),
-		editor: resEditor,
+		editor: caps.vms['VM.Config.Memory'] ? 'PVE.lxc.MemoryEdit' : undefined,
 		never_delete: true,
 		renderer: function(value) {
 		    return PVE.Utils.format_size(value*1024*1024);
@@ -114,7 +30,7 @@ Ext.define('PVE.lxc.RessourceView', {
 	    },
 	    swap: {
 		header: gettext('Swap'),
-		editor: resEditor,
+		editor: caps.vms['VM.Config.Memory'] ? 'PVE.lxc.MemoryEdit' : undefined,
 		never_delete: true,
 		renderer: function(value) {
 		    return PVE.Utils.format_size(value*1024*1024);
@@ -123,7 +39,7 @@ Ext.define('PVE.lxc.RessourceView', {
 	    cpulimit: {
 		header: gettext('CPU limit'),
 		never_delete: true,
-		editor: resEditor,
+		editor: caps.vms['VM.Config.CPU'] ? 'PVE.lxc.CPUEdit' : undefined,
 		defaultValue: 1,
 		renderer: function(value) {
 		    if (value) { return value; };
@@ -133,7 +49,7 @@ Ext.define('PVE.lxc.RessourceView', {
 	    cpuunits: {
 		header: gettext('CPU units'),
 		never_delete: true,
-		editor: resEditor,
+		editor: caps.vms['VM.Config.CPU'] ? 'PVE.lxc.CPUEdit' : undefined,
 		defaultValue: 1024
 	    }
 	};
-- 
2.1.4





More information about the pve-devel mailing list