1
|
import {Component} from '@angular/core';
|
2
|
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
3
|
|
4
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
5
|
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
6
|
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
7
|
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
|
8
|
import {Session} from './openaireLibrary/login/utils/helper.class';
|
9
|
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
|
10
|
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
|
11
|
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
12
|
|
13
|
@Component({
|
14
|
//changeDetection: ChangeDetectionStrategy.Default,
|
15
|
//encapsulation: ViewEncapsulation.Emulated,
|
16
|
selector: 'app-root',
|
17
|
styles: [`
|
18
|
`],
|
19
|
template: `
|
20
|
<div [class]="(community)?(community.id +'App'):'connectApp'">
|
21
|
<navbar *ngIf="properties && showMenu && !community" portal="connect" [onlyTop]=false
|
22
|
[userMenuItems]=userMenuItems [menuItems]=menuItems
|
23
|
[showMenu]=showMenu [properties]="properties" [showHomeMenuItem]="true"></navbar>
|
24
|
<navbar *ngIf="properties && showMenu && community" portal="connect" [onlyTop]=false [communityId]="community.id"
|
25
|
[userMenuItems]=userMenuItems [menuItems]=menuItems
|
26
|
[community]=community [showMenu]=showMenu [properties]="properties" [enableSearch]="true"
|
27
|
[showHomeMenuItem]="true"></navbar>
|
28
|
<customization *ngIf="properties && community"></customization>
|
29
|
<div class="custom-main-content">
|
30
|
<main>
|
31
|
<router-outlet></router-outlet>
|
32
|
</main>
|
33
|
</div>
|
34
|
<!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
|
35
|
<cookie-law *ngIf="isClient" position="bottom">
|
36
|
OpenAIRE uses cookies in order to function properly.<br>
|
37
|
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
|
38
|
experience possible.
|
39
|
By using the OpenAIRE portal you accept our use of cookies. <a
|
40
|
href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
|
41
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
|
42
|
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03"
|
43
|
points="7 4 13 10 7 16"></polyline></svg>
|
44
|
</span></a>
|
45
|
</cookie-law>
|
46
|
<bottom *ngIf="properties && isClient && showMenu && !community" [grantAdvance]="false"
|
47
|
[properties]="properties"></bottom>
|
48
|
<bottom *ngIf="properties && isClient && showMenu && community" class="communityPanelBackground"
|
49
|
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
|
50
|
[communityId]="community.id" [menuItems]=bottomMenuItems [properties]="properties"></bottom>
|
51
|
</div>
|
52
|
`
|
53
|
|
54
|
})
|
55
|
export class AppComponent {
|
56
|
isClient: boolean = false;
|
57
|
|
58
|
userMenuItems: MenuItem[] = [];
|
59
|
|
60
|
|
61
|
menuItems: RootMenuItem [] = [];
|
62
|
bottomMenuItems: MenuItem[] = [];
|
63
|
public community = null;
|
64
|
properties: EnvProperties;
|
65
|
showMenu: boolean = false;
|
66
|
communities = null;
|
67
|
subscriberOfCommunities = false;
|
68
|
managerOfCommunities = false;
|
69
|
|
70
|
// community: {id:string, name:string, logoUrl:string};
|
71
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
72
|
private _communitiesService: CommunitiesService, private _subscribeService: SubscribeService,
|
73
|
private router: Router) {
|
74
|
router.events.forEach((event) => {
|
75
|
if (event instanceof NavigationStart) {
|
76
|
HelperFunctions.scroll();
|
77
|
}
|
78
|
});
|
79
|
}
|
80
|
|
81
|
ngOnInit() {
|
82
|
this.propertiesService.loadEnvironment()
|
83
|
.then(es => {
|
84
|
this.properties = this.propertiesService.envSpecific;
|
85
|
var communityId: string = "";
|
86
|
this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
|
87
|
if (this.properties.environment == "development") {
|
88
|
this.showMenu = false;
|
89
|
this.route.queryParams.subscribe(params => {
|
90
|
communityId = (params['communityId']) ? params['communityId'] : '';
|
91
|
this.buildMenu(communityId);
|
92
|
})
|
93
|
} else {
|
94
|
this.showMenu = false;
|
95
|
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
96
|
this.buildMenu(communityId);
|
97
|
}
|
98
|
if (typeof document !== 'undefined') {
|
99
|
try {
|
100
|
this.isClient = true;
|
101
|
} catch (e) {
|
102
|
}
|
103
|
}
|
104
|
}, error => {
|
105
|
console.log("App couldn't fetch properties");
|
106
|
console.log(error);
|
107
|
|
108
|
});
|
109
|
}
|
110
|
|
111
|
public buildMenu(communityId: string) {
|
112
|
let community = null;
|
113
|
this.community = null;
|
114
|
this._communitiesService.getCommunitiesState().subscribe(
|
115
|
communities => {
|
116
|
if (!communities || communities.length == 0 && communityId !== null && communityId !== '') {
|
117
|
return;
|
118
|
}
|
119
|
for (var com of communities) {
|
120
|
if ((communityId && communityId != "" && com.communityId == communityId
|
121
|
&& community != null) ||
|
122
|
(
|
123
|
!(communityId && communityId != "" && com.communityId == communityId)
|
124
|
&&
|
125
|
this.managerOfCommunities && this.subscriberOfCommunities)) {
|
126
|
break;
|
127
|
}
|
128
|
if (Session.isLoggedIn() && com['status'] != "hidden") {
|
129
|
if (Session.isCommunityCurator() || Session.isPortalAdministrator()) {
|
130
|
this.managerOfCommunities = true;
|
131
|
} else if (com.managers.indexOf(Session.getUserEmail()) != -1) {
|
132
|
this.managerOfCommunities = true;
|
133
|
}
|
134
|
}
|
135
|
|
136
|
|
137
|
if (communityId && communityId != "" && com.communityId == communityId) {
|
138
|
community = com;
|
139
|
let isCommunityManager: boolean = false;
|
140
|
if (Session.isCommunityCurator() || Session.isPortalAdministrator()) {
|
141
|
isCommunityManager = true;
|
142
|
} else if (com.managers.indexOf(Session.getUserEmail()) != -1) {
|
143
|
isCommunityManager = true;
|
144
|
}
|
145
|
this.community = {
|
146
|
id: community.communityId,
|
147
|
name: (community.shortTitle) ? community.shortTitle : community.title,
|
148
|
logoUrl: community.logoUrl
|
149
|
};
|
150
|
this.menuItems = [];
|
151
|
|
152
|
this.menuItems.push(
|
153
|
{
|
154
|
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}),
|
155
|
items: [new MenuItem("", "Publications", "", "/search/find/publications", false, ["publication"], ["/search/find/publications"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
156
|
new MenuItem("", "Research Data", "", "/search/find/datasets", false, ["dataset"], ["/search/find/datasets"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
157
|
new MenuItem("", "Software", "", "/search/find/software", false, ["software"], ["/search/find/software"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
158
|
new MenuItem("", "Other Research Products", "", "/search/find/other", false, ["orp"], ["/search/find/other"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
159
|
new MenuItem("", "Projects", "", "/search/find/projects/", false, ["project"], ["/search/find/projects"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
160
|
new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
161
|
]
|
162
|
});
|
163
|
|
164
|
this.menuItems.push({
|
165
|
rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
166
|
items: [
|
167
|
/*
|
168
|
new MenuItem("","Zenodo Communities","","/participate/share-zenodo",false,[],["/participate/share-zenodo"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
169
|
new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
170
|
new MenuItem("","Research Data","","/participate/deposit-datasets",false,["dataset"],["/participate/deposit-datasets"],this.properties.environment!="development"?{}:{communityId:community.communityId})
|
171
|
*/
|
172
|
]
|
173
|
});
|
174
|
this.menuItems.push(
|
175
|
{
|
176
|
rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
177
|
items: [
|
178
|
new MenuItem("", "Start linking", "", "/participate/claim", false, [], ["/participate/claim"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
179
|
new MenuItem("", "Learn more", this.properties.claimsInformationLink, "", false, [], [], {})
|
180
|
]
|
181
|
});
|
182
|
if (isCommunityManager) {
|
183
|
this.menuItems.push(
|
184
|
{
|
185
|
rootItem: new MenuItem("manage", "Manage", 'https://beta.admin.connect.openaire.eu/dashboard?communityId=' + community.communityId, "", false, [], [], {}),
|
186
|
items: []
|
187
|
});
|
188
|
}
|
189
|
|
190
|
}
|
191
|
|
192
|
}
|
193
|
if (community == null) {
|
194
|
this.menuItems = [];
|
195
|
this.menuItems.push({
|
196
|
rootItem: new MenuItem("about", "About", "", "/about/learn-how", false, [], null, {}),
|
197
|
items: []
|
198
|
});
|
199
|
var myCommunities = [];
|
200
|
/*if(this.managerOfCommunities){
|
201
|
myCommunities.push( new MenuItem("","Managing communities","","/search/find/communities",false,[],[],{role:"%22manager%22"}))
|
202
|
}
|
203
|
if(Session.isLoggedIn()){
|
204
|
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe (
|
205
|
pids => {
|
206
|
if(pids.length > 0 ) {
|
207
|
myCommunities.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
|
208
|
}
|
209
|
},
|
210
|
error => {
|
211
|
console.error("Error fetching your subscribed communities")
|
212
|
});
|
213
|
}*/
|
214
|
this.menuItems.push({
|
215
|
rootItem: new MenuItem("communities", "Communities", "", "/search/find/communities", false, [], null, {}),
|
216
|
items: []
|
217
|
});
|
218
|
this.menuItems.push({
|
219
|
rootItem: new MenuItem("join", "Join", "", "/contact-us", false, [], null, {}),
|
220
|
items: []
|
221
|
});
|
222
|
/*if(this.managerOfCommunities || this.subscriberOfCommunities){
|
223
|
let myCommunitiesMenu = new MenuItem("myCommunities","My Communities","","",false,[],[],{});
|
224
|
myCommunitiesMenu.setMarkAsActive(false);
|
225
|
this.menuItems.push({rootItem: myCommunitiesMenu, items: myCommunities});
|
226
|
}*/
|
227
|
|
228
|
|
229
|
this.bottomMenuItems = [
|
230
|
new MenuItem("", "About", "https://beta.openaire.eu/project-factsheets", "", false, [], [], {}),
|
231
|
new MenuItem("", "News - Events", "https://beta.openaire.eu/news-events", "", false, [], [], {}),
|
232
|
new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}),
|
233
|
new MenuItem("", "Contact us", "https://beta.openaire.eu/contact-us", "", false, [], [], {})
|
234
|
];
|
235
|
// if(this.properties.showContent){
|
236
|
// this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
|
237
|
// }
|
238
|
this.userMenuItems = [
|
239
|
// new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],(data['communityId'] && typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:data['communityId']}),
|
240
|
];
|
241
|
if (Session.isPortalAdministrator()) {
|
242
|
//((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire"
|
243
|
this.userMenuItems.push(new MenuItem("", "Manage Helptexts",
|
244
|
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
|
245
|
"", false, [], [], {}))
|
246
|
}
|
247
|
/*if(this.managerOfCommunities){
|
248
|
this.userMenuItems.push( new MenuItem("","Managing communities","","/search/find/communities",false,[],[],{role:"%22manager%22"}))
|
249
|
}
|
250
|
if(Session.isLoggedIn()){
|
251
|
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe (
|
252
|
pids => {
|
253
|
if(pids.length > 0 ) {
|
254
|
this.userMenuItems.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
|
255
|
}
|
256
|
},
|
257
|
error => {
|
258
|
console.error("Error fetching your subscribed communities")
|
259
|
});
|
260
|
}*/
|
261
|
if (Session.isLoggedIn()) {
|
262
|
this.userMenuItems.push(new MenuItem("my-communities", "My Communities", "",
|
263
|
"/myCommunities", false, [], [], {}));
|
264
|
}
|
265
|
} else {
|
266
|
this.bottomMenuItems = [
|
267
|
// new MenuItem("","About","","/about",false,[],["/about"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
268
|
new MenuItem("", "Organizations", "", "/organizations", false, [], ["/organizations"], this.properties.environment != "development" ? {} : {communityId: community.communityId})
|
269
|
];
|
270
|
if (this.properties.showContent) {
|
271
|
this.bottomMenuItems.push(new MenuItem("", "Content Policy", "", "/content", false, [], [], {}));
|
272
|
}
|
273
|
this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/
|
274
|
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
275
|
new MenuItem("", "Invite users", "", "/invite", false, [], [], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
276
|
];
|
277
|
if (this.managerOfCommunities) {
|
278
|
this.userMenuItems.push(new MenuItem("", "Support", "https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611", "", false, [], [], {}))
|
279
|
}
|
280
|
}
|
281
|
this.showMenu = true;
|
282
|
});
|
283
|
}
|
284
|
}
|