[master] create contact page
This commit is contained in:
parent
635f4f23ec
commit
da5694d97c
|
@ -41,6 +41,11 @@ const routes: Routes = [
|
|||
loadChildren: () => import('./upload-dois/upload-dois.module').then(m => m.UploadDoisModule),
|
||||
data: {title: Irish.METADATA_PREFIX}, canActivate: [HasConsentGuard]
|
||||
},
|
||||
{
|
||||
path: 'contact-us',
|
||||
loadChildren: () => import('./contact/contact.module').then(m => m.ContactModule),
|
||||
data: {title: Irish.METADATA_PREFIX}
|
||||
},
|
||||
{
|
||||
path: 'admin',
|
||||
loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule),
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {ContactComponent} from './contact.component';
|
||||
import {PreviousRouteRecorder} from "../openaireLibrary/utils/piwik/previousRouteRecorder.guard";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{ path: '', component: ContactComponent, canActivate: [], canDeactivate: [PreviousRouteRecorder]}
|
||||
])
|
||||
]
|
||||
})
|
||||
export class ContactRoutingModule { }
|
|
@ -0,0 +1,22 @@
|
|||
<schema2jsonld *ngIf="url" [URL]="url" [name]="title" type="other" [description]="description"></schema2jsonld>
|
||||
<div>
|
||||
<div class="uk-section uk-container uk-container-large uk-flex uk-flex-center"
|
||||
uk-scrollspy="target: [uk-scrollspy-class]; cls: uk-animation-slide-bottom-medium; delay: 200">
|
||||
<div class="uk-padding-small uk-width-1-2@l uk-width-2-3@m uk-width-1-1">
|
||||
<contact-us [sending]="sending" [scrollspy]="true"
|
||||
[contactForm]="contactForm" (sendEmitter)="send($event)">
|
||||
<h1 page-title class="uk-visible@m uk-margin-auto uk-text-center" uk-scrollspy-class>
|
||||
Contact us<span class="uk-text-primary">.</span>
|
||||
</h1>
|
||||
<h1 page-title class="uk-hidden@m uk-heading-large uk-margin-auto uk-text-center" uk-scrollspy-class>
|
||||
Contact us<span class="uk-text-primary">.</span>
|
||||
</h1>
|
||||
</contact-us>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<modal-alert #modal (alertOutput)="goToHome()">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
Our team will respond to your submission soon.<br>
|
||||
</div>
|
||||
</modal-alert>
|
|
@ -0,0 +1,99 @@
|
|||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {EmailService} from "../openaireLibrary/utils/email/email.service";
|
||||
import {Composer} from "../openaireLibrary/utils/email/composer";
|
||||
import {Meta, Title} from "@angular/platform-browser";
|
||||
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
|
||||
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
||||
import {UntypedFormBuilder, UntypedFormGroup, Validators} from "@angular/forms";
|
||||
import {NotificationHandler} from "../openaireLibrary/utils/notification-handler";
|
||||
import {BaseComponent} from '../openaireLibrary/sharedComponents/base/base.component';
|
||||
|
||||
@Component({
|
||||
selector: 'contact',
|
||||
templateUrl: './contact.component.html'
|
||||
})
|
||||
export class ContactComponent extends BaseComponent implements OnInit {
|
||||
public url: string = null;
|
||||
public sending = false;
|
||||
public contactForm: UntypedFormGroup;
|
||||
@ViewChild('modal') modal;
|
||||
|
||||
constructor(protected _route: ActivatedRoute,
|
||||
protected _router: Router,
|
||||
protected _title: Title,
|
||||
protected _meta: Meta,
|
||||
protected _piwikService: PiwikService,
|
||||
protected seoService: SEOService,
|
||||
private emailService: EmailService,
|
||||
private fb: UntypedFormBuilder) {
|
||||
super();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.title = 'Contact us';
|
||||
this.description = 'Contact us';
|
||||
this.url = this.properties.domain + this.properties.baseLink + this._router.url;
|
||||
this.setMetadata();
|
||||
this.reset();
|
||||
}
|
||||
|
||||
public send(event) {
|
||||
if(event.valid === true) {
|
||||
this.sendMail(this.properties.admins);
|
||||
}
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.contactForm = this.fb.group( {
|
||||
name: this.fb.control('', Validators.required),
|
||||
email: this.fb.control('', [Validators.required, Validators.email]),
|
||||
subject: this.fb.control('', Validators.required),
|
||||
message: this.fb.control('', Validators.required),
|
||||
recaptcha: this.fb.control('', Validators.required),
|
||||
});
|
||||
}
|
||||
|
||||
private sendMail(admins: any) {
|
||||
this.sending = true;
|
||||
this.subscriptions.push(this.emailService.contact(this.properties,
|
||||
Composer.composeEmailforIrishMonitor(this.contactForm.value, admins),
|
||||
this.contactForm.value.recaptcha).subscribe(
|
||||
res => {
|
||||
if (res) {
|
||||
this.sending = false;
|
||||
this.reset();
|
||||
this.modalOpen();
|
||||
} else {
|
||||
this.handleError('Email <b>sent failed!</b> Please try again.');
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.handleError('Email <b>sent failed!</b> Please try again.', error);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
handleError(message: string, error = null) {
|
||||
if(error) {
|
||||
console.error(error);
|
||||
}
|
||||
NotificationHandler.rise(message, 'danger');
|
||||
this.sending = false;
|
||||
this.contactForm.get('recaptcha').setValue('');
|
||||
}
|
||||
|
||||
public goToHome() {
|
||||
this._router.navigate(['/']);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
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 "ng-recaptcha";
|
||||
import {AlertModalModule} from "../openaireLibrary/utils/modal/alertModal.module";
|
||||
import {IsRouteEnabled} from "../openaireLibrary/error/isRouteEnabled.guard";
|
||||
import {Schema2jsonldModule} from "../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module";
|
||||
import {ContactUsModule} from "../openaireLibrary/contact-us/contact-us.module";
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
ContactRoutingModule, CommonModule, RouterModule,
|
||||
AlertModalModule, RecaptchaModule,
|
||||
Schema2jsonldModule, ContactUsModule
|
||||
],
|
||||
declarations: [
|
||||
ContactComponent
|
||||
],
|
||||
providers: [
|
||||
EmailService, IsRouteEnabled
|
||||
],
|
||||
exports: [
|
||||
ContactComponent
|
||||
]
|
||||
})
|
||||
|
||||
export class ContactModule { }
|
|
@ -1 +1 @@
|
|||
Subproject commit 21f49bbc6cd0d4b350a68eabd8c79cb32b310658
|
||||
Subproject commit 5d7e72eb3d8585512af39b9775c716e88f7a8aad
|
Loading…
Reference in New Issue