99 lines
3.9 KiB
TypeScript
99 lines
3.9 KiB
TypeScript
|
import { Component } from '@angular/core';
|
||
|
// 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';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'navbar',
|
||
|
templateUrl: 'navigationBar.component.html'
|
||
|
})
|
||
|
export class NavigationBarComponent {
|
||
|
public isAuthorized: boolean = false;
|
||
|
sub:any;
|
||
|
isClient:boolean = false;
|
||
|
|
||
|
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;
|
||
|
specialAnnouncementContent:string= null;
|
||
|
|
||
|
|
||
|
constructor( private router: Router, private route: ActivatedRoute, private config: ConfigurationService) {}
|
||
|
|
||
|
ngOnInit() {
|
||
|
if (typeof document !== 'undefined') {
|
||
|
try{
|
||
|
this.isClient = true;
|
||
|
}catch (e) {
|
||
|
}
|
||
|
}
|
||
|
// this.initialize();
|
||
|
this.sub = this.route.queryParams.subscribe(params => {
|
||
|
this.initialize();
|
||
|
});
|
||
|
console.log("Before get entities");
|
||
|
|
||
|
// const entityOne = this.config.isEntityEnabled("publication");
|
||
|
// const entityTwo = this.config.isEntityEnabled("dataset");
|
||
|
// const entityThree = this.config.isEntityEnabled("project");
|
||
|
// const entityFour = this.config.isEntityEnabled("organization");
|
||
|
// const entityFive = this.config.isEntityEnabled("datasource");
|
||
|
// const entitySix = this.config.isEntityEnabled("software");
|
||
|
// const entity7 = this.config.isPageEnabled("participate/deposit-publications");
|
||
|
// const entity8 = this.config.isPageEnabled("participate/deposit-datasets");
|
||
|
// const entity9 = this.config.isPageEnabled("participate/claim");
|
||
|
// const example = Observable.zip(entityOne,entityTwo,entityThree,entityFour,entityFive,entitySix, entity7, entity8, entity9);
|
||
|
// const subscribe = example.subscribe(data => {
|
||
|
// console.log("Got the respond")
|
||
|
// this.showPublications = data[0];
|
||
|
// this.showDatasets = data[1];
|
||
|
// this.showProjects = data[2];
|
||
|
// this.showOrganizations = data[3];
|
||
|
// this.showDataProviders = data[4];
|
||
|
// this.showSoftware = data[5];
|
||
|
// this.showDepositPublications = data[6];
|
||
|
// this.showDepositDatasets = data[7];
|
||
|
// this.showLinking = data[8];
|
||
|
// });
|
||
|
|
||
|
}
|
||
|
ngOnDestroy(){
|
||
|
this.sub.unsubscribe();
|
||
|
}
|
||
|
initialize(){
|
||
|
if(Session.isLoggedIn() && Session.isUserValid() && Session.isAdminUser()){
|
||
|
this.isAuthorized = true;
|
||
|
}else {
|
||
|
this.isAuthorized = false;
|
||
|
}
|
||
|
this.config.isEntityEnabled("publication").subscribe(data => {
|
||
|
console.log("heree");
|
||
|
this.showPublications = data;
|
||
|
});
|
||
|
this.config.isEntityEnabled("dataset").subscribe(data => { this.showDatasets = data;});
|
||
|
this.config.isEntityEnabled("software").subscribe(data => { this.showSoftware = data;})
|
||
|
this.config.isEntityEnabled("project").subscribe(data => { this.showProjects = data;});
|
||
|
this.config.isEntityEnabled("organization").subscribe(data => { this.showOrganizations = data;});
|
||
|
this.config.isEntityEnabled("datasource").subscribe(data => { this.showDataProviders = data;});
|
||
|
|
||
|
this.config.isPageEnabled("participate/deposit-publications").subscribe(data => { this.showDepositPublications = data;});
|
||
|
this.config.isPageEnabled("participate/deposit-datasets").subscribe(data => { this.showDepositDatasets = data;});
|
||
|
this.config.isPageEnabled("participate/claim").subscribe(data => { this.showLinking = data;});
|
||
|
this.config.getSpecialAnouncementContent().subscribe(data => { this.specialAnnouncementContent = data;});
|
||
|
}
|
||
|
onClick(id: string) {
|
||
|
var el: HTMLElement = document.getElementById(id);
|
||
|
el.classList.remove('uk-open');
|
||
|
}
|
||
|
|
||
|
}
|