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

svn-commits at proxmox.com svn-commits at proxmox.com
Mon May 30 13:49:19 CEST 2011


Author: dietmar
Date: 2011-05-30 13:49:19 +0200 (Mon, 30 May 2011)
New Revision: 6045

Added:
   pve-manager/pve2/www/new/dc/UserView.js
Modified:
   pve-manager/pve2/www/new/Makefile.am
   pve-manager/pve2/www/new/dc/Config.js
Log:
impl. UserView


Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am	2011-05-30 11:23:08 UTC (rev 6044)
+++ pve-manager/pve2/www/new/Makefile.am	2011-05-30 11:49:19 UTC (rev 6045)
@@ -56,6 +56,7 @@
 	qemu/CreateWizard.js				\
 	openvz/CreateWizard.js				\
 	storage/Browser.js				\
+	dc/UserView.js					\
 	dc/Config.js					\
 	Workspace.js
 

Modified: pve-manager/pve2/www/new/dc/Config.js
===================================================================
--- pve-manager/pve2/www/new/dc/Config.js	2011-05-30 11:23:08 UTC (rev 6044)
+++ pve-manager/pve2/www/new/dc/Config.js	2011-05-30 11:49:19 UTC (rev 6045)
@@ -20,7 +20,7 @@
 		    html: 'storage '
 		},
 		{
-		    //xtype: 'pveUserView',
+		    xtype: 'pveUserView',
 		    title: 'Users',
 		    itemId: 'users'
 		},

Added: pve-manager/pve2/www/new/dc/UserView.js
===================================================================
--- pve-manager/pve2/www/new/dc/UserView.js	                        (rev 0)
+++ pve-manager/pve2/www/new/dc/UserView.js	2011-05-30 11:49:19 UTC (rev 6045)
@@ -0,0 +1,111 @@
+Ext.define('PVE.dc.UserView', {
+    extend: 'Ext.grid.GridPanel',
+
+    alias: ['widget.pveUserView'],
+
+    initComponent : function() {
+	var me = this;
+
+	var store = new Ext.data.Store({
+	    model: Ext.define('pve-users', {
+		extend: 'Ext.data.Model',
+		fields: [ 
+		    'userid', 'firstname', 'lastname' , 'email', 'comment',
+		    { type: 'boolean', name: 'enabled' }, 
+		    { type: 'date', dateFormat: 'timestamp', name: 'expire' },
+		],
+		idProperty: 'userid'
+	    }),
+	    proxy: {
+                type: 'pve',
+		url: "/api2/json/access/users"
+	    },
+	    sorters: { 
+		property: 'userid', 
+		order: 'DESC' 
+	    }
+	});
+
+	var render_expire = function(date) {
+	    if (!date)
+		return 'never';
+
+	    return Ext.Date.format(date, "Y-m-d");
+	};
+
+	var render_full_name = function(firstname, metaData, record) {
+
+	    var first = firstname || '';
+	    var last = record.data.lastname || '';
+	    return first + " " + last;
+	};
+
+	var render_username = function(userid) {
+	    return userid.match(/^([^@]+)/)[1];
+	};
+
+	var render_realm = function(userid) {
+	    return userid.match(/@([^@]+)$/)[1];
+	};
+
+	Ext.apply(me, {
+	    store: store,
+	    stateful: false,
+
+	    viewConfig: {
+		trackOver: false
+	    },
+
+	    columns: [
+		{
+		    header: 'User name',
+		    width: 200,
+		    sortable: true,
+		    renderer: render_username,
+		    dataIndex: 'userid'
+		},
+		{
+		    header: 'Realm',
+		    width: 100,
+		    sortable: true,
+		    renderer: render_realm,
+		    dataIndex: 'userid'
+		},
+		{
+		    header: 'Enabled',
+		    width: 80,
+		    sortable: true,
+		    dataIndex: 'enabled'
+		},
+		{
+		    header: 'Expire',
+		    width: 80,
+		    sortable: true,
+		    renderer: render_expire, 
+		    dataIndex: 'expire'
+		},
+		{
+		    header: 'Name',
+		    width: 150,
+		    sortable: true,
+		    renderer: render_full_name,
+		    dataIndex: 'firstname'
+		},
+		{
+		    id: 'comment',
+		    header: 'Comment',
+		    sortable: false,
+		    dataIndex: 'comment',
+		    flex: 1
+		}
+	    ],
+	    listeners: {
+		show: function() {
+		    store.load();
+		}
+	    }
+	});
+
+	me.callParent();
+    }
+});
\ No newline at end of file




More information about the pve-devel mailing list