[pve-devel] r5991 - in pve-manager/pve2/www/new: . node
svn-commits at proxmox.com
svn-commits at proxmox.com
Wed May 18 07:39:51 CEST 2011
Author: dietmar
Date: 2011-05-18 07:39:51 +0200 (Wed, 18 May 2011)
New Revision: 5991
Added:
pve-manager/pve2/www/new/node/DNSEdit.js
Modified:
pve-manager/pve2/www/new/Makefile.am
pve-manager/pve2/www/new/PVEUtils.js
pve-manager/pve2/www/new/node/DNSView.js
pve-manager/pve2/www/new/node/TimeEdit.js
Log:
mpl. DNSEdit
Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am 2011-05-18 04:48:26 UTC (rev 5990)
+++ pve-manager/pve2/www/new/Makefile.am 2011-05-18 05:39:51 UTC (rev 5991)
@@ -30,6 +30,7 @@
grid/ResourceGrid.js \
tree/ResourceTree.js \
panel/ConfigPanel.js \
+ node/DNSEdit.js \
node/DNSView.js \
node/TimeView.js \
node/TimeEdit.js \
Modified: pve-manager/pve2/www/new/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/new/PVEUtils.js 2011-05-18 04:48:26 UTC (rev 5990)
+++ pve-manager/pve2/www/new/PVEUtils.js 2011-05-18 05:39:51 UTC (rev 5991)
@@ -55,6 +55,50 @@
//return 21;
},
+ extractRequestError: function(result, verbose) {
+ var msg = 'Successful';
+
+ if (!result.success) {
+ var msg = "Unknown error";
+ if (result.message) {
+ msg = result.message;
+ if (result.status)
+ msg += ' (' + result.status + ')';
+ }
+ if (verbose && Ext.isObject(result.errors)) {
+ msg += "<br>";
+ Ext.Object.each(result.errors, function(prop, desc) {
+ msg += "<br><b>" + Ext.htmlEncode(prop) + "</b>: " +
+ Ext.htmlEncode(desc);
+ });
+ }
+ }
+
+ return msg;
+ },
+
+ extractFormActionError: function(action) {
+ var msg;
+ console.log("TEST " + action.failureType);
+ console.dir(action);
+ switch (action.failureType) {
+ case Ext.form.action.Action.CLIENT_INVALID:
+ msg = 'Form fields may not be submitted with invalid values';
+ break;
+ case Ext.form.action.Action.CONNECT_FAILURE:
+ msg = 'Connect failure';
+ var resp = action.response;
+ if (resp.status && resp.statusText)
+ msg += " " + resp.status + ": " + resp.statusText;
+ break;
+ case Ext.form.action.Action.LOAD_FAILURE:
+ case Ext.form.action.Action.SERVER_INVALID:
+ msg = PVE.Utils.extractRequestError(action.result, true);
+ break;
+ }
+ return msg;
+ },
+
// Ext.Ajax.request
API2Request: function(options) {
var callbackFn = options.callback;
@@ -68,20 +112,7 @@
options.success = function(response, options) {
var result = Ext.decode(response.responseText);
if (!result.success) {
- var msg = "Unknown error";
- if (result.message) {
- msg = result.message;
- if (result.status)
- msg += ' (' + result.status + ')';
- }
- if (Ext.isObject(result.errors)) {
- msg += "<br>";
- Ext.Object.each(result.errors, function(prop, desc) {
- msg += "<br><b>" + Ext.htmlEncode(prop) + "</b>: " +
- Ext.htmlEncode(desc);
- });
- }
- response.htmlStatus = msg;
+ response.htmlStatus = PVE.Utils.extractRequestError(result, true);
Ext.callback(callbackFn, options.scope, [options, false, response])
Ext.callback(failureFn, options.scope, [response, options])
return;
Added: pve-manager/pve2/www/new/node/DNSEdit.js
===================================================================
--- pve-manager/pve2/www/new/node/DNSEdit.js (rev 0)
+++ pve-manager/pve2/www/new/node/DNSEdit.js 2011-05-18 05:39:51 UTC (rev 5991)
@@ -0,0 +1,114 @@
+Ext.define('PVE.node.DNSEdit', {
+ extend: 'Ext.window.Window',
+ requires: [
+ 'PVE.Utils'
+ ],
+
+ alias: ['widget.pveNodeDNSEdit'],
+
+ initComponent : function() {
+ var me = this;
+
+ var nodename = me.pveSelNode.data.node;
+ if (!nodename)
+ throw "no node name specified";
+
+ var formpanel = Ext.create('Ext.form.Panel', {
+ url: "/api2/extjs/nodes/" + nodename + "/dns",
+ method: 'PUT',
+ trackResetOnLoad: true,
+ bodyPadding: 10,
+
+ fieldDefaults: {
+ labelWidth: 130,
+ anchor: '100%'
+ },
+ items: [
+ {
+ xtype: 'textfield',
+ fieldLabel: 'Search domain',
+ name: 'search',
+ allowBlank: false
+ },
+ {
+ xtype: 'textfield',
+ fieldLabel: 'First DNS server',
+ name: 'dns1'
+ },
+ {
+ xtype: 'textfield',
+ fieldLabel: 'Second DNS server',
+ name: 'dns2'
+ },
+ {
+ xtype: 'textfield',
+ fieldLabel: 'Third DNS server',
+ name: 'dns3'
+ }
+ ]
+ });
+
+ 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();
+ }
+ });
+
+ form.on('dirtychange', function(form, dirty){
+ submitBtn.setDisabled(!dirty);
+ resetBtn.setDisabled(!dirty);
+ });
+
+ formpanel.load({
+ method: 'GET',
+ failure: function(form, action) {
+ var msg = PVE.Utils.extractFormActionError(action);
+ Ext.Msg.alert("Load failed", msg, function() {
+ me.close();
+ });
+ }
+ });
+
+
+ Ext.applyIf(me, {
+ title: "Edit DNS settings",
+ modal: true,
+ width: 400,
+ height: 200,
+ layout: 'fit',
+ border: false,
+ items: formpanel,
+ buttons: [
+ submitBtn,
+ resetBtn,
+ {
+ text: 'Cancel',
+ handler: function(){
+ me.close();
+ }
+ }
+ ]
+ });
+
+ me.callParent();
+ }
+});
Modified: pve-manager/pve2/www/new/node/DNSView.js
===================================================================
--- pve-manager/pve2/www/new/node/DNSView.js 2011-05-18 04:48:26 UTC (rev 5990)
+++ pve-manager/pve2/www/new/node/DNSView.js 2011-05-18 05:39:51 UTC (rev 5991)
@@ -19,7 +19,7 @@
Ext.applyIf(me, {
url: "/api2/json/nodes/" + nodename + "/dns",
- cwidth1: 150,
+ cwidth1: 130,
interval: 1000,
rows: {
search: { header: 'Search domain', required: true },
Modified: pve-manager/pve2/www/new/node/TimeEdit.js
===================================================================
--- pve-manager/pve2/www/new/node/TimeEdit.js 2011-05-18 04:48:26 UTC (rev 5990)
+++ pve-manager/pve2/www/new/node/TimeEdit.js 2011-05-18 05:39:51 UTC (rev 5991)
@@ -1,7 +1,7 @@
Ext.define('PVE.node.TimeEdit', {
extend: 'Ext.window.Window',
requires: ['PVE.data.TimezoneStore'],
- alias: ['widget.PVE.node.TimeEdit'],
+ alias: ['widget.pveNodeTimeEdit'],
initComponent : function() {
var me = this;
@@ -14,7 +14,7 @@
url: "/api2/extjs/nodes/" + nodename + "/time",
method: 'PUT',
trackResetOnLoad: true,
- bodyPadding: 5,
+ bodyPadding: 10,
fieldDefaults: {
labelWidth: 80,
@@ -47,17 +47,7 @@
me.close();
},
failure: function(form, action) {
- switch (action.failureType) {
- case Ext.form.action.Action.CLIENT_INVALID:
- Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
- break;
- case Ext.form.action.Action.CONNECT_FAILURE:
- Ext.Msg.alert('Failure', 'Ajax communication failed');
- break;
- case Ext.form.action.Action.SERVER_INVALID:
- console.dir(action);
- Ext.Msg.alert('Failure', action.result.message);
- }
+ Ext.Msg.alert('Error', PVE.Utils.extractFormActionError(action));
}
});
}
@@ -77,16 +67,15 @@
});
formpanel.load({
- url: "/api2/extjs/nodes/" + nodename + "/time",
method: 'GET',
failure: function(form, action) {
- Ext.Msg.alert("Load failed", action.result.message, function() {
+ var msg = PVE.Utils.extractFormActionError(action);
+ Ext.Msg.alert("Load failed", msg, function() {
me.close();
});
}
});
-
Ext.applyIf(me, {
title: "Set time zone",
modal: true,
More information about the pve-devel
mailing list