mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
improve user grid
This commit is contained in:
@@ -39,6 +39,7 @@ import sonia.scm.TypedObject;
|
||||
import sonia.scm.Validateable;
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.util.ValidationUtil;
|
||||
import sonia.scm.xml.XmlTimestampDateAdapter;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -49,7 +50,7 @@ import java.security.Principal;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
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")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(propOrder =
|
||||
{
|
||||
"name", "displayName", "mail", "password", "admin", "type", "lastLogin"
|
||||
})
|
||||
public class User
|
||||
implements TypedObject, Principal, Cloneable, Validateable, Serializable
|
||||
{
|
||||
@@ -226,6 +223,17 @@ public class User
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getCreationDate()
|
||||
{
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -332,6 +340,17 @@ public class User
|
||||
this.admin = admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param creationDate
|
||||
*/
|
||||
public void setCreationDate(long creationDate)
|
||||
{
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -404,11 +423,16 @@ public class User
|
||||
/** Field description */
|
||||
private boolean admin;
|
||||
|
||||
/** Field description */
|
||||
@XmlJavaTypeAdapter(XmlTimestampDateAdapter.class)
|
||||
private Long creationDate;
|
||||
|
||||
/** Field description */
|
||||
private String displayName;
|
||||
|
||||
/** Field description */
|
||||
private long lastLogin;
|
||||
@XmlJavaTypeAdapter(XmlTimestampDateAdapter.class)
|
||||
private Long lastLogin;
|
||||
|
||||
/** Field description */
|
||||
private String mail;
|
||||
|
||||
@@ -165,6 +165,8 @@ public class XmlUserManager extends AbstractUserManager
|
||||
user.setType(TYPE);
|
||||
}
|
||||
|
||||
user.setCreationDate(System.currentTimeMillis());
|
||||
|
||||
synchronized (XmlUserManager.class)
|
||||
{
|
||||
userDB.add(user.clone());
|
||||
|
||||
@@ -60,7 +60,7 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
var userStore = new Sonia.rest.JsonStore({
|
||||
url: restUrl + 'users.json',
|
||||
root: 'users',
|
||||
fields: [ 'name', 'displayName', 'mail', 'admin', 'type'],
|
||||
fields: [ 'name', 'displayName', 'mail', 'admin', 'creationDate', 'lastLogin', 'type'],
|
||||
sortInfo: {
|
||||
field: 'name'
|
||||
}
|
||||
@@ -77,6 +77,8 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
{id: 'displayName', header: 'Display Name', dataIndex: 'displayName', width: 250},
|
||||
{id: 'mail', header: 'Mail', dataIndex: 'mail', renderer: this.renderMailto, width: 200},
|
||||
{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}
|
||||
]
|
||||
});
|
||||
@@ -108,10 +110,12 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
scope: this
|
||||
}
|
||||
});
|
||||
if ( item.type == 'xml' ){
|
||||
panel.getForm().setValues([
|
||||
{id: 'password', value: dummyPassword},
|
||||
{id: 'password-confirm', value: dummyPassword}
|
||||
]);
|
||||
}
|
||||
Sonia.user.setEditPanel(panel);
|
||||
}
|
||||
|
||||
@@ -138,8 +142,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var config = {
|
||||
items: [{
|
||||
var items = [{
|
||||
fieldLabel: 'Name',
|
||||
name: 'name',
|
||||
allowBlank: false,
|
||||
@@ -153,7 +156,10 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
name: 'mail',
|
||||
allowBlank: false,
|
||||
vtype: 'email'
|
||||
},{
|
||||
}];
|
||||
|
||||
if ( this.item == null || this.item.type == 'xml' ){
|
||||
items.push({
|
||||
fieldLabel: 'Password',
|
||||
id: 'pwd',
|
||||
name: 'password',
|
||||
@@ -169,14 +175,16 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
minLengthText: 'Password must be at least 6 characters long.',
|
||||
vtype: 'password',
|
||||
initialPassField: 'pwd'
|
||||
},{
|
||||
});
|
||||
}
|
||||
|
||||
items.push({
|
||||
fieldLabel: 'Administrator',
|
||||
name: 'admin',
|
||||
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);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user