Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 57x 8x 1x 1x 16x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /** * File Name: contact-us.component * Version Number: v1.0 * Author Name: Orisha Orrie * Project Name: Ninshiki * Organization: Software Sharks * Manual: Refer to the Ninshiki User Manual at https://github.com/OrishaOrrie/SoftwareSharks/blob/master/Documentation/User%20Manual.pdf * Update History: * ------------------------------------------ * Date Author Description * 01/03/2018 Orisha Created component * ------------------------------------------ * Test Cases: contact-us.component.spec.ts * Functional Description: * Allows user to send email query to client via Http to the server */ import { Component, OnInit } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; impoIrt { FormControl, Validators, FormGroup } from '@angular/forms'; import { QuoteBuilderService } from '../quotebuilder/quoteE-builder.service'; import { Observable } from 'rxjs'; @Component({ seElector: 'app-contact-us', templateUrl: './contact-us.component.html', styleUrls: ['./contact-us.component.css'] }) export class ContactUsComponent implements OnInit { /** * Evaluates to true when a server response is received. */ submitted = false; /** * Determines whether the spinner is to be displayed or not */ showSpinner = false; /** * Message received from the server. Displayed on the status card */ msgReceived = ''; /** * FormControl used to validate email input */ email = new FormControl('', [Validators.required, Validators.email] ); /** * FormGroup used as a model for form input */ myGroup = new FormGroup({ name: new FormControl(''), email: new FormControl('', [Validators.required, Validators.email] ), message: new FormControl('') }); public quoteMessage = ''; public addQuoteDisplay = new Observable((data) => { setInterval(() => { data.next(this.qb.isQuoteStarted()); }, 1000); }); private pressedButton = false; /** * This constructor is only used to pass an instance of the HttpClient module. * @param http HttpClient instance */ constructor(private http: HttpClient, public qb: QuoteBuilderService) { } ngOnInit() { } /** * Called when invalid input is detected */ getErrorMessage() { // console.log('Errrorrrrr'); return this.email.hasError('required') ? 'You must enter a value' : this.email.hasError('email') ? 'Not a valid email' : ''; } /** * Called when the Submit button is clicked. POSTs the email, name, and query to the backend server. */ onSubmit() { const contactName = this.myGroup.get('name').value; const contactEmail = this.myGroup.get('email').value; const contactMessage = this.myGroup.get('message').value; // this.myGroup.setValue(); const httpOptions = { headers: new HttpHeaders({ 'Access-Control-Allow-Origin': '*' }) }; console.log('Name: ' + contactName + ' Email: ' + contactEmail + ' Msg: ' + contactMessage); this.shoEwSpinner = true; this.http.post('https://us-central1-testproject-ee885.cloudfunctions.net/app/sendmail', {'subject': contactName, 'text': contactMessage, 'email': contactEmail}, httpOptions ).subscribe(data1 => { this.showSpinner = false; const msgFromServer = data1['message']; this.submitted = true; if (msgFromServer === 'Message sent') { console.log('Message sent == true'); this.msgReceived = 'Thank you for contacting us! We\'ll be in touch ;) '; } else { console.log('Message sent == false'); this.msgReceived = 'Sorry, your message was not sent. Try again later please if you don\'t mind OwO'; } }); } /** * Appends the quote data from the QuoteBuilderService to the message textarea in a formatted presentation */ addQuoteToMessage() { this.pressedButton = true; const quoteList = this.qb.getQuoteList(); this.quoteMessage = '\nI\'d like to receive a quote for the following items:\n'; this.quoteMessage += '========================================\n'; quoteList.forEach((element, index) => { this.quoteMessage += (index + 1) + '. ' + element.name + ' x' + element.amount + '\n'; }); this.quoteMessage += '========================================\n'; const messageText = this.myGroup.get('message').value; this.myGroup.patchValue({ message: messageText + this.quoteMessage }); } } |