connect/src/app/searchPages/find/search.component.ts

41 lines
1.7 KiB
TypeScript
Raw Normal View History

import {Component, ViewChild, ElementRef} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {PiwikHelper} from '../../utils/piwikHelper';
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
@Component({
selector: 'openaire-search-find',
template: `
<search-find [customFilter]=customFilter [piwikSiteId]="piwikSiteId" formPlaceholderText="Search for research results"></search-find>
`,
})
export class OpenaireSearchComponent{
connectCommunityId:string;
customFilter: SearchCustomFilter = null;
piwikSiteId = null;
constructor ( private route: ActivatedRoute) {
}
ngOnInit() {
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, "");
}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, "");
}
});
}
});
}
}