1
|
import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation, Injector } from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
import {ActivatedRoute} from '@angular/router';
|
4
|
|
5
|
import { EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
6
|
import{MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
7
|
import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
8
|
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
|
9
|
import {Session} from './openaireLibrary/login/utils/helper.class';
|
10
|
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
|
11
|
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
|
12
|
|
13
|
// import {LayoutService} from "./openaireLibrary/services/layout.service";
|
14
|
|
15
|
@Component({
|
16
|
//changeDetection: ChangeDetectionStrategy.Default,
|
17
|
//encapsulation: ViewEncapsulation.Emulated,
|
18
|
selector: 'app-root',
|
19
|
styles: [`
|
20
|
`],
|
21
|
template: `
|
22
|
|
23
|
<navbar *ngIf= "properties && showMenu && !community" [environment]=properties.environment portal="connect" [onlyTop]=false [userMenuItems]=userMenuItems [menuItems]=menuItems
|
24
|
[(APIUrl)]="properties.adminToolsAPIURL" [(logInUrl)]="properties.loginUrl" [(logOutUrl)]="properties.logoutUrl" [(cookieDomain)]="properties.cookieDomain" [showMenu]=showMenu></navbar>
|
25
|
<navbar *ngIf= "properties && showMenu && community" [environment]=properties.environment portal="connect" [onlyTop]=false [(communityId)]="community.id" [userMenuItems]=userMenuItems [menuItems]=menuItems
|
26
|
[(APIUrl)]="properties.adminToolsAPIURL" [(logInUrl)]="properties.loginUrl" [(logOutUrl)]="properties.logoutUrl" [(cookieDomain)]="properties.cookieDomain" [(community)]=community [showMenu]=showMenu></navbar>
|
27
|
|
28
|
<div class="custom-main-content" >
|
29
|
<main>
|
30
|
<router-outlet></router-outlet>
|
31
|
</main>
|
32
|
</div>
|
33
|
<!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
|
34
|
<cookie-law *ngIf= "isClient" position="bottom">
|
35
|
OpenAIRE uses cookies in order to function properly.<br>
|
36
|
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing experience possible.
|
37
|
By using the OpenAIRE portal you accept our use of cookies. <a href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
|
38
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
|
39
|
</span></a>
|
40
|
</cookie-law>
|
41
|
<bottom *ngIf= "properties && isClient && showMenu && !community" [environment]=properties.environment [grantAdvance]="false" ></bottom>
|
42
|
<bottom *ngIf= "properties && isClient && showMenu && community" [environment]=properties.environment [showSocialButtons] = "true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true" [(communityId)]="community.id" [(APIUrl)]="properties.adminToolsAPIURL" [menuItems]=bottomMenuItems ></bottom>
|
43
|
|
44
|
`
|
45
|
|
46
|
})
|
47
|
export class AppComponent {
|
48
|
isClient:boolean = false;
|
49
|
|
50
|
userMenuItems:MenuItem[] =[];
|
51
|
|
52
|
|
53
|
menuItems:RootMenuItem []=[];
|
54
|
bottomMenuItems:MenuItem[] =[];
|
55
|
public community = null;
|
56
|
properties:EnvProperties;
|
57
|
showMenu:boolean = false;
|
58
|
communities = null;
|
59
|
subscriberOfCommunities = [];
|
60
|
managerOfCommunities = [];
|
61
|
|
62
|
// layout = null;
|
63
|
// community: {id:string, name:string, logoUrl:string};
|
64
|
constructor( private route: ActivatedRoute, private propertiesService:EnvironmentSpecificService,
|
65
|
private _communitiesService:CommunitiesService, private _subscribeService: SubscribeService,){//, private _layoutService: LayoutService) {
|
66
|
|
67
|
}
|
68
|
|
69
|
ngOnInit() {
|
70
|
this.propertiesService.loadEnvironment()
|
71
|
.then(es => {
|
72
|
this.properties = this.propertiesService.envSpecific;
|
73
|
this.route.queryParams.subscribe(data => {
|
74
|
var community = null;
|
75
|
this.community = null;
|
76
|
this.showMenu = false;
|
77
|
|
78
|
this._communitiesService.getCommunities(this.properties, this.properties.communitiesAPI).subscribe (
|
79
|
communities => {
|
80
|
console.log(communities);
|
81
|
for(var com of communities){
|
82
|
if(Session.isLoggedIn() && com['status'] != "hidden"){
|
83
|
if(Session.isCommunityCurator() || Session.isPortalAdministrator()){
|
84
|
this.managerOfCommunities.push(com);
|
85
|
}else if(com.managers.indexOf(Session.getUserEmail())!=-1){
|
86
|
this.managerOfCommunities.push(com);
|
87
|
}else{
|
88
|
// check if subscriber
|
89
|
if(com['status'] != "private"){
|
90
|
this._subscribeService.isSubscribedToCommunity(com.communityId, Session.getUserEmail(), this.properties.adminToolsAPIURL).subscribe (
|
91
|
isSubscriber => {
|
92
|
if(isSubscriber) {
|
93
|
this.subscriberOfCommunities.push(com);
|
94
|
}
|
95
|
},
|
96
|
error => {
|
97
|
console.error("Error fetching your subscribed communities")
|
98
|
});
|
99
|
}
|
100
|
}
|
101
|
}
|
102
|
|
103
|
|
104
|
|
105
|
if((data['communityId'] && data['communityId']!="" && com.communityId == data['communityId'])
|
106
|
|| (ConnectHelper.getCommunityFromDomain(this.properties.domain) == com.communityId ) ){
|
107
|
community = com;
|
108
|
// this._layoutService.getLayout(com.communityId,
|
109
|
// this.properties.adminToolsAPIURL + '/').subscribe (
|
110
|
// layout => {
|
111
|
// this.layout = layout;
|
112
|
// document.documentElement.style.setProperty('--portal-main-color', this.layout.color);
|
113
|
// }
|
114
|
// );
|
115
|
this.community = {id: community.communityId, name: (community.shortTitle)?community.shortTitle:community.title, logoUrl:community.logoUrl};
|
116
|
this.menuItems= [
|
117
|
{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"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
118
|
items: [new MenuItem("","Publications","","/search/find/publications",false,["publication"],["/search/find/publications"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
119
|
new MenuItem("","Research Data","","/search/find/datasets",false,["dataset"],["/search/find/datasets"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
120
|
new MenuItem("","Software","","/search/find/software",false,["software"],["/search/find/software"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
121
|
new MenuItem("","Other Research Products","","/search/find/other",false,["orp"],["/search/find/other"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
122
|
new MenuItem("","Projects","","/search/find/projects/",false,["project"],["/search/find/projects"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
123
|
new MenuItem("","Content Providers","","/search/find/dataproviders",false,["datasource"],["/search/find/dataproviders"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
124
|
]},
|
125
|
{
|
126
|
rootItem: new MenuItem("monitor","Monitor","","/monitor",false,[],["/monitor"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
127
|
items: []
|
128
|
},
|
129
|
{
|
130
|
rootItem: new MenuItem("share","Share","","",false,[],["/participate/deposit-publications","/participate/deposit-datasets","/participate/share-zenodo"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
131
|
items: [
|
132
|
new MenuItem("","Zenodo Communities","","/participate/share-zenodo",false,[],["/participate/share-zenodo"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
133
|
new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
134
|
new MenuItem("","Research Data","","/participate/deposit-datasets",false,["dataset"],["/participate/deposit-datasets"],this.properties.environment!="development"?{}:{communityId:community.communityId})]
|
135
|
},
|
136
|
{
|
137
|
rootItem: new MenuItem("link","Link","","/participate/claim",false,[],["/participate/claim"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
138
|
items: []
|
139
|
}
|
140
|
];
|
141
|
|
142
|
}
|
143
|
|
144
|
}
|
145
|
if(community == null){
|
146
|
this.menuItems= [];
|
147
|
var myCommunities = [];
|
148
|
if(this.managerOfCommunities.length > 0){
|
149
|
myCommunities.push( new MenuItem("","Managing communities","","/search/find/communities",false,[],[],{role:"%22manager%22"}))
|
150
|
}
|
151
|
if(this.subscriberOfCommunities.length > 0){
|
152
|
myCommunities.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
|
153
|
}
|
154
|
|
155
|
this.menuItems.push({rootItem: new MenuItem("communities","Communities","","/search/find/communities",false,[],null,{}), items: []});
|
156
|
if(this.managerOfCommunities.length > 0 || this.subscriberOfCommunities.length > 0){
|
157
|
this.menuItems.push({rootItem: new MenuItem("myCommunities","My Communities","","",false,[],[],{}), items: myCommunities});
|
158
|
}
|
159
|
this.menuItems.push({rootItem: new MenuItem("howto","Create Community","","/how-to-create-community",false,[],null,{}), items: []});
|
160
|
|
161
|
|
162
|
|
163
|
this.bottomMenuItems =[
|
164
|
new MenuItem("","About","https://beta.openaire.eu/project-factsheets","",false,[],[],{}),
|
165
|
new MenuItem("","News - Events","https://beta.openaire.eu/news-events","",false,[],[],{}),
|
166
|
new MenuItem("","Blog","https://blogs.openaire.eu/","",false,[],[],{}),
|
167
|
new MenuItem("","Contact us","https://beta.openaire.eu/contact-us","",false,[],[],{})
|
168
|
];
|
169
|
// if(this.properties.showContent){
|
170
|
// this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
|
171
|
// }
|
172
|
this.userMenuItems =[
|
173
|
// new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],(data['communityId'] && typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:data['communityId']}),
|
174
|
];
|
175
|
|
176
|
}else{
|
177
|
this.bottomMenuItems = [
|
178
|
new MenuItem("","About","","/about",false,[],["/about"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
179
|
new MenuItem("","Organizations","","/organizations",false,[],["/organizations"],this.properties.environment!="development"?{}:{communityId:community.communityId})
|
180
|
];
|
181
|
if(this.properties.showContent){
|
182
|
this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
|
183
|
}
|
184
|
this.userMenuItems =[ new MenuItem("","My profile","","",false,[],[],{}),
|
185
|
new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
186
|
new MenuItem("","Invite users","","/invite",false,[],[],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
187
|
];
|
188
|
}
|
189
|
this.showMenu = true;
|
190
|
});
|
191
|
|
192
|
|
193
|
});
|
194
|
if (typeof document !== 'undefined') {
|
195
|
try{
|
196
|
this.isClient = true;
|
197
|
}catch (e) {
|
198
|
}
|
199
|
}
|
200
|
}, error => {
|
201
|
console.log("App couldn't fetch properties");
|
202
|
console.log(error);
|
203
|
|
204
|
});
|
205
|
}
|
206
|
}
|