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