[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:
Argiro Kokogiannaki 2020-11-03 09:42:47 +00:00
parent 4746e10acd
commit 63e5b51dcd
9 changed files with 39 additions and 21 deletions

View File

@ -212,6 +212,13 @@ export class AppComponent implements OnInit, OnDestroy {
this.menuItems = []; this.menuItems = [];
this.adminMenuItems = []; this.adminMenuItems = [];
this.userMenuItems = []; 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.stakeholder) {
if (this.isFrontPage) { if (this.isFrontPage) {
this.menuHeader = { this.menuHeader = {
@ -262,13 +269,7 @@ export class AppComponent implements OnInit, OnDestroy {
"", "/helptexts", true, [], [], {communityId:'openaire'})) "", "/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 { } else {
if (this.isFrontPage || !this.hasAdminMenu) { if (this.isFrontPage || !this.hasAdminMenu) {
this.menuHeader = { this.menuHeader = {
@ -316,7 +317,7 @@ export class AppComponent implements OnInit, OnDestroy {
} }
public isAdmin() { 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() { private resolvePageInner() {

View File

@ -8,6 +8,8 @@ import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properti
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeholder.service";
import {UtilitiesService} from "../../openaireLibrary/services/utilities.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({ @Component({
selector: 'edit-stakeholder', selector: 'edit-stakeholder',
@ -76,8 +78,8 @@ import {UtilitiesService} from "../../openaireLibrary/services/utilities.service
[options]="stakeholderUtils.statuses" type="select"> [options]="stakeholderUtils.statuses" type="select">
</div> </div>
<div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('type')" <div dashboard-input class="uk-width-1-3@m" [formInput]="stakeholderFb.get('type')"
[placeholder]="'Select a type'" hint="Select the type of your profile" [placeholder]="'Select a type'" hint="Select the type of your profile"
label="Type" [options]="stakeholderUtils.types" type="select"> label="Type" [options]="stakeholderUtils.getTypesByUserRoles(user)" type="select">
</div> </div>
<ng-container *ngIf="!stakeholderFb.get('isDefault').value && isNew && stakeholderFb.get('type').valid && defaultStakeholdersOptions"> <ng-container *ngIf="!stakeholderFb.get('isDefault').value && isNew && stakeholderFb.get('type').valid && defaultStakeholdersOptions">
<div [placeholder]="'Select a template'" <div [placeholder]="'Select a template'"
@ -114,10 +116,10 @@ export class EditStakeholderComponent implements OnDestroy {
public uploadError: string; public uploadError: string;
public deleteCurrentPhoto: boolean = false; public deleteCurrentPhoto: boolean = false;
private maxsize: number = 200 * 1024; private maxsize: number = 200 * 1024;
user: User;
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private stakeholderService: StakeholderService, private stakeholderService: StakeholderService,
private utilsService: UtilitiesService) { private utilsService: UtilitiesService, private userManagementService: UserManagementService,) {
} }
ngOnDestroy() { ngOnDestroy() {
@ -132,6 +134,12 @@ export class EditStakeholderComponent implements OnDestroy {
this.defaultStakeholders = defaultStakeholders; this.defaultStakeholders = defaultStakeholders;
this.isDefault = isDefault; this.isDefault = isDefault;
this.isNew = isNew; 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({ this.stakeholderFb = this.fb.group({
_id: this.fb.control(this.stakeholder._id), _id: this.fb.control(this.stakeholder._id),
defaultId: this.fb.control(this.stakeholder.defaultId), defaultId: this.fb.control(this.stakeholder.defaultId),

View File

@ -27,7 +27,7 @@
<div class="uk-card uk-card-default uk-position-relative" style="min-height: 60vh"> <div class="uk-card uk-card-default uk-position-relative" style="min-height: 60vh">
<div [class.hidden]="loading"> <div [class.hidden]="loading">
<edit-stakeholder #editStakeholderComponent [disableAlias]="true" <edit-stakeholder #editStakeholderComponent [disableAlias]="true"
[maxHeight]="'60vh'" [paddingLarge]="true"></edit-stakeholder> [maxHeight]="'60vh'" [paddingLarge]="true" ></edit-stakeholder>
</div> </div>
<div *ngIf="loading" class="uk-position-center"> <div *ngIf="loading" class="uk-position-center">
<loading *ngIf="loading"></loading> <loading *ngIf="loading"></loading>

View File

@ -248,7 +248,7 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
} }
public isCurator(): boolean { public isCurator(): boolean {
return this.isAdmin() || Session.isCommunityCurator(this.user) || Session.isMonitorCurator(this.user); return this.isAdmin() || Session.isMonitorCurator(this.user);
} }
public isAdmin(): boolean { public isAdmin(): boolean {

View File

@ -437,7 +437,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
} }
isAdmin(){ 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 { public isPublicOrIsMember(visibility: Visibility): boolean {

View File

@ -737,7 +737,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
} }
public get isAdministrator(): boolean { 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() { refreshIndicator() {

View File

@ -24,8 +24,8 @@ export class AdminDashboardGuard implements CanActivate {
if(user) { if(user) {
return this.stakeholderService.getStakeholder(alias).pipe(map(stakeholder => { return this.stakeholderService.getStakeholder(alias).pipe(map(stakeholder => {
if(stakeholder) { if(stakeholder) {
return (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || return (Session.isPortalAdministrator(user) ||
Session.isMonitorCurator(user) || Session.isManager(stakeholder.type, stakeholder.alias, user)); Session.isCurator(stakeholder.type, user) || Session.isManager(stakeholder.type, stakeholder.alias, user));
} else { } else {
return false; return false;
} }

View File

@ -9,13 +9,14 @@ import {
} from "../openaireLibrary/monitor/entities/stakeholder"; } from "../openaireLibrary/monitor/entities/stakeholder";
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms"; import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
import {Option} from "../openaireLibrary/dashboard/sharedComponents/input/input.component"; import {Option} from "../openaireLibrary/dashboard/sharedComponents/input/input.component";
import {Session} from "../openaireLibrary/login/utils/helper.class";
export class StakeholderUtils { export class StakeholderUtils {
statuses: Option[] = [ statuses: Option[] = [
{value: 'PUBLIC', label: 'Public'}, {value: 'PUBLIC', label: 'Public'},
{value: 'RESTRICTED', label: 'Restricted'}, {value: 'RESTRICTED', label: 'Restricted'},
{value: 'PRIVATE', label: 'Private'} {value: 'PRIVATE', label: 'Private'}
] ];
types: Option[] = [ types: Option[] = [
{value: 'funder', label: 'Funder'}, {value: 'funder', label: 'Funder'},
@ -23,7 +24,15 @@ export class StakeholderUtils {
{value: 'project', label: 'Project'}, {value: 'project', label: 'Project'},
{value: 'organization', label: 'Organization'} {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[] = [ visibility: Option[] = [
{icon: 'world', value: "PUBLIC", label: 'Public'}, {icon: 'world', value: "PUBLIC", label: 'Public'},
{icon: 'lock', value: "RESTRICTED", label: 'Restricted'}, {icon: 'lock', value: "RESTRICTED", label: 'Restricted'},

View File

@ -85,7 +85,7 @@
transition-property: left; transition-property: left;
} }
.sidebar_main_swipe #page_content { .sidebar_main_swipe #page_content, openaire-user {
padding-left: var(--sidebar-width); padding-left: var(--sidebar-width);
padding-top: var(--header-height); padding-top: var(--header-height);
transition: 0.5s; transition: 0.5s;