1 |
55209
|
k.triantaf
|
import {Component, Input, ViewChild} from '@angular/core';
|
2 |
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
3 |
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
4 |
56808
|
k.triantaf
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
5 |
55209
|
k.triantaf
|
import {CommunityInfo} from "../../connect/community/communityInfo";
|
6 |
|
|
import {Router} from "@angular/router";
|
7 |
56808
|
k.triantaf
|
import {LocalStorageService} from "../../services/localStorage.service";
|
8 |
|
|
|
9 |
55209
|
k.triantaf
|
@Component({
|
10 |
|
|
selector: 'community-search-result',
|
11 |
56808
|
k.triantaf
|
templateUrl: 'communitySearchResults.component.html'
|
12 |
55209
|
k.triantaf
|
})
|
13 |
|
|
|
14 |
|
|
export class CommunitySearchResultsComponent {
|
15 |
55339
|
k.triantaf
|
@Input() results: CommunityInfo[];
|
16 |
55209
|
k.triantaf
|
@Input() status: number;
|
17 |
|
|
@Input() type: string;
|
18 |
56845
|
k.triantaf
|
@Input() showType = false;
|
19 |
55209
|
k.triantaf
|
@Input() showLoading: boolean = false;
|
20 |
|
|
@Input() custom_class: string = "search-results";
|
21 |
|
|
@Input() properties: EnvProperties;
|
22 |
55234
|
k.triantaf
|
@Input() maxCharacters: number = 150;
|
23 |
55209
|
k.triantaf
|
@ViewChild('AlertModal') modal;
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
public urlParam: string;
|
27 |
56808
|
k.triantaf
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
28 |
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
29 |
55209
|
k.triantaf
|
public errorMessage: string = "No results found";
|
30 |
|
|
public selectedCommunityId: string;
|
31 |
56808
|
k.triantaf
|
public directLink: boolean = true;
|
32 |
55209
|
k.triantaf
|
|
33 |
|
|
|
34 |
56808
|
k.triantaf
|
constructor(private router: Router,
|
35 |
|
|
private localStorageService: LocalStorageService) {
|
36 |
55209
|
k.triantaf
|
}
|
37 |
|
|
|
38 |
56808
|
k.triantaf
|
ngOnInit() {
|
39 |
|
|
this.localStorageService.get().subscribe(value => {
|
40 |
|
|
this.directLink = value;
|
41 |
|
|
});
|
42 |
55209
|
k.triantaf
|
}
|
43 |
|
|
|
44 |
56808
|
k.triantaf
|
getProductionPrefix(): string {
|
45 |
58470
|
argiro.kok
|
// return (this.properties.environment == "beta") ? "beta." : "";
|
46 |
|
|
return "beta.";
|
47 |
56808
|
k.triantaf
|
}
|
48 |
55209
|
k.triantaf
|
|
49 |
56808
|
k.triantaf
|
isProduction(): boolean {
|
50 |
|
|
return this.properties.environment != "development";
|
51 |
|
|
|
52 |
55209
|
k.triantaf
|
}
|
53 |
|
|
|
54 |
56808
|
k.triantaf
|
public _formatDescription(description) {
|
55 |
|
|
return (((description).length > this.maxCharacters) ? (description.substring(0, (this.maxCharacters - ('...').length)) + "...") : description);
|
56 |
55234
|
k.triantaf
|
}
|
57 |
|
|
|
58 |
55209
|
k.triantaf
|
public confirmModalOpen(community: CommunityInfo) {
|
59 |
57791
|
argiro.kok
|
this.selectedCommunityId = (this.type == 'community')? community.communityId:community['alias'];
|
60 |
56808
|
k.triantaf
|
this.modal.cancelButton = true;
|
61 |
|
|
this.modal.okButton = true;
|
62 |
|
|
this.modal.alertTitle = 'You are going to visit ' +
|
63 |
57791
|
argiro.kok
|
((community.title) ? community.title : community.shortTitle) + (this.type == 'community')? ' Gateway':' Monitor Dashboard';
|
64 |
56808
|
k.triantaf
|
this.modal.alertMessage = false;
|
65 |
|
|
this.modal.okButtonLeft = false;
|
66 |
|
|
this.modal.okButtonText = 'Yes';
|
67 |
|
|
this.modal.cancelButtonText = 'No';
|
68 |
|
|
this.modal.choice = true;
|
69 |
|
|
this.modal.open();
|
70 |
55209
|
k.triantaf
|
}
|
71 |
|
|
|
72 |
57791
|
argiro.kok
|
public getCommunityPageUrl(entity): string {
|
73 |
55209
|
k.triantaf
|
let url = '';
|
74 |
56808
|
k.triantaf
|
if (this.isProduction()) {
|
75 |
57791
|
argiro.kok
|
url = 'https://' + this.getProductionPrefix() + entity.communityId + '.openaire.eu';
|
76 |
55209
|
k.triantaf
|
} else {
|
77 |
|
|
url = this.router.createUrlTree(['/'], {
|
78 |
57791
|
argiro.kok
|
queryParams: {'communityId': entity.communityId}
|
79 |
56808
|
k.triantaf
|
}).toString();
|
80 |
55209
|
k.triantaf
|
}
|
81 |
57791
|
argiro.kok
|
if(this.type == 'funder'){
|
82 |
|
|
url = "http://dl170.madgik.di.uoa.gr/monitor/dashboard/"+entity.alias;
|
83 |
|
|
}
|
84 |
56808
|
k.triantaf
|
return url;
|
85 |
55209
|
k.triantaf
|
}
|
86 |
56808
|
k.triantaf
|
|
87 |
|
|
public goToCommunityPage(data: any) {
|
88 |
|
|
if (data.value == true) {
|
89 |
|
|
this.localStorageService.setCommunityDirectLink(data.choice);
|
90 |
|
|
let url = '';
|
91 |
|
|
if (this.isProduction()) {
|
92 |
|
|
url = 'https://' + this.getProductionPrefix() + this.selectedCommunityId + '.openaire.eu';
|
93 |
|
|
} else {
|
94 |
|
|
url = this.router.createUrlTree(['/'], {
|
95 |
|
|
queryParams: {'communityId': this.selectedCommunityId}
|
96 |
|
|
}).toString();
|
97 |
|
|
}
|
98 |
57791
|
argiro.kok
|
if(this.type == 'funder'){
|
99 |
|
|
url = "http://dl170.madgik.di.uoa.gr/monitor/dashboard/"+this.selectedCommunityId;
|
100 |
|
|
}
|
101 |
|
|
console.log(url)
|
102 |
56808
|
k.triantaf
|
window.open(url, '_blank');
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
55209
|
k.triantaf
|
}
|