improve user grid

This commit is contained in:
Sebastian Sdorra
2010-12-05 17:46:26 +01:00
parent 56b6b808c3
commit f69dceb729
3 changed files with 68 additions and 34 deletions

View File

@@ -39,6 +39,7 @@ import sonia.scm.TypedObject;
import sonia.scm.Validateable; import sonia.scm.Validateable;
import sonia.scm.util.Util; import sonia.scm.util.Util;
import sonia.scm.util.ValidationUtil; import sonia.scm.util.ValidationUtil;
import sonia.scm.xml.XmlTimestampDateAdapter;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
@@ -49,7 +50,7 @@ import java.security.Principal;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/** /**
* *
@@ -57,10 +58,6 @@ import javax.xml.bind.annotation.XmlType;
*/ */
@XmlRootElement(name = "users") @XmlRootElement(name = "users")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder =
{
"name", "displayName", "mail", "password", "admin", "type", "lastLogin"
})
public class User public class User
implements TypedObject, Principal, Cloneable, Validateable, Serializable implements TypedObject, Principal, Cloneable, Validateable, Serializable
{ {
@@ -226,6 +223,17 @@ public class User
//~--- get methods ---------------------------------------------------------- //~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public long getCreationDate()
{
return creationDate;
}
/** /**
* Method description * Method description
* *
@@ -332,6 +340,17 @@ public class User
this.admin = admin; this.admin = admin;
} }
/**
* Method description
*
*
* @param creationDate
*/
public void setCreationDate(long creationDate)
{
this.creationDate = creationDate;
}
/** /**
* Method description * Method description
* *
@@ -404,11 +423,16 @@ public class User
/** Field description */ /** Field description */
private boolean admin; private boolean admin;
/** Field description */
@XmlJavaTypeAdapter(XmlTimestampDateAdapter.class)
private Long creationDate;
/** Field description */ /** Field description */
private String displayName; private String displayName;
/** Field description */ /** Field description */
private long lastLogin; @XmlJavaTypeAdapter(XmlTimestampDateAdapter.class)
private Long lastLogin;
/** Field description */ /** Field description */
private String mail; private String mail;

View File

@@ -165,6 +165,8 @@ public class XmlUserManager extends AbstractUserManager
user.setType(TYPE); user.setType(TYPE);
} }
user.setCreationDate(System.currentTimeMillis());
synchronized (XmlUserManager.class) synchronized (XmlUserManager.class)
{ {
userDB.add(user.clone()); userDB.add(user.clone());

View File

@@ -60,7 +60,7 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
var userStore = new Sonia.rest.JsonStore({ var userStore = new Sonia.rest.JsonStore({
url: restUrl + 'users.json', url: restUrl + 'users.json',
root: 'users', root: 'users',
fields: [ 'name', 'displayName', 'mail', 'admin', 'type'], fields: [ 'name', 'displayName', 'mail', 'admin', 'creationDate', 'lastLogin', 'type'],
sortInfo: { sortInfo: {
field: 'name' field: 'name'
} }
@@ -77,6 +77,8 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
{id: 'displayName', header: 'Display Name', dataIndex: 'displayName', width: 250}, {id: 'displayName', header: 'Display Name', dataIndex: 'displayName', width: 250},
{id: 'mail', header: 'Mail', dataIndex: 'mail', renderer: this.renderMailto, width: 200}, {id: 'mail', header: 'Mail', dataIndex: 'mail', renderer: this.renderMailto, width: 200},
{id: 'admin', header: 'Admin', dataIndex: 'admin', renderer: this.renderCheckbox, width: 50}, {id: 'admin', header: 'Admin', dataIndex: 'admin', renderer: this.renderCheckbox, width: 50},
{id: 'creationDate', header: 'Creation date', dataIndex: 'creationDate'},
{id: 'lastLogin', header: 'Last login', dataIndex: 'lastLogin'},
{id: 'type', header: 'Type', dataIndex: 'type', width: 80} {id: 'type', header: 'Type', dataIndex: 'type', width: 80}
] ]
}); });
@@ -108,10 +110,12 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
scope: this scope: this
} }
}); });
if ( item.type == 'xml' ){
panel.getForm().setValues([ panel.getForm().setValues([
{id: 'password', value: dummyPassword}, {id: 'password', value: dummyPassword},
{id: 'password-confirm', value: dummyPassword} {id: 'password-confirm', value: dummyPassword}
]); ]);
}
Sonia.user.setEditPanel(panel); Sonia.user.setEditPanel(panel);
} }
@@ -138,8 +142,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
initComponent: function(){ initComponent: function(){
var config = { var items = [{
items: [{
fieldLabel: 'Name', fieldLabel: 'Name',
name: 'name', name: 'name',
allowBlank: false, allowBlank: false,
@@ -153,7 +156,10 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
name: 'mail', name: 'mail',
allowBlank: false, allowBlank: false,
vtype: 'email' vtype: 'email'
},{ }];
if ( this.item == null || this.item.type == 'xml' ){
items.push({
fieldLabel: 'Password', fieldLabel: 'Password',
id: 'pwd', id: 'pwd',
name: 'password', name: 'password',
@@ -169,14 +175,16 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
minLengthText: 'Password must be at least 6 characters long.', minLengthText: 'Password must be at least 6 characters long.',
vtype: 'password', vtype: 'password',
initialPassField: 'pwd' initialPassField: 'pwd'
},{ });
}
items.push({
fieldLabel: 'Administrator', fieldLabel: 'Administrator',
name: 'admin', name: 'admin',
xtype: 'checkbox' xtype: 'checkbox'
}] });
};
Ext.apply(this, Ext.apply(this.initialConfig, config)); Ext.apply(this, Ext.apply(this.initialConfig, {items: items}));
Sonia.user.FormPanel.superclass.initComponent.apply(this, arguments); Sonia.user.FormPanel.superclass.initComponent.apply(this, arguments);
}, },