feat(indicadores): dashboard interactivo multidominio y seguimiento CaCu
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { ChangeDetectorRef, Component, DestroyRef, inject, Input, OnChanges } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { catchError, of, Subject, switchMap } from 'rxjs';
|
||||
import { Dominio, IndicadorMetadatos } from './indicadores.models';
|
||||
import { IndicadoresService } from './indicadores.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-indicador-metadata',
|
||||
template: `
|
||||
@if (loading) { <p role="status">Cargando información metodológica…</p> }
|
||||
@if (metadata?.referencias?.length) {
|
||||
<h4>Referencias</h4><ul>@for (ref of metadata!.referencias; track $index) { <li>{{ ref.etiqueta }}@if (ref.ref) { · {{ ref.ref }} }</li> }</ul>
|
||||
}
|
||||
@if (metadata?.poblaciones?.length) {
|
||||
<h4>Poblaciones del estudio</h4><ul>@for (p of metadata!.poblaciones; track $index) { <li>{{ p.descripcion }}</li> }</ul>
|
||||
}
|
||||
@if (!loading && !metadata?.referencias?.length && !metadata?.poblaciones?.length) { <p>La información metodológica ampliada no está disponible para este indicador.</p> }
|
||||
`,
|
||||
})
|
||||
export class IndicadorMetadata implements OnChanges {
|
||||
@Input({ required: true }) dominio!: Dominio;
|
||||
@Input({ required: true }) indicador!: string;
|
||||
private readonly service = inject(IndicadoresService);
|
||||
private readonly requests = new Subject<void>();
|
||||
metadata?: IndicadorMetadatos;
|
||||
loading = false;
|
||||
private readonly changeDetector = inject(ChangeDetectorRef);
|
||||
constructor() {
|
||||
this.requests.pipe(switchMap(() => this.service.metadatos(this.dominio, this.indicador).pipe(catchError(() => of(undefined)))), takeUntilDestroyed(inject(DestroyRef))).subscribe(value => { this.metadata = value; this.loading = false; this.changeDetector.markForCheck(); });
|
||||
}
|
||||
ngOnChanges() { this.metadata = undefined; this.loading = true; this.requests.next(); }
|
||||
}
|
||||
Reference in New Issue
Block a user