diff --git a/deploy/beta-properties.json b/deploy/beta-properties.json
index bf537c1..259b172 100644
--- a/deploy/beta-properties.json
+++ b/deploy/beta-properties.json
@@ -72,6 +72,7 @@
"searchLinkToOrganization" : "/search/organization?organizationId=",
"searchLinkToOrp" : "/search/other?orpId=",
+ "searchLinkToCommunities" : "/search/find/communities",
"searchLinkToPublications" : "/search/find/publications",
"searchLinkToDataProviders" : "/search/find/dataproviders",
"searchLinkToProjects" : "/search/find/projects",
@@ -104,5 +105,9 @@
"widgetLink" : "https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId=",
"claimsInformationLink": "https://beta.openaire.eu/linking",
- "shareInZenodoPage": "/participate/share-zenodo?communityId="
+ "shareInZenodoPage": "/participate/share-zenodo?communityId=",
+
+ "reCaptchaSiteKey": "6LcVtFIUAAAAAB2ac6xYivHxYXKoUvYRPi-6_rLu",
+
+ "admins" : []
}
diff --git a/package.json b/package.json
index fe7512b..5217794 100644
--- a/package.json
+++ b/package.json
@@ -35,13 +35,13 @@
"@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",
"datatables.net": "^1.10.16",
"datatables.net-dt": "^1.10.16",
"jquery": "^3.2.1",
+ "ng-recaptcha": "^3.0.5",
"ng2-ckeditor": "1.1.9",
"ngx-json-ld": "0.1.6",
"rxjs": "^5.4.2",
diff --git a/src/app/contact/contact.component.html b/src/app/contact/contact.component.html
index 1f0d97f..c2b5e67 100644
--- a/src/app/contact/contact.component.html
+++ b/src/app/contact/contact.component.html
@@ -17,10 +17,12 @@
Surname *
-
+
Please write us a message.
+
+
+
+
Please complete reCaptcha challenge.
+
-
* Required fields
+
@@ -68,7 +81,3 @@
-{{updateErrorMessage}}
-{{errorMessage}}
-{{successfulSaveMessage}}
-{{successfulResetMessage}}
diff --git a/src/app/contact/contact.component.ts b/src/app/contact/contact.component.ts
index 628fc7f..fa6ca9d 100644
--- a/src/app/contact/contact.component.ts
+++ b/src/app/contact/contact.component.ts
@@ -4,44 +4,47 @@ 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 "./contact-form";
+import {Composer} from "../openaireLibrary/utils/email/composer";
@Component({
selector: 'contact',
templateUrl: './contact.component.html',
})
-export class ContactComponent implements OnInit{
+export class ContactComponent implements OnInit {
@Input('group')
myForm: FormGroup;
public showLoading = true;
- public errorMessage = '';
+ public errorMessage = '';
public updateErrorMessage = '';
public successfulSaveMessage = '';
public successfulResetMessage = '';
- public hasChanged = false;
- public res = [];
+ public isSubmitted = false;
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;
+ public contactForm: ContactForm = new ContactForm();
+ public recaptchaToken: string = null;
+ @ViewChild('name') name;
+ @ViewChild('surname') surname;
+ @ViewChild('sender') sender;
+ @ViewChild('affiliation') affiliation;
+ @ViewChild('community') community;
+ @ViewChild('message') message;
+ @ViewChild('recaptcha') recaptcha;
- constructor (private element: ElementRef,
- private route: ActivatedRoute,
- private _router: Router,
- public _fb: FormBuilder,
- private _emailService: EmailService) { }
+ constructor(private element: ElementRef,
+ private route: ActivatedRoute,
+ private _router: Router,
+ private _emailService: EmailService) {
+ }
ngOnInit() {
@@ -55,104 +58,43 @@ export class ContactComponent implements OnInit{
}
public scroll() {
- if (typeof document !== 'undefined') {
- this.element.nativeElement.scrollIntoView();
- }
- }
-
- public resetForm() {
-
+ if (typeof document !== 'undefined') {
+ this.element.nativeElement.scrollIntoView();
+ }
}
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]);
- }
+ this.isSubmitted = true;
+ if(!this.name.invalid && !this.surname.invalid && !this.sender.invalid &&
+ !this.affiliation.invalid && !this.message.invalid && this.contactForm.recaptcha) {
+ this.sendMail(this.properties.admins);
}
- 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 : ''
- });
+ this.contactForm = new ContactForm();
+ this.recaptcha.reset();
}
- handleUpdateError(message: string, error) {
- this.updateErrorMessage = message;
- console.log('Server responded: ' + error);
+ private sendMail(admins: any) {
+ this._emailService.sendEmail(this.properties.adminToolsAPIURL + '/sendMail/',
+ Composer.composeEmailForNewCommunity(this.contactForm, admins)).subscribe(
+ res => {
+ console.log(res)
+ },
+ error => console.log(error)
+ );
+ }
- this.showLoading = false;
+
+ public handleRecaptcha(captchaResponse: string) {
+ this.recaptchaToken = captchaResponse;
+ if(this.recaptchaToken) {
+ this.contactForm.recaptcha = true;
+ }
}
+
handleError(message: string, error) {
this.errorMessage = message;
console.log('Server responded: ' + error);
@@ -165,12 +107,4 @@ export class ContactComponent implements OnInit{
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
index 7a6be2a..58415bc 100644
--- a/src/app/contact/contact.module.ts
+++ b/src/app/contact/contact.module.ts
@@ -6,15 +6,13 @@ 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";
+import {RecaptchaModule} from "ng-recaptcha";
@NgModule({
imports: [
ContactRoutingModule, CommonModule, FormsModule, RouterModule,
- RecaptchaModule.forRoot({
- siteKey: '6LffKp0UAAAAAHFvnvEY4YUV_ojH90_loQp5gOqH',
- }),
+ RecaptchaModule.forRoot()
],
declarations: [
ContactComponent
diff --git a/src/assets/env-properties.json b/src/assets/env-properties.json
index 11e87d5..22fb49b 100644
--- a/src/assets/env-properties.json
+++ b/src/assets/env-properties.json
@@ -102,12 +102,15 @@
"notifyForNewManagers": "http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools/notifyForNewManagers/",
"notifyForNewSubscribers": "http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools/notifyForNewSubscribers/",
-
"lastIndexInformationLink" : "https://beta.openaire.eu/aggregation-and-content-provision-workflows",
"showLastIndexInformationLink" : true,
"widgetLink" : "https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId=",
"claimsInformationLink": "https://beta.openaire.eu/linking",
- "shareInZenodoPage": "/participate/share-zenodo?communityId="
+ "shareInZenodoPage": "/participate/share-zenodo?communityId=",
+
+ "reCaptchaSiteKey": "6LcVtFIUAAAAAB2ac6xYivHxYXKoUvYRPi-6_rLu",
+
+ "admins" : ["kostis30fylloy@gmail.com"]
}