1
|
import {Component, Input} from '@angular/core';
|
2
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
3
|
import {CuratorService} from "../openaireLibrary/connect/curators/curator.service";
|
4
|
import {Curator} from "../openaireLibrary/utils/entities/CuratorInfo";
|
5
|
import {ActivatedRoute, Router} from "@angular/router";
|
6
|
import {CommunitiesService} from "../openaireLibrary/connect/communities/communities.service";
|
7
|
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
|
8
|
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
9
|
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
10
|
import {Meta, Title} from "@angular/platform-browser";
|
11
|
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
12
|
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
|
13
|
import {PiwikHelper} from "../utils/piwikHelper";
|
14
|
|
15
|
@Component({
|
16
|
selector: 'curators',
|
17
|
templateUrl: './curators.component.html'
|
18
|
|
19
|
})
|
20
|
|
21
|
export class CuratorsComponent {
|
22
|
@Input() managers: string[];
|
23
|
@Input() communityId = null;
|
24
|
@Input() longView = true;
|
25
|
public downloadUrl = null;
|
26
|
public showLoading = true;
|
27
|
|
28
|
public curators: Curator[];
|
29
|
|
30
|
public showMore = [];
|
31
|
public maxCharacters = 500;
|
32
|
|
33
|
public properties: EnvProperties;
|
34
|
public pageContents = null;
|
35
|
public divContents = null;
|
36
|
|
37
|
public piwiksub: any;
|
38
|
public url: string = null;
|
39
|
public pageTitle: string = "Curators";
|
40
|
|
41
|
constructor (private route: ActivatedRoute,
|
42
|
private curatorsService: CuratorService,
|
43
|
private communitiesService: CommunitiesService,
|
44
|
private _router: Router,
|
45
|
private helper: HelperService,
|
46
|
private _meta: Meta,
|
47
|
private _title: Title,
|
48
|
private seoService: SEOService,
|
49
|
private _piwikService: PiwikService) {}
|
50
|
|
51
|
ngOnInit() {
|
52
|
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
|
53
|
this.showLoading = true;
|
54
|
this.properties = data.envSpecific;
|
55
|
if(this.longView) {
|
56
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
57
|
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe();
|
58
|
}
|
59
|
this.url = this.properties.baseLink + this._router.url;
|
60
|
this.seoService.createLinkForCanonicalURL(this.url);
|
61
|
this.updateUrl(this.url);
|
62
|
this.updateTitle(this.pageTitle);
|
63
|
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community");
|
64
|
}
|
65
|
this.downloadUrl = this.properties.utilsService + '/download/';
|
66
|
if(!this.longView) {
|
67
|
let emails = this.managers.join();
|
68
|
this.curatorsService.getCurators(this.properties, emails).subscribe(curators => {
|
69
|
this.curators = curators;
|
70
|
for(let i = 0; i < this.curators.length; i++) {
|
71
|
this.showMore[i]= false;
|
72
|
}
|
73
|
this.showLoading = false;
|
74
|
HelperFunctions.scroll();
|
75
|
})
|
76
|
} else {
|
77
|
this.route.queryParams.subscribe(data => {
|
78
|
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
79
|
if(!this.communityId) {
|
80
|
this.communityId = data['communityId'];
|
81
|
}
|
82
|
//this.getDivContents();
|
83
|
this.getPageContents();
|
84
|
this.communitiesService.getCommunities(this.properties,
|
85
|
this.properties.communityAPI + this.communityId).subscribe(community => {
|
86
|
this.managers = community[0].managers;
|
87
|
let emails = this.managers.join();
|
88
|
this.curatorsService.getCurators(this.properties, emails).subscribe(curators => {
|
89
|
this.curators = curators;
|
90
|
for(let i = 0; i < this.curators.length; i++) {
|
91
|
this.showMore[i]= false;
|
92
|
}
|
93
|
this.showLoading = false;
|
94
|
HelperFunctions.scroll();
|
95
|
});
|
96
|
})
|
97
|
});
|
98
|
}
|
99
|
});
|
100
|
}
|
101
|
|
102
|
ngOnDestroy() {
|
103
|
if(this.piwiksub) {
|
104
|
this.piwiksub.unsubscribe();
|
105
|
}
|
106
|
}
|
107
|
|
108
|
private getPageContents() {
|
109
|
this.helper.getPageHelpContents(this.properties, 'connect', this._router.url).subscribe(contents => {
|
110
|
this.pageContents = contents;
|
111
|
})
|
112
|
}
|
113
|
|
114
|
private getDivContents() {
|
115
|
this.helper.getDivHelpContents(this.properties, 'connect', this._router.url).subscribe(contents => {
|
116
|
this.divContents = contents;
|
117
|
})
|
118
|
}
|
119
|
|
120
|
public toggle(index: number) {
|
121
|
this.showMore[index] = !this.showMore[index];
|
122
|
}
|
123
|
|
124
|
_format(name: string){
|
125
|
if(name) {
|
126
|
return (((name).length > this.maxCharacters) ? (name.substring(0, (this.maxCharacters - ('...').length)) + '...') : name);
|
127
|
} else {
|
128
|
return null;
|
129
|
}
|
130
|
}
|
131
|
|
132
|
private updateDescription(description: string) {
|
133
|
this._meta.updateTag({content: description}, "name='description'");
|
134
|
this._meta.updateTag({content: description}, "property='og:description'");
|
135
|
}
|
136
|
|
137
|
private updateTitle(title: string) {
|
138
|
var _title = ((title.length > 50) ? title.substring(0, 50) : title);
|
139
|
this._title.setTitle(_title);
|
140
|
this._meta.updateTag({content: _title}, "property='og:title'");
|
141
|
}
|
142
|
|
143
|
private updateUrl(url: string) {
|
144
|
this._meta.updateTag({content: url}, "property='og:url'");
|
145
|
}
|
146
|
}
|