2018-01-11 11:55:54 +01:00
|
|
|
import { Component, Input } from '@angular/core';
|
2017-12-19 13:53:46 +01:00
|
|
|
// import 'rxjs/Rx';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
|
|
|
|
|
|
|
import {Session} from '../login/utils/helper.class';
|
|
|
|
import { ConfigurationService } from '../utils/configuration/configuration.service';
|
2018-02-05 14:14:59 +01:00
|
|
|
import{MenuItem,RootMenuItem} from './menu';
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'navbar',
|
|
|
|
templateUrl: 'navigationBar.component.html'
|
|
|
|
})
|
|
|
|
export class NavigationBarComponent {
|
2018-01-11 11:55:54 +01:00
|
|
|
@Input() portal:string = "connect";
|
|
|
|
@Input() onlyTop ;
|
|
|
|
@Input() logoPath:string = "assets/";
|
|
|
|
@Input() userMenu;
|
2018-01-11 16:20:43 +01:00
|
|
|
@Input() logInUrl;
|
|
|
|
@Input() logOutUrl;
|
2018-02-05 14:14:59 +01:00
|
|
|
@Input() APIUrl;
|
|
|
|
@Input() communityId;
|
|
|
|
@Input() cookieDomain;
|
|
|
|
@Input() userMenuItems:MenuItem[] ;
|
|
|
|
@Input() menuItems:RootMenuItem [] ;
|
|
|
|
@Input() community: {id:string, name:string, logoUrl:string};
|
2018-01-11 16:20:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
<li *ngIf="showDataProviders" class="uk-nav-header uk-parent">
|
|
|
|
Content Providers
|
|
|
|
<ul class="uk-nav-sub">
|
|
|
|
<li><a href="https://beta.openaire.eu/oa-policies-mandates" class="uk-offcanvas-close custom-offcanvas-close" >Data Policies</a></li>
|
|
|
|
<li><a routerLinkActive="uk-link" routerLink="/search/content-providers" class="uk-offcanvas-close custom-offcanvas-close" >Repositories</a></li>
|
|
|
|
<li><a routerLinkActive="uk-link" routerLink="/search/journals" class="uk-offcanvas-close custom-offcanvas-close" >Journals</a></li>
|
|
|
|
<li><a routerLinkActive="uk-link" routerLink="/search/entity-registries" class="uk-offcanvas-close custom-offcanvas-close" >Registries/ Databases</a></li>
|
|
|
|
<li><a routerLinkActive="uk-link" routerLink="/search/find/dataproviders" class="uk-offcanvas-close custom-offcanvas-close" >Browse all</a></li>
|
|
|
|
</ul>
|
|
|
|
</li>*/
|
2017-12-19 13:53:46 +01:00
|
|
|
public isAuthorized: boolean = false;
|
|
|
|
sub:any;
|
|
|
|
isClient:boolean = false;
|
2018-02-05 14:14:59 +01:00
|
|
|
showEntity ={};
|
|
|
|
showPage ={};
|
|
|
|
// showPublications:boolean= false;
|
|
|
|
// showDatasets:boolean= false;
|
|
|
|
// showSoftware:boolean=false;
|
|
|
|
// showProjects:boolean= false;
|
|
|
|
// showDataProviders:boolean= false;
|
|
|
|
// showOrganizations:boolean= false;
|
|
|
|
// showDepositDatasets:boolean= false;
|
|
|
|
// showDepositPublications:boolean= false;
|
|
|
|
// showLinking:boolean= false;
|
2017-12-19 13:53:46 +01:00
|
|
|
specialAnnouncementContent:string= null;
|
|
|
|
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
constructor( private router: Router, private route: ActivatedRoute, private config: ConfigurationService) {
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
ngOnInit() {
|
2018-01-11 16:20:43 +01:00
|
|
|
console.log(this.menuItems);
|
2017-12-19 13:53:46 +01:00
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
try{
|
|
|
|
this.isClient = true;
|
|
|
|
}catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// this.initialize();
|
|
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
|
|
|
this.initialize();
|
|
|
|
});
|
2018-01-11 11:55:54 +01:00
|
|
|
|
|
|
|
if(this.userMenu == "true"){
|
|
|
|
this.userMenu = true;
|
|
|
|
}
|
|
|
|
else if(this.userMenu == "false"){
|
|
|
|
this.userMenu = false;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this.userMenu = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.onlyTop == "true"){
|
|
|
|
this.onlyTop = true;
|
|
|
|
}
|
|
|
|
else if(this.onlyTop == "false"){
|
|
|
|
this.onlyTop = false;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this.onlyTop = false;
|
|
|
|
}
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
ngOnDestroy(){
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
|
|
|
initialize(){
|
|
|
|
if(Session.isLoggedIn() && Session.isUserValid() && Session.isAdminUser()){
|
|
|
|
this.isAuthorized = true;
|
|
|
|
}else {
|
|
|
|
this.isAuthorized = false;
|
|
|
|
}
|
|
|
|
|
2018-02-05 16:13:55 +01:00
|
|
|
if( this.APIUrl && this.communityId ){
|
2018-02-05 14:14:59 +01:00
|
|
|
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
|
|
|
|
for(var i=0; i< data.entities.length; i++){
|
|
|
|
|
|
|
|
this.showEntity[""+data.entities[i]["pid"]+""] = data.entities[i]["isEnabled"];
|
|
|
|
}
|
|
|
|
for(var i=0; i< data.pages.length; i++){
|
|
|
|
this.showPage[data.pages[i]["route"]] = data.pages[i]["isEnabled"];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2018-02-05 16:13:55 +01:00
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
onClick(id: string) {
|
|
|
|
var el: HTMLElement = document.getElementById(id);
|
|
|
|
el.classList.remove('uk-open');
|
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
isEnabled(required, enabled){
|
|
|
|
if(!required ){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(let requiredEntity of required){
|
|
|
|
// console.log(requiredEntity)
|
|
|
|
// console.log(enabled)
|
|
|
|
|
|
|
|
if(typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|