1
|
import {Component, Input} from '@angular/core';
|
2
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
3
|
import {ActivatedRoute, Router} from "@angular/router";
|
4
|
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
|
5
|
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
|
6
|
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
7
|
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
8
|
import {Meta, Title} from "@angular/platform-browser";
|
9
|
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
10
|
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
|
11
|
import {PiwikHelper} from "../utils/piwikHelper";
|
12
|
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
13
|
import {Breadcrumb} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.component";
|
14
|
|
15
|
@Component({
|
16
|
selector: 'subjects',
|
17
|
template: `
|
18
|
<schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other"></schema2jsonld>
|
19
|
|
20
|
<div style=" min-height: 650px;" class="communityBackground">
|
21
|
<div class="uk-section uk-padding-remove-top uk-padding-remove-bottom">
|
22
|
<breadcrumbs addClass="uk-margin-large-left uk-margin-remove-bottom uk-margin-small-top" [breadcrumbs]="breadcrumbs"></breadcrumbs>
|
23
|
<!-- <div *ngIf="communityId != null && communityId != ''" -->
|
24
|
<!-- class="uk-container uk-container-large uk-margin-top white-box-with-border">-->
|
25
|
|
26
|
<div class="uk-container uk-container-large">
|
27
|
<div *ngIf="showLoading">
|
28
|
<div class="uk-animation-fade uk-width-1-1" role="alert"><span
|
29
|
class="loading-gif uk-align-center"></span></div>
|
30
|
</div>
|
31
|
<div *ngIf="!showLoading">
|
32
|
<div class="uk-h2 uk-margin-bottom uk-margin-medium-top">
|
33
|
<span>Subjects</span>
|
34
|
</div>
|
35
|
|
36
|
<div style=" min-height: 250px;" class="white-box-with-border uk-padding uk-list">
|
37
|
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
|
38
|
[texts]="pageContents['top']"></helper>
|
39
|
|
40
|
<span *ngFor="let subject of subjects let i=index">
|
41
|
<span *ngIf="subject != ''">
|
42
|
<a class="portal-link"
|
43
|
[queryParams]="{f0:'resultsubject',fv0:createParams(subject)}"
|
44
|
routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToAdvancedResults" >
|
45
|
<span>{{subject}}</span>
|
46
|
</a>
|
47
|
<span *ngIf="i < subjects.length-1">, </span>
|
48
|
</span>
|
49
|
</span>
|
50
|
</div>
|
51
|
</div>
|
52
|
</div>
|
53
|
</div>
|
54
|
</div>
|
55
|
`
|
56
|
|
57
|
})
|
58
|
|
59
|
export class SubjectsComponent {
|
60
|
public subjects: string[];
|
61
|
@Input() communityId = null;
|
62
|
public showLoading = true;
|
63
|
|
64
|
public properties: EnvProperties;
|
65
|
public pageContents = null;
|
66
|
public divContents = null;
|
67
|
|
68
|
public piwiksub: any;
|
69
|
public url: string = null;
|
70
|
public pageTitle: string = "Subjects";
|
71
|
|
72
|
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'about - subjects'}];
|
73
|
|
74
|
constructor (private route: ActivatedRoute,
|
75
|
private communityService: CommunityService,
|
76
|
private _router: Router,
|
77
|
private helper: HelperService,
|
78
|
private _meta: Meta,
|
79
|
private _title: Title,
|
80
|
private seoService: SEOService,
|
81
|
private _piwikService: PiwikService) {}
|
82
|
|
83
|
ngOnInit() {
|
84
|
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
|
85
|
this.showLoading = true;
|
86
|
this.properties = data.envSpecific;
|
87
|
|
88
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
89
|
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe();
|
90
|
}
|
91
|
this.url = this.properties.baseLink + this._router.url;
|
92
|
this.seoService.createLinkForCanonicalURL(this.url);
|
93
|
this.updateUrl(this.url);
|
94
|
this.updateTitle(this.pageTitle);
|
95
|
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community");
|
96
|
|
97
|
this.route.queryParams.subscribe(data => {
|
98
|
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
99
|
if(!this.communityId) {
|
100
|
this.communityId = data['communityId'];
|
101
|
}
|
102
|
//this.getDivContents();
|
103
|
this.getPageContents();
|
104
|
this.communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(community => {
|
105
|
this.subjects = community.subjects;
|
106
|
this.showLoading = false;
|
107
|
HelperFunctions.scroll();
|
108
|
});
|
109
|
});
|
110
|
});
|
111
|
}
|
112
|
|
113
|
createParams(param) {
|
114
|
return StringUtils.quote(StringUtils.URIEncode(param));
|
115
|
}
|
116
|
|
117
|
ngOnDestroy() {
|
118
|
if(this.piwiksub) {
|
119
|
this.piwiksub.unsubscribe();
|
120
|
}
|
121
|
}
|
122
|
|
123
|
private getPageContents() {
|
124
|
this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
125
|
this.pageContents = contents;
|
126
|
})
|
127
|
}
|
128
|
|
129
|
private getDivContents() {
|
130
|
this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
131
|
this.divContents = contents;
|
132
|
})
|
133
|
}
|
134
|
|
135
|
private updateDescription(description: string) {
|
136
|
this._meta.updateTag({content: description}, "name='description'");
|
137
|
this._meta.updateTag({content: description}, "property='og:description'");
|
138
|
}
|
139
|
|
140
|
private updateTitle(title: string) {
|
141
|
var _title = ((title.length > 50) ? title.substring(0, 50) : title);
|
142
|
this._title.setTitle(_title);
|
143
|
this._meta.updateTag({content: _title}, "property='og:title'");
|
144
|
}
|
145
|
|
146
|
private updateUrl(url: string) {
|
147
|
this._meta.updateTag({content: url}, "property='og:url'");
|
148
|
}
|
149
|
}
|