From 4792981c60a0d81b2917abb39ddb28058b68efc5 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Fri, 25 Feb 2022 11:30:47 +0200 Subject: [PATCH] Change contact base on new contact --- src/app/contact/contact.component.html | 8 +++--- src/app/contact/contact.component.ts | 35 ++++++++++++-------------- src/app/openaireLibrary | 2 +- src/assets/openaire-theme | 2 +- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/app/contact/contact.component.html b/src/app/contact/contact.component.html index fb036ac..0923215 100644 --- a/src/app/contact/contact.component.html +++ b/src/app/contact/contact.component.html @@ -7,21 +7,19 @@
- +

Contact us to
learn more.

-
+
-
+
Our team will respond to your submission soon.
Press OK to redirect to OpenAIRE Connect home page.
diff --git a/src/app/contact/contact.component.ts b/src/app/contact/contact.component.ts index 14f7ac4..2a7e063 100644 --- a/src/app/contact/contact.component.ts +++ b/src/app/contact/contact.component.ts @@ -13,6 +13,7 @@ import {FormBuilder, FormGroup, Validators} from "@angular/forms"; import {Breadcrumb} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.component"; import {Subscriber} from "rxjs"; import {properties} from "../../environments/environment"; +import {NotificationHandler} from "../openaireLibrary/utils/notification-handler"; @Component({ selector: 'contact', @@ -23,17 +24,16 @@ export class ContactComponent implements OnInit { public url: string = null; public pageTitle: string = "OpenAIRE - Connect | Contact Us"; public description: string = "Contact us to learn more about OpenAIRE Connect Research Gateways"; - public showLoading = true; - public errorMessage = ''; + public sending = true; public email: Email; - public properties: EnvProperties = null; + public properties: EnvProperties = properties; public pageContents = null; public divContents = null; public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Contact us'}]; - public contactForm: FormGroup; @ViewChild('AlertModal') modal; private subscriptions = []; + ngOnDestroy() { this.subscriptions.forEach(subscription => { if (subscription instanceof Subscriber) { @@ -70,7 +70,7 @@ export class ContactComponent implements OnInit { this.reset(); //this.getDivContents(); this.getPageContents(); - this.showLoading = false; + this.sending = false; } @@ -90,8 +90,6 @@ export class ContactComponent implements OnInit { HelperFunctions.scroll(); if(event.valid === true) { this.sendMail(this.properties.admins); - } else { - this.errorMessage = 'Please fill in all the required fields!'; } } @@ -104,29 +102,25 @@ export class ContactComponent implements OnInit { community: this.fb.control('', Validators.required), message: this.fb.control('', Validators.required), recaptcha: this.fb.control('', Validators.required), - }); - this.errorMessage = ''; + }) } private sendMail(admins: any) { - this.showLoading = true; + this.sending = true; this.subscriptions.push(this._emailService.contact(this.properties, Composer.composeEmailForNewCommunity(this.contactForm.value, admins), this.contactForm.value.recaptcha).subscribe( res => { - this.showLoading = false; if (res) { + this.sending = false; this.reset(); this.modalOpen(); } else { - this.errorMessage = 'Email sent failed! Please try again.'; - this.contactForm.get('recaptcha').setValue(''); + this.handleError('Email sent failed! Please try again.'); } }, error => { this.handleError('Email sent failed! Please try again.', error); - this.showLoading = false; - this.contactForm.get('recaptcha').setValue(''); } )); } @@ -141,10 +135,13 @@ export class ContactComponent implements OnInit { this.modal.open(); } - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; + handleError(message: string, error = null) { + if(error) { + console.error(error); + } + NotificationHandler.rise(message, 'danger'); + this.sending = false; + this.contactForm.get('recaptcha').setValue(''); } public goToHome() { diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 5a69cb2..ada419f 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 5a69cb210178c77ef078eb3d5e35e527570e722e +Subproject commit ada419f8e82836c19633544aeddcc7ca31a5699b diff --git a/src/assets/openaire-theme b/src/assets/openaire-theme index eb0b04c..0a34bf8 160000 --- a/src/assets/openaire-theme +++ b/src/assets/openaire-theme @@ -1 +1 @@ -Subproject commit eb0b04cb96b9ab92387d61cdafae21256a6da762 +Subproject commit 0a34bf8f62ef7544060acc4e8333ce13ea929d91