import { Component, Input } from '@angular/core'; import { RouterLink } from '@angular/router'; import { TPlatformServiceType, TPlatformServiceStatus } from '../../core/types/api.types'; import { CardComponent, CardHeaderComponent, CardTitleComponent, CardDescriptionComponent, CardContentComponent, } from '../../ui/card/card.component'; interface IPlatformServiceSummary { type: TPlatformServiceType; displayName: string; status: TPlatformServiceStatus; resourceCount: number; } @Component({ selector: 'app-platform-services-card', standalone: true, imports: [ RouterLink, CardComponent, CardHeaderComponent, CardTitleComponent, CardDescriptionComponent, CardContentComponent, ], template: ` Platform Services Infrastructure status @for (service of services; track service.type) {
{{ service.displayName }}
@if (service.status === 'running') { @if (service.resourceCount > 0) { {{ service.resourceCount }} {{ service.resourceCount === 1 ? getResourceLabel(service.type) : getResourceLabelPlural(service.type) }} } @else { Running } } @else { {{ formatStatus(service.status) }} }
} @empty {
No platform services
}
`, }) export class PlatformServicesCardComponent { @Input() services: IPlatformServiceSummary[] = []; formatStatus(status: string): string { return status.replace('-', ' '); } getResourceLabel(type: TPlatformServiceType): string { switch (type) { case 'mongodb': case 'postgresql': case 'clickhouse': return 'DB'; case 'minio': return 'bucket'; case 'redis': return 'cache'; case 'rabbitmq': return 'queue'; default: return 'resource'; } } getResourceLabelPlural(type: TPlatformServiceType): string { switch (type) { case 'mongodb': case 'postgresql': case 'clickhouse': return 'DBs'; case 'minio': return 'buckets'; case 'redis': return 'caches'; case 'rabbitmq': return 'queues'; default: return 'resources'; } } }