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:

modules/uoa-services-library/trunk/ng-openaire-library/src/app/error/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
}
modules/uoa-services-library/trunk/ng-openaire-library/src/app/landingPages/dataProvider/dataProvider.component.ts
130 130
      this.datasourceId = data['datasourceId'];
131 131
      if (this.datasourceId) {
132 132
        this.getDataProviderInfo(this.datasourceId);
133
      } else {
134
        this.showLoading = false;
135
        this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToDataProvider + this.datasourceId, "page_type": "dataprovider"}});
133 136
      }
134 137

  
135 138
      HelperFunctions.scroll();
......
200 203
        err => {
201 204
          //console.log(err);
202 205
          this.handleError("Error getting content provider for id: " + this.datasourceId, err);
203
          this.errorMessage = 'No dataProvider found';
206
          if(err.status == 404) {
207
            this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToDataProvider + this.datasourceId, "page_type": "dataprovider"}});
208
          }
209
          //this.errorMessage = 'No dataProvider found';
204 210
          this.showLoading = false;
205 211
          this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToDataProviders);
206 212
        }
modules/uoa-services-library/trunk/ng-openaire-library/src/app/landingPages/organization/organization.component.ts
146 146
        this.getOrganizationInfo();
147 147
      } else {
148 148
        this.showLoading = false;
149
        this.warningMessage = "No valid organization id";
149
        this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToOrganization + this.organizationId, "page_type": "organization"}});
150
        //this.warningMessage = "No valid organization id";
150 151
      }
151 152

  
152 153
      HelperFunctions.scroll();
......
254 255
      err => {
255 256
        //console.log(err)
256 257
        this.handleError("Error getting organization for id: " + this.organizationId, err);
258
        if(err.status == 404) {
259
          this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToOrganization + this.organizationId, "page_type": "organization"}});
260
        }
257 261
        this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToOrganizations);
258
        this.errorMessage = 'No organization found';
262
        //this.errorMessage = 'No organization found';
259 263
        this.showLoading = false;
260 264
      }
261 265
    );
modules/uoa-services-library/trunk/ng-openaire-library/src/app/landingPages/project/project.component.ts
148 148
      } else {
149 149

  
150 150
        this.showLoading = false;
151
        this.warningMessage = "No valid project id";
151
        this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToProject + this.projectId, "page_type": "project"}});
152
        //this.warningMessage = "No valid project id";
152 153
      }
153 154

  
154 155
      this.downloadURLAPI = this.properties.csvAPIURL;
......
329 330
      err => {
330 331
        //console.log(err);
331 332
        this.handleError("Error getting project for id: " + this.projectId, err);
333
        if(err.status == 404) {
334
          this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToProject + this.projectId, "page_type": "project"}});
335
        }
332 336
        this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects);
333
        this.errorMessage = 'No project found';
337
        //this.errorMessage = 'No project found';
334 338
        this.showLoading = false;
335 339
      }
336 340
    );
modules/uoa-services-library/trunk/ng-openaire-library/src/app/landingPages/result/resultLanding.component.ts
12 12
import {HelperFunctions} from '../../utils/HelperFunctions.class';
13 13
import {HelperService} from '../../utils/helper/helper.service';
14 14
import {isPlatformBrowser} from "@angular/common";
15
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
15 16

  
16 17

  
17 18
@Component({
......
145 146
          } else {
146 147
            this.showLoading = false;
147 148

  
149
            this._router.navigate(['/error'], {queryParams: {"page": this.linkToSearchPage + this.id, "page_type": this.type}});
150
            /*
148 151
            this.warningMessage = "No valid ";
149 152
            if(this.type == "publication" || this.type == "software") {
150 153
              this.warningMessage += this.type + " ";
......
154 157
              this.warningMessage += "other research product ";
155 158
            }
156 159
            this.warningMessage += "id";
160
            */
157 161
          }
158 162

  
159 163
          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 291
      err => {
288 292
        this.handleError("Error getting "+this.type+" for id: " + this.id, err);
289 293

  
294
        if(err.status == 404) {
295
          this._router.navigate(['/error'], {queryParams: {"page": this.linkToSearchPage + this.id, "page_type": this.type}});
296
        }
297

  
290 298
        if(this.type == "publication" || this.type == "software") {
291 299
          this.errorMessage = 'No '+this.type+' found';
292 300
        } else if(this.type == "dataset") {

Also available in: Unified diff