[pve-devel] r6342 - in pve-manager/pve2: . www/manager www/manager/dc www/manager/storage www/manager/window

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jul 21 12:23:41 CEST 2011


Author: dietmar
Date: 2011-07-21 12:23:41 +0200 (Thu, 21 Jul 2011)
New Revision: 6342

Added:
   pve-manager/pve2/www/manager/storage/NFSEdit.js
Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/Makefile.am
   pve-manager/pve2/www/manager/Utils.js
   pve-manager/pve2/www/manager/dc/StorageView.js
   pve-manager/pve2/www/manager/storage/DirEdit.js
   pve-manager/pve2/www/manager/window/Edit.js
Log:
	* www/manager/storage/NFSEdit.js: impl.

	* www/manager/Utils.js: new waitMsgTarget option (mask el), better
	error messages



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-21 08:10:31 UTC (rev 6341)
+++ pve-manager/pve2/ChangeLog	2011-07-21 10:23:41 UTC (rev 6342)
@@ -1,5 +1,10 @@
 2011-07-21  Proxmox Support Team  <support at proxmox.com>
 
+	* www/manager/storage/NFSEdit.js: impl.
+
+	* www/manager/Utils.js: new waitMsgTarget option (mask el), better
+	error messages
+
 	* www/manager/form/StorageSelector.js: display 'avail' instead of
 	'used'
 

Modified: pve-manager/pve2/www/manager/Makefile.am
===================================================================
--- pve-manager/pve2/www/manager/Makefile.am	2011-07-21 08:10:31 UTC (rev 6341)
+++ pve-manager/pve2/www/manager/Makefile.am	2011-07-21 10:23:41 UTC (rev 6342)
@@ -84,6 +84,7 @@
 	storage/Summary.js				\
 	storage/Browser.js				\
 	storage/DirEdit.js				\
+	storage/NFSEdit.js				\
 	dc/StorageView.js				\
 	dc/UserEdit.js					\
 	dc/UserView.js					\

Modified: pve-manager/pve2/www/manager/Utils.js
===================================================================
--- pve-manager/pve2/www/manager/Utils.js	2011-07-21 08:10:31 UTC (rev 6341)
+++ pve-manager/pve2/www/manager/Utils.js	2011-07-21 10:23:41 UTC (rev 6342)
@@ -249,16 +249,21 @@
     // Ext.Ajax.request
     API2Request: function(reqOpts) {
 
-	var newopts = Ext.apply({}, reqOpts);
+	var newopts = Ext.apply({
+	    waitMsg: 'Please wait...'
+	}, reqOpts);
 
 	if (!newopts.url.match(/^\/api2/)) {
 	    newopts.url = '/api2/extjs' + newopts.url;
 	}
 	delete newopts.callback;
 
-	var createWrapper = function(successFn, callbackFn, failureFn) {
+ 	var createWrapper = function(successFn, callbackFn, failureFn) {
 	    Ext.apply(newopts, {
 		success: function(response, options) {
+		    if (options.waitMsgTarget) {
+			options.waitMsgTarget.unmask();
+		    }
 		    var result = Ext.decode(response.responseText);
 		    response.result = result;
 		    if (!result.success) {
@@ -271,9 +276,18 @@
 		    Ext.callback(successFn, options.scope, [response, options]);
 		},
 		failure: function(response, options) {
+		    if (options.waitMsgTarget) {
+			options.waitMsgTarget.unmask();
+		    }
+		    var result = Ext.decode(response.responseText);
+		    response.result = result || {};
 		    var msg = "Connection error - server offline?";
-		    if (response.status && response.statusText) {
-			msg = "Connection error " + response.status + ": " + response.statusText;
+		    if (response.aborted) {
+			msg = 'Transaction aborted.';
+		    } else if (response.timedout) {
+			msg = 'Communication failure: Timeout.';
+		    } else if (response.status && response.statusText) {
+			msg = 'Connection error ' + response.status + ': ' + response.statusText;
 		    }
 		    response.htmlStatus = msg;
 		    Ext.callback(callbackFn, options.scope, [options, false, response]);
@@ -284,6 +298,9 @@
 
 	createWrapper(reqOpts.success, reqOpts.callback, reqOpts.failure);
 
+	if (newopts.waitMsgTarget) {
+	    newopts.waitMsgTarget.mask(newopts.waitMsg, 'x-mask-loading');
+	}
 	Ext.Ajax.request(newopts);
     },
 

Modified: pve-manager/pve2/www/manager/dc/StorageView.js
===================================================================
--- pve-manager/pve2/www/manager/dc/StorageView.js	2011-07-21 08:10:31 UTC (rev 6341)
+++ pve-manager/pve2/www/manager/dc/StorageView.js	2011-07-21 10:23:41 UTC (rev 6342)
@@ -33,6 +33,8 @@
 	    var editor;
 	    if (type === 'dir') {
 		editor = 'PVE.storage.DirEdit';
+	    } else if (type === 'nfs') {
+		editor = 'PVE.storage.NFSEdit';
 	    } else {
 		return;
 	    }
@@ -125,7 +127,12 @@
 			    },
 			    {
 				text: 'NFS share',
-				iconCls: 'pve-itype-icon-node'
+				iconCls: 'pve-itype-icon-node',
+				handler: function() {
+				    var win = Ext.create('PVE.storage.NFSEdit', {});
+				    win.on('destroy', reload);
+				    win.show();
+				}
 			    },
 			    {
 				text: 'iSCSI target',
@@ -172,11 +179,11 @@
 		    renderer: PVE.Utils.format_boolean
 		},
 		{
-		    header: 'Disable',
+		    header: 'Enable',
 		    width: 80,
 		    sortable: true,
 		    dataIndex: 'disable',
-		    renderer: PVE.Utils.format_boolean
+		    renderer: PVE.Utils.format_neg_boolean
 		}
 	    ],
 	    listeners: {

Modified: pve-manager/pve2/www/manager/storage/DirEdit.js
===================================================================
--- pve-manager/pve2/www/manager/storage/DirEdit.js	2011-07-21 08:10:31 UTC (rev 6341)
+++ pve-manager/pve2/www/manager/storage/DirEdit.js	2011-07-21 10:23:41 UTC (rev 6342)
@@ -4,13 +4,15 @@
     onGetValues: function(values) {
 	var me = this;
 
-	values.type = 'dir';
-
-	if (!me.create) {
-	    delete values.type;
+	if (me.create) {
+	    values.type = 'dir';
+	} else {
 	    delete values.storage;
 	}
-	
+
+	values.disable = values.enable ? 0 : 1;	    
+	delete values.enable;
+
 	return values;
     },
 
@@ -49,9 +51,10 @@
 	me.column2 = [
 	    {
 		xtype: 'pvecheckbox',
-		name: 'disable',
+		name: 'enable',
+		checked: true,
 		uncheckedValue: 0,
-		fieldLabel: 'Disable'
+		fieldLabel: 'Enable'
 	    },
 	    {
 		xtype: 'pvecheckbox',
@@ -103,6 +106,7 @@
 		    if (values.storage === 'local') {
 			values.content = ctypes.split(',');
 		    }
+		    values.enable = values.disable ? 0 : 1;
 
 		    ipanel.setValues(values);
 		}

Added: pve-manager/pve2/www/manager/storage/NFSEdit.js
===================================================================
--- pve-manager/pve2/www/manager/storage/NFSEdit.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/storage/NFSEdit.js	2011-07-21 10:23:41 UTC (rev 6342)
@@ -0,0 +1,117 @@
+Ext.define('PVE.storage.NFSInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+
+    onGetValues: function(values) {
+	var me = this;
+
+	if (me.create) {
+	    values.type = 'nfs';
+	} else {
+	    delete values.storage;
+	}
+
+	values.disable = values.enable ? 0 : 1;	    
+	delete values.enable;
+	
+	return values;
+    },
+
+    initComponent : function() {
+	var me = this;
+
+
+	me.column1 = [
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'storage',
+		height: 22, // hack: set same height as text fields
+		value: me.storageId || '',
+		fieldLabel: 'Storage ID',
+		vtype: 'StorageId',
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		height: 22, // hack: set same height as text fields
+		name: 'server',
+		value: '',
+		fieldLabel: 'Server',
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		height: 22, // hack: set same height as text fields
+		name: 'export',
+		value: '',
+		fieldLabel: 'Export',
+		allowBlank: false
+	    },
+	    {
+		xtype: 'pveContentTypeSelector',
+		name: 'content',
+		value: 'images',
+		multiSelect: me.storageId === 'local',
+		fieldLabel: 'Content',
+		allowBlank: false
+	    }
+	];
+
+	me.column2 = [
+	    {
+		xtype: 'pvecheckbox',
+		name: 'enable',
+		checked: true,
+		uncheckedValue: 0,
+		fieldLabel: 'Enable'
+	    }
+	];
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.storage.NFSEdit', {
+    extend: 'PVE.window.Edit',
+
+    initComponent : function() {
+	var me = this;
+ 
+	me.create = !me.storageId;
+
+	if (me.create) {
+            me.url = '/api2/extjs/storage';
+            me.method = 'POST';
+        } else {
+            me.url = '/api2/extjs/storage/' + me.storageId;
+            me.method = 'PUT';
+        }
+
+	var ipanel = Ext.create('PVE.storage.NFSInputPanel', {
+	    create: me.create,
+	    storageId: me.storageId
+	});
+	
+	Ext.apply(me, {
+	    title: me.create ? "Create NFS storage" :
+		"Edit NFS storage '" + me.storageId + "'",
+	    items: [ ipanel ]
+	});
+
+	me.callParent();
+
+	if (!me.create) {
+	    me.load({
+		success:  function(response, options) {
+		    var values = response.result.data;
+		    var ctypes = values.content || '';
+
+		    if (values.storage === 'local') {
+			values.content = ctypes.split(',');
+		    }
+		    values.enable = values.disable ? 0 : 1;
+		    ipanel.setValues(values);
+		}
+	    });
+	}
+    }
+});

Modified: pve-manager/pve2/www/manager/window/Edit.js
===================================================================
--- pve-manager/pve2/www/manager/window/Edit.js	2011-07-21 08:10:31 UTC (rev 6341)
+++ pve-manager/pve2/www/manager/window/Edit.js	2011-07-21 10:23:41 UTC (rev 6342)
@@ -68,6 +68,7 @@
 
 	PVE.Utils.API2Request({
 	    url: me.url,
+	    waitMsgTarget: me.getTargetEl(),
 	    method: me.method || 'PUT',
 	    params: values,
 	    failure: function(response, options) {
@@ -89,7 +90,9 @@
 
 	options = options || {};
 
-	var newopts = Ext.apply({}, options);
+	var newopts = Ext.apply({
+	    waitMsgTarget: me.getTargetEl()
+	}, options);
 
 	var createWrapper = function(successFn) {
 	    Ext.apply(newopts, {




More information about the pve-devel mailing list