[Monitor Dashboard|Trunk]
- update checks for roles - Stakeholder form: create stakeholder type if curator of that type of portal administrator git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59747 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
4746e10acd
commit
63e5b51dcd
|
@ -212,6 +212,13 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||
this.menuItems = [];
|
||||
this.adminMenuItems = [];
|
||||
this.userMenuItems = [];
|
||||
if (this.isAdmin()) {
|
||||
this.userMenuItems.push(new MenuItem("", "Manage profiles",
|
||||
"", "/admin", true, [], [], {}))
|
||||
}
|
||||
if (this.user) {
|
||||
this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
|
||||
}
|
||||
if (this.stakeholder) {
|
||||
if (this.isFrontPage) {
|
||||
this.menuHeader = {
|
||||
|
@ -262,13 +269,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||
"", "/helptexts", true, [], [], {communityId:'openaire'}))
|
||||
|
||||
}*/
|
||||
if (this.isAdmin()) {
|
||||
this.userMenuItems.push(new MenuItem("", "Manage profiles",
|
||||
"", "/admin", true, [], [], {}))
|
||||
}
|
||||
if (this.user) {
|
||||
this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this.isFrontPage || !this.hasAdminMenu) {
|
||||
this.menuHeader = {
|
||||
|
@ -316,7 +317,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
public isAdmin() {
|
||||
return this.user && (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || Session.isMonitorCurator(this.user) || (this.stakeholder && Session.isManager(this.stakeholder.type, this.stakeholder.alias, this.user)));
|
||||
return this.user && (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || (this.stakeholder && Session.isManager(this.stakeholder.type, this.stakeholder.alias, this.user)));
|
||||
}
|
||||
|
||||
private resolvePageInner() {
|
||||
|
|
|
@ -8,6 +8,8 @@ import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properti
|
|||
import {properties} from "../../../environments/environment";
|
||||
import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeholder.service";
|
||||
import {UtilitiesService} from "../../openaireLibrary/services/utilities.service";
|
||||
import {User} from "../../openaireLibrary/login/utils/helper.class";
|
||||
import {UserManagementService} from "../../openaireLibrary/services/user-management.service";
|
||||
|
||||
@Component({
|
||||
selector: 'edit-stakeholder',
|
||||
|
@ -76,8 +78,8 @@ import {UtilitiesService} from "../../openaireLibrary/services/utilities.service
|
|||
[options]="stakeholderUtils.statuses" type="select">
|
||||
</div>
|
||||
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('type')"
|
||||
[placeholder]="'Select a type'" hint="Select the type of your profile"
|
||||
label="Type" [options]="stakeholderUtils.types" type="select">
|
||||
[placeholder]="'Select a type'" hint="Select the type of your profile"
|
||||
label="Type" [options]="stakeholderUtils.getTypesByUserRoles(user)" type="select">
|
||||
</div>
|
||||
<ng-container *ngIf="!stakeholderFb.get('isDefault').value && isNew && stakeholderFb.get('type').valid && defaultStakeholdersOptions">
|
||||
<div [placeholder]="'Select a template'"
|
||||
|
@ -114,10 +116,10 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
public uploadError: string;
|
||||
public deleteCurrentPhoto: boolean = false;
|
||||
private maxsize: number = 200 * 1024;
|
||||
|
||||
user: User;
|
||||
constructor(private fb: FormBuilder,
|
||||
private stakeholderService: StakeholderService,
|
||||
private utilsService: UtilitiesService) {
|
||||
private utilsService: UtilitiesService, private userManagementService: UserManagementService,) {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@ -132,6 +134,12 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
this.defaultStakeholders = defaultStakeholders;
|
||||
this.isDefault = isDefault;
|
||||
this.isNew = isNew;
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
}, error => {
|
||||
console.log("App couldn't fetch properties");
|
||||
console.log(error);
|
||||
}));
|
||||
this.stakeholderFb = this.fb.group({
|
||||
_id: this.fb.control(this.stakeholder._id),
|
||||
defaultId: this.fb.control(this.stakeholder.defaultId),
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<div class="uk-card uk-card-default uk-position-relative" style="min-height: 60vh">
|
||||
<div [class.hidden]="loading">
|
||||
<edit-stakeholder #editStakeholderComponent [disableAlias]="true"
|
||||
[maxHeight]="'60vh'" [paddingLarge]="true"></edit-stakeholder>
|
||||
[maxHeight]="'60vh'" [paddingLarge]="true" ></edit-stakeholder>
|
||||
</div>
|
||||
<div *ngIf="loading" class="uk-position-center">
|
||||
<loading *ngIf="loading"></loading>
|
||||
|
|
|
@ -248,7 +248,7 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
public isCurator(): boolean {
|
||||
return this.isAdmin() || Session.isCommunityCurator(this.user) || Session.isMonitorCurator(this.user);
|
||||
return this.isAdmin() || Session.isMonitorCurator(this.user);
|
||||
}
|
||||
|
||||
public isAdmin(): boolean {
|
||||
|
|
|
@ -437,7 +437,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
isAdmin(){
|
||||
return this.user && (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || Session.isMonitorCurator(this.user));
|
||||
return this.user && (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user));
|
||||
}
|
||||
|
||||
public isPublicOrIsMember(visibility: Visibility): boolean {
|
||||
|
|
|
@ -737,7 +737,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
}
|
||||
|
||||
public get isAdministrator(): boolean {
|
||||
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user)
|
||||
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user)
|
||||
}
|
||||
|
||||
refreshIndicator() {
|
||||
|
|
|
@ -24,8 +24,8 @@ export class AdminDashboardGuard implements CanActivate {
|
|||
if(user) {
|
||||
return this.stakeholderService.getStakeholder(alias).pipe(map(stakeholder => {
|
||||
if(stakeholder) {
|
||||
return (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) ||
|
||||
Session.isMonitorCurator(user) || Session.isManager(stakeholder.type, stakeholder.alias, user));
|
||||
return (Session.isPortalAdministrator(user) ||
|
||||
Session.isCurator(stakeholder.type, user) || Session.isManager(stakeholder.type, stakeholder.alias, user));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,13 +9,14 @@ import {
|
|||
} from "../openaireLibrary/monitor/entities/stakeholder";
|
||||
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
|
||||
import {Option} from "../openaireLibrary/dashboard/sharedComponents/input/input.component";
|
||||
import {Session} from "../openaireLibrary/login/utils/helper.class";
|
||||
|
||||
export class StakeholderUtils {
|
||||
statuses: Option[] = [
|
||||
{value: 'PUBLIC', label: 'Public'},
|
||||
{value: 'RESTRICTED', label: 'Restricted'},
|
||||
{value: 'PRIVATE', label: 'Private'}
|
||||
]
|
||||
];
|
||||
|
||||
types: Option[] = [
|
||||
{value: 'funder', label: 'Funder'},
|
||||
|
@ -23,7 +24,15 @@ export class StakeholderUtils {
|
|||
{value: 'project', label: 'Project'},
|
||||
{value: 'organization', label: 'Organization'}
|
||||
];
|
||||
|
||||
getTypesByUserRoles(user):Option[]{
|
||||
let types = [];
|
||||
for(let type of this.types){
|
||||
if(Session.isCurator(type.value, user)|| Session.isPortalAdministrator(user)){
|
||||
types.push(type);
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
visibility: Option[] = [
|
||||
{icon: 'world', value: "PUBLIC", label: 'Public'},
|
||||
{icon: 'lock', value: "RESTRICTED", label: 'Restricted'},
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
transition-property: left;
|
||||
}
|
||||
|
||||
.sidebar_main_swipe #page_content {
|
||||
.sidebar_main_swipe #page_content, openaire-user {
|
||||
padding-left: var(--sidebar-width);
|
||||
padding-top: var(--header-height);
|
||||
transition: 0.5s;
|
||||
|
|
Loading…
Reference in New Issue