1
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from '@angular/router';
|
3
|
import {EmailService} from '../openaireLibrary/utils/email/email.service';
|
4
|
import {Email} from '../openaireLibrary/utils/email/email';
|
5
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
6
|
import {Composer} from '../openaireLibrary/utils/email/composer';
|
7
|
import {Meta, Title} from '@angular/platform-browser';
|
8
|
import {HelperFunctions} from '../openaireLibrary/utils/HelperFunctions.class';
|
9
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
10
|
import {properties} from '../../environments/environment';
|
11
|
import {FAQ} from "../openaireLibrary/utils/entities/FAQ";
|
12
|
import {Breadcrumb} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.component";
|
13
|
import {Subscription} from 'rxjs';
|
14
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
15
|
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
16
|
|
17
|
@Component({
|
18
|
selector: 'contact',
|
19
|
templateUrl: './contact.component.html',
|
20
|
styleUrls: ['contact.component.css']
|
21
|
})
|
22
|
|
23
|
export class ContactComponent implements OnInit {
|
24
|
public showLoading = true;
|
25
|
public errorMessage = '';
|
26
|
public email: Email;
|
27
|
public faqs: FAQ[] = [];
|
28
|
public properties: EnvProperties = properties;
|
29
|
subs: Subscription[] = [];
|
30
|
description = "Do you have questions? Contact us";
|
31
|
title = "OpenAIRE - Research Graph | Support";
|
32
|
public contactForm: FormGroup;
|
33
|
@ViewChild('AlertModal') modal;
|
34
|
@ViewChild('recaptcha') recaptcha;
|
35
|
|
36
|
public breadcrumbs: Breadcrumb[] = [
|
37
|
{
|
38
|
name: 'home',
|
39
|
route: '/'
|
40
|
},
|
41
|
{
|
42
|
name: 'support'
|
43
|
}
|
44
|
];
|
45
|
|
46
|
constructor(private router: Router,
|
47
|
private route: ActivatedRoute,
|
48
|
private emailService: EmailService,
|
49
|
private _title: Title,
|
50
|
private _piwikService:PiwikService,
|
51
|
private _meta: Meta, private seoService: SEOService,
|
52
|
private fb: FormBuilder) {
|
53
|
this.setFaqs();
|
54
|
}
|
55
|
|
56
|
ngOnInit() {
|
57
|
this._title.setTitle(this.title);
|
58
|
this._meta.updateTag({content:this.description},"name='description'");
|
59
|
this._meta.updateTag({content:this.description},"property='og:description'");
|
60
|
this._meta.updateTag({content:this.title},"property='og:title'");
|
61
|
this.email = {body: '', subject: '', recipients: []};
|
62
|
this.reset();
|
63
|
this.showLoading = false;
|
64
|
var url = this.properties.domain + this.properties.baseLink+this.router.url;
|
65
|
this.seoService.createLinkForCanonicalURL(url, false);
|
66
|
this._meta.updateTag({content:url},"property='og:url'");
|
67
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
68
|
this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
|
69
|
}
|
70
|
}
|
71
|
|
72
|
public send(event) {
|
73
|
HelperFunctions.scroll();
|
74
|
if (event.valid === true) {
|
75
|
this.sendMail(this.properties.admins);
|
76
|
} else {
|
77
|
this.errorMessage = 'Please fill in all the required fields!';
|
78
|
}
|
79
|
}
|
80
|
|
81
|
public reset() {
|
82
|
this.contactForm = this.fb.group({
|
83
|
name: this.fb.control('', Validators.required),
|
84
|
email: this.fb.control('', [Validators.required, Validators.email]),
|
85
|
affiliation: this.fb.control('', Validators.required),
|
86
|
organization: this.fb.control('', Validators.required),
|
87
|
description: this.fb.control('', Validators.required),
|
88
|
recaptcha: this.fb.control('', Validators.required),
|
89
|
});
|
90
|
this.errorMessage = '';
|
91
|
}
|
92
|
|
93
|
private sendMail(admins: any) {
|
94
|
this.showLoading = true;
|
95
|
this.subs.push(this.emailService.contact(this.properties,
|
96
|
Composer.composeEmailForGraph(this.contactForm.value, admins),
|
97
|
this.contactForm.value.recaptcha).subscribe(
|
98
|
res => {
|
99
|
this.showLoading = false;
|
100
|
if (res) {
|
101
|
this.reset();
|
102
|
this.modalOpen();
|
103
|
} else {
|
104
|
this.errorMessage = 'Email sent failed! Please try again.';
|
105
|
this.contactForm.get('recaptcha').setValue('');
|
106
|
}
|
107
|
},
|
108
|
error => {
|
109
|
this.handleError('Email sent failed! Please try again.', error);
|
110
|
this.showLoading = false;
|
111
|
this.contactForm.get('recaptcha').setValue('');
|
112
|
}
|
113
|
));
|
114
|
}
|
115
|
|
116
|
public modalOpen() {
|
117
|
this.modal.okButton = true;
|
118
|
this.modal.alertTitle = 'Your request has been successfully submitted';
|
119
|
this.modal.alertMessage = false;
|
120
|
this.modal.cancelButton = false;
|
121
|
this.modal.okButtonLeft = false;
|
122
|
this.modal.okButtonText = 'OK';
|
123
|
this.modal.open();
|
124
|
}
|
125
|
|
126
|
handleError(message: string, error) {
|
127
|
this.errorMessage = message;
|
128
|
console.log('Server responded: ' + error);
|
129
|
this.showLoading = false;
|
130
|
}
|
131
|
|
132
|
public goToHome() {
|
133
|
this.router.navigate(['/']);
|
134
|
}
|
135
|
|
136
|
private setFaqs() {
|
137
|
this.faqs.push({
|
138
|
"question": "What are \"trusted\" sources?",
|
139
|
"answer": "OpenAIRE data sources are considered \"trusted\" when researchers rely on them to share, discover, monitor, and assess their scientific products. " +
|
140
|
"Known sources collected by OpenAIRE are institutional repositories (e.g. university archives, libraries), catch-all repositories (e.g. Zenodo, Figshare, Dryad, B2Share, etc.), " +
|
141
|
"data repositories (e.g. Pangaea, GESIS, bio sources), thematic repositories (e.g. ArXiv, EuropePMC, RePec, etc.), " +
|
142
|
"Open Access publishers (e.g. F1000, OpenEdition, etc.), knowledge graphs (e.g. Microsoft Academic Graph, OpenCitations), " +
|
143
|
"registries (e.g. CrossRef, DataCite, ORCID, GRID.ac, OpenDOAR, re3data.org, etc), aggregators " +
|
144
|
"(e.g. Unpaywall, BASE, Scielo, DOAJ, CORE-UK, etc.), funders (e.g. European Commission, NSF, Wellcome Trust, etc.)."
|
145
|
});
|
146
|
|
147
|
this.faqs.push({
|
148
|
"question": "What do you mean with “transparent graph”?",
|
149
|
"answer": "The OpenAIRE Research Graph is transparent because it keeps tracks of the provenance of each and every information it contains. " +
|
150
|
"For each field you can know if they have been collected from one of our sources, if it has been inferred (and with which algorithm and with which confidence level)"
|
151
|
});
|
152
|
}
|
153
|
|
154
|
public ngOnDestroy() {
|
155
|
for (let sub of this.subs) {
|
156
|
sub.unsubscribe();
|
157
|
}
|
158
|
}
|
159
|
}
|