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