import { HealthCheckService } from './health-check.service';
import { Component, OnInit } from '@angular/core';
import { Metrics } from '../core/entities';

@Component({
	selector: 'app-health-check',
	templateUrl: './health-check.component.html',
	styleUrls: ['./health-check.component.scss']
})
export class HealthCheckComponent implements OnInit {
	metrics: Metrics = new Metrics('1.0.0', null, '?');

	constructor(
		private healthCheckService: HealthCheckService
	) {}

	ngOnInit() {
		this.healthCheckService.healthCheck().subscribe(metrics => {
			this.metrics = metrics;
		});
	}

	getLocalDateString(): string {
		return new Date(this.metrics.uptime).toLocaleString('fr-Fr');
	}
}
