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
|
|
6
|
@Component({
|
7
|
selector: 'monitor-advanced-search-dataproviders',
|
8
|
template: `
|
9
|
<div id="page_content">
|
10
|
<search-dataproviders *ngIf="initialized" [simpleView]="false"
|
11
|
[customFilter]=customFilter [hasPrefix]="false"
|
12
|
[includeOnlyResultsAndFilter]="false">
|
13
|
</search-dataproviders>
|
14
|
</div>
|
15
|
`
|
16
|
})
|
17
|
export class MonitorAdvancedSearchDataprovidersComponent {
|
18
|
customFilter: SearchCustomFilter = null;
|
19
|
initialized: boolean = false;
|
20
|
|
21
|
constructor(private route: ActivatedRoute,
|
22
|
private router: Router,
|
23
|
private stakeholderService: StakeholderService) {
|
24
|
}
|
25
|
|
26
|
ngOnInit() {
|
27
|
this.route.params.subscribe(params => {
|
28
|
if (params['stakeholder']) {
|
29
|
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
30
|
if (stakeholder) {
|
31
|
if (stakeholder.type === "funder") {
|
32
|
this.navigateToError();
|
33
|
} else if (stakeholder.type === "organization") {
|
34
|
let value = stakeholder.index_id;
|
35
|
this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, "");
|
36
|
this.customFilter.isHiddenFilter = false;
|
37
|
} else if (stakeholder.type === "ri") {
|
38
|
this.navigateToError();
|
39
|
}
|
40
|
this.initialized = true;
|
41
|
}
|
42
|
});
|
43
|
}
|
44
|
});
|
45
|
}
|
46
|
|
47
|
navigateToError() {
|
48
|
this.router.navigate(['/error'], {queryParams: {'page': this.router.url}});
|
49
|
}
|
50
|
}
|