[Trunk|Connect]: 1. SearchCommunities: change getSubscribe method. 2. replace scroll with new helper function. 3. SubscribeModule: add forRoot for service

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55417 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-04-24 12:02:11 +00:00
parent e92220bd31
commit 6b5c935300
12 changed files with 388 additions and 414 deletions

View File

@ -333,10 +333,6 @@ export class AppComponent {
console.error("Error fetching your subscribed communities") console.error("Error fetching your subscribed communities")
}); });
} }
// if(this.subscriberOfCommunities){
// myCommunities.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
// }
this.menuItems.push({rootItem: new MenuItem("communities","Communities","","/search/find/communities",false,[],null,{}), items: []}); this.menuItems.push({rootItem: new MenuItem("communities","Communities","","/search/find/communities",false,[],null,{}), items: []});
if(this.managerOfCommunities || this.subscriberOfCommunities){ if(this.managerOfCommunities || this.subscriberOfCommunities){
this.menuItems.push({rootItem: new MenuItem("myCommunities","My Communities","","",false,[],[],{}), items: myCommunities}); this.menuItems.push({rootItem: new MenuItem("myCommunities","My Communities","","",false,[],[],{}), items: myCommunities});

View File

@ -1,27 +1,25 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {APP_BASE_HREF, CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {HttpModule} from '@angular/http'; import {HttpModule} from '@angular/http';
import {RouterModule} from '@angular/router'; import {BrowserModule} from '@angular/platform-browser';
import {BrowserModule} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {CKEditorModule} from 'ng2-ckeditor'; import {CKEditorModule} from 'ng2-ckeditor';
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
import {OpenaireErrorPageComponent} from './error/errorPage.component'; import {OpenaireErrorPageComponent} from './error/errorPage.component';
import {AppRoutingModule} from './app-routing.module'; import {AppRoutingModule} from './app-routing.module';
import {SharedModule} from './shared/shared.module'; import {SharedModule} from './shared/shared.module';
import {CookieLawModule} from './openaireLibrary/sharedComponents/cookie-law/cookie-law.module'; import {CookieLawModule} from './openaireLibrary/sharedComponents/cookie-law/cookie-law.module';
import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module'; import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module';
import {FeedbackModule} from './openaireLibrary/sharedComponents/feedback/feedback.module'; import {ErrorModule} from './openaireLibrary/error/error.module';
import {ErrorModule} from './openaireLibrary/error/error.module'; import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module';
import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module';
import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver';
import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service'; import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service';
import {LayoutService} from "./openaireLibrary/services/layout.service"; import {LayoutService} from "./openaireLibrary/services/layout.service";
import {SubscribeModule} from './utils/subscribe/subscribe.module'; import {SubscribeModule} from './utils/subscribe/subscribe.module';
@ -35,10 +33,10 @@ import {SubscribeModule} from './utils/subscribe/subscribe.module';
ErrorModule, ErrorModule,
CKEditorModule, CKEditorModule,
FormsModule, FormsModule,
NavigationBarModule, //FeedbackModule, NavigationBarModule,
BottomModule, BottomModule,
CookieLawModule, CookieLawModule,
SubscribeModule, SubscribeModule.forRoot(),
BrowserModule.withServerTransition({appId: 'my-app'}), BrowserModule.withServerTransition({appId: 'my-app'}),
AppRoutingModule AppRoutingModule
], ],

View File

@ -2,7 +2,6 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {SubscribeModule} from '../utils/subscribe/subscribe.module';
import {ManageModule} from '../openaireLibrary/utils/manage/manage.module'; import {ManageModule} from '../openaireLibrary/utils/manage/manage.module';
import {CommunitiesComponent} from './communities.component'; import {CommunitiesComponent} from './communities.component';
@ -19,14 +18,14 @@ import {BrowseCommunityModule} from './browseCommunity/browse-community.modul
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, RouterModule, CommonModule, FormsModule, RouterModule,
SubscribeModule, ManageModule, ErrorMessagesModule, ManageModule, ErrorMessagesModule,
SearchFormModule, BrowseCommunityModule SearchFormModule, BrowseCommunityModule
], ],
declarations: [ declarations: [
CommunitiesComponent CommunitiesComponent
], ],
providers:[ providers:[
FreeGuard, PreviousRouteRecorder, ConfigurationService, FreeGuard, PreviousRouteRecorder,
PiwikService PiwikService
], ],
exports: [ exports: [

View File

@ -1,32 +1,28 @@
import {Component, Input, Output, ElementRef} from '@angular/core'; import {Component, ElementRef, Input, ViewChild} from '@angular/core';
import {EventEmitter, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router';
import {ChangeDetectionStrategy} from '@angular/core'; import {Location} from '@angular/common';
import {ViewEncapsulation} from '@angular/core'; import {Meta, Title} from '@angular/platform-browser';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import "rxjs/add/observable/zip"; import "rxjs/add/observable/zip";
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {CommunityService} from "../openaireLibrary/connect/community/community.service"; import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service'; import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {SearchEntriesService} from '../searchEntries/searchEntries.service'; import {SearchEntriesService} from '../searchEntries/searchEntries.service';
import {SearchZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service'; import {SearchZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
import {Session} from '../openaireLibrary/login/utils/helper.class'; import {Session} from '../openaireLibrary/login/utils/helper.class';
import {StatisticsForDashboardComponent} from '../statistics/statistics.component'; import {StatisticsForDashboardComponent} from '../statistics/statistics.component';
import {StringUtils} from '../openaireLibrary/utils/string-utils.class'; import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
import {PiwikHelper} from '../utils/piwikHelper'; import {PiwikHelper} from '../utils/piwikHelper';
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
@Component({ @Component({
selector: 'community', selector: 'community',
templateUrl: 'community.component.html', templateUrl: 'community.component.html',
}) })
export class CommunityComponent { export class CommunityComponent {
@ -42,8 +38,8 @@ export class CommunityComponent {
public contentProviderTotal = null; public contentProviderTotal = null;
public organizationTotal = null; public organizationTotal = null;
params: any ={}; params: any = {};
properties:EnvProperties; properties: EnvProperties;
public publicationResults = null; public publicationResults = null;
public researchDataResults = null; public researchDataResults = null;
@ -64,180 +60,179 @@ export class CommunityComponent {
public subResearchData; public subResearchData;
public subSoftware; public subSoftware;
public subOrps; public subOrps;
@ViewChild (StatisticsForDashboardComponent) statistics : StatisticsForDashboardComponent =null; @ViewChild(StatisticsForDashboardComponent) statistics: StatisticsForDashboardComponent = null;
public activeTab = "publication"; public activeTab = "publication";
constructor (
constructor(
private element: ElementRef, private element: ElementRef,
private route: ActivatedRoute, private route: ActivatedRoute,
private _router: Router, private _router: Router,
private location: Location, private location: Location,
private _meta: Meta, private _meta: Meta,
private _title: Title, private _title: Title,
private _piwikService:PiwikService, private _piwikService: PiwikService,
private config: ConfigurationService, private config: ConfigurationService,
private _communityService:CommunityService, private _communityService: CommunityService,
private _searchEntriesService:SearchEntriesService, private _searchEntriesService: SearchEntriesService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService, private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
private _ΖenodoCommunitieService: ZenodoCommunitiesService) { private _ΖenodoCommunitieService: ZenodoCommunitiesService) {
var description = "OpenAIRE - Connect, Community Dashboard, research community"; var description = "OpenAIRE - Connect, Community Dashboard, research community";
var title = "OpenAIRE - Connect"; var title = "OpenAIRE - Connect";
this._meta.updateTag({content:description},"name='description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content:description},"property='og:description'"); this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content:title},"property='og:title'"); this._meta.updateTag({content: title}, "property='og:title'");
this._title.setTitle(title); this._title.setTitle(title);
} }
public ngOnInit() { public ngOnInit() {
this.route.data this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
var url = data.envSpecific.baseLink+this._router.url; var url = data.envSpecific.baseLink + this._router.url;
this._meta.updateTag({content:url},"property='og:url'"); this._meta.updateTag({content: url}, "property='og:url'");
if (this.communityId != null && this.communityId != '') { if (this.communityId != null && this.communityId != '') {
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe ( this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => { community => {
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView(); HelperFunctions.scroll();
} }
this.community = community; this.community = community;
if(this.properties.environment == "development"){ if (this.properties.environment == "development") {
this.params = {communityId: community.communityId}; this.params = {communityId: community.communityId};
} }
this._meta.updateTag({content:community.description},"name='description'"); this._meta.updateTag({content: community.description}, "name='description'");
this._meta.updateTag({content:community.description},"property='og:description'"); this._meta.updateTag({content: community.description}, "property='og:description'");
this._meta.updateTag({content:community.title},"property='og:title'"); this._meta.updateTag({content: community.title}, "property='og:title'");
this._title.setTitle(community.title); this._title.setTitle(community.title);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, community.title,PiwikHelper.siteIDs[this.communityId]).subscribe(); this.piwiksub = this._piwikService.trackView(this.properties, community.title, PiwikHelper.siteIDs[this.communityId]).subscribe();
} }
if(this.community.zenodoCommunity){ if (this.community.zenodoCommunity) {
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+this.community.zenodoCommunity, null).subscribe( this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.community.zenodoCommunity, null).subscribe(
result => { result => {
this.masterZenodoCommunity = result; this.masterZenodoCommunity = result;
},
error => {
// var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo();
// emptyCommunity.id = this.masterZenodoCommunityId;
// emptyCommunity.title = this.masterZenodoCommunityId;
// this.masterZenodoCommunity = emptyCommunity;
//console.log("Master Zenodo community'" + this.community.zenodoCommunity + "' couldn't be loaded");
this.handleError("Error getting Master Zenodo community with id: "+this.community.zenodoCommunityId, error);
}
);
}
this._searchZenodoCommunitiesService.searchZCommunities(this.properties,this.communityId).subscribe (
result => {
this.zenodoCommunityIdS = result;
},
error => {
//console.error("list of zenodo communities couldn't be loaded");
this.handleError("Error getting list of zenodo communities for community with openaire id: "+this.communityId, error);
} //this.handleError('System error retrieving community profile', error)
);
//console.log(community);
});
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'publications/count?format=json&fq=communityid='+this.communityId).subscribe(
publicationTotal => {
this.publicationTotal = publicationTotal;
this.showLoading = true;
this.searchPublications();
}, },
error => { error => {
this.handleError("Error getting number of publications for community with id: "+this.communityId, error); // var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo();
// emptyCommunity.id = this.masterZenodoCommunityId;
// emptyCommunity.title = this.masterZenodoCommunityId;
// this.masterZenodoCommunity = emptyCommunity;
//console.log("Master Zenodo community'" + this.community.zenodoCommunity + "' couldn't be loaded");
this.handleError("Error getting Master Zenodo community with id: " + this.community.zenodoCommunityId, error);
} }
); );
}
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'datasets/count?format=json&fq=communityid='+this.communityId).subscribe( this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
researchDataTotal => { result => {
this.researchDataTotal = researchDataTotal; this.zenodoCommunityIdS = result;
},
error => {
this.handleError("Error getting number of research data for community with id: "+this.communityId, error);
}
);
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'software/count?format=json&fq=communityid='+this.communityId).subscribe(
softwareTotal => {
this.softwareTotal = softwareTotal;
},
error => {
this.handleError("Error getting number of software for community with id: "+this.communityId, error);
}
);
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'other/count?format=json&fq=communityid='+this.communityId).subscribe(
orpTotal => {
this.orpTotal = orpTotal;
},
error => {
this.handleError("Error getting number of other research products for community with id: "+this.communityId, error);
}
);
this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/projects').subscribe(
projectTotal => {
this.projectTotal = projectTotal;
//console.log(projectTotal);
},
error => {
this.handleError("Error getting number of projects for community with id: "+this.communityId, error);
}
);
this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/contentproviders').subscribe(
contentProviderTotal => {
this.contentProviderTotal = contentProviderTotal;
//console.log(contentProviderTotal);
},
error => {
this.handleError("Error getting number of content providers for community with id: "+this.communityId, error);
}
);
// this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
// organizationTotal => {
// this.organizationTotal = organizationTotal;
// console.log(organizationTotal);
// });
/**/ },
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe( error => {
res => { //console.error("list of zenodo communities couldn't be loaded");
this.communityInfo = res; this.handleError("Error getting list of zenodo communities for community with openaire id: " + this.communityId, error);
}, } //this.handleError('System error retrieving community profile', error)
error => { );
//console.log(error)
this.handleError("Error getting community with id: "+this.communityId, error); //console.log(community);
} });
);
}
}); this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'publications/count?format=json&fq=communityid=' + this.communityId).subscribe(
publicationTotal => {
this.publicationTotal = publicationTotal;
this.showLoading = true;
this.searchPublications();
},
error => {
this.handleError("Error getting number of publications for community with id: " + this.communityId, error);
}
);
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'datasets/count?format=json&fq=communityid=' + this.communityId).subscribe(
researchDataTotal => {
this.researchDataTotal = researchDataTotal;
},
error => {
this.handleError("Error getting number of research data for community with id: " + this.communityId, error);
}
);
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'software/count?format=json&fq=communityid=' + this.communityId).subscribe(
softwareTotal => {
this.softwareTotal = softwareTotal;
},
error => {
this.handleError("Error getting number of software for community with id: " + this.communityId, error);
}
);
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'other/count?format=json&fq=communityid=' + this.communityId).subscribe(
orpTotal => {
this.orpTotal = orpTotal;
},
error => {
this.handleError("Error getting number of other research products for community with id: " + this.communityId, error);
}
);
this._searchEntriesService.countTotal(this.properties.communityAPI + this.communityId + '/projects').subscribe(
projectTotal => {
this.projectTotal = projectTotal;
//console.log(projectTotal);
},
error => {
this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
}
);
this._searchEntriesService.countTotal(this.properties.communityAPI + this.communityId + '/contentproviders').subscribe(
contentProviderTotal => {
this.contentProviderTotal = contentProviderTotal;
//console.log(contentProviderTotal);
},
error => {
this.handleError("Error getting number of content providers for community with id: " + this.communityId, error);
}
);
// this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
// organizationTotal => {
// this.organizationTotal = organizationTotal;
// console.log(organizationTotal);
// });
/**/
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe(
res => {
this.communityInfo = res;
},
error => {
//console.log(error)
this.handleError("Error getting community with id: " + this.communityId, error);
}
);
}
});
} }
public searchPublications() { public searchPublications() {
this.activeTab = "publication"; this.activeTab = "publication";
if (this.publicationTotal > 0 && this.publicationResults == null) { if (this.publicationTotal > 0 && this.publicationResults == null) {
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'publications?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'publications?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
publicationResults => { publicationResults => {
this.publicationResults = publicationResults; this.publicationResults = publicationResults;
this.showLoading = false; this.showLoading = false;
//console.log(publicationResults); //console.log(publicationResults);
}, },
error => { error => {
this.handleError("Error getting publications for community with id: "+this.communityId, error); this.handleError("Error getting publications for community with id: " + this.communityId, error);
} }
); );
} }
@ -246,13 +241,13 @@ public activeTab = "publication";
public searchResearchData() { public searchResearchData() {
this.activeTab = "dataset"; this.activeTab = "dataset";
if (this.researchDataTotal > 0 && this.researchDataResults == null) { if (this.researchDataTotal > 0 && this.researchDataResults == null) {
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'datasets?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'datasets?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
researchDataResults => { researchDataResults => {
this.researchDataResults = researchDataResults; this.researchDataResults = researchDataResults;
this.showLoading = false; this.showLoading = false;
}, },
error => { error => {
this.handleError("Error getting research data for community with id: "+this.communityId, error); this.handleError("Error getting research data for community with id: " + this.communityId, error);
} }
); );
} }
@ -261,13 +256,13 @@ public activeTab = "publication";
public searchSoftware() { public searchSoftware() {
this.activeTab = "software"; this.activeTab = "software";
if (this.softwareTotal > 0 && this.softwareResults == null) { if (this.softwareTotal > 0 && this.softwareResults == null) {
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'software?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'software?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
softwareResults => { softwareResults => {
this.softwareResults = softwareResults; this.softwareResults = softwareResults;
this.showLoading = false; this.showLoading = false;
}, },
error => { error => {
this.handleError("Error getting software for community with id: "+this.communityId, error); this.handleError("Error getting software for community with id: " + this.communityId, error);
} }
); );
} }
@ -276,80 +271,83 @@ public activeTab = "publication";
public searchOrps() { public searchOrps() {
this.activeTab = "orp"; this.activeTab = "orp";
if (this.orpTotal > 0 && this.orpResults == null) { if (this.orpTotal > 0 && this.orpResults == null) {
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'other?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'other?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
orpResults => { orpResults => {
this.orpResults = orpResults; this.orpResults = orpResults;
this.showLoading = false; this.showLoading = false;
}, },
error => { error => {
this.handleError("Error getting other research products for community with id: "+this.communityId, error); this.handleError("Error getting other research products for community with id: " + this.communityId, error);
} }
); );
} }
} }
public ngOnDestroy() { public ngOnDestroy() {
if(this.piwiksub){ if (this.piwiksub) {
this.piwiksub.unsubscribe(); this.piwiksub.unsubscribe();
} }
} }
isEntityEnabled(entity: string) { isEntityEnabled(entity: string) {
return this.communityInfo.entities.some(x => x['pid'] == entity && x['isEnabled']===true); return this.communityInfo.entities.some(x => x['pid'] == entity && x['isEnabled'] === true);
} }
isRouteEnabled(route: string) { isRouteEnabled(route: string) {
return this.communityInfo.pages.some(x => x['route'] == route && x['isEnabled']===true); return this.communityInfo.pages.some(x => x['route'] == route && x['isEnabled'] === true);
} }
showInvite(){
showInvite() {
return this.isManager(); return this.isManager();
} }
isManager(){ isManager() {
var email = Session.getUserEmail(); var email = Session.getUserEmail();
var index =-1; var index = -1;
if(email && this.community != null && this.community.managers != null){ if (email && this.community != null && this.community.managers != null) {
index = this.community.managers.indexOf(email); index = this.community.managers.indexOf(email);
} }
return Session.isPortalAdministrator() || Session.isCommunityCurator() || index != -1; return Session.isPortalAdministrator() || Session.isCommunityCurator() || index != -1;
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Community (component): "+message, error); console.error("Community (component): " + message, error);
} }
getSearchPlaceHolder(){ getSearchPlaceHolder() {
var entities = []; var entities = [];
if(this.isEntityEnabled("publication")){ if (this.isEntityEnabled("publication")) {
entities.push("publications"); entities.push("publications");
} }
if(this.isEntityEnabled("dataset")){ if (this.isEntityEnabled("dataset")) {
entities.push("research data"); entities.push("research data");
} }
if(this.isEntityEnabled("software")){ if (this.isEntityEnabled("software")) {
entities.push("software"); entities.push("software");
} }
if(this.isEntityEnabled("orp")){ if (this.isEntityEnabled("orp")) {
entities.push("other research products"); entities.push("other research products");
} }
return "Search"+ ((entities.length > 0 )?(" for "+entities.join(', ')+"..."):""); return "Search" + ((entities.length > 0) ? (" for " + entities.join(', ') + "...") : "");
} }
countOtherGraphs(){ countOtherGraphs() {
var count = 0; var count = 0;
if(this.statistics && this.statistics.allowedEntities){ if (this.statistics && this.statistics.allowedEntities) {
for(var entity of this.statistics.allowedEntities){ for (var entity of this.statistics.allowedEntities) {
if(this.statistics.statisticsSum[entity].total>0 && this.statistics.allowedCharts[entity].length>0 && this.activeTab!=entity){ if (this.statistics.statisticsSum[entity].total > 0 && this.statistics.allowedCharts[entity].length > 0 && this.activeTab != entity) {
count+=this.statistics.allowedCharts[entity].length; count += this.statistics.allowedCharts[entity].length;
}
} }
} }
return count;
} }
return count;
} createParams(param) {
createParams(param){
return StringUtils.quote(StringUtils.URIEncode(param)); return StringUtils.quote(StringUtils.URIEncode(param));
} }
} }

View File

@ -31,7 +31,7 @@ import {SearchFormModule} from '../openaireLibrary/searchPages/searchUti
CommunityComponent, ResultsComponent CommunityComponent, ResultsComponent
], ],
providers:[ providers:[
FreeGuard, PreviousRouteRecorder, ConfigurationService, FreeGuard, PreviousRouteRecorder,
PiwikService, CommunityService, SearchEntriesService PiwikService, CommunityService, SearchEntriesService
], ],
exports: [ exports: [

View File

@ -8,6 +8,7 @@ import {ContactForm} from "../openaireLibrary/utils/email/contact-form";
import {Composer} from "../openaireLibrary/utils/email/composer"; import {Composer} from "../openaireLibrary/utils/email/composer";
import {Title} from "@angular/platform-browser"; import {Title} from "@angular/platform-browser";
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service"; import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
@Component({ @Component({
selector: 'contact', selector: 'contact',
@ -36,8 +37,7 @@ export class ContactComponent implements OnInit {
@ViewChild('message') message; @ViewChild('message') message;
@ViewChild('recaptcha') recaptcha; @ViewChild('recaptcha') recaptcha;
constructor(private element: ElementRef, constructor(private route: ActivatedRoute,
private route: ActivatedRoute,
private _router: Router, private _router: Router,
private _emailService: EmailService, private _emailService: EmailService,
private _title: Title, private _title: Title,
@ -53,19 +53,13 @@ export class ContactComponent implements OnInit {
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect|Contact Us", this.properties.piwikSiteId).subscribe(); this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect|Contact Us", this.properties.piwikSiteId).subscribe();
} }
this.scroll(); HelperFunctions.scroll();
this.showLoading = false; this.showLoading = false;
}); });
} }
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
public send() { public send() {
this.scroll(); HelperFunctions.scroll();
if(!this.name.invalid && !this.surname.invalid && !this.sender.invalid && if(!this.name.invalid && !this.surname.invalid && !this.sender.invalid &&
this.contactForm.email.match('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$') && this.contactForm.email.match('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$') &&
!this.affiliation.invalid && !this.message.invalid && this.contactForm.recaptcha != '') { !this.affiliation.invalid && !this.message.invalid && this.contactForm.recaptcha != '') {

View File

@ -4,7 +4,6 @@ import {Title, Meta} from '@angular/platform-browser';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {AppElementService} from "../appElementService.service";
declare var UIkit: any; declare var UIkit: any;
@ -277,8 +276,7 @@ export class CommunityCreationInstructionsComponent {
private route: ActivatedRoute, private route: ActivatedRoute,
private _router: Router, private _router: Router,
private _title: Title, private _title: Title,
private _piwikService:PiwikService, private _piwikService:PiwikService) {
private appElementsService: AppElementService) {
var description = "OpenAIRE - Connect, Community Dashboard, research community"; var description = "OpenAIRE - Connect, Community Dashboard, research community";
var title = "OpenAIRE - Connect | Create and manage your community page"; var title = "OpenAIRE - Connect | Create and manage your community page";
@ -345,7 +343,7 @@ export class CommunityCreationInstructionsComponent {
*/ */
/*UIkit.util.on('#logo', 'beforehide', function () { /*UIkit.util.on('#logo', 'beforehide', function () {
// do something // do something
if(this.hide == false) { if(this.hide =http://www.equp4.wf/= false) {
return false; return false;
} }
});*/ });*/

View File

@ -1,168 +1,173 @@
import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core'; import {Component} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Meta, Title} from '@angular/platform-browser';
import{EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service'; import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo';
import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo';
import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class';
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
@Component({ @Component({
selector: 'share-in-zenodo', selector: 'share-in-zenodo',
templateUrl: './shareInZenodo.component.html' templateUrl: './shareInZenodo.component.html'
}) })
export class ShareInZenodoComponent { export class ShareInZenodoComponent {
properties:EnvProperties; properties: EnvProperties;
private communityId: string = null; private communityId: string = null;
private community:CommunityInfo = null; private community: CommunityInfo = null;
// public warningMessage = ""; // public warningMessage = "";
// public infoMessage = ""; // public infoMessage = "";
masterZenodoCommunityId = null; masterZenodoCommunityId = null;
masterZenodoCommunity = null; masterZenodoCommunity = null;
CommunityIds = null; CommunityIds = null;
communities = []; communities = [];
zenodocommunitiesloadedCount = 0; zenodocommunitiesloadedCount = 0;
zenodoSearchUtils:SearchUtilsClass = new SearchUtilsClass(); zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass();
errorCodes: ErrorCodes = new ErrorCodes();; errorCodes: ErrorCodes = new ErrorCodes();
depositLink = "https://zenodo.org/deposit/new?c="; depositLink = "https://zenodo.org/deposit/new?c=";
constructor (private element: ElementRef, private route: ActivatedRoute, private _router: Router, constructor(private route: ActivatedRoute, private _router: Router,
private _meta: Meta, private _title: Title, private _ΖenodoCommunitieService: ZenodoCommunitiesService,private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {} private _meta: Meta, private _title: Title, private _ΖenodoCommunitieService: ZenodoCommunitiesService, private _communityService: CommunityService, private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
}
public ngOnInit() { public ngOnInit() {
this.zenodoSearchUtils.status = this.errorCodes.LOADING;; this.zenodoSearchUtils.status = this.errorCodes.LOADING;
;
this.route.data this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.updateUrl(data.envSpecific.baseLink+this._router.url); this.updateUrl(data.envSpecific.baseLink + this._router.url);
this.updateTitle("Share in Zenodo"); this.updateTitle("Share in Zenodo");
this.updateDescription("Zenodo, repository, deposit, share"); this.updateDescription("Zenodo, repository, deposit, share");
this.properties = data.envSpecific; this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
this.communityId = params['communityId']; this.communityId = params['communityId'];
if(!this.communityId){ if (!this.communityId) {
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
} }
if(this.communityId) { if (this.communityId) {
if (this.communityId != null && this.communityId != '') { if (this.communityId != null && this.communityId != '') {
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe ( this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => { community => {
this.community = community; this.community = community;
this.masterZenodoCommunityId = this.community.zenodoCommunity; this.masterZenodoCommunityId = this.community.zenodoCommunity;
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView(); HelperFunctions.scroll();
} }
if(this.masterZenodoCommunityId){ if (this.masterZenodoCommunityId) {
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+this.masterZenodoCommunityId, null).subscribe( this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.masterZenodoCommunityId, null).subscribe(
result => { result => {
this.masterZenodoCommunity = result; this.masterZenodoCommunity = result;
}, },
error => {
// var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo();
// emptyCommunity.id = this.masterZenodoCommunityId;
// emptyCommunity.title = this.masterZenodoCommunityId;
// this.masterZenodoCommunity = emptyCommunity;
//console.error("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded");
this.handleError("Error getting Master Zenodo community with id: "+this.masterZenodoCommunityId, error);
}
);
}
this.zenodoSearchUtils.status = this.errorCodes.LOADING;;
this._searchZenodoCommunitiesService.searchZCommunities(this.properties,this.communityId).subscribe (
result => {
this.CommunityIds = result;
this.zenodoSearchUtils.totalResults = this.CommunityIds.length;
if(this.CommunityIds.length == 0){
this.zenodoSearchUtils.status = this.errorCodes.NONE;
}
for(let i=0; i< this.CommunityIds.length; i++){
this.getZenodoCommunityById(this.CommunityIds[i]["zenodoid"], this.CommunityIds[i]["id"]);
}
},
error => {
//console.error("list of zenodo communities couldn't be loaded");
this.handleError("Error getting list of zenodo communities for community with openaire id: "+this.communityId, error);
this.zenodoSearchUtils.status = this.errorCodes.ERROR;
} //this.handleError('System error retrieving community profile', error)
);
},
error => { error => {
//console.error("Community couldn't be loaded"); // var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo();
this.handleError("Error getting community with id: "+this.communityId, error); // emptyCommunity.id = this.masterZenodoCommunityId;
this.zenodoSearchUtils.status = this.errorCodes.ERROR; // emptyCommunity.title = this.masterZenodoCommunityId;
// this.masterZenodoCommunity = emptyCommunity;
//console.error("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded");
this.handleError("Error getting Master Zenodo community with id: " + this.masterZenodoCommunityId, error);
} }
); );
}
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
;
this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
result => {
this.CommunityIds = result;
this.zenodoSearchUtils.totalResults = this.CommunityIds.length;
if (this.CommunityIds.length == 0) {
this.zenodoSearchUtils.status = this.errorCodes.NONE;
}
for (let i = 0; i < this.CommunityIds.length; i++) {
this.getZenodoCommunityById(this.CommunityIds[i]["zenodoid"], this.CommunityIds[i]["id"]);
}
},
error => {
//console.error("list of zenodo communities couldn't be loaded");
this.handleError("Error getting list of zenodo communities for community with openaire id: " + this.communityId, error);
this.zenodoSearchUtils.status = this.errorCodes.ERROR;
} //this.handleError('System error retrieving community profile', error)
);
},
error => {
//console.error("Community couldn't be loaded");
this.handleError("Error getting community with id: " + this.communityId, error);
this.zenodoSearchUtils.status = this.errorCodes.ERROR;
} }
);
} }
});
}
}); });
} });
private updateDescription(description:string){
this._meta.updateTag({content:description},"name='description'");
this._meta.updateTag({content:description},"property='og:description'");
} }
private updateTitle(title:string){
var _prefix ="OpenAIRE | ";
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title); private updateDescription(description: string) {
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
}
private updateTitle(title: string) {
var _prefix = "OpenAIRE | ";
var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title); this._title.setTitle(_title);
this._meta.updateTag({content:_title},"property='og:title'"); this._meta.updateTag({content: _title}, "property='og:title'");
} }
private updateUrl(url:string){
this._meta.updateTag({content:url},"property='og:url'"); private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'");
} }
getZenodoCommunityById(zenodoid, openaireId){
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+zenodoid, openaireId).subscribe( getZenodoCommunityById(zenodoid, openaireId) {
result => { this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + zenodoid, openaireId).subscribe(
this.communities.push(result); result => {
this.zenodocommunitiesloadedCount++; this.communities.push(result);
if(this.zenodocommunitiesloadedCount >= this.CommunityIds.length){ this.zenodocommunitiesloadedCount++;
this.zenodoSearchUtils.status = this.errorCodes.DONE; if (this.zenodocommunitiesloadedCount >= this.CommunityIds.length) {
} this.zenodoSearchUtils.status = this.errorCodes.DONE;
}
}, },
error => { error => {
// var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo(); // var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo();
// emptyCommunity.id = zenodoid; // emptyCommunity.id = zenodoid;
// emptyCommunity.openaireId = openaireId; // emptyCommunity.openaireId = openaireId;
// emptyCommunity.title = zenodoid; // emptyCommunity.title = zenodoid;
// this.communities.push(emptyCommunity); // this.communities.push(emptyCommunity);
this.zenodocommunitiesloadedCount++; this.zenodocommunitiesloadedCount++;
if(this.zenodocommunitiesloadedCount >= this.CommunityIds.length){ if (this.zenodocommunitiesloadedCount >= this.CommunityIds.length) {
this.zenodoSearchUtils.status = this.errorCodes.DONE; this.zenodoSearchUtils.status = this.errorCodes.DONE;
} }
//console.error("Zenodo community'"+zenodoid+"' couldn't be loaded"); //console.error("Zenodo community'"+zenodoid+"' couldn't be loaded");
this.handleError("Error getting Zenodo community with id: "+zenodoid+" and openaire id: "+openaireId, error); this.handleError("Error getting Zenodo community with id: " + zenodoid + " and openaire id: " + openaireId, error);
}
);
} }
);
}
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Share in Zenodo Page: "+message, error); console.error("Share in Zenodo Page: " + message, error);
} }
} }

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, ViewChild} from "@angular/core"; import {Component, ViewChild} from "@angular/core";
import {SearchUtilsClass} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchUtilsClass} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ErrorMessagesComponent} from "../../openaireLibrary/utils/errorMessages.component"; import {ErrorMessagesComponent} from "../../openaireLibrary/utils/errorMessages.component";
import {ErrorCodes} from "../../openaireLibrary/utils/properties/errorCodes"; import {ErrorCodes} from "../../openaireLibrary/utils/properties/errorCodes";
@ -11,11 +11,9 @@ import {CommunitiesService} from "../../openaireLibrary/connect/communities/comm
import {Session} from "../../openaireLibrary/login/utils/helper.class"; import {Session} from "../../openaireLibrary/login/utils/helper.class";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service"; import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
import {Observable} from "rxjs";
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service"; import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
import {catchError} from "rxjs/operators"; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {of} from "rxjs/observable/of";
@Component({ @Component({
selector: 'search-communities', selector: 'search-communities',
@ -51,7 +49,6 @@ export class SearchCommunitiesComponent {
constructor (private route: ActivatedRoute, constructor (private route: ActivatedRoute,
private _communitiesService: CommunitiesService, private _communitiesService: CommunitiesService,
private _subscribeService: SubscribeService, private _subscribeService: SubscribeService,
private element: ElementRef,
private _piwikService: PiwikService) { private _piwikService: PiwikService) {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
@ -104,7 +101,6 @@ export class SearchCommunitiesComponent {
private initCommunities(params: Map<string, string>) { private initCommunities(params: Map<string, string>) {
this.subResults = this._communitiesService.getCommunitiesState().subscribe( this.subResults = this._communitiesService.getCommunitiesState().subscribe(
data => { data => {
let observables: Observable<boolean>[] = [];
for(let i = 0; i < data.length; i++) { for(let i = 0; i < data.length; i++) {
this.totalResults[i] = data[i]; this.totalResults[i] = data[i];
this.totalResults[i].isManager = false; this.totalResults[i].isManager = false;
@ -113,21 +109,17 @@ export class SearchCommunitiesComponent {
//this.results[i].description = "EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation." //this.results[i].description = "EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation."
//this.results[i].date = new Date(new Date(2012, 0, 1).getTime() + Math.random() * (new Date().getTime() - new Date(2012, 0, 1).getTime())); //this.results[i].date = new Date(new Date(2012, 0, 1).getTime() + Math.random() * (new Date().getTime() - new Date(2012, 0, 1).getTime()));
if(Session.isLoggedIn()) { if(Session.isLoggedIn()) {
let observable: Observable<boolean> = this._subscribeService.isSubscribedToCommunity(this.totalResults[i].communityId, Session.getUserEmail(), this.properties["adminToolsAPIURL"]);
observables.push(observable.pipe(catchError(err => {
return of(false);
})));
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]); this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
} }
} }
if (observables.length > 0) { if(Session.isLoggedIn()) {
Observable.forkJoin(observables).subscribe( this._subscribeService.getCommunitiesSubscribedTo(Session.getUserEmail(), this.properties["adminToolsAPIURL"]).subscribe(
res => { res => {
for (let i = 0; i < res.length; i++) { for (let i = 0; i < this.totalResults.length; i++) {
this.totalResults[i].isSubscribed = res[i]; this.totalResults[i].isSubscribed = (res.indexOf(this.totalResults[i].communityId) != -1);
}
this._getResults(params);
} }
this._getResults(params);
}
); );
} }
else { else {
@ -138,7 +130,7 @@ export class SearchCommunitiesComponent {
this.handleError('Error getting communities', err); this.handleError('Error getting communities', err);
this.searchUtils.status = this.errorMessages.getErrorCode(err.status); this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
this.disableForms = false; this.disableForms = false;
this.scroll(); HelperFunctions.scroll();
} }
); );
} }
@ -217,7 +209,7 @@ export class SearchCommunitiesComponent {
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
} }
} }
this.scroll(); HelperFunctions.scroll();
} }
@ -481,9 +473,4 @@ export class SearchCommunitiesComponent {
console.error('Communities Search Page: ' + message, error); console.error('Communities Search Page: ' + message, error);
} }
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
} }

View File

@ -4,10 +4,8 @@ import {FormsModule} from "@angular/forms";
import {SearchCommunitiesComponent} from "./searchCommunities.component"; import {SearchCommunitiesComponent} from "./searchCommunities.component";
import {SearchPageModule} from "../../openaireLibrary/searchPages/searchUtils/searchPage.module"; import {SearchPageModule} from "../../openaireLibrary/searchPages/searchUtils/searchPage.module";
import {SearchFormModule} from "../../openaireLibrary/searchPages/searchUtils/searchForm.module"; import {SearchFormModule} from "../../openaireLibrary/searchPages/searchUtils/searchForm.module";
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service";
import {SearchCommunitiesRoutingModule} from "./searchCommunities-routing.module"; import {SearchCommunitiesRoutingModule} from "./searchCommunities-routing.module";
import {PreviousRouteRecorder} from "../../openaireLibrary/utils/piwik/previousRouteRecorder.guard"; import {PreviousRouteRecorder} from "../../openaireLibrary/utils/piwik/previousRouteRecorder.guard";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service"; import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
@NgModule({ @NgModule({
@ -19,7 +17,7 @@ import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
declarations: [ declarations: [
SearchCommunitiesComponent SearchCommunitiesComponent
], ],
providers:[ SubscribeService, PreviousRouteRecorder, PiwikService], providers:[ PreviousRouteRecorder, PiwikService],
exports: [ exports: [
SearchCommunitiesComponent SearchCommunitiesComponent
] ]

View File

@ -16,6 +16,7 @@ import {CommunityService} from "../../../openaire
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../../openaireLibrary/utils/errorMessages.component'; import {ErrorMessagesComponent} from '../../../openaireLibrary/utils/errorMessages.component';
import {Session} from '../../../openaireLibrary/login/utils/helper.class'; import {Session} from '../../../openaireLibrary/login/utils/helper.class';
import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class";
@Component({ @Component({
selector: 'invite', selector: 'invite',
@ -59,7 +60,6 @@ export class InviteComponent implements OnInit {
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
constructor ( constructor (
private element: ElementRef,
private route: ActivatedRoute, private route: ActivatedRoute,
private _router: Router, private _router: Router,
public _fb: FormBuilder, public _fb: FormBuilder,
@ -112,22 +112,17 @@ export class InviteComponent implements OnInit {
}); });
this.scroll(); HelperFunctions.scroll();
}); });
} }
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
public invite() { public invite() {
this.successfulSentMessage = ""; this.successfulSentMessage = "";
this.failureSentMessage = ""; this.failureSentMessage = "";
this.inviteErrorMessage = ""; this.inviteErrorMessage = "";
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.scroll(); HelperFunctions.scroll();
if (!this.isEmpty(this.recipients) && this.body.fromName != "") { if (!this.isEmpty(this.recipients) && this.body.fromName != "") {
if (this.validateEmails()) { if (this.validateEmails()) {
this.composeEmail(); this.composeEmail();

View File

@ -1,8 +1,8 @@
import { NgModule} from '@angular/core'; import {ModuleWithProviders, NgModule} from '@angular/core';
import { CommonModule } from '@angular/common'; import {CommonModule} from '@angular/common';
import { RouterModule } from '@angular/router'; import {RouterModule} from '@angular/router';
import { SubscribeService } from '../../openaireLibrary/utils/subscribe/subscribe.service'; import {SubscribeService} from '../../openaireLibrary/utils/subscribe/subscribe.service';
import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
import {EmailService} from "../../openaireLibrary/utils/email/email.service"; import {EmailService} from "../../openaireLibrary/utils/email/email.service";
@ -11,16 +11,22 @@ import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.mod
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, RouterModule, AlertModalModule CommonModule, RouterModule, AlertModalModule
], ],
declarations: [ declarations: [
SubscribeComponent SubscribeComponent
], ],
providers:[
SubscribeService, EmailService, CommunityService
],
exports: [ exports: [
SubscribeComponent SubscribeComponent
] ]
}) })
export class SubscribeModule { } export class SubscribeModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SubscribeModule,
providers: [
SubscribeService, EmailService, CommunityService
]
}
}
}