all files / src/app/pages/quote-detail/ quote-detail.component.ts

100% Statements 21/21
100% Branches 2/2
100% Functions 4/4
100% Lines 19/19
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                         11×                       11× 11× 11× 11× 11× 11×               11× 1331×       594×   737× 737×               737×        
import { Component, OnInit } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { QuoteModel } from '../../models';
import { AlertService, PageService, SeoService } from '../../services';
 
/**
 * Quote Detail Component
 */
@Component({
    selector: 'app-quote-detail',
    templateUrl: './quote-detail.component.html'
})
export class QuoteDetailComponent implements OnInit {
    /** current quote object */
    quote$: Observable<QuoteModel>;
    /** current quote id */
    quoteID = '';
 
    /**
     * constructor of QuoteDetailComponent
     * @param afs: AngularFirestore
     * @param seo: SeoService
     * @param alert: AlertService
     * @param router: Router
     * @param route: ActivatedRoute
     * @param pageService: PageService
     */
    constructor(
        private readonly afs: AngularFirestore,
        private readonly seo: SeoService,
        private readonly alert: AlertService,
        public router: Router,
        private readonly route: ActivatedRoute,
        public pageService: PageService
    ) {
    }
 
    /**
     * ngOnInit
     */
    ngOnInit(): void {
        this.route.paramMap.subscribe(pmap => {
            if (this.pageService.checkToRedirectByIDParam(pmap,
                'quotes',
                this.pageService.routerLinks.quotes,
                this.pageService.routerLinks.quote)) {
                return;
            }
            this.quoteID = pmap.get('id');
            this.initQuote();
        });
    }
 
    /**
     * init quote
     */
    initQuote(): void {
        this.quote$ = this.pageService.getPageFromFirestore(QuoteModel, 'quotes', this.quoteID);
    }
 
}