2019-10-22 12:06:44 +02:00
|
|
|
import {Component, Inject, Input, Optional} from '@angular/core';
|
2018-04-11 16:06:36 +02:00
|
|
|
import {Location} from '@angular/common';
|
|
|
|
import {ActivatedRoute} from '@angular/router';
|
|
|
|
import {Title, Meta} from '@angular/platform-browser';
|
2019-10-22 12:06:44 +02:00
|
|
|
import {RESPONSE} from "@nguniversal/express-engine/tokens";
|
2019-10-31 12:39:23 +01:00
|
|
|
import {EnvProperties} from "../utils/properties/env-properties";
|
2019-11-07 10:51:09 +01:00
|
|
|
import {SEOService} from "../sharedComponents/SEO/SEO.service";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'error',
|
|
|
|
template: `
|
2020-05-07 19:20:33 +02:00
|
|
|
<div id="tm-main" class=" uk-section tm-middle">
|
|
|
|
<div uk-grid class="uk-margin-small-top">
|
2017-12-19 13:53:46 +01:00
|
|
|
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
|
|
|
|
<div class="uk-container">
|
|
|
|
<h2>
|
|
|
|
Bad karma: we can't find that page!
|
|
|
|
</h2>
|
2019-10-31 12:39:23 +01:00
|
|
|
<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>
|
2017-12-19 13:53:46 +01:00
|
|
|
<br>
|
|
|
|
<p>
|
|
|
|
You asked for {{page}}, but despite our computers looking very hard, we could not find it. What happened ?
|
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li>the link you clicked to arrive here has a typo in it</li>
|
|
|
|
<li>or somehow we removed that page, or gave it another name</li>
|
|
|
|
<li>or, quite unlikely for sure, maybe you typed it yourself and there was a little mistake ?</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class ErrorPageComponent {
|
|
|
|
public page: string;
|
2019-10-31 12:39:23 +01:00
|
|
|
public page_type: string;
|
|
|
|
public searchPage: string;
|
|
|
|
public page_type_name: string;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2018-04-11 16:06:36 +02:00
|
|
|
constructor (private _location: Location, private _meta: Meta,
|
2019-10-22 12:06:44 +02:00
|
|
|
private _title: Title, private route: ActivatedRoute,
|
2019-11-07 10:51:09 +01:00
|
|
|
@Optional() @Inject(RESPONSE) private response: any,
|
|
|
|
private seoService: SEOService) {
|
2018-04-11 16:06:36 +02:00
|
|
|
|
|
|
|
var title = "OpenAIRE | Error page";
|
|
|
|
|
|
|
|
this._meta.updateTag({content:title},"property='og:title'");
|
|
|
|
this._title.setTitle(title);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.page = _location.path(true);
|
|
|
|
//this.page = _router.url;
|
|
|
|
//this.page = location.href;
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
2019-10-31 12:39:23 +01:00
|
|
|
if(this.response) {
|
|
|
|
this.response.statusCode = 404;
|
|
|
|
this.response.statusMessage = '404 - Page not found';
|
|
|
|
}
|
2019-11-07 10:51:09 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
let properties = data.envSpecific;
|
|
|
|
this.seoService.createLinkForCanonicalURL(properties.baseLink + "/error");
|
|
|
|
|
|
|
|
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) {
|
2019-10-31 12:39:23 +01:00
|
|
|
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";
|
|
|
|
}
|
2019-11-07 10:51:09 +01:00
|
|
|
}
|
|
|
|
});
|
2019-10-31 12:39:23 +01:00
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|