import { HttpClient } from '@angular/common/http' ; import { Component , OnInit } from '@angular/core' ; import { FormBuilder , FormGroup } from '@angular/forms' ; import { HelpModel , HelpTopic } from '@shared/models/index.model' ; /**
 * Help component
 */ @ Component ( { selector : 'dashboard-help' , templateUrl : './help.component.html' , styleUrls : [ './help.component.scss' ] , } ) export class HelpComponent implements OnInit { public searchForm : FormGroup ; public filteredTopics : HelpTopic [ ] = [ ] ; public help : HelpModel = new HelpModel ( ) ; public topics : HelpTopic [ ] ; param http param form param dialog constructor ( private http , private form ) { } /**
     * Life cycle init method
     */ ngOnInit ( ) { this . topics = this . help . topics ; this . topics . forEach ( ( help , index ) => { this . http . get ( `/assets/help/${ help . path }.md` , { responseType : 'text' } ) . subscribe ( ( content ) => { this . topics [ index ] . content = content ; } ) ; } ) ; this . filteredTopics = this . topics ; this . searchForm = this . form . group ( { search : [ undefined , [ ] ] , } ) ; this . searchForm . get ( 'search' ) . valueChanges . subscribe ( ( search ) => this . filterTopics ( search ) ) ; } param keyword filterTopics ( keyword = '' ) { this . filteredTopics = this . topics . filter ( ( help ) => { return help . title . toLowerCase ( ) . includes ( keyword . toLowerCase ( ) ) || help . description . toLowerCase ( ) . includes ( keyword . toLowerCase ( ) ) ; } ) ; } }