2018-05-24 11:30:02 +00:00
|
|
|
import { Component, OnInit, AfterViewInit, AfterContentInit, ViewChild, OnDestroy, Output, EventEmitter, Input } from '@angular/core';
|
|
|
|
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-06 13:02:46 +00:00
|
|
|
@Component({
|
|
|
|
selector: 'of-probe-list',
|
|
|
|
templateUrl: './list.component.html',
|
|
|
|
})
|
2018-05-24 11:30:02 +00:00
|
|
|
export class ProbeListComponent {
|
|
|
|
@Output() select = new EventEmitter<ProbeHost>();
|
2018-05-26 09:08:40 +00:00
|
|
|
@Input() pending;
|
2018-05-24 11:30:02 +00:00
|
|
|
@Input() probeHosts: ProbeHost[];
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-05-24 11:30:02 +00:00
|
|
|
constructor() {
|
2018-04-06 13:02:46 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-05-26 09:59:57 +00:00
|
|
|
onProbeSelect(event) {
|
2018-05-24 11:30:02 +00:00
|
|
|
this.select.emit(event.data);
|
2018-04-06 13:02:46 +00:00
|
|
|
}
|
2018-05-14 09:02:48 +00:00
|
|
|
|
|
|
|
getUptime(probe: Probe) {
|
2018-05-26 09:59:57 +00:00
|
|
|
if (!probe.connectDate) {
|
|
|
|
return 'Not Connected.';
|
|
|
|
}
|
|
|
|
const hours = Math.abs(new Date().getTime() - probe.connectDate.getTime());
|
|
|
|
return this.convertUptimeString(hours);
|
|
|
|
}
|
|
|
|
|
|
|
|
convertUptimeString(hours: number) {
|
|
|
|
if (hours === 0) {
|
|
|
|
return 'Less than an hour.';
|
|
|
|
} else {
|
|
|
|
return 'About ' + hours;
|
|
|
|
}
|
2018-05-14 09:02:48 +00:00
|
|
|
}
|
2018-04-06 13:02:46 +00:00
|
|
|
}
|