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