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