[pve-devel] r6225 - in pve-manager/pve2: . www/manager/dc

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Jul 4 08:23:17 CEST 2011


Author: dietmar
Date: 2011-07-04 08:23:17 +0200 (Mon, 04 Jul 2011)
New Revision: 6225

Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/dc/UserEdit.js
   pve-manager/pve2/www/manager/dc/UserView.js
Log:
commit UserEdit patch from Seth - modified to make it work with emtpy values


Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-04 06:11:35 UTC (rev 6224)
+++ pve-manager/pve2/ChangeLog	2011-07-04 06:23:17 UTC (rev 6225)
@@ -1,3 +1,10 @@
+2011-07-01  Seth Lauzon  <seth.lauzon at gmail.com>
+
+	* www/manager/UserView.js: add modify functionality and disallow
+	deletion of user root at pam
+
+	* www/manager/UserEdit.js: add modify functionality
+
 2011-07-01  Proxmox Support Team  <support at proxmox.com>
 
 	* www/manager/PVEUtils.js: do nou use 'singleton: true' - that

Modified: pve-manager/pve2/www/manager/dc/UserEdit.js
===================================================================
--- pve-manager/pve2/www/manager/dc/UserEdit.js	2011-07-04 06:11:35 UTC (rev 6224)
+++ pve-manager/pve2/www/manager/dc/UserEdit.js	2011-07-04 06:23:17 UTC (rev 6225)
@@ -8,60 +8,85 @@
         if (create) {
             title = "Create User";
         } else {
-            title = "Edit User'" + userid + "'";
+            title = "Edit User '" + me.userid + "'";
         }
 
         var url;
         var method;
-        var userid;
 
         if (create) {
             url = '/api2/extjs/access/users';
             method = 'POST';
         } else {
-            url = '/api2/extjs/access/users/' + userid;
+            url = '/api2/extjs/access/users/' + me.userid;
             method = 'PUT';
         }
 
         me.column1 = [
             {
-                xtype: 'pvetextfield',
+                xtype: create ? 'textfield' : 'displayfield',
                 name: 'userid',
                 fieldLabel: 'Userid',
+                value: me.userid,
+                allowBlank: false,
             },
+//            {
+//                xtype: 'pveRealmComboBox',
+//                name: 'realm',
+//                fieldLabel: 'Realm',
+//                allowBlank: false,
+//            },
             {
-                xtype: 'pvetextfield',
-                name: 'firstname',
-                fieldLabel: 'First Name',
-            },
-            {
-                xtype: 'pvetextfield',
+                xtype: 'textfield',
                 name: 'email',
                 fieldLabel: 'Email',
+		vtype: 'email'
             }
         ];
 
         me.column2 = [
             {
-                xtype: 'pvetextfield',
-                name: 'domain',
-                fieldLabel: 'Domain',
+                xtype: 'textfield',
+                name: 'firstname',
+                fieldLabel: 'First Name',
             },
             {
-                xtype: 'pvetextfield',
+                xtype: 'textfield',
                 name: 'lastname',
                 fieldLabel: 'Last Name',
             }
         ];
 
+        if (!create) {
+            me.column1.push({
+                xtype: 'pvecheckbox',
+                fieldLabel: 'Locked',
+                name: 'lock',
+                uncheckedValue: 0
+            });
+        }
+
         Ext.applyIf(me, {
             title: title,
             url: url,
-            method: method,
+            method: method
         });
 
         me.callParent();
 
+        if (!create) {
+            me.load({
+                success: function(form, action) {
+//                    if (action.result.data.type !== me.userid) {
+//                        var msg = "Got unexpected userid";
+//                        Ext.Msg.alert("Load failed", msg, function() {
+//                            me.close();
+//                        });
+//                        return;
+//                    }
+                }
+            });
+        }
     }
 });
 

Modified: pve-manager/pve2/www/manager/dc/UserView.js
===================================================================
--- pve-manager/pve2/www/manager/dc/UserView.js	2011-07-04 06:11:35 UTC (rev 6224)
+++ pve-manager/pve2/www/manager/dc/UserView.js	2011-07-04 06:23:17 UTC (rev 6225)
@@ -36,8 +36,18 @@
             {
 		text: 'Modify',
 		handler: function() {
-		    var msg = 'This feature is not implemented yet!';
-		    Ext.Msg.alert('Not Implemented', msg);
+		    var sm = me.getSelectionModel();
+		    var rec = sm.getSelection()[0];
+		    if (!rec)
+			return;
+
+		    var userid = rec.data.userid;
+
+                    var win = Ext.create('PVE.dc.UserEdit',{
+                        userid: userid,
+                    });
+                    win.on('destroy', reload);
+                    win.show();
 		}
             },
             {
@@ -50,24 +60,29 @@
 
 		    var userid = rec.data.userid;
 
-		    var msg = 'Are you sure you want to permanently delete the user: ' + userid;
-		    Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
-			if (btn !== 'yes')
-			    return;
+		    if (userid !== 'root at pam') {
+			var msg = 'Are you sure you want to permanently delete the user: ' + userid;
+			Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
+			    if (btn !== 'yes')
+				return;
 
-			me.setLoading(true, true);
-			PVE.Utils.API2Request({
-			    url: '/access/users/' + userid,
-			    method: 'DELETE',
-			    callback: function() {
-				me.setLoading(false);
-				reload();
-			    },
-			    failure: function (response, opts) {
-				Ext.Msg.alert('Error',response.htmlStatus);
-			    },
+			    me.setLoading(true, true);
+			    PVE.Utils.API2Request({
+				url: '/access/users/' + userid,
+				method: 'DELETE',
+				callback: function() {
+				    me.setLoading(false);
+				    reload();
+				},
+				failure: function (response, opts) {
+				    Ext.Msg.alert('Error',response.htmlStatus);
+				}
+			    });
 			});
-		    });
+		    } else {
+			var msg = 'You are not permitted to delete the user: root at pam';
+			Ext.Msg.alert('Error', msg);
+		    }
 		}
             }
         ];




More information about the pve-devel mailing list