member_webapp/@overflow/probe/component/list/list.component.ts

37 lines
937 B
TypeScript
Raw Normal View History

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-29 12:18:43 +00:00
@Input() pending: boolean;
2018-05-24 11:30:02 +00:00
@Input() probeHosts: ProbeHost[];
2018-05-29 12:18:43 +00:00
@Input() error: any;
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
}