search/find: do not query for results if count returns 0

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@48517 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2017-07-10 15:59:09 +00:00
parent 8d80576fc1
commit 30e3abed04
2 changed files with 51 additions and 21 deletions

View File

@ -336,42 +336,52 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
}
public searchPublications() {
this.activeTab = "publications";
if(this.reloadPublications) {
this.reloadPublications = false;
this.fetchPublications.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications();// + "?keyword=" + this.keyword;
if( this.reloadPublications &&
this.fetchPublications.searchUtils.status != this.errorCodes.NONE &&
this.fetchPublications.searchUtils.status != this.errorCodes.ERROR) {
this.reloadPublications = false;
this.fetchPublications.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications();// + "?keyword=" + this.keyword;
}
}
public searchDatasets() {
this.activeTab = "datasets";
if(this.reloadDatasets) {
this.reloadDatasets = false;
this.fetchDatasets.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets();// + "?keyword=" + this.keyword;
if(this.reloadDatasets &&
this.fetchDatasets.searchUtils.status != this.errorCodes.NONE &&
this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR) {
this.reloadDatasets = false;
this.fetchDatasets.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets();// + "?keyword=" + this.keyword;
}
}
public searchProjects() {
this.activeTab = "projects";
if(this.reloadProjects) {
this.reloadProjects = false;
this.fetchProjects.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchProjects = OpenaireProperties.getLinkToSearchProjects();// + "?keyword=" + this.keyword;
if(this.reloadProjects &&
this.fetchProjects.searchUtils.status != this.errorCodes.NONE &&
this.fetchProjects.searchUtils.status != this.errorCodes.ERROR) {
this.reloadProjects = false;
this.fetchProjects.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchProjects = OpenaireProperties.getLinkToSearchProjects();// + "?keyword=" + this.keyword;
}
}
public searchDataProviders() {
this.activeTab = "dataproviders";
if(this.reloadDataproviders) {
this.reloadDataproviders = false;
this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();// + "?keyword=" + this.keyword;
if( this.reloadDataproviders &&
this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE &&
this.fetchDataproviders.searchUtils.status != this.errorCodes.ERROR) {
this.reloadDataproviders = false;
this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();// + "?keyword=" + this.keyword;
}
}
public searchOrganizations() {
this.activeTab = "organizations";
if(this.reloadOrganizations) {
this.reloadOrganizations = false;
this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations();// + "?keyword=" + this.keyword;
if( this.reloadOrganizations &&
this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE &&
this.fetchOrganizations.searchUtils.status != this.errorCodes.ERROR) {
this.reloadOrganizations = false;
this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10);
this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations();// + "?keyword=" + this.keyword;
}
}
@ -404,11 +414,15 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
private count() {
if(this.activeTab != "publications"){
this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
this.fetchPublications.results = [];
this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword).subscribe(
data => {
console.log("Count results: "+data);
this.fetchPublications.searchUtils.totalResults = data;
this.fetchPublications.searchUtils.status = this.errorCodes.DONE;
if(this.fetchPublications.searchUtils.totalResults == 0) {
this.fetchPublications.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
@ -418,10 +432,14 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
}
if(this.activeTab != "datasets"){
this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
this.fetchDatasets.results = [];
this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword).subscribe(
data => {
this.fetchDatasets.searchUtils.totalResults = data;
this.fetchDatasets.searchUtils.status = this.errorCodes.DONE;
if(this.fetchDatasets.searchUtils.totalResults == 0) {
this.fetchDatasets.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
@ -431,10 +449,14 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
}
if(this.activeTab != "projects"){
this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
this.fetchProjects.results = [];
this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword).subscribe(
data => {
this.fetchProjects.searchUtils.totalResults = data;
this.fetchProjects.searchUtils.status = this.errorCodes.DONE;
if(this.fetchProjects.searchUtils.totalResults == 0) {
this.fetchProjects.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
@ -443,15 +465,19 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
);
}
if(this.activeTab != "dataproviders"){
this.fetchDataproviders.results = [];
this.fetchDataproviders.getNumForSearch(this.keyword);
}
if(this.activeTab != "organizations"){
this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
this.fetchOrganizations.results = [];
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword).subscribe(
data => {
this.fetchOrganizations.searchUtils.totalResults = data;
this.fetchOrganizations.searchUtils.status = this.errorCodes.DONE;
if(this.fetchOrganizations.searchUtils.totalResults == 0) {
this.fetchOrganizations.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);

View File

@ -100,6 +100,10 @@ export class FetchDataproviders {
data => {
this.searchUtils.totalResults = data;
this.searchUtils.status = errorCodes.DONE;
if(this.searchUtils.totalResults == 0) {
this.searchUtils.status = errorCodes.NONE;
}
},
err => {
console.log(err);