added svcapi ui and camunda code
[it/otf.git] / otf-frontend / client / src / app / layout / feedback / feedback.component.ts
diff --git a/otf-frontend/client/src/app/layout/feedback/feedback.component.ts b/otf-frontend/client/src/app/layout/feedback/feedback.component.ts
new file mode 100644 (file)
index 0000000..ed1be7f
--- /dev/null
@@ -0,0 +1,98 @@
+/*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
+#                                                                              #\r
+#   Licensed under the Apache License, Version 2.0 (the "License");            #\r
+#   you may not use this file except in compliance with the License.           #\r
+#   You may obtain a copy of the License at                                    #\r
+#                                                                              #\r
+#       http://www.apache.org/licenses/LICENSE-2.0                             #\r
+#                                                                              #\r
+#   Unless required by applicable law or agreed to in writing, software        #\r
+#   distributed under the License is distributed on an "AS IS" BASIS,          #\r
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
+#   See the License for the specific language governing permissions and        #\r
+#   limitations under the License.                                             #\r
+##############################################################################*/\r
+\r
+\r
+import {Component, OnInit} from '@angular/core';\r
+import {routerTransition} from 'app/router.animations';\r
+import {FormControl, FormGroup, Validators} from '@angular/forms';\r
+import {MatDialog} from '@angular/material';\r
+import {AlertModalComponent} from '../../shared/modules/alert-modal/alert-modal.component';\r
+import {FeedbackService} from "../../shared/services/feedback.service";\r
+\r
+@Component({\r
+    selector: 'app-feedback',\r
+    templateUrl: './feedback.component.pug',\r
+    styleUrls: ['./feedback.component.scss'],\r
+    animations: [routerTransition()]\r
+})\r
+export class FeedbackComponent implements OnInit {\r
+    private firstName: string;\r
+    private lastName: string;\r
+    private email: string;\r
+    private message: string;\r
+\r
+    public FeedbackFormGroup: FormGroup;\r
+    private FirstNameFormControl: FormControl;\r
+    private LastNameFormControl: FormControl;\r
+    private EmailFormControl: FormControl;\r
+    private MessageFormControl: FormControl;\r
+\r
+    constructor(\r
+        private ResponseMatDialog: MatDialog,\r
+        private feedback: FeedbackService\r
+    ) {\r
+    }\r
+\r
+\r
+    // @ViewChild('feedbackForm') private FeedBackForm;\r
+\r
+    ngOnInit(): void {\r
+        this.createFormControls();\r
+        this.createFormGroup();\r
+    }\r
+\r
+    private createFormControls() {\r
+        this.FirstNameFormControl = new FormControl('', [Validators.required]);\r
+        this.LastNameFormControl = new FormControl('', [Validators.required]);\r
+        this.EmailFormControl = new FormControl('', [Validators.required, Validators.email]);\r
+        this.MessageFormControl = new FormControl('', [Validators.required]);\r
+    }\r
+\r
+    private createFormGroup() {\r
+        this.FeedbackFormGroup = new FormGroup({\r
+            firstName: this.FirstNameFormControl,\r
+            lastName: this.LastNameFormControl,\r
+            email: this.EmailFormControl,\r
+            message: this.MessageFormControl\r
+        });\r
+    }\r
+\r
+    // submit button action\r
+    public onSubmitFeedback() {\r
+        if (!this.FeedbackFormGroup.invalid) {\r
+            // console.log(this.FeedbackFormGroup.getRawValue())\r
+            this.feedback.sendFeedback(this.FeedbackFormGroup.getRawValue()).subscribe(\r
+                (result) => {\r
+                    this.sendFeedbackAlert('ok', 'Feedback sent!');\r
+                },\r
+                (error) => {\r
+                    this.sendFeedbackAlert('warning', 'Please verify form fields are correct.');\r
+                }\r
+            )        }\r
+        else{\r
+            this.sendFeedbackAlert('warning', 'Please verify form fields are correct.');\r
+        }\r
+    }\r
+\r
+    private sendFeedbackAlert(type: string, message: string) {\r
+        this.ResponseMatDialog.open(AlertModalComponent, {\r
+            width: '250px',\r
+            data: {\r
+                type: type,\r
+                message: message\r
+            }\r
+        });\r
+    }\r
+}\r