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 | 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x | import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core'; import { AngularFirestore } from '@angular/fire/firestore'; import * as firebase from 'firebase/app'; import { Observable } from 'rxjs'; import { ContactModel, PageModel } from '../../models'; import { AlertService, PageService } from '../../services'; /** * Contact Component */ @Component({ selector: 'app-contact', templateUrl: './contact.component.html' }) export class ContactComponent implements OnInit { /** current page object */ page$: Observable<PageModel>; /** current contact data */ contact: ContactModel = {}; /** is show privacy policy? */ isShowPrivacyPolicy = false; /** is show thank you note? */ isShowThankYou = false; /** * constructor of ContactComponent * @param platformId: PLATFORM_ID * @param pageService: PageService * @param afs: AngularFirestore * @param alert: AlertService */ constructor(@Inject(PLATFORM_ID) private readonly platformId: string, public pageService: PageService, private readonly afs: AngularFirestore, public alert: AlertService) { } /** * ngOnInit */ ngOnInit(): void { this.isShowPrivacyPolicy = false; this.isShowThankYou = false; this.page$ = this.pageService.getPageFromFirestore(PageModel, 'pages', this.pageService.getRoutePathName()); } /** * on click send button */ onClickSend(): void { this.contact.created = firebase.default.firestore.FieldValue.serverTimestamp(); this.afs.collection(`messages_${this.pageService.locale}`) .add(this.contact) .then(value => { this.isShowThankYou = true; this.contact = {}; }) .catch(// istanbul ignore next reason => { this.alert.error(reason); }); } } |