2020-12-15 13:48:37 +01:00
|
|
|
import {Component, Inject, RendererFactory2, ViewEncapsulation} from '@angular/core';
|
2019-05-23 15:38:44 +02:00
|
|
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
2022-09-21 00:05:21 +02:00
|
|
|
import {MenuItem} from './openaireLibrary/sharedComponents/menu';
|
2020-12-15 13:48:37 +01:00
|
|
|
import {AggregatorInfo, PortalAggregators} from "./utils/aggregators";
|
2019-09-24 14:42:17 +02:00
|
|
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
|
|
|
import {User} from "./openaireLibrary/login/utils/helper.class";
|
2020-11-18 18:01:52 +01:00
|
|
|
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
|
|
|
|
import {portalProperties} from "../environments/environment-aggregator";
|
2020-11-23 13:28:46 +01:00
|
|
|
import {properties} from "../environments/environment";
|
|
|
|
import {ConnectHelper} from "./openaireLibrary/connect/connectHelper";
|
2020-11-25 18:39:05 +01:00
|
|
|
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
|
|
|
import {Subscriber} from "rxjs";
|
2020-12-15 13:48:37 +01:00
|
|
|
import {DOCUMENT} from "@angular/common";
|
2021-04-21 14:36:46 +02:00
|
|
|
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
|
2022-05-03 15:53:37 +02:00
|
|
|
import {ActivatedRoute, NavigationEnd, Router} from "@angular/router";
|
[Aggregator | new-theme]: [NEW] Added service entity in Menu, properties and added landing and search pages.
1. aggregators.ts: Added in PortalAggregators.disabled object, service entity & route.
2. app.component.ts: Added in menuItems "Serive" and use for menuItems entity names from OpenaireEntities.
3. app-routing.module.ts: Added routes for service landing, search and advanced search pages.
4. environments/: Added values for properties searchLinkToService, searchLinkToServices, searchLinkToAdvancedServices, errorLink
5. [NEW] Files added for services landing, search and advanced search pages: landingPages/service/, advancedSearchServices.component.ts, advancedSearchServices.module.ts, advancedSearchServices-routing.module.ts, searchServices.component.ts, searchServices.module.ts, searchServices-routing.module.ts
2022-05-13 15:07:09 +02:00
|
|
|
import {OpenaireEntities} from "./openaireLibrary/utils/properties/searchFields";
|
2019-05-23 15:38:44 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
template: `
|
2022-08-08 11:47:14 +02:00
|
|
|
<div id="modal-container"></div>
|
2020-11-23 13:28:46 +01:00
|
|
|
<div *ngIf="agg">
|
2022-05-03 15:53:37 +02:00
|
|
|
<navbar *ngIf="properties && loginCheck && header && showHeader" portal="aggregator" [properties]=properties [onlyTop]=false
|
2020-11-23 13:28:46 +01:00
|
|
|
[user]="user" [userMenuItems]="userMenuItems"
|
|
|
|
[communityId]="properties.adminToolsCommunity" [menuItems]=menuItems
|
2022-02-18 15:58:47 +01:00
|
|
|
[userMenu]="agg.enableLogin" [header]="header"></navbar>
|
2020-11-23 13:28:46 +01:00
|
|
|
<div class="custom-main-content">
|
|
|
|
<main>
|
|
|
|
<router-outlet></router-outlet>
|
|
|
|
</main>
|
|
|
|
</div>
|
2022-08-08 16:20:28 +02:00
|
|
|
<cookie-law *ngIf="isClient" position="bottom">
|
2020-11-23 13:28:46 +01: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
|
2021-12-10 11:31:53 +01:00
|
|
|
href="https://www.openaire.eu/privacy-policy#cookies" target="_blank"> Read more <span class="uk-icon">
|
2019-05-23 15:38:44 +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>
|
2020-11-23 13:28:46 +01:00
|
|
|
</cookie-law>
|
2023-07-13 12:44:40 +02:00
|
|
|
<bottom *ngIf="isClient && properties" [properties]=properties [centered]="true" [showMenuItems]="true" [menuItems]="[]"></bottom>
|
2020-11-23 13:28:46 +01:00
|
|
|
</div>
|
2019-05-23 15:38:44 +02:00
|
|
|
`
|
|
|
|
})
|
|
|
|
export class AppComponent {
|
|
|
|
isClient: boolean = false;
|
2022-09-21 00:05:21 +02:00
|
|
|
menuItems: MenuItem [] = [];
|
2020-11-23 13:28:46 +01:00
|
|
|
userMenuItems: MenuItem[] = [];
|
2019-06-13 14:40:03 +02:00
|
|
|
community = null;
|
2019-10-17 14:21:24 +02:00
|
|
|
id: string = null;
|
2020-11-23 13:28:46 +01:00
|
|
|
properties: EnvProperties = properties;
|
2019-09-24 14:42:17 +02:00
|
|
|
user: User;
|
|
|
|
loginCheck: boolean = false;
|
2020-11-23 13:28:46 +01:00
|
|
|
footer = portalProperties.sectionFooter;
|
|
|
|
header: Header;
|
2022-05-03 15:53:37 +02:00
|
|
|
showHeader;
|
2020-12-15 13:48:37 +01:00
|
|
|
agg: AggregatorInfo = null;
|
2020-11-25 18:39:05 +01:00
|
|
|
subscriptions = [];
|
2022-02-18 15:58:47 +01:00
|
|
|
|
2021-04-21 14:36:46 +02:00
|
|
|
constructor(private userManagementService: UserManagementService,
|
|
|
|
private configurationService: ConfigurationService, private smoothScroll: SmoothScroll,
|
2022-05-03 15:53:37 +02:00
|
|
|
@Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2, private router: Router, private route: ActivatedRoute) {
|
2020-11-25 18:39:05 +01:00
|
|
|
this.id = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
|
|
|
this.agg = PortalAggregators.getFilterInfoByMenuId(this.id);
|
2020-12-15 13:48:37 +01:00
|
|
|
this.setStyles();
|
2023-07-13 12:44:40 +02:00
|
|
|
this.configurationService.initStaticPortal(PortalAggregators.getCommunityInfoByMenuId(this.id));
|
2022-05-03 15:53:37 +02:00
|
|
|
this.showHeader = this.agg.showHeaderAlways;
|
2020-11-25 18:39:05 +01:00
|
|
|
}
|
2022-02-18 15:58:47 +01:00
|
|
|
|
2020-11-23 13:28:46 +01:00
|
|
|
ngOnInit() {
|
2022-05-03 15:53:37 +02:00
|
|
|
this.subscriptions.push(this.router.events.subscribe(event => {
|
|
|
|
if (event instanceof NavigationEnd) {
|
|
|
|
let r = this.route;
|
|
|
|
while (r.firstChild) {
|
|
|
|
r = r.firstChild;
|
|
|
|
}
|
|
|
|
this.showHeader = (r.snapshot.data.showHeader == true || this.agg.showHeaderAlways);
|
|
|
|
}
|
|
|
|
}));
|
2020-11-23 13:28:46 +01:00
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
this.isClient = true;
|
|
|
|
}
|
|
|
|
this.id = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
|
|
|
this.agg = PortalAggregators.getFilterInfoByMenuId(this.id);
|
|
|
|
if (this.agg) {
|
|
|
|
this.header = {
|
|
|
|
route: '/',
|
|
|
|
url: null,
|
|
|
|
title: this.agg.title,
|
|
|
|
logoUrl: this.agg.logoUrl,
|
|
|
|
logoSmallUrl: this.agg.logoUrl,
|
2022-08-08 16:20:28 +02:00
|
|
|
position: 'left',
|
2022-10-20 22:05:43 +02:00
|
|
|
menuPosition: 'center',
|
2022-08-08 16:20:28 +02:00
|
|
|
badge: true
|
2020-11-23 13:28:46 +01:00
|
|
|
};
|
|
|
|
this.buildMenu();
|
|
|
|
}
|
2020-11-25 18:39:05 +01:00
|
|
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
2020-11-23 13:28:46 +01:00
|
|
|
this.user = user;
|
|
|
|
this.loginCheck = true;
|
|
|
|
this.userMenuItems = [];
|
|
|
|
if (this.user) {
|
2020-12-15 13:48:37 +01:00
|
|
|
this.userMenuItems.push(new MenuItem("", "My links", "", "/myclaims", false, [], [], {}));
|
2022-11-09 12:41:33 +01:00
|
|
|
this.userMenuItems.push(new MenuItem("", "My ORCID links", "", "/my-orcid-links", false, [], [""], {}));
|
2020-12-15 13:48:37 +01:00
|
|
|
// this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|
2020-11-25 18:39:05 +01:00
|
|
|
}));
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|
2022-02-18 15:58:47 +01:00
|
|
|
|
2021-04-21 14:36:46 +02:00
|
|
|
ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.configurationService.clearSubscriptions();
|
|
|
|
this.userManagementService.clearSubscriptions();
|
|
|
|
this.smoothScroll.clearSubscriptions();
|
|
|
|
}
|
2022-02-18 15:58:47 +01:00
|
|
|
|
2019-10-17 14:21:24 +02:00
|
|
|
private buildMenu() {
|
|
|
|
this.menuItems = [
|
2022-09-21 00:05:21 +02:00
|
|
|
new MenuItem("home", "Home", "", "/", false, [], null, {}),
|
|
|
|
new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find"], {}),
|
|
|
|
new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], {}),
|
|
|
|
new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], {},
|
|
|
|
null, null, null, null, "_blank", "internal", false,
|
|
|
|
[
|
|
|
|
new MenuItem("", "Start linking", "", "/participate/claim", false, [], ["/participate/claim"], {}),
|
|
|
|
new MenuItem("", "Learn more", this.properties.claimsInformationLink, "", false, [], [], {})
|
|
|
|
]
|
|
|
|
),
|
|
|
|
new MenuItem("develop", "Develop", "", "/develop", false, [], ["/develop"], {}),
|
2019-10-17 14:21:24 +02:00
|
|
|
];
|
2020-11-23 13:28:46 +01:00
|
|
|
let params = {};
|
2020-11-26 16:03:13 +01:00
|
|
|
// params[this.agg.queryFieldName] = this.agg.valueId;
|
[Aggregator | new-theme]: [NEW] Added service entity in Menu, properties and added landing and search pages.
1. aggregators.ts: Added in PortalAggregators.disabled object, service entity & route.
2. app.component.ts: Added in menuItems "Serive" and use for menuItems entity names from OpenaireEntities.
3. app-routing.module.ts: Added routes for service landing, search and advanced search pages.
4. environments/: Added values for properties searchLinkToService, searchLinkToServices, searchLinkToAdvancedServices, errorLink
5. [NEW] Files added for services landing, search and advanced search pages: landingPages/service/, advancedSearchServices.component.ts, advancedSearchServices.module.ts, advancedSearchServices-routing.module.ts, searchServices.component.ts, searchServices.module.ts, searchServices-routing.module.ts
2022-05-13 15:07:09 +02:00
|
|
|
this.menuItems[1].items.push(new MenuItem("", OpenaireEntities.RESULTS, "", properties.searchLinkToResults, false, [], ["/search/find/research-outcomes"], params));
|
|
|
|
this.menuItems[1].items.push(new MenuItem("", OpenaireEntities.PROJECTS, "", properties.searchLinkToProjects, false, ["project"], ["/search/find/projects"], params));
|
|
|
|
this.menuItems[1].items.push(new MenuItem("", OpenaireEntities.DATASOURCES, "", properties.searchLinkToDataProviders, false, ["datasource"], ["/search/find/dataproviders"], params));
|
2022-05-19 17:35:59 +02:00
|
|
|
this.menuItems[1].items.push(new MenuItem("", OpenaireEntities.SERVICES, "", properties.searchLinkToServices, false, ["service"], ["/search/find/services"], params));
|
[Aggregator | new-theme]: [NEW] Added service entity in Menu, properties and added landing and search pages.
1. aggregators.ts: Added in PortalAggregators.disabled object, service entity & route.
2. app.component.ts: Added in menuItems "Serive" and use for menuItems entity names from OpenaireEntities.
3. app-routing.module.ts: Added routes for service landing, search and advanced search pages.
4. environments/: Added values for properties searchLinkToService, searchLinkToServices, searchLinkToAdvancedServices, errorLink
5. [NEW] Files added for services landing, search and advanced search pages: landingPages/service/, advancedSearchServices.component.ts, advancedSearchServices.module.ts, advancedSearchServices-routing.module.ts, searchServices.component.ts, searchServices.module.ts, searchServices-routing.module.ts
2022-05-13 15:07:09 +02:00
|
|
|
this.menuItems[1].items.push(new MenuItem("", OpenaireEntities.ORGANIZATIONS, "", properties.searchLinkToOrganizations, false, ["organization"], ["/search/find/organizations"], params));
|
2020-11-25 18:39:05 +01:00
|
|
|
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|
2020-12-15 13:48:37 +01:00
|
|
|
setStyles(){
|
2022-05-03 15:53:37 +02:00
|
|
|
let css:string = this.agg.customCss;
|
2020-12-15 13:48:37 +01:00
|
|
|
try {
|
|
|
|
if( this.document.getElementById('customStyle')){
|
|
|
|
try {
|
|
|
|
this.document.getElementById('customStyle').append(css);
|
|
|
|
}catch(e){
|
|
|
|
console.log("error with append style")
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
const renderer = this.rendererFactory.createRenderer(this.document, {
|
|
|
|
id: '-1',
|
|
|
|
encapsulation: ViewEncapsulation.None,
|
|
|
|
styles: [],
|
|
|
|
data: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
const head = this.document.head;
|
|
|
|
if (head === null) {
|
|
|
|
throw new Error('<head> not found within DOCUMENT.');
|
|
|
|
}
|
|
|
|
const style = renderer.createElement('style');
|
|
|
|
renderer.setAttribute(style, "id", "customStyle");
|
|
|
|
let CSSElement = renderer.createText(css);
|
|
|
|
renderer.appendChild(head, style);
|
|
|
|
renderer.appendChild(style, CSSElement);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Renderrer Error to append style ', e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-23 15:38:44 +02:00
|
|
|
}
|