[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")
});
}
// 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: []});
if(this.managerOfCommunities || this.subscriberOfCommunities){
this.menuItems.push({rootItem: new MenuItem("myCommunities","My Communities","","",false,[],[],{}), items: myCommunities});

View File

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

View File

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

View File

@ -1,32 +1,28 @@
import {Component, Input, Output, ElementRef} from '@angular/core';
import {EventEmitter, ViewChild} from '@angular/core';
import {ChangeDetectionStrategy} from '@angular/core';
import {ViewEncapsulation} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Component, ElementRef, Input, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Meta, Title} from '@angular/platform-browser';
import "rxjs/add/observable/zip";
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {SearchEntriesService} from '../searchEntries/searchEntries.service';
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {SearchEntriesService} from '../searchEntries/searchEntries.service';
import {SearchZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
import {Session} from '../openaireLibrary/login/utils/helper.class';
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 {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'community',
templateUrl: 'community.component.html',
selector: 'community',
templateUrl: 'community.component.html',
})
export class CommunityComponent {
@ -42,8 +38,8 @@ export class CommunityComponent {
public contentProviderTotal = null;
public organizationTotal = null;
params: any ={};
properties:EnvProperties;
params: any = {};
properties: EnvProperties;
public publicationResults = null;
public researchDataResults = null;
@ -64,180 +60,179 @@ export class CommunityComponent {
public subResearchData;
public subSoftware;
public subOrps;
@ViewChild (StatisticsForDashboardComponent) statistics : StatisticsForDashboardComponent =null;
public activeTab = "publication";
constructor (
@ViewChild(StatisticsForDashboardComponent) statistics: StatisticsForDashboardComponent = null;
public activeTab = "publication";
constructor(
private element: ElementRef,
private route: ActivatedRoute,
private _router: Router,
private location: Location,
private _meta: Meta,
private _title: Title,
private _piwikService:PiwikService,
private config: ConfigurationService,
private _communityService:CommunityService,
private _searchEntriesService:SearchEntriesService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
private route: ActivatedRoute,
private _router: Router,
private location: Location,
private _meta: Meta,
private _title: Title,
private _piwikService: PiwikService,
private config: ConfigurationService,
private _communityService: CommunityService,
private _searchEntriesService: SearchEntriesService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
private _ΖenodoCommunitieService: ZenodoCommunitiesService) {
var description = "OpenAIRE - Connect, Community Dashboard, research community";
var title = "OpenAIRE - Connect";
this._meta.updateTag({content:description},"name='description'");
this._meta.updateTag({content:description},"property='og:description'");
this._meta.updateTag({content:title},"property='og:title'");
this._title.setTitle(title);
var description = "OpenAIRE - Connect, Community Dashboard, research community";
var title = "OpenAIRE - Connect";
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content: title}, "property='og:title'");
this._title.setTitle(title);
}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
var url = data.envSpecific.baseLink+this._router.url;
this._meta.updateTag({content:url},"property='og:url'");
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
var url = data.envSpecific.baseLink + this._router.url;
this._meta.updateTag({content: url}, "property='og:url'");
if (this.communityId != null && this.communityId != '') {
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
community => {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
this.community = community;
if(this.properties.environment == "development"){
this.params = {communityId: community.communityId};
}
this._meta.updateTag({content:community.description},"name='description'");
this._meta.updateTag({content:community.description},"property='og:description'");
this._meta.updateTag({content:community.title},"property='og:title'");
this._title.setTitle(community.title);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, community.title,PiwikHelper.siteIDs[this.communityId]).subscribe();
}
if(this.community.zenodoCommunity){
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+this.community.zenodoCommunity, null).subscribe(
result => {
this.masterZenodoCommunity = result;
if (this.communityId != null && this.communityId != '') {
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => {
if (typeof document !== 'undefined') {
HelperFunctions.scroll();
}
this.community = community;
if (this.properties.environment == "development") {
this.params = {communityId: community.communityId};
}
this._meta.updateTag({content: community.description}, "name='description'");
this._meta.updateTag({content: community.description}, "property='og:description'");
this._meta.updateTag({content: community.title}, "property='og:title'");
this._title.setTitle(community.title);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, community.title, PiwikHelper.siteIDs[this.communityId]).subscribe();
}
if (this.community.zenodoCommunity) {
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.community.zenodoCommunity, null).subscribe(
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 => {
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(
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._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
result => {
this.zenodoCommunityIdS = result;
/**/
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);
}
);
}
});
},
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 => {
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() {
this.activeTab = "publication";
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 => {
this.publicationResults = publicationResults;
this.showLoading = false;
//console.log(publicationResults);
this.publicationResults = publicationResults;
this.showLoading = false;
//console.log(publicationResults);
},
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() {
this.activeTab = "dataset";
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 => {
this.researchDataResults = researchDataResults;
this.showLoading = false;
this.researchDataResults = researchDataResults;
this.showLoading = false;
},
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() {
this.activeTab = "software";
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 => {
this.softwareResults = softwareResults;
this.showLoading = false;
this.softwareResults = softwareResults;
this.showLoading = false;
},
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() {
this.activeTab = "orp";
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 => {
this.orpResults = orpResults;
this.showLoading = false;
this.orpResults = orpResults;
this.showLoading = false;
},
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() {
if(this.piwiksub){
if (this.piwiksub) {
this.piwiksub.unsubscribe();
}
}
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) {
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();
}
isManager(){
isManager() {
var email = Session.getUserEmail();
var index =-1;
if(email && this.community != null && this.community.managers != null){
index = this.community.managers.indexOf(email);
var index = -1;
if (email && this.community != null && this.community.managers != null) {
index = this.community.managers.indexOf(email);
}
return Session.isPortalAdministrator() || Session.isCommunityCurator() || index != -1;
}
private handleError(message: string, error) {
console.error("Community (component): "+message, error);
console.error("Community (component): " + message, error);
}
getSearchPlaceHolder(){
getSearchPlaceHolder() {
var entities = [];
if(this.isEntityEnabled("publication")){
if (this.isEntityEnabled("publication")) {
entities.push("publications");
}
if(this.isEntityEnabled("dataset")){
if (this.isEntityEnabled("dataset")) {
entities.push("research data");
}
if(this.isEntityEnabled("software")){
if (this.isEntityEnabled("software")) {
entities.push("software");
}
if(this.isEntityEnabled("orp")){
if (this.isEntityEnabled("orp")) {
entities.push("other research products");
}
return "Search"+ ((entities.length > 0 )?(" for "+entities.join(', ')+"..."):"");
return "Search" + ((entities.length > 0) ? (" for " + entities.join(', ') + "...") : "");
}
countOtherGraphs(){
var count = 0;
if(this.statistics && 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){
count+=this.statistics.allowedCharts[entity].length;
countOtherGraphs() {
var count = 0;
if (this.statistics && 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) {
count += this.statistics.allowedCharts[entity].length;
}
}
}
return count;
}
return count;
}
createParams(param){
createParams(param) {
return StringUtils.quote(StringUtils.URIEncode(param));
}
}
}

View File

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

View File

@ -8,6 +8,7 @@ import {ContactForm} from "../openaireLibrary/utils/email/contact-form";
import {Composer} from "../openaireLibrary/utils/email/composer";
import {Title} from "@angular/platform-browser";
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'contact',
@ -36,8 +37,7 @@ export class ContactComponent implements OnInit {
@ViewChild('message') message;
@ViewChild('recaptcha') recaptcha;
constructor(private element: ElementRef,
private route: ActivatedRoute,
constructor(private route: ActivatedRoute,
private _router: Router,
private _emailService: EmailService,
private _title: Title,
@ -53,19 +53,13 @@ export class ContactComponent implements OnInit {
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect|Contact Us", this.properties.piwikSiteId).subscribe();
}
this.scroll();
HelperFunctions.scroll();
this.showLoading = false;
});
}
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
public send() {
this.scroll();
HelperFunctions.scroll();
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.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 {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {AppElementService} from "../appElementService.service";
declare var UIkit: any;
@ -277,8 +276,7 @@ export class CommunityCreationInstructionsComponent {
private route: ActivatedRoute,
private _router: Router,
private _title: Title,
private _piwikService:PiwikService,
private appElementsService: AppElementService) {
private _piwikService:PiwikService) {
var description = "OpenAIRE - Connect, Community Dashboard, research community";
var title = "OpenAIRE - Connect | Create and manage your community page";
@ -345,7 +343,7 @@ export class CommunityCreationInstructionsComponent {
*/
/*UIkit.util.on('#logo', 'beforehide', function () {
// do something
if(this.hide == false) {
if(this.hide =http://www.equp4.wf/= false) {
return false;
}
});*/

View File

@ -1,168 +1,173 @@
import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Component} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import{EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {Meta, Title} from '@angular/platform-browser';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo';
import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo';
import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class';
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'share-in-zenodo',
templateUrl: './shareInZenodo.component.html'
selector: 'share-in-zenodo',
templateUrl: './shareInZenodo.component.html'
})
export class ShareInZenodoComponent {
properties:EnvProperties;
private communityId: string = null;
private community:CommunityInfo = null;
properties: EnvProperties;
private communityId: string = null;
private community: CommunityInfo = null;
// public warningMessage = "";
// public infoMessage = "";
// public warningMessage = "";
// public infoMessage = "";
masterZenodoCommunityId = null;
masterZenodoCommunity = null;
masterZenodoCommunityId = null;
masterZenodoCommunity = null;
CommunityIds = null;
communities = [];
CommunityIds = null;
communities = [];
zenodocommunitiesloadedCount = 0;
zenodoSearchUtils:SearchUtilsClass = new SearchUtilsClass();
errorCodes: ErrorCodes = new ErrorCodes();;
depositLink = "https://zenodo.org/deposit/new?c=";
zenodocommunitiesloadedCount = 0;
zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass();
errorCodes: ErrorCodes = new ErrorCodes();
depositLink = "https://zenodo.org/deposit/new?c=";
constructor (private element: ElementRef, private route: ActivatedRoute, private _router: Router,
private _meta: Meta, private _title: Title, private _ΖenodoCommunitieService: ZenodoCommunitiesService,private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {}
constructor(private route: ActivatedRoute, private _router: Router,
private _meta: Meta, private _title: Title, private _ΖenodoCommunitieService: ZenodoCommunitiesService, private _communityService: CommunityService, private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
}
public ngOnInit() {
this.zenodoSearchUtils.status = this.errorCodes.LOADING;;
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
;
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.updateUrl(data.envSpecific.baseLink+this._router.url);
this.updateTitle("Share in Zenodo");
this.updateDescription("Zenodo, repository, deposit, share");
this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => {
this.communityId = params['communityId'];
if(!this.communityId){
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
}
this.updateUrl(data.envSpecific.baseLink + this._router.url);
this.updateTitle("Share in Zenodo");
this.updateDescription("Zenodo, repository, deposit, share");
this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => {
this.communityId = params['communityId'];
if (!this.communityId) {
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 (
community => {
this.community = community;
this.masterZenodoCommunityId = this.community.zenodoCommunity;
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
if(this.masterZenodoCommunityId){
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+this.masterZenodoCommunityId, null).subscribe(
result => {
this.masterZenodoCommunity = result;
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => {
this.community = community;
this.masterZenodoCommunityId = this.community.zenodoCommunity;
if (typeof document !== 'undefined') {
HelperFunctions.scroll();
}
if (this.masterZenodoCommunityId) {
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.masterZenodoCommunityId, null).subscribe(
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 => {
//console.error("Community couldn't be loaded");
this.handleError("Error getting community with id: "+this.communityId, error);
this.zenodoSearchUtils.status = this.errorCodes.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 => {
//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._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(
result => {
this.communities.push(result);
this.zenodocommunitiesloadedCount++;
if(this.zenodocommunitiesloadedCount >= this.CommunityIds.length){
this.zenodoSearchUtils.status = this.errorCodes.DONE;
}
getZenodoCommunityById(zenodoid, openaireId) {
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + zenodoid, openaireId).subscribe(
result => {
this.communities.push(result);
this.zenodocommunitiesloadedCount++;
if (this.zenodocommunitiesloadedCount >= this.CommunityIds.length) {
this.zenodoSearchUtils.status = this.errorCodes.DONE;
}
},
error => {
// var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo();
// emptyCommunity.id = zenodoid;
// emptyCommunity.openaireId = openaireId;
// emptyCommunity.title = zenodoid;
// this.communities.push(emptyCommunity);
this.zenodocommunitiesloadedCount++;
if(this.zenodocommunitiesloadedCount >= this.CommunityIds.length){
this.zenodoSearchUtils.status = this.errorCodes.DONE;
}
//console.error("Zenodo community'"+zenodoid+"' couldn't be loaded");
this.handleError("Error getting Zenodo community with id: "+zenodoid+" and openaire id: "+openaireId, error);
},
error => {
// var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo();
// emptyCommunity.id = zenodoid;
// emptyCommunity.openaireId = openaireId;
// emptyCommunity.title = zenodoid;
// this.communities.push(emptyCommunity);
this.zenodocommunitiesloadedCount++;
if (this.zenodocommunitiesloadedCount >= this.CommunityIds.length) {
this.zenodoSearchUtils.status = this.errorCodes.DONE;
}
//console.error("Zenodo community'"+zenodoid+"' couldn't be loaded");
this.handleError("Error getting Zenodo community with id: " + zenodoid + " and openaire id: " + openaireId, 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 {ErrorMessagesComponent} from "../../openaireLibrary/utils/errorMessages.component";
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 {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
import {Observable} from "rxjs";
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
import {catchError} from "rxjs/operators";
import {of} from "rxjs/observable/of";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'search-communities',
@ -51,7 +49,6 @@ export class SearchCommunitiesComponent {
constructor (private route: ActivatedRoute,
private _communitiesService: CommunitiesService,
private _subscribeService: SubscribeService,
private element: ElementRef,
private _piwikService: PiwikService) {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
@ -104,7 +101,6 @@ export class SearchCommunitiesComponent {
private initCommunities(params: Map<string, string>) {
this.subResults = this._communitiesService.getCommunitiesState().subscribe(
data => {
let observables: Observable<boolean>[] = [];
for(let i = 0; i < data.length; i++) {
this.totalResults[i] = data[i];
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].date = new Date(new Date(2012, 0, 1).getTime() + Math.random() * (new Date().getTime() - new Date(2012, 0, 1).getTime()));
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]);
}
}
if (observables.length > 0) {
Observable.forkJoin(observables).subscribe(
res => {
for (let i = 0; i < res.length; i++) {
this.totalResults[i].isSubscribed = res[i];
}
this._getResults(params);
if(Session.isLoggedIn()) {
this._subscribeService.getCommunitiesSubscribedTo(Session.getUserEmail(), this.properties["adminToolsAPIURL"]).subscribe(
res => {
for (let i = 0; i < this.totalResults.length; i++) {
this.totalResults[i].isSubscribed = (res.indexOf(this.totalResults[i].communityId) != -1);
}
this._getResults(params);
}
);
}
else {
@ -138,7 +130,7 @@ export class SearchCommunitiesComponent {
this.handleError('Error getting communities', err);
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
this.disableForms = false;
this.scroll();
HelperFunctions.scroll();
}
);
}
@ -217,7 +209,7 @@ export class SearchCommunitiesComponent {
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);
}
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 {SearchPageModule} from "../../openaireLibrary/searchPages/searchUtils/searchPage.module";
import {SearchFormModule} from "../../openaireLibrary/searchPages/searchUtils/searchForm.module";
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service";
import {SearchCommunitiesRoutingModule} from "./searchCommunities-routing.module";
import {PreviousRouteRecorder} from "../../openaireLibrary/utils/piwik/previousRouteRecorder.guard";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
@NgModule({
@ -19,7 +17,7 @@ import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
declarations: [
SearchCommunitiesComponent
],
providers:[ SubscribeService, PreviousRouteRecorder, PiwikService],
providers:[ PreviousRouteRecorder, PiwikService],
exports: [
SearchCommunitiesComponent
]

View File

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

View File

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