import {Component, Input, OnInit} from '@angular/core'; import {Session, User} from '../../openaireLibrary/login/utils/helper.class'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {ActivatedRoute} from '@angular/router'; import {EnvironmentSpecificService} from '../../openaireLibrary/utils/properties/environment-specific.service'; import {CommunitiesService} from '../../openaireLibrary/connect/communities/communities.service'; import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; @Component({ selector: 'wellcome', template: `
Build an Open Research Gateway for your Community

Turn Open Science into practice

Share and link your research results.
Across organizations, across borders.
Customized to your needs.
` }) export class WellcomeComponent implements OnInit { properties: EnvProperties = null; public communities: CommunityInfo[] = []; showLoading: boolean; private user: User; constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, private _communitiesService: CommunitiesService, private userManagementService: UserManagementService) { } ngOnInit() { this.showLoading = true; this.propertiesService.loadEnvironment().then(es => { this.propertiesService.setEnvProperties(es); this.properties = this.propertiesService.envSpecific; HelperFunctions.scroll(); this.userManagementService.getUserInfo().subscribe(user => { this.user = user; //this._communitiesService.getCommunities(this.properties, this.properties.communityAPI + 'communities').subscribe( this._communitiesService.getCommunitiesState().subscribe( communities => { if (!communities || communities.length === 0) { return; } var countCommunities = 0; var index_managerOfCommunity = null; for (var i = 0; i < communities.length; i++) { var com = communities[i]; if (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user)) { this.communities.push(communities[i]); } else { for (var manager of com.managers) { if (this.user && manager == this.user.email) { countCommunities++; index_managerOfCommunity = i; this.communities.push(communities[i]); break; } } } } this.showLoading = false; }); }); }); } }