Add errorLink property and change routing to this. Add searchPageParams to errorPage

This commit is contained in:
Konstantinos Triantafyllou 2022-05-11 12:55:14 +03:00
parent 10c70ad1da
commit 78b46ae45f
10 changed files with 26 additions and 20 deletions

View File

@ -22,7 +22,7 @@ export class ConnectCommunityGuard implements CanActivate, CanActivateChild {
check(community: string, url: string): Observable<boolean> | 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}});
}
}));
}

View File

@ -22,7 +22,7 @@ export class ConnectRIGuard implements CanActivate, CanActivateChild {
check(community: string, url: string): Observable<boolean> | 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}});
}
}));
}

View File

@ -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;
}
}

View File

@ -23,7 +23,7 @@ import {OpenaireEntities} from "../utils/properties/searchFields";
</h3>
<h6 *ngIf="page_type" class="uk-margin-remove">
Not valid or missing {{page_type_name}} id.
<a *ngIf="page_type" routerLinkActive="router-link-active" [routerLink]="searchPage">Search </a>another {{page_type_name}}?
<a *ngIf="page_type" routerLinkActive="router-link-active" [routerLink]="searchPage" [queryParams]="searchPagePrams">Search </a>another {{page_type_name}}?
</h6>
<br>
<div *ngIf="page !='-1'">
@ -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;

View File

@ -15,7 +15,7 @@ export class IsRouteEnabled implements CanActivate {
check(data: Data, path: string): Observable<boolean> | 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'];

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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{

View File

@ -117,6 +117,7 @@ export interface EnvProperties {
searchLinkToAdvancedDataProviders?: string;
searchLinkToAdvancedOrganizations?: string;
searchLinkToAdvancedResults?: string;
errorLink?: string
lastIndexInformationLink?: string;
showLastIndexInformationLink?: boolean;
widgetLink?: string;