[pve-devel] r6311 - in pve-manager/pve2: . www/manager/dc www/manager/node www/manager/qemu www/manager/window
svn-commits at proxmox.com
svn-commits at proxmox.com
Fri Jul 15 12:59:30 CEST 2011
Author: dietmar
Date: 2011-07-15 12:59:30 +0200 (Fri, 15 Jul 2011)
New Revision: 6311
Modified:
pve-manager/pve2/ChangeLog
pve-manager/pve2/www/manager/dc/GroupEdit.js
pve-manager/pve2/www/manager/dc/UserEdit.js
pve-manager/pve2/www/manager/node/NetworkEdit.js
pve-manager/pve2/www/manager/qemu/CDEdit.js
pve-manager/pve2/www/manager/qemu/HDEdit.js
pve-manager/pve2/www/manager/qemu/NetworkEdit.js
pve-manager/pve2/www/manager/qemu/OSTypeEdit.js
pve-manager/pve2/www/manager/window/Edit.js
Log:
i * www/manager/qemu/*.js: fix success callback
* www/manager/qemu/OSTypeEdit.js: use new setValues()
* www/manager/dc/UserEdit.js: use new setValues()
* www/manager/node/NetworkEdit.js: use new setValues()
* www/manager/window/Edit.js (getValues, setValues): try to replace
BasicForm.setValues(), make it work with 'inputpanel'
* www/manager/window/Edit.js (submit): do not use
Ext.form.Action.Submit, instead simply use API2Request
* www/manager/window/Edit.js (load): do not use
Ext.form.Action.Load, instead simply use API2Request
* www/manager/dc/UserEdit.js: use onGetValues to workaround ExtJS
datefield behaviour, set expired to 'never' instead of '1970-01-01'
Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/ChangeLog 2011-07-15 10:59:30 UTC (rev 6311)
@@ -1,5 +1,22 @@
2011-07-15 Proxmox Support Team <support at proxmox.com>
+ * www/manager/qemu/*.js: fix success callback
+
+ * www/manager/qemu/OSTypeEdit.js: use new setValues()
+
+ * www/manager/dc/UserEdit.js: use new setValues()
+
+ * www/manager/node/NetworkEdit.js: use new setValues()
+
+ * www/manager/window/Edit.js (getValues, setValues): try to replace
+ BasicForm.setValues(), make it work with 'inputpanel'
+
+ * www/manager/window/Edit.js (submit): do not use
+ Ext.form.Action.Submit, instead simply use API2Request
+
+ * www/manager/window/Edit.js (load): do not use
+ Ext.form.Action.Load, instead simply use API2Request
+
* www/manager/dc/UserEdit.js: use onGetValues to workaround ExtJS
datefield behaviour, set expired to 'never' instead of '1970-01-01'
Modified: pve-manager/pve2/www/manager/dc/GroupEdit.js
===================================================================
--- pve-manager/pve2/www/manager/dc/GroupEdit.js 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/www/manager/dc/GroupEdit.js 2011-07-15 10:59:30 UTC (rev 6311)
@@ -43,17 +43,7 @@
me.callParent();
if (!me.create) {
- me.load({
- success: function(form, action) {
-// if (action.result.data.type !== me.groupid) {
-// var msg = "Got unexpected groupid";
-// Ext.Msg.alert("Load failed", msg, function() {
-// me.close();
-// });
-// return;
-// }
- }
- });
+ me.load();
}
}
});
Modified: pve-manager/pve2/www/manager/dc/UserEdit.js
===================================================================
--- pve-manager/pve2/www/manager/dc/UserEdit.js 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/www/manager/dc/UserEdit.js 2011-07-15 10:59:30 UTC (rev 6311)
@@ -130,8 +130,7 @@
}
return values;
- },
-
+ }
});
Ext.applyIf(me, {
@@ -145,16 +144,17 @@
if (!me.create) {
me.load({
- success: function(form, action) {
- var data = action.result.data;
+ success: function(response, options) {
+ var data = response.result.data;
if (Ext.isDefined(data.expire)) {
if (data.expire) {
- ipanel.setValues({ expire: new Date(data.expire * 1000) });
+ data.expire = new Date(data.expire * 1000);
} else {
// display 'never' instead of '1970-01-01'
- ipanel.setValues({ expire: '' });
+ data.expire = null;
}
}
+ me.setValues(data);
}
});
}
Modified: pve-manager/pve2/www/manager/node/NetworkEdit.js
===================================================================
--- pve-manager/pve2/www/manager/node/NetworkEdit.js 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/www/manager/node/NetworkEdit.js 2011-07-15 10:59:30 UTC (rev 6311)
@@ -143,14 +143,16 @@
me.down('field[name=iface]').setValue(me.iface_default);
} else {
me.load({
- success: function(form, action) {
- if (action.result.data.type !== me.iftype) {
+ success: function(response, options) {
+ var data = response.result.data;
+ if (data.type !== me.iftype) {
var msg = "Got unexpected device type";
Ext.Msg.alert("Load failed", msg, function() {
me.close();
});
return;
}
+ me.setValues(data);
}
});
}
Modified: pve-manager/pve2/www/manager/qemu/CDEdit.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/CDEdit.js 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/www/manager/qemu/CDEdit.js 2011-07-15 10:59:30 UTC (rev 6311)
@@ -174,10 +174,10 @@
me.callParent();
me.load({
- success: function(form, action) {
- ipanel.setVMConfig(action.result.data);
+ success: function(response, options) {
+ ipanel.setVMConfig(response.result.data);
if (me.confid) {
- var value = action.result.data[me.confid];
+ var value = response.result.data[me.confid];
var drive = PVE.Parser.parseQemuDrive(me.confid, value);
if (!drive) {
Ext.Msg.alert('Error', 'Unable to parse drive options');
Modified: pve-manager/pve2/www/manager/qemu/HDEdit.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HDEdit.js 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/www/manager/qemu/HDEdit.js 2011-07-15 10:59:30 UTC (rev 6311)
@@ -205,10 +205,10 @@
me.callParent();
me.load({
- success: function(form, action) {
- ipanel.setVMConfig(action.result.data);
+ success: function(response, options) {
+ ipanel.setVMConfig(response.result.data);
if (me.confid) {
- var value = action.result.data[me.confid];
+ var value = response.result.data[me.confid];
var drive = PVE.Parser.parseQemuDrive(me.confid, value);
if (!drive) {
Ext.Msg.alert('Error', 'Unable to parse drive options');
Modified: pve-manager/pve2/www/manager/qemu/NetworkEdit.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/NetworkEdit.js 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/www/manager/qemu/NetworkEdit.js 2011-07-15 10:59:30 UTC (rev 6311)
@@ -150,9 +150,9 @@
me.callParent();
me.load({
- success: function(form, action) {
+ success: function(response, options) {
var i, confid;
- me.vmconfig = action.result.data;
+ me.vmconfig = response.result.data;
if (!me.create) {
var value = me.vmconfig[me.confid];
var network = PVE.Parser.parseQemuNetwork(me.confid, value);
Modified: pve-manager/pve2/www/manager/qemu/OSTypeEdit.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/OSTypeEdit.js 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/www/manager/qemu/OSTypeEdit.js 2011-07-15 10:59:30 UTC (rev 6311)
@@ -92,9 +92,9 @@
me.callParent();
me.load({
- success: function(form, action) {
- var value = action.result.data.ostype || 'other';
- form.setValues({ ostype: value});
+ success: function(response, options) {
+ var value = response.result.data.ostype || 'other';
+ me.setValues({ ostype: value});
}
});
}
Modified: pve-manager/pve2/www/manager/window/Edit.js
===================================================================
--- pve-manager/pve2/www/manager/window/Edit.js 2011-07-15 07:01:51 UTC (rev 6310)
+++ pve-manager/pve2/www/manager/window/Edit.js 2011-07-15 10:59:30 UTC (rev 6311)
@@ -10,67 +10,103 @@
// OK and RESET)
create: false,
- submit: function(formpanel) {
+ getValues: function(dirtyOnly) {
var me = this;
- var inputpanel = formpanel.child('inputpanel');
+ var values = {};
- if (inputpanel) {
+ var form = me.formPanel.getForm();
- var values = formpanel.getValues();
+ form.getFields().each(function(field) {
+ if (!field.up('inputpanel') && (!dirtyOnly || field.isDirty())) {
+ PVE.Utils.assemble_field_data(values, field.getSubmitData());
+ }
+ });
- var params = inputpanel.onGetValues(values);
+ Ext.Array.each(me.query('inputpanel'), function(panel) {
+ PVE.Utils.assemble_field_data(values, panel.getValues(dirtyOnly));
+ });
- PVE.Utils.API2Request({
- url: me.url,
- method: me.method || 'PUT',
- params: params,
- failure: function(response, opts) {
- Ext.Msg.alert('Error', response.htmlStatus);
- },
- success: function(response, opts) {
- me.close();
- }
- });
+ return values;
+ },
- } else {
- formpanel.submit({
- success: function() {
- me.close();
- },
- failure: function(form, action) {
- Ext.Msg.alert('Error', PVE.Utils.extractFormActionError(action));
+ setValues: function(values) {
+ var me = this;
+
+ var form = me.formPanel.getForm();
+
+ Ext.iterate(values, function(fieldId, val) {
+ var field = form.findField(fieldId);
+ if (field && !field.up('inputpanel')) {
+ field.setValue(val);
+ if (form.trackResetOnLoad) {
+ field.resetOriginalValue();
+ }
+ }
+ });
+
+ Ext.Array.each(me.query('inputpanel'), function(panel) {
+ panel.setValues(values);
+ });
+
+ form.setValues(values);
+ },
+
+ submit: function() {
+ var me = this;
+
+ var form = me.formPanel.getForm();
+
+ var values = me.getValues();
+
+ PVE.Utils.API2Request({
+ url: me.url,
+ method: me.method || 'PUT',
+ params: values,
+ failure: function(response, options) {
+ if (response.result.errors) {
+ form.markInvalid(response.result.errors);
}
- });
- }
+ Ext.Msg.alert('Error', response.htmlStatus);
+ },
+ success: function(response, options) {
+ me.close();
+ }
+ });
},
load: function(options) {
var me = this;
+ var form = me.formPanel.getForm();
+
options = options || {};
var orgSuccessFn = options.success;
- options.success = function(form, action) {
- if (orgSuccessFn) {
- orgSuccessFn(form, action);
- }
- // hack: fix ExtJS bug
- Ext.Array.each(me.query('radiofield'), function(f) {
- f.resetOriginalValue();
- });
- };
var newopts = Ext.apply({}, options, {
+ url: me.url,
method: 'GET',
- failure: function(form, action) {
- var msg = PVE.Utils.extractFormActionError(action);
- Ext.Msg.alert("Load failed", msg, function() {
+ success: function(response, opts) {
+ form.clearInvalid();
+ if (orgSuccessFn) {
+ orgSuccessFn(response, opts);
+ } else {
+ me.setValues(response.result.data);
+ }
+ // hack: fix ExtJS bug
+ Ext.Array.each(me.query('radiofield'), function(f) {
+ f.resetOriginalValue();
+ });
+ },
+ failure: function(response, opts) {
+ Ext.Msg.alert('Error', response.htmlStatus, function() {
me.close();
});
}
});
- me.down('form').load(newopts);
+
+ PVE.Utils.API2Request(newopts);
},
initComponent : function() {
@@ -84,7 +120,7 @@
me.items = undefined;
- var formpanel = Ext.create('Ext.form.Panel', {
+ me.formPanel = Ext.create('Ext.form.Panel', {
url: me.url,
method: me.method || 'PUT',
trackResetOnLoad: true,
@@ -100,13 +136,13 @@
items: items
});
- var form = formpanel.getForm();
+ var form = me.formPanel.getForm();
var submitBtn = Ext.create('Ext.Button', {
text: me.create ? 'Create' : 'OK',
disabled: !me.create,
handler: function() {
- me.submit(formpanel);
+ me.submit();
}
});
@@ -140,7 +176,7 @@
layout: 'auto',
width: twoColumn ? colwidth*2 : colwidth,
border: false,
- items: [ formpanel ],
+ items: [ me.formPanel ],
buttons: me.create ? [ submitBtn ] : [ submitBtn, resetBtn ]
});
More information about the pve-devel
mailing list