|
|
@@ -14,7 +14,19 @@ import { CommonModule } from '@angular/common';
|
|
|
import { CdkDrag, CdkDragHandle } from '@angular/cdk/drag-drop';
|
|
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
|
import { VisionSocketService } from '../../services/vision-socket.service';
|
|
|
-import { ServiceStatus } from '../../core/interfaces/system-metrics.interface';
|
|
|
+import { ServiceStatus, ServiceStatusType } from '../../core/interfaces/system-metrics.interface';
|
|
|
+
|
|
|
+export interface StatusConfig {
|
|
|
+ color: string; // CSS color for the status pill and bar
|
|
|
+ label: string; // Human-readable state label
|
|
|
+ showBar: boolean; // Whether to render the CPU progress bar at all
|
|
|
+}
|
|
|
+
|
|
|
+const STATUS_CONFIG: Record<ServiceStatusType, StatusConfig> = {
|
|
|
+ ACTIVE: { color: '#00a651', label: 'ACTIVE', showBar: true },
|
|
|
+ IDLE: { color: '#ffc107', label: 'IDLE', showBar: true },
|
|
|
+ OFFLINE: { color: '#555555', label: 'OFFLINE', showBar: false },
|
|
|
+};
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-performance-hud',
|
|
|
@@ -33,8 +45,13 @@ export class PerformanceHudComponent {
|
|
|
this.collapsed.update(v => !v);
|
|
|
}
|
|
|
|
|
|
+ /** Returns the full rendering config for a service status — no branching in the template. */
|
|
|
+ statusConfig(status: ServiceStatusType): StatusConfig {
|
|
|
+ return STATUS_CONFIG[status];
|
|
|
+ }
|
|
|
+
|
|
|
formatBytes(bytes: number): string {
|
|
|
- if (bytes === 0) return '0 B';
|
|
|
+ if (bytes === 0) return '—';
|
|
|
const mb = bytes / (1024 * 1024);
|
|
|
return `${mb.toFixed(1)} MB`;
|
|
|
}
|