2019-09-30 14:48:48 +02:00
|
|
|
import {Component} from '@angular/core';
|
|
|
|
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
2019-01-09 12:05:23 +01:00
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
|
|
|
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
|
|
|
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
|
|
|
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
|
|
|
|
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
|
|
|
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
|
|
|
|
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
|
|
|
|
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
|
|
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
2019-01-09 12:05:23 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
template: `
|
2020-06-03 23:55:32 +02:00
|
|
|
<div class="monitorApp">
|
2019-12-23 17:01:48 +01:00
|
|
|
<navbar *ngIf="properties && showMenu && !community" portal="monitor" [onlyTop]=false
|
2019-09-30 14:48:48 +02:00
|
|
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
2020-06-03 23:55:32 +02:00
|
|
|
[showMenu]=showMenu [properties]="properties"></navbar>
|
2019-12-23 17:01:48 +01:00
|
|
|
<navbar *ngIf="properties && showMenu && community" portal="monitor" [onlyTop]=false [communityId]="community.id"
|
2019-09-30 14:48:48 +02:00
|
|
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
2020-06-03 23:55:32 +02:00
|
|
|
[community]=community [showMenu]=showMenu [properties]="properties" [enableSearch]="true"></navbar>
|
2019-09-30 14:48:48 +02:00
|
|
|
<div class="custom-main-content">
|
|
|
|
<main>
|
|
|
|
<router-outlet></router-outlet>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
<!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
|
|
|
|
<cookie-law *ngIf="isClient" position="bottom">
|
|
|
|
OpenAIRE uses cookies in order to function properly.<br>
|
|
|
|
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
|
|
|
|
experience possible.
|
|
|
|
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">
|
|
|
|
<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>
|
|
|
|
</span></a>
|
|
|
|
</cookie-law>
|
|
|
|
<bottom *ngIf="properties && isClient && showMenu && !community" [grantAdvance]="false"
|
|
|
|
[properties]="properties"></bottom>
|
|
|
|
<bottom *ngIf="properties && isClient && showMenu && community" class="communityPanelBackground"
|
|
|
|
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
|
|
|
|
[communityId]="community.id" [menuItems]=bottomMenuItems [properties]="properties"></bottom>
|
|
|
|
</div>
|
|
|
|
`
|
2019-01-09 12:05:23 +01:00
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
})
|
|
|
|
export class AppComponent {
|
|
|
|
isClient: boolean = false;
|
2019-01-09 12:05:23 +01:00
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
userMenuItems: MenuItem[] = [];
|
2019-01-09 12:05:23 +01:00
|
|
|
|
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
menuItems: RootMenuItem [] = [];
|
|
|
|
bottomMenuItems: MenuItem[] = [];
|
|
|
|
public community = null;
|
|
|
|
properties: EnvProperties;
|
|
|
|
showMenu: boolean = false;
|
|
|
|
communities = null;
|
|
|
|
subscriberOfCommunities = false;
|
|
|
|
managerOfCommunities = false;
|
|
|
|
user: User;
|
2019-01-09 12:05:23 +01:00
|
|
|
|
2019-09-30 14:48:48 +02:00
|
|
|
// community: {id:string, name:string, logoUrl:string};
|
|
|
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
|
|
|
private _communitiesService: CommunitiesService, private _subscribeService: SubscribeService,
|
|
|
|
private router: Router, private userManagementService: UserManagementService) {
|
|
|
|
router.events.forEach((event) => {
|
|
|
|
if (event instanceof NavigationStart) {
|
|
|
|
HelperFunctions.scroll();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.propertiesService.loadEnvironment()
|
|
|
|
.then(es => {
|
|
|
|
this.properties = this.propertiesService.envSpecific;
|
|
|
|
var communityId: string = "";
|
|
|
|
this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
|
2019-12-23 17:01:48 +01:00
|
|
|
this.userManagementService.getUserInfo().subscribe( user => {
|
2019-09-30 14:48:48 +02:00
|
|
|
this.user = user;
|
|
|
|
if (this.properties.environment == "development") {
|
|
|
|
this.showMenu = false;
|
|
|
|
this.route.queryParams.subscribe(params => {
|
|
|
|
communityId = (params['communityId']) ? params['communityId'] : '';
|
|
|
|
this.buildMenu(communityId);
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.showMenu = false;
|
|
|
|
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
|
|
|
this.buildMenu(communityId);
|
|
|
|
}
|
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
try {
|
|
|
|
this.isClient = true;
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, error => {
|
|
|
|
console.log("App couldn't fetch properties");
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public buildMenu(communityId: string) {
|
|
|
|
let community = null;
|
|
|
|
this.community = null;
|
|
|
|
this._communitiesService.getCommunitiesState().subscribe(
|
|
|
|
communities => {
|
|
|
|
if (!communities || communities.length == 0 && communityId !== null && communityId !== '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (var com of communities) {
|
|
|
|
if ((communityId && communityId != "" && com.communityId == communityId
|
|
|
|
&& community != null) ||
|
|
|
|
(
|
|
|
|
!(communityId && communityId != "" && com.communityId == communityId)
|
|
|
|
&&
|
|
|
|
this.managerOfCommunities && this.subscriberOfCommunities)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (this.user && com['status'] != "hidden") {
|
|
|
|
if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user)) {
|
|
|
|
this.managerOfCommunities = true;
|
|
|
|
} else if (com.managers.indexOf(this.user.email) != -1) {
|
|
|
|
this.managerOfCommunities = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
if (community == null) {
|
|
|
|
this.menuItems = [];
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("about", "About", "", "/about/learn-how", false, [], null, {}),
|
|
|
|
items: []
|
|
|
|
});
|
|
|
|
var myCommunities = [];
|
|
|
|
/*if(this.managerOfCommunities){
|
|
|
|
myCommunities.push( new MenuItem("","Managing communities","","/search/find/communities",false,[],[],{role:"%22manager%22"}))
|
|
|
|
}
|
|
|
|
if(Session.isLoggedIn()){
|
|
|
|
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe (
|
|
|
|
pids => {
|
|
|
|
if(pids.length > 0 ) {
|
|
|
|
myCommunities.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.error("Error fetching your subscribed communities")
|
|
|
|
});
|
|
|
|
}*/
|
|
|
|
this.menuItems.push({
|
2020-06-03 23:55:32 +02:00
|
|
|
rootItem: new MenuItem("stakeholders", "Members in Action", "", "/search/find/stakeholders", false, [], null, {}),
|
2019-09-30 14:48:48 +02:00
|
|
|
items: []
|
|
|
|
});
|
|
|
|
this.menuItems.push({
|
2020-06-03 23:55:32 +02:00
|
|
|
rootItem: new MenuItem("contact-us", "Contact us", "", "/contact-us", false, [], null, {}),
|
2019-09-30 14:48:48 +02:00
|
|
|
items: []
|
|
|
|
});
|
|
|
|
/*if(this.managerOfCommunities || this.subscriberOfCommunities){
|
|
|
|
let myCommunitiesMenu = new MenuItem("myCommunities","My Communities","","",false,[],[],{});
|
|
|
|
myCommunitiesMenu.setMarkAsActive(false);
|
|
|
|
this.menuItems.push({rootItem: myCommunitiesMenu, items: myCommunities});
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
this.bottomMenuItems = [
|
|
|
|
new MenuItem("", "About", "https://beta.openaire.eu/project-factsheets", "", false, [], [], {}),
|
|
|
|
new MenuItem("", "News - Events", "https://beta.openaire.eu/news-events", "", false, [], [], {}),
|
|
|
|
new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}),
|
|
|
|
new MenuItem("", "Contact us", "https://beta.openaire.eu/contact-us", "", false, [], [], {})
|
|
|
|
];
|
|
|
|
// if(this.properties.showContent){
|
|
|
|
// this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
|
|
|
|
// }
|
|
|
|
this.userMenuItems = [
|
|
|
|
// new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],(data['communityId'] && typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:data['communityId']}),
|
|
|
|
];
|
2020-06-03 23:55:32 +02:00
|
|
|
if (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user)) {
|
2019-09-30 14:48:48 +02:00
|
|
|
this.userMenuItems.push(new MenuItem("", "Manage Helptexts",
|
|
|
|
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
|
|
|
|
"", false, [], [], {}))
|
2020-06-03 23:55:32 +02:00
|
|
|
this.userMenuItems.push(new MenuItem("", "Manage Stakeholders",
|
|
|
|
"/admin", "", true, [], [], {}))
|
2019-09-30 14:48:48 +02:00
|
|
|
}
|
|
|
|
/*if(this.managerOfCommunities){
|
|
|
|
this.userMenuItems.push( new MenuItem("","Managing communities","","/search/find/communities",false,[],[],{role:"%22manager%22"}))
|
|
|
|
}
|
|
|
|
if(Session.isLoggedIn()){
|
|
|
|
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe (
|
|
|
|
pids => {
|
|
|
|
if(pids.length > 0 ) {
|
|
|
|
this.userMenuItems.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.error("Error fetching your subscribed communities")
|
|
|
|
});
|
|
|
|
}*/
|
|
|
|
} else {
|
|
|
|
this.bottomMenuItems = [
|
|
|
|
// new MenuItem("","About","","/about",false,[],["/about"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
|
|
|
new MenuItem("", "Organizations", "", "/organizations", false, [], ["/organizations"], this.properties.environment != "development" ? {} : {communityId: community.communityId})
|
|
|
|
];
|
|
|
|
if (this.properties.showContent) {
|
|
|
|
this.bottomMenuItems.push(new MenuItem("", "Content Policy", "", "/content", false, [], [], {}));
|
|
|
|
}
|
|
|
|
this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/
|
|
|
|
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
|
|
|
new MenuItem("", "Invite users", "", "/invite", false, [], [], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
|
|
|
];
|
|
|
|
if (this.managerOfCommunities) {
|
|
|
|
this.userMenuItems.push(new MenuItem("", "Support", "https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611", "", false, [], [], {}))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.showMenu = true;
|
|
|
|
});
|
|
|
|
}
|
2019-01-09 12:05:23 +01:00
|
|
|
}
|