2019-04-05 19:21:23 +02:00
|
|
|
import {Component, Input, ViewChild} from '@angular/core';
|
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
|
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {CommunityInfo} from "../../connect/community/communityInfo";
|
|
|
|
import {Router} from "@angular/router";
|
|
|
|
@Component({
|
|
|
|
selector: 'community-search-result',
|
|
|
|
templateUrl:'communitySearchResults.component.html'
|
|
|
|
})
|
|
|
|
|
|
|
|
export class CommunitySearchResultsComponent {
|
2019-04-13 20:26:46 +02:00
|
|
|
@Input() results: CommunityInfo[];
|
2019-04-05 19:21:23 +02:00
|
|
|
@Input() status: number;
|
|
|
|
@Input() type: string;
|
|
|
|
@Input() showLoading: boolean = false;
|
|
|
|
@Input() custom_class: string = "search-results";
|
|
|
|
@Input() properties: EnvProperties;
|
2019-04-08 16:53:09 +02:00
|
|
|
@Input() maxCharacters: number = 150;
|
2019-04-05 19:21:23 +02:00
|
|
|
@ViewChild('AlertModal') modal;
|
|
|
|
|
|
|
|
|
|
|
|
public urlParam: string;
|
|
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
|
|
|
public errorMessage: string = "No results found";
|
|
|
|
public selectedCommunityId: string;
|
|
|
|
constructor(private router: Router) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getProductionPrefix():string{
|
2019-04-08 16:53:09 +02:00
|
|
|
return (this.properties.environment == "beta")?"beta.":""
|
2019-04-05 19:21:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
isProduction():boolean{
|
|
|
|
return this.properties.environment!="development";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-04-08 16:53:09 +02:00
|
|
|
public _formatDescription(description){
|
2019-04-10 00:06:34 +02:00
|
|
|
return (((description).length > this.maxCharacters)?(description.substring(0,(this.maxCharacters - ('...').length))+"..."):description);
|
2019-04-08 16:53:09 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 19:21:23 +02:00
|
|
|
public confirmModalOpen(community: CommunityInfo) {
|
|
|
|
this.selectedCommunityId = community.communityId;
|
|
|
|
this.modal.cancelButton = true;
|
|
|
|
this.modal.okButton = true;
|
|
|
|
this.modal.alertTitle = 'You have selected ' + community.title;
|
|
|
|
this.modal.alertMessage = false;
|
|
|
|
this.modal.okButtonLeft = false;
|
|
|
|
this.modal.okButtonText = 'Yes';
|
|
|
|
this.modal.cancelButtonText = 'No';
|
|
|
|
this.modal.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
public goToCommunityPage(data: any) {
|
|
|
|
let url = '';
|
|
|
|
if(this.isProduction()) {
|
|
|
|
url = 'https://'+ this.getProductionPrefix() + this.selectedCommunityId +'.openaire.eu';
|
|
|
|
} else {
|
|
|
|
url = this.router.createUrlTree(['/'], {
|
|
|
|
queryParams: { 'communityId': this.selectedCommunityId} }).toString();
|
|
|
|
}
|
|
|
|
window.open(url, '_blank');
|
|
|
|
}
|
|
|
|
}
|