From 206bc1e73b2c1e8e1e285c6a2b17909384d7db9e Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Mon, 21 Nov 2016 13:21:31 +0000 Subject: [PATCH] correcting bug with paging in search pages + advanced pages, use SearchUtilsClass, show paging in advanced, correcting issue with paging base url in advanced git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44587 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../advancedSearchDataProviders.component.ts | 34 +++++----- .../advancedSearchDatasets.component.ts | 33 ++++----- .../advancedSearchOrganizations.component.ts | 33 ++++----- .../advancedSearchPeople.component.ts | 33 ++++----- .../advancedSearchProjects.component.ts | 34 +++++----- .../advancedSearchPublications.component.ts | 30 ++++----- .../compatibleDataProviders.component.ts | 28 ++++---- .../entityRegistries.component.ts | 29 ++++---- .../searchDataproviders.component.ts | 67 +++++++++---------- .../searchPages/searchDatasets.component.ts | 50 +++++++------- .../searchOrganizations.component.ts | 31 +++++---- .../app/searchPages/searchPeople.component.ts | 43 ++++++------ .../searchPages/searchProjects.component.ts | 32 ++++----- .../searchPublications.component.ts | 46 ++++++------- .../advancedSearchPage.component.ts | 25 ++++--- .../searchUtils/searchPage.component.ts | 45 ++++++------- .../searchUtils/searchUtils.class.ts | 7 ++ 17 files changed, 300 insertions(+), 300 deletions(-) create mode 100644 portal-2/src/app/searchPages/searchUtils/searchUtils.class.ts diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts index 5b5c0181..96bcbd30 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts @@ -7,6 +7,7 @@ import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @@ -14,10 +15,9 @@ import {SearchFields} from '../../utils/properties/searchFields'; selector: 'advanced-search-dataprovider', template: ` @@ -28,9 +28,11 @@ export class AdvancedSearchDataProvidersComponent { private results =[]; private filters =[]; private totalResults:number = 0 ; - private page :number = 1; - private size :number = 10; - public status:number; + // private page :number = 1; + // private size :number = 10; + // public status:number; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private baseUrl: string; private searchFields:SearchFields = new SearchFields(); @@ -45,7 +47,7 @@ export class AdvancedSearchDataProvidersComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); @@ -53,15 +55,15 @@ export class AdvancedSearchDataProvidersComponent { } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; - this.page = ( page <= 0 ) ? 1 : page; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; this.searchPage.selectedFields = this.selectedFields; this.searchPage.fieldIdsMap = this.fieldIdsMap; this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.page, this.size); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); }); } @@ -71,7 +73,7 @@ export class AdvancedSearchDataProvidersComponent { sub: any; public getResults(parameters:string, page: number, size: number){ var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.LOADING; + this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Publications: Execute search query "+parameters); this._searchDataProvidersService.searchDataproviders(parameters, null, page, size, []).subscribe( data => { @@ -80,9 +82,9 @@ export class AdvancedSearchDataProvidersComponent { this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { @@ -90,10 +92,10 @@ export class AdvancedSearchDataProvidersComponent { console.info("error"); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = errorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.NOT_AVAILABLE; + this.searchUtils.status = errorCodes.NOT_AVAILABLE; } ); } @@ -103,7 +105,7 @@ export class AdvancedSearchDataProvidersComponent { private queryChanged($event) { var parameters = $event.value; - this.getResults(parameters, this.page,this.size); + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); } diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts index 77a17f4e..ec5027a8 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts @@ -7,7 +7,7 @@ import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields} from '../../utils/properties/searchFields'; - +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @Component({ @@ -15,9 +15,8 @@ import {SearchFields} from '../../utils/properties/searchFields'; template: ` @@ -28,9 +27,11 @@ export class AdvancedSearchDatasetsComponent { private results =[]; private filters =[]; private totalResults:number = 0 ; - private page :number = 1; - private size :number = 10; - public status:number; + // private page :number = 1; + // private size :number = 10; + // public status:number; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private baseUrl: string; private searchFields:SearchFields = new SearchFields(); @@ -45,7 +46,7 @@ export class AdvancedSearchDatasetsComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); @@ -53,15 +54,15 @@ export class AdvancedSearchDatasetsComponent { } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; - this.page = ( page <= 0 ) ? 1 : page; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; this.searchPage.selectedFields = this.selectedFields; this.searchPage.fieldIdsMap = this.fieldIdsMap; this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.page, this.size); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); }); } @@ -71,7 +72,7 @@ export class AdvancedSearchDatasetsComponent { sub: any; public getResults(parameters:string, page: number, size: number){ var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.LOADING; + this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Datasets: Execute search query "+parameters); this._searchDatasetsService.searchDatasets(parameters, null, page, size, []).subscribe( data => { @@ -80,9 +81,9 @@ export class AdvancedSearchDatasetsComponent { this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { @@ -90,10 +91,10 @@ export class AdvancedSearchDatasetsComponent { console.info("error"); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = errorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.NOT_AVAILABLE; + this.searchUtils.status = errorCodes.NOT_AVAILABLE; } ); } @@ -103,7 +104,7 @@ export class AdvancedSearchDatasetsComponent { private queryChanged($event) { var parameters = $event.value; - this.getResults(parameters, this.page,this.size); + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); } diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts index 49646a55..bc87cfdc 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts @@ -7,7 +7,7 @@ import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields} from '../../utils/properties/searchFields'; - +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @Component({ @@ -15,9 +15,8 @@ import {SearchFields} from '../../utils/properties/searchFields'; template: ` @@ -28,9 +27,11 @@ export class AdvancedSearchOrganizationsComponent { private results =[]; private filters =[]; private totalResults:number = 0 ; - private page :number = 1; - private size :number = 10; - public status:number; + // private page :number = 1; + // private size :number = 10; + // public status:number; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private baseUrl: string; private searchFields:SearchFields = new SearchFields(); @@ -45,7 +46,7 @@ export class AdvancedSearchOrganizationsComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); @@ -53,15 +54,15 @@ export class AdvancedSearchOrganizationsComponent { } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; - this.page = ( page <= 0 ) ? 1 : page; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; this.searchPage.selectedFields = this.selectedFields; this.searchPage.fieldIdsMap = this.fieldIdsMap; this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.page, this.size); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); }); } @@ -71,7 +72,7 @@ export class AdvancedSearchOrganizationsComponent { sub: any; public getResults(parameters:string, page: number, size: number){ var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.LOADING; + this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Organizations: Execute search query "+parameters); this._searchOrganizationsService.searchOrganizations(parameters, null, page, size, []).subscribe( data => { @@ -80,9 +81,9 @@ export class AdvancedSearchOrganizationsComponent { this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { @@ -90,10 +91,10 @@ export class AdvancedSearchOrganizationsComponent { console.info("error"); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = errorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.NOT_AVAILABLE; + this.searchUtils.status = errorCodes.NOT_AVAILABLE; } ); } @@ -103,7 +104,7 @@ export class AdvancedSearchOrganizationsComponent { private queryChanged($event) { var parameters = $event.value; - this.getResults(parameters, this.page,this.size); + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); } diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPeople.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPeople.component.ts index 6aa8acaa..eb766dab 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPeople.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPeople.component.ts @@ -7,7 +7,7 @@ import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields} from '../../utils/properties/searchFields'; - +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @Component({ @@ -15,9 +15,8 @@ import {SearchFields} from '../../utils/properties/searchFields'; template: ` @@ -28,9 +27,11 @@ export class AdvancedSearchPeopleComponent { private results =[]; private filters =[]; private totalResults:number = 0 ; - private page :number = 1; - private size :number = 10; - public status:number; + // private page :number = 1; + // private size :number = 10; + // public status:number; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private baseUrl: string; private searchFields:SearchFields = new SearchFields(); @@ -45,7 +46,7 @@ export class AdvancedSearchPeopleComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); @@ -53,15 +54,15 @@ export class AdvancedSearchPeopleComponent { } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; - this.page = ( page <= 0 ) ? 1 : page; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; this.searchPage.selectedFields = this.selectedFields; this.searchPage.fieldIdsMap = this.fieldIdsMap; this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.page, this.size); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); }); } @@ -71,7 +72,7 @@ export class AdvancedSearchPeopleComponent { sub: any; public getResults(parameters:string, page: number, size: number){ var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.LOADING; + this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search People: Execute search query "+parameters); this._searchPeopleService.searchPeople(parameters, null, page, size, []).subscribe( data => { @@ -80,9 +81,9 @@ export class AdvancedSearchPeopleComponent { this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { @@ -90,10 +91,10 @@ export class AdvancedSearchPeopleComponent { console.info("error"); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = errorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.NOT_AVAILABLE; + this.searchUtils.status = errorCodes.NOT_AVAILABLE; } ); } @@ -103,7 +104,7 @@ export class AdvancedSearchPeopleComponent { private queryChanged($event) { var parameters = $event.value; - this.getResults(parameters, this.page,this.size); + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); } diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts index 67d5a179..0421fb0a 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts @@ -7,17 +7,15 @@ import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields} from '../../utils/properties/searchFields'; - - +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @Component({ selector: 'advanced-search-projects', template: ` @@ -28,9 +26,11 @@ export class AdvancedSearchProjectsComponent { private results =[]; private filters =[]; private totalResults:number = 0 ; - private page :number = 1; - private size :number = 10; - public status:number; + // private page :number = 1; + // private size :number = 10; + // public status:number; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private baseUrl: string; private searchFields:SearchFields = new SearchFields(); @@ -45,7 +45,7 @@ export class AdvancedSearchProjectsComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); @@ -53,15 +53,15 @@ export class AdvancedSearchProjectsComponent { } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.size =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; - this.page = ( page <= 0 ) ? 1 : page; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; this.searchPage.selectedFields = this.selectedFields; this.searchPage.fieldIdsMap = this.fieldIdsMap; this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.page, this.size); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); }); } @@ -71,7 +71,7 @@ export class AdvancedSearchProjectsComponent { sub: any; public getResults(parameters:string, page: number, size: number){ var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.LOADING; + this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Publications: Execute search query "+parameters); this._searchProjectsService.searchProjects(parameters, null, page, size, []).subscribe( data => { @@ -80,9 +80,9 @@ export class AdvancedSearchProjectsComponent { this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { @@ -90,10 +90,10 @@ export class AdvancedSearchProjectsComponent { console.info("error"); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = errorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.NOT_AVAILABLE; + this.searchUtils.status = errorCodes.NOT_AVAILABLE; } ); } @@ -103,7 +103,7 @@ export class AdvancedSearchProjectsComponent { private queryChanged($event) { var parameters = $event.value; - this.getResults(parameters, this.page,this.size); + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); } diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts index 88500a3a..ec8badc1 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts @@ -7,7 +7,7 @@ import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; import {SearchFields} from '../../utils/properties/searchFields'; - +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @Component({ @@ -15,9 +15,8 @@ import {SearchFields} from '../../utils/properties/searchFields'; template: ` @@ -28,9 +27,8 @@ export class AdvancedSearchPublicationsComponent { private results =[]; private filters =[]; private totalResults:number = 0 ; - private page :number = 1; - private size :number = 10; - public status:number; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private baseUrl: string; private searchFields:SearchFields = new SearchFields(); @@ -45,7 +43,7 @@ export class AdvancedSearchPublicationsComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); @@ -53,15 +51,15 @@ export class AdvancedSearchPublicationsComponent { } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; - this.page = ( page <= 0 ) ? 1 : page; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; this.searchPage.selectedFields = this.selectedFields; this.searchPage.fieldIdsMap = this.fieldIdsMap; this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.page, this.size); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); }); } @@ -71,7 +69,7 @@ export class AdvancedSearchPublicationsComponent { sub: any; public getResults(parameters:string, page: number, size: number){ var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.LOADING; + this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Publications: Execute search query "+parameters); this._searchPublicationsService.searchPublications(parameters, null, page, size, []).subscribe( data => { @@ -80,9 +78,9 @@ export class AdvancedSearchPublicationsComponent { this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { @@ -90,10 +88,10 @@ export class AdvancedSearchPublicationsComponent { console.info("error"); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.NOT_AVAILABLE; + this.searchUtils.status = errorCodes.NOT_AVAILABLE; } ); } @@ -103,7 +101,7 @@ export class AdvancedSearchPublicationsComponent { private queryChanged($event) { var parameters = $event.value; - this.getResults(parameters, this.page,this.size); + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); console.info("queryChanged: Execute search query "+parameters); } diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts index 1d3ed94c..67df3407 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts @@ -8,14 +8,15 @@ import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {SearchFields} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; @Component({ selector: 'search-dataproviders', template: ` + [(results)] = "results" [(totalResults)] = "totalResults" [(searchUtils)] = "searchUtils" + [baseUrl] = "baseUrl" [showResultCount]=false (queryChange)="queryChanged($event)" > @@ -27,10 +28,7 @@ export class SearchCompatibleDataprovidersComponent { private filters =[]; public totalResults:number = 0 ; private baseUrl:string; - public status:number; - private keyword = ''; - private page :number = 1; - private size :number = 10; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private _location:Location; private searchFields:SearchFields = new SearchFields(); @@ -44,7 +42,7 @@ export class SearchCompatibleDataprovidersComponent { constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders(); for(var i = 0; i < this._prefixQueryFields.length; i++ ){ for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ @@ -61,11 +59,11 @@ export class SearchCompatibleDataprovidersComponent { this.searchPage.indexIdsMap = this.indexIdsMap; this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; this.filters = this.createFilters(); var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); - this._getResults(queryParameters, false, this.page, this.size); + this._getResults(queryParameters, false, this.searchUtils.page, this.searchUtils.size); }); } @@ -86,19 +84,19 @@ export class SearchCompatibleDataprovidersComponent { this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -110,7 +108,7 @@ export class SearchCompatibleDataprovidersComponent { var parameters = $event.index; console.info("queryChanged: Execute search query "+parameters); - this._getResults(parameters, false, this.page, this.size); + this._getResults(parameters, false, this.searchUtils.page, this.searchUtils.size); } private createFilters():Filter[] { var filter_names=["Type","Compatibility Level"]; diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts index 39b6e00a..77e46610 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts @@ -8,14 +8,16 @@ import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {SearchFields} from '../../utils/properties/searchFields'; import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + @Component({ selector: 'search-entity-registries', template: ` + [(results)] = "results" [(totalResults)] = "totalResults" [(searchUtils)] = "searchUtils" + [baseUrl] = "baseUrl" [showResultCount]=false (queryChange)="queryChanged($event)" > ` @@ -26,10 +28,7 @@ export class SearchEntityRegistriesComponent { private filters =[]; public totalResults:number = 0 ; private baseUrl:string; - public status:number; - private keyword = ''; - private page :number = 1; - private size :number = 10; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private _location:Location; private searchFields:SearchFields = new SearchFields(); @@ -44,7 +43,7 @@ export class SearchEntityRegistriesComponent { constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders(); for(var i = 0; i < this._prefixQueryFields.length; i++ ){ for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ @@ -61,12 +60,12 @@ export class SearchEntityRegistriesComponent { this.searchPage.indexIdsMap = this.indexIdsMap; this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; this.filters = this.createFilters(); var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); - this._getResults(queryParameters, false, this.page, this.size); + this._getResults(queryParameters, false, this.searchUtils.page, this.searchUtils.size); }); } @@ -86,19 +85,19 @@ export class SearchEntityRegistriesComponent { this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -109,7 +108,7 @@ export class SearchEntityRegistriesComponent { private queryChanged($event) { var parameters = $event.index; console.info("queryChanged: Execute search query "+parameters); - this._getResults(parameters, false, this.page, this.size); + this._getResults(parameters, false, this.searchUtils.page, this.searchUtils.size); } private createFilters():Filter[] { var filter_names=["Type","Compatibility Level"]; diff --git a/portal-2/src/app/searchPages/searchDataproviders.component.ts b/portal-2/src/app/searchPages/searchDataproviders.component.ts index 75f4abcc..55c9d744 100644 --- a/portal-2/src/app/searchPages/searchDataproviders.component.ts +++ b/portal-2/src/app/searchPages/searchDataproviders.component.ts @@ -8,14 +8,14 @@ import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProper import {SearchFields} from '../utils/properties/searchFields'; import {SearchPageComponent } from './searchUtils/searchPage.component'; import {ExportCSVComponent} from '../utils/exportCSV.component'; +import {SearchUtilsClass } from './searchUtils/searchUtils.class'; @Component({ selector: 'search-dataproviders', template: ` @@ -26,10 +26,7 @@ export class SearchDataprovidersComponent { private filters =[]; public totalResults:number = 0 ; private baseUrl:string; - public status:number; - private keyword = ''; - private page :number = 1; - private size :number = 10; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private _location:Location; private searchFields:SearchFields = new SearchFields(); @@ -45,7 +42,7 @@ export class SearchDataprovidersComponent { constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders(); } @@ -55,12 +52,12 @@ export class SearchDataprovidersComponent { this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; -console.info("PAGE init = "+this.page); + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; +console.info("PAGE init = "+this.searchUtils.page); var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, true, this.page, this.size); + this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size); }); } @@ -91,10 +88,10 @@ console.info("PAGE init = "+this.page); console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -113,15 +110,15 @@ console.info("PAGE init = "+this.page); console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } -public getResultsForDeposit(id:string, type:string, page: number, size: number){ +public getResultsForDeposit(id:string, type:string, page: number, size: number){ if(id != "") { @@ -132,19 +129,19 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number){ this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -165,19 +162,19 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number){ this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -188,7 +185,7 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number){ if(keyword.length > 0){ parameters = "q=" + keyword + "&op=and"; } - this._getResults(parameters,refine,page,size); + this._getResults(parameters,refine,page,this.searchUtils.size); } private _getResults(parameters:string,refine:boolean, page: number, size: number){ if(!refine && !this.searchPage){ @@ -204,19 +201,19 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number){ // this.filters = this.searchPage.checkSelectedFilters(data[2]); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -227,8 +224,8 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number){ private queryChanged($event) { var parameters = $event.value; -console.info("PAGE queryChanged = "+this.page); - this._getResults(parameters, true, this.page, this.size); +console.info("PAGE queryChanged = "+this.searchUtils.page); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } private downloadClicked($event) { @@ -245,19 +242,19 @@ console.info("PAGE queryChanged = "+this.page); ExportCSVComponent.downloadCSV(this.CSV, "dataproviders.csv"); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); /* diff --git a/portal-2/src/app/searchPages/searchDatasets.component.ts b/portal-2/src/app/searchPages/searchDatasets.component.ts index 212f3af9..2a950cda 100644 --- a/portal-2/src/app/searchPages/searchDatasets.component.ts +++ b/portal-2/src/app/searchPages/searchDatasets.component.ts @@ -8,13 +8,15 @@ import {SearchResult} from '../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; import {SearchFields} from '../utils/properties/searchFields'; import {SearchPageComponent } from './searchUtils/searchPage.component'; +import {SearchUtilsClass } from './searchUtils/searchUtils.class'; + @Component({ selector: 'search-datasets', template: ` + [(results)] = "results" [(totalResults)] = "totalResults" [(searchUtils)] = "searchUtils" + [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" > ` @@ -25,10 +27,8 @@ export class SearchDatasetsComponent { private filters: Filter[] =[]; public totalResults:number = 0 ; private baseUrl:string; - public status:number; - private keyword = ''; - private page :number = 1; - private size :number = 10; + + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private searchFields:SearchFields = new SearchFields(); @@ -43,7 +43,7 @@ export class SearchDatasetsComponent { constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchDatasets(); } @@ -54,12 +54,12 @@ export class SearchDatasetsComponent { this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; // this.getRefineResults(); - //this.getResults(this.keyword, this.page, this.size, "searchPage"); + //this.getResults(this.searchUtils.keyword, this.searchUtils.page, this.searchUtils.size, "searchPage"); var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, true, this.page, this.size); + this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size); }); } @@ -92,19 +92,19 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -127,19 +127,19 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -165,19 +165,19 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -190,7 +190,7 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number private queryChanged($event) { var parameters = $event.value; - //this.getResults(parameters, this.page, this.size, "searchPage"); - this._getResults(parameters, true, this.page, this.size); + //this.getResults(parameters, this.searchUtils.page, this.searchUtils.size, "searchPage"); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } } diff --git a/portal-2/src/app/searchPages/searchOrganizations.component.ts b/portal-2/src/app/searchPages/searchOrganizations.component.ts index 73daea69..e2ab9bdf 100644 --- a/portal-2/src/app/searchPages/searchOrganizations.component.ts +++ b/portal-2/src/app/searchPages/searchOrganizations.component.ts @@ -7,13 +7,15 @@ import {SearchResult} from '../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; import {SearchFields} from '../utils/properties/searchFields'; import {SearchPageComponent } from './searchUtils/searchPage.component'; +import {SearchUtilsClass } from './searchUtils/searchUtils.class'; + @Component({ selector: 'search-organizations', template: ` + [(results)] = "results" [(totalResults)] = "totalResults" [(searchUtils)] = "searchUtils" + [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" > ` @@ -24,10 +26,7 @@ export class SearchOrganizationsComponent { private filters =[]; public totalResults:number = 0 ; private baseUrl:string; - public status:number; - private keyword = ''; - private page :number = 1; - private size :number = 10; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private searchFields:SearchFields = new SearchFields(); @@ -42,7 +41,7 @@ export class SearchOrganizationsComponent { constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchOrganizations(); } @@ -53,11 +52,11 @@ export class SearchOrganizationsComponent { this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, true, this.page, this.size); + this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size); }); } @@ -76,7 +75,7 @@ export class SearchOrganizationsComponent { if(keyword.length > 0){ parameters = "q=" + keyword + "&op=and"; } - this._getResults(parameters,refine,page,size); + this._getResults(parameters,refine,page,this.searchUtils.size); } private _getResults(parameters:string,refine:boolean, page: number, size: number){ @@ -92,19 +91,19 @@ export class SearchOrganizationsComponent { this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -113,6 +112,6 @@ export class SearchOrganizationsComponent { private queryChanged($event) { var parameters = $event.value; console.info("queryChanged: Execute search query "+parameters); - this._getResults(parameters, true, this.page, this.size); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } } diff --git a/portal-2/src/app/searchPages/searchPeople.component.ts b/portal-2/src/app/searchPages/searchPeople.component.ts index ce81f26c..88061085 100644 --- a/portal-2/src/app/searchPages/searchPeople.component.ts +++ b/portal-2/src/app/searchPages/searchPeople.component.ts @@ -9,13 +9,15 @@ import {SearchResult} from '../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; import {SearchFields} from '../utils/properties/searchFields'; import {SearchPageComponent } from './searchUtils/searchPage.component'; +import {SearchUtilsClass } from './searchUtils/searchUtils.class'; + @Component({ selector: 'search-people', template: ` + [(results)] = "results" [(totalResults)] = "totalResults" + [(searchUtils)] = "searchUtils" [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" [showRefine]=false > ` @@ -25,11 +27,8 @@ export class SearchPeopleComponent { public results =[]; private filters =[]; public totalResults:number = 0 ; - public status:number; private baseUrl:string; - private keyword = ''; - private page :number = 1; - private size :number = 10; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private _location:Location; private refineFields = []; @@ -41,7 +40,7 @@ export class SearchPeopleComponent { //this.results =[]; //this.filters =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchPeople(); //get refine field filters from url parameters if(!this.searchPage){ @@ -52,8 +51,8 @@ export class SearchPeopleComponent { private ngOnInit() { this.searchPage.refineFields = this.refineFields; //TODO make it work as a directive this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; for(var i=0; i<5 ; i++){ var values = []; for(var j=0; j<10 ; j++){ @@ -91,7 +90,7 @@ export class SearchPeopleComponent { }); var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'} this.filters.push(filter1); - this.getResults(this.keyword, true, this.page, this.size); + this.getResults(this.searchUtils.keyword, true, this.searchUtils.page, this.searchUtils.size); } @@ -118,18 +117,18 @@ export class SearchPeopleComponent { this.sub.unsubscribe(); } /* - public getResults(parameters:string, page: number, size: number){ + public getResults(parameters:string, page: number, searchUtils.size: number){ console.info("getResults: Execute search query "+parameters); - this._searchPeopleService.searchPeople(parameters, page, size).subscribe( + this._searchPeopleService.searchPeople(parameters, page, searchUtils.size).subscribe( data => { this.totalResults = data[0]; console.info("search People total="+this.totalResults); this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { @@ -137,10 +136,10 @@ export class SearchPeopleComponent { console.info("error"); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.NOT_AVAILABLE; + this.searchUtils.status = errorCodes.NOT_AVAILABLE; } ); } @@ -151,7 +150,7 @@ public getResults(keyword:string,refine:boolean, page: number, size: number){ if(keyword.length > 0){ parameters = "q=" + keyword + "&op=and"; } - this._getResults(parameters,refine,page,size); + this._getResults(parameters,refine,page,this.searchUtils.size); } private _getResults(parameters:string,refine:boolean, page: number, size: number){ @@ -163,19 +162,19 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number this.filters = this.searchPage.checkSelectedFilters(data[2]); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -187,7 +186,7 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number private queryChanged($event) { var parameters = $event.value; console.info("queryChanged: Execute search query "+parameters); - this._getResults(parameters, true, this.page, this.size); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } diff --git a/portal-2/src/app/searchPages/searchProjects.component.ts b/portal-2/src/app/searchPages/searchProjects.component.ts index 9c7dc62a..018c069b 100644 --- a/portal-2/src/app/searchPages/searchProjects.component.ts +++ b/portal-2/src/app/searchPages/searchProjects.component.ts @@ -7,13 +7,16 @@ import {SearchResult} from '../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; import {SearchFields} from '../utils/properties/searchFields'; import {SearchPageComponent } from './searchUtils/searchPage.component'; +import {SearchUtilsClass } from './searchUtils/searchUtils.class'; + @Component({ selector: 'search-projects', template: ` + [(results)] = "results" [(totalResults)] = "totalResults" + [(searchUtils)] = "searchUtils" + [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" > ` @@ -22,11 +25,8 @@ export class SearchProjectsComponent { public results =[]; private filters: Filter[] =[]; public totalResults:number = 0 ; - public status:number; private baseUrl:string; - private keyword = ''; - private page :number = 1; - private size :number = 10; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private searchFields:SearchFields = new SearchFields(); @@ -42,7 +42,7 @@ export class SearchProjectsComponent { console.info(" constructor SearchProjectsComponent "+this.refineFields.length); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchProjects(); } @@ -57,13 +57,13 @@ export class SearchProjectsComponent { this.sub = this.route.queryParams.subscribe(params => { //get keyword from url parameters - this.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); //get page from url parameters - this.page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, true, this.page, this.size); + this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size); }); } @@ -81,7 +81,7 @@ export class SearchProjectsComponent { if(keyword.length > 0){ parameters = "q=" + keyword + "&op=and"; } - this._getResults(parameters,refine,page,size); + this._getResults(parameters,refine,page,this.searchUtils.size); } private _getResults(parameters:string,refine:boolean, page: number, size: number){ if(!refine && !this.searchPage){ @@ -97,19 +97,19 @@ export class SearchProjectsComponent { // this.filters = this.searchPage.checkSelectedFilters(data[2]); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -118,7 +118,7 @@ export class SearchProjectsComponent { private queryChanged($event) { this.urlParams = undefined; var parameters = $event.value; - this._getResults(parameters, true, this.page, this.size); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } } diff --git a/portal-2/src/app/searchPages/searchPublications.component.ts b/portal-2/src/app/searchPages/searchPublications.component.ts index 17481de8..4f82d0ef 100644 --- a/portal-2/src/app/searchPages/searchPublications.component.ts +++ b/portal-2/src/app/searchPages/searchPublications.component.ts @@ -9,14 +9,15 @@ import {SearchResult} from '../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; import {SearchFields} from '../utils/properties/searchFields'; import {SearchPageComponent } from './searchUtils/searchPage.component'; +import {SearchUtilsClass} from './searchUtils/searchUtils.class'; @Component({ selector: 'search-publications', template: ` + [(results)] = "results" [(totalResults)] = "totalResults" + [(searchUtils)] = "searchUtils" [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" > ` @@ -26,11 +27,9 @@ export class SearchPublicationsComponent { public results =[]; private filters =[]; public totalResults:number = 0 ; - public status:number; private baseUrl:string; - private keyword = ''; - private page :number = 1; - private size :number = 10; + private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private sub: any; private subResults: any; private searchFields:SearchFields = new SearchFields(); @@ -43,7 +42,7 @@ export class SearchPublicationsComponent { constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) { var errorCodes:ErrorCodes = new ErrorCodes(); - this.status =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchPublications(); } @@ -54,10 +53,10 @@ export class SearchPublicationsComponent { this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, true, this.page, this.size); + this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size); }); } @@ -112,19 +111,19 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -147,19 +146,19 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -185,19 +184,19 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; + this.searchUtils.status = errorCodes.DONE; if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; + this.searchUtils.status = errorCodes.NONE; } }, err => { console.error(err); //TODO check erros (service not available, bad request) // if( ){ - // this.status = ErrorCodes.ERROR; + // this.searchUtils.status = ErrorCodes.ERROR; // } var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; + this.searchUtils.status = errorCodes.ERROR; } ); } @@ -207,7 +206,8 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number private queryChanged($event) { var parameters = $event.value; console.info("queryChanged: Execute search query "+parameters); - this._getResults(parameters, true, this.page, this.size); + console.info("Search Pubs::page "+this.searchUtils.page); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } diff --git a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts index 17a2cec5..29a129b2 100644 --- a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts @@ -4,6 +4,7 @@ import {Location} from '@angular/common'; import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; import {SearchResult} from '../../utils/entities/searchResult'; import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass} from './searchUtils.class'; @Component({ selector: 'advanced-search-page', @@ -34,12 +35,12 @@ import {SearchFields} from '../../utils/properties/searchFields'; [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)"> -
- + + -
+
- +
@@ -52,14 +53,12 @@ export class AdvancedSearchPageComponent { @Input() pageTitle = ""; @Input() results = []; @Input() entityType; - @Input() page:number = 1; - @Input() size: number = 10; + @Input() searchUtils:SearchUtilsClass = new SearchUtilsClass(); @Input() totalResults: number = 0; @Input() fieldIds: string[]; @Input() fieldIdsMap:{ [key:string]:{ name:string, operator:string, type:string, indexField:string }} ; @Input() selectedFields:AdvancedField[]; @Input() baseUrl:string = ''; - @Input() status: number; @Input() simpleSearchUrl: string; private baseURLWithParameters:string = ''; @@ -119,10 +118,10 @@ export class AdvancedSearchPageComponent { "&"+this.fieldIdsMap[this.fieldIds[i]].operator+"="+fields[this.fieldIds[i]].operators.join() } } - if(includePage && this.page != 1){ - params += "&page="+this.page; + if(includePage && this.searchUtils.page != 1){ + params += "&page="+this.searchUtils.page; } - return params; + return '?'+params; } public createQueryParameters(){ var params=""; @@ -145,7 +144,7 @@ export class AdvancedSearchPageComponent { goTo(page:number = 1){ console.info("goto"); //console.info("keyword: "+this.keyword); - this.page = page; + this.searchUtils.page = page; var urlParameters = this.createUrlParameters(true); var queryParameters = this.createQueryParameters(); this.location.go(location.pathname,urlParameters); @@ -160,8 +159,8 @@ export class AdvancedSearchPageComponent { this.goTo(1); } pageChanged($event) { - this.page = +$event.value; - this.goTo(this.page); + this.searchUtils.page = +$event.value; + this.goTo(this.searchUtils.page); } /* * Update the url with proper parameters. This is used as base url in Paging Component diff --git a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts index a6b43be9..a1efeb6b 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts @@ -4,13 +4,14 @@ import {Location} from '@angular/common'; import { Filter, Value} from './searchHelperClasses.class'; import {SearchResult} from '../../utils/entities/searchResult'; import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass} from './searchUtils.class'; @Component({ selector: 'search-page', template: `
-