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
|
|
7
|
@Component({
|
8
|
selector: 'monitor-advanced-search-dataproviders',
|
9
|
template: `
|
10
|
<div id="page_content">
|
11
|
<search-dataproviders *ngIf="initialized" [simpleView]="false"
|
12
|
[customFilter]=customFilter [hasPrefix]="false"
|
13
|
[includeOnlyResultsAndFilter]="false" [showSwitchSearchLink]="showSwitchSearchLink">
|
14
|
</search-dataproviders>
|
15
|
</div>
|
16
|
`
|
17
|
})
|
18
|
export class MonitorAdvancedSearchDataprovidersComponent {
|
19
|
customFilter: SearchCustomFilter = null;
|
20
|
initialized: boolean = false;
|
21
|
showSwitchSearchLink:boolean = false;
|
22
|
constructor(private route: ActivatedRoute,
|
23
|
private router: Router,
|
24
|
private stakeholderService: StakeholderService) {
|
25
|
}
|
26
|
subscriptions = [];
|
27
|
ngOnDestroy() {
|
28
|
this.subscriptions.forEach(subscription => {
|
29
|
if (subscription instanceof Subscriber) {
|
30
|
subscription.unsubscribe();
|
31
|
}
|
32
|
});
|
33
|
}
|
34
|
|
35
|
ngOnInit() {
|
36
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
37
|
if (params['stakeholder']) {
|
38
|
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
39
|
if (stakeholder) {
|
40
|
if (stakeholder.type === "organization") {
|
41
|
let value = stakeholder.index_id;
|
42
|
this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, "");
|
43
|
this.showSwitchSearchLink = true;
|
44
|
} else if (stakeholder.type === "funder") {
|
45
|
let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName;
|
46
|
this.customFilter = new SearchCustomFilter("Funder", "relfunder", value, stakeholder.name);
|
47
|
} else if (stakeholder.type === "ri") {
|
48
|
let value = stakeholder.index_id+"||"+stakeholder.index_name;
|
49
|
this.customFilter = new SearchCustomFilter("Community", "community", value, stakeholder.name);
|
50
|
}
|
51
|
this.initialized = true;
|
52
|
}
|
53
|
}));
|
54
|
}
|
55
|
}));
|
56
|
}
|
57
|
|
58
|
}
|