[Monitor Dashboard|Trunk]

-app component: 
	add monitor menu items for non admin pages
	update user menu items - add user info and manage profiles in any page
-update role check check for stakeholder types
	




git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59751 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Argiro Kokogiannaki 2020-11-03 10:59:48 +00:00
parent 95d2ba3475
commit 29537d917d
3 changed files with 31 additions and 32 deletions

View File

@ -43,7 +43,7 @@ export class AppComponent implements OnInit, OnDestroy {
stickyAnimation: false
};
userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
userMenuItems: MenuItem[] = [];
adminMenuItems: MenuItem[] = [];
stakeholder: Stakeholder = null;
activeTopic: Topic = null;
@ -212,12 +212,12 @@ 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.isCurator()) {
this.userMenuItems.push(new MenuItem("", "Manage profiles",
"", "/admin", false, [], [], {}));
}
}
if (this.stakeholder) {
if (this.isFrontPage) {
@ -231,7 +231,7 @@ export class AppComponent implements OnInit, OnDestroy {
badge: false,
stickyAnimation: false
};
if (this.isAdmin()) {
if (this.isCurator()) {
this.menuItems.push({
rootItem: new MenuItem("manage", "Manage",
"", "/admin", false, [], null, {}), items: []
@ -263,13 +263,6 @@ export class AppComponent implements OnInit, OnDestroy {
this.specialSideBarMenuItem.icon = '<span class="uk-icon-button small uk-icon uk-button-secondary">' + arrow_left.data + '</span>'; // '<span class="uk-icon-button uk-icon portal-button " uk-icon="chevron-left"></span>';
this.specialSideBarMenuItem.customClass = 'uk-text-uppercase uk-text-bold uk-text-secondary';
}
this.userMenuItems = [];
/* if (Session.isPortalAdministrator(this.user)) {
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
"", "/helptexts", true, [], [], {communityId:'openaire'}))
}*/
} else {
if (this.isFrontPage || !this.hasAdminMenu) {
this.menuHeader = {
@ -282,8 +275,18 @@ export class AppComponent implements OnInit, OnDestroy {
badge: true,
stickyAnimation: false
};
//TODO monitor menu items?
this.menuItems.push({
rootItem: new MenuItem("about", "About",
"https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/about/learn-how', "", false, [], null, {}), items: []
});
this.menuItems.push({
rootItem: new MenuItem("browse", "Browse",
"https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/browse', "", false, [], null, {}), items: []
});
this.menuItems.push({
rootItem: new MenuItem("contact", "Contact us",
"https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/contact-us', "", false, [], null, {}), items: []
});
} else {
this.menuHeader = {
route: "/",
@ -315,9 +318,11 @@ export class AppComponent implements OnInit, OnDestroy {
}
}
public isAdmin() {
return this.user && (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || (this.stakeholder && Session.isManager(this.stakeholder.type, this.stakeholder.alias, this.user)));
public isCurator() {
return this.user && (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isKindOfMonitorManager(this.user));
}
public isManager(stakeholder:Stakeholder) {
return this.user && (Session.isPortalAdministrator(this.user) || Session.isCurator(stakeholder.type, this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user));
}
private resolvePageInner() {
@ -341,7 +346,7 @@ export class AppComponent implements OnInit, OnDestroy {
} else {
if (this.isViewPublic) { // preview for not members
return false;
} else if (this.isAdmin()) {
} else if (this.isManager(this.stakeholder)) {
// if user is member, return true
return true;
}

View File

@ -16,7 +16,7 @@ declare var UIkit;
@Component({
selector: 'edit-stakeholder',
template: `
<div *ngIf="stakeholderFb" [ngStyle]="{'max-height': maxHeight}"
<div *ngIf="stakeholderFb && user" [ngStyle]="{'max-height': maxHeight}"
[class.uk-padding-small]="!paddingLarge" [class.uk-padding-large]="paddingLarge"
class="uk-overflow-auto"
[formGroup]="stakeholderFb">
@ -81,7 +81,7 @@ declare var UIkit;
</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.getTypesByUserRoles(user)" type="select">
label="Type" [options]="stakeholderUtils.getTypesByUserRoles(user, stakeholder.alias)" type="select">
</div>
<ng-container *ngIf="!stakeholderFb.get('isDefault').value && isNew && stakeholderFb.get('type').valid && defaultStakeholdersOptions">
<div [placeholder]="'Select a template'"
@ -182,15 +182,9 @@ export class EditStakeholderComponent implements OnDestroy {
this.stakeholderFb.get('type').enable();
}, 0);
} else {
if (this.stakeholderFb.value.type) {
setTimeout(() => {
this.stakeholderFb.get('type').disable();
}, 0);
} else {
setTimeout(() => {
this.stakeholderFb.get('type').enable();
}, 0);
}
setTimeout(() => {
this.stakeholderFb.get('type').disable();
}, 0);
}
}

View File

@ -24,10 +24,10 @@ export class StakeholderUtils {
{value: 'project', label: 'Project'},
{value: 'organization', label: 'Organization'}
];
getTypesByUserRoles(user):Option[]{
getTypesByUserRoles(user, id:string = null):Option[]{
let types = [];
for(let type of this.types){
if(Session.isCurator(type.value, user)|| Session.isPortalAdministrator(user)){
if(Session.isCurator(type.value, user)|| Session.isPortalAdministrator(user)|| Session.isManager(type.value, id, user)){
types.push(type);
}
}