member_webapp/@overflow/probe/component/list/list.component.ts
2018-05-29 21:18:43 +09:00

37 lines
937 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: boolean;
@Input() probeHosts: ProbeHost[];
@Input() error: any;
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;
}
}
}