diff --git a/src/app/contact/contact.component.html b/src/app/contact/contact.component.html index d84995b..51fc28c 100644 --- a/src/app/contact/contact.component.html +++ b/src/app/contact/contact.component.html @@ -1,5 +1,4 @@ - @@ -32,92 +31,9 @@
-
-
Contact us to create your Monitor Dashboard
- -
-
* Required - fields -
-
- -
- Please add a name. -
- -
-
- -
- Please add a surname. -
- -
-
- -
- Please add an email. -
-
Please add a valid email. -
- -
-
- -
Please add an affiliation. -
- -
- -
-
Please add a funder name. -
- -
- -
-
- Please write us a message. -
- -
-
-
Please complete reCaptcha challenge. -
- -
-
- - - -
-
-
+
@@ -127,9 +43,9 @@ - +
Our team will respond to your submission soon.
- Press OK to redirect to OpenAIRE Connect home page. + Press OK to redirect to OpenAIRE Monitor home page.
diff --git a/src/app/contact/contact.component.ts b/src/app/contact/contact.component.ts index 3a350e6..d378907 100644 --- a/src/app/contact/contact.component.ts +++ b/src/app/contact/contact.component.ts @@ -1,16 +1,15 @@ -import {Component, OnInit, Input, ElementRef, ViewChild} from '@angular/core'; -import {FormGroup} from '@angular/forms'; +import {Component, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {EmailService} from "../openaireLibrary/utils/email/email.service"; import {Email} from "../openaireLibrary/utils/email/email"; import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties"; -import {ContactForm} from "../openaireLibrary/utils/email/contact-form"; import {Composer} from "../openaireLibrary/utils/email/composer"; import {Meta, Title} from "@angular/platform-browser"; import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service"; import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class"; import {HelperService} from "../openaireLibrary/utils/helper/helper.service"; import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service"; +import {FormBuilder, FormGroup, Validators} from "@angular/forms"; @Component({ selector: 'contact', @@ -18,152 +17,139 @@ import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service"; }) export class ContactComponent implements OnInit { - public url: string = null; - public pageTitle: string = "OpenAIRE - Connect | Contact Us"; + public url: string = null; + public pageTitle: string = "OpenAIRE - Monitor | Contact Us"; + public piwiksub: any; + public showLoading = true; + public errorMessage = ''; + public email: Email; + public properties: EnvProperties = null; + public pageContents = null; + public divContents = null; - @Input('group') - myForm: FormGroup; - public piwiksub: any; - public showLoading = true; - public errorMessage = ''; - public isSubmitted = false; - public email: Email; - public note = ''; - public properties: EnvProperties = null; - public pageContents = null; - public divContents = null; + public contactForm: FormGroup; + @ViewChild('AlertModal') modal; + @ViewChild('recaptcha') recaptcha; - public contactForm: ContactForm = new ContactForm(); - @ViewChild('AlertModal') modal; - @ViewChild('name') name; - @ViewChild('surname') surname; - @ViewChild('sender') sender; - @ViewChild('affiliation') affiliation; - @ViewChild('community') community; - @ViewChild('message') message; - @ViewChild('recaptcha') recaptcha; + constructor(private route: ActivatedRoute, + private _router: Router, + private _emailService: EmailService, + private _meta: Meta, + private _title: Title, + private seoService: SEOService, + private _piwikService: PiwikService, + private fb: FormBuilder, + private helper: HelperService) { + } - constructor(private route: ActivatedRoute, - private _router: Router, - private _emailService: EmailService, - private _meta: Meta, - private _title: Title, - private seoService: SEOService, - private _piwikService: PiwikService, - private helper: HelperService) { - } + ngOnInit() { + this._title.setTitle('OpenAIRE-Monitor | Contact Us'); + this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { + this.properties = data.envSpecific; + this.email = {body: '', subject: '', recipients: []}; - ngOnInit() { - this._title.setTitle('OpenAIRE-Connect | Contact Us'); - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.email = {body: '', subject: '', recipients: []}; + if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { + this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.properties.piwikSiteId).subscribe(); + } + this.url = this.properties.baseLink + this._router.url; + this.seoService.createLinkForCanonicalURL(this.url); + this.updateUrl(this.url); + this.updateTitle(this.pageTitle); + this.updateDescription("OpenAIRE - Monitor, Community Gateway, research community"); + this.reset(); + //this.getDivContents(); + this.getPageContents(); + HelperFunctions.scroll(); + this.showLoading = false; + }); + } - if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.properties.piwikSiteId).subscribe(); - } - this.url = this.properties.baseLink + this._router.url; - this.seoService.createLinkForCanonicalURL(this.url); - this.updateUrl(this.url); - this.updateTitle(this.pageTitle); - this.updateDescription("OpenAIRE - Connect, Community Gateway, research community"); + private getPageContents() { + this.helper.getPageHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => { + this.pageContents = contents; + }) + } - //this.getDivContents(); - this.getPageContents(); - HelperFunctions.scroll(); - this.showLoading = false; - }); - } + private getDivContents() { + this.helper.getDivHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => { + this.divContents = contents; + }) + } - private getPageContents() { - this.helper.getPageHelpContents(this._router.url, this.properties, 'connect').subscribe(contents => { - this.pageContents = contents; - }) - } + public send(event) { + HelperFunctions.scroll(); + if(event.valid === true) { + this.sendMail(this.properties.admins); + } else { + this.errorMessage = 'Please fill in all the required fields!'; + } + } - private getDivContents() { - this.helper.getDivHelpContents(this._router.url, this.properties, 'connect').subscribe(contents => { - this.divContents = contents; - }) - } + public reset() { + this.contactForm = this.fb.group( { + name: this.fb.control('', Validators.required), + surname: this.fb.control('', Validators.required), + email: this.fb.control('', [Validators.required, Validators.email]), + affiliation: this.fb.control('', Validators.required), + funder: this.fb.control('', Validators.required), + message: this.fb.control('', Validators.required), + recaptcha: this.fb.control('', Validators.required), + }); + this.errorMessage = ''; + } - public send() { - HelperFunctions.scroll(); - if(!this.name.invalid && !this.surname.invalid && !this.sender.invalid && - this.contactForm.email.match('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$') && - !this.affiliation.invalid && !this.message.invalid && this.contactForm.recaptcha != '') { - this.sendMail(this.properties.admins); - } - else { - this.errorMessage = 'Please fill in all the required fields!' - this.isSubmitted = true; - } - } + private sendMail(admins: any) { + /*this.showLoading = true; + this._emailService.contact(this.properties.adminToolsAPIURL + '/contact', + Composer.composeEmailForNewCommunity(this.contactForm.value, admins), + this.contactForm.value.recaptcha).subscribe( + res => { + if (res) { + this.reset(); + this.modalOpen(); + this.showLoading = false; + } + }, + error => { + this.handleError('Email sent failed! Please try again.', error); + this.showLoading = false; + this.contactForm.get('recaptcha').setValue(''); + } + );*/ + } - public reset() { - this.contactForm = new ContactForm(); - this.isSubmitted = false; - this.errorMessage = ''; - this.contactForm.recaptcha = ''; - } + public modalOpen() { + this.modal.okButton = true; + this.modal.alertTitle = 'Your request has been successfully submitted'; + this.modal.alertMessage = false; + this.modal.cancelButton = false; + this.modal.okButtonLeft = false; + this.modal.okButtonText = 'OK'; + this.modal.open(); + } - private sendMail(admins: any) { - this.showLoading = true; - this._emailService.contact(this.properties.adminToolsAPIURL + '/contact', - Composer.composeEmailForNewCommunity(this.contactForm, admins), this.contactForm.recaptcha).subscribe( - res => { - if(res) { - this.reset(); - this.modalOpen(); - this.showLoading = false; - } - }, - error => { - this.handleError('Email sent failed! Please try again.', error); - this.showLoading = false; - this.contactForm.recaptcha = ''; - } - ); - } + handleError(message: string, error) { + this.errorMessage = message; + console.log('Server responded: ' + error); + this.showLoading = false; + } - public modalOpen() { - this.modal.okButton = true; - this.modal.alertTitle = 'Your request has been successfully submitted'; - this.modal.alertMessage = false; - this.modal.cancelButton = false; - this.modal.okButtonLeft = false; - this.modal.okButtonText = 'OK'; - this.modal.open(); - } + public goToHome() { + this._router.navigate(['/']); + } - public handleRecaptcha(captchaResponse: string) { - this.contactForm.recaptcha = captchaResponse; - } + private updateDescription(description: string) { + this._meta.updateTag({content: description}, "name='description'"); + this._meta.updateTag({content: description}, "property='og:description'"); + } + private updateTitle(title: string) { + var _title = ((title.length > 50) ? title.substring(0, 50) : title); + this._title.setTitle(_title); + this._meta.updateTag({content: _title}, "property='og:title'"); + } - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - public goToHome(data: any) { - this._router.navigate(['/']); - } - - private updateDescription(description: string) { - this._meta.updateTag({content: description}, "name='description'"); - this._meta.updateTag({content: description}, "property='og:description'"); - } - - private updateTitle(title: string) { - var _title = ((title.length > 50) ? title.substring(0, 50) : title); - this._title.setTitle(_title); - this._meta.updateTag({content: _title}, "property='og:title'"); - } - - private updateUrl(url: string) { - this._meta.updateTag({content: url}, "property='og:url'"); - } + private updateUrl(url: string) { + this._meta.updateTag({content: url}, "property='og:url'"); + } } diff --git a/src/app/contact/contact.module.ts b/src/app/contact/contact.module.ts index 3309a8b..95fec20 100644 --- a/src/app/contact/contact.module.ts +++ b/src/app/contact/contact.module.ts @@ -1,6 +1,5 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; import {RouterModule} from '@angular/router'; import {ContactComponent} from './contact.component'; @@ -13,14 +12,15 @@ import {HelperModule} from "../openaireLibrary/utils/helper/helper.module"; import {IsRouteEnabled} from "../openaireLibrary/error/isRouteEnabled.guard"; import {Schema2jsonldModule} from "../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module"; import {SEOServiceModule} from "../openaireLibrary/sharedComponents/SEO/SEOService.module"; +import {ContactUsModule} from "../openaireLibrary/contact-us/contact-us.module"; @NgModule({ - imports: [ - ContactRoutingModule, CommonModule, FormsModule, RouterModule, - AlertModalModule, RecaptchaModule.forRoot(), HelperModule, - Schema2jsonldModule, SEOServiceModule - ], + imports: [ + ContactRoutingModule, CommonModule, RouterModule, + AlertModalModule, RecaptchaModule.forRoot(), HelperModule, + Schema2jsonldModule, SEOServiceModule, ContactUsModule + ], declarations: [ ContactComponent ],