Project

General

Profile

« Previous | Next » 

Revision 57494

[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.

View differences:

errorPage.component.ts
3 3
import {ActivatedRoute}           from '@angular/router';
4 4
import {Title, Meta}              from '@angular/platform-browser';
5 5
import {RESPONSE} from "@nguniversal/express-engine/tokens";
6
import {EnvProperties} from "../utils/properties/env-properties";
6 7

  
7 8
@Component({
8 9
    selector: 'error',
......
14 15
            <h2>
15 16
                Bad karma: we can't find that page!
16 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>
17 22
            <br>
18 23
            <p>
19 24
                You asked for {{page}}, but despite our computers looking very hard, we could not find it. What happened ?
......
32 37

  
33 38
export class ErrorPageComponent {
34 39
    public page: string;
40
    public page_type: string;
41
    public searchPage: string;
42
    public page_type_name: string;
35 43

  
36 44
    constructor (private _location: Location, private _meta: Meta,
37 45
                 private _title: Title, private route: ActivatedRoute,
......
46 54
        //this.page = location.href;
47 55
    }
48 56
    ngOnInit() {
49
      this.response.statusCode = 404;
50
      this.response.statusMessage = '404 - Page not found';
51
         this.route.queryParams.subscribe(data => {
52
            this.page = data['page'];
53
            if (!this.page) {
54
              this.page = this._location.path(true);
55
            }
56
          });
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
      });
57 96
    }
58 97
}

Also available in: Unified diff