From 8d8b85ad6ba50dbf9790e9c48d1368b53671c54a Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 20 Dec 2017 15:59:15 +0000 Subject: [PATCH] Paging in search and advanced search pages limited to 20 (defined in OpenaireProperties file) | Csv and Html requests (currently on local machine rudie) changed - no size, no page parameters in requests | Limit for csv (defined in OpenaireProperties file) changed to 2000 git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@50185 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../htmlProjectReport.component.ts | 9 +- .../htmlProjectReport.service.ts | 4 +- .../organization/organization.component.html | 7 +- .../organization/organization.component.ts | 13 +- .../project/project.component.html | 4 +- .../landingPages/project/project.component.ts | 6 +- .../advancedSearchDataProviders.component.ts | 73 ++++++----- .../advancedSearchDatasets.component.ts | 109 ++++++++-------- .../advancedSearchOrganizations.component.ts | 31 +++-- .../advancedSearchProjects.component.ts | 115 +++++++++-------- .../advancedSearchPublications.component.ts | 113 +++++++++-------- .../advancedSearchSoftware.component.ts | 115 +++++++++-------- .../advancedSearchPage.component.html | 13 +- .../advancedSearchPage.component.ts | 8 ++ .../searchUtils/searchDownload.component.ts | 8 +- .../searchUtils/searchPage.component.html | 12 +- .../searchUtils/searchPage.component.ts | 7 ++ .../simple/searchDataproviders.component.ts | 25 ++-- .../simple/searchDatasets.component.ts | 25 ++-- .../simple/searchOrganizations.component.ts | 25 ++-- .../simple/searchProjects.component.ts | 26 ++-- .../simple/searchPublications.component.ts | 118 +++++++++--------- .../simple/searchSoftware.component.ts | 113 ++++++++--------- .../app/utils/pagingFormatter.component.ts | 14 ++- .../utils/properties/openaireProperties.ts | 18 ++- 25 files changed, 557 insertions(+), 454 deletions(-) diff --git a/portal-4cli/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts b/portal-4cli/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts index b08ccf15..eb641367 100644 --- a/portal-4cli/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts +++ b/portal-4cli/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts @@ -156,8 +156,13 @@ export class HtmlProjectReportComponent{ if (typeof window !== 'undefined') { this.subHTML = this.htmlService.getHTML(this.projectId, this.totalResults, this.resultsType).subscribe( data => { - let body: string = intro+'

'+this.header1+'

'+this.header2+'

'+data+''; - this.htmlResult = data; + //let body: string = intro+'

'+this.header1+'

'+this.header2+'

'+data+''; + let body: string = intro+'

'+this.header1+'

'+this.header2+'

'; + body += ""+data+"
TitleAuthorsPublication YearDOIPermanent IdentifierPublication typeJournalProject Name (GA Number)Access Mode
"; + body += ''; + + //this.htmlResult = data; + this.htmlResult = ""+data+"
TitleAuthorsPublication YearDOIPermanent IdentifierPublication typeJournalProject Name (GA Number)Access Mode
"; let clipboard; let Clipboard; diff --git a/portal-4cli/src/app/landingPages/htmlProjectReport/htmlProjectReport.service.ts b/portal-4cli/src/app/landingPages/htmlProjectReport/htmlProjectReport.service.ts index c044af95..c6c96a1f 100644 --- a/portal-4cli/src/app/landingPages/htmlProjectReport/htmlProjectReport.service.ts +++ b/portal-4cli/src/app/landingPages/htmlProjectReport/htmlProjectReport.service.ts @@ -27,7 +27,9 @@ export class HtmlProjectReportService { //let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json"; let url = OpenaireProperties.getCsvAPIURL(); - url += 'resources?format=html&page=0&size='+size+'&type='+requestType+'&query=(((oaftype exact result) and (resulttypeid exact '+resultTypeId+')) and (relprojectid exact "'+id+'"))'; + //url += 'resources?format=html&page=0&size='+size+'&type='+requestType+'&query=(((oaftype exact result) and (resulttypeid exact '+resultTypeId+')) and (relprojectid exact "'+id+'"))'; + url += '?format=html&type='+requestType+'&fq=(((oaftype exact result) and (resulttypeid exact '+resultTypeId+')) and (relprojectid exact "'+id+'"))'; + let key = url; return this.http.get(url) diff --git a/portal-4cli/src/app/landingPages/organization/organization.component.html b/portal-4cli/src/app/landingPages/organization/organization.component.html index 83ebdb03..055c7f9f 100644 --- a/portal-4cli/src/app/landingPages/organization/organization.component.html +++ b/portal-4cli/src/app/landingPages/organization/organization.component.html @@ -160,7 +160,7 @@ - + Project list for {{funder.name}} (CSV) @@ -175,7 +175,10 @@
  • - + + + + Publications of organization (CSV) - based on the affiliation information. diff --git a/portal-4cli/src/app/landingPages/organization/organization.component.ts b/portal-4cli/src/app/landingPages/organization/organization.component.ts index 1e02b02d..fa5ddf1c 100644 --- a/portal-4cli/src/app/landingPages/organization/organization.component.ts +++ b/portal-4cli/src/app/landingPages/organization/organization.component.ts @@ -131,7 +131,7 @@ export class OrganizationComponent { }); this.downloadURLAPI = OpenaireProperties.getCsvAPIURL(); - this.csvProjectParamsHead = 'format=csv&type=projects&page=0&query=( (oaftype exact project)and (funder exact "'; + this.csvProjectParamsHead = 'format=csv&type=projects&fq=( (oaftype exact project)and (funder exact "'; //this.csvPublicationParamsHead = 'format=csv-special&type=publications&page=0&query=((((oaftype exact result) and (resulttypeid exact publication)) and (funderid exact '; } @@ -328,13 +328,16 @@ export class OrganizationComponent { // let index: number = this.organizationInfo.projects.get(funder).indexOf(project); let url: string; - if(index == 0 || !title) { - url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special&size="+data; + if(!title) { + //url = this.downloadURLAPI+"projects/"+projects[index].id+"?type=publications&format=csv-special";//&size="+data; + url = this.downloadURLAPI+"?format=csv-special&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact '"+projects[index].id+"'))" + console.info(url); } else { - url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special-notitle&size="+data; + //url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special-notitle";//&size="+data; + url = this.downloadURLAPI+"?format=csv-special-notitle&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact '"+projects[index].id+"'))" } - if(data == 0) { // if no publications for this project + if(data == 0 && (counter > 1 || title)) { // if no publications for this project counter--; response[index] = ""; if(counter == 0) { diff --git a/portal-4cli/src/app/landingPages/project/project.component.html b/portal-4cli/src/app/landingPages/project/project.component.html index 43a4b467..f4c2188a 100644 --- a/portal-4cli/src/app/landingPages/project/project.component.html +++ b/portal-4cli/src/app/landingPages/project/project.component.html @@ -323,7 +323,7 @@
  • - + Get {{projectInfo.funder}} report (CSV)
  • @@ -356,7 +356,7 @@
  • - + Get {{projectInfo.funder}} report (CSV)
  • diff --git a/portal-4cli/src/app/landingPages/project/project.component.ts b/portal-4cli/src/app/landingPages/project/project.component.ts index 3e8f32d3..1674fb87 100644 --- a/portal-4cli/src/app/landingPages/project/project.component.ts +++ b/portal-4cli/src/app/landingPages/project/project.component.ts @@ -152,9 +152,9 @@ export class ProjectComponent{ this.downloadURLAPI = OpenaireProperties.getCsvAPIURL(); this.createClipboard(); - this.csvParams = "format=csv-special&page=0&type=publications&query=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact "+this.projectId+"))&size="; - this.csvParamsDatasets = "format=csv-special&page=0&type=datasets&query=(((oaftype exact result) and (resulttypeid exact dataset)) and (relprojectid exact "+this.projectId+"))&size="; - this.csvParamsSoftware = "format=csv-special&page=0&type=software&query=(((oaftype exact result) and (resulttypeid exact software)) and (relprojectid exact "+this.projectId+"))&size="; + this.csvParams = "?format=csv-special&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact "+this.projectId+"))"; + this.csvParamsDatasets = "?format=csv-special&type=datasets&fq=(((oaftype exact result) and (resulttypeid exact dataset)) and (relprojectid exact "+this.projectId+"))"; + this.csvParamsSoftware = "?format=csv-special&type=software&fq=(((oaftype exact result) and (resulttypeid exact software)) and (relprojectid exact "+this.projectId+"))"; if (typeof document !== 'undefined') { this.element.nativeElement.scrollIntoView(); diff --git a/portal-4cli/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts b/portal-4cli/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts index 85f620eb..7ecd345d 100644 --- a/portal-4cli/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts +++ b/portal-4cli/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts @@ -20,7 +20,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" [(searchUtils)] = "searchUtils" (queryChange)="queryChanged($event)" - [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/dataproviders" + [csvParams]="csvParams" csvPath="datasources" simpleSearchLink="/search/find/dataproviders" [disableForms]="disableForms" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults"> @@ -78,22 +78,26 @@ export class AdvancedSearchDataProvidersComponent { } sub: any; public getResults(parameters:string, page: number, size: number){ + if(page > OpenaireProperties.getPagingLimit()) { + size=0; + } + if(page <= OpenaireProperties.getPagingLimit() || this.searchUtils.status == this.errorCodes.LOADING) { if(parameters!= null && parameters != '' ) { - this.csvParams ="&type=datasources&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))"; }else{ - this.csvParams ="&type=datasources&query="+this.resourcesQuery; + this.csvParams ="&fq="+this.resourcesQuery; } - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + //this.searchPage.openLoading(); + this.disableForms = true; + this.results = []; + this.searchUtils.totalResults = 0; - console.info("Advanced Search for Content Providers: Execute search query "+parameters); - this._searchDataProvidersService.advancedSearchDataproviders(parameters, page, size).subscribe( - data => { + console.info("Advanced Search for Content Providers: Execute search query "+parameters); + this._searchDataProvidersService.advancedSearchDataproviders(parameters, page, size).subscribe( + data => { this.searchUtils.totalResults = data[0]; console.info("Adv Search Content Providers total="+this.searchUtils.totalResults); this.results = data[1]; @@ -117,32 +121,33 @@ export class AdvancedSearchDataProvidersComponent { this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } - }, - err => { - console.log(err); - console.info("error"); - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = errorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - } - ); + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.NOT_AVAILABLE; + if(err.status == '404') { + this.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.searchUtils.status = this.errorCodes.ERROR; + } else { + this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + //this.searchPage.closeLoading(); + this.disableForms = false; + } + ); + } } public queryChanged($event) { this.loadPaging = true; - + var parameters = $event.value; this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); diff --git a/portal-4cli/src/app/searchPages/advanced/advancedSearchDatasets.component.ts b/portal-4cli/src/app/searchPages/advanced/advancedSearchDatasets.component.ts index d5a41f05..468d9069 100644 --- a/portal-4cli/src/app/searchPages/advanced/advancedSearchDatasets.component.ts +++ b/portal-4cli/src/app/searchPages/advanced/advancedSearchDatasets.component.ts @@ -19,7 +19,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(searchUtils)] = "searchUtils" [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" - [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/datasets" + [csvParams]="csvParams" csvPath="datasets" simpleSearchLink="/search/find/datasets" [disableForms]="disableForms" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults"> @@ -82,67 +82,72 @@ export class AdvancedSearchDatasetsComponent { } sub: any; public getResults(parameters:string, page: number, size: number){ + if(page > OpenaireProperties.getPagingLimit()) { + size=0; + } + if(page <= OpenaireProperties.getPagingLimit() || this.searchUtils.status == this.errorCodes.LOADING) { if(parameters!= null && parameters != '' ) { - this.csvParams ="&type=datasets&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))"; }else{ - this.csvParams ="&type=datasets&query="+this.resourcesQuery; + this.csvParams ="&fq="+this.resourcesQuery; } - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + //this.searchPage.openLoading(); + this.disableForms = true; + this.results = []; + this.searchUtils.totalResults = 0; - console.info("Advanced Search for Research Data: Execute search query "+parameters); - this._searchDatasetsService.advancedSearchDatasets(parameters, page, size).subscribe( + console.info("Advanced Search for Research Data: Execute search query "+parameters); + this._searchDatasetsService.advancedSearchDatasets(parameters, page, size).subscribe( data => { - this.searchUtils.totalResults = data[0]; - console.info("search Research Data total="+this.searchUtils.totalResults); - this.results = data[1]; - this.searchPage.updateBaseUrlWithParameters(); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; + this.searchUtils.totalResults = data[0]; + console.info("search Research Data total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = this.errorCodes.NONE; + } + //this.searchPage.closeLoading(); + this.disableForms = false; - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } + if(this.searchUtils.status == this.errorCodes.DONE) { + // Page out of limit!!! + let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + if(totalPages < page) { + this.searchUtils.totalResults = 0; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; + } + } }, err => { - console.log(err); - console.info("error"); - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = errorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.NOT_AVAILABLE; + if(err.status == '404') { + this.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.searchUtils.status = this.errorCodes.ERROR; + } else { + this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; + } - //this.searchPage.closeLoading(); - this.disableForms = false; + //this.searchPage.closeLoading(); + this.disableForms = false; } - ); + ); + } } private setFilters(){ //TODO set filters from @@ -150,7 +155,7 @@ export class AdvancedSearchDatasetsComponent { public queryChanged($event) { this.loadPaging = true; - + var parameters = $event.value; this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); diff --git a/portal-4cli/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts b/portal-4cli/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts index dffde579..b3a42d1a 100644 --- a/portal-4cli/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts +++ b/portal-4cli/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts @@ -19,7 +19,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(searchUtils)] = "searchUtils" [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" - [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/organizations" + [csvParams]="csvParams" csvPath="organizations" simpleSearchLink="/search/find/organizations" [disableForms]="disableForms" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults"> @@ -82,21 +82,25 @@ public resourcesQuery = "(oaftype exact organization)"; } sub: any; public getResults(parameters:string, page: number, size: number){ + if(page > OpenaireProperties.getPagingLimit()) { + size=0; + } + if(page <= OpenaireProperties.getPagingLimit() || this.searchUtils.status == this.errorCodes.LOADING) { if(parameters!= null && parameters != '' ) { - this.csvParams ="&type=organizations&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))"; }else{ - this.csvParams ="&type=organizations&query="+this.resourcesQuery; + this.csvParams ="&fq="+this.resourcesQuery; } - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + //this.searchPage.openLoading(); + this.disableForms = true; + this.results = []; + this.searchUtils.totalResults = 0; - console.info("Advanced Search for Organizations: Execute search query "+parameters); - this._searchOrganizationsService.advancedSearchOrganizations(parameters, page, size).subscribe( + console.info("Advanced Search for Organizations: Execute search query "+parameters); + this._searchOrganizationsService.advancedSearchOrganizations(parameters, page, size).subscribe( data => { this.searchUtils.totalResults = data[0]; console.info("search Organizations total="+this.searchUtils.totalResults); @@ -142,7 +146,8 @@ public resourcesQuery = "(oaftype exact organization)"; //this.searchPage.closeLoading(); this.disableForms = false; } - ); + ); + } } private setFilters(){ //TODO set filters from @@ -150,7 +155,7 @@ public resourcesQuery = "(oaftype exact organization)"; public queryChanged($event) { this.loadPaging = true; - + var parameters = $event.value; this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); diff --git a/portal-4cli/src/app/searchPages/advanced/advancedSearchProjects.component.ts b/portal-4cli/src/app/searchPages/advanced/advancedSearchProjects.component.ts index bf1af211..355150e9 100644 --- a/portal-4cli/src/app/searchPages/advanced/advancedSearchProjects.component.ts +++ b/portal-4cli/src/app/searchPages/advanced/advancedSearchProjects.component.ts @@ -18,7 +18,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(searchUtils)] = "searchUtils" [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" - [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/projects" + [csvParams]="csvParams" csvPath="projects" simpleSearchLink="/search/find/projects" [disableForms]="disableForms" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults"> @@ -82,68 +82,73 @@ export class AdvancedSearchProjectsComponent { } sub: any; public getResults(parameters:string, page: number, size: number){ + if(page > OpenaireProperties.getPagingLimit()) { + size=0; + } + if(page <= OpenaireProperties.getPagingLimit() || this.searchUtils.status == this.errorCodes.LOADING) { if(parameters!= null && parameters != '' ) { - this.csvParams ="&type=projects&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))"; }else{ - this.csvParams ="&type=projects&query="+this.resourcesQuery; + this.csvParams ="&fq="+this.resourcesQuery; } - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + //this.searchPage.openLoading(); + this.disableForms = true; + this.results = []; + this.searchUtils.totalResults = 0; - console.info("Advanced Search for Publications: Execute search query "+parameters); - this._searchProjectsService.advancedSearchProjects(parameters, page, size).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - console.info("Advanced Search for Projects total="+this.searchUtils.totalResults); - this.results = data[1]; - this.searchPage.updateBaseUrlWithParameters(); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); + console.info("Advanced Search for Publications: Execute search query "+parameters); + this._searchProjectsService.advancedSearchProjects(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("Advanced Search for Projects total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = this.errorCodes.NONE; } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; + //this.searchPage.closeLoading(); + this.disableForms = false; + + if(this.searchUtils.status == this.errorCodes.DONE) { + // Page out of limit!!! + let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + if(totalPages < page) { + this.searchUtils.totalResults = 0; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; + } + } + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.NOT_AVAILABLE; + if(err.status == '404') { + this.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.searchUtils.status = this.errorCodes.ERROR; + } else { + this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; } - } - }, - err => { - console.log(err); - console.info("error"); - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = errorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; + //this.searchPage.closeLoading(); + this.disableForms = false; - } - ); + } + ); + } } private setFilters(){ //TODO set filters from @@ -151,7 +156,7 @@ export class AdvancedSearchProjectsComponent { public queryChanged($event) { this.loadPaging = true; - + var parameters = $event.value; this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); diff --git a/portal-4cli/src/app/searchPages/advanced/advancedSearchPublications.component.ts b/portal-4cli/src/app/searchPages/advanced/advancedSearchPublications.component.ts index 8f0cfa26..8682b6da 100644 --- a/portal-4cli/src/app/searchPages/advanced/advancedSearchPublications.component.ts +++ b/portal-4cli/src/app/searchPages/advanced/advancedSearchPublications.component.ts @@ -19,7 +19,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(searchUtils)] = "searchUtils" [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" - [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/publications" + [csvParams]="csvParams" csvPath="publications" simpleSearchLink="/search/find/publications" [disableForms]="disableForms" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults"> @@ -83,68 +83,73 @@ export class AdvancedSearchPublicationsComponent { } sub: any; public getResults(parameters:string, page: number, size: number){ + if(page > OpenaireProperties.getPagingLimit()) { + size=0; + } + if(page <= OpenaireProperties.getPagingLimit() || this.searchUtils.status == this.errorCodes.LOADING) { if(parameters!= null && parameters != '' ) { - this.csvParams ="&type=publications&query=("+this.resourcesQuery +" and (" + parameters + "))"; + this.csvParams ="&fq=("+this.resourcesQuery +" and (" + parameters + "))"; }else{ - this.csvParams ="&type=publications&query="+this.resourcesQuery; + this.csvParams ="&fq="+this.resourcesQuery; } - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + //this.searchPage.openLoading(); + this.disableForms = true; + this.results = []; + this.searchUtils.totalResults = 0; - console.info("Advanced Search for Publications: Execute search query "+parameters); - this._searchPublicationsService.advancedSearchPublications(parameters, page, size).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - console.info("searchPubl total="+this.searchUtils.totalResults); - this.results = data[1]; - this.searchPage.updateBaseUrlWithParameters(); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); + console.info("Advanced Search for Publications: Execute search query "+parameters); + this._searchPublicationsService.advancedSearchPublications(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("searchPubl total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = this.errorCodes.NONE; } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; + //this.searchPage.closeLoading(); + this.disableForms = false; + + if(this.searchUtils.status == this.errorCodes.DONE) { + // Page out of limit!!! + let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + if(totalPages < page) { + this.searchUtils.totalResults = 0; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; + } + } + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.NOT_AVAILABLE; + if(err.status == '404') { + this.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.searchUtils.status = this.errorCodes.ERROR; + } else { + this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; } - } - }, - err => { - console.log(err); - console.info("error"); - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; + //this.searchPage.closeLoading(); + this.disableForms = false; - } - ); + } + ); + } } public queryChanged($event) { diff --git a/portal-4cli/src/app/searchPages/advanced/advancedSearchSoftware.component.ts b/portal-4cli/src/app/searchPages/advanced/advancedSearchSoftware.component.ts index 73275cea..2444de15 100644 --- a/portal-4cli/src/app/searchPages/advanced/advancedSearchSoftware.component.ts +++ b/portal-4cli/src/app/searchPages/advanced/advancedSearchSoftware.component.ts @@ -19,7 +19,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(searchUtils)] = "searchUtils" [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" - [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/software" + [csvParams]="csvParams" csvPath="software" simpleSearchLink="/search/find/software" [disableForms]="disableForms" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults"> @@ -82,67 +82,72 @@ export class AdvancedSearchSoftwareComponent { } sub: any; public getResults(parameters:string, page: number, size: number){ + if(page > OpenaireProperties.getPagingLimit()) { + size=0; + } + if(page <= OpenaireProperties.getPagingLimit() || this.searchUtils.status == this.errorCodes.LOADING) { if(parameters!= null && parameters != '' ) { - this.csvParams ="&type=software&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))"; }else{ - this.csvParams ="&type=software&query="+this.resourcesQuery; + this.csvParams ="&fq="+this.resourcesQuery; } - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + //this.searchPage.openLoading(); + this.disableForms = true; + this.results = []; + this.searchUtils.totalResults = 0; - console.info("Advanced Search for Software: Execute search query "+parameters); - this._searchSoftwareService.advancedSearchSoftware(parameters, page, size).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - console.info("search Software total="+this.searchUtils.totalResults); - this.results = data[1]; - this.searchPage.updateBaseUrlWithParameters(); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); + console.info("Advanced Search for Software: Execute search query "+parameters); + this._searchSoftwareService.advancedSearchSoftware(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Software total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = this.errorCodes.NONE; } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - console.log(err); - console.info("error"); - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = errorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - } + //this.searchPage.closeLoading(); + this.disableForms = false; - //this.searchPage.closeLoading(); - this.disableForms = false; - } - ); + if(this.searchUtils.status == this.errorCodes.DONE) { + // Page out of limit!!! + let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + if(totalPages < page) { + this.searchUtils.totalResults = 0; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; + } + } + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.NOT_AVAILABLE; + if(err.status == '404') { + this.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.searchUtils.status = this.errorCodes.ERROR; + } else { + this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + + //this.searchPage.closeLoading(); + this.disableForms = false; + } + ); + } } private setFilters(){ //TODO set filters from diff --git a/portal-4cli/src/app/searchPages/searchUtils/advancedSearchPage.component.html b/portal-4cli/src/app/searchPages/searchUtils/advancedSearchPage.component.html index bea9e58f..1bc62d0d 100644 --- a/portal-4cli/src/app/searchPages/searchUtils/advancedSearchPage.component.html +++ b/portal-4cli/src/app/searchPages/searchUtils/advancedSearchPage.component.html @@ -27,15 +27,20 @@ - + -
    +
    + +
    +

    For more results please try a new, more specific query

    +
    +
    @@ -43,11 +48,11 @@
    -
    +
    - +
    diff --git a/portal-4cli/src/app/searchPages/searchUtils/advancedSearchPage.component.ts b/portal-4cli/src/app/searchPages/searchUtils/advancedSearchPage.component.ts index a668f7af..e3fc652b 100644 --- a/portal-4cli/src/app/searchPages/searchUtils/advancedSearchPage.component.ts +++ b/portal-4cli/src/app/searchPages/searchUtils/advancedSearchPage.component.ts @@ -40,11 +40,19 @@ export class AdvancedSearchPageComponent { public baseURLWithParameters:string = ''; + public csvLimit: number = 0; + public pagingLimit: number = 0; + public resultsPerPage: number = 0; + @Output() queryChange = new EventEmitter(); constructor (private location: Location, private _meta: Meta, private _piwikService:PiwikService, private router: Router) { } ngOnInit() { + this.csvLimit = OpenaireProperties.getCsvLimit(); + this.pagingLimit = OpenaireProperties.getPagingLimit(); + this.resultsPerPage = OpenaireProperties.getResultsPerPage(); + this.updateTitle("Advanced search "+this.pageTitle); this.updateDescription("Openaire, search, repositories, open access, type, content provider, funder, project, "+ this.pageTitle); if(typeof window !== 'undefined') { diff --git a/portal-4cli/src/app/searchPages/searchUtils/searchDownload.component.ts b/portal-4cli/src/app/searchPages/searchUtils/searchDownload.component.ts index 55df68d0..cbd96a8c 100644 --- a/portal-4cli/src/app/searchPages/searchUtils/searchDownload.component.ts +++ b/portal-4cli/src/app/searchPages/searchUtils/searchDownload.component.ts @@ -9,8 +9,9 @@ import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'search-download', template: ` - - + + + (CSV) @@ -31,6 +32,8 @@ export class SearchDownloadComponent { sub: any; downloadFilePiwikSub: any; + public csvLimit: number = 0; + @ViewChild (ModalLoading) loading : ModalLoading ; // Alert box when something is wrong with CSV requests @ViewChild('AlertModalCsvError') alertCsvError; @@ -38,6 +41,7 @@ export class SearchDownloadComponent { constructor ( private _reportsService: ReportsService, private _piwikService:PiwikService) {} ngOnInit() { + this.csvLimit = OpenaireProperties.getCsvLimit(); this.downloadURLAPI = OpenaireProperties.getCsvAPIURL(); } diff --git a/portal-4cli/src/app/searchPages/searchUtils/searchPage.component.html b/portal-4cli/src/app/searchPages/searchUtils/searchPage.component.html index 029d3709..fda911c5 100644 --- a/portal-4cli/src/app/searchPages/searchUtils/searchPage.component.html +++ b/portal-4cli/src/app/searchPages/searchUtils/searchPage.component.html @@ -72,7 +72,7 @@
    -
    + -
    +
    +
    +

    For more results please try a new, more specific query

    +
    +
    @@ -100,7 +104,7 @@
    -