2020-04-03 18:02:40 +02:00
|
|
|
import {Component} from '@angular/core';
|
2018-11-22 16:29:51 +01:00
|
|
|
import {ActivatedRoute} from '@angular/router';
|
|
|
|
import {PiwikHelper} from '../../utils/piwikHelper';
|
|
|
|
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
|
2019-06-13 14:32:41 +02:00
|
|
|
import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
2018-01-26 16:00:07 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'openaire-search-find',
|
2018-11-22 16:29:51 +01:00
|
|
|
template: `
|
2020-04-03 18:02:40 +02:00
|
|
|
<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>-->
|
2018-01-26 16:00:07 +01:00
|
|
|
`,
|
|
|
|
})
|
|
|
|
export class OpenaireSearchComponent{
|
2018-11-22 16:29:51 +01:00
|
|
|
connectCommunityId:string;
|
2019-06-13 14:32:41 +02:00
|
|
|
customFilter: SearchCustomFilter = null;
|
2018-11-22 16:29:51 +01:00
|
|
|
piwikSiteId = null;
|
|
|
|
constructor ( private route: ActivatedRoute) {
|
2018-01-26 16:00:07 +01:00
|
|
|
}
|
|
|
|
ngOnInit() {
|
2019-03-01 12:34:19 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: any }) => {
|
|
|
|
var communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
|
2019-08-02 16:56:03 +02:00
|
|
|
this.piwikSiteId = PiwikHelper.getSiteId(communityId,data.envSpecific.environment);
|
2019-03-01 12:34:19 +01:00
|
|
|
if(communityId){
|
2019-06-13 14:32:41 +02:00
|
|
|
this.connectCommunityId = communityId;
|
|
|
|
this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, "");
|
2019-03-01 12:34:19 +01:00
|
|
|
}else{
|
2019-08-02 16:56:03 +02:00
|
|
|
this.route.queryParams.subscribe(params => {
|
|
|
|
if(params['communityId'] && params['communityId']!=""){
|
|
|
|
this.connectCommunityId = params['communityId'];
|
|
|
|
this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId,data.envSpecific.environment);
|
2019-06-13 14:32:41 +02:00
|
|
|
this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, "");
|
2019-03-01 12:34:19 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2018-11-22 16:29:51 +01:00
|
|
|
}
|
2018-01-26 16:00:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|