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

100% Statements 22/22
100% Branches 2/2
100% Functions 4/4
100% Lines 20/20

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 671x 1x 1x   1x 1x                   1x       11x                         11x 11x 11x 11x 11x 11x 11x               11x 1331x       594x   737x 737x               737x        
import { Component, Inject, LOCALE_ID, 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',
    styleUrls: ['./quote-detail.component.scss']
})
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
     * @param locale: LOCALE_ID
     */
    constructor(
        private readonly afs: AngularFirestore,
        private readonly seo: SeoService,
        private readonly alert: AlertService,
        public router: Router,
        private readonly route: ActivatedRoute,
        public pageService: PageService,
        @Inject(LOCALE_ID) public locale: string
    ) {
    }
 
    /**
     * 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);
    }
 
}