[Library|Trunk]
New roles update: - user component: update user formating - Sesssion: add methods about Curators git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59746 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
2716235881
commit
36bfc07747
|
@ -8,6 +8,7 @@ import {RouterHelper} from '../utils/routerHelper.class';
|
|||
import {EnvProperties} from '../utils/properties/env-properties';
|
||||
import {UserManagementService} from "../services/user-management.service";
|
||||
import {properties} from "../../../environments/environment";
|
||||
import {StringUtils} from "../utils/string-utils.class";
|
||||
|
||||
@Component({
|
||||
selector: 'user',
|
||||
|
@ -130,6 +131,14 @@ export class UserComponent {
|
|||
formattedRole = formattedRole.replace("+", " ");
|
||||
formattedRole = formattedRole.split("+").join(" ");
|
||||
formattedRoles.push(formattedRole);
|
||||
}else{
|
||||
if(role.indexOf("_MANAGER")!=-1){
|
||||
formattedRoles.push("Manager of " + role.split("_")[1]);
|
||||
}else if((["FUNDER","COMMUNITY","INSTITUTION","PROJECT"]).indexOf(role.split("_")[0])!=-1){
|
||||
formattedRoles.push("Member of " + role.split("_")[1]);
|
||||
}else{
|
||||
formattedRoles.splice(0,0,StringUtils.capitalize(role.split('_').join(' ').toLowerCase()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return formattedRoles.join(", ");
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import {StringUtils} from "../../utils/string-utils.class";
|
||||
|
||||
export class User {
|
||||
email:string;
|
||||
firstname: string;
|
||||
|
@ -55,17 +57,36 @@ export class Session{
|
|||
(user.role.indexOf('urn:geant:openaire.eu:group:Curator+-+Claim#aai.openaire.eu') !== -1 ||
|
||||
user.role.indexOf('CURATOR_CLAIM') !== -1);
|
||||
}
|
||||
|
||||
public static isCommunityCurator(user: User): boolean {
|
||||
return user &&
|
||||
(user.role.indexOf('urn:geant:openaire.eu:group:Curator+-+Community#aai.openaire.eu') !== -1||
|
||||
user.role.indexOf('CURATOR_COMMUNITY') !== -1);
|
||||
}
|
||||
|
||||
public static isMonitorCurator(user: User): boolean {
|
||||
return this.isCommunityCurator(user) || this.isProjectCurator(user) ||this.isFunderCurator(user) || this.isOrganizationCurator(user);
|
||||
}
|
||||
public static isCommunityCurator(user: User): boolean {
|
||||
return this.isTypeCurator("Community", user);
|
||||
}
|
||||
public static isFunderCurator(user: User): boolean {
|
||||
return this.isTypeCurator("Funder", user);
|
||||
}
|
||||
public static isProjectCurator(user: User): boolean {
|
||||
return this.isTypeCurator("Project", user);
|
||||
}
|
||||
public static isOrganizationCurator(user: User): boolean {
|
||||
return this.isTypeCurator("Institution", user);
|
||||
}
|
||||
private static isTypeCurator(type: string, user: User): boolean {
|
||||
return user &&
|
||||
(user.role.indexOf('urn:geant:openaire.eu:group:Expert+-+Funder#aai.openaire.eu') !== -1 ||
|
||||
user.role.indexOf('urn:geant:openaire.eu:group:Curator+-+Funder#aai.openaire.eu') !== -1);
|
||||
( user.role.indexOf('CURATOR_'+type.toUpperCase()) !== -1 ||
|
||||
user.role.indexOf('urn:geant:openaire.eu:group:Curator+-+' + type + '#aai.openaire.eu') !== -1);
|
||||
}
|
||||
public static isCurator(type: string, user: User): boolean {
|
||||
if(type == 'funder'){
|
||||
return user && this.isFunderCurator( user);
|
||||
}else if(type == 'ri' || type == 'community'){
|
||||
return user && this.isCommunityCurator(user);
|
||||
}else if(type == 'organization' || type == 'institution'){
|
||||
return user && this.isOrganizationCurator(user);
|
||||
}else if(type == 'project'){
|
||||
return user && this.isProjectCurator(user);
|
||||
}
|
||||
}
|
||||
|
||||
public static isPortalAdministrator(user: User): boolean {
|
||||
|
@ -85,6 +106,11 @@ export class Session{
|
|||
}
|
||||
|
||||
public static isManager(type: string, id: string, user: User): boolean {
|
||||
if(type == "ri"){
|
||||
type = "community";
|
||||
}else if (type == "organization"){
|
||||
type = "institution";
|
||||
}
|
||||
return user && user.role.indexOf(type.toUpperCase() + '_' + id.toUpperCase() + '_MANAGER') !== -1
|
||||
}
|
||||
public static isKindOfMonitorManager(user: User): boolean {
|
||||
|
|
|
@ -82,13 +82,14 @@ export class UserManagementService {
|
|||
}
|
||||
}
|
||||
user.role = [];
|
||||
if (info.edu_person_entitlements) {
|
||||
user.role = info.edu_person_entitlements;
|
||||
}
|
||||
if (info.roles) {
|
||||
info.roles.forEach(role => {
|
||||
user.role.push(role);
|
||||
});
|
||||
}else{
|
||||
if (info.edu_person_entitlements) {
|
||||
user.role = info.edu_person_entitlements;
|
||||
}
|
||||
}
|
||||
user.expirationDate = info.exp_date;
|
||||
return user;
|
||||
|
|
Loading…
Reference in New Issue