import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute} 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 {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
import {Session} from './openaireLibrary/login/utils/helper.class';
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
@Component({
//changeDetection: ChangeDetectionStrategy.Default,
//encapsulation: ViewEncapsulation.Emulated,
selector: 'app-root',
styles: [`
`],
template: `
OpenAIRE uses cookies in order to function properly.
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. Read more
`
})
export class AppComponent {
isClient:boolean = false;
userMenuItems:MenuItem[] =[];
menuItems:RootMenuItem []=[];
bottomMenuItems:MenuItem[] =[];
public community = null;
properties:EnvProperties;
showMenu:boolean = false;
communities = null;
// community: {id:string, name:string, logoUrl:string};
constructor( private route: ActivatedRoute, private propertiesService:EnvironmentSpecificService, private _communitiesService:CommunitiesService ) {
}
ngOnInit() {
this.propertiesService.loadEnvironment()
.then(es => {
this.propertiesService.setEnvProperties(es);
this.properties = this.propertiesService.envSpecific;
this.route.queryParams.subscribe(data => {
var community = null;
this.community = null;
this.showMenu = false;
// var test:MenuItem = new MenuItem("monitor","Monitor","","/monitor",false,[],["/monitor"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId});
// test.
this._communitiesService.getCommunities(this.properties, this.properties.communitiesAPI).subscribe (
communities => {
for(var com of communities){
if((data['communityId'] && data['communityId']!="" && com.communityId == data['communityId'])
|| (ConnectHelper.getCommunityFromDomain(document.location.hostname) == com.communityId )){
community = com;
this.community = {id: community.communityId, name: (community.shortTitle)?community.shortTitle:community.title, logoUrl:community.logoUrl};
this.menuItems= [
// {rootItem: new MenuItem("dashboard","Dashboard","","/",false,[],[],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
// items: []
// },
{rootItem: new MenuItem("search","Search","","/search/find",false,[],["/search/find", "/search/find/publications", "/search/find/datasets", "/search/find/software", "/search/find/other", "/search/find/projects", "/search/find/dataproviders"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
items: [new MenuItem("","Publications","","/search/find/publications",false,["publication"],["/search/find/publications"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Research Data","","/search/find/datasets",false,["dataset"],["/search/find/datasets"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Software","","/search/find/software",false,["software"],["/search/find/software"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Other Research Products","","/search/find/other",false,["orp"],["/search/find/other"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Projects","","/search/find/projects/",false,["project"],["/search/find/projects"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Content Providers","","/search/find/dataproviders",false,["datasource"],["/search/find/dataproviders"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
]},
{
rootItem: new MenuItem("monitor","Monitor","","/monitor",false,[],["/monitor"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
items: []
},
{
rootItem: new MenuItem("share","Share","","",false,[],["/participate/deposit-publications","/participate/deposit-datasets","/participate/share-zenodo"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
items: [
new MenuItem("","Zenodo Communities","","/participate/share-zenodo",false,[],["/participate/share-zenodo"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Research Data","","/participate/deposit-datasets",false,["dataset"],["/participate/deposit-datasets"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId})]
},
{
rootItem: new MenuItem("link","Link","","/participate/claim",false,[],["/participate/claim"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
items: []
}
];
}
}
if(community == null){
this.menuItems= [];
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,[],[],{})
];
// if(this.properties.showContent){
// this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
// }
this.userMenuItems =[
// new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],(data['communityId'] && typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:data['communityId']}),
];
}else{
this.bottomMenuItems = [
new MenuItem("","About","","/about",false,[],["/about"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Organizations","","/organizations",false,[],["/organizations"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId})
];
if(this.properties.showContent){
this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
}
this.userMenuItems =[ new MenuItem("","My profile","","",false,[],[],{}),
new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
new MenuItem("","Invite users","","/invite",false,[],[],(typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:community.communityId}),
];
}
this.showMenu = true;
});
});
if (typeof document !== 'undefined') {
try{
this.isClient = true;
}catch (e) {
}
}
}, error => {
console.log("App couldn't fetch properties");
console.log(error);
});
}
}