Project

General

Profile

1
import {Component} from '@angular/core';
2
import {ActivatedRoute} from '@angular/router';
3
import {PiwikHelper} from '../../utils/piwikHelper';
4
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
5
import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
6

    
7
@Component({
8
  selector: 'openaire-search-other',
9
  template: `    
10
    <search-research-results openaireLink="https://beta.explore.openaire.eu/search/find/other"
11
                             [customFilter]=customFilter [piwikSiteId]="piwikSiteId" [hasPrefix]="false"
12
                             resultType="other">
13
    </search-research-results>
14
  `
15

    
16
})
17
export class OpenaireSearchOrpsComponent {
18

    
19
  advancedSearchParameters: any;
20
  connectCommunityId: string;
21
  piwikSiteId = null;
22
  customFilter: SearchCustomFilter = null;
23

    
24
  constructor(private  route: ActivatedRoute) {
25
  }
26

    
27
  ngOnInit() {
28

    
29
    this.route.data
30
      .subscribe((data: { envSpecific: any }) => {
31

    
32
        var communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
33
        if (communityId) {
34
          this.connectCommunityId = communityId
35
          this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId,data.envSpecific.environment);
36
          this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, "");
37

    
38
        } else {
39
          this.route.queryParams.subscribe(params => {
40
            if (params['communityId'] && params['communityId'] != "") {
41
              this.connectCommunityId = params['communityId'];
42
              this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId,data.envSpecific.environment);
43
              this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, "");
44

    
45
            }
46
          });
47
        }
48

    
49
      });
50

    
51
  }
52
}
(11-11/24)