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