1
|
import {Component} from '@angular/core';
|
2
|
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
3
|
import {ActivatedRoute, Router} from "@angular/router";
|
4
|
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
|
5
|
import {Subscriber} from "rxjs";
|
6
|
import {properties} from "../../../../environments/environment";
|
7
|
import {ConfigurationService} from "../../../openaireLibrary/utils/configuration/configuration.service";
|
8
|
|
9
|
@Component({
|
10
|
selector: 'monitor-advanced-search-results',
|
11
|
template: `
|
12
|
<div id="page_content">
|
13
|
<search-research-results *ngIf="initialized" resultType="result" [simpleView]="false"
|
14
|
[customFilter]=customFilter [hasPrefix]="false"
|
15
|
[includeOnlyResultsAndFilter]="false"
|
16
|
[showSwitchSearchLink]="true"
|
17
|
[openaireLink]="'https://'+(properties.environment != 'production'?'beta.':'')+'explore.openaire.eu/search/advanced/research-outcomes'"
|
18
|
[piwikSiteId]="piwikSiteId"
|
19
|
></search-research-results>
|
20
|
</div>
|
21
|
`
|
22
|
})
|
23
|
export class MonitorAdvancedSearchResearchResultsComponent {
|
24
|
customFilter: SearchCustomFilter = null;
|
25
|
initialized: boolean = false;
|
26
|
properties;
|
27
|
piwikSiteId;
|
28
|
constructor(private route: ActivatedRoute,
|
29
|
private router: Router,
|
30
|
private stakeholderService: StakeholderService, private configurationService: ConfigurationService) {
|
31
|
}
|
32
|
subscriptions = [];
|
33
|
ngOnDestroy() {
|
34
|
this.subscriptions.forEach(subscription => {
|
35
|
if (subscription instanceof Subscriber) {
|
36
|
subscription.unsubscribe();
|
37
|
}
|
38
|
});
|
39
|
}
|
40
|
|
41
|
ngOnInit() {
|
42
|
this.properties = properties;
|
43
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
44
|
if (params['stakeholder']) {
|
45
|
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
46
|
if (stakeholder) {
|
47
|
if (stakeholder.type === "funder") {
|
48
|
let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName;
|
49
|
this.customFilter = new SearchCustomFilter("Funder", "relfunder", value, stakeholder.name);
|
50
|
} else if (stakeholder.type === "organization") {
|
51
|
let value = stakeholder.index_id;
|
52
|
this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, stakeholder.name);
|
53
|
} else if (stakeholder.type === "ri") {
|
54
|
let value = stakeholder.index_id+"||"+stakeholder.index_name;
|
55
|
this.customFilter = new SearchCustomFilter("Community", "community", value, stakeholder.name);
|
56
|
}
|
57
|
this.subscriptions.push(this.configurationService.communityInformationState.subscribe(portal => {
|
58
|
if (portal) {
|
59
|
this.piwikSiteId = portal.piwik;
|
60
|
}
|
61
|
}));
|
62
|
this.initialized = true;
|
63
|
}
|
64
|
}));
|
65
|
}
|
66
|
}));
|
67
|
}
|
68
|
}
|