[Trunk | Library]:
1. landingPages/: When no id is specified or id is not found (search service returns 404), redirect to /error with more specific message. 2. error/errorPage.component.ts: When the error was caused by landing pages, add more specific message - suggest to search again. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57494 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
8dbf6c5d76
commit
9a6031d28e
|
@ -3,6 +3,7 @@ import {Location} from '@angular/common';
|
|||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Title, Meta} from '@angular/platform-browser';
|
||||
import {RESPONSE} from "@nguniversal/express-engine/tokens";
|
||||
import {EnvProperties} from "../utils/properties/env-properties";
|
||||
|
||||
@Component({
|
||||
selector: 'error',
|
||||
|
@ -14,6 +15,10 @@ import {RESPONSE} from "@nguniversal/express-engine/tokens";
|
|||
<h2>
|
||||
Bad karma: we can't find that page!
|
||||
</h2>
|
||||
<h5 *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}}?
|
||||
</h5>
|
||||
<br>
|
||||
<p>
|
||||
You asked for {{page}}, but despite our computers looking very hard, we could not find it. What happened ?
|
||||
|
@ -32,6 +37,9 @@ import {RESPONSE} from "@nguniversal/express-engine/tokens";
|
|||
|
||||
export class ErrorPageComponent {
|
||||
public page: string;
|
||||
public page_type: string;
|
||||
public searchPage: string;
|
||||
public page_type_name: string;
|
||||
|
||||
constructor (private _location: Location, private _meta: Meta,
|
||||
private _title: Title, private route: ActivatedRoute,
|
||||
|
@ -46,13 +54,44 @@ export class ErrorPageComponent {
|
|||
//this.page = location.href;
|
||||
}
|
||||
ngOnInit() {
|
||||
if(this.response) {
|
||||
this.response.statusCode = 404;
|
||||
this.response.statusMessage = '404 - Page not found';
|
||||
}
|
||||
this.route.queryParams.subscribe(data => {
|
||||
this.page = data['page'];
|
||||
if (!this.page) {
|
||||
this.page = this._location.path(true);
|
||||
}
|
||||
this.page_type = data['page_type'];
|
||||
if(this.page_type) {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
let properties = data.envSpecific;
|
||||
if (this.page_type == "publication") {
|
||||
this.searchPage = properties.searchLinkToPublications;
|
||||
this.page_type_name = "publication";
|
||||
} else if (this.page_type == "software") {
|
||||
this.searchPage = properties.searchLinkToSoftware;
|
||||
this.page_type_name = "software";
|
||||
} else if (this.page_type == "dataset") {
|
||||
this.searchPage = properties.searchLinkToDatasets;
|
||||
this.page_type_name = "dataset";
|
||||
} else if (this.page_type == "orp") {
|
||||
this.searchPage = properties.searchLinkToOrps;
|
||||
this.page_type_name = "research product";
|
||||
} else if (this.page_type == "organization") {
|
||||
this.searchPage = properties.searchLinkToOrganizations;
|
||||
this.page_type_name = "organization";
|
||||
} else if (this.page_type == "project") {
|
||||
this.searchPage = properties.searchLinkToProjects;
|
||||
this.page_type_name = "project";
|
||||
} else if (this.page_type == "dataprovider") {
|
||||
this.searchPage = properties.searchLinkToDataProviders;
|
||||
this.page_type_name = "content provider";
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,6 +130,9 @@ export class DataProviderComponent {
|
|||
this.datasourceId = data['datasourceId'];
|
||||
if (this.datasourceId) {
|
||||
this.getDataProviderInfo(this.datasourceId);
|
||||
} else {
|
||||
this.showLoading = false;
|
||||
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToDataProvider + this.datasourceId, "page_type": "dataprovider"}});
|
||||
}
|
||||
|
||||
HelperFunctions.scroll();
|
||||
|
@ -200,7 +203,10 @@ export class DataProviderComponent {
|
|||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting content provider for id: " + this.datasourceId, err);
|
||||
this.errorMessage = 'No dataProvider found';
|
||||
if(err.status == 404) {
|
||||
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToDataProvider + this.datasourceId, "page_type": "dataprovider"}});
|
||||
}
|
||||
//this.errorMessage = 'No dataProvider found';
|
||||
this.showLoading = false;
|
||||
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToDataProviders);
|
||||
}
|
||||
|
|
|
@ -146,7 +146,8 @@ export class OrganizationComponent {
|
|||
this.getOrganizationInfo();
|
||||
} else {
|
||||
this.showLoading = false;
|
||||
this.warningMessage = "No valid organization id";
|
||||
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToOrganization + this.organizationId, "page_type": "organization"}});
|
||||
//this.warningMessage = "No valid organization id";
|
||||
}
|
||||
|
||||
HelperFunctions.scroll();
|
||||
|
@ -254,8 +255,11 @@ export class OrganizationComponent {
|
|||
err => {
|
||||
//console.log(err)
|
||||
this.handleError("Error getting organization for id: " + this.organizationId, err);
|
||||
if(err.status == 404) {
|
||||
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToOrganization + this.organizationId, "page_type": "organization"}});
|
||||
}
|
||||
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToOrganizations);
|
||||
this.errorMessage = 'No organization found';
|
||||
//this.errorMessage = 'No organization found';
|
||||
this.showLoading = false;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -148,7 +148,8 @@ export class ProjectComponent {
|
|||
} else {
|
||||
|
||||
this.showLoading = false;
|
||||
this.warningMessage = "No valid project id";
|
||||
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToProject + this.projectId, "page_type": "project"}});
|
||||
//this.warningMessage = "No valid project id";
|
||||
}
|
||||
|
||||
this.downloadURLAPI = this.properties.csvAPIURL;
|
||||
|
@ -329,8 +330,11 @@ export class ProjectComponent {
|
|||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting project for id: " + this.projectId, err);
|
||||
if(err.status == 404) {
|
||||
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToProject + this.projectId, "page_type": "project"}});
|
||||
}
|
||||
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects);
|
||||
this.errorMessage = 'No project found';
|
||||
//this.errorMessage = 'No project found';
|
||||
this.showLoading = false;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -12,6 +12,7 @@ import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
|||
import {HelperFunctions} from '../../utils/HelperFunctions.class';
|
||||
import {HelperService} from '../../utils/helper/helper.service';
|
||||
import {isPlatformBrowser} from "@angular/common";
|
||||
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -145,6 +146,8 @@ export class ResultLandingComponent {
|
|||
} else {
|
||||
this.showLoading = false;
|
||||
|
||||
this._router.navigate(['/error'], {queryParams: {"page": this.linkToSearchPage + this.id, "page_type": this.type}});
|
||||
/*
|
||||
this.warningMessage = "No valid ";
|
||||
if(this.type == "publication" || this.type == "software") {
|
||||
this.warningMessage += this.type + " ";
|
||||
|
@ -154,6 +157,7 @@ export class ResultLandingComponent {
|
|||
this.warningMessage += "other research product ";
|
||||
}
|
||||
this.warningMessage += "id";
|
||||
*/
|
||||
}
|
||||
|
||||
this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
||||
|
@ -287,6 +291,10 @@ export class ResultLandingComponent {
|
|||
err => {
|
||||
this.handleError("Error getting "+this.type+" for id: " + this.id, err);
|
||||
|
||||
if(err.status == 404) {
|
||||
this._router.navigate(['/error'], {queryParams: {"page": this.linkToSearchPage + this.id, "page_type": this.type}});
|
||||
}
|
||||
|
||||
if(this.type == "publication" || this.type == "software") {
|
||||
this.errorMessage = 'No '+this.type+' found';
|
||||
} else if(this.type == "dataset") {
|
||||
|
|
Loading…
Reference in New Issue