[Trunk | Monitor Dashboard]: monitor.component: Add method "isPublicOrIsMember()" to check when to show public/ private entities.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@58687 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantina Galouni 2020-05-13 08:23:19 +00:00
parent dd5ed9db7b
commit 98f8c36f06
2 changed files with 100 additions and 77 deletions

View File

@ -51,7 +51,7 @@
<div *ngIf="stakeholder && status === errorCodes.DONE && activeTopic" class="uk-navbar-center">
<ul class="uk-navbar-nav">
<ng-template ngFor [ngForOf]="stakeholder.topics" let-topic let-i="index">
<li *ngIf="topic.isPublic && topic.isActive"
<li *ngIf="isPublicOrIsMember(topic.isPublic) && topic.isActive"
[ngClass]="(topic.alias === activeTopic.alias)?'uk-active':''">
<a (click)="navigateTo(stakeholder.alias, topic.alias)" class="uk-margin-remove-bottom uk-h4"
><span>{{topic.name}}</span></a>
@ -91,7 +91,7 @@
<ng-template ngFor [ngForOf]="activeSubCategory.numbers" let-number let-i="index">
<h4 class="uk-width-1-1">{{number.title}}</h4>
<ng-template ngFor [ngForOf]="number.indicators" let-indicator let-j="index">
<div *ngIf="indicator.isActive && indicator.isPublic"
<div *ngIf="indicator.isActive && isPublicOrIsMember(indicator.isPublic)"
[class.uk-width-1-3@m]="indicator.width === 'small'"
[class.uk-width-1-2@m]="indicator.width === 'medium'"
[class.uk-width-1-1]="indicator.width === 'large'">
@ -131,7 +131,7 @@
<h3 *ngIf="chart.title && chart.title.length > 0" class="uk-width-1-1 uk-margin-top">{{chart.title}}</h3>
<ng-template ngFor [ngForOf]="chart.indicators" let-indicator let-j="index">
<div *ngIf="indicator.isActive && indicator.isPublic && chartsActiveType.get(i + '-' + j)"
<div *ngIf="indicator.isActive && isPublicOrIsMember(indicator.isPublic) && chartsActiveType.get(i + '-' + j)"
[class.uk-width-1-3@m]="indicator.width === 'small'"
[class.uk-width-1-2@m]="indicator.width === 'medium'"
[class.uk-width-1-1]="indicator.width === 'large'">

View File

@ -39,6 +39,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
public divContents = null;
public status: number;
public loading: boolean = true;
public isViewPublic: boolean = false;
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
public activeTopic: Topic = null;
@ -85,71 +86,79 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
let subscription: Subscription;
this.route.params.subscribe(params => {
if (subscription) {
subscription.unsubscribe();
}
this.properties = data.envSpecific;
var url = data.envSpecific.baseLink + this._router.url;
if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) {
this.status = this.errorCodes.LOADING;
this.numberResults = new Map<string, number>();
this.chartsActiveType = new Map<string, IndicatorPath>();
subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
// let stakeholder: Stakeholder = null;
// if (params['stakeholder'] == "fwf") {
// stakeholder = new Stakeholder(null, "funder", "fwf_________::FWF", "Austrian Science Fund (FWF)", "FWF",
// "fwf", true, true, null);
// stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
// stakeholder.logoUrl = "./assets/fwf.png";
// } else if (params['stakeholder'] == "arc") {
// stakeholder = new Stakeholder(null, "funder", "arc_________::ARC",
// "Australian Research Council (ARC)", "ARC", "arc", true, true, null);
// stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
// stakeholder.logoUrl = "./assets/arc1.gif";
// } else {
// stakeholder = new Stakeholder(null, "funder", "ec__________::EC",
// "European Commission", "EC",
// "ec", true, true, null);
// stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
// stakeholder.logoUrl = "./assets/ec.png";
// }
if (stakeholder) {
this.stakeholder = stakeholder;
console.info(this.stakeholder);
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
this.buildMenu();
this.seoService.createLinkForCanonicalURL(url, false);
this._meta.updateTag({content: url}, "property='og:url'");
var description = "Monitor Dashboard | " + this.stakeholder.index_name;
var title = "Monitor Dashboard | " + this.stakeholder.index_shortName;
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content: title}, "property='og:title'");
this._title.setTitle(title);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, title, this.properties.piwikSiteId).subscribe();
}
//this.getDivContents();
this.getPageContents();
this.status = this.errorCodes.DONE;
this.setView(params);
this.layoutService.setOpen(true);
this.route.params.subscribe(params => {
if (subscription) {
subscription.unsubscribe();
}
}, error => {
this.navigateToError();
this.properties = data.envSpecific;
var url = data.envSpecific.baseLink + this._router.url;
this.route.queryParams.subscribe(params => {
this.isViewPublic = (params['view'] == 'public');
});
this.subscriptions.push(subscription);
} else {
this.setView(params);
}
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
this.buildMenu();
}, error => {
console.log("App couldn't fetch properties");
console.log(error);
}));
});
if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) {
this.status = this.errorCodes.LOADING;
this.numberResults = new Map<string, number>();
this.chartsActiveType = new Map<string, IndicatorPath>();
subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
// let stakeholder: Stakeholder = null;
// if (params['stakeholder'] == "fwf") {
// stakeholder = new Stakeholder(null, "funder", "fwf_________::FWF", "Austrian Science Fund (FWF)", "FWF",
// "fwf", true, true, null);
// stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
// stakeholder.logoUrl = "./assets/fwf.png";
// } else if (params['stakeholder'] == "arc") {
// stakeholder = new Stakeholder(null, "funder", "arc_________::ARC",
// "Australian Research Council (ARC)", "ARC", "arc", true, true, null);
// stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
// stakeholder.logoUrl = "./assets/arc1.gif";
// } else {
// stakeholder = new Stakeholder(null, "funder", "ec__________::EC",
// "European Commission", "EC",
// "ec", true, true, null);
// stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
// stakeholder.logoUrl = "./assets/ec.png";
// }
if (stakeholder) {
this.stakeholder = stakeholder;
console.info(this.stakeholder);
this.seoService.createLinkForCanonicalURL(url, false);
this._meta.updateTag({content: url}, "property='og:url'");
var description = "Monitor Dashboard | " + this.stakeholder.index_name;
var title = "Monitor Dashboard | " + this.stakeholder.index_shortName;
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content: title}, "property='og:title'");
this._title.setTitle(title);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, title, this.properties.piwikSiteId).subscribe();
}
//this.getDivContents();
this.getPageContents();
this.status = this.errorCodes.DONE;
this.setView(params);
this.layoutService.setOpen(true);
}
}, error => {
this.navigateToError();
});
this.subscriptions.push(subscription);
} else {
this.setView(params);
}
// this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
// this.user = user;
// this.buildMenu();
// }, error => {
// console.log("App couldn't fetch properties");
// console.log(error);
// }));
});
}));
});
}
@ -185,20 +194,20 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
private setView(params: Params) {
if (params['topic']) {
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && topic.isPublic && topic.isActive);
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.isPublic) && topic.isActive);
if (this.activeTopic) {
if (params['category']) {
this.activeCategory = this.activeTopic.categories.find(category =>
(category.alias === params['category']) && category.isPublic && category.isActive);
(category.alias === params['category']) && this.isPublicOrIsMember(category.isPublic) && category.isActive);
if (!this.activeCategory) {
this.navigateToError();
return;
}
} else {
this.activeCategory = this.activeTopic.categories.find(category => category.isPublic && category.isActive);
this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.isPublic) && category.isActive);
if (this.activeCategory) {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
subCategory.isPublic && subCategory.isActive);
this.isPublicOrIsMember(subCategory.isPublic) && subCategory.isActive);
this.setSideBar();
if (this.activeSubCategory) {
this.setIndicators();
@ -211,14 +220,14 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
if (this.activeCategory) {
if (params['subCategory']) {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
(subCategory.alias === params['subCategory'] && subCategory.isPublic && subCategory.isActive));
(subCategory.alias === params['subCategory'] && this.isPublicOrIsMember(subCategory.isPublic) && subCategory.isActive));
if (!this.activeSubCategory) {
this.navigateToError();
return;
}
} else {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
subCategory.isPublic && subCategory.isActive);
this.isPublicOrIsMember(subCategory.isPublic) && subCategory.isActive);
}
if (this.activeSubCategory) {
this.setSideBar();
@ -235,11 +244,11 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
return;
}
} else {
this.activeTopic = this.stakeholder.topics.find(topic => topic.isPublic && topic.isActive);
this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.isPublic) && topic.isActive);
if (this.activeTopic) {
this.activeCategory = this.activeTopic.categories.find(category => category.isPublic && category.isActive);
this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.isPublic) && category.isActive);
if (this.activeCategory) {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => subCategory.isPublic && subCategory.isActive);
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => this.isPublicOrIsMember(subCategory.isPublic) && subCategory.isActive);
if (this.activeSubCategory) {
this.setSideBar();
this.setIndicators();
@ -258,10 +267,10 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
private setSideBar() {
let items: MenuItem[] = [];
this.activeTopic.categories.forEach((category, index) => {
if (category.isPublic && category.isActive) {
if (this.isPublicOrIsMember(category.isPublic) && category.isActive) {
let subItems: MenuItem[] = [];
category.subCategories.forEach(subCategory => {
if (subCategory.isPublic && subCategory.isActive) {
if (this.isPublicOrIsMember(subCategory.isPublic) && subCategory.isActive) {
subItems.push(new MenuItem(subCategory.alias, subCategory.name, "", (
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias + '/' + subCategory.alias),
null, null, [], {}));
@ -290,7 +299,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
let urls: Map<string, [number, number][]> = new Map<string, [number, number][]>();
this.activeSubCategory.numbers.forEach((section, i) => {
section.indicators.forEach((number, j) => {
if (number.isActive && number.isPublic) {
if (number.isActive && this.isPublicOrIsMember(number.isPublic)) {
let url = number.indicatorPaths[0].url;
//add fundingLevel0 filter in the query
if (this.fundingL0 && number.indicatorPaths[0].filters.get("fundingL0")) {
@ -374,4 +383,18 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
isAdmin(){
return this.user && Session.isPortalAdministrator(this.user);
}
public isPublicOrIsMember(isPublic: boolean): boolean {
if (isPublic) {
return true;
} else {
if (this.isViewPublic) { // preview for not members
return false;
} else if(this.user) {
// if user is member, return true
return true;
}
return false;
}
}
}