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';
39 selector: 'cd-overview-health-card',
42 ProductiveCardComponent,
54 templateUrl: './overview-health-card.component.html',
55 styleUrl: './overview-health-card.component.scss',
56 encapsulation: ViewEncapsulation.None,
57 changeDetection: ChangeDetectionStrategy.OnPush
59 export class OverviewHealthCardComponent {
60 private readonly summaryService = inject(SummaryService);
61 private readonly upgradeService = inject(UpgradeService);
63 @Input({ required: true }) vm!: HealthCardVM;
64 @Output() viewIncidents = new EventEmitter<void>();
66 activeSection: TabSection | null = null;
68 toggleSection(section: TabSection) {
69 this.activeSection = this.activeSection === section ? null : section;
72 readonly data$: Observable<OverviewHealthData> = combineLatest([
73 this.summaryService.summaryData$.pipe(filter((summary): summary is Summary => !!summary)),
74 this.upgradeService.listCached().pipe(
75 startWith(null as UpgradeInfoInterface),
76 catchError(() => of(null))
78 ]).pipe(map(([summary, upgrade]) => ({ summary, upgrade })));
80 onViewIncidentsClick() {
81 this.viewIncidents.emit();