all files / src/app/pages/taxonomy/ taxonomy.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                                                           484× 484×   484×                              
import { Component, 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
     */
    constructor(private readonly afs: AngularFirestore,
                private readonly seo: SeoService,
                public router: Router,
                private readonly route: ActivatedRoute,
                public pageService: PageService,
                public pagination: PaginationService) {
    }
 
    /**
     * 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.pageService.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();
        }
    }
 
}