import { Component, Input, Output, EventEmitter } from '@angular/core'; import { Host } from '@overflow/model/discovery'; import { ProbeService } from '../service/probe.service'; import { map, catchError, take } from 'rxjs/operators'; import { PingResult, PingResponse } from '@overflow/model/ping'; import { of } from 'rxjs'; import { Message } from 'primeng/primeng'; @Component({ selector: 'app-host-detail', templateUrl: './host-detail.component.html', styleUrls: ['./host-detail.component.scss'], }) export class HostDetailComponent { @Input() host: Host; pingResult: PingResult; constructor( private probeService: ProbeService ) { } doPing() { const option = { Retry: 3, Interval: 1, Deadline: 1, }; this.probeService .call('PingService.PingHost', this.host, option) .pipe( map((pingResult: PingResult) => { if (pingResult) { this.pingResult = pingResult; } }), catchError(error => { console.log(error); alert('An error has occurred.'); return of(); }), take(1) ) .subscribe(); } }