Project

General

Profile

1
import {Component} from '@angular/core';
2
import {ActivatedRoute, Router} from '@angular/router';
3

    
4

    
5
@Component({
6
  selector: 'page-URL-resolver',
7
  template: `    
8
     `
9
})
10

    
11
export class PageURLResolverComponent {
12
  parameters= {};
13
  constructor(private route: ActivatedRoute, private router : Router) {
14
  }
15

    
16
  ngOnInit() {
17
    this.route.queryParams.subscribe(params => {
18
      console.log(params);
19
      this.parameters = Object.assign({}, params);
20
      this.navigateTO(this.router.url.split("?")[0])
21

    
22
    });
23
  }
24

    
25
  navigateTO(url:string){
26
    if( url == "/search/find/publications" ){
27
      this.parameters["type"]="publications";
28
      this.router.navigate(["/search/find/research-outcomes"],{queryParams:this.parameters})
29
    }else if( url == "/search/find/datasets" ){
30
      this.parameters["type"]="datasets";
31
      this.router.navigate(["/search/find/research-outcomes"],{queryParams:this.parameters})
32
    }else if( url == "/search/find/software" ){
33
      this.parameters["type"]="software";
34
      this.router.navigate(["/search/find/research-outcomes"],{queryParams:this.parameters})
35
    }else if( url == "/search/find/other" ){
36
      this.parameters["type"]="other";
37
      this.router.navigate(["/search/find/research-outcomes"],{queryParams:this.parameters})
38
    }else if( url == "/search/advanced/publications" ){
39
      this.parameters["type"]="publications";
40
      this.router.navigate(["/search/advanced/research-outcomes"],{queryParams:this.parameters})
41
    }else if( url == "/search/advanced/datasets" ){
42
      this.parameters["type"]="datasets";
43
      this.router.navigate(["/search/advanced/research-outcomes"],{queryParams:this.parameters})
44
    }else if( url == "/search/advanced/software" ){
45
      this.parameters["type"]="software";
46
      this.router.navigate(["/search/advanced/research-outcomes"],{queryParams:this.parameters})
47
    }else if( url == "/search/advanced/other" ){
48
      this.parameters["type"]="other";
49
      this.router.navigate(["/search/advanced/research-outcomes"],{queryParams:this.parameters})
50
    }
51
  }
52
}
(15-15/23)