1
|
import { Component } from '@angular/core';
|
2
|
// import 'rxjs/Rx';
|
3
|
import {ActivatedRoute, Router} from '@angular/router';
|
4
|
import {Observable} from 'rxjs/Observable';
|
5
|
|
6
|
import {Session} from '../login/utils/helper.class';
|
7
|
import { ConfigurationService } from '../utils/configuration/configuration.service';
|
8
|
|
9
|
@Component({
|
10
|
selector: 'navbar',
|
11
|
templateUrl: 'navigationBar.component.html'
|
12
|
})
|
13
|
export class NavigationBarComponent {
|
14
|
public isAuthorized: boolean = false;
|
15
|
sub:any;
|
16
|
isClient:boolean = false;
|
17
|
|
18
|
showPublications:boolean= false;
|
19
|
showDatasets:boolean= false;
|
20
|
showSoftware:boolean=false;
|
21
|
showProjects:boolean= false;
|
22
|
showDataProviders:boolean= false;
|
23
|
showOrganizations:boolean= false;
|
24
|
showDepositDatasets:boolean= false;
|
25
|
showDepositPublications:boolean= false;
|
26
|
showLinking:boolean= false;
|
27
|
specialAnnouncementContent:string= null;
|
28
|
|
29
|
|
30
|
constructor( private router: Router, private route: ActivatedRoute, private config: ConfigurationService) {}
|
31
|
|
32
|
ngOnInit() {
|
33
|
if (typeof document !== 'undefined') {
|
34
|
try{
|
35
|
this.isClient = true;
|
36
|
}catch (e) {
|
37
|
}
|
38
|
}
|
39
|
// this.initialize();
|
40
|
this.sub = this.route.queryParams.subscribe(params => {
|
41
|
this.initialize();
|
42
|
});
|
43
|
console.log("Before get entities");
|
44
|
|
45
|
// const entityOne = this.config.isEntityEnabled("publication");
|
46
|
// const entityTwo = this.config.isEntityEnabled("dataset");
|
47
|
// const entityThree = this.config.isEntityEnabled("project");
|
48
|
// const entityFour = this.config.isEntityEnabled("organization");
|
49
|
// const entityFive = this.config.isEntityEnabled("datasource");
|
50
|
// const entitySix = this.config.isEntityEnabled("software");
|
51
|
// const entity7 = this.config.isPageEnabled("participate/deposit-publications");
|
52
|
// const entity8 = this.config.isPageEnabled("participate/deposit-datasets");
|
53
|
// const entity9 = this.config.isPageEnabled("participate/claim");
|
54
|
// const example = Observable.zip(entityOne,entityTwo,entityThree,entityFour,entityFive,entitySix, entity7, entity8, entity9);
|
55
|
// const subscribe = example.subscribe(data => {
|
56
|
// console.log("Got the respond")
|
57
|
// this.showPublications = data[0];
|
58
|
// this.showDatasets = data[1];
|
59
|
// this.showProjects = data[2];
|
60
|
// this.showOrganizations = data[3];
|
61
|
// this.showDataProviders = data[4];
|
62
|
// this.showSoftware = data[5];
|
63
|
// this.showDepositPublications = data[6];
|
64
|
// this.showDepositDatasets = data[7];
|
65
|
// this.showLinking = data[8];
|
66
|
// });
|
67
|
|
68
|
}
|
69
|
ngOnDestroy(){
|
70
|
this.sub.unsubscribe();
|
71
|
}
|
72
|
initialize(){
|
73
|
if(Session.isLoggedIn() && Session.isUserValid() && Session.isAdminUser()){
|
74
|
this.isAuthorized = true;
|
75
|
}else {
|
76
|
this.isAuthorized = false;
|
77
|
}
|
78
|
this.config.isEntityEnabled("publication").subscribe(data => {
|
79
|
console.log("heree");
|
80
|
this.showPublications = data;
|
81
|
});
|
82
|
this.config.isEntityEnabled("dataset").subscribe(data => { this.showDatasets = data;});
|
83
|
this.config.isEntityEnabled("software").subscribe(data => { this.showSoftware = data;})
|
84
|
this.config.isEntityEnabled("project").subscribe(data => { this.showProjects = data;});
|
85
|
this.config.isEntityEnabled("organization").subscribe(data => { this.showOrganizations = data;});
|
86
|
this.config.isEntityEnabled("datasource").subscribe(data => { this.showDataProviders = data;});
|
87
|
|
88
|
this.config.isPageEnabled("participate/deposit-publications").subscribe(data => { this.showDepositPublications = data;});
|
89
|
this.config.isPageEnabled("participate/deposit-datasets").subscribe(data => { this.showDepositDatasets = data;});
|
90
|
this.config.isPageEnabled("participate/claim").subscribe(data => { this.showLinking = data;});
|
91
|
this.config.getSpecialAnouncementContent().subscribe(data => { this.specialAnnouncementContent = data;});
|
92
|
}
|
93
|
onClick(id: string) {
|
94
|
var el: HTMLElement = document.getElementById(id);
|
95
|
el.classList.remove('uk-open');
|
96
|
}
|
97
|
|
98
|
}
|