All files / src/app/pages/taxonomy taxonomy.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 651x 1x 1x   1x 1x                   1x       4x                       4x 4x 4x 4x 4x 4x 4x             4x 484x 484x   484x                   2x 1x          
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 { TaxonomyModel } from '../../models';
import { PageService, PaginationService, SeoService } from '../../services';
 
/**
 * Taxonomy Component
 */
@Component({
    selector: 'app-taxonomy',
    templateUrl: './taxonomy.component.html',
    styleUrls: ['./taxonomy.component.scss']
})
export class TaxonomyComponent implements OnInit {
    /** current tag object */
    tag$: Observable<TaxonomyModel>;
    /** current tagID */
    tagID = '';
 
    /**
     * constructor of TaxonomyComponent
     * @param afs: AngularFirestore
     * @param seo: SeoService
     * @param router: Router
     * @param route: ActivatedRoute
     * @param pageService: PageService
     * @param pagination: PaginationService
     * @param locale: LOCALE_ID
     */
    constructor(private readonly afs: AngularFirestore,
                private readonly seo: SeoService,
                public router: Router,
                private readonly route: ActivatedRoute,
                public pageService: PageService,
                public pagination: PaginationService,
                @Inject(LOCALE_ID) public locale: string) {
    }
 
    /**
     * ngOnInit
     */
    ngOnInit(): void {
        this.route.paramMap.subscribe(pmap => {
            this.tagID = pmap.get('id');
            this.tag$ = this.pageService.getPageFromFirestore(TaxonomyModel, 'taxonomy', this.tagID);
 
            this.pagination.init(`taxonomy_${this.locale}/${this.tagID}/contents`, 'created', {reverse: true, prepend: false, limit: 5});
 
        });
    }
 
    /**
     * scroll handler for pagination
     * @param e: event
     */
    scrollHandler(e): void {
        if (e === 'bottom') {
            this.pagination.more();
        }
    }
 
}