import { AfterViewInit , Component , OnDestroy , ViewEncapsulation } from '@angular/core' ; import { Subscription } from 'rxjs' ; import { EventService } from '@core/event.service' ; import { PagerXmlService } from '../pagerxml.service' ; /**
 * Pager component to display losspager product information
 *
 */ @ Component ( { encapsulation : ViewEncapsulation . None , selector : 'pager-pager' , styleUrls : [ './pager.component.scss' ] , templateUrl : './pager.component.html' } ) export class PagerComponent implements AfterViewInit , OnDestroy { /** subscription to product observable */ pending : boolean ; subscription : Subscription = new Subscription ( ) ; constructor ( public eventService , public pagerXmlService ) { } param product returns isPending ( alertlevel ) { if ( alertlevel . toLowerCase ( ) === 'pending' ) { return true ; } else { return false ; } } ngAfterViewInit ( ) { this . subscription . add ( this . eventService . product$ . subscribe ( product => { this . onProduct ( product ) ; } ) ) ; } ngOnDestroy ( ) { this . subscription . unsubscribe ( ) ; } param product onProduct ( product ) { if ( product && product . type === 'losspager' ) { this . pagerXmlService . getPagerXml ( product ) ; } if ( product && product . properties ) { if ( product . properties . alertlevel ) { this . pending = this . isPending ( product . properties . alertlevel ) ; } else { this . pending = false ; } } } }