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 {CommunityService} from "../openaireLibrary/connect/community/community.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
|
import {Breadcrumb} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.component";
|
15
|
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
16
|
import {Subscription} from "rxjs";
|
17
|
import {properties} from "../../environments/environment";
|
18
|
import {UserRegistryService} from "../openaireLibrary/services/user-registry.service";
|
19
|
|
20
|
@Component({
|
21
|
selector: 'curators',
|
22
|
templateUrl: './curators.component.html'
|
23
|
|
24
|
})
|
25
|
export class CuratorsComponent {
|
26
|
@Input() longView = true;
|
27
|
communityId = null;
|
28
|
public downloadUrl = null;
|
29
|
public showLoading = true;
|
30
|
|
31
|
public curators: Curator[] = [];
|
32
|
|
33
|
public curatorsLimit: number = 5;
|
34
|
public numberOfCurators: number = 5;
|
35
|
|
36
|
public showMore = [];
|
37
|
public maxCharacters = 500;
|
38
|
|
39
|
public properties: EnvProperties;
|
40
|
public pageContents = null;
|
41
|
public divContents = null;
|
42
|
|
43
|
public url: string = null;
|
44
|
public pageTitle: string = "Curators";
|
45
|
|
46
|
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'About - curators'}];
|
47
|
|
48
|
subs: Subscription[] = [];
|
49
|
|
50
|
constructor(private route: ActivatedRoute,
|
51
|
private curatorsService: CuratorService,
|
52
|
private communityService: CommunityService,
|
53
|
private userRegistryService: UserRegistryService,
|
54
|
private _router: Router,
|
55
|
private helper: HelperService,
|
56
|
private _meta: Meta,
|
57
|
private _title: Title,
|
58
|
private seoService: SEOService,
|
59
|
private _piwikService: PiwikService) {
|
60
|
}
|
61
|
|
62
|
ngOnInit() {
|
63
|
this.showLoading = true;
|
64
|
this.properties = properties;
|
65
|
this.downloadUrl = this.properties.utilsService + '/download/';
|
66
|
//if (properties.environment !== 'development') {
|
67
|
if (!this.longView) {
|
68
|
this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
|
69
|
if (community) {
|
70
|
this.communityId = community.communityId;
|
71
|
this.getCurators();
|
72
|
}
|
73
|
}));
|
74
|
} else {
|
75
|
this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
|
76
|
if (community) {
|
77
|
this.communityId = community.communityId;
|
78
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
79
|
this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe());
|
80
|
}
|
81
|
this.url = this.properties.domain + this._router.url;
|
82
|
this.seoService.createLinkForCanonicalURL(this.url);
|
83
|
this.updateUrl(this.url);
|
84
|
this.updateTitle(this.pageTitle);
|
85
|
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community");
|
86
|
//this.getDivContents();
|
87
|
this.getPageContents();
|
88
|
this.getCurators();
|
89
|
}
|
90
|
}));
|
91
|
}
|
92
|
}
|
93
|
|
94
|
ngOnDestroy() {
|
95
|
for (let sub of this.subs) {
|
96
|
sub.unsubscribe();
|
97
|
}
|
98
|
}
|
99
|
|
100
|
private getCurators() {
|
101
|
this.subs.push(this.curatorsService.getCurators(this.properties, this.communityId).subscribe(curators => {
|
102
|
this.curators = curators;
|
103
|
for (let i = 0; i < this.curators.length; i++) {
|
104
|
this.showMore[i] = false;
|
105
|
}
|
106
|
this.showLoading = false;
|
107
|
}));
|
108
|
}
|
109
|
|
110
|
private getPageContents() {
|
111
|
this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
112
|
this.pageContents = contents;
|
113
|
}));
|
114
|
}
|
115
|
|
116
|
private getDivContents() {
|
117
|
this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
118
|
this.divContents = contents;
|
119
|
}));
|
120
|
}
|
121
|
|
122
|
public toggle(index: number) {
|
123
|
this.showMore[index] = !this.showMore[index];
|
124
|
}
|
125
|
|
126
|
_format(name: string) {
|
127
|
if (name) {
|
128
|
return (((name).length > this.maxCharacters) ? (name.substring(0, (this.maxCharacters - ('...').length)) + '...') : name);
|
129
|
} else {
|
130
|
return null;
|
131
|
}
|
132
|
}
|
133
|
|
134
|
private updateDescription(description: string) {
|
135
|
this._meta.updateTag({content: description}, "name='description'");
|
136
|
this._meta.updateTag({content: description}, "property='og:description'");
|
137
|
}
|
138
|
|
139
|
private updateTitle(title: string) {
|
140
|
var _title = ((title.length > 50) ? title.substring(0, 50) : title);
|
141
|
this._title.setTitle(_title);
|
142
|
this._meta.updateTag({content: _title}, "property='og:title'");
|
143
|
}
|
144
|
|
145
|
private updateUrl(url: string) {
|
146
|
this._meta.updateTag({content: url}, "property='og:url'");
|
147
|
}
|
148
|
}
|