1
|
import {Component} from '@angular/core';
|
2
|
import {Subscription} from 'rxjs';
|
3
|
import {ActivatedRoute, Router} from '@angular/router';
|
4
|
import {Location} from '@angular/common';
|
5
|
import 'rxjs/add/observable/zip';
|
6
|
import {Meta, Title} from '@angular/platform-browser';
|
7
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
8
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
9
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
10
|
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
11
|
import {properties} from '../../environments/environment';
|
12
|
import {portals} from './portals';
|
13
|
import {Filter} from '../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class';
|
14
|
import {RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
|
15
|
|
16
|
@Component({
|
17
|
selector: 'home',
|
18
|
templateUrl: 'home.component.html',
|
19
|
styleUrls: ['home.component.css']
|
20
|
})
|
21
|
export class HomeComponent {
|
22
|
public pageTitle = 'OpenAIRE - Research Graph';
|
23
|
public portals: any[] = portals;
|
24
|
public state: number = 0;
|
25
|
public properties: EnvProperties = properties;
|
26
|
public selectedEntity = 'all';
|
27
|
public url: string;
|
28
|
public routerHelper: RouterHelper = new RouterHelper();
|
29
|
public resultTypes: Filter = {
|
30
|
values: [
|
31
|
{name: 'Publications', id: 'publications', selected: true, number: 0},
|
32
|
{name: "Research data", id: "datasets", selected: true, number: 0},
|
33
|
{name: "Software", id: "software", selected: true, number: 0},
|
34
|
{name: "Other research products", id: "other", selected: true, number: 0}
|
35
|
],
|
36
|
filterId: 'type',
|
37
|
countSelectedValues: 0,
|
38
|
filterType: 'checkbox',
|
39
|
originalFilterId: '',
|
40
|
valueIsExact: true,
|
41
|
title: 'Result Types',
|
42
|
filterOperator: 'or'
|
43
|
};
|
44
|
public resultsQuickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
|
45
|
filter: null,
|
46
|
selected: true,
|
47
|
filterId: 'resultbestaccessright',
|
48
|
value: 'Open Access'
|
49
|
};
|
50
|
public keyword: string = '';
|
51
|
private timeouts: any[] = [];
|
52
|
private subs: Subscription[] = [];
|
53
|
|
54
|
constructor(
|
55
|
private route: ActivatedRoute,
|
56
|
private _router: Router,
|
57
|
private location: Location, private _piwikService: PiwikService,
|
58
|
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService
|
59
|
) {
|
60
|
|
61
|
let description = 'OpenAIRE Research Graph is an open resource that aggregates a collection of research data properties (metadata, links) available within the OpenAIRE Open Science infrastructure for funders, organizations, researchers, research communities and publishers to interlink information by using a semantic graph database approach.';
|
62
|
|
63
|
this._title.setTitle(this.pageTitle);
|
64
|
this._meta.updateTag({content: description}, 'name=\'description\'');
|
65
|
this._meta.updateTag({content: description}, 'property=\'og:description\'');
|
66
|
this._meta.updateTag({content: this.pageTitle}, 'property=\'og:title\'');
|
67
|
}
|
68
|
|
69
|
public ngOnInit() {
|
70
|
if (this.properties) {
|
71
|
let url = this.properties.domain + this.properties.baseLink + this._router.url;
|
72
|
this.seoService.createLinkForCanonicalURL(url, false);
|
73
|
this._meta.updateTag({content: url}, 'property=\'og:url\'');
|
74
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
75
|
this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
|
76
|
}
|
77
|
this.animation();
|
78
|
}
|
79
|
}
|
80
|
|
81
|
public ngOnDestroy() {
|
82
|
for (let sub of this.subs) {
|
83
|
sub.unsubscribe();
|
84
|
}
|
85
|
this.clearTimeouts();
|
86
|
}
|
87
|
|
88
|
private animation() {
|
89
|
this.timeouts.push(setTimeout(() => {
|
90
|
this.animation();
|
91
|
if (this.state === (this.portals.length - 1)) {
|
92
|
this.state = 0;
|
93
|
} else {
|
94
|
this.state++;
|
95
|
}
|
96
|
}, 4000));
|
97
|
}
|
98
|
|
99
|
entityChanged($event) {
|
100
|
this.selectedEntity = $event.entity;
|
101
|
this.url = $event.simpleUrl;
|
102
|
}
|
103
|
|
104
|
private changeSlide(slide: number) {
|
105
|
this.clearTimeouts();
|
106
|
this.state = slide;
|
107
|
this.animation();
|
108
|
}
|
109
|
|
110
|
private clearTimeouts() {
|
111
|
this.timeouts.forEach(timeout => {
|
112
|
clearTimeout(timeout);
|
113
|
});
|
114
|
this.state = 0;
|
115
|
}
|
116
|
|
117
|
goTo() {
|
118
|
let url = 'https://explore.openaire.eu' + this.url;
|
119
|
let parameterNames = [];
|
120
|
let parameterValues = [];
|
121
|
if (this.selectedEntity == 'result') {
|
122
|
if (this.resultTypes) {
|
123
|
let values = [];
|
124
|
for (let value of this.resultTypes.values) {
|
125
|
if (value.selected) {
|
126
|
values.push(value.id);
|
127
|
}
|
128
|
}
|
129
|
if (values.length > 0 && values.length != 4) {
|
130
|
parameterNames.push('type');
|
131
|
parameterValues.push(values.join(','));
|
132
|
}
|
133
|
if (this.resultsQuickFilter) {
|
134
|
parameterNames.push('qf');
|
135
|
parameterValues.push('' + this.resultsQuickFilter.selected);
|
136
|
}
|
137
|
}
|
138
|
} else if (this.selectedEntity == 'all') {
|
139
|
if (this.resultsQuickFilter) {
|
140
|
parameterNames.push('qf');
|
141
|
parameterValues.push('true');
|
142
|
}
|
143
|
}
|
144
|
if (this.keyword.length > 0) {
|
145
|
parameterNames.push('fv0');
|
146
|
parameterValues.push(this.keyword);
|
147
|
parameterNames.push('f0');
|
148
|
parameterValues.push('q');
|
149
|
}
|
150
|
window.open(url + this.routerHelper.createQueryParamsString(parameterNames, parameterValues), '_blank').focus();
|
151
|
}
|
152
|
}
|