2 ChangeDetectionStrategy,
9 } from '@angular/core';
17 } from 'carbon-components-angular';
18 import { ProductiveCardComponent } from '~/app/shared/components/productive-card/productive-card.component';
19 import { RouterModule } from '@angular/router';
20 import { ComponentsModule } from '~/app/shared/components/components.module';
21 import { SummaryService } from '~/app/shared/services/summary.service';
22 import { Summary } from '~/app/shared/models/summary.model';
23 import { combineLatest, Observable, of } from 'rxjs';
24 import { CommonModule } from '@angular/common';
25 import { PipesModule } from '~/app/shared/pipes/pipes.module';
26 import { UpgradeInfoInterface } from '~/app/shared/models/upgrade.interface';
27 import { UpgradeService } from '~/app/shared/api/upgrade.service';
28 import { catchError, filter, map, startWith } from 'rxjs/operators';
29 import { HealthCardVM } from '~/app/shared/models/overview';
31 type OverviewHealthData = {
33 upgrade: UpgradeInfoInterface;
36 type TabSection = 'system' | 'hardware' | 'resiliency';
38 interface HealthItemConfig {
39 key: 'mon' | 'mgr' | 'osd' | 'hosts';
46 selector: 'cd-overview-health-card',
49 ProductiveCardComponent,
61 templateUrl: './overview-health-card.component.html',
62 styleUrl: './overview-health-card.component.scss',
63 encapsulation: ViewEncapsulation.None,
64 changeDetection: ChangeDetectionStrategy.OnPush
66 export class OverviewHealthCardComponent {
67 private readonly summaryService = inject(SummaryService);
68 private readonly upgradeService = inject(UpgradeService);
70 @Input({ required: true }) vm!: HealthCardVM;
71 @Output() viewIncidents = new EventEmitter<void>();
73 activeSection: TabSection | null = null;
74 healthItems: HealthItemConfig[] = [
75 { key: 'mon', label: $localize`Monitor` },
76 { key: 'mgr', label: $localize`Manager` },
77 { key: 'osd', label: $localize`OSD` },
78 { key: 'hosts', label: $localize`Nodes` }
81 toggleSection(section: TabSection) {
82 this.activeSection = this.activeSection === section ? null : section;
85 readonly data$: Observable<OverviewHealthData> = combineLatest([
86 this.summaryService.summaryData$.pipe(filter((summary): summary is Summary => !!summary)),
87 this.upgradeService.listCached().pipe(
88 startWith(null as UpgradeInfoInterface),
89 catchError(() => of(null))
91 ]).pipe(map(([summary, upgrade]) => ({ summary, upgrade })));
93 onViewIncidentsClick() {
94 this.viewIncidents.emit();