import { Component , OnDestroy , OnInit } from '@angular/core' ; import { ActivatedRoute } from '@angular/router' ; import { BehaviorSubject , ReplaySubject } from 'rxjs' ; import { takeUntil } from 'rxjs/operators' ; @ Component ( { selector : 'cmdb-task-logs' , templateUrl : './exportd-job-logs.component.html' , styleUrls : [ './exportd-job-logs.component.scss' ] } ) export class ExportdJobLogsComponent implements OnInit , OnDestroy { private private subscriber : ReplaySubject < void > = new ReplaySubject < void > ( ) ; /**
     * Export query
     */ public query : any ; private private taskIDSubject : BehaviorSubject < number > = new BehaviorSubject < number > ( undefined ) ; constructor ( private route ) { this . route . params . pipe ( takeUntil ( this . subscriber ) ) . subscribe ( ( id ) => this . taskIDSubject . next ( id . publicID ) ) ; } /**
     * Get the current task id.
     */ public get taskID ( ) : number { return this . taskIDSubject . value ; } public ngOnInit ( ) { this . taskIDSubject . asObservable ( ) . pipe ( takeUntil ( this . subscriber ) ) . subscribe ( ( id ) => this . genQuery ( id ) ) ; } param id private private genQuery ( id ) { this . query = [ { $match : { job_id : + id } } ] ; } /**
     * Component destroyer.
     */ public ngOnDestroy ( ) { this . subscriber . next ( ) ; this . subscriber . complete ( ) ; } }