2019-09-30 14:48:48 +02:00
|
|
|
import {Component} from '@angular/core';
|
2020-06-29 15:16:21 +02:00
|
|
|
import {ActivatedRoute, NavigationEnd, NavigationStart, Params, Router} from '@angular/router';
|
2019-01-09 12:05:23 +01:00
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
|
|
|
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
|
|
|
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
|
|
|
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
|
|
|
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
|
|
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
2020-06-11 17:34:42 +02:00
|
|
|
import {properties} from "../environments/environment";
|
2020-06-29 15:16:21 +02:00
|
|
|
import {LinksResolver} from "./search/links-resolver";
|
|
|
|
import {BehaviorSubject, Subscriber} from "rxjs";
|
|
|
|
import {StakeholderService} from "./openaireLibrary/monitor/services/stakeholder.service";
|
|
|
|
import {Stakeholder} from "./openaireLibrary/monitor/entities/stakeholder";
|
2019-01-09 12:05:23 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
template: `
|
2020-06-03 23:55:32 +02:00
|
|
|
<div class="monitorApp">
|
2020-06-29 15:16:21 +02:00
|
|
|
<navbar *ngIf="properties && showMenu" portal="monitor" [onlyTop]=false [stakeholder]="stakeholder"
|
2019-09-30 14:48:48 +02:00
|
|
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
2020-06-03 23:55:32 +02:00
|
|
|
[showMenu]=showMenu [properties]="properties"></navbar>
|
2019-09-30 14:48:48 +02:00
|
|
|
<div class="custom-main-content">
|
|
|
|
<main>
|
|
|
|
<router-outlet></router-outlet>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
<cookie-law *ngIf="isClient" position="bottom">
|
|
|
|
OpenAIRE uses cookies in order to function properly.<br>
|
|
|
|
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
|
|
|
|
experience possible.
|
|
|
|
By using the OpenAIRE portal you accept our use of cookies. <a
|
2020-06-05 14:59:28 +02:00
|
|
|
href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
|
2019-09-30 14:48:48 +02:00
|
|
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
|
|
|
|
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03"
|
|
|
|
points="7 4 13 10 7 16"></polyline></svg>
|
|
|
|
</span></a>
|
|
|
|
</cookie-law>
|
2020-06-05 14:59:28 +02:00
|
|
|
<bottom *ngIf="properties && isClient && showMenu" [grantAdvance]="false"
|
2019-09-30 14:48:48 +02:00
|
|
|
[properties]="properties"></bottom>
|
|
|
|
</div>
|
|
|
|
`
|
2020-06-05 14:59:28 +02:00
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
})
|
|
|
|
export class AppComponent {
|
|
|
|
isClient: boolean = false;
|
|
|
|
userMenuItems: MenuItem[] = [];
|
|
|
|
menuItems: RootMenuItem [] = [];
|
|
|
|
bottomMenuItems: MenuItem[] = [];
|
2020-06-29 15:16:21 +02:00
|
|
|
properties: EnvProperties = properties;
|
2019-09-30 14:48:48 +02:00
|
|
|
showMenu: boolean = false;
|
|
|
|
user: User;
|
2020-06-29 15:16:21 +02:00
|
|
|
params: BehaviorSubject<Params> = new BehaviorSubject<Params>(null);
|
|
|
|
url: string;
|
|
|
|
stakeholder: Stakeholder = null;
|
|
|
|
private subscriptions: any[] = [];
|
2020-06-05 14:59:28 +02:00
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
2020-06-29 15:16:21 +02:00
|
|
|
private router: Router, private stakeholderService: StakeholderService,
|
|
|
|
private userManagementService: UserManagementService) {
|
2019-09-30 14:48:48 +02:00
|
|
|
router.events.forEach((event) => {
|
|
|
|
if (event instanceof NavigationStart) {
|
|
|
|
HelperFunctions.scroll();
|
2020-06-29 15:16:21 +02:00
|
|
|
} else if (event instanceof NavigationEnd) {
|
|
|
|
this.url = event.url;
|
|
|
|
let r = this.route;
|
|
|
|
while (r.firstChild) {
|
|
|
|
r = r.firstChild;
|
|
|
|
}
|
|
|
|
let params = r.snapshot.params;
|
|
|
|
this.params.next(params);
|
2019-09-30 14:48:48 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-06-05 14:59:28 +02:00
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
ngOnInit() {
|
2020-06-29 15:16:21 +02:00
|
|
|
this.subscriptions.push(this.params.subscribe( params => {
|
|
|
|
if (params && params['stakeholder']) {
|
|
|
|
if (!this.stakeholderService.stakeholder ||
|
|
|
|
this.stakeholderService.stakeholder.alias !== params['stakeholder']) {
|
|
|
|
this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => {
|
|
|
|
this.stakeholderService.setStakeholder(stakeholder);
|
|
|
|
this.stakeholder = stakeholder;
|
|
|
|
LinksResolver.setProperties(this.stakeholder.alias);
|
|
|
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
|
|
this.user = user;
|
|
|
|
this.setUserMenu();
|
|
|
|
this.buildStakeholderMenu();
|
|
|
|
}));
|
|
|
|
}, error => {
|
|
|
|
this.navigateToError();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LinksResolver.resetProperties();
|
|
|
|
this.stakeholderService.setStakeholder(null);
|
|
|
|
if(this.url && !this.url.includes('search')) {
|
|
|
|
this.stakeholder = null;
|
|
|
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
|
|
this.user = user;
|
|
|
|
this.setUserMenu();
|
|
|
|
this.buildMenu();
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(value => {
|
|
|
|
if (value instanceof Subscriber) {
|
|
|
|
value.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
navigateToError() {
|
|
|
|
this.router.navigate(['/error'], {queryParams: {'page': this.router.url}});
|
2019-09-30 14:48:48 +02:00
|
|
|
}
|
2020-06-05 14:59:28 +02:00
|
|
|
|
|
|
|
public buildMenu() {
|
|
|
|
this.menuItems = [];
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("about", "About", "", "/about/learn-how", false, [], null, {}),
|
|
|
|
items: []
|
|
|
|
});
|
|
|
|
this.menuItems.push({
|
2020-06-29 15:16:21 +02:00
|
|
|
rootItem: new MenuItem("stakeholders", "Browse", "", "browse", false, [], null, {}),
|
2020-06-05 14:59:28 +02:00
|
|
|
items: []
|
|
|
|
});
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("contact-us", "Contact us", "", "/contact-us", false, [], null, {}),
|
|
|
|
items: []
|
|
|
|
});
|
|
|
|
this.bottomMenuItems = [
|
|
|
|
new MenuItem("", "About", "https://beta.openaire.eu/project-factsheets", "", false, [], [], {}),
|
|
|
|
new MenuItem("", "News - Events", "https://beta.openaire.eu/news-events", "", false, [], [], {}),
|
|
|
|
new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}),
|
|
|
|
new MenuItem("", "Contact us", "https://beta.openaire.eu/contact-us", "", false, [], [], {})
|
|
|
|
];
|
2020-06-29 15:16:21 +02:00
|
|
|
this.showMenu = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public buildStakeholderMenu() {
|
|
|
|
this.menuItems = [];
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("", "Dashboard",
|
|
|
|
properties.baseLink + "/dashboard/" + this.stakeholder.alias , "", true, [], [], {}),
|
|
|
|
items: []
|
|
|
|
});
|
|
|
|
if (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user)) {
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("", "Manage",
|
|
|
|
properties.baseLink + "/dashboard/admin/" + this.stakeholder.alias , "", true, [], [], {}),
|
|
|
|
items: []
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.showMenu = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public setUserMenu() {
|
2020-06-05 14:59:28 +02:00
|
|
|
this.userMenuItems = [];
|
|
|
|
if (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user)) {
|
2020-06-12 16:14:34 +02:00
|
|
|
/*this.userMenuItems.push(new MenuItem("", "Manage Helptexts",
|
2020-06-05 14:59:28 +02:00
|
|
|
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
|
2020-06-12 16:14:34 +02:00
|
|
|
"", false, [], [], {}))*/
|
2020-06-05 14:59:28 +02:00
|
|
|
this.userMenuItems.push(new MenuItem("", "Manage Stakeholders",
|
2020-06-12 19:41:07 +02:00
|
|
|
properties.baseLink + "/dashboard/admin", "", true, [], [], {}))
|
2020-06-05 14:59:28 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-09 12:05:23 +01:00
|
|
|
}
|