2018-04-11 13:24:57 +02:00
|
|
|
import {Component, Input, Output} from '@angular/core';
|
|
|
|
import {EventEmitter, ViewChild} from '@angular/core';
|
|
|
|
import {ChangeDetectionStrategy} from '@angular/core';
|
|
|
|
import {ViewEncapsulation} from '@angular/core';
|
2018-03-12 17:34:48 +01:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Location} from '@angular/common';
|
2018-04-11 13:24:57 +02:00
|
|
|
import {Title, Meta} from '@angular/platform-browser';
|
|
|
|
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
import "rxjs/add/observable/zip";
|
2018-04-11 13:24:57 +02:00
|
|
|
|
|
|
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
|
|
|
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
2018-03-06 14:54:17 +01:00
|
|
|
|
2018-03-12 17:34:48 +01:00
|
|
|
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';
|
2018-04-11 13:24:57 +02:00
|
|
|
|
|
|
|
|
2018-04-11 12:40:29 +02:00
|
|
|
import {PiwikHelper} from '../utils/piwikHelper';
|
2018-01-26 16:00:07 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'community',
|
|
|
|
templateUrl: 'community.component.html',
|
|
|
|
})
|
2018-03-12 17:34:48 +01:00
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
export class CommunityComponent {
|
2018-10-16 14:52:51 +02:00
|
|
|
public sub: any;
|
2018-01-26 16:00:07 +01:00
|
|
|
public piwiksub: any;
|
|
|
|
public subfunders: any;
|
|
|
|
|
2018-02-20 12:13:44 +01:00
|
|
|
public publicationTotal = null;
|
|
|
|
public researchDataTotal = null;
|
|
|
|
public softwareTotal = null;
|
2018-07-27 16:45:08 +02:00
|
|
|
public orpTotal = null;
|
2018-02-28 17:44:33 +01:00
|
|
|
public projectTotal = null;
|
|
|
|
public contentProviderTotal = null;
|
|
|
|
public organizationTotal = null;
|
2018-02-20 12:13:44 +01:00
|
|
|
|
2018-02-28 15:15:00 +01:00
|
|
|
params: any;
|
2018-02-12 12:41:40 +01:00
|
|
|
properties:EnvProperties;
|
2018-02-02 13:02:04 +01:00
|
|
|
|
2018-02-20 12:13:44 +01:00
|
|
|
public publicationResults = null;
|
|
|
|
public researchDataResults = null;
|
|
|
|
public softwareResults = null;
|
2018-07-27 16:45:08 +02:00
|
|
|
public orpResults = null;
|
2018-01-26 16:00:07 +01:00
|
|
|
|
2018-03-22 16:38:42 +01:00
|
|
|
@Input() communityId = null;
|
2018-02-28 14:10:11 +01:00
|
|
|
public community = null;
|
2018-02-27 16:03:40 +01:00
|
|
|
|
2018-04-18 12:31:33 +02:00
|
|
|
public communityInfo = null;
|
|
|
|
|
2018-10-16 17:00:13 +02:00
|
|
|
public showLoading: boolean = true;
|
|
|
|
|
2018-10-16 14:52:51 +02:00
|
|
|
// TODO Unsubscribe
|
|
|
|
public subPublications;
|
|
|
|
public subResearchData;
|
|
|
|
public subSoftware;
|
|
|
|
public subOrps;
|
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
constructor (
|
2018-03-12 17:34:48 +01:00
|
|
|
private route: ActivatedRoute,
|
2018-01-26 16:00:07 +01:00
|
|
|
private _router: Router,
|
2018-04-17 15:37:38 +02:00
|
|
|
private location: Location,
|
|
|
|
private _meta: Meta,
|
|
|
|
private _title: Title,
|
2018-03-06 14:54:17 +01:00
|
|
|
private _piwikService:PiwikService,
|
2018-01-29 15:31:10 +01:00
|
|
|
private config: ConfigurationService,
|
2018-03-06 14:54:17 +01:00
|
|
|
private _communityService:CommunityService,
|
2018-03-12 17:34:48 +01:00
|
|
|
private _searchEntriesService:SearchEntriesService) {
|
|
|
|
|
2018-10-24 11:15:13 +02:00
|
|
|
var description = "OpenAIRE - Connect, Community Dashboard, research community";
|
|
|
|
var title = "OpenAIRE - Connect";
|
2018-04-02 10:48:06 +02:00
|
|
|
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);
|
2018-01-26 16:00:07 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
2018-02-12 12:41:40 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
2018-04-17 15:37:38 +02:00
|
|
|
this.properties = data.envSpecific;
|
|
|
|
var url = data.envSpecific.baseLink+this._router.url;
|
2018-04-02 10:48:06 +02:00
|
|
|
this._meta.updateTag({content:url},"property='og:url'");
|
2018-04-11 12:40:29 +02:00
|
|
|
|
2018-02-12 12:41:40 +01:00
|
|
|
|
2018-03-22 16:38:42 +01:00
|
|
|
// this.route.queryParams.subscribe(
|
|
|
|
// communityId => {
|
|
|
|
// this.communityId = communityId['communityId'];
|
|
|
|
// if(!this.communityId){
|
|
|
|
// this.communityId = this.route.snapshot.paramMap.get('id');
|
|
|
|
// }
|
|
|
|
// });
|
2018-03-12 17:34:48 +01:00
|
|
|
|
2018-03-16 11:46:34 +01:00
|
|
|
if (this.communityId != null && this.communityId != '') {
|
2018-04-04 16:02:53 +02:00
|
|
|
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
|
2018-03-15 17:14:49 +01:00
|
|
|
community => {
|
2018-07-27 16:45:08 +02:00
|
|
|
this.community = community;
|
|
|
|
this.params = {communityId: community.communityId};
|
2018-04-02 10:48:06 +02:00
|
|
|
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);
|
2018-04-11 12:40:29 +02:00
|
|
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
|
|
|
this.piwiksub = this._piwikService.trackView(this.properties, community.title,PiwikHelper.siteIDs[this.communityId]).subscribe();
|
|
|
|
}
|
2018-04-02 10:48:06 +02:00
|
|
|
|
2018-03-15 17:14:49 +01:00
|
|
|
//console.log(community);
|
|
|
|
});
|
|
|
|
|
|
|
|
// this._communityService.getCommunity('https://dev-openaire.d4science.org/openaire/community/'+this.communityId).subscribe (
|
|
|
|
// community => {
|
|
|
|
// this.community = community;
|
|
|
|
// this.params = {community: encodeURIComponent('"'+community.queryId+'"')};
|
|
|
|
// //console.log(community);
|
|
|
|
// });
|
|
|
|
|
|
|
|
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'publications/count?format=json&fq=communityid='+this.communityId).subscribe(
|
|
|
|
publicationTotal => {
|
|
|
|
this.publicationTotal = publicationTotal;
|
2018-10-16 17:00:13 +02:00
|
|
|
this.showLoading = true;
|
2018-10-16 14:52:51 +02:00
|
|
|
this.searchPublications();
|
2018-03-15 17:14:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'datasets/count?format=json&fq=communityid='+this.communityId).subscribe(
|
|
|
|
researchDataTotal => {
|
|
|
|
this.researchDataTotal = researchDataTotal;
|
|
|
|
});
|
|
|
|
|
|
|
|
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'software/count?format=json&fq=communityid='+this.communityId).subscribe(
|
|
|
|
softwareTotal => {
|
|
|
|
this.softwareTotal = softwareTotal;
|
|
|
|
});
|
|
|
|
|
2018-07-27 16:45:08 +02:00
|
|
|
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'other/count?format=json&fq=communityid='+this.communityId).subscribe(
|
|
|
|
orpTotal => {
|
|
|
|
this.orpTotal = orpTotal;
|
|
|
|
});
|
|
|
|
|
2018-03-15 17:14:49 +01:00
|
|
|
this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/projects').subscribe(
|
|
|
|
projectTotal => {
|
|
|
|
this.projectTotal = projectTotal;
|
|
|
|
//console.log(projectTotal);
|
|
|
|
});
|
|
|
|
|
|
|
|
this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/contentproviders').subscribe(
|
|
|
|
contentProviderTotal => {
|
|
|
|
this.contentProviderTotal = contentProviderTotal;
|
|
|
|
//console.log(contentProviderTotal);
|
|
|
|
});
|
|
|
|
|
|
|
|
// this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
|
|
|
|
// organizationTotal => {
|
|
|
|
// this.organizationTotal = organizationTotal;
|
|
|
|
// console.log(organizationTotal);
|
|
|
|
// });
|
|
|
|
|
2018-04-18 12:31:33 +02:00
|
|
|
|
|
|
|
/**/
|
|
|
|
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe(
|
|
|
|
res => {
|
|
|
|
this.communityInfo = res;
|
|
|
|
},
|
|
|
|
error => console.log(error)
|
|
|
|
);
|
2018-03-15 17:14:49 +01:00
|
|
|
}
|
2018-02-12 12:41:40 +01:00
|
|
|
});
|
2018-01-26 16:00:07 +01:00
|
|
|
}
|
2018-02-27 12:37:18 +01:00
|
|
|
|
2018-10-16 14:52:51 +02:00
|
|
|
public searchPublications() {
|
|
|
|
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(
|
|
|
|
publicationResults => {
|
|
|
|
this.publicationResults = publicationResults;
|
2018-10-16 17:00:13 +02:00
|
|
|
this.showLoading = false;
|
2018-10-16 14:52:51 +02:00
|
|
|
//console.log(publicationResults);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchResearchData() {
|
|
|
|
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(
|
|
|
|
researchDataResults => {
|
|
|
|
this.researchDataResults = researchDataResults;
|
2018-10-16 17:00:13 +02:00
|
|
|
this.showLoading = false;
|
2018-10-16 14:52:51 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchSoftware() {
|
|
|
|
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(
|
|
|
|
softwareResults => {
|
|
|
|
this.softwareResults = softwareResults;
|
2018-10-16 17:00:13 +02:00
|
|
|
this.showLoading = false;
|
2018-10-16 14:52:51 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchOrps() {
|
|
|
|
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(
|
|
|
|
orpResults => {
|
|
|
|
this.orpResults = orpResults;
|
2018-10-16 17:00:13 +02:00
|
|
|
this.showLoading = false;
|
2018-10-16 14:52:51 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-26 16:00:07 +01:00
|
|
|
public ngOnDestroy() {
|
|
|
|
if(this.piwiksub){
|
|
|
|
this.piwiksub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
2018-04-18 12:31:33 +02:00
|
|
|
|
|
|
|
IsEntityEnabled(entity: string) {
|
|
|
|
return this.communityInfo.entities.some(x => x['pid'] == entity && x['isEnabled']===true);
|
|
|
|
}
|
2018-01-26 16:00:07 +01:00
|
|
|
}
|