import { Component , OnDestroy , OnInit } from '@angular/core' ; import { ActivatedRoute } from '@angular/router' ; import { Subscription } from 'rxjs' ; import { Breakpoints , BreakpointObserver , BreakpointState } from '@angular/cdk/layout' ; import { PingService } from '@core/services/index.service' ; import { BreadCrumbModel , PingModel , ProjectModel } from '@shared/models/index.model' ; /**
 * Ping list components
 */ @ Component ( { selector : 'dashboard-pings-list' , templateUrl : './pings-list.component.html' , styleUrls : [ './pings-list.component.scss' ] , } ) export class PingsListComponent implements OnInit , OnDestroy { private pingSubscription : Subscription ; public pings : PingModel [ ] = [ ] ; public projectUid : string ; public monitorUid : string ; public displayedColumns : string [ ] ; public breadCrumb : BreadCrumbModel [ ] ; public project : ProjectModel ; param route param pingService param breakpointObserver constructor ( private route , private pingService , private breakpointObserver ) { } /**
     * Life cycle init method
     */ ngOnInit ( ) { this . projectUid = this . route . snapshot . paramMap . get ( 'projectUid' ) ; this . monitorUid = this . route . snapshot . paramMap . get ( 'monitorUid' ) ; this . route . data . subscribe ( ( data ) => { this . pings = data . pings ; this . project = data . project ; this . breadCrumb = [ { link : `/projects/${ this . project . uid }` , title : this . project . title } , { link : `/projects/${ this . project . uid }/monitors` , title : 'Monitors' } , ] ; } ) ; this . pingSubscription = this . pingService . findAllByMonitor ( this . projectUid , this . monitorUid ) . subscribe ( ( pings ) => this . pings = pings ) ; this . breakpointObserver . observe ( [ Breakpoints . XSmall ] ) . subscribe ( ( state ) => { if ( state . matches ) { this . displayedColumns = [ 'url' , 'statusCode' ] ; } else { this . displayedColumns = [ 'url' , 'statusCode' , 'duration' , 'type' , 'time' ] ; } } ) ; } /**
     * Life cycle destroy method
     */ ngOnDestroy ( ) { this . pingSubscription . unsubscribe ( ) ; } }