1
|
import {Component, Inject, Input, Optional} from '@angular/core';
|
2
|
import {Location} from '@angular/common';
|
3
|
import {ActivatedRoute} from '@angular/router';
|
4
|
import {Title, Meta} from '@angular/platform-browser';
|
5
|
import {RESPONSE} from "@nguniversal/express-engine/tokens";
|
6
|
import {EnvProperties} from "../utils/properties/env-properties";
|
7
|
|
8
|
@Component({
|
9
|
selector: 'error',
|
10
|
template: `
|
11
|
<div id="tm-main" class=" uk-section uk-margin-small-top tm-middle">
|
12
|
<div uk-grid uk-grid>
|
13
|
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
|
14
|
<div class="uk-container">
|
15
|
<h2>
|
16
|
Bad karma: we can't find that page!
|
17
|
</h2>
|
18
|
<h5 *ngIf="page_type" class="uk-margin-remove">
|
19
|
Not valid or missing {{page_type_name}} id.
|
20
|
<a *ngIf="page_type" routerLinkActive="router-link-active" [routerLink]="searchPage">Search </a>another {{page_type_name}}?
|
21
|
</h5>
|
22
|
<br>
|
23
|
<p>
|
24
|
You asked for {{page}}, but despite our computers looking very hard, we could not find it. What happened ?
|
25
|
</p>
|
26
|
<ul>
|
27
|
<li>the link you clicked to arrive here has a typo in it</li>
|
28
|
<li>or somehow we removed that page, or gave it another name</li>
|
29
|
<li>or, quite unlikely for sure, maybe you typed it yourself and there was a little mistake ?</li>
|
30
|
</ul>
|
31
|
</div>
|
32
|
</div>
|
33
|
</div>
|
34
|
</div>
|
35
|
`
|
36
|
})
|
37
|
|
38
|
export class ErrorPageComponent {
|
39
|
public page: string;
|
40
|
public page_type: string;
|
41
|
public searchPage: string;
|
42
|
public page_type_name: string;
|
43
|
|
44
|
constructor (private _location: Location, private _meta: Meta,
|
45
|
private _title: Title, private route: ActivatedRoute,
|
46
|
@Optional() @Inject(RESPONSE) private response: any) {
|
47
|
|
48
|
var title = "OpenAIRE | Error page";
|
49
|
|
50
|
this._meta.updateTag({content:title},"property='og:title'");
|
51
|
this._title.setTitle(title);
|
52
|
this.page = _location.path(true);
|
53
|
//this.page = _router.url;
|
54
|
//this.page = location.href;
|
55
|
}
|
56
|
ngOnInit() {
|
57
|
if(this.response) {
|
58
|
this.response.statusCode = 404;
|
59
|
this.response.statusMessage = '404 - Page not found';
|
60
|
}
|
61
|
this.route.queryParams.subscribe(data => {
|
62
|
this.page = data['page'];
|
63
|
if (!this.page) {
|
64
|
this.page = this._location.path(true);
|
65
|
}
|
66
|
this.page_type = data['page_type'];
|
67
|
if(this.page_type) {
|
68
|
this.route.data
|
69
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
70
|
let properties = data.envSpecific;
|
71
|
if (this.page_type == "publication") {
|
72
|
this.searchPage = properties.searchLinkToPublications;
|
73
|
this.page_type_name = "publication";
|
74
|
} else if (this.page_type == "software") {
|
75
|
this.searchPage = properties.searchLinkToSoftware;
|
76
|
this.page_type_name = "software";
|
77
|
} else if (this.page_type == "dataset") {
|
78
|
this.searchPage = properties.searchLinkToDatasets;
|
79
|
this.page_type_name = "dataset";
|
80
|
} else if (this.page_type == "orp") {
|
81
|
this.searchPage = properties.searchLinkToOrps;
|
82
|
this.page_type_name = "research product";
|
83
|
} else if (this.page_type == "organization") {
|
84
|
this.searchPage = properties.searchLinkToOrganizations;
|
85
|
this.page_type_name = "organization";
|
86
|
} else if (this.page_type == "project") {
|
87
|
this.searchPage = properties.searchLinkToProjects;
|
88
|
this.page_type_name = "project";
|
89
|
} else if (this.page_type == "dataprovider") {
|
90
|
this.searchPage = properties.searchLinkToDataProviders;
|
91
|
this.page_type_name = "content provider";
|
92
|
}
|
93
|
});
|
94
|
}
|
95
|
});
|
96
|
}
|
97
|
}
|