[pve-devel] r6204 - in pve-manager/pve2: . www/manager www/manager/data www/manager/form www/manager/qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jun 29 16:07:10 CEST 2011


Author: dietmar
Date: 2011-06-29 16:07:10 +0200 (Wed, 29 Jun 2011)
New Revision: 6204

Added:
   pve-manager/pve2/www/manager/form/CPUModelSelector.js
Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/Makefile.am
   pve-manager/pve2/www/manager/PVEUtils.js
   pve-manager/pve2/www/manager/data/DiffStore.js
   pve-manager/pve2/www/manager/form/BondModeSelector.js
   pve-manager/pve2/www/manager/qemu/HardwareView.js
Log:
impl. PVE.qemu.ProcessorEdit


Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-06-29 10:58:01 UTC (rev 6203)
+++ pve-manager/pve2/ChangeLog	2011-06-29 14:07:10 UTC (rev 6204)
@@ -1,5 +1,9 @@
 2011-06-29  Proxmox Support Team  <support at proxmox.com>
 
+	* www/manager/qemu/HardwareView.js: impl. PVE.qemu.ProcessorEdit
+
+	* www/manager/form/CPUModelSelector.js: impl.
+
 	* www/manager/form/RealmComboBox.js: use 'pam' as default realm
 
 	* bin/init.d/pvenetcommit: moved functionality from pvesetup

Modified: pve-manager/pve2/www/manager/Makefile.am
===================================================================
--- pve-manager/pve2/www/manager/Makefile.am	2011-06-29 10:58:01 UTC (rev 6203)
+++ pve-manager/pve2/www/manager/Makefile.am	2011-06-29 14:07:10 UTC (rev 6204)
@@ -25,7 +25,8 @@
 	form/NodeSelector.js				\
 	form/FileSelector.js				\
 	form/StorageSelector.js				\
-	dc/Tasks.js				\
+	form/CPUModelSelector.js			\
+	dc/Tasks.js					\
 	dc/Log.js					\
 	panel/StatusPanel.js				\
 	panel/RRDView.js				\

Modified: pve-manager/pve2/www/manager/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/manager/PVEUtils.js	2011-06-29 10:58:01 UTC (rev 6203)
+++ pve-manager/pve2/www/manager/PVEUtils.js	2011-06-29 14:07:10 UTC (rev 6204)
@@ -44,6 +44,11 @@
    
 });
 
+// we dont want that a display field set the form dirty flag! 
+Ext.override(Ext.form.field.Display, {
+    isDirty: function() { return false; }
+});
+
 Ext.define('PVE.Utils', {
     singleton: true,
 

Modified: pve-manager/pve2/www/manager/data/DiffStore.js
===================================================================
--- pve-manager/pve2/www/manager/data/DiffStore.js	2011-06-29 10:58:01 UTC (rev 6203)
+++ pve-manager/pve2/www/manager/data/DiffStore.js	2011-06-29 14:07:10 UTC (rev 6204)
@@ -51,7 +51,7 @@
 	    me.suspendEvents();
 
 	    // remove vanished items
-	    me.each(function(olditem) {
+	    (me.snapshot || me.data).each(function(olditem) {
 		var item = rstore.getById(olditem.getId());
 		if (!item)
 		    me.remove(olditem);

Modified: pve-manager/pve2/www/manager/form/BondModeSelector.js
===================================================================
--- pve-manager/pve2/www/manager/form/BondModeSelector.js	2011-06-29 10:58:01 UTC (rev 6203)
+++ pve-manager/pve2/www/manager/form/BondModeSelector.js	2011-06-29 14:07:10 UTC (rev 6204)
@@ -14,7 +14,7 @@
 		['broadcast', ''], 
 		['802.3ad', ''], 
 		['balance-tlb', ''], 
-		['balance-alb', ''], 
+		['balance-alb', '']
 	    ]
         });
 

Added: pve-manager/pve2/www/manager/form/CPUModelSelector.js
===================================================================
--- pve-manager/pve2/www/manager/form/CPUModelSelector.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/form/CPUModelSelector.js	2011-06-29 14:07:10 UTC (rev 6204)
@@ -0,0 +1,57 @@
+Ext.define('PVE.form.CPUModelSelector', {
+    extend: 'Ext.form.field.ComboBox',
+    alias: ['widget.CPUModelSelector'],
+  
+    deleteEmpty: true,
+    
+    getSubmitData: function() {
+        var me = this,
+            data = null,
+            val;
+        if (!me.disabled && me.submitValue && !me.isFileUpload()) {
+            val = me.getSubmitValue();
+            if (val !== null && val != '') {
+                data = {};
+                data[me.getName()] = val;
+            } else if (me.deleteEmpty) {
+		data = {};
+                data['delete'] = me.getName();
+	    }
+        }
+        return data;
+    },
+
+    initComponent: function() {
+	var me = this;
+
+	var store = Ext.create('Ext.data.ArrayStore', {
+	    model: 'KeyValue',
+            data : [ 
+		['', 'Default (qemu64)'],
+		['486', '486'],
+		['athlon', 'athlon'],
+		['core2duo', 'core2duo'],
+		['coreduo', 'coreduo'],
+		['kvm32', 'kvm32'],
+		['kvm64', 'kvm64'],
+		['pentium', 'pentium'],
+		['pentium2', 'pentium2'],
+		['pentium3', 'pentium3'],
+		['phenom', 'phenom'],
+		['qemu32', 'qemu32'],
+		['qemu64', 'qemu64'],
+		['host', 'host']
+	    ]
+        });
+
+	Ext.apply(me, {
+	    store: store,
+	    queryMode: 'local',
+	    editable: false,
+	    displayField: 'value',
+	    valueField: 'key'
+	});
+
+	me.callParent();
+    }
+});

Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-06-29 10:58:01 UTC (rev 6203)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-06-29 14:07:10 UTC (rev 6204)
@@ -1,3 +1,145 @@
+Ext.define('PVE.qemu.ProcessorEdit', {
+    extend: 'Ext.window.Window',
+
+    initComponent : function() {
+	var me = this;
+
+	var nodename = me.pveSelNode.data.node;
+	if (!nodename) 
+	    throw "no node name specified";
+
+	if (!me.store) 
+	    throw "no store specified";
+	
+	var data = {};
+	var rec = me.store.getById('sockets');
+	data.sockets = rec && rec.data.value ? rec.data.value : 1;
+	rec = me.store.getById('cores');
+	data.cores = rec && rec.data.value ? rec.data.value : 1;
+	rec = me.store.getById('cpu');
+ 	data.cpu = rec && rec.data.value ? rec.data.value : '';
+
+	var formpanel = Ext.create('Ext.form.Panel', {
+	    url: me.url,
+	    method: 'PUT',
+	    trackResetOnLoad: true,
+	    bodyPadding: 10,
+	    border: false,	    
+	    fieldDefaults: {
+		labelWidth: 100,
+		anchor: '100%'
+            },
+	    layout: 'column',
+	    defaultType: 'container',
+	    items: [
+		{
+		    columnWidth: .5,
+		    items: [
+			{
+			    xtype: 'numberfield',
+			    name: 'sockets',
+			    minValue: 1,
+			    maxValue: 4,
+			    value: 1,
+			    fieldLabel: 'Sockets',
+			    allowBlank: false,
+			    listeners: {
+				change: function(f, value) {
+				    var sockets = me.down('field[name=sockets]').getValue();
+				    var cores = me.down('field[name=cores]').getValue();
+				    me.down('field[name=totalcores]').setValue(sockets*cores);
+				}
+			    }
+			},
+			{
+			    xtype: 'numberfield',
+			    name: 'cores',
+			    minValue: 1,
+			    maxValue: 32,
+			    value: 1,
+			    fieldLabel: 'Cores',
+			    allowBlank: false,
+			    listeners: {
+				change: function(f, value) {
+				    var sockets = me.down('field[name=sockets]').getValue();
+				    var cores = me.down('field[name=cores]').getValue();
+				    me.down('field[name=totalcores]').setValue(sockets*cores);
+				}
+			    }
+			},
+			{
+			    xtype: 'displayfield',
+			    fieldLabel: 'Total cores',
+			    name: 'totalcores',
+			    value: 1
+			}
+		    ]
+		},
+		{
+		    columnWidth: .5,
+		    items: [
+			{
+			    xtype: 'CPUModelSelector',
+			    name: 'cpu',
+			    fieldLabel: 'CPU type',
+			}
+		    ]
+		}
+	    ]
+	});
+
+	var form = formpanel.getForm();
+
+	var submitBtn = Ext.create('Ext.Button', {
+	    text: 'OK',
+	    disabled: true,
+	    handler: function() {
+		formpanel.submit({
+		    success: function() { 
+			me.close();
+		    },
+		    failure: function(form, action) {
+			Ext.Msg.alert('Error', PVE.Utils.extractFormActionError(action));
+		    }
+		});
+	    }
+	});
+
+	var resetBtn = Ext.create('Ext.Button', {
+	    text: 'Reset',
+	    disabled: true,
+	    handler: function(){
+		form.reset();
+	    }
+	});
+
+	var set_button_status = function() {
+	    var valid = form.isValid();
+	    var dirty = form.isDirty();
+	    submitBtn.setDisabled(!(valid && dirty));
+	    resetBtn.setDisabled(!dirty);
+	};
+
+	form.on('dirtychange', set_button_status);
+	form.on('validitychange', set_button_status);
+
+	Ext.applyIf(me, {
+	    title: "Edit processor settings",
+	    modal: true,
+            width: 600,
+	    height: 200,
+	    layout: 'fit',
+	    border: false,
+	    items: formpanel,
+	    buttons: [ submitBtn, resetBtn ]
+	});
+
+	me.callParent();
+
+	form.setValues(data);
+    }
+});
+
 Ext.define('PVE.qemu.HardwareView', {
     extend: 'PVE.grid.ObjectGrid',
     alias: ['widget.PVE.qemu.HardwareView'],
@@ -43,15 +185,20 @@
 	    sockets: {
 		header: 'Processors',
 		never_delete: true,
+		editor: 'PVE.qemu.ProcessorEdit',
 		tdCls: 'pve-itype-icon-processor',
 		defaultValue: 1,
 		renderer: function(value, metaData, record, rowIndex, colIndex, store) {
-		    var rec = (store.snapshot || store.data).get('cores');
-		    if (!rec || (rec.data.value <= 1))
+		    var model = me.getObjectValue('cpu');
+		    var cores = me.getObjectValue('cores');
+		    if (!cores || (cores <= 1))
 			return value;
 
-		    var cores = rec.data.value;
-		    return (value*cores) + ' (' + value + ' x ' + cores + ' cores)';
+		    var res = (value*cores) + ' (' + value + ' x ' + cores + ' cores)';
+		    if (model)
+			res += ' [' + model + ']';
+
+		    return res;
 		}
 	    },
 	    keyboard: {
@@ -68,8 +215,10 @@
 		defaultValue: 'default'		
 	    },
 	    cores: {
-		header: 'Cores',
 		visible: false
+	    },
+	    cpu: {
+		visible: false
 	    }
 	};
 
@@ -109,10 +258,25 @@
 	}
 
 	var run_editor = function() {
-	    
-	    console.log("TEST EDIT");
+	    var sm = me.getSelectionModel();
+	    var rec = sm.getSelection()[0];
+	    if (!rec)
+		return;
 
-	    me.rstore.load();
+	    var rowdef = rows[rec.data.key];
+	    if (!rowdef.editor)
+		return;
+
+	    var win = Ext.create(rowdef.editor, {
+		pveSelNode: me.pveSelNode,
+		url: me.url,
+		store: me.rstore
+	    });
+
+	    win.show();
+	    win.on('destroy', function() {
+		me.rstore.load();
+	    });
 	};
 
 	var edit_btn = new Ext.Button({
@@ -139,15 +303,15 @@
 		return;
 	    }
 
-	    edit_btn.enable();
-
 	    var rowdef = rows[rec.data.key];
 
+	    edit_btn.setDisabled(!rowdef.editor);
+
 	    remove_btn.setDisabled(rowdef.never_delete === true);
 	}
 
 	Ext.applyIf(me, {
-	    url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/config",
+	    url: "/api2/extjs/nodes/" + nodename + "/qemu/" + vmid + "/config",
 	    cwidth1: 150,
 	    tbar: [ 
 		{




More information about the pve-devel mailing list