diff --git a/src/app/monitor/monitor.component.ts b/src/app/monitor/monitor.component.ts
index 8ea40a8..23b391b 100644
--- a/src/app/monitor/monitor.component.ts
+++ b/src/app/monitor/monitor.component.ts
@@ -23,7 +23,7 @@ import {IndicatorUtils, StakeholderUtils} from "../utils/indicator-utils";
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {UntypedFormBuilder, UntypedFormControl} from "@angular/forms";
import {Subscriber, Subscription} from "rxjs";
-import {User} from "../openaireLibrary/login/utils/helper.class";
+import {Session, User} from "../openaireLibrary/login/utils/helper.class";
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {RangeFilter} from "../openaireLibrary/utils/rangeFilter/rangeFilterHelperClasses.class";
import {Filter, Value} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
@@ -49,7 +49,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
public divContents = null;
public status: number;
public loading: boolean = true;
- public isViewPublic: boolean = false;
+ public view: Visibility;
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
public activeTopic: Topic = null;
@@ -172,36 +172,36 @@ export class MonitorComponent implements OnInit, OnDestroy {
}
this.subscriptions.push(this.route.queryParams.subscribe( queryParams => {
this.handleQueryParams(queryParams, params);
- }));
- this.seoService.createLinkForCanonicalURL(url, false);
- this._meta.updateTag({content: url}, "property='og:url'");
- this.description = "Monitor Dashboard | " + this.stakeholder.name;
- this.title = "Monitor Dashboard | " + this.stakeholder.name;
- this._meta.updateTag({content: this.description}, "name='description'");
- this._meta.updateTag({content: this.description}, "property='og:description'");
- this._meta.updateTag({content: this.title}, "property='og:title'");
- this._title.setTitle(this.title);
- if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
- this.subscriptions.push(this.configurationService.communityInformationState.subscribe(portal => {
- if (portal && portal.piwik) {
- this.piwikSiteId = portal.piwik;
- this.subscriptions.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe());
- }
- }));
-
- }
- if (this.isPublicOrIsMember(stakeholder.visibility)) {
- //this.getDivContents();
- // this.getPageContents();
- this.status = this.errorCodes.DONE;
- this.setView(params);
- } else {
- this.privateStakeholder = true;
- // this.navigateToError();
- if (subscription) {
- subscription.unsubscribe();
+ this.seoService.createLinkForCanonicalURL(url, false);
+ this._meta.updateTag({content: url}, "property='og:url'");
+ this.description = "Monitor Dashboard | " + this.stakeholder.name;
+ this.title = "Monitor Dashboard | " + this.stakeholder.name;
+ this._meta.updateTag({content: this.description}, "name='description'");
+ this._meta.updateTag({content: this.description}, "property='og:description'");
+ this._meta.updateTag({content: this.title}, "property='og:title'");
+ this._title.setTitle(this.title);
+ if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
+ this.subscriptions.push(this.configurationService.communityInformationState.subscribe(portal => {
+ if (portal && portal.piwik) {
+ this.piwikSiteId = portal.piwik;
+ this.subscriptions.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe());
+ }
+ }));
+
}
- }
+ if (this.hasPermission((this.view && this.isManager(this.stakeholder))?this.view:this.stakeholder.visibility)) {
+ //this.getDivContents();
+ // this.getPageContents();
+ this.status = this.errorCodes.DONE;
+ this.setView(params);
+ } else {
+ this.privateStakeholder = true;
+ // this.navigateToError();
+ if (subscription) {
+ subscription.unsubscribe();
+ }
+ }
+ }));
} else {
this.navigateToError();
if (subscription) {
@@ -239,7 +239,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
this.router.navigate([], {queryParams: {}});
}
}
- this.isViewPublic = (queryParams['view'] == 'public');
+ this.view = queryParams['view'];
}
private initializeFilters() {
@@ -346,20 +346,20 @@ export class MonitorComponent implements OnInit, OnDestroy {
private setView(params: Params) {
this.loading = false;
if (params['topic']) {
- this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility));
+ this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.hasPermission(topic.visibility));
if (this.activeTopic) {
if (params['category']) {
this.activeCategory = this.activeTopic.categories.find(category =>
- (category.alias === params['category']) && this.isPublicOrIsMember(category.visibility));
+ (category.alias === params['category']) && this.hasPermission(category.visibility));
if (!this.activeCategory) {
this.navigateToError();
return;
}
} else {
- this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility));
+ this.activeCategory = this.activeTopic.categories.find(category => this.hasPermission(category.visibility));
if (this.activeCategory) {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
- this.isPublicOrIsMember(subCategory.visibility));
+ this.hasPermission(subCategory.visibility));
if (this.activeSubCategory) {
this.setIndicators();
}
@@ -369,14 +369,14 @@ export class MonitorComponent implements OnInit, OnDestroy {
if (this.activeCategory) {
if (params['subCategory']) {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
- (subCategory.alias === params['subCategory'] && this.isPublicOrIsMember(subCategory.visibility)));
+ (subCategory.alias === params['subCategory'] && this.hasPermission(subCategory.visibility)));
if (!this.activeSubCategory) {
this.navigateToError();
return;
}
} else {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
- this.isPublicOrIsMember(subCategory.visibility));
+ this.hasPermission(subCategory.visibility));
}
if (this.activeSubCategory) {
this.setIndicators();
@@ -392,11 +392,11 @@ export class MonitorComponent implements OnInit, OnDestroy {
return;
}
} else {
- this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility));
+ this.activeTopic = this.stakeholder.topics.find(topic => this.hasPermission(topic.visibility));
if (this.activeTopic) {
- this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility));
+ this.activeCategory = this.activeTopic.categories.find(category => this.hasPermission(category.visibility));
if (this.activeCategory) {
- this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => this.isPublicOrIsMember(subCategory.visibility));
+ this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => this.hasPermission(subCategory.visibility));
if (this.activeSubCategory) {
this.setIndicators();
}
@@ -472,7 +472,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
let urls: Map
= new Map();
this.activeSubCategory.numbers.forEach((section, i) => {
section.indicators.forEach((number, j) => {
- if (this.isPublicOrIsMember(number.visibility)) {
+ if (this.hasPermission(number.visibility)) {
let url = this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, number.indicatorPaths[0], this.getfl0(), this.periodFilter.selectedFromValue, this.periodFilter.selectedToValue, this.getCoFunded());
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
const indexes = urls.get(pair) ? urls.get(pair) : [];
@@ -543,12 +543,27 @@ export class MonitorComponent implements OnInit, OnDestroy {
});
}
- public isPublicOrIsMember(visibility: Visibility): boolean {
- return !(visibility == "PRIVATE" || (this.isViewPublic && visibility != "PUBLIC"));
+ public isMember(stakeholder: Stakeholder) {
+ return this.user && (Session.isPortalAdministrator(this.user) || Session.isCurator(stakeholder.type, this.user)
+ || Session.isManager(stakeholder.type, stakeholder.alias, this.user) || Session.isMember(stakeholder.type, stakeholder.alias, 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));
+ }
+
+ public hasPermission(visibility: Visibility): boolean {
+ if(visibility === 'PUBLIC') {
+ return true;
+ } else if(visibility === 'RESTRICTED') {
+ return (!this.view || this.view === 'RESTRICTED') && this.isMember(this.stakeholder);
+ } else {
+ return !this.view && this.isManager(this.stakeholder);
+ }
}
public countSubCategoriesToShow(category: Category): number {
- return category.subCategories.filter(subCategory => this.isPublicOrIsMember(subCategory.visibility)).length;
+ return category.subCategories.filter(subCategory => this.hasPermission(subCategory.visibility)).length;
}
public countSectionsWithIndicatorsToShow(sections: Section[]):number {
@@ -556,7 +571,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
}
public countIndicatorsToShow(indicators: Indicator[]): number {
- return indicators.filter(indicator => this.isPublicOrIsMember(indicator.visibility)).length;
+ return indicators.filter(indicator => this.hasPermission(indicator.visibility)).length;
}
public get feedback() {
diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary
index 06f2f58..10130d3 160000
--- a/src/app/openaireLibrary
+++ b/src/app/openaireLibrary
@@ -1 +1 @@
-Subproject commit 06f2f586a88a1766f183356b6497c0fc66436f36
+Subproject commit 10130d368a1e3c72e6785fe2291234529040bf84
diff --git a/src/app/search/landingPages/publication/publication.component.ts b/src/app/search/landingPages/publication/publication.component.ts
index 5859718..0ec217b 100644
--- a/src/app/search/landingPages/publication/publication.component.ts
+++ b/src/app/search/landingPages/publication/publication.component.ts
@@ -35,7 +35,6 @@ export class MonitorPublicationComponent {
this.communityId = stakeholder.alias;
this.subscriptions.push(this.configurationService.communityInformationState.subscribe(portal => {
if (portal) {
- console.debug(portal)
this.piwikSiteId = portal.piwik;
}
}));
diff --git a/src/app/topic/topic.component.html b/src/app/topic/topic.component.html
index 02d6c51..50e5802 100644
--- a/src/app/topic/topic.component.html
+++ b/src/app/topic/topic.component.html
@@ -310,12 +310,12 @@