import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {ActivatedRoute} from "@angular/router"; import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper"; import {PiwikHelper} from "../../utils/piwikHelper"; import {Subscriber} from "rxjs"; @Component({ selector: 'openaire-advanced-search-projects', template: ` ` }) export class OpenaireAdvancedSearchProjectsComponent { connectCommunityId:string; piwikSiteId = null; customFilter: SearchCustomFilter = null; constructor ( private route: ActivatedRoute) { } sub; ngOnDestroy() { if (this.sub instanceof Subscriber) { this.sub.unsubscribe(); } } ngOnInit() { this.sub = this.route.data .subscribe((data: { envSpecific: any }) => { var communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain); this.piwikSiteId = PiwikHelper.getSiteId(communityId, data.envSpecific.environment); if(communityId){ this.connectCommunityId = communityId; this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); this.customFilter.isHiddenFilter = false; } else{ this.route.queryParams.subscribe(params => { if(params['communityId'] && params['communityId']!=""){ this.connectCommunityId = params['communityId']; this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId, data.envSpecific.environment); this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); this.customFilter.isHiddenFilter = false; } }); } }); } }