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 ;
|
2018-05-11 13:33:50 +02:00
|
|
|
@Input() logoPath:string = "assets/common-assets/";
|
2018-01-11 11:55:54 +01:00
|
|
|
@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-03-16 09:56:42 +01:00
|
|
|
@Input() showMenu:boolean = true;
|
2018-01-11 16:20:43 +01:00
|
|
|
|
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 ={};
|
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.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(){
|
2018-06-12 13:15:42 +02:00
|
|
|
if(Session.isLoggedIn() && (Session.isClaimsCurator() || Session.isPortalAdministrator())){
|
2017-12-19 13:53:46 +01:00
|
|
|
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){
|
|
|
|
if(typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|