36 lines
905 B
TypeScript
Raw Normal View History

2018-05-24 20:30:02 +09: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 20:02:18 +09:00
2018-04-06 22:02:46 +09:00
@Component({
selector: 'of-probe-list',
templateUrl: './list.component.html',
})
2018-05-24 20:30:02 +09:00
export class ProbeListComponent {
@Output() select = new EventEmitter<ProbeHost>();
2018-05-26 18:08:40 +09:00
@Input() pending;
2018-05-24 20:30:02 +09:00
@Input() probeHosts: ProbeHost[];
2018-04-06 20:02:18 +09:00
2018-05-24 20:30:02 +09:00
constructor() {
2018-04-06 22:02:46 +09:00
}
2018-04-06 20:02:18 +09:00
2018-05-26 18:59:57 +09:00
onProbeSelect(event) {
2018-05-24 20:30:02 +09:00
this.select.emit(event.data);
2018-04-06 22:02:46 +09:00
}
2018-05-14 18:02:48 +09:00
getUptime(probe: Probe) {
2018-05-26 18:59:57 +09: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 18:02:48 +09:00
}
2018-04-06 22:02:46 +09:00
}