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 {SEOService} from "../sharedComponents/SEO/SEO.service";
|
6
|
import {properties} from "../../../environments/environment";
|
7
|
import {RESPONSE} from '../utils/tokens';
|
8
|
import {Response} from 'express';
|
9
|
|
10
|
@Component({
|
11
|
selector: 'error',
|
12
|
template: `
|
13
|
<div id="tm-main" class=" uk-section tm-middle">
|
14
|
<div uk-grid class="uk-margin-small-top">
|
15
|
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
|
16
|
<div class="uk-container">
|
17
|
<h3>
|
18
|
<span *ngIf="page !='-1'">Bad karma: we can't find that page!</span>
|
19
|
<div *ngIf="page =='-1'" class="uk-text-center uk-margin-large-top">
|
20
|
<svg _ngcontent-my-app-c8="" fill="black" height="24px" viewBox="0 0 24 24" width="24px" xmlns="http://www.w3.org/2000/svg"><path _ngcontent-my-app-c8="" d="M0 0h24v24H0z" fill="none"></path><path _ngcontent-my-app-c8="" d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"></path></svg>
|
21
|
Private Data</div>
|
22
|
</h3>
|
23
|
<h6 *ngIf="page_type" class="uk-margin-remove">
|
24
|
Not valid or missing {{page_type_name}} id.
|
25
|
<a *ngIf="page_type" routerLinkActive="router-link-active" [routerLink]="searchPage">Search </a>another {{page_type_name}}?
|
26
|
</h6>
|
27
|
<br>
|
28
|
<div *ngIf="page !='-1'">
|
29
|
<p>
|
30
|
You asked for {{page}}, but despite our computers looking very hard, we could not find it. What happened ?
|
31
|
</p>
|
32
|
<ul>
|
33
|
<li>the link you clicked to arrive here has a typo in it</li>
|
34
|
<li>or somehow we removed that page, or gave it another name</li>
|
35
|
<li>or, quite unlikely for sure, maybe you typed it yourself and there was a little mistake ?</li>
|
36
|
</ul>
|
37
|
</div>
|
38
|
</div>
|
39
|
</div>
|
40
|
</div>
|
41
|
</div>
|
42
|
`
|
43
|
})
|
44
|
|
45
|
export class ErrorPageComponent {
|
46
|
@Input() public page: string;
|
47
|
public page_type: string;
|
48
|
public searchPage: string;
|
49
|
public page_type_name: string;
|
50
|
|
51
|
constructor (private _location: Location, private _meta: Meta,
|
52
|
private _title: Title, private route: ActivatedRoute,
|
53
|
@Optional() @Inject(RESPONSE) private response: Response,
|
54
|
private seoService: SEOService) {}
|
55
|
|
56
|
ngOnInit() {
|
57
|
this.seoService.createLinkForCanonicalURL(properties.domain + properties.baseLink + "/error");
|
58
|
this.route.queryParams.subscribe(data => {
|
59
|
this.page = this.page?this.page:data['page'];
|
60
|
if (!this.page) {
|
61
|
this.page = this._location.path(true);
|
62
|
}
|
63
|
if(this.response) {
|
64
|
this.response.statusCode = 404;
|
65
|
this.response.statusMessage = '404 - Page not found';
|
66
|
}
|
67
|
if(this.page != "-1") {
|
68
|
let title = "OpenAIRE | Error page";
|
69
|
this._meta.updateTag({content:title},"property='og:title'");
|
70
|
this._title.setTitle(title);
|
71
|
} else{
|
72
|
let title = "OpenAIRE | Private data";
|
73
|
this._meta.updateTag({content:title},"property='og:title'");
|
74
|
this._title.setTitle(title);
|
75
|
}
|
76
|
this.page_type = data['page_type'];
|
77
|
if(this.page_type) {
|
78
|
if (this.page_type == "publication") {
|
79
|
this.searchPage = properties.searchLinkToPublications;
|
80
|
this.page_type_name = "publication";
|
81
|
} else if (this.page_type == "software") {
|
82
|
this.searchPage = properties.searchLinkToSoftware;
|
83
|
this.page_type_name = "software";
|
84
|
} else if (this.page_type == "dataset") {
|
85
|
this.searchPage = properties.searchLinkToDatasets;
|
86
|
this.page_type_name = "dataset";
|
87
|
} else if (this.page_type == "orp") {
|
88
|
this.searchPage = properties.searchLinkToOrps;
|
89
|
this.page_type_name = "research product";
|
90
|
} else if (this.page_type == "organization") {
|
91
|
this.searchPage = properties.searchLinkToOrganizations;
|
92
|
this.page_type_name = "organization";
|
93
|
} else if (this.page_type == "project") {
|
94
|
this.searchPage = properties.searchLinkToProjects;
|
95
|
this.page_type_name = "project";
|
96
|
} else if (this.page_type == "dataprovider") {
|
97
|
this.searchPage = properties.searchLinkToDataProviders;
|
98
|
this.page_type_name = "content provider";
|
99
|
}
|
100
|
}
|
101
|
});
|
102
|
}
|
103
|
}
|