2019-05-23 15:38:44 +02:00
|
|
|
import {Component} from '@angular/core';
|
|
|
|
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
|
|
|
|
|
|
|
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 {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
2019-06-13 14:40:03 +02:00
|
|
|
import {FilterInfo, 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";
|
2019-05-23 15:38:44 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
//changeDetection: ChangeDetectionStrategy.Default,
|
|
|
|
//encapsulation: ViewEncapsulation.Emulated,
|
|
|
|
selector: 'app-root',
|
|
|
|
styles: [`
|
|
|
|
`],
|
|
|
|
template: `
|
|
|
|
|
2019-09-24 14:42:17 +02:00
|
|
|
<navbar *ngIf="properties && loginCheck" portal="aggregator" [properties]=properties [onlyTop]=false [user]="user"
|
|
|
|
[communityId]="properties.adminToolsCommunity" [menuItems]=menuItems
|
2019-06-13 14:40:03 +02:00
|
|
|
[userMenu]="false" [community]="community" [showCommunityName]="true"></navbar>
|
2019-05-23 15:38:44 +02:00
|
|
|
<div class="custom-main-content">
|
|
|
|
<main>
|
|
|
|
<router-outlet></router-outlet>
|
|
|
|
</main>
|
|
|
|
</div>
|
2019-05-24 15:54:22 +02:00
|
|
|
<cookie-law *ngIf="isClient" position="bottom">
|
2019-05-23 15:38:44 +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
|
|
|
|
href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
|
|
|
|
<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>
|
2019-06-13 14:40:03 +02:00
|
|
|
<bottom *ngIf="isClient && properties" [properties]=properties></bottom>
|
2019-05-23 15:38:44 +02:00
|
|
|
|
|
|
|
`
|
|
|
|
|
|
|
|
})
|
|
|
|
export class AppComponent {
|
|
|
|
isClient: boolean = false;
|
|
|
|
menuItems: RootMenuItem [] = [
|
|
|
|
{rootItem: new MenuItem("home", "Home", "", "/", false, [], null, {}), items: []},
|
|
|
|
{
|
2019-09-24 14:42:17 +02:00
|
|
|
rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], null, {}),
|
2019-06-14 15:14:22 +02:00
|
|
|
items: [new MenuItem("", "Publications", "", "/search/find/publications", false, [], [], {}),
|
|
|
|
new MenuItem("", "Research Data", "", "/search/find/datasets", false, [], [], {}),
|
|
|
|
new MenuItem("", "Software", "", "/search/find/software", false, [], [], {}),
|
|
|
|
new MenuItem("", "Other Research Products", "", "/search/find/other", false, [], [], {}),
|
|
|
|
new MenuItem("", "Projects", "", "/search/find/projects/", false, [], [], {}),
|
|
|
|
new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, [], [], {}),
|
|
|
|
new MenuItem("", "Organizations", "", "/search/find/organizations/", false, [], [], {})
|
2019-05-23 15:38:44 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
2019-06-13 14:40:03 +02:00
|
|
|
community = null;
|
2019-05-23 15:38:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
properties: EnvProperties;
|
2019-09-24 14:42:17 +02:00
|
|
|
user: User;
|
|
|
|
loginCheck: boolean = false;
|
2019-05-23 15:38:44 +02:00
|
|
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
2019-09-24 14:42:17 +02:00
|
|
|
private router: Router, private userManagementService: UserManagementService) {
|
2019-06-13 14:40:03 +02:00
|
|
|
|
2019-05-23 15:38:44 +02:00
|
|
|
router.events.forEach((event) => {
|
2019-06-13 14:40:03 +02:00
|
|
|
|
2019-05-23 15:38:44 +02:00
|
|
|
if (event instanceof NavigationStart) {
|
|
|
|
HelperFunctions.scroll();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2019-06-13 14:40:03 +02:00
|
|
|
let id = this.router.url;
|
|
|
|
|
|
|
|
console.log("Id is:"+id);
|
|
|
|
let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id);
|
|
|
|
if(agg){
|
|
|
|
this.community = {id: agg.menuId, name: agg.title, logoUrl:agg.logoUrl};
|
|
|
|
}
|
2019-05-23 15:38:44 +02:00
|
|
|
|
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
try {
|
|
|
|
this.isClient = true;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
this.propertiesService.loadEnvironment()
|
|
|
|
.then(es => {
|
|
|
|
this.propertiesService.setEnvProperties(es);
|
|
|
|
this.properties = this.propertiesService.envSpecific;
|
2019-09-24 14:42:17 +02:00
|
|
|
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
|
|
|
this.user = user;
|
|
|
|
this.loginCheck = true;
|
|
|
|
console.log(this.user)
|
|
|
|
});
|
2019-05-23 15:38:44 +02:00
|
|
|
}, error => {
|
|
|
|
console.log("App couldn't fetch properties");
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|