1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 import {Component, OnInit} from '@angular/core';
\r
18 import {routerTransition} from 'app/router.animations';
\r
19 import {FormControl, FormGroup, Validators} from '@angular/forms';
\r
20 import {MatDialog} from '@angular/material';
\r
21 import {AlertModalComponent} from '../../shared/modules/alert-modal/alert-modal.component';
\r
22 import {FeedbackService} from "../../shared/services/feedback.service";
\r
25 selector: 'app-feedback',
\r
26 templateUrl: './feedback.component.pug',
\r
27 styleUrls: ['./feedback.component.scss'],
\r
28 animations: [routerTransition()]
\r
30 export class FeedbackComponent implements OnInit {
\r
31 private firstName: string;
\r
32 private lastName: string;
\r
33 private email: string;
\r
34 private message: string;
\r
36 public FeedbackFormGroup: FormGroup;
\r
37 private FirstNameFormControl: FormControl;
\r
38 private LastNameFormControl: FormControl;
\r
39 private EmailFormControl: FormControl;
\r
40 private MessageFormControl: FormControl;
\r
43 private ResponseMatDialog: MatDialog,
\r
44 private feedback: FeedbackService
\r
49 // @ViewChild('feedbackForm') private FeedBackForm;
\r
52 this.createFormControls();
\r
53 this.createFormGroup();
\r
56 private createFormControls() {
\r
57 this.FirstNameFormControl = new FormControl('', [Validators.required]);
\r
58 this.LastNameFormControl = new FormControl('', [Validators.required]);
\r
59 this.EmailFormControl = new FormControl('', [Validators.required, Validators.email]);
\r
60 this.MessageFormControl = new FormControl('', [Validators.required]);
\r
63 private createFormGroup() {
\r
64 this.FeedbackFormGroup = new FormGroup({
\r
65 firstName: this.FirstNameFormControl,
\r
66 lastName: this.LastNameFormControl,
\r
67 email: this.EmailFormControl,
\r
68 message: this.MessageFormControl
\r
72 // submit button action
\r
73 public onSubmitFeedback() {
\r
74 if (!this.FeedbackFormGroup.invalid) {
\r
75 // console.log(this.FeedbackFormGroup.getRawValue())
\r
76 this.feedback.sendFeedback(this.FeedbackFormGroup.getRawValue()).subscribe(
\r
78 this.sendFeedbackAlert('ok', 'Feedback sent!');
\r
81 this.sendFeedbackAlert('warning', 'Please verify form fields are correct.');
\r
85 this.sendFeedbackAlert('warning', 'Please verify form fields are correct.');
\r
89 private sendFeedbackAlert(type: string, message: string) {
\r
90 this.ResponseMatDialog.open(AlertModalComponent, {
\r