1
|
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
2
|
import {ViewChild, ChangeDetectionStrategy} from '@angular/core';
|
3
|
import {ViewEncapsulation} from '@angular/core';
|
4
|
import {ActivatedRoute, Router} from '@angular/router';
|
5
|
import {Location} from '@angular/common';
|
6
|
|
7
|
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
|
8
|
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
|
9
|
import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo';
|
10
|
|
11
|
@Component({
|
12
|
selector: 'browse-community',
|
13
|
templateUrl: 'browse-community.component.html'
|
14
|
})
|
15
|
|
16
|
export class BrowseCommunityComponent {
|
17
|
@Input() public community: CommunityInfo = null;
|
18
|
@Input() public showDescription: boolean = true;
|
19
|
@ViewChild('AlertModal') modal;
|
20
|
|
21
|
public hiddenMessage: string = "Community is hidden to registered users. It is visible only to users that have privileges to manage community; delay: 100";
|
22
|
// cut title too
|
23
|
// check title length, if is manager, if is private and cut description accordingly
|
24
|
public thresholdTitle: number = 50;
|
25
|
public thresholdDescription: number = 150;
|
26
|
properties:EnvProperties;
|
27
|
|
28
|
constructor ( private route: ActivatedRoute,
|
29
|
private router: Router,
|
30
|
private location: Location) {}
|
31
|
|
32
|
|
33
|
public ngOnInit() {
|
34
|
this.route.data
|
35
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
36
|
this.properties = data.envSpecific;
|
37
|
});
|
38
|
}
|
39
|
|
40
|
public ngOnDestroy() {}
|
41
|
|
42
|
isProduction():boolean{
|
43
|
return this.properties.environment!="development";
|
44
|
}
|
45
|
getProductionPrefix():string{
|
46
|
return (this.properties.environment =="beta")?"beta.":""
|
47
|
}
|
48
|
|
49
|
public confirmModalOpen() {
|
50
|
this.modal.cancelButton = true;
|
51
|
this.modal.okButton = true;
|
52
|
this.modal.alertTitle = 'You have selected ' + this.community.title;
|
53
|
this.modal.alertMessage = false;
|
54
|
this.modal.okButtonLeft = false;
|
55
|
this.modal.okButtonText = 'Yes';
|
56
|
this.modal.cancelButtonText = 'No';
|
57
|
this.modal.open();
|
58
|
}
|
59
|
|
60
|
public goToCommunityPage(data: any) {
|
61
|
let url = '';
|
62
|
if(this.isProduction()) {
|
63
|
url = 'https://'+ this.getProductionPrefix() + this.community.communityId +'.openaire.eu';
|
64
|
} else {
|
65
|
url = this.router.createUrlTree(['/'], {
|
66
|
queryParams: { 'communityId': this.community.communityId} }).toString();
|
67
|
}
|
68
|
window.open(url, '_blank');
|
69
|
}
|
70
|
}
|