From 1854ed76e7a97acfdf1be255817caa0856685be7 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Tue, 9 Apr 2019 22:09:38 +0000 Subject: [PATCH] [Trunk|Connect]: 1. Add Recaptcha module at package.json. 2. Create Contact Component. 3. Add contact to app-routing as route '/contact' 4. Contact Us is not working right now git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55252 d315682c-612b-4755-9ff5-7f18f6832af3 --- package.json | 1 + src/app/app-routing.module.ts | 1 + src/app/contact/contact-routing.module.ts | 12 ++ src/app/contact/contact.component.html | 74 +++++++++ src/app/contact/contact.component.ts | 176 ++++++++++++++++++++++ src/app/contact/contact.module.ts | 30 ++++ 6 files changed, 294 insertions(+) create mode 100644 src/app/contact/contact-routing.module.ts create mode 100644 src/app/contact/contact.component.html create mode 100644 src/app/contact/contact.component.ts create mode 100644 src/app/contact/contact.module.ts diff --git a/package.json b/package.json index 7515f9f..fe7512b 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@nguniversal/express-engine": "^1.0.0-beta.3", "@nguniversal/module-map-ngfactory-loader": "^1.0.0-beta.3", "angular-datatables": "^4.4.0", + "angular-google-recaptcha": "^1.0.3", "citation-js": "^0.3.4", "clipboard": "^1.5.16", "core-js": "^2.4.1", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 10363d4..9c932e2 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -9,6 +9,7 @@ import { OpenaireErrorPageComponent } from './error/errorPage.component'; const routes: Routes = [ { path: '', loadChildren: './communitywrapper/communityWrapper.module#CommunityWrapperModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'how-to-create-community', loadChildren: './createCommunity/community-creation-instructions.module#CommunityCreationInstructionsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, + { path: 'contact', loadChildren: './contact/contact.module#ContactModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'invite', loadChildren: './utils/subscribe/invite/invite.module#InviteModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'about', loadChildren: './htmlPages/about/aboutPage.module#AboutPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'content', loadChildren: './content/contentPage.module#ContentPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, diff --git a/src/app/contact/contact-routing.module.ts b/src/app/contact/contact-routing.module.ts new file mode 100644 index 0000000..48fe931 --- /dev/null +++ b/src/app/contact/contact-routing.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import {RouterModule} from '@angular/router'; +import {ContactComponent} from './contact.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: ContactComponent} + ]) + ] +}) +export class ContactRoutingModule { } diff --git a/src/app/contact/contact.component.html b/src/app/contact/contact.component.html new file mode 100644 index 0000000..1f0d97f --- /dev/null +++ b/src/app/contact/contact.component.html @@ -0,0 +1,74 @@ +
+ +
+
+
+
+
+
+
+
+

Contact us and create your community profile

+
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
* Required fields
+
+ +
+
+
+
+
OpenAIRE gives you the virtual environment and services designed for your community to:
+
    +
  • Create and Manage your community
  • +
  • Access, share and link together all your research
  • +
  • Monitor and report your community's progress
  • +
+
+
+ +
+
+
+
+
+ + + + diff --git a/src/app/contact/contact.component.ts b/src/app/contact/contact.component.ts new file mode 100644 index 0000000..628fc7f --- /dev/null +++ b/src/app/contact/contact.component.ts @@ -0,0 +1,176 @@ +import {Component, OnInit, Input, ElementRef, ViewChild} from '@angular/core'; +import {FormGroup, FormBuilder, Validators} from '@angular/forms'; +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"; + +@Component({ + selector: 'contact', + templateUrl: './contact.component.html', +}) + +export class ContactComponent implements OnInit{ + + @Input('group') + myForm: FormGroup; + + public showLoading = true; + public errorMessage = ''; + public updateErrorMessage = ''; + + public successfulSaveMessage = ''; + public successfulResetMessage = ''; + + public hasChanged = false; + public res = []; + public email: Email; + public emailToInform: Email; + public note = ''; + public properties: EnvProperties = null; + + public name = ''; + public surname = ''; + public sender = ''; + public affiliation = ''; + public community = ''; + public message = ''; + public recaptcha: any = null; + + constructor (private element: ElementRef, + private route: ActivatedRoute, + private _router: Router, + public _fb: FormBuilder, + private _emailService: EmailService) { } + + + ngOnInit() { + this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { + this.properties = data.envSpecific; + this.email = {body: '', subject: '', recipients: []}; + this.emailToInform = {body: '', subject: '', recipients: []}; + this.scroll(); + this.showLoading = false; + }); + } + + public scroll() { + if (typeof document !== 'undefined') { + this.element.nativeElement.scrollIntoView(); + } + } + + public resetForm() { + + } + + public send() { + console.log(this.recaptcha); + } + + /* private sendMailToNewManagers(managers: any) { + this._emailService.sendEmail(this.properties.adminToolsAPIURL + '/sendMail/', + Composer.composeEmailForNewManager(this.communityId, + this.community.title, managers)).subscribe( + res => { + // console.log("The email has been sent successfully!") + }, + error => console.log(error) + ); + }*/ + + + private getNonEmptyItems(data: string[]): string[] { + const length = data.length; + const arrayNonEmpty = new Array(); + + let j = 0; + for (let i = 0; i < length; i++) { + if (this.isEmpty(data[i])) { + // console.log(data[i]); + } else if (this.isNonEmpty(data[i])) { + arrayNonEmpty[j] = data[i]; + j++; + // console.log(data[i]); + } + } + return arrayNonEmpty; + } + + private hasFilled(data: any): boolean { + if (this.isNonEmpty(data) && !this.isEmpty(data)) { + return true; + } + return false; + } + + private isEmpty(data: string): boolean { + if (data !== undefined && !data.replace(/\s/g, '').length) { + return true; + } else { + return false; + + } + } + + private isNonEmpty(data: string): boolean { + if (data !== undefined && data != null) { + return true; + } else { + return false; + +} + } + + private change() { + this.hasChanged = true; + this.successfulSaveMessage = ''; + this.successfulResetMessage = ''; + } + + private resetChange() { + this.hasChanged = false; + } + + public get form() { + return this._fb.group({ + _id : '', + name : ['', Validators.required] + }); + } + + public reset() { + this.myForm.patchValue({ + name : '', + _id : '' + }); + } + + handleUpdateError(message: string, error) { + this.updateErrorMessage = message; + console.log('Server responded: ' + error); + + this.showLoading = false; + } + + handleError(message: string, error) { + this.errorMessage = message; + console.log('Server responded: ' + error); + + this.showLoading = false; + } + + handleSuccessfulSend(message) { + this.showLoading = false; + this.successfulSaveMessage = message; + } + + handleSuccessfulReset(message) { + this.showLoading = false; + this.successfulResetMessage = message; + } + + trackByFn(index: any, item: any) { + return index; + } +} diff --git a/src/app/contact/contact.module.ts b/src/app/contact/contact.module.ts new file mode 100644 index 0000000..7a6be2a --- /dev/null +++ b/src/app/contact/contact.module.ts @@ -0,0 +1,30 @@ +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'; +import {ContactRoutingModule} from "./contact-routing.module"; +import {EmailService} from "../openaireLibrary/utils/email/email.service"; +import {RecaptchaModule} from "angular-google-recaptcha"; + + +@NgModule({ + imports: [ + ContactRoutingModule, CommonModule, FormsModule, RouterModule, + RecaptchaModule.forRoot({ + siteKey: '6LffKp0UAAAAAHFvnvEY4YUV_ojH90_loQp5gOqH', + }), + ], + declarations: [ + ContactComponent + ], + providers: [ + EmailService + ], + exports: [ + ContactComponent + ] +}) + +export class ContactModule { }