[Trunk | Connect]: community.component & results.component: Merge methods for research results (since they are now merged in one common service & component).
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@57085 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
bec026f9f3
commit
86820efde1
|
@ -348,11 +348,11 @@
|
|||
|
||||
<ul class="uk-margin-remove uk-flex-center"
|
||||
data-uk-tab="{connect: '#resultTabs'">
|
||||
<li *ngIf="isEntityEnabled('publication')" (click)="searchPublications()" class="uk-active"><a
|
||||
<li *ngIf="isEntityEnabled('publication')" (click)="searchResearchResults('publication', publicationTotal, publicationResults)" class="uk-active"><a
|
||||
href="#">publications</a></li>
|
||||
<li *ngIf="isEntityEnabled('dataset')" (click)="searchResearchData()"><a href="#">research data</a></li>
|
||||
<li *ngIf="isEntityEnabled('software')" (click)="searchSoftware()"><a href="#">software</a></li>
|
||||
<li *ngIf="isEntityEnabled('orp')" (click)="searchOrps()"><a href="#">other research products</a></li>
|
||||
<li *ngIf="isEntityEnabled('dataset')" (click)="searchResearchResults('dataset', researchDataTotal, researchDataResults)"><a href="#">research data</a></li>
|
||||
<li *ngIf="isEntityEnabled('software')" (click)="searchResearchResults('software', softwareTotal, softwareResults)"><a href="#">software</a></li>
|
||||
<li *ngIf="isEntityEnabled('orp')" (click)="searchResearchResults('other', orpTotal, orpResults)"><a href="#">other research products</a></li>
|
||||
</ul>
|
||||
|
||||
<ul id="resultTabs" class=" communityBorder customTabsContent uk-switcher " style="min-height:450px;">
|
||||
|
|
|
@ -176,63 +176,29 @@ export class CommunityComponent {
|
|||
//console.log(community);
|
||||
});
|
||||
|
||||
this.countResearchResults("publication");
|
||||
this.countResearchResults("dataset");
|
||||
this.countResearchResults("software");
|
||||
this.countResearchResults("other");
|
||||
|
||||
this._searchResearchResultsService.countTotalResults("publication", this.properties,"&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._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId ).subscribe(
|
||||
projectTotal => {
|
||||
this.projectTotal = projectTotal;
|
||||
//console.log(projectTotal);
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
|
||||
}
|
||||
);
|
||||
|
||||
this._searchResearchResultsService.countTotalResults("dataset", this.properties,"&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._searchResearchResultsService.countTotalResults("software", this.properties,"&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._searchResearchResultsService.countTotalResults("other", this.properties,"&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._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId ).subscribe(
|
||||
projectTotal => {
|
||||
this.projectTotal = projectTotal;
|
||||
//console.log(projectTotal);
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
|
||||
}
|
||||
);
|
||||
|
||||
this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId ).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._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId ).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(
|
||||
|
@ -256,64 +222,33 @@ export class CommunityComponent {
|
|||
});
|
||||
}
|
||||
|
||||
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')
|
||||
this._searchResearchResultsService.search("publication","","&fq=communityid=" + this.communityId,1,5,"resultdateofacceptance,descending",[],this.properties)
|
||||
.subscribe(
|
||||
publicationResults => {
|
||||
this.publicationResults = publicationResults[1];
|
||||
this.showLoading = false;
|
||||
//console.log(publicationResults);
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting publications for community with id: " + this.communityId, error);
|
||||
public countResearchResults(resultType: string) {
|
||||
this._searchResearchResultsService.countTotalResults(resultType, this.properties,"&fq=communityid=" + this.communityId).subscribe(
|
||||
researchResultsTotal => {
|
||||
this.setTotal(resultType, researchResultsTotal);
|
||||
if(resultType == "publication") {
|
||||
this.searchResearchResults(resultType, this.publicationTotal, this.publicationResults);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting number of "+this.getEntityName(resultType, true, true)+" for community with id: " + this.communityId, error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public searchResearchData() {
|
||||
this.activeTab = "dataset";
|
||||
if (this.researchDataTotal > 0 && this.researchDataResults == null) {
|
||||
this._searchResearchResultsService.search("dataset","","&fq=communityid=" + this.communityId,1,5,"resultdateofacceptance,descending",[],this.properties).subscribe(
|
||||
researchDataResults => {
|
||||
this.researchDataResults = researchDataResults[1];
|
||||
public searchResearchResults(resultType: string, resultsTotal: number, results: Array<any>) {
|
||||
this.setActiveTab(resultType);
|
||||
|
||||
if (resultsTotal > 0 && results == null) {
|
||||
this.showLoading = true;
|
||||
|
||||
this._searchResearchResultsService.search(resultType, "", "&fq=communityid=" + this.communityId, 1, 5, "resultdateofacceptance,descending", [], this.properties).subscribe(
|
||||
researchResults => {
|
||||
this.setResults(resultType, researchResults[1]);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting research data for community with id: " + this.communityId, error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public searchSoftware() {
|
||||
this.activeTab = "software";
|
||||
if (this.softwareTotal > 0 && this.softwareResults == null) {
|
||||
this._searchResearchResultsService.search("software","","&fq=communityid=" + this.communityId,1,5,"resultdateofacceptance,descending",[],this.properties).subscribe(
|
||||
softwareResults => {
|
||||
this.softwareResults = softwareResults[1];
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting software for community with id: " + this.communityId, error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public searchOrps() {
|
||||
this.activeTab = "orp";
|
||||
if (this.orpTotal > 0 && this.orpResults == null) {
|
||||
this._searchResearchResultsService.search("other","","&fq=communityid=" + this.communityId,1,5,"resultdateofacceptance,descending",[],this.properties).subscribe(
|
||||
orpResults => {
|
||||
this.orpResults = orpResults[1];
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting other research products for community with id: " + this.communityId, error);
|
||||
this.handleError("Error getting "+this.getEntityName(resultType, true, true)+" for community with id: " + this.communityId, error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -386,4 +321,47 @@ export class CommunityComponent {
|
|||
return StringUtils.quote(StringUtils.URIEncode(param));
|
||||
}
|
||||
|
||||
private setActiveTab(entityType: string) {
|
||||
if(entityType == "other") {
|
||||
this.activeTab = "orp";
|
||||
} else {
|
||||
this.activeTab = entityType;
|
||||
}
|
||||
}
|
||||
|
||||
private setResults(entityType: string, results: Array<any>) {
|
||||
if(entityType == "publication") {
|
||||
this.publicationResults = results;
|
||||
} else if(entityType == "dataset") {
|
||||
this.researchDataResults = results;
|
||||
} else if(entityType == "software") {
|
||||
this.softwareResults = results;
|
||||
} else if(entityType == "other") {
|
||||
this.orpResults = results;
|
||||
}
|
||||
}
|
||||
|
||||
private setTotal(entityType: string, total: number) {
|
||||
if(entityType == "publication") {
|
||||
this.publicationTotal = total;
|
||||
} else if(entityType == "dataset") {
|
||||
this.researchDataTotal = total;
|
||||
} else if(entityType == "software") {
|
||||
this.softwareTotal = total;
|
||||
} else if(entityType == "other") {
|
||||
this.orpTotal = total;
|
||||
}
|
||||
}
|
||||
|
||||
private getEntityName (entityType:string, plural:boolean, full:boolean): string {
|
||||
if(entityType == "publication") {
|
||||
return "publication" + (plural ? "s" : "");
|
||||
} else if(entityType == "dataset") {
|
||||
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
|
||||
} else if(entityType == "software") {
|
||||
return "software";
|
||||
} else if(entityType == "other") {
|
||||
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import {SearchResult} from "../../openaireLibrary/utils/entities/searchResult";
|
|||
template: `
|
||||
<div class="uk-h5 uk-text-bold uk-margin-top uk-margin-remove-bottom">Recent research results</div>
|
||||
<div *ngIf="!results && total != 0">
|
||||
<div *ngIf="!showLoading" class="uk-animation-fade uk-width-1-1" role="alert"><span class="loading-gif uk-align-center"></span></div>
|
||||
<div *ngIf="showLoading" class="uk-animation-fade uk-width-1-1" role="alert"><span class="loading-gif uk-align-center"></span></div>
|
||||
</div>
|
||||
<div *ngIf="results != null && results.length > 0">
|
||||
<div class="uk-text-right">
|
||||
|
|
Loading…
Reference in New Issue