F1h: Gobernanza without Vista previa and Subir archivos, button spacing

Keep preview state in Modelos and reset the toggle on domain changes. Hide the form while collapsed so the current selections, run monitor and result dialog survive toggling. Keep the existing evaluation and PDF handlers.

Use one wrapping button-row class with space-3 gaps and block margins. Inside table cells use the existing cell padding between rows. Apply the same class to the indicators export and keep the existing domain navigation bottom margin.

Delete the training upload UI and hand-edit the client and OpenAPI. Preserve the generator format and update the Modelos component spec and Gobernanza page case to cover both toggle states.
This commit is contained in:
2026-12-01 13:49:28 -06:00
parent e14a85261c
commit 71777537e1
22 changed files with 349 additions and 649 deletions
+158 -158
View File
@@ -1,5 +1,5 @@
import { KeyValuePipe } from '@angular/common';
import { Component, inject, signal } from '@angular/core';
import { Component, inject, input, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
@@ -23,170 +23,170 @@ import { downloadPreviewPdf } from './preview-pdf';
RunMonitor,
],
template: `
<section class="card" aria-labelledby="preview-heading">
<h2 id="preview-heading">Vista previa</h2>
<form (ngSubmit)="start(edf.files?.[0], ados.files?.[0], birth.value)">
<input
#edf
type="file"
accept=".edf"
required
hidden
aria-label="EDF"
(change)="edfFiles.set(edf.files)"
/>
<button mat-stroked-button type="button" (click)="edf.click()">EDF</button>
@for (file of edfFiles(); track $index) {
<span>{{ file.name }}</span>
}
<input
#ados
type="file"
accept=".pdf"
hidden
aria-label="ADOS-2 (PDF)"
(change)="adosFiles.set(ados.files)"
/>
<button mat-stroked-button type="button" (click)="ados.click()">ADOS-2 (PDF)</button>
@for (file of adosFiles(); track $index) {
<span>{{ file.name }}</span>
}
<mat-form-field appearance="outline">
<mat-label>Fecha de nacimiento</mat-label>
<input matInput #birth type="date" />
</mat-form-field>
<button mat-stroked-button type="submit" [disabled]="busy() || !edfFiles()?.length">
Vista previa
</button>
</form>
@if (error()) {
<p role="alert">{{ error() }}</p>
<form
class="button-row"
[hidden]="!active()"
(ngSubmit)="start(edf.files?.[0], ados.files?.[0], birth.value)"
>
<input
#edf
type="file"
accept=".edf"
required
hidden
aria-label="EDF"
(change)="edfFiles.set(edf.files)"
/>
<button mat-stroked-button type="button" (click)="edf.click()">EDF</button>
@for (file of edfFiles(); track $index) {
<span>{{ file.name }}</span>
}
@if (runId(); as id) {
<app-run-monitor [runId]="id" (finished)="finish($event, dialog)" />
<input
#ados
type="file"
accept=".pdf"
hidden
aria-label="ADOS-2 (PDF)"
(change)="adosFiles.set(ados.files)"
/>
<button mat-stroked-button type="button" (click)="ados.click()">ADOS-2 (PDF)</button>
@for (file of adosFiles(); track $index) {
<span>{{ file.name }}</span>
}
<dialog #dialog aria-label="Vista previa del estudio">
<mat-form-field appearance="outline">
<mat-label>Fecha de nacimiento</mat-label>
<input matInput #birth type="date" />
</mat-form-field>
<button mat-stroked-button type="submit" [disabled]="busy() || !edfFiles()?.length">
Vista previa
</button>
</form>
@if (error()) {
<p role="alert">{{ error() }}</p>
}
@if (runId(); as id) {
<app-run-monitor [runId]="id" (finished)="finish($event, dialog)" />
}
<dialog #dialog aria-label="Vista previa del estudio">
@if (result(); as r) {
<h3>Resultado de la vista previa</h3>
<p>
{{ r.eeg.level }} ·
{{ r.eeg.valid === true ? 'Válido' : r.eeg.valid === false ? 'No válido' : '—' }}
</p>
@if (r.eeg.error) {
<p role="alert">{{ r.eeg.error }}</p>
}
<h4>Comprobaciones</h4>
<table class="plain">
<thead>
<tr>
<th>Comprobación</th>
<th>Electrodo</th>
<th>Resultado</th>
<th>Rango</th>
<th>Anormal</th>
</tr>
</thead>
<tbody>
@for (check of r.eeg.checks; track $index) {
<tr>
<td>{{ check['code'] }}</td>
<td>{{ check['electrode'] ?? '—' }}</td>
<td>{{ check['value'] ?? check['text'] ?? '—' }} {{ check['unit'] }}</td>
<td>{{ check['low'] ?? '—' }} / {{ check['high'] ?? '—' }}</td>
<td>
{{ check['abnormal'] === true ? 'Sí' : check['abnormal'] === false ? 'No' : '—' }}
</td>
</tr>
}
</tbody>
</table>
<h4>Métricas</h4>
<table class="plain">
<thead>
<tr>
<th>Métrica</th>
<th>Valor</th>
<th>z</th>
<th>p5 / mediana / p95</th>
<th>Fuera de rango</th>
</tr>
</thead>
<tbody>
@for (metric of r.eeg.metrics; track metric.code) {
<tr>
<th>{{ metric.code }}</th>
<td>{{ metric.value ?? '—' }}</td>
<td>{{ metric.score?.z ?? '—' }}</td>
<td>
{{ metric.score?.p5 ?? '—' }} / {{ metric.score?.median ?? '—' }} /
{{ metric.score?.p95 ?? '—' }}
</td>
<td>{{ metric.score?.outside ?? '—' }}</td>
</tr>
@for (site of metric.electrodes | keyvalue; track site.key) {
<tr>
<td>{{ site.key }}</td>
<td>{{ site.value.value ?? '—' }}</td>
<td>{{ site.value.score?.z ?? '—' }}</td>
<td>
{{ site.value.score?.p5 ?? '—' }} / {{ site.value.score?.median ?? '—' }} /
{{ site.value.score?.p95 ?? '—' }}
</td>
<td>{{ site.value.score?.outside ?? '—' }}</td>
</tr>
}
@for (site of metric.zones | keyvalue; track site.key) {
<tr>
<td>{{ site.key }}</td>
<td>{{ site.value.value ?? '—' }}</td>
<td>{{ site.value.score?.z ?? '—' }}</td>
<td>
{{ site.value.score?.p5 ?? '—' }} / {{ site.value.score?.median ?? '—' }} /
{{ site.value.score?.p95 ?? '—' }}
</td>
<td>{{ site.value.score?.outside ?? '—' }}</td>
</tr>
}
}
</tbody>
</table>
@if (r.ados2; as ados2) {
<h4>ADOS-2</h4>
<p>{{ ados2.classification }} · CSS {{ ados2.css ?? '—' }}</p>
<dl>
@for (item of ados2.items | keyvalue: unsorted; track item.key) {
<dt>{{ ados2.titles[item.key] ?? item.key }}</dt>
<dd>{{ item.value ?? '—' }}</dd>
}
</dl>
}
@if (r.warnings.length) {
<h4>Advertencias</h4>
<ul>
@for (warning of r.warnings; track $index) {
<li>{{ warning }}</li>
}
</ul>
}
}
@if (pdfError()) {
<p role="alert">{{ pdfError() }}</p>
}
<form class="button-row" method="dialog">
@if (result(); as r) {
<h3>Resultado de la vista previa</h3>
<p>
{{ r.eeg.level }} ·
{{ r.eeg.valid === true ? 'Válido' : r.eeg.valid === false ? 'No válido' : '—' }}
</p>
@if (r.eeg.error) {
<p role="alert">{{ r.eeg.error }}</p>
}
<h4>Comprobaciones</h4>
<table class="plain">
<thead>
<tr>
<th>Comprobación</th>
<th>Electrodo</th>
<th>Resultado</th>
<th>Rango</th>
<th>Anormal</th>
</tr>
</thead>
<tbody>
@for (check of r.eeg.checks; track $index) {
<tr>
<td>{{ check['code'] }}</td>
<td>{{ check['electrode'] ?? '—' }}</td>
<td>{{ check['value'] ?? check['text'] ?? '—' }} {{ check['unit'] }}</td>
<td>{{ check['low'] ?? '—' }} / {{ check['high'] ?? '—' }}</td>
<td>
{{
check['abnormal'] === true ? 'Sí' : check['abnormal'] === false ? 'No' : '—'
}}
</td>
</tr>
}
</tbody>
</table>
<h4>Métricas</h4>
<table class="plain">
<thead>
<tr>
<th>Métrica</th>
<th>Valor</th>
<th>z</th>
<th>p5 / mediana / p95</th>
<th>Fuera de rango</th>
</tr>
</thead>
<tbody>
@for (metric of r.eeg.metrics; track metric.code) {
<tr>
<th>{{ metric.code }}</th>
<td>{{ metric.value ?? '—' }}</td>
<td>{{ metric.score?.z ?? '—' }}</td>
<td>
{{ metric.score?.p5 ?? '—' }} / {{ metric.score?.median ?? '—' }} /
{{ metric.score?.p95 ?? '—' }}
</td>
<td>{{ metric.score?.outside ?? '—' }}</td>
</tr>
@for (site of metric.electrodes | keyvalue; track site.key) {
<tr>
<td>{{ site.key }}</td>
<td>{{ site.value.value ?? '—' }}</td>
<td>{{ site.value.score?.z ?? '—' }}</td>
<td>
{{ site.value.score?.p5 ?? '—' }} / {{ site.value.score?.median ?? '—' }} /
{{ site.value.score?.p95 ?? '—' }}
</td>
<td>{{ site.value.score?.outside ?? '—' }}</td>
</tr>
}
@for (site of metric.zones | keyvalue; track site.key) {
<tr>
<td>{{ site.key }}</td>
<td>{{ site.value.value ?? '—' }}</td>
<td>{{ site.value.score?.z ?? '—' }}</td>
<td>
{{ site.value.score?.p5 ?? '—' }} / {{ site.value.score?.median ?? '—' }} /
{{ site.value.score?.p95 ?? '—' }}
</td>
<td>{{ site.value.score?.outside ?? '—' }}</td>
</tr>
}
}
</tbody>
</table>
@if (r.ados2; as ados2) {
<h4>ADOS-2</h4>
<p>{{ ados2.classification }} · CSS {{ ados2.css ?? '—' }}</p>
<dl>
@for (item of ados2.items | keyvalue: unsorted; track item.key) {
<dt>{{ ados2.titles[item.key] ?? item.key }}</dt>
<dd>{{ item.value ?? '—' }}</dd>
}
</dl>
}
@if (r.warnings.length) {
<h4>Advertencias</h4>
<ul>
@for (warning of r.warnings; track $index) {
<li>{{ warning }}</li>
}
</ul>
}
<button mat-stroked-button type="button" [disabled]="exporting()" (click)="pdf(r)">
Guardar como PDF
</button>
}
@if (pdfError()) {
<p role="alert">{{ pdfError() }}</p>
}
<form method="dialog">
@if (result(); as r) {
<button mat-stroked-button type="button" [disabled]="exporting()" (click)="pdf(r)">
Guardar como PDF
</button>
}
<button mat-stroked-button>Cerrar</button>
</form>
</dialog>
</section>
<button mat-stroked-button>Cerrar</button>
</form>
</dialog>
`,
})
export class EegPreview {
readonly active = input.required<boolean>();
private readonly api = inject(Api);
protected readonly edfFiles = signal<FileList | null>(null);
protected readonly adosFiles = signal<FileList | null>(null);