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 {BehaviorSubject, Subscriber} from "rxjs";
|
|
|
|
import {StakeholderService} from "./openaireLibrary/monitor/services/stakeholder.service";
|
2020-10-14 13:23:40 +02:00
|
|
|
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
|
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-10-14 13:40:12 +02:00
|
|
|
<navbar *ngIf="properties && showMenu && header" portal="monitor" [header]="header" [onlyTop]="false"
|
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>
|
2020-10-13 22:32:48 +02:00
|
|
|
<cookie-law position="bottom">
|
2019-09-30 14:48:48 +02:00
|
|
|
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-10-13 22:32:48 +02:00
|
|
|
<bottom *ngIf="properties && 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 {
|
|
|
|
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;
|
2020-10-14 13:23:40 +02:00
|
|
|
header: Header;
|
|
|
|
logoPath: string = 'assets/common-assets/';
|
2020-06-29 15:16:21 +02:00
|
|
|
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-07-13 15:05:41 +02:00
|
|
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
|
|
this.user = user;
|
|
|
|
this.setUserMenu();
|
2020-10-14 13:23:40 +02:00
|
|
|
this.header = {
|
|
|
|
route: "/",
|
|
|
|
url: null,
|
|
|
|
title: 'monitor',
|
|
|
|
logoUrl: this.logoPath + 'logo-large-monitor.png',
|
|
|
|
logoSmallUrl:this.logoPath + 'logo-small-monitor.png',
|
|
|
|
position:'left',
|
|
|
|
badge:true
|
|
|
|
};
|
2020-07-13 15:05:41 +02:00
|
|
|
this.buildMenu();
|
2020-06-29 15:16:21 +02:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(value => {
|
|
|
|
if (value instanceof Subscriber) {
|
|
|
|
value.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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 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-09-21 09:28:46 +02:00
|
|
|
this.properties.domain + properties.baseLink + "/dashboard/admin", "", true, [], [], {}))
|
2020-06-05 14:59:28 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-09 12:05:23 +01:00
|
|
|
}
|