From 4bb3dc98fb458afbe6ffc2fc02d0d0c3ecd3f91f Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 29 Sep 2017 13:58:35 +0000 Subject: [PATCH] Utils of landing pages moved to 'landing-utils' folder | errorMessages.component created to centralize errorMessages according to ErrorCodes in openaireProperties.ts file | http service returning errorCodes and proper display fixed in search and fetch subscriptions (claims, home component, html project report page, csv files, basic info in landing pages, helper component, staticAutocomplete do not return errorCodes yet) | simple searchPages: paging remains when page changes while results load, filters on the left do not change position according to paging git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@49174 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../app/deposit/depositResult.component.ts | 33 ++-- .../dataProvider/dataProvider.component.html | 5 +- .../dataProvider/dataProvider.component.ts | 54 +++--- .../dataProvider/dataProvider.module.ts | 9 +- .../dataProvider/dataProvider.service.ts | 2 +- .../dataProvider/datasetsTab.component.ts | 9 +- .../dataProvider/datasourcesTab.component.ts | 6 +- .../dataProvider/projectsTab.component.ts | 5 +- .../dataProvider/publicationsTab.component.ts | 3 +- .../relatedDatasourcesTab.component.ts | 10 +- .../dataProvider/statisticsTab.component.ts | 5 +- .../landingPages/dataset/dataset.module.ts | 6 +- .../{ => landing-utils}/addThis.component.ts | 0 .../{ => landing-utils}/landing.module.ts | 4 +- .../{ => landing-utils}/metrics.component.ts | 20 ++- .../{ => landing-utils}/metrics.module.ts | 14 +- .../resultLanding.module.ts | 2 +- .../searchingProjectsInTab.component.ts | 15 +- .../searchingProjectsInTab.module.ts | 11 +- .../showAuthors.component.ts | 2 +- .../showIdentifiers.component.ts | 2 +- .../showSubjects.component.ts | 0 .../showTitle.component.ts | 0 .../tabPaging.component.ts | 0 .../{ => landing-utils}/tabTable.component.ts | 4 +- .../organization/organization.component.html | 10 +- .../organization/organization.component.ts | 10 +- .../organization/organization.module.ts | 7 +- .../project/project.component.html | 17 +- .../landingPages/project/project.module.ts | 7 +- .../publication/publication.module.ts | 6 +- .../advancedSearchDataProviders.component.ts | 64 ++++--- .../advancedSearchDatasets.component.ts | 60 ++++--- .../advancedSearchOrganizations.component.ts | 52 ++++-- .../advancedSearchProjects.component.ts | 54 ++++-- .../advancedSearchPublications.component.ts | 66 +++++--- .../compatibleDataProviders.component.ts | 27 ++- .../compatibleDataProvidersTable.component.ts | 43 +++-- .../entityRegistries.component.ts | 28 +++- .../entityRegistriesTable.component.ts | 43 +++-- .../dataProviders/journals.component.ts | 28 +++- .../dataProviders/journalsTable.component.ts | 43 +++-- .../app/searchPages/find/search.component.ts | 56 +++++-- .../advancedSearchPage.component.html | 2 +- .../advancedSearchPage.component.ts | 5 +- .../searchUtils/browseEntities.component.ts | 15 +- .../searchUtils/browseEntities.module.ts | 3 +- .../searchUtils/searchDownload.component.ts | 2 +- .../searchUtils/searchPage.component.html | 126 +++++++------- .../searchUtils/searchPage.component.ts | 7 +- .../searchPageTableView.component.html | 34 ++-- .../searchUtils/searchPageTableView.module.ts | 4 +- .../searchUtils/searchPaging.component.ts | 35 ++-- .../searchUtils/searchResult.component.html | 5 +- .../searchUtils/searchResults.module.ts | 16 +- .../simple/searchDataproviders.component.ts | 157 ++++++++++++------ .../simple/searchDatasets.component.ts | 77 ++++++--- .../simple/searchOrganizations.component.ts | 43 +++-- .../simple/searchProjects.component.ts | 81 ++++++--- .../simple/searchPublications.component.ts | 77 ++++++--- .../app/services/searchDatasets.service.ts | 2 +- .../src/app/utils/errorMessages.component.ts | 51 ++++++ .../src/app/utils/errorMessages.module.ts | 19 +++ .../fetchDataproviders.class.ts | 151 +++++++++++------ .../fetchDatasets.class.ts | 115 ++++++++----- .../fetchOrganizations.class.ts | 28 +++- .../fetchProjects.class.ts | 91 ++++++---- .../fetchPublications.class.ts | 95 +++++++---- .../utils/properties/openaireProperties.ts | 1 + portal-2/src/assets/discover-custom.css | 3 + 70 files changed, 1384 insertions(+), 703 deletions(-) rename portal-2/src/app/landingPages/{ => landing-utils}/addThis.component.ts (100%) rename portal-2/src/app/landingPages/{ => landing-utils}/landing.module.ts (83%) rename portal-2/src/app/landingPages/{ => landing-utils}/metrics.component.ts (92%) rename portal-2/src/app/landingPages/{ => landing-utils}/metrics.module.ts (67%) rename portal-2/src/app/landingPages/{ => landing-utils}/resultLanding.module.ts (94%) rename portal-2/src/app/landingPages/{ => landing-utils}/searchingProjectsInTab.component.ts (88%) rename portal-2/src/app/landingPages/{ => landing-utils}/searchingProjectsInTab.module.ts (62%) rename portal-2/src/app/landingPages/{ => landing-utils}/showAuthors.component.ts (97%) rename portal-2/src/app/landingPages/{ => landing-utils}/showIdentifiers.component.ts (97%) rename portal-2/src/app/landingPages/{ => landing-utils}/showSubjects.component.ts (100%) rename portal-2/src/app/landingPages/{ => landing-utils}/showTitle.component.ts (100%) rename portal-2/src/app/landingPages/{ => landing-utils}/tabPaging.component.ts (100%) rename portal-2/src/app/landingPages/{ => landing-utils}/tabTable.component.ts (96%) create mode 100644 portal-2/src/app/utils/errorMessages.component.ts create mode 100644 portal-2/src/app/utils/errorMessages.module.ts diff --git a/portal-2/src/app/deposit/depositResult.component.ts b/portal-2/src/app/deposit/depositResult.component.ts index ac77adff..be15f886 100644 --- a/portal-2/src/app/deposit/depositResult.component.ts +++ b/portal-2/src/app/deposit/depositResult.component.ts @@ -51,7 +51,7 @@ import {PiwikService} from '../utils/piwik/piwik.service';
-

+

content providers for institution: {{organization['name']}} () @@ -86,8 +86,8 @@ import {PiwikService} from '../utils/piwik/piwik.service';
-
+ || status == errorCodes.NOT_FOUND || status == errorCodes.ERROR || status == errorCodes.NOT_AVAILABLE" class = "alert alert-warning"> +
An error occured. @@ -98,12 +98,15 @@ import {PiwikService} from '../utils/piwik/piwik.service'; {{organization['name']}} .
-
+
No organization with ID: {{organizationId}} found.
An error occured.
+ + Service temprorarily unavailable. Please try again later. +
No ID for organization.
@@ -123,6 +126,7 @@ import {PiwikService} from '../utils/piwik/piwik.service';
+ ` }) @@ -211,19 +215,26 @@ export class DepositResultComponent { this._organizationService.getOrganizationInfo(this.organizationId).subscribe( data => { - this.organization = (data && data.title)?data.title:""; - this.status = this.errorCodes.DONE; - this.searchDataproviders(); + if(data == null) { + this.status = this.errorCodes.NOT_FOUND; + } else { + this.organization = data.title; + this.status = this.errorCodes.DONE; + this.searchDataproviders(); + } }, err => { //console.log(err) if(err.status == '404') { - this.status = this.errorCodes.NONE; - console.info("none"); + this.status = this.errorCodes.NOT_FOUND; + console.info("not found"); + } else if(err.status == '500') { + this.status = this.errorCodes.ERROR; + console.info("error"); } else { - this.status = this.errorCodes.ERROR; - console.info("error"); + this.status = this.errorCodes.NOT_AVAILABLE; + console.info("not available"); } } ); diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider.component.html b/portal-2/src/app/landingPages/dataProvider/dataProvider.component.html index ed68885e..e26008aa 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider.component.html +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider.component.html @@ -165,15 +165,16 @@ - + class="uk-animation-fade uk-margin-large-top uk-width-1-1" role="alert">Loading +

Latest Research Result Timeline

diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider.component.ts b/portal-2/src/app/landingPages/dataProvider/dataProvider.component.ts index e03bccf9..155960ee 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider.component.ts @@ -160,7 +160,7 @@ export class DataProviderComponent { } }, err => { - console.log(err) + console.log(err); // console.info("error"); this.errorMessage = 'No dataProvider found'; this.showLoading = false; @@ -271,11 +271,9 @@ export class DataProviderComponent { } private searchPublications(page: number, size: number) { - if(this.fetchPublications.searchUtils.status == this.errorCodes.NONE) { - this.reloadPublications = false; - } - - if(this.reloadPublications) { + if( this.reloadPublications && + ( this.fetchPublications.searchUtils.status == this.errorCodes.LOADING || + this.fetchPublications.searchUtils.status == this.errorCodes.DONE ) ) { this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size); } this.reloadPublications = false; @@ -286,11 +284,9 @@ export class DataProviderComponent { } private searchDatasets(page: number, size: number) { - if(this.fetchDatasets.searchUtils.status == this.errorCodes.NONE) { - this.reloadDatasets = false; - } - - if(this.reloadDatasets) { + if( this.reloadDatasets && + ( this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING || + this.fetchDatasets.searchUtils.status == this.errorCodes.DONE ) ) { this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size); } this.reloadDatasets = false; @@ -301,11 +297,9 @@ export class DataProviderComponent { } private searchProjects(page: number, size: number) { - if(this.fetchProjects.searchUtils.status == this.errorCodes.NONE) { - this.reloadProjects = false; - } - - if(this.reloadProjects) { + if( this.reloadProjects && + ( this.fetchProjects.searchUtils.status == this.errorCodes.LOADING || + this.fetchProjects.searchUtils.status == this.errorCodes.DONE ) ) { this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size); } this.reloadProjects = false; @@ -316,11 +310,9 @@ export class DataProviderComponent { } private searchDatasources(page: number, size: number) { - if(this.fetchDataproviders.searchUtils.status == this.errorCodes.NONE) { - this.reloadDataproviders = false; - } - - if(this.reloadDataproviders) { + if( this.reloadDataproviders && + ( this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING || + this.fetchDataproviders.searchUtils.status == this.errorCodes.DONE ) ) { this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size); } this.reloadDataproviders = false; @@ -332,13 +324,13 @@ export class DataProviderComponent { private searchRelatedDatasources(page: number, size: number) { // Currently no counting is done for this tab. Following condition is always false - if(this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.NONE - && this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.NONE) { - this.reloadRelatedDatasources = false; - this.loadingRelatedDatasources = false; - } - if(this.reloadRelatedDatasources) { + if( this.reloadRelatedDatasources && + ( this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.LOADING || + this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE ) + && + ( this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.LOADING || + this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.DONE ) ) { this.relatedDatasourcesSub = Observable.merge(this.fetchAggregatorsPublications.requestComplete, this.fetchAggregatorsDatasets.requestComplete) .subscribe( data => {}, @@ -348,7 +340,9 @@ export class DataProviderComponent { this.fetchAggregatorsPublications.getAggregatorResults(this.datasourceId, page, size); this.fetchAggregatorsDatasets.getAggregatorResults(this.datasourceId, page, size); - } + } else { + this.loadingRelatedDatasources = false; + } this.reloadRelatedDatasources = false; @@ -361,7 +355,8 @@ export class DataProviderComponent { private preprocessRelatedDatasources() { - if(this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE || this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.DONE) { + if( this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE || + this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.DONE ) { this.dataProviderInfo.relatedDatasources = new Map(); } for(let result of this.fetchAggregatorsPublications.results) { @@ -379,7 +374,6 @@ export class DataProviderComponent { this.dataProviderInfo.relatedDatasources.get(result.id).countDatasets = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countDatasets + result.count)+""; } } - this.loadingRelatedDatasources = false; } diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider.module.ts b/portal-2/src/app/landingPages/dataProvider/dataProvider.module.ts index ee4b8ad7..df41b8c2 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider.module.ts +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider.module.ts @@ -4,10 +4,11 @@ import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import {IFrameModule} from '../../utils/iframe.module'; +import {ErrorMessagesModule} from '../../utils/errorMessages.module'; // import { ResultLandingModule } from '../resultLanding.module'; import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; -import {MetricsModule} from '../metrics.module'; -import { LandingModule } from '../landing.module'; +import {MetricsModule} from '../landing-utils/metrics.module'; +import {LandingModule} from '../landing-utils/landing.module'; import {PagingModule} from '../../utils/paging.module'; import {PublicationsTabComponent} from './publicationsTab.component'; @@ -20,7 +21,7 @@ import {RelatedDatasourcesTabComponent} from './relatedDatasourcesTab.component' // import {TabsComponent} from './tabs.component'; import {DataProviderComponent} from './dataProvider.component'; -import { DataProviderService} from './dataProvider.service'; +import {DataProviderService} from './dataProvider.service'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {ProjectsServiceModule} from '../../services/projectsService.module'; @@ -32,7 +33,7 @@ import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [CommonModule, FormsModule, RouterModule,DataProviderRoutingModule, - TabResultModule, IFrameModule, MetricsModule, LandingModule, + TabResultModule, IFrameModule, ErrorMessagesModule, MetricsModule, LandingModule, DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, PublicationsServiceModule, PagingModule], declarations: diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider.service.ts b/portal-2/src/app/landingPages/dataProvider/dataProvider.service.ts index 4c1fcc22..c01168dd 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider.service.ts +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider.service.ts @@ -17,7 +17,7 @@ export class DataProviderService { getDataproviderInfo (id: string):any { console.info("getDataProviderInfo in service"); - let url = OpenaireProperties.getSearchAPIURLLast() + 'datasources/' +id +"?format=json"; + let url = OpenaireProperties.getSearchAPIURLLast() + 'datasources/' +id +"?formatt=json"; let key = url; if (this._cache.has(key)) { return Observable.of(this._cache.get(key)).map(res => this.parseDataProviderInfo(res)); diff --git a/portal-2/src/app/landingPages/dataProvider/datasetsTab.component.ts b/portal-2/src/app/landingPages/dataProvider/datasetsTab.component.ts index ec5abb83..d75edae7 100644 --- a/portal-2/src/app/landingPages/dataProvider/datasetsTab.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/datasetsTab.component.ts @@ -6,9 +6,12 @@ import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openairePro @Component({ selector: 'datasetsTab', template: ` - - - + + + + diff --git a/portal-2/src/app/landingPages/dataProvider/relatedDatasourcesTab.component.ts b/portal-2/src/app/landingPages/dataProvider/relatedDatasourcesTab.component.ts index 6c0db45e..da85f597 100644 --- a/portal-2/src/app/landingPages/dataProvider/relatedDatasourcesTab.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/relatedDatasourcesTab.component.ts @@ -10,21 +10,23 @@ import { Observable } from 'rxjs/Observable'; @Component({ selector: 'relatedDatasourcesTab', template: ` - + - + + +
diff --git a/portal-2/src/app/landingPages/dataProvider/statisticsTab.component.ts b/portal-2/src/app/landingPages/dataProvider/statisticsTab.component.ts index f96811e2..4aae1f91 100644 --- a/portal-2/src/app/landingPages/dataProvider/statisticsTab.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/statisticsTab.component.ts @@ -7,14 +7,15 @@ import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openairePro selector: 'statisticsTab', template: `
- + class="uk-animation-fade uk-width-1-1" role="alert">Loading + - + +
Project metrics are derived from aggregating individual research results metrics.
@@ -196,6 +198,7 @@ export class MetricsComponent { data => { this.metrics = data; this.status = this.errorCodes.DONE; + this.metricsResults.emit({ totalViews: this.metrics.totalViews, totalDownloads: this.metrics.totalDownloads, @@ -204,9 +207,12 @@ export class MetricsComponent { }, err => { console.log(err); - this.status = this.errorCodes.ERROR; if(err.status == '404') { - this.status = this.errorCodes.NOT_AVAILABLE; + this.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.status = this.errorCodes.ERROR; + } else { + this.status = this.errorCodes.NOT_AVAILABLE; } this.metricsResults.emit({ totalViews: 0, diff --git a/portal-2/src/app/landingPages/metrics.module.ts b/portal-2/src/app/landingPages/landing-utils/metrics.module.ts similarity index 67% rename from portal-2/src/app/landingPages/metrics.module.ts rename to portal-2/src/app/landingPages/landing-utils/metrics.module.ts index ccd0dcee..3fb241b4 100644 --- a/portal-2/src/app/landingPages/metrics.module.ts +++ b/portal-2/src/app/landingPages/landing-utils/metrics.module.ts @@ -5,22 +5,22 @@ import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import {MetricsComponent} from './metrics.component'; - import { MetricsService } from '../services/metrics.service'; + import { MetricsService } from '../../services/metrics.service'; + + import {ErrorMessagesModule} from '../../utils/errorMessages.module'; @NgModule({ imports: [ - - CommonModule, FormsModule - ], + CommonModule, FormsModule, ErrorMessagesModule + ], declarations: [ - MetricsComponent + MetricsComponent ], providers:[ MetricsService ], exports: [ - MetricsComponent - ] + ] }) export class MetricsModule { } diff --git a/portal-2/src/app/landingPages/resultLanding.module.ts b/portal-2/src/app/landingPages/landing-utils/resultLanding.module.ts similarity index 94% rename from portal-2/src/app/landingPages/resultLanding.module.ts rename to portal-2/src/app/landingPages/landing-utils/resultLanding.module.ts index 6529c62d..f7c45d7d 100644 --- a/portal-2/src/app/landingPages/resultLanding.module.ts +++ b/portal-2/src/app/landingPages/landing-utils/resultLanding.module.ts @@ -3,7 +3,7 @@ import { NgModule} from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; -import {PagingModule} from '../utils/paging.module'; +import {PagingModule} from '../../utils/paging.module'; import {ShowAuthorsComponent} from './showAuthors.component'; import {ShowIdentifiersComponent} from './showIdentifiers.component'; diff --git a/portal-2/src/app/landingPages/searchingProjectsInTab.component.ts b/portal-2/src/app/landingPages/landing-utils/searchingProjectsInTab.component.ts similarity index 88% rename from portal-2/src/app/landingPages/searchingProjectsInTab.component.ts rename to portal-2/src/app/landingPages/landing-utils/searchingProjectsInTab.component.ts index 3000c919..c96d23ba 100644 --- a/portal-2/src/app/landingPages/searchingProjectsInTab.component.ts +++ b/portal-2/src/app/landingPages/landing-utils/searchingProjectsInTab.component.ts @@ -1,12 +1,12 @@ import {Component, Input} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; -import { FetchProjects } from '../utils/fetchEntitiesClasses/fetchProjects.class'; -import { SearchProjectsService } from '../services/searchProjects.service'; +import { FetchProjects } from '../../utils/fetchEntitiesClasses/fetchProjects.class'; +import { SearchProjectsService } from '../../services/searchProjects.service'; -import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; -import {StringUtils} from '../utils/string-utils.class'; -import {RouterHelper} from '../utils/routerHelper.class'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {StringUtils} from '../../utils/string-utils.class'; +import {RouterHelper} from '../../utils/routerHelper.class'; @Component({ selector: 'searchingProjectsTab', @@ -14,10 +14,11 @@ import {RouterHelper} from '../utils/routerHelper.class'; - + +
diff --git a/portal-2/src/app/landingPages/searchingProjectsInTab.module.ts b/portal-2/src/app/landingPages/landing-utils/searchingProjectsInTab.module.ts similarity index 62% rename from portal-2/src/app/landingPages/searchingProjectsInTab.module.ts rename to portal-2/src/app/landingPages/landing-utils/searchingProjectsInTab.module.ts index 5b9f3917..e3d7a061 100644 --- a/portal-2/src/app/landingPages/searchingProjectsInTab.module.ts +++ b/portal-2/src/app/landingPages/landing-utils/searchingProjectsInTab.module.ts @@ -5,17 +5,18 @@ import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; -import { ProjectsServiceModule} from '../services/projectsService.module'; -import { TabResultModule } from '../searchPages/searchUtils/tabResult.module'; +import { ProjectsServiceModule} from '../../services/projectsService.module'; +import { TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; import { SearchingProjectsTabComponent} from './searchingProjectsInTab.component'; -import {PagingModule } from '../utils/paging.module'; - +import {PagingModule } from '../../utils/paging.module'; +import {ErrorMessagesModule} from '../../utils/errorMessages.module'; @NgModule({ imports: [ RouterModule, CommonModule, FormsModule, - ProjectsServiceModule, TabResultModule, PagingModule + ProjectsServiceModule, TabResultModule, + PagingModule, ErrorMessagesModule ], declarations: [ SearchingProjectsTabComponent diff --git a/portal-2/src/app/landingPages/showAuthors.component.ts b/portal-2/src/app/landingPages/landing-utils/showAuthors.component.ts similarity index 97% rename from portal-2/src/app/landingPages/showAuthors.component.ts rename to portal-2/src/app/landingPages/landing-utils/showAuthors.component.ts index 11492819..0d5d5195 100644 --- a/portal-2/src/app/landingPages/showAuthors.component.ts +++ b/portal-2/src/app/landingPages/landing-utils/showAuthors.component.ts @@ -1,5 +1,5 @@ import {Component, Input, ElementRef} from '@angular/core'; -import {RouterHelper} from '../utils/routerHelper.class'; +import {RouterHelper} from '../../utils/routerHelper.class'; @Component({ selector: 'showAuthors', diff --git a/portal-2/src/app/landingPages/showIdentifiers.component.ts b/portal-2/src/app/landingPages/landing-utils/showIdentifiers.component.ts similarity index 97% rename from portal-2/src/app/landingPages/showIdentifiers.component.ts rename to portal-2/src/app/landingPages/landing-utils/showIdentifiers.component.ts index 54247998..e4e8b497 100644 --- a/portal-2/src/app/landingPages/showIdentifiers.component.ts +++ b/portal-2/src/app/landingPages/landing-utils/showIdentifiers.component.ts @@ -1,5 +1,5 @@ import {Component, Input, ElementRef} from '@angular/core'; -import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; @Component({ selector: 'showIdentifiers', diff --git a/portal-2/src/app/landingPages/showSubjects.component.ts b/portal-2/src/app/landingPages/landing-utils/showSubjects.component.ts similarity index 100% rename from portal-2/src/app/landingPages/showSubjects.component.ts rename to portal-2/src/app/landingPages/landing-utils/showSubjects.component.ts diff --git a/portal-2/src/app/landingPages/showTitle.component.ts b/portal-2/src/app/landingPages/landing-utils/showTitle.component.ts similarity index 100% rename from portal-2/src/app/landingPages/showTitle.component.ts rename to portal-2/src/app/landingPages/landing-utils/showTitle.component.ts diff --git a/portal-2/src/app/landingPages/tabPaging.component.ts b/portal-2/src/app/landingPages/landing-utils/tabPaging.component.ts similarity index 100% rename from portal-2/src/app/landingPages/tabPaging.component.ts rename to portal-2/src/app/landingPages/landing-utils/tabPaging.component.ts diff --git a/portal-2/src/app/landingPages/tabTable.component.ts b/portal-2/src/app/landingPages/landing-utils/tabTable.component.ts similarity index 96% rename from portal-2/src/app/landingPages/tabTable.component.ts rename to portal-2/src/app/landingPages/landing-utils/tabTable.component.ts index f6852130..2aeb71f2 100644 --- a/portal-2/src/app/landingPages/tabTable.component.ts +++ b/portal-2/src/app/landingPages/landing-utils/tabTable.component.ts @@ -1,6 +1,6 @@ import {Component, Input} from '@angular/core'; -import {RouterHelper} from '../utils/routerHelper.class'; -import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {RouterHelper} from '../../utils/routerHelper.class'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; //import {PagingModule} from '../utils/paging.module'; @Component({ diff --git a/portal-2/src/app/landingPages/organization/organization.component.html b/portal-2/src/app/landingPages/organization/organization.component.html index f3509221..031854c1 100644 --- a/portal-2/src/app/landingPages/organization/organization.component.html +++ b/portal-2/src/app/landingPages/organization/organization.component.html @@ -87,10 +87,11 @@
- + +
@@ -115,10 +116,11 @@ No content providers available - + +
diff --git a/portal-2/src/app/landingPages/organization/organization.component.ts b/portal-2/src/app/landingPages/organization/organization.component.ts index 90bd35a0..9ddd68af 100644 --- a/portal-2/src/app/landingPages/organization/organization.component.ts +++ b/portal-2/src/app/landingPages/organization/organization.component.ts @@ -14,7 +14,7 @@ import {SearchDataprovidersService} from '../../services/searchDataproviders.ser import {SearchProjectsService} from '../../services/searchProjects.service'; import { Meta} from '../../../angular2-meta'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; -import {SearchingProjectsTabComponent} from '../searchingProjectsInTab.component'; +import {SearchingProjectsTabComponent} from '../landing-utils/searchingProjectsInTab.component'; import {RouterHelper} from '../../utils/routerHelper.class'; import {ModalLoading} from '../../utils/modal/loading.component'; @@ -296,7 +296,7 @@ export class OrganizationComponent { this.downloadFilePiwikSub = this._piwikService.trackDownload(url).subscribe(); } }, - error => { + err => { console.log("Error downloading the file."); this.closeLoading(); this.confirmOpenCsvError(); @@ -369,7 +369,7 @@ export class OrganizationComponent { // } } }, - error => { + err => { console.log("Error downloading the file."); this.closeLoading(); this.confirmOpenCsvError(); @@ -378,11 +378,11 @@ export class OrganizationComponent { ); } }, - error => console.log("Error getting number of publications for project.")); + err => console.log("Error getting number of publications for project.")); }//); }, - error => { + err => { console.log("Error getting projects project."); this.closeLoading(); this.confirmOpenCsvError(); diff --git a/portal-2/src/app/landingPages/organization/organization.module.ts b/portal-2/src/app/landingPages/organization/organization.module.ts index d7f4a2a8..52ee2651 100644 --- a/portal-2/src/app/landingPages/organization/organization.module.ts +++ b/portal-2/src/app/landingPages/organization/organization.module.ts @@ -5,26 +5,27 @@ import { RouterModule } from '@angular/router'; import {LoadingModalModule} from '../../utils/modal/loadingModal.module'; import {AlertModalModule} from '../../utils/modal/alertModal.module'; +import {ErrorMessagesModule} from '../../utils/errorMessages.module'; import { OrganizationServiceModule} from '../../services/organizationService.module'; // import { ProjectsServiceModule} from '../../services/projectsService.module'; import { OrganizationComponent } from './organization.component'; import { OrganizationRoutingModule } from './organization-routing.module'; -import { LandingModule } from '../landing.module'; +import { LandingModule } from '../landing-utils/landing.module'; import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {ReportsServiceModule} from '../../services/reportsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {ProjectsServiceModule} from '../../services/projectsService.module'; -import { SearchingProjectsTabModule} from '../searchingProjectsInTab.module'; +import { SearchingProjectsTabModule} from '../landing-utils/searchingProjectsInTab.module'; import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, - LoadingModalModule, AlertModalModule, + LoadingModalModule, AlertModalModule, ErrorMessagesModule, LandingModule, OrganizationRoutingModule, TabResultModule, diff --git a/portal-2/src/app/landingPages/project/project.component.html b/portal-2/src/app/landingPages/project/project.component.html index d1797152..8aa5c5c6 100644 --- a/portal-2/src/app/landingPages/project/project.component.html +++ b/portal-2/src/app/landingPages/project/project.component.html @@ -158,11 +158,11 @@ - + +
@@ -182,11 +182,11 @@ - + +
@@ -206,14 +206,15 @@ - + class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">Loading +
diff --git a/portal-2/src/app/landingPages/project/project.module.ts b/portal-2/src/app/landingPages/project/project.module.ts index 09dd9802..81ac48b8 100644 --- a/portal-2/src/app/landingPages/project/project.module.ts +++ b/portal-2/src/app/landingPages/project/project.module.ts @@ -7,22 +7,23 @@ import { RouterModule } from '@angular/router'; import { ProjectServiceModule} from './projectService.module'; // import {HtmlProgressReportService} from './htmlProgressReport.service'; import{LoadingModalModule} from '../../utils/modal/loadingModal.module'; +import {ErrorMessagesModule} from '../../utils/errorMessages.module'; import { ProjectComponent } from './project.component'; import { ProjectRoutingModule } from './project-routing.module'; import {IFrameModule} from '../../utils/iframe.module'; -import {MetricsModule} from '../metrics.module'; +import {MetricsModule} from '../landing-utils/metrics.module'; import {ReportsServiceModule} from '../../services/reportsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; -import { LandingModule } from '../landing.module'; +import { LandingModule } from '../landing-utils/landing.module'; import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, LandingModule, - ProjectRoutingModule, LoadingModalModule, + ProjectRoutingModule, LoadingModalModule, ErrorMessagesModule, TabResultModule, IFrameModule, MetricsModule, ReportsServiceModule, PublicationsServiceModule, DatasetsServiceModule, ProjectServiceModule ], diff --git a/portal-2/src/app/landingPages/publication/publication.module.ts b/portal-2/src/app/landingPages/publication/publication.module.ts index ed6d05c9..77241d64 100644 --- a/portal-2/src/app/landingPages/publication/publication.module.ts +++ b/portal-2/src/app/landingPages/publication/publication.module.ts @@ -8,14 +8,14 @@ import { RouterModule } from '@angular/router'; import { PublicationService} from './publication.service'; import { PublicationComponent } from './publication.component'; import { PublicationRoutingModule } from './publication-routing.module'; -import {MetricsModule} from '../metrics.module'; +import {MetricsModule} from '../landing-utils/metrics.module'; import {IFrameModule} from '../../utils/iframe.module'; import {AltMetricsModule} from '../../utils/altmetrics.module'; import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module'; import {PagingModule} from '../../utils/paging.module'; -import { ResultLandingModule } from '../resultLanding.module'; -import { LandingModule } from '../landing.module'; +import { ResultLandingModule } from '../landing-utils/resultLanding.module'; +import { LandingModule } from '../landing-utils/landing.module'; import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts index bbe605c7..85f620eb 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts @@ -21,13 +21,17 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(searchUtils)] = "searchUtils" (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/dataproviders" - [disableForms]="disableForms"> + [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults"> ` }) export class AdvancedSearchDataProvidersComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); @@ -41,27 +45,32 @@ export class AdvancedSearchDataProvidersComponent { public resourcesQuery = "(oaftype exact datasource)"; public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; constructor (private route: ActivatedRoute, private _searchDataProvidersService: SearchDataprovidersService ) { - this.results =[]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedDataProviders; console.info("Con -base url:"+this.searchUtils.baseUrl ); } ngOnInit() { this.sub = this.route.queryParams.subscribe(params => { - let page = (params['page']=== undefined)?0:+params['page']; - this.searchUtils.page = ( page < 1 ) ? 1 : page; - this.searchPage.fieldIds = this.fieldIds; - this.selectedFields =[]; - this.searchPage.selectedFields = this.selectedFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } + let page = (params['page']=== undefined)?0:+params['page']; + this.searchUtils.page = ( page < 1 ) ? 1 : page; + this.searchPage.fieldIds = this.fieldIds; + this.selectedFields =[]; + this.searchPage.selectedFields = this.selectedFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.getSelectedFiltersFromUrl(params); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); }); } ngOnDestroy() { @@ -75,37 +84,37 @@ export class AdvancedSearchDataProvidersComponent { this.csvParams ="&type=datasources&query="+this.resourcesQuery; } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //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); + 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]; this.searchPage.updateBaseUrlWithParameters(); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { - // Page out of limit!!! + 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 = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -116,8 +125,15 @@ export class AdvancedSearchDataProvidersComponent { // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.NOT_AVAILABLE; + //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; } @@ -125,6 +141,8 @@ export class AdvancedSearchDataProvidersComponent { } 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-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts index 87d8e260..d5a41f05 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts @@ -20,44 +20,52 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/datasets" - [disableForms]="disableForms"> + [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults"> ` }) export class AdvancedSearchDatasetsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public searchFields:SearchFields = new SearchFields(); - - public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; - public fieldIdsMap= this.searchFields.RESULT_FIELDS; - public selectedFields:AdvancedField[] = []; + public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; + public fieldIdsMap= this.searchFields.RESULT_FIELDS; + public selectedFields:AdvancedField[] = []; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; public resourcesQuery = "( (oaftype exact result) and (resulttypeid exact dataset) )"; public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) { - this.results =[]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedDatasets; } ngOnInit() { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; - this.sub = this.route.queryParams.subscribe(params => { + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + this.sub = this.route.queryParams.subscribe(params => { + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } + let page = (params['page']=== undefined)?1:+params['page']; this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; @@ -80,8 +88,8 @@ export class AdvancedSearchDatasetsComponent { this.csvParams ="&type=datasets&query="+this.resourcesQuery; } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -94,15 +102,15 @@ export class AdvancedSearchDatasetsComponent { console.info("search Research Data total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -110,7 +118,7 @@ export class AdvancedSearchDatasetsComponent { } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -121,8 +129,16 @@ export class AdvancedSearchDatasetsComponent { // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.NOT_AVAILABLE; + //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; } @@ -133,6 +149,8 @@ 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-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts index 9ad6f004..dffde579 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts @@ -20,13 +20,17 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/organizations" - [disableForms]="disableForms"> + [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults"> ` }) export class AdvancedSearchOrganizationsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); @@ -37,25 +41,31 @@ export class AdvancedSearchOrganizationsComponent { public selectedFields:AdvancedField[] = []; public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; public resourcesQuery = "(oaftype exact organization)"; constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { - this.results =[]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedOrganizations; } ngOnInit() { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + + this.sub = this.route.queryParams.subscribe(params => { + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } - this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; @@ -78,8 +88,8 @@ public resourcesQuery = "(oaftype exact organization)"; this.csvParams ="&type=organizations&query="+this.resourcesQuery; } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -92,15 +102,15 @@ public resourcesQuery = "(oaftype exact organization)"; console.info("search Organizations total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -108,7 +118,7 @@ public resourcesQuery = "(oaftype exact organization)"; } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -119,8 +129,16 @@ public resourcesQuery = "(oaftype exact organization)"; // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.NOT_AVAILABLE; + //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; } @@ -131,6 +149,8 @@ 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-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts index 8061b74d..bf1af211 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts @@ -19,19 +19,22 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/projects" - [disableForms]="disableForms"> + [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults"> ` }) export class AdvancedSearchProjectsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - - public searchFields:SearchFields = new SearchFields(); + public searchFields:SearchFields = new SearchFields(); public fieldIds: string[] = this.searchFields.PROJECT_ADVANCED_FIELDS; public fieldIdsMap = this.searchFields.PROJECT_FIELDS; @@ -41,21 +44,28 @@ export class AdvancedSearchProjectsComponent { public resourcesQuery = "(oaftype exact project)"; public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService ) { this.results =[]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedProjects; } ngOnInit() { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; - this.sub = this.route.queryParams.subscribe(params => { + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + this.sub = this.route.queryParams.subscribe(params => { + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } + let page = (params['page']=== undefined)?1:+params['page']; this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; @@ -78,8 +88,8 @@ export class AdvancedSearchProjectsComponent { this.csvParams ="&type=projects&query="+this.resourcesQuery; } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -92,15 +102,15 @@ export class AdvancedSearchProjectsComponent { 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 = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -108,7 +118,7 @@ export class AdvancedSearchProjectsComponent { } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -119,8 +129,16 @@ export class AdvancedSearchProjectsComponent { // if( ){ // this.searchUtils.status = errorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.NOT_AVAILABLE; + //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; @@ -132,6 +150,8 @@ 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-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts index 1208e035..8f0cfa26 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts @@ -20,24 +20,30 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields" (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/publications" - [disableForms]="disableForms"> + [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults"> ` }) export class AdvancedSearchPublicationsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); public searchFields:SearchFields = new SearchFields(); public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; - public fieldIdsMap= this.searchFields.RESULT_FIELDS; - public selectedFields:AdvancedField[] = []; - public resourcesQuery = "((oaftype exact result) and (resulttypeid exact publication))"; - public csvParams: string; - public disableForms: boolean = false; + public fieldIdsMap= this.searchFields.RESULT_FIELDS; + public selectedFields:AdvancedField[] = []; + public resourcesQuery = "((oaftype exact result) and (resulttypeid exact publication))"; + public csvParams: string; + public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; @@ -45,17 +51,22 @@ export class AdvancedSearchPublicationsComponent { constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) { this.results =[]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedPublications; } ngOnInit() { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; - this.sub = this.route.queryParams.subscribe(params => { + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; + this.sub = this.route.queryParams.subscribe(params => { + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } + let page = (params['page']=== undefined)?1:+params['page']; this.searchUtils.page = ( page <= 0 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; @@ -64,8 +75,7 @@ export class AdvancedSearchPublicationsComponent { this.searchPage.fieldIdsMap = this.fieldIdsMap; this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); - + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); }); } ngOnDestroy() { @@ -79,8 +89,8 @@ export class AdvancedSearchPublicationsComponent { this.csvParams ="&type=publications&query="+this.resourcesQuery; } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -93,15 +103,15 @@ export class AdvancedSearchPublicationsComponent { console.info("searchPubl total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -109,7 +119,7 @@ export class AdvancedSearchPublicationsComponent { } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -120,8 +130,16 @@ export class AdvancedSearchPublicationsComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.NOT_AVAILABLE; + //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; @@ -130,6 +148,8 @@ export class AdvancedSearchPublicationsComponent { } 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-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts index c80d9a50..4e842e97 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts @@ -31,6 +31,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; }) export class SearchCompatibleDataprovidersComponent { + private errorCodes: ErrorCodes; public results =[]; public filters =[]; public baseUrl:string; @@ -55,8 +56,8 @@ export class SearchCompatibleDataprovidersComponent { @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchCompatibleDataProviders(); for(var i = 0; i < this._prefixQueryFields.length; i++ ){ for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ @@ -91,8 +92,8 @@ export class SearchCompatibleDataprovidersComponent { private _getResults(parameters:string,refine:boolean, page: number, size: number){ this.csvParams = parameters+this.resourcesQuery+"&type=datasources"; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -105,10 +106,10 @@ export class SearchCompatibleDataprovidersComponent { this.results = data[1]; this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; @@ -120,8 +121,16 @@ export class SearchCompatibleDataprovidersComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts index e6c85963..3b4e7c4f 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts @@ -27,6 +27,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; }) export class SearchCompatibleDataprovidersTableComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public baseUrl:string; @@ -48,8 +50,8 @@ export class SearchCompatibleDataprovidersTableComponent { @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchCompatibleDataProvidersTable(); } @@ -74,8 +76,8 @@ export class SearchCompatibleDataprovidersTableComponent { private _getResults(){ //this.csvParams = this.resourcesQuery+"&type=datasources"; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.disableForms = true; this.results = []; this.searchUtils.totalResults = 0; @@ -93,10 +95,10 @@ export class SearchCompatibleDataprovidersTableComponent { this.searchPage.checkSelectedFilters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } this.disableForms = false; }, @@ -106,8 +108,16 @@ export class SearchCompatibleDataprovidersTableComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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.disableForms = false; } @@ -115,8 +125,8 @@ export class SearchCompatibleDataprovidersTableComponent { } else { this.searchPage.checkSelectedFilters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.NONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.NONE; this.disableForms = false; } }, @@ -126,8 +136,15 @@ export class SearchCompatibleDataprovidersTableComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts index ba082d12..d3652b04 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts @@ -30,6 +30,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; }) export class SearchEntityRegistriesComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public baseUrl:string; @@ -55,8 +57,8 @@ export class SearchEntityRegistriesComponent { public csvParams: string; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchEntityRegistries(); for(var i = 0; i < this._prefixQueryFields.length; i++ ){ for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ @@ -91,8 +93,8 @@ export class SearchEntityRegistriesComponent { private _getResults(parameters:string,refine:boolean, page: number, size: number){ this.csvParams = parameters+this.resourcesQuery+"&type=datasources"; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -105,10 +107,10 @@ export class SearchEntityRegistriesComponent { this.results = data[1]; this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; @@ -120,8 +122,16 @@ export class SearchEntityRegistriesComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts index 255cab62..c4c5a453 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts @@ -28,6 +28,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; }) export class SearchEntityRegistriesTableComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public baseUrl:string; @@ -41,8 +43,8 @@ export class SearchEntityRegistriesTableComponent { @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; } public ngOnInit() { @@ -65,8 +67,8 @@ export class SearchEntityRegistriesTableComponent { this.subResults.unsubscribe(); } } private _getResults(parameters:string,refine:boolean, page: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.disableForms = true; this.results = []; this.searchUtils.totalResults = 0; @@ -83,10 +85,10 @@ export class SearchEntityRegistriesTableComponent { this.results = data[1]; this.searchPage.checkSelectedFilters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } this.disableForms = false; @@ -97,8 +99,16 @@ export class SearchEntityRegistriesTableComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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.disableForms = false; } @@ -106,8 +116,8 @@ export class SearchEntityRegistriesTableComponent { } else { this.searchPage.checkSelectedFilters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.NONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.NONE; this.disableForms = false; } }, @@ -117,8 +127,15 @@ export class SearchEntityRegistriesTableComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); /* diff --git a/portal-2/src/app/searchPages/dataProviders/journals.component.ts b/portal-2/src/app/searchPages/dataProviders/journals.component.ts index b9f2dbcd..265d0126 100644 --- a/portal-2/src/app/searchPages/dataProviders/journals.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/journals.component.ts @@ -29,6 +29,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; }) export class SearchJournalsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public baseUrl:string; @@ -54,8 +56,8 @@ export class SearchJournalsComponent { @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchJournals(); for(var i = 0; i < this._prefixQueryFields.length; i++ ){ for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ @@ -90,8 +92,8 @@ export class SearchJournalsComponent { private _getResults(parameters:string,refine:boolean, page: number, size: number){ this.csvParams = parameters+this.resourcesQuery+"&type=datasources"; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -104,10 +106,10 @@ export class SearchJournalsComponent { this.results = data[1]; this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; @@ -119,8 +121,16 @@ export class SearchJournalsComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; diff --git a/portal-2/src/app/searchPages/dataProviders/journalsTable.component.ts b/portal-2/src/app/searchPages/dataProviders/journalsTable.component.ts index 15000828..4322a268 100644 --- a/portal-2/src/app/searchPages/dataProviders/journalsTable.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/journalsTable.component.ts @@ -27,6 +27,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; }) export class SearchJournalsTableComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public baseUrl:string; @@ -48,8 +50,8 @@ export class SearchJournalsTableComponent { @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchJournalsTable(); } @@ -74,8 +76,8 @@ export class SearchJournalsTableComponent { private _getResults(){ //this.csvParams = this.resourcesQuery+"&type=datasources"; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.disableForms = true; this.results = []; this.searchUtils.totalResults = 0; @@ -93,10 +95,10 @@ export class SearchJournalsTableComponent { this.searchPage.checkSelectedFilters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } this.disableForms = false; }, @@ -106,8 +108,16 @@ export class SearchJournalsTableComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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.disableForms = false; } @@ -115,8 +125,8 @@ export class SearchJournalsTableComponent { } else { this.searchPage.checkSelectedFilters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.NONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.NONE; this.disableForms = false; } }, @@ -126,8 +136,15 @@ export class SearchJournalsTableComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); diff --git a/portal-2/src/app/searchPages/find/search.component.ts b/portal-2/src/app/searchPages/find/search.component.ts index 4d70c9c3..4a01101e 100644 --- a/portal-2/src/app/searchPages/find/search.component.ts +++ b/portal-2/src/app/searchPages/find/search.component.ts @@ -142,8 +142,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; public searchPublications() { this.activeTab = "publications"; if( this.reloadPublications && - this.fetchPublications.searchUtils.status != this.errorCodes.NONE && - this.fetchPublications.searchUtils.status != this.errorCodes.ERROR) { + ( this.fetchPublications.searchUtils.status == this.errorCodes.LOADING || + this.fetchPublications.searchUtils.status == this.errorCodes.DONE )) { this.reloadPublications = false; this.fetchPublications.getResultsByKeyword(this.keyword, 1, 10); this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications();// + "?keyword=" + this.keyword; @@ -152,8 +152,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; public searchDatasets() { this.activeTab = "research data"; if(this.reloadDatasets && - this.fetchDatasets.searchUtils.status != this.errorCodes.NONE && - this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR) { + ( this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING || + this.fetchDatasets.searchUtils.status == this.errorCodes.DONE )) { this.reloadDatasets = false; this.fetchDatasets.getResultsByKeyword(this.keyword, 1, 10); this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets();// + "?keyword=" + this.keyword; @@ -163,8 +163,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; this.activeTab = "projects"; console.log("searchProjects"); if(this.reloadProjects && - this.fetchProjects.searchUtils.status != this.errorCodes.NONE && - this.fetchProjects.searchUtils.status != this.errorCodes.ERROR) { + ( this.fetchProjects.searchUtils.status == this.errorCodes.LOADING || + this.fetchProjects.searchUtils.status == this.errorCodes.DONE )) { this.reloadProjects = false; console.log("do the search searchProjects"); @@ -175,8 +175,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; public searchDataProviders() { this.activeTab = "content providers"; if( this.reloadDataproviders && - this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE && - this.fetchDataproviders.searchUtils.status != this.errorCodes.ERROR) { + ( this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING || + this.fetchDataproviders.searchUtils.status == this.errorCodes.DONE )) { this.reloadDataproviders = false; this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10); this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();// + "?keyword=" + this.keyword; @@ -185,8 +185,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; public searchOrganizations() { this.activeTab = "organizations"; if( this.reloadOrganizations && - this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE && - this.fetchOrganizations.searchUtils.status != this.errorCodes.ERROR) { + ( this.fetchOrganizations.searchUtils.status == this.errorCodes.LOADING || + this.fetchOrganizations.searchUtils.status == this.errorCodes.DONE )) { this.reloadOrganizations = false; this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10); this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations();// + "?keyword=" + this.keyword; @@ -234,7 +234,14 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; }, err => { console.log(err); - this.fetchPublications.searchUtils.status = this.errorCodes.ERROR; + if(err.status == '404') { + this.fetchPublications.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.fetchPublications.searchUtils.status = this.errorCodes.ERROR; + } else { + this.fetchPublications.searchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + //this.fetchPublications.searchUtils.status = this.errorCodes.ERROR; } ); } @@ -251,7 +258,14 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; }, err => { console.log(err); - this.fetchDatasets.searchUtils.status = this.errorCodes.ERROR; + if(err.status == '404') { + this.fetchDatasets.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.fetchDatasets.searchUtils.status = this.errorCodes.ERROR; + } else { + this.fetchDatasets.searchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + //this.fetchDatasets.searchUtils.status = this.errorCodes.ERROR; } ); } @@ -268,7 +282,14 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; }, err => { console.log(err); - this.fetchProjects.searchUtils.status = this.errorCodes.ERROR; + if(err.status == '404') { + this.fetchProjects.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.fetchProjects.searchUtils.status = this.errorCodes.ERROR; + } else { + this.fetchProjects.searchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + //this.fetchProjects.searchUtils.status = this.errorCodes.ERROR; } ); } @@ -289,7 +310,14 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr; }, err => { console.log(err); - this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR; + if(err.status == '404') { + this.fetchOrganizations.searchUtils.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR; + } else { + this.fetchOrganizations.searchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + //this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR; } ); diff --git a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.html b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.html index ef3cddc7..fcae0007 100644 --- a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.html +++ b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.html @@ -21,7 +21,7 @@
- +
diff --git a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts index e4ebe4de..14acacef 100644 --- a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts @@ -14,7 +14,7 @@ import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'advanced-search-page', - templateUrl: 'advancedSearchPage.component.html' + templateUrl: 'advancedSearchPage.component.html' }) export class AdvancedSearchPageComponent { @Input() pageTitle = ""; @@ -31,6 +31,9 @@ export class AdvancedSearchPageComponent { @Input() csvPath: string; @Input() simpleSearchLink: string = ""; @Input() disableForms:boolean = false; + @Input() loadPaging: boolean = true; + @Input() oldTotalResults: number = 0; + piwiksub: any; public parameterNames:string[] =[]; public parameterValues:string[] =[]; diff --git a/portal-2/src/app/searchPages/searchUtils/browseEntities.component.ts b/portal-2/src/app/searchPages/searchUtils/browseEntities.component.ts index 767fea1f..e8285021 100644 --- a/portal-2/src/app/searchPages/searchUtils/browseEntities.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/browseEntities.component.ts @@ -14,10 +14,12 @@ import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; selector: 'browse-entities', template: `
- + +
@@ -81,7 +83,14 @@ private getStats(){ // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - this.status = this.errorCodes.ERROR; + //this.status = this.errorCodes.ERROR; + if(err.status == '404') { + this.status = this.errorCodes.NOT_FOUND; + } else if(err.status == '500') { + this.status = this.errorCodes.ERROR; + } else { + this.status = this.errorCodes.NOT_AVAILABLE; + } } ); } diff --git a/portal-2/src/app/searchPages/searchUtils/browseEntities.module.ts b/portal-2/src/app/searchPages/searchUtils/browseEntities.module.ts index 163cb7dd..2d8d3cda 100644 --- a/portal-2/src/app/searchPages/searchUtils/browseEntities.module.ts +++ b/portal-2/src/app/searchPages/searchUtils/browseEntities.module.ts @@ -8,10 +8,11 @@ import {RefineFieldResultsServiceModule} from '../../services/refineFieldResults import {BrowseEntitiesComponent} from './browseEntities.component'; import {BrowseStatisticComponent} from './browseStatistic.component'; +import {ErrorMessagesModule} from '../../utils/errorMessages.module'; @NgModule({ imports: [ - CommonModule, FormsModule, + CommonModule, FormsModule, ErrorMessagesModule, RefineFieldResultsServiceModule, RouterModule ], declarations: [ diff --git a/portal-2/src/app/searchPages/searchUtils/searchDownload.component.ts b/portal-2/src/app/searchPages/searchUtils/searchDownload.component.ts index 8814c41c..383b9e90 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchDownload.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchDownload.component.ts @@ -9,7 +9,7 @@ import {PiwikService} from '../../utils/piwik/piwik.service'; @Component({ selector: 'search-download', template: ` - + (CSV) diff --git a/portal-2/src/app/searchPages/searchUtils/searchPage.component.html b/portal-2/src/app/searchPages/searchUtils/searchPage.component.html index a992d6bf..55e3188c 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPage.component.html +++ b/portal-2/src/app/searchPages/searchUtils/searchPage.component.html @@ -1,66 +1,66 @@
-
-
+
+
-
- diff --git a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts index 293b2afe..55bba1ef 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts @@ -40,6 +40,8 @@ export class SearchPageComponent { @Input() advancedSearchLink: string = ""; @Input() tableViewLink: string; @Input() disableForms: boolean = false; + @Input() loadPaging: boolean = true; + @Input() oldTotalResults: number = 0; @Input() tableView: boolean = false; @Input() searchFormClass: string = "searchForm"; @ViewChild (ModalLoading) loading : ModalLoading ; @@ -118,12 +120,15 @@ export class SearchPageComponent { public getQueryParametersFromUrl(params){ // var parameters = ""; var allFqs = ""; + this.queryParameters = new Map(); + for(var i=0; i< this.refineFields.length ; i++){ var filterId = this.refineFields[i]; if(params[filterId] != undefined) { this.queryParameters[filterId]=StringUtils.URIDecode(params[filterId]); + let values = (StringUtils.URIDecode(this.queryParameters[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); var countvalues = 0; var fq = ""; @@ -138,8 +143,6 @@ export class SearchPageComponent { } allFqs += fq; } - - } var keyword = params['keyword']; var doiQuery = ""; diff --git a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.component.html b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.component.html index e97596f2..c6c09370 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.component.html +++ b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.component.html @@ -32,12 +32,14 @@
- + + +
@@ -55,18 +57,18 @@
-
+
-
+
- @@ -155,9 +147,17 @@
+
{{searchUtils.totalResults}} content providers, page {{searchUtils.page}} of {{(totalPages())}} @@ -75,16 +77,6 @@ -
-

- - - - - - -

-
- -
+
+

+ + + + + + +

+
diff --git a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts index 86de5549..2586914e 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts @@ -23,11 +23,13 @@ import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; import {HelperModule} from '../../utils/helper/helper.module'; +import {ErrorMessagesModule} from '../../utils/errorMessages.module'; @NgModule({ imports: [ CommonModule, FormsModule,RouterModule, SearchFormModule, SearchResultsModule, LoadingModalModule, - ReportsServiceModule, SearchPagingModule, SearchDownloadModule, ModalModule, PagingModule, DataTableModule, SearchFilterModule, PiwikServiceModule, HelperModule + ReportsServiceModule, SearchPagingModule, SearchDownloadModule, ModalModule, PagingModule, + DataTableModule, SearchFilterModule, PiwikServiceModule, HelperModule, ErrorMessagesModule ], declarations: [ SearchPageTableViewComponent//, diff --git a/portal-2/src/app/searchPages/searchUtils/searchPaging.component.ts b/portal-2/src/app/searchPages/searchUtils/searchPaging.component.ts index 1f8b4a64..a3ca6a6b 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPaging.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPaging.component.ts @@ -1,15 +1,22 @@ import {Component, Input, Output, EventEmitter} from '@angular/core'; import {Observable} from 'rxjs/Observable'; +import {ErrorCodes} from '../../utils/properties/openaireProperties'; @Component({ selector: 'search-paging', template: ` -
-
- {{searchUtils.totalResults}} {{type}}, page {{searchUtils.page}} of {{(totalPages())}} +
+
+ {{searchUtils.totalResults}} {{type}}, page {{searchUtils.page}} of {{(totalPages(searchUtils.totalResults))}}
-
- +
+ {{oldTotalResults}} {{type}}, page {{searchUtils.page}} of {{(totalPages(oldTotalResults))}} +
+
+ +
+
+
` @@ -23,16 +30,24 @@ export class SearchPagingComponent { @Input() parameterNames:string[]; @Input() parameterValues:string[]; + @Input() loadPaging: boolean = true; + @Input() oldTotalResults: number = 0; + + public totalResults: number = 0; + public errorCodes:ErrorCodes = new ErrorCodes(); + // @Input() totalResults:number = 0; - constructor () { - } + constructor () {} ngOnInit() { - + // this.totalResults = this.searchUtils.totalResults; + // if(!this.loadPaging && this.totalResults == 0) { + // this.totalResults = this.oldTotalResults; + // } } - totalPages(): number { - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); + totalPages(totalResults: number): number { + let totalPages:any = totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { totalPages = (parseInt(totalPages, 10) + 1); } diff --git a/portal-2/src/app/searchPages/searchUtils/searchResult.component.html b/portal-2/src/app/searchPages/searchUtils/searchResult.component.html index 8a0ebbf8..4d408432 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchResult.component.html +++ b/portal-2/src/app/searchPages/searchUtils/searchResult.component.html @@ -1,10 +1,11 @@
    - + +
  • diff --git a/portal-2/src/app/searchPages/searchUtils/searchResults.module.ts b/portal-2/src/app/searchPages/searchUtils/searchResults.module.ts index 9c85670c..0ca38971 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchResults.module.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchResults.module.ts @@ -1,15 +1,17 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; -import {SearchResult} from '../../utils/entities/searchResult'; -import {SearchResultComponent} from './searchResult.component'; -import { RouterModule } from '@angular/router'; +import {ErrorMessagesModule} from '../../utils/errorMessages.module'; + +import {SearchResult} from '../../utils/entities/searchResult'; +import {SearchResultComponent} from './searchResult.component'; @NgModule({ imports: [ CommonModule, FormsModule, - RouterModule + RouterModule, ErrorMessagesModule ], declarations: [ SearchResultComponent, diff --git a/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts b/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts index 1b0da1cd..8e57cd16 100644 --- a/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts +++ b/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts @@ -20,12 +20,16 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="datasources" advancedSearchLink="/search/advanced/dataproviders" [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults" searchFormClass="datasourcesSearchForm"> ` }) export class SearchDataprovidersComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public totalResults:number = 0 ; @@ -35,7 +39,7 @@ export class SearchDataprovidersComponent { public _location:Location; public searchFields:SearchFields = new SearchFields(); public refineFields: string[] = this.searchFields.DATASOURCE_REFINE_FIELDS; - public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; + public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], "export":[] }; @@ -43,12 +47,14 @@ export class SearchDataprovidersComponent { public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders(); } @@ -59,17 +65,22 @@ export class SearchDataprovidersComponent { var firstLoad =true; this.sub = this.route.queryParams.subscribe(params => { - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - var refine = true; - if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ - refine = false; + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } - } - firstLoad = false; - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + var refine = true; + if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ + refine = false; - var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); + } + firstLoad = false; + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); }); } @@ -83,8 +94,8 @@ export class SearchDataprovidersComponent { } public getNumForEntity(entity: string, id:string) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; if(id != "" && entity != "") { @@ -92,10 +103,10 @@ export class SearchDataprovidersComponent { data => { this.searchUtils.totalResults = data; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -104,25 +115,33 @@ export class SearchDataprovidersComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + + 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; + } } ); } } public getNumForSearch(keyword: string) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this._searchDataprovidersService.numOfDataproviders(keyword).subscribe( data => { this.searchUtils.totalResults = data; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -131,8 +150,15 @@ export class SearchDataprovidersComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } @@ -148,10 +174,10 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) console.info("search Dataproviders forDeposit: [id:"+id+", type:"+type+" ] [total results:"+this.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -160,8 +186,15 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } @@ -181,10 +214,10 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -193,8 +226,15 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } @@ -208,10 +248,10 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) console.info("search Dataproviders for Entity Registry: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -220,8 +260,15 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } @@ -239,8 +286,8 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) // if(!refine && !this.searchPage){ // this.searchPage = new SearchPageComponent(this._location); // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; @@ -258,15 +305,15 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) this.searchPage.checkSelectedFilters(this.filters); // this.filters = this.searchPage.checkSelectedFilters(data[2]); this.searchPage.updateBaseUrlWithParameters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -274,7 +321,7 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -284,8 +331,16 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; } @@ -297,6 +352,8 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) } public queryChanged($event) { + this.loadPaging = true; + var parameters = $event.value; this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); } diff --git a/portal-2/src/app/searchPages/simple/searchDatasets.component.ts b/portal-2/src/app/searchPages/simple/searchDatasets.component.ts index 5a335f16..60a8099a 100644 --- a/portal-2/src/app/searchPages/simple/searchDatasets.component.ts +++ b/portal-2/src/app/searchPages/simple/searchDatasets.component.ts @@ -22,12 +22,16 @@ import {DOI} from '../../utils/string-utils.class'; [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="datasets" advancedSearchLink="/search/advanced/datasets" [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults" searchFormClass="datasetsSearchForm"> ` }) export class SearchDatasetsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters: Filter[] =[]; // public totalResults:number = 0 ; @@ -43,12 +47,14 @@ export class SearchDatasetsComponent { private _location:Location; public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; this.baseUrl = OpenaireProperties.getLinkToSearchDatasets(); @@ -60,6 +66,11 @@ export class SearchDatasetsComponent { this.searchPage.type = "research data"; var firstLoad =true; this.sub = this.route.queryParams.subscribe(params => { + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); var refine = true; if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ @@ -99,10 +110,10 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) console.info("search Research Data for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -111,8 +122,15 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } @@ -134,10 +152,10 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s console.info("search Research Data for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -146,8 +164,15 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } @@ -175,8 +200,8 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number // if(!refine && !this.searchPage){ // this.searchPage = new SearchPageComponent(this._location); // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -192,15 +217,15 @@ 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.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -208,7 +233,7 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -218,8 +243,16 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; } @@ -233,6 +266,8 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } public queryChanged($event) { + this.loadPaging = true; + var parameters = $event.value; //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/simple/searchOrganizations.component.ts b/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts index e28cca90..12c5d7ec 100644 --- a/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts +++ b/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts @@ -20,6 +20,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="organizations" advancedSearchLink="/search/advanced/organizations" [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults" searchFormClass="organizationsSearchForm"> @@ -27,6 +29,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; }) export class SearchOrganizationsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public baseUrl:string; @@ -40,13 +44,15 @@ export class SearchOrganizationsComponent { public _location:Location; public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; this.baseUrl = OpenaireProperties.getLinkToSearchOrganizations(); @@ -57,6 +63,11 @@ export class SearchOrganizationsComponent { this.searchPage.fieldIdsMap = this.fieldIdsMap; var firstLoad = true; this.sub = this.route.queryParams.subscribe(params => { + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); var refine = true; if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ @@ -94,8 +105,8 @@ export class SearchOrganizationsComponent { // if(!refine && !this.searchPage){ // this.searchPage = new SearchPageComponent(this._location); // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -111,15 +122,15 @@ export class SearchOrganizationsComponent { } this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -127,7 +138,7 @@ export class SearchOrganizationsComponent { } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -137,8 +148,16 @@ export class SearchOrganizationsComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; } @@ -147,6 +166,8 @@ export class SearchOrganizationsComponent { public queryChanged($event) { + this.loadPaging = true; + var parameters = $event.value; console.info("queryChanged: Execute search query "+parameters); this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); diff --git a/portal-2/src/app/searchPages/simple/searchProjects.component.ts b/portal-2/src/app/searchPages/simple/searchProjects.component.ts index 8b80ae3b..0c7bbb5f 100644 --- a/portal-2/src/app/searchPages/simple/searchProjects.component.ts +++ b/portal-2/src/app/searchPages/simple/searchProjects.component.ts @@ -20,12 +20,16 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" [csvParams]="csvParams" csvPath="projects" advancedSearchLink="/search/advanced/projects" [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults" searchFormClass="projectsSearchForm"> ` }) export class SearchProjectsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters: Filter[] =[]; public baseUrl:string; @@ -39,14 +43,16 @@ export class SearchProjectsComponent { public _location:Location; public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService) { console.info(" constructor SearchProjectsComponent "+this.refineFields.length); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; this.baseUrl = OpenaireProperties.getLinkToSearchProjects(); @@ -59,19 +65,23 @@ export class SearchProjectsComponent { //get refine field filters from url parameters var firstLoad = true; this.sub = this.route.queryParams.subscribe(params => { + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } - //get keyword from url parameters - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - var refine = true; - if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ - refine = false; + //get keyword from url parameters + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + var refine = true; + if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ + refine = false; - } - firstLoad = false; - //get page from url parameters - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); + } + firstLoad = false; + //get page from url parameters + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); }); } @@ -98,8 +108,8 @@ export class SearchProjectsComponent { // this.searchPage = new SearchPageComponent(this._location); // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -116,15 +126,15 @@ export class SearchProjectsComponent { this.searchPage.checkSelectedFilters(this.filters); // this.filters = this.searchPage.checkSelectedFilters(data[2]); this.searchPage.updateBaseUrlWithParameters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -132,7 +142,7 @@ export class SearchProjectsComponent { } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -142,8 +152,16 @@ export class SearchProjectsComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; } @@ -158,10 +176,10 @@ export class SearchProjectsComponent { console.info("search Projects for Dataproviders: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -170,14 +188,23 @@ export class SearchProjectsComponent { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } public queryChanged($event) { + this.loadPaging = true; + this.urlParams = undefined; var parameters = $event.value; this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); diff --git a/portal-2/src/app/searchPages/simple/searchPublications.component.ts b/portal-2/src/app/searchPages/simple/searchPublications.component.ts index 466c38f0..2d667f14 100644 --- a/portal-2/src/app/searchPages/simple/searchPublications.component.ts +++ b/portal-2/src/app/searchPages/simple/searchPublications.component.ts @@ -25,6 +25,8 @@ import {DOI} from '../../utils/string-utils.class'; [csvParams]="csvParams" csvPath="publications" advancedSearchLink="/search/advanced/publications" [disableForms]="disableForms" + [loadPaging]="loadPaging" + [oldTotalResults]="oldTotalResults" searchFormClass="publicationsSearchForm"> @@ -32,6 +34,8 @@ import {DOI} from '../../utils/string-utils.class'; }) export class SearchPublicationsComponent { + private errorCodes: ErrorCodes; + public results =[]; public filters =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); @@ -54,10 +58,12 @@ export class SearchPublicationsComponent { public CSVDownloaded = false; public csvParams: string; public disableForms: boolean = false; + public loadPaging: boolean = true; + public oldTotalResults: number = 0; constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.page =1; this.baseUrl = OpenaireProperties.getLinkToSearchPublications(); @@ -69,6 +75,11 @@ export class SearchPublicationsComponent { this.searchPage.type = "publications"; var firstLoad =true; this.sub = this.route.queryParams.subscribe(params => { + if(params['page'] && this.searchUtils.page != params['page']) { + this.loadPaging = false; + this.oldTotalResults = this.searchUtils.totalResults; + } + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); var refine = true; if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ @@ -106,10 +117,10 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) console.info("search Publications for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -118,8 +129,15 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } @@ -141,10 +159,10 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s console.info("search Publications for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -153,8 +171,15 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } @@ -185,8 +210,8 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number // this.searchPage = new SearchPageComponent(this._location); // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; //this.searchPage.openLoading(); this.disableForms = true; this.results = []; @@ -203,16 +228,16 @@ 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(); + //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } //this.searchPage.closeLoading(); this.disableForms = false; - if(this.searchUtils.status == errorCodes.DONE) { + if(this.searchUtils.status == this.errorCodes.DONE) { // Page out of limit!!! let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); if(!(Number.isInteger(totalPages))) { @@ -220,7 +245,7 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } if(totalPages < page) { this.searchUtils.totalResults = 0; - this.searchUtils.status = errorCodes.OUT_OF_BOUND; + this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; } } }, @@ -230,8 +255,16 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; @@ -263,6 +296,8 @@ public getAggregatorResults(id:string, page: number, size: number){ }*/ public queryChanged($event) { + this.loadPaging = true; + var parameters = $event.value; console.info("queryChanged: Execute search query "+parameters); console.info("Search Pubs::page "+this.searchUtils.page); diff --git a/portal-2/src/app/services/searchDatasets.service.ts b/portal-2/src/app/services/searchDatasets.service.ts index 3e203c20..df5910de 100644 --- a/portal-2/src/app/services/searchDatasets.service.ts +++ b/portal-2/src/app/services/searchDatasets.service.ts @@ -78,7 +78,7 @@ export class SearchDatasetsService { .do(res => { this._cache.set(key, res); }) - .map(res => this.parseRefineResults(id, res['refineResults'])); + .map(res => this.parseRefineResults(id, res['refineResults'])) } searchDatasetsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[] ):any { diff --git a/portal-2/src/app/utils/errorMessages.component.ts b/portal-2/src/app/utils/errorMessages.component.ts new file mode 100644 index 00000000..aeb43d66 --- /dev/null +++ b/portal-2/src/app/utils/errorMessages.component.ts @@ -0,0 +1,51 @@ +import {Component, Input} from '@angular/core'; +import {ErrorCodes} from './properties/openaireProperties'; + +@Component({ + selector: 'errorMessages', + template: ` + + + + + + + ` + }) + + export class ErrorMessagesComponent { + @Input() status: Array; + @Input() type: string; + + public errorCodes:ErrorCodes; + + constructor () {} + + ngOnInit() { + this.errorCodes = new ErrorCodes(); + console.info("ngOnInit"); + if(!this.status) { + this.status = [this.errorCodes.LOADING]; + } + } + + ngOnDestroy() {} + + public checkErroCode(code: number) { + return function(status: number) { + return (status == code); + } + } + } diff --git a/portal-2/src/app/utils/errorMessages.module.ts b/portal-2/src/app/utils/errorMessages.module.ts new file mode 100644 index 00000000..9f7315af --- /dev/null +++ b/portal-2/src/app/utils/errorMessages.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {ErrorMessagesComponent} from './errorMessages.component'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ErrorMessagesComponent + ], + exports: [ + ErrorMessagesComponent + ] +}) +export class ErrorMessagesModule { } diff --git a/portal-2/src/app/utils/fetchEntitiesClasses/fetchDataproviders.class.ts b/portal-2/src/app/utils/fetchEntitiesClasses/fetchDataproviders.class.ts index 3bc41131..1ef9125c 100644 --- a/portal-2/src/app/utils/fetchEntitiesClasses/fetchDataproviders.class.ts +++ b/portal-2/src/app/utils/fetchEntitiesClasses/fetchDataproviders.class.ts @@ -3,6 +3,8 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties'; import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class'; export class FetchDataproviders { + private errorCodes: ErrorCodes; + public results =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); public sub: any; public subResults: any; @@ -14,8 +16,8 @@ export class FetchDataproviders { constructor ( private _searchDataprovidersService: SearchDataprovidersService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; } @@ -34,8 +36,8 @@ export class FetchDataproviders { parameters = "q=" + keyword; } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.subResults = this._searchDataprovidersService.searchDataproviders(parameters,null, page, size,[]).subscribe( @@ -44,10 +46,10 @@ export class FetchDataproviders { console.info("search Content Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //ar errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -56,15 +58,22 @@ export class FetchDataproviders { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } public getNumForEntity(entity: string, id:string) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; if(id != "" && entity != "") { @@ -72,10 +81,10 @@ export class FetchDataproviders { data => { this.searchUtils.totalResults = data; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -84,24 +93,31 @@ export class FetchDataproviders { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } } public getNumForSearch(keyword: string) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this._searchDataprovidersService.numOfSearchDataproviders(keyword).subscribe( data => { this.searchUtils.totalResults = data; - this.searchUtils.status = errorCodes.DONE; + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0) { - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -110,15 +126,22 @@ export class FetchDataproviders { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } public getResultsForDeposit(id:string, type:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; if(id != "") { @@ -128,10 +151,10 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) console.info("search Dataproviders forDeposit: [id:"+id+", type:"+type+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -140,25 +163,32 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } } public getResultsBySubjectsForDeposit(subject:string, type:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this._searchDataprovidersService.searchDataProvidersBySubjects(subject,type, page, size).subscribe( data => { this.searchUtils.totalResults = data[0]; console.info("search Dataproviders forDeposit: [subject:"+subject+", type:"+type+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -167,15 +197,22 @@ public getResultsBySubjectsForDeposit(subject:string, type:string, page: number, // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } public getResultsForEntity(entity:string, id:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; var parameters = ""; @@ -191,10 +228,10 @@ public getResultsBySubjectsForDeposit(subject:string, type:string, page: number, console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -203,16 +240,23 @@ public getResultsBySubjectsForDeposit(subject:string, type:string, page: number, // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } } public getResultsForDataproviders(id:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this._searchDataprovidersService.getDataProvidersforEntityRegistry(id, page, size).subscribe( data => { @@ -220,10 +264,10 @@ public getResultsBySubjectsForDeposit(subject:string, type:string, page: number, console.info("search Dataproviders for Entity Registry: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -232,8 +276,15 @@ public getResultsBySubjectsForDeposit(subject:string, type:string, page: number, // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } diff --git a/portal-2/src/app/utils/fetchEntitiesClasses/fetchDatasets.class.ts b/portal-2/src/app/utils/fetchEntitiesClasses/fetchDatasets.class.ts index d6d65727..9e6916b6 100644 --- a/portal-2/src/app/utils/fetchEntitiesClasses/fetchDatasets.class.ts +++ b/portal-2/src/app/utils/fetchEntitiesClasses/fetchDatasets.class.ts @@ -5,6 +5,8 @@ import {DOI} from '../../utils/string-utils.class'; import {Subject} from 'rxjs/Subject'; export class FetchDatasets{ + private errorCodes: ErrorCodes; + public results =[]; public requestComplete: Subject; @@ -16,8 +18,8 @@ export class FetchDatasets{ constructor ( private _searchDatasetsService: SearchDatasetsService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.requestComplete = new Subject(); } @@ -50,8 +52,8 @@ export class FetchDatasets{ } } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.subResults = this._searchDatasetsService.searchDatasets(parameters,null, page, size, []).subscribe( data => { @@ -59,10 +61,10 @@ export class FetchDatasets{ console.info("search Research Data: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -71,15 +73,22 @@ export class FetchDatasets{ // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } public getNumForEntity(entity:string, id:string){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; if(id != "" && entity != "") { @@ -87,10 +96,10 @@ public getNumForEntity(entity:string, id:string){ data => { this.searchUtils.totalResults = data; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -99,16 +108,23 @@ public getNumForEntity(entity:string, id:string){ // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } } public getResultsForEntity(entity:string, id:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; var parameters = ""; @@ -124,10 +140,10 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) console.info("search Research Data for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -136,16 +152,23 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } } public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; var parameters; if(resultsFrom == "collectedFrom") { @@ -162,10 +185,10 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s console.info("search Research Data for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -174,39 +197,55 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } } public getAggregatorResults(id:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.subResults = this._searchDatasetsService.searchAggregators(id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size).subscribe( data => { this.results = data; this.searchUtils.totalResults = this.results.length; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } this.requestComplete.complete(); }, err => { - this.requestComplete.complete(); console.log(err); + console.info("status: "+err.status); //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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.requestComplete.complete(); } ); } diff --git a/portal-2/src/app/utils/fetchEntitiesClasses/fetchOrganizations.class.ts b/portal-2/src/app/utils/fetchEntitiesClasses/fetchOrganizations.class.ts index 0124ce01..07cb4c61 100644 --- a/portal-2/src/app/utils/fetchEntitiesClasses/fetchOrganizations.class.ts +++ b/portal-2/src/app/utils/fetchEntitiesClasses/fetchOrganizations.class.ts @@ -3,6 +3,8 @@ import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class'; export class FetchOrganizations { + private errorCodes: ErrorCodes; + public results =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); @@ -13,8 +15,8 @@ export class FetchOrganizations { constructor ( private _searchOrganizationsService: SearchOrganizationsService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; } @@ -35,8 +37,8 @@ export class FetchOrganizations { parameters = "q=" + keyword; } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.subResults = this._searchOrganizationsService.searchOrganizations(parameters, null, page, size, []).subscribe( data => { @@ -44,10 +46,10 @@ export class FetchOrganizations { console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -56,8 +58,16 @@ export class FetchOrganizations { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + + 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; + } } ); } diff --git a/portal-2/src/app/utils/fetchEntitiesClasses/fetchProjects.class.ts b/portal-2/src/app/utils/fetchEntitiesClasses/fetchProjects.class.ts index 1c0214ee..d31a3232 100644 --- a/portal-2/src/app/utils/fetchEntitiesClasses/fetchProjects.class.ts +++ b/portal-2/src/app/utils/fetchEntitiesClasses/fetchProjects.class.ts @@ -3,6 +3,8 @@ import {ErrorCodes} from '../../utils/properties/openaireProperties'; import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class'; export class FetchProjects{ + private errorCodes: ErrorCodes; + public results =[]; public filters; // for getResultsForOrganizations @@ -14,8 +16,8 @@ export class FetchProjects{ constructor (private _searchProjectsService: SearchProjectsService) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; } @@ -34,8 +36,8 @@ export class FetchProjects{ parameters = "q=" + keyword; } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, []).subscribe( data => { @@ -43,10 +45,10 @@ export class FetchProjects{ console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -55,15 +57,22 @@ export class FetchProjects{ // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } public getResultsForDataproviders(id:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this._searchProjectsService.getProjectsforDataProvider(id, page, size).subscribe( data => { @@ -71,10 +80,10 @@ export class FetchProjects{ console.info("search Projects for Dataproviders: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -83,15 +92,22 @@ export class FetchProjects{ // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } public getNumForEntity(entity: string, id:string) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; if(id != "" && entity != "") { @@ -99,10 +115,10 @@ export class FetchProjects{ data => { this.searchUtils.totalResults = data; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -111,16 +127,24 @@ export class FetchProjects{ // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + + 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; + } } ); } } public getResultsForOrganizations(organizationId:string, filterquery:string, page: number, size: number, refineFields:string[]){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this._searchProjectsService.getProjectsForOrganizations(organizationId,filterquery, page, size,refineFields).subscribe( data => { @@ -156,10 +180,10 @@ export class FetchProjects{ console.log(" this.funders:"+ this.funders); } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -168,8 +192,15 @@ export class FetchProjects{ // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } diff --git a/portal-2/src/app/utils/fetchEntitiesClasses/fetchPublications.class.ts b/portal-2/src/app/utils/fetchEntitiesClasses/fetchPublications.class.ts index e46b08e8..9e6959f1 100644 --- a/portal-2/src/app/utils/fetchEntitiesClasses/fetchPublications.class.ts +++ b/portal-2/src/app/utils/fetchEntitiesClasses/fetchPublications.class.ts @@ -7,6 +7,8 @@ import {DOI} from '../../utils/string-utils.class'; import {Subject} from 'rxjs/Subject'; export class FetchPublications { + private errorCodes: ErrorCodes; + public results =[]; public requestComplete: Subject; @@ -30,8 +32,8 @@ export class FetchPublications { public csvParams: string; constructor ( private _searchPublicationsService: SearchPublicationsService ) { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status =errorCodes.LOADING; + this.errorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; // this.baseUrl = OpenaireProperties.getLinkToSearchPublications(); this.requestComplete = new Subject(); @@ -64,8 +66,8 @@ export class FetchPublications { } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.subResults = this._searchPublicationsService.searchPublications(parameters,null, page, size, []).subscribe( data => { @@ -73,10 +75,10 @@ export class FetchPublications { console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -85,16 +87,22 @@ export class FetchPublications { // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; - + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } public getResultsForEntity(entity:string, id:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; var parameters = ""; if(entity == "project") { @@ -111,10 +119,10 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) console.info("search Publications for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -123,16 +131,24 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + + 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; + } } ); } } public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; var parameters; if(resultsFrom == "collectedFrom") { @@ -149,10 +165,10 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s console.info("search Publications for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } }, err => { @@ -161,39 +177,54 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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; + } } ); } } public getAggregatorResults(id:string, page: number, size: number){ - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.LOADING; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.LOADING; this.subResults = this._searchPublicationsService.searchAggregators(id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size).subscribe( data => { this.results = data; this.searchUtils.totalResults = this.results.length; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; + //var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; + this.searchUtils.status = this.errorCodes.NONE; } this.requestComplete.complete(); }, err => { - this.requestComplete.complete(); console.log(err); //TODO check erros (service not available, bad request) // if( ){ // this.searchUtils.status = ErrorCodes.ERROR; // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.searchUtils.status = errorCodes.ERROR; + 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.requestComplete.complete(); } ); } diff --git a/portal-2/src/app/utils/properties/openaireProperties.ts b/portal-2/src/app/utils/properties/openaireProperties.ts index 3df9808e..fc500c65 100644 --- a/portal-2/src/app/utils/properties/openaireProperties.ts +++ b/portal-2/src/app/utils/properties/openaireProperties.ts @@ -375,4 +375,5 @@ export class ErrorCodes { public ERROR = 3; public NOT_AVAILABLE = 4; public OUT_OF_BOUND = 5; + public NOT_FOUND = 6; } diff --git a/portal-2/src/assets/discover-custom.css b/portal-2/src/assets/discover-custom.css index 3ddd9463..a0d24eac 100644 --- a/portal-2/src/assets/discover-custom.css +++ b/portal-2/src/assets/discover-custom.css @@ -86,6 +86,9 @@ h2 .custom-external { .search-results { min-height: 1100px; } +.searchPaging { + min-height: 46px; +} .other-results { min-height: 300px; }