mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
added admin flag to user
This commit is contained in:
@@ -59,7 +59,7 @@ import javax.xml.bind.annotation.XmlType;
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(propOrder =
|
||||
{
|
||||
"name", "displayName", "mail", "password", "type"
|
||||
"name", "displayName", "mail", "password", "admin", "type"
|
||||
})
|
||||
public class User
|
||||
implements TypedObject, Principal, Cloneable, Validateable, Serializable
|
||||
@@ -267,6 +267,17 @@ public class User
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isAdmin()
|
||||
{
|
||||
return admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -283,6 +294,17 @@ public class User
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param admin
|
||||
*/
|
||||
public void setAdmin(boolean admin)
|
||||
{
|
||||
this.admin = admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -341,6 +363,9 @@ public class User
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private boolean admin;
|
||||
|
||||
/** Field description */
|
||||
private String displayName;
|
||||
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
<displayName>SCM Administrator</displayName>
|
||||
<mail>scm-admin@scm-manager.com</mail>
|
||||
<password>ff8f5c593a01f9fcd3ed48b09a4b013e8d8f3be7</password>
|
||||
<admin>true</admin>
|
||||
<type>xml</type>
|
||||
</users>
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
@@ -36,6 +38,7 @@ package sonia.scm.api.rest;
|
||||
import sonia.scm.ScmState;
|
||||
import sonia.scm.group.Group;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.user.User;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -70,8 +73,8 @@ public class JsonJaxbContextResolver implements ContextResolver<JAXBContext>
|
||||
JSONConfiguration.mapped().rootUnwrapping(true).arrays(
|
||||
"member", "groups", "permissions", "repositories",
|
||||
"repositoryTypes").nonStrings(
|
||||
"readable", "writeable", "groupPermission").build(), types.toArray(
|
||||
new Class[0]));
|
||||
"readable", "writeable", "groupPermission",
|
||||
"admin").build(), types.toArray(new Class[0]));
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -99,5 +102,5 @@ public class JsonJaxbContextResolver implements ContextResolver<JAXBContext>
|
||||
|
||||
/** Field description */
|
||||
private List<Class> types = Arrays.asList(new Class[] { Group.class,
|
||||
Repository.class, ScmState.class });
|
||||
Repository.class, ScmState.class, User.class });
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
urlTemplate: '<a href="{0}" target="_blank">{0}</a>',
|
||||
mailtoTemplate: '<a href="mailto: {0}">{0}</a>',
|
||||
checkboxTemplate: '<input type="checkbox" disabled="true" {0}/>',
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
@@ -118,6 +119,14 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
renderMailto: function(mail){
|
||||
return String.format( this.mailtoTemplate, mail );
|
||||
},
|
||||
|
||||
renderCheckbox: function(value){
|
||||
var param = "";
|
||||
if ( value ){
|
||||
param = "checked='checked' ";
|
||||
}
|
||||
return String.format( this.checkboxTemplate, param );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -40,7 +40,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', 'type'],
|
||||
fields: [ 'name', 'displayName', 'mail', 'admin', 'type'],
|
||||
sortInfo: {
|
||||
field: 'name'
|
||||
}
|
||||
@@ -56,6 +56,7 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
{id: 'name', header: 'Name', dataIndex: 'name'},
|
||||
{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: 'type', header: 'Type', dataIndex: 'type', width: 80}
|
||||
]
|
||||
});
|
||||
@@ -151,6 +152,10 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
minLengthText: 'Password must be at least 6 characters long.',
|
||||
vtype: 'password',
|
||||
initialPassField: 'pwd'
|
||||
},{
|
||||
fieldLabel: 'Administrator',
|
||||
name: 'admin',
|
||||
xtype: 'checkbox'
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user