import {Component, OnInit} from '@angular/core';
import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper";
import {PiwikHelper} from "../../utils/piwikHelper";
import {properties} from "../../../environments/environment";

@Component({
  selector: 'openaire-advanced-search-projects',
  template: `
    <search-projects [simpleView]="false" [customFilter]=customFilter [piwikSiteId]="piwikSiteId" [hasPrefix]="false"
                     [showBreadcrumb]="true" [showSwitchSearchLink]="false">
    </search-projects>
  
  `
})

export class OpenaireAdvancedSearchProjectsComponent implements OnInit {
  communityId: string;
  piwikSiteId;
  customFilter: SearchCustomFilter = null;
  
  constructor() {
  }
  
  ngOnInit() {
    let communityId = ConnectHelper.getCommunityFromDomain(properties.domain);
    if (communityId) {
      this.communityId = communityId;
      this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment);
      this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, "");
      this.customFilter.isHiddenFilter = false;
    }
  }
}
