integrating latest dashboard changes

This commit is contained in:
Roberto Treviño Cervantes
2026-10-26 01:42:32 -06:00
parent d9245fe9b7
commit 51517ddf61
85 changed files with 7754 additions and 320 deletions
@@ -10,8 +10,9 @@ import { IndicadorKpiCard } from './indicador-kpi-card';
import { KpiDefinition, KpiResult, kpiResult } from './indicadores-kpi';
import { PeriodAvailability, sortedPeriods } from './indicadores-periodos';
import { httpMessage } from './indicadores-http';
import { IndicadoresSnapshots } from './indicadores-snapshots';
interface KpiDisplay extends KpiResult { period?: string; earlier?: boolean; }
interface KpiDisplay extends KpiResult { period?: string; earlier?: boolean; version?: string; }
@Component({
selector: 'app-indicador-kpi-panel',
@@ -32,6 +33,7 @@ export class IndicadorKpiPanel implements OnChanges {
@Input() availability?: PeriodAvailability;
@Input() initialPresentation = false;
private readonly queries = inject(IndicadoresKpiQueries);
private readonly snapshots = inject(IndicadoresSnapshots);
private readonly destroyRef = inject(DestroyRef);
private readonly requests = new Subject<void>();
private key = '';
@@ -68,8 +70,9 @@ export class IndicadorKpiPanel implements OnChanges {
const search = (index: number, latest?: KpiDisplay, allSuppressed = true): Observable<KpiDisplay> => {
const period = periods[index];
const resolved: GlobalApplied = { ...applied, selection: { mode: 'explicit', periodos: [period] } };
return this.queries.datos(domain, definition.id, applied.tipo, period).pipe(
map(data => ({ ...kpiResult(data, definition, domain, resolved), notes: data.notas, period } as KpiDisplay)),
return this.queries.datos(domain, definition.id, applied.tipo, period, this.indicador?.version).pipe(
map(data => ({ ...kpiResult(data, definition, domain, resolved), notes: data.notas, period,
version: typeof data['version'] === 'string' ? data['version'] : undefined } as KpiDisplay)),
catchError(error => of<KpiDisplay>({ period,
state: error instanceof HttpErrorResponse && error.status === 404 ? 'Sin datos del periodo' : 'Error de consulta',
info: error instanceof HttpErrorResponse && error.status === 404 ? undefined : httpMessage(error) })),
@@ -88,10 +91,12 @@ export class IndicadorKpiPanel implements OnChanges {
}), takeUntilDestroyed(this.destroyRef)).subscribe(result => {
this.usedPeriod.set(result.period);
this.result.set(result);
if (this.applied) this.snapshots.publishKpi(this.dominio, this.indicador ?? this.definition, this.applied,
{ ...result, period: this.temporalReference, unit: this.definition.unit }, result.version);
});
}
ngOnChanges() {
const key = JSON.stringify([this.dominio, this.definition.id, this.indicador, this.initialPresentation, this.applied && selectionKey(this.applied),
const key = JSON.stringify([this.dominio, this.definition.id, this.indicador, this.initialPresentation, this.applied?.revision, this.applied && selectionKey(this.applied),
this.applied?.selection.mode === 'todos' ? [this.availability?.status, this.availability?.byIndicator[this.definition.id], this.availability?.errors[this.definition.id]] : undefined]);
if (key === this.key) return;
this.key = key;