All files / src/app/pages/home home.component.ts

100% Statements 20/20
100% Branches 0/0
100% Functions 4/4
100% Lines 18/18

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 611x 1x   1x 1x                   1x                                     6x 6x 6x 6x 6x 6x 6x 6x             7x   7x 7x     7x   11x          
import { Component, Inject, LOCALE_ID, OnInit, PLATFORM_ID } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
import { ConfigModel, CustomHtmlModel, PageBaseModel, PageModel } from '../../models';
import { AlertService, CarouselService, ConfigService, PageService, SeoService } from '../../services';
 
/**
 * Home Component
 */
@Component({
    selector: 'app-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
    /** current page object */
    page$: Observable<PageModel>;
    /** contents of current page */
    contents$: Observable<Array<PageBaseModel>>;
    /** primary custom html widget */
    customHtml: CustomHtmlModel;
 
    /**
     * constructor of HomeComponent
     * @param platformId: PLATFORM_ID
     * @param seo: SeoService
     * @param alert: AlertService
     * @param carouselService: CarouselService
     * @param afs: AngularFirestore
     * @param pageService: PageService
     * @param configService: ConfigService
     * @param locale: LOCALE_ID
     */
    constructor(@Inject(PLATFORM_ID) private readonly platformId: string,
                public seo: SeoService,
                public alert: AlertService,
                public carouselService: CarouselService,
                private readonly afs: AngularFirestore,
                public pageService: PageService,
                public configService: ConfigService,
                @Inject(LOCALE_ID) public locale: string) {
    }
 
    /**
     * ngOnInit
     */
    ngOnInit(): void {
        this.page$ = this.pageService.getPageFromFirestore(PageModel, 'pages', 'home');
 
        this.contents$ = this.pageService.getCollectionFromFirestore(`pages_${this.locale}/home/contents`,
            ref => ref.orderBy('orderNo')
                .limit(3));
 
        this.configService.getConfig()
            .subscribe((config: ConfigModel) => {
                this.customHtml = config.primaryCustomHtmlWidget;
            });
    }
 
}