From 78b46ae45fa6404a8b4d7ec147d15e9afad0d12c Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Wed, 11 May 2022 12:55:14 +0300 Subject: [PATCH] Add errorLink property and change routing to this. Add searchPageParams to errorPage --- .../communityGuard/connectCommunityGuard.guard.ts | 2 +- connect/communityGuard/connectRIGuard.guard.ts | 2 +- connect/communityGuard/isCommunity.guard.ts | 4 ++-- error/errorPage.component.ts | 15 ++++++++++----- error/isRouteEnabled.guard.ts | 2 +- .../dataProvider/dataProvider.component.ts | 4 ++-- .../organization/organization.component.ts | 6 +++--- landingPages/project/project.component.ts | 6 +++--- landingPages/result/resultLanding.component.ts | 4 ++-- utils/properties/env-properties.ts | 1 + 10 files changed, 26 insertions(+), 20 deletions(-) diff --git a/connect/communityGuard/connectCommunityGuard.guard.ts b/connect/communityGuard/connectCommunityGuard.guard.ts index 3709d4ed..256bfdb9 100644 --- a/connect/communityGuard/connectCommunityGuard.guard.ts +++ b/connect/communityGuard/connectCommunityGuard.guard.ts @@ -22,7 +22,7 @@ export class ConnectCommunityGuard implements CanActivate, CanActivateChild { check(community: string, url: string): Observable | boolean { return this.communityService.isCommunityType(community).pipe(take(1), tap(isCommunity => { if (!isCommunity) { - this.router.navigate(['/error'], {queryParams: {'page': url}}); + this.router.navigate([this.properties.errorLink], {queryParams: {'page': url}}); } })); } diff --git a/connect/communityGuard/connectRIGuard.guard.ts b/connect/communityGuard/connectRIGuard.guard.ts index 1e0f67a7..5dd1698e 100644 --- a/connect/communityGuard/connectRIGuard.guard.ts +++ b/connect/communityGuard/connectRIGuard.guard.ts @@ -22,7 +22,7 @@ export class ConnectRIGuard implements CanActivate, CanActivateChild { check(community: string, url: string): Observable | boolean { return this.communityService.isRIType(community).pipe(tap(authorized => { if (!authorized) { - this.router.navigate(['/error'], {queryParams: {'page': url}}); + this.router.navigate([this.properties.errorLink], {queryParams: {'page': url}}); } })); } diff --git a/connect/communityGuard/isCommunity.guard.ts b/connect/communityGuard/isCommunity.guard.ts index 76b6cb91..41b737c2 100644 --- a/connect/communityGuard/isCommunity.guard.ts +++ b/connect/communityGuard/isCommunity.guard.ts @@ -32,12 +32,12 @@ export class IsCommunity implements CanActivate, CanActivateChild { if(community) { return true; } else { - this.router.navigate(['error'], {queryParams: {page: state.url}}); + this.router.navigate([properties.errorLink], {queryParams: {page: state.url}}); return false; } })); } else { - this.router.navigate(['error'], {queryParams: {page: state.url}}); + this.router.navigate([properties.errorLink], {queryParams: {page: state.url}}); return false; } } diff --git a/error/errorPage.component.ts b/error/errorPage.component.ts index a31edaf7..c20eab39 100644 --- a/error/errorPage.component.ts +++ b/error/errorPage.component.ts @@ -23,7 +23,7 @@ import {OpenaireEntities} from "../utils/properties/searchFields";
Not valid or missing {{page_type_name}} id. - Search another {{page_type_name}}? + Search another {{page_type_name}}?

@@ -47,6 +47,7 @@ export class ErrorPageComponent { @Input() public page: string; public page_type: string; public searchPage: string; + public searchPagePrams: {}; public page_type_name: string; constructor (private _location: Location, private _meta: Meta, @@ -77,16 +78,20 @@ export class ErrorPageComponent { this.page_type = data['page_type']; if(this.page_type) { if (this.page_type == "publication") { - this.searchPage = properties.searchLinkToPublications; + this.searchPage = properties.searchLinkToResults; + this.searchPagePrams = {type: 'publications'} this.page_type_name = OpenaireEntities.PUBLICATION.toLowerCase(); } else if (this.page_type == "software") { - this.searchPage = properties.searchLinkToSoftware; + this.searchPage = properties.searchLinkToResults; + this.searchPagePrams = {type: 'software'} this.page_type_name = OpenaireEntities.SOFTWARE_SINGULAR.toLowerCase(); } else if (this.page_type == "dataset") { - this.searchPage = properties.searchLinkToDatasets; + this.searchPagePrams = {type: 'datasets'} + this.searchPage = properties.searchLinkToResults; this.page_type_name = OpenaireEntities.DATASET.toLowerCase(); } else if (this.page_type == "orp") { - this.searchPage = properties.searchLinkToOrps; + this.searchPagePrams = {type: 'orps'} + this.searchPage = properties.searchLinkToResults; this.page_type_name = OpenaireEntities.OTHER_SINGULAR.toLowerCase(); } else if (this.page_type == "organization") { this.searchPage = properties.searchLinkToOrganizations; diff --git a/error/isRouteEnabled.guard.ts b/error/isRouteEnabled.guard.ts index 4d05d73b..c03821b2 100644 --- a/error/isRouteEnabled.guard.ts +++ b/error/isRouteEnabled.guard.ts @@ -15,7 +15,7 @@ export class IsRouteEnabled implements CanActivate { check(data: Data, path: string): Observable | boolean { const customRedirect = data['redirect']; - const redirect = customRedirect ? customRedirect : '/error'; + const redirect = customRedirect ? customRedirect : properties.errorLink; let community = ConnectHelper.getCommunityFromDomain(properties.domain); if (!community && data['community']) { // for openaire or connect community = data['community']; diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index 4d86ab81..b7f3d57a 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -178,7 +178,7 @@ export class DataProviderComponent { this.getDataProviderInfo(this.datasourceId); } else { this.showLoading = false; - this._router.navigate(['/error'], { + this._router.navigate([this.properties.errorLink], { queryParams: { "page": this._location.path(true), "page_type": "dataprovider" @@ -326,7 +326,7 @@ export class DataProviderComponent { //console.log(err); this.handleError("Error getting "+this.openaireEntities.DATASOURCE+" for id: " + this.datasourceId, err); if (err.status == 404) { - this._router.navigate(['/error'], { + this._router.navigate([this.properties.errorLink], { queryParams: { "page": this._location.path(true), "page_type": "dataprovider" diff --git a/landingPages/organization/organization.component.ts b/landingPages/organization/organization.component.ts index 84a83e95..f89e311a 100644 --- a/landingPages/organization/organization.component.ts +++ b/landingPages/organization/organization.component.ts @@ -173,7 +173,7 @@ export class OrganizationComponent { this.getOrganizationInfo(); } else { this.showLoading = false; - this._router.navigate(['/error'], { + this._router.navigate([this.properties.errorLink], { queryParams: { "page": this._location.path(true), "page_type": "organization" @@ -363,7 +363,7 @@ export class OrganizationComponent { data => { if (data == null) { this.showLoading = false; - this._router.navigate(['/error'], { + this._router.navigate([this.properties.errorLink], { queryParams: { "page": this._location.path(true), "page_type": "organization" @@ -399,7 +399,7 @@ export class OrganizationComponent { //console.log(err) this.handleError("Error getting organization for id: " + this.organizationId, err); if (err.status == 404) { - this._router.navigate(['/error'], { + this._router.navigate([this.properties.errorLink], { queryParams: { "page": this._location.path(true), "page_type": "organization" diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index 8011020b..63e68c45 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -220,7 +220,7 @@ export class ProjectComponent { } else { this.showLoading = false; - this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "project"}}); + this._router.navigate([this.properties.errorLink], {queryParams: {"page": this._location.path(true), "page_type": "project"}}); //this.warningMessage = "No valid project id"; } @@ -437,7 +437,7 @@ export class ProjectComponent { //console.log(err); this.handleError("Error getting project for id: " + this.projectId, err); if(err.status == 404) { - this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "project"}}); + this._router.navigate([this.properties.errorLink], {queryParams: {"page": this._location.path(true), "page_type": "project"}}); }else if(err.name == "TimeoutError"){ this.errorMessage = 'An error occurred please try again later'; }else { @@ -469,7 +469,7 @@ export class ProjectComponent { //console.log(err); this.handleError("Error getting project for grant id: " + grantId + " and funder: " + funder, err); if(err.status == 404) { - this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "project"}}); + this._router.navigate([this.properties.errorLink], {queryParams: {"page": this._location.path(true), "page_type": "project"}}); }else if(err.name == "TimeoutError"){ this.errorMessage = 'An error occurred please try again later'; }else { diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index b07ec4b4..66a8b7bc 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -206,7 +206,7 @@ export class ResultLandingComponent { } else { this.showLoading = false; - this._router.navigate(['/error'], { + this._router.navigate([this.properties.errorLink], { queryParams: { "page": this._location.path(true), "page_type": this.type @@ -514,7 +514,7 @@ export class ResultLandingComponent { err => { this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err); if (err.status == 404) { - this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}}); + this._router.navigate([this.properties.errorLink], {queryParams: {"page": this._location.path(true), "page_type": this.type}}); }else if(err.name == "TimeoutError"){ this.errorMessage = 'An error occurred please try again later'; }else{ diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index 6ce69460..f6b1a2fb 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -117,6 +117,7 @@ export interface EnvProperties { searchLinkToAdvancedDataProviders?: string; searchLinkToAdvancedOrganizations?: string; searchLinkToAdvancedResults?: string; + errorLink?: string lastIndexInformationLink?: string; showLastIndexInformationLink?: boolean; widgetLink?: string;