diff --git a/src/app/community/community.component.html b/src/app/community/community.component.html
index af9bce8..f853f33 100644
--- a/src/app/community/community.component.html
+++ b/src/app/community/community.component.html
@@ -151,9 +151,9 @@
diff --git a/src/app/community/community.component.ts b/src/app/community/community.component.ts
index bde3c4e..89c7f7e 100644
--- a/src/app/community/community.component.ts
+++ b/src/app/community/community.component.ts
@@ -26,6 +26,7 @@ import {PiwikHelper} from '../utils/piwikHelper';
})
export class CommunityComponent {
+ public sub: any;
public piwiksub: any;
public subfunders: any;
@@ -52,6 +53,12 @@ export class CommunityComponent {
public communityInfo = null;
+ // TODO Unsubscribe
+ public subPublications;
+ public subResearchData;
+ public subSoftware;
+ public subOrps;
+
constructor (
private route: ActivatedRoute,
private _router: Router,
@@ -114,46 +121,22 @@ export class CommunityComponent {
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'publications/count?format=json&fq=communityid='+this.communityId).subscribe(
publicationTotal => {
this.publicationTotal = publicationTotal;
- if (this.publicationTotal > 0) {
- 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;
- //console.log(publicationResults);
- });
- }
+ this.searchPublications();
});
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'datasets/count?format=json&fq=communityid='+this.communityId).subscribe(
researchDataTotal => {
this.researchDataTotal = researchDataTotal;
- if (this.researchDataTotal > 0) {
- 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._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'software/count?format=json&fq=communityid='+this.communityId).subscribe(
softwareTotal => {
this.softwareTotal = softwareTotal;
- if (this.softwareTotal > 0) {
- 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._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'other/count?format=json&fq=communityid='+this.communityId).subscribe(
orpTotal => {
this.orpTotal = orpTotal;
- if (this.orpTotal > 0) {
- 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._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/projects').subscribe(
@@ -186,6 +169,43 @@ export class CommunityComponent {
});
}
+ 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;
+ //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;
+ });
+ }
+ }
+
+ 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;
+ });
+ }
+ }
+
+ 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;
+ });
+ }
+ }
+
public ngOnDestroy() {
if(this.piwiksub){
this.piwiksub.unsubscribe();