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-software',
9
  template: `
10
    <search-research-results openaireLink="https://beta.explore.openaire.eu/search/find/software"
11
                             [customFilter]=customFilter [piwikSiteId]="piwikSiteId" [hasPrefix]="false"
12
                             resultType="software">
13
    </search-research-results>
14
  `
15
})
16

    
17
export class OpenaireSearchSoftwareComponent {
18
  advancedSearchParameters: any;
19
  connectCommunityId: string;
20
  piwikSiteId = null;
21
  customFilter: SearchCustomFilter = null;
22

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

    
26
  ngOnInit() {
27

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

    
31
        var communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
32
        if (communityId) {
33
          this.connectCommunityId = communityId;
34

    
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
}
(23-23/24)