import { Component, Input } from '@angular/core'; @Component({ selector: 'app-status-tab', templateUrl: './status-tab.component.html', styleUrl: './status-tab.component.css' }) export class StatusTabComponent { @Input() loading: boolean = false; @Input() diskUsage: any = {}; @Input() servicesStatus: any = {}; @Input() installedOgLives: any[] = []; @Input() subnets: any[] = []; @Input() diskUsageChartData: any[] = []; @Input() showLabels: boolean = true; @Input() isDoughnut: boolean = true; @Input() colorScheme: any = { domain: ['#df200d', '#26a700'] }; @Input() view: [number, number] = [400, 220]; @Input() isDhcp: boolean = false; @Input() processesStatus: any = {}; @Input() ramUsage: any = {}; @Input() cpuUsage: any = {}; @Input() ramUsageChartData: any[] = []; @Input() isRepository: boolean = false; getServices(): { name: string, status: string }[] { if (!this.servicesStatus) { return []; } const services = Object.keys(this.servicesStatus).map(key => ({ name: key, status: this.servicesStatus[key] })) return services; } getProcesses(): { name: string, status: string }[] { if (!this.processesStatus) { return []; } return Object.keys(this.processesStatus).map(key => ({ name: key, status: this.processesStatus[key] })); } formatBytes(bytes: number): string { if (bytes >= 1e9) { return (bytes / 1e9).toFixed(2) + ' GB'; } else if (bytes >= 1e6) { return (bytes / 1e6).toFixed(2) + ' MB'; } else if (bytes >= 1e3) { return (bytes / 1e3).toFixed(2) + ' KB'; } else { return bytes + ' B'; } } }