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

View File

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