[Monitor Dashboard | Trunk]: 1. Fix preview link 2. if stakeholder doesnt exist go to error page. 3. If stakeholder is inactive or private and user no admin go to error page

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@58875 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2020-06-10 14:03:28 +00:00
parent e7d906c691
commit bf58c1b7d5
5 changed files with 32 additions and 60 deletions

View File

@ -84,6 +84,8 @@ export class AppComponent implements OnInit, OnDestroy {
this.stakeholderService.setStakeholder(stakeholder);
this.layoutService.setOpen(true);
this.stakeHolder = stakeholder;
}, error => {
this.navigateToError();
});
}
} else {
@ -109,6 +111,10 @@ export class AppComponent implements OnInit, OnDestroy {
}
});
}
private navigateToError() {
this.router.navigate(['/error'], {queryParams: {'page': this.router.url}});
}
public get open() {
return this.layoutService.open;

View File

@ -142,10 +142,10 @@
(click)="$event.stopPropagation();editStakeholder(stakeholder);hide(element);$event.preventDefault()">Edit</a>
</li>
<li><a (click)="$event.stopPropagation();toggleStakeholderStatus(stakeholder);hide(element);$event.preventDefault()">
{{stakeholder.isActive ? 'Deactivate' : 'Activate'}}</a>
{{stakeholder.isActive ? 'Inactive' : 'Active'}}</a>
</li>
<li><a (click)="$event.stopPropagation();toggleStakeholderAccess(stakeholder);hide(element);$event.preventDefault()">
{{stakeholder.isPublic ? 'Unpublish' : 'Publish'}}</a>
{{stakeholder.isPublic ? 'Private' : 'Public'}}</a>
</li>
<hr class="uk-nav-divider">
<li><a

View File

@ -113,59 +113,35 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
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(stakeholder).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(stakeholder).topics);
// stakeholder.logoUrl = "./assets/arc1.gif";
// } else if (params['stakeholder'] == "ec") {
// stakeholder = new Stakeholder(null, "funder", "ec__________::EC",
// "European Commission", "EC",
// "ec", true, true, null);
// stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile(stakeholder).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();
if(stakeholder.isActive && (stakeholder.isPublic || this.isAdmin())) {
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);
} else {
this.navigateToError();
subscription.unsubscribe();
}
//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);
// }));
});
}));
});

View File

@ -57,15 +57,7 @@ export class StakeholderComponent implements OnInit, OnDestroy, IDeactivateCompo
this.form = null;
this.title.setTitle(stakeholder.index_name);
}
},
err => {
console.error("Error getting stakeholder: ", err);
if(err.status == 404) {
//{queryParams: {"page": this.location.path(true), "page_type": "dataprovider"}}
this.router.navigate(['/error'], );
}
}));
}));
});
}

View File

@ -125,11 +125,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.filterCharts();
this.filterNumbers();
}
if (this.topicIndex && this.categoryIndex && this.subcategoryIndex) {
this.preview = '/' + this.stakeholder.alias + '/' + this.stakeholder.topics[this.topicIndex].alias +
'/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].alias +
'/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].alias;
}
this.preview = '/' + this.stakeholder.alias + '/' + this.stakeholder.topics[this.topicIndex].alias +
'/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].alias +
'/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].alias;
}
initReorder() {