1
|
import {Component} from '@angular/core';
|
2
|
import {ActivatedRoute, 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, User} from './openaireLibrary/login/utils/helper.class';
|
9
|
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
|
10
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
11
|
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
12
|
import {properties} from '../environments/environment';
|
13
|
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
|
14
|
import {Subscriber} from "rxjs";
|
15
|
import {CommunityService} from "./openaireLibrary/connect/community/community.service";
|
16
|
import {StringUtils} from "./openaireLibrary/utils/string-utils.class";
|
17
|
import {LoginErrorCodes} from "./openaireLibrary/login/utils/guardHelper.class";
|
18
|
import {CustomizationOptions} from "./openaireLibrary/connect/community/CustomizationOptions";
|
19
|
import {LayoutService} from "./openaireLibrary/services/layout.service";
|
20
|
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
|
21
|
import {Meta} from "@angular/platform-browser";
|
22
|
import {CommunityInfo} from "./openaireLibrary/connect/community/communityInfo";
|
23
|
import {SEOService} from "./openaireLibrary/sharedComponents/SEO/SEO.service";
|
24
|
|
25
|
@Component({
|
26
|
selector: 'app-root',
|
27
|
styles: [`
|
28
|
`],
|
29
|
template: `
|
30
|
<div [class]="(community)?(community.communityId +'App communityApp'):'connectApp'">
|
31
|
<navbar *ngIf="properties && showMenu && !community && header" [portal]="properties.dashboard" [onlyTop]=false
|
32
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user" [header]="header"
|
33
|
[showMenu]=showMenu [properties]="properties" [showHomeMenuItem]="false" communityId="connect"></navbar>
|
34
|
<navbar *ngIf="properties && showMenu && community && header" [portal]="community.communityId" [onlyTop]=false
|
35
|
[communityId]="community.communityId" [header]="header"
|
36
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
37
|
[showMenu]=showMenu [properties]="properties" [enableSearch]="false"
|
38
|
searchRoute="/search/find/research-outcomes"
|
39
|
[showHomeMenuItem]="false"></navbar>
|
40
|
<customization *ngIf="properties && showMenu && communityId && communityId.length > 0 && layout" [properties]="properties"
|
41
|
[communityId]="communityId" [layout]="layout" ></customization>
|
42
|
<schema2jsonld *ngIf="properties && showMenu && !community" [URL]="properties.domain + properties.baseLink"
|
43
|
[logoURL]="properties.domain + properties.baseLink+'/assets/common-assets/logo-small-connect.png'"
|
44
|
type="home"
|
45
|
[searchActionRoute]="properties.searchLinkToCommunities" [searchAction]="true"
|
46
|
name="OpenAIRE Connect"
|
47
|
description="Build a Gateway for your Community: Turn Open Science into Practice. It takes your open and linked research outcomes.">
|
48
|
</schema2jsonld>
|
49
|
<schema2jsonld *ngIf="properties && showMenu && communityId && communityId.length > 0 && community"
|
50
|
[URL]="properties.domain + properties.baseLink"
|
51
|
[logoURL]="community.logoUrl" type="home" [searchActionRoute]="properties.searchLinkToResults"
|
52
|
[name]="(community.shortTitle) ? community.shortTitle : community.title" [description]="community.description">
|
53
|
</schema2jsonld>
|
54
|
<div class="custom-main-content">
|
55
|
<main>
|
56
|
<router-outlet></router-outlet>
|
57
|
</main>
|
58
|
</div>
|
59
|
<div id="subscribeAndInviteBtn" *ngIf="isClient && communityId && community">
|
60
|
<subscribe [communityId]="community.communityId"></subscribe>
|
61
|
<invite *ngIf="isManager" [longView]="false"></invite>
|
62
|
</div>
|
63
|
<!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
|
64
|
<cookie-law *ngIf="isClient" position="bottom">
|
65
|
OpenAIRE uses cookies in order to function properly.<br>
|
66
|
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
|
67
|
experience possible.
|
68
|
By using the OpenAIRE portal you accept our use of cookies. <a
|
69
|
href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
|
70
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
|
71
|
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03"
|
72
|
points="7 4 13 10 7 16"></polyline></svg>
|
73
|
</span></a>
|
74
|
</cookie-law>
|
75
|
<bottom *ngIf="properties && isClient && showMenu && !community" [grantAdvance]="false"
|
76
|
[properties]="properties"></bottom>
|
77
|
<bottom *ngIf="properties && isClient && showMenu && community" class=" communityPanelBackground "
|
78
|
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
|
79
|
[communityId]="community.communityId" [menuItems]=bottomMenuItems [properties]="properties"
|
80
|
[darkBackground]="true" [centered]="true"></bottom>
|
81
|
<role-verification *ngIf="community" service="connect"
|
82
|
[id]="community.communityId" [name]="community.title" [type]="'community'"></role-verification>
|
83
|
</div>
|
84
|
`
|
85
|
|
86
|
})
|
87
|
export class AppComponent {
|
88
|
isClient: boolean = false;
|
89
|
userMenuItems: MenuItem[] = [];
|
90
|
menuItems: RootMenuItem [] = [];
|
91
|
bottomMenuItems: MenuItem[] = [];
|
92
|
public community:CommunityInfo = null;
|
93
|
properties: EnvProperties = properties;
|
94
|
showMenu: boolean = false;
|
95
|
communities = null;
|
96
|
user: User;
|
97
|
communityId: string = "";
|
98
|
header: Header;
|
99
|
logoPath: string = 'assets/common-assets/';
|
100
|
subscriptions = [];
|
101
|
layout: CustomizationOptions = null;
|
102
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
103
|
private _communitiesService: CommunitiesService, private smoothScroll: SmoothScroll,
|
104
|
private router: Router, private userManagementService: UserManagementService,
|
105
|
private configurationService: ConfigurationService, private _communityService: CommunityService, private _layoutService: LayoutService, private _meta: Meta, private seoService: SEOService) {
|
106
|
}
|
107
|
|
108
|
ngOnDestroy() {
|
109
|
this.subscriptions.forEach(subscription => {
|
110
|
if (subscription instanceof Subscriber) {
|
111
|
subscription.unsubscribe();
|
112
|
}
|
113
|
});
|
114
|
this._communitiesService.clearSubscriptions();
|
115
|
this.userManagementService.clearSubscriptions();
|
116
|
this.configurationService.clearSubscriptions();
|
117
|
this._communityService.clearSubscriptions();
|
118
|
this.smoothScroll.clearSubscriptions();
|
119
|
}
|
120
|
|
121
|
ngOnInit() {
|
122
|
if (this.properties.environment == "production" || this.properties.environment == "development") {
|
123
|
this.subscriptions.push(this.route.queryParams.subscribe(data => {
|
124
|
this._meta.updateTag({content: 'all', name: 'robots'});
|
125
|
this.seoService.removeLinkForPrevURL();
|
126
|
this.seoService.removeLinkForNextURL();
|
127
|
}));
|
128
|
}
|
129
|
this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
|
130
|
if (typeof document !== 'undefined') {
|
131
|
try {
|
132
|
this.isClient = true;
|
133
|
} catch (e) {
|
134
|
}
|
135
|
}
|
136
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
137
|
this.user = user;
|
138
|
this.init();
|
139
|
}, error => {
|
140
|
this.init()}));
|
141
|
}
|
142
|
|
143
|
get isManager() {
|
144
|
return Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || (this.communityId && Session.isManager('community', this.communityId, this.user))
|
145
|
}
|
146
|
|
147
|
get isPrivate() {
|
148
|
return this.community && !ConnectHelper.isPrivate(this.community, this.user)
|
149
|
}
|
150
|
|
151
|
private init() {
|
152
|
let communityId: string = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
153
|
this.showMenu = false;
|
154
|
this.initAdminToolCommunity(communityId);
|
155
|
this.buildMenu(communityId);
|
156
|
// this.communityId = communityId;
|
157
|
if (this.communityId === null) {
|
158
|
this.userManagementService.fixRedirectURL = properties.afterLoginRedirectLink;
|
159
|
} else {
|
160
|
this.userManagementService.fixRedirectURL = null;
|
161
|
}
|
162
|
}
|
163
|
|
164
|
initAdminToolCommunity(communityId) {
|
165
|
if (communityId) {
|
166
|
this.properties.adminToolsPortalType = "community";
|
167
|
this.initLayout(communityId);
|
168
|
}
|
169
|
this.configurationService.initCommunityInformation(this.properties, (communityId) ? communityId : this.properties.adminToolsPortalType);
|
170
|
}
|
171
|
initLayout(communityId){
|
172
|
if(!this.layout) {
|
173
|
this._layoutService.getLayout(this.properties, communityId).subscribe(
|
174
|
layout => {
|
175
|
if (layout) {
|
176
|
this.layout = CustomizationOptions.checkForObsoleteVersion(layout.layoutOptions,this.communityId);
|
177
|
} else {
|
178
|
this.layout = new CustomizationOptions(CustomizationOptions.getIdentity(communityId).mainColor, CustomizationOptions.getIdentity(communityId).secondaryColor);
|
179
|
}
|
180
|
|
181
|
},
|
182
|
error => {
|
183
|
this.layout = new CustomizationOptions(CustomizationOptions.getIdentity(communityId).mainColor, CustomizationOptions.getIdentity(communityId).secondaryColor);
|
184
|
}
|
185
|
);
|
186
|
}else{
|
187
|
this.layout = new CustomizationOptions(CustomizationOptions.getIdentity(communityId).mainColor, CustomizationOptions.getIdentity(communityId).secondaryColor);
|
188
|
}
|
189
|
}
|
190
|
public buildMenu(communityId: string) {
|
191
|
if (communityId) {
|
192
|
if (!this.community || this.communityId !== communityId) {
|
193
|
this.subscriptions.push(this._communityService.getCommunity(communityId).subscribe(community => {
|
194
|
if (community) {
|
195
|
this.community = community;
|
196
|
}else{
|
197
|
this.community = null;
|
198
|
this.communityId = null;
|
199
|
}
|
200
|
this.buildCommunityMenu();
|
201
|
}));
|
202
|
} else {
|
203
|
this.buildCommunityMenu();
|
204
|
}
|
205
|
} else {
|
206
|
this.buildConnectMenu();
|
207
|
}
|
208
|
}
|
209
|
|
210
|
buildCommunityMenu(){
|
211
|
if (this.community && !ConnectHelper.isPrivate(this.community, this.user)) {
|
212
|
this.communityId = this.community.communityId;
|
213
|
this.header = {
|
214
|
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
|
215
|
route: "/",
|
216
|
title: (this.community.shortTitle) ? this.community.shortTitle : this.community.title,
|
217
|
logoUrl: (this.community.isUpload) ? (properties.utilsService + '/download/' + this.community.logoUrl) : (StringUtils.urlPrefix(this.community.logoUrl) + this.community.logoUrl),
|
218
|
logoSmallUrl: (this.community.isUpload) ? (properties.utilsService + '/download/' + this.community.logoUrl) : (StringUtils.urlPrefix(this.community.logoUrl) + this.community.logoUrl),
|
219
|
position: 'left',
|
220
|
badge: true
|
221
|
};
|
222
|
this.menuItems = [];
|
223
|
this.menuItems.push({
|
224
|
rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], {}),
|
225
|
items: []
|
226
|
});
|
227
|
this.menuItems.push(
|
228
|
{
|
229
|
rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], {}),
|
230
|
items: [
|
231
|
new MenuItem("", "Start linking", "", "/participate/claim", false, [], ["/participate/claim"], {}),
|
232
|
new MenuItem("", "Learn more", this.properties.claimsInformationLink, "", false, [], [], {})
|
233
|
]
|
234
|
});
|
235
|
this.menuItems.push(
|
236
|
{
|
237
|
rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find"], {}),
|
238
|
items: [
|
239
|
new MenuItem("", "Research outcomes", "", "/search/find/research-outcomes", false, [], ["/search/find/research-outcomes"], {resultbestaccessright: '"' + encodeURIComponent("Open Access") + '"'}),
|
240
|
new MenuItem("", "Projects", "", "/search/find/projects/", false, ["project"], ["/search/find/projects"], {}),
|
241
|
new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {}),
|
242
|
]
|
243
|
});
|
244
|
this.menuItems.push(
|
245
|
{
|
246
|
rootItem: new MenuItem("about", "About", "", "", false, [], [], {}),
|
247
|
items: [
|
248
|
new MenuItem("", "Supporting organizations", "", "/organizations", false, [], ["/organizations"], {}),
|
249
|
new MenuItem("", "Curators", "", "/curators", false, [], ["/curators"], {}),
|
250
|
new MenuItem("", "Sources and methodology", "", "/content", false, [], ["/content"], {}),
|
251
|
new MenuItem("", "National Bulletins", "", "/national-bulletins", false, [], ["/national-bulletins"], {}),
|
252
|
new MenuItem("", "Subjects", "", "/subjects", false, [], ["/subjects"], {}),
|
253
|
new MenuItem("", "Projects and funding Opportunities", "", "/projects", false, [], ["/projects"], {}),
|
254
|
]
|
255
|
});
|
256
|
if (this.isManager) {
|
257
|
this.menuItems.push(
|
258
|
{
|
259
|
rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL + '/' + this.community.communityId, "", false, [], [], {}),
|
260
|
items: []
|
261
|
});
|
262
|
}
|
263
|
this.bottomMenuItems = [
|
264
|
new MenuItem("", "Supporting organizations", "", "/organizations", false, [], ["/organizations"], {})
|
265
|
];
|
266
|
if (this.properties.showContent) {
|
267
|
this.bottomMenuItems.push(new MenuItem("", "Sources and methodology", "", "/content", false, [], [], {}));
|
268
|
}
|
269
|
if (this.user) {
|
270
|
this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/
|
271
|
new MenuItem("", "My ORCID links", "", "/my-orcid-links", false, [], [], {}),
|
272
|
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {}),
|
273
|
new MenuItem("", "Invite users", "", "/invite", false, [], [], {}),
|
274
|
];
|
275
|
if (this.isManager) {
|
276
|
this.userMenuItems.push(new MenuItem("", "Support", "https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611", "", false, [], [], {}))
|
277
|
}
|
278
|
}
|
279
|
this.showMenu = true;
|
280
|
} else {
|
281
|
this.communityId = null;
|
282
|
this.properties.adminToolsPortalType = "connect";
|
283
|
this.configurationService.initCommunityInformation(this.properties, "connect");
|
284
|
this.initAdminToolCommunity(null);
|
285
|
this.buildConnectMenu(true);
|
286
|
if (this.community && this.community.status == "manager") {
|
287
|
if (!this.user ) {
|
288
|
if(typeof location !== 'undefined' && location.pathname.indexOf("user-info") == -1) {
|
289
|
this.router.navigate(['/user-info'], {
|
290
|
queryParams: {
|
291
|
"errorCode": LoginErrorCodes.NOT_LOGIN,
|
292
|
"redirectUrl": location.pathname + location.search + location.hash
|
293
|
}
|
294
|
});
|
295
|
}
|
296
|
} else {
|
297
|
if(typeof location !== 'undefined' && location.pathname.indexOf("user-info") == -1) {
|
298
|
this.router.navigate(['/'], {queryParamsHandling: "merge"});
|
299
|
}
|
300
|
}
|
301
|
}else if (this.community && this.community.status == "hidden") {
|
302
|
this.router.navigate(['/error']);
|
303
|
}else{
|
304
|
this.router.navigate(['/'], this.community && this.community.status ? { queryParamsHandling: "merge" } : {});
|
305
|
}
|
306
|
}
|
307
|
}
|
308
|
buildConnectMenu(restrictedData: boolean = false) {
|
309
|
let url = "https://" + (properties.environment != "production" ? "beta." : "") + "connect.openaire.eu";
|
310
|
this.header = {
|
311
|
route: restrictedData ? "" : "/",
|
312
|
url: restrictedData ? url : "",
|
313
|
title: 'connect',
|
314
|
logoUrl: this.logoPath + 'logo-large-connect.png',
|
315
|
logoSmallUrl: this.logoPath + 'logo-small-connect.png',
|
316
|
position: 'left',
|
317
|
badge: true
|
318
|
};
|
319
|
this.menuItems = [];
|
320
|
this.menuItems.push({
|
321
|
rootItem: new MenuItem("about", "About", restrictedData ? url + "/about/learn-how" : "", restrictedData ? "" : "/about/learn-how", false, [], ["/about/learn-how"], {}),
|
322
|
items: [
|
323
|
new MenuItem("", "Learn the process", restrictedData ? url + "/about/learn-how" : "", restrictedData ? "" : "/about/learn-how", false, [], ["/about/learn-in-depth"], {}),
|
324
|
new MenuItem("", "Publications", restrictedData ? url + "/publications" : "", restrictedData ? "" : "/publications", false, [], ["/publications"], {}),
|
325
|
new MenuItem("", "Roadmap", "https://trello.com/b/yfzUz0kp/openaire-connect-dashboard", "", false, [], [], {}),
|
326
|
new MenuItem("", "FAQs", restrictedData ? url + "/about/faq" : "", restrictedData ? "" : "/about/faq", false, [], ["/about/faq"], {})
|
327
|
]
|
328
|
|
329
|
});
|
330
|
this.menuItems.push({
|
331
|
rootItem: new MenuItem("communities", "Communities", restrictedData ? url + "/search/find/communities" : "", restrictedData ? "" : "/search/find/communities", false, [], ['/search/find/communities'], {}),
|
332
|
items: []
|
333
|
});
|
334
|
this.menuItems.push({
|
335
|
rootItem: new MenuItem("contact-us", "Contact us", restrictedData ? url + "/contact-us" : "", restrictedData ? "" : "/contact-us", false, [], ['/contact-us'], {}),
|
336
|
items: []
|
337
|
});
|
338
|
this.bottomMenuItems = [
|
339
|
new MenuItem("", "About", "https://openaire.eu/project-factsheets", "", false, [], [], {}),
|
340
|
new MenuItem("", "News - Events", "https://openaire.eu/news-events", "", false, [], [], {}),
|
341
|
new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}),
|
342
|
new MenuItem("", "Contact us", restrictedData ? url + "/contact-us" : "", restrictedData ? "" : "/contact-us", false, [], [], {})
|
343
|
];
|
344
|
this.userMenuItems = [];
|
345
|
if (Session.isPortalAdministrator(this.user)) {
|
346
|
this.userMenuItems.push(new MenuItem("", "Manage Helptexts",
|
347
|
properties.adminPortalURL + "/connect/admin-tools/pages", "", false, [], [], {}))
|
348
|
}
|
349
|
if (this.user) {
|
350
|
this.userMenuItems.push(new MenuItem("my-communities", "My Communities", restrictedData ? url + "/myCommunities" : "",
|
351
|
restrictedData ? "" : "/myCommunities", false, [], [], {}));
|
352
|
}
|
353
|
this.showMenu = true;
|
354
|
}
|
355
|
}
|