36 lines
905 B
TypeScript
36 lines
905 B
TypeScript
import { Component, OnInit, AfterViewInit, AfterContentInit, ViewChild, OnDestroy, Output, EventEmitter, Input } from '@angular/core';
|
|
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
|
|
|
|
@Component({
|
|
selector: 'of-probe-list',
|
|
templateUrl: './list.component.html',
|
|
})
|
|
export class ProbeListComponent {
|
|
@Output() select = new EventEmitter<ProbeHost>();
|
|
@Input() pending;
|
|
@Input() probeHosts: ProbeHost[];
|
|
|
|
constructor() {
|
|
}
|
|
|
|
onProbeSelect(event) {
|
|
this.select.emit(event.data);
|
|
}
|
|
|
|
getUptime(probe: Probe) {
|
|
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;
|
|
}
|
|
}
|
|
}
|