Commit da5dac81 authored by Wolfgang Link's avatar Wolfgang Link Committed by Dietmar Maurer

fix bug #781: separate CPU and memory in editor

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.
parent 3101e87e
......@@ -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 \
......
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();
}
});
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
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment