2020-07-10 10:38:52 +02:00
|
|
|
import {Component} from '@angular/core';
|
|
|
|
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
|
|
|
import {ActivatedRoute, Router} from "@angular/router";
|
|
|
|
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
|
2020-11-13 17:42:12 +01:00
|
|
|
import {Subscriber} from "rxjs";
|
2020-11-27 11:46:58 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2020-12-18 16:31:21 +01:00
|
|
|
import {ConfigurationService} from "../../../openaireLibrary/utils/configuration/configuration.service";
|
2020-07-10 10:38:52 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'monitor-search-projects',
|
|
|
|
template: `
|
|
|
|
<search-projects *ngIf="initialized"
|
|
|
|
[customFilter]=customFilter [hasPrefix]="false"
|
2020-11-27 11:46:58 +01:00
|
|
|
[includeOnlyResultsAndFilter]="false"
|
2020-12-18 16:31:21 +01:00
|
|
|
[openaireLink]="'https://'+(properties.environment != 'production'?'beta.':'')+'explore.openaire.eu/search/simple/projects'"
|
|
|
|
[piwikSiteId]="piwikSiteId">
|
2020-07-10 10:38:52 +02:00
|
|
|
</search-projects>
|
|
|
|
`
|
|
|
|
|
|
|
|
})
|
|
|
|
export class MonitorSearchProjectsComponent {
|
|
|
|
customFilter: SearchCustomFilter = null;
|
|
|
|
initialized: boolean = false;
|
2020-12-18 16:31:21 +01:00
|
|
|
properties;
|
|
|
|
piwikSiteId;
|
2020-07-10 10:38:52 +02:00
|
|
|
constructor(private route: ActivatedRoute,
|
|
|
|
private router: Router,
|
2020-12-18 16:31:21 +01:00
|
|
|
private stakeholderService: StakeholderService, private configurationService: ConfigurationService) {
|
2020-07-10 10:38:52 +02:00
|
|
|
}
|
2020-11-13 17:42:12 +01:00
|
|
|
subscriptions = [];
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-10 10:38:52 +02:00
|
|
|
ngOnInit() {
|
2020-11-27 11:46:58 +01:00
|
|
|
this.properties = properties;
|
2020-11-13 17:42:12 +01:00
|
|
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
2020-07-10 10:38:52 +02:00
|
|
|
if (params['stakeholder']) {
|
2020-11-13 17:42:12 +01:00
|
|
|
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
2020-07-10 10:38:52 +02:00
|
|
|
if (stakeholder) {
|
|
|
|
if (stakeholder.type === "funder") {
|
2020-08-04 09:57:51 +02:00
|
|
|
let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName;
|
|
|
|
this.customFilter = new SearchCustomFilter("Funder", "funder", value, "");
|
2020-07-10 10:38:52 +02:00
|
|
|
} else if (stakeholder.type === "organization") {
|
|
|
|
let value = stakeholder.index_id;
|
|
|
|
this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, "");
|
|
|
|
} else if (stakeholder.type === "ri") {
|
|
|
|
this.navigateToError();
|
|
|
|
}
|
2020-12-18 16:31:21 +01:00
|
|
|
this.subscriptions.push(this.configurationService.communityInformationState.subscribe(portal => {
|
|
|
|
if (portal) {
|
|
|
|
this.piwikSiteId = portal.piwik;
|
|
|
|
}
|
|
|
|
}));
|
2020-07-10 10:38:52 +02:00
|
|
|
this.initialized = true;
|
2020-07-13 11:23:04 +02:00
|
|
|
|
2020-07-10 10:38:52 +02:00
|
|
|
}
|
2020-11-13 17:42:12 +01:00
|
|
|
}));
|
2020-07-10 10:38:52 +02:00
|
|
|
}
|
2020-11-13 17:42:12 +01:00
|
|
|
}));
|
2020-07-10 10:38:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
navigateToError() {
|
|
|
|
this.router.navigate(['/error'], {queryParams: {'page': this.router.url}});
|
|
|
|
}
|
|
|
|
}
|