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