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

43 lines
1.9 KiB
TypeScript
Raw Normal View History

import {Component} 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-all logoURL = "/assets/common-assets/logo-small-explore.png" name="OpenAIRE Connect" [customFilter]=customFilter [piwikSiteId]="piwikSiteId" ></search-all>
<!-- <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, "");
}
});
}
});
}
}