1
|
import {Component, OnDestroy, OnInit} from '@angular/core';
|
2
|
import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
3
|
import {ActivatedRoute} from "@angular/router";
|
4
|
import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper";
|
5
|
import {PiwikHelper} from "../../utils/piwikHelper";
|
6
|
import {Subscriber} from "rxjs";
|
7
|
import {properties} from "../../../environments/environment";
|
8
|
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
|
9
|
import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
|
10
|
|
11
|
@Component({
|
12
|
selector: 'openaire-search-results',
|
13
|
template: `
|
14
|
<search-research-results resultType="result" [simpleView]="false" [customFilter]=customFilter
|
15
|
[piwikSiteId]="piwikSiteId" [hasPrefix]="false" [showBreadcrumb]="true"
|
16
|
[openaireLink]="'https://' + (properties.environment == 'production'?'':'beta.') + 'explore.openaire.eu/search/advanced/research-outcomes'"
|
17
|
></search-research-results>
|
18
|
`
|
19
|
})
|
20
|
export class OpenaireSearchResearchResultsComponent implements OnInit, OnDestroy {
|
21
|
connectCommunityId: string;
|
22
|
piwikSiteId = null;
|
23
|
customFilter: SearchCustomFilter = null;
|
24
|
properties: EnvProperties = properties;
|
25
|
sub;
|
26
|
|
27
|
constructor(private route: ActivatedRoute, private _communityService: CommunityService) {
|
28
|
}
|
29
|
|
30
|
ngOnInit() {
|
31
|
this.setCommunity();
|
32
|
}
|
33
|
|
34
|
ngOnDestroy() {
|
35
|
if (this.sub instanceof Subscriber) {
|
36
|
this.sub.unsubscribe();
|
37
|
}
|
38
|
}
|
39
|
|
40
|
setCommunity() {
|
41
|
this.sub = this._communityService.getCommunityAsObservable().subscribe(community => {
|
42
|
if (community != null) {
|
43
|
this.connectCommunityId = community.communityId;
|
44
|
this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId, properties.environment);
|
45
|
this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, community.shortTitle);
|
46
|
}
|
47
|
});
|
48
|
}
|
49
|
}
|