Files
WebApp/src/app/gobernanza/models.html
T
alberto 3a26c63931 T13: Gobernanza as one page with its sections in fixed places
Keep the route, title, subtitle, domain navigation and composition in
gobernanza.{ts,html,scss}. Ejecución keeps mode and health in execution.ts.
Add models.{ts,html,scss} to own the actions, run monitor, status, versions,
reports, figures, clinical validation, and checks and lineage dialogs.

Render training.ts after Modelos with the existing source, configuration,
promotion checkbox, input sets and upload. Keep ZIP export and import in
bundles.ts. Keep scope, study list, EDF upload and run progress in
tea/studies.{ts,html}, and render tea/preview.ts separately for TEA with
its EDF and ADOS-2 selection, results and PDF export.

Use a page grid for section spacing and the global card style. Keep
table, action and dialog styles local to Modelos. Use Material fields
for editable values and Material buttons to open native file pickers,
retaining input labels and showing the selected filenames. Keep the
native suggestion lists for scheduler and input set names.

Default the training target to all on domain changes. Both Modelos
training actions focus the Entrenamiento heading and use the same
Formly submit path. Use the existing shared start flag and version
refresh via the Modelos component. Reset the training promotion
checkbox on domain changes and the upload selection with its input
listing. Ignore training submissions that finish in a different domain.

Move gobernanza.spec.ts to models.spec.ts alongside checkActions.
Keep bundles, execution, training, run-monitor, figures and preview PDF
logic specs. Update e2e/pages.spec.ts for Material selections and
the Modelos monitor, and check section order and training focus.

Prettier 3.10.1 and git diff --cached --check passed. The main checkout
has no local Prettier installation, so use the available lockfile
version directly from the requested working directory. Angular builds,
unit tests and Playwright are deferred to the VM per the spec.
2026-12-01 02:15:51 -06:00

280 lines
8.9 KiB
HTML

<section class="card" aria-labelledby="models-heading">
<h2 id="models-heading">Modelos</h2>
<div class="actions">
<button mat-flat-button type="button" (click)="selectTraining('all')">Entrenar modelos</button>
<button
mat-stroked-button
type="button"
[disabled]="starting() || running()"
(click)="start('score')"
>
Calcular riesgos
</button>
@if (domain() === 'tea') {
<button
mat-stroked-button
type="button"
[disabled]="starting() || running() || !execution()"
(click)="start('analyze')"
>
Analizar EEG
</button>
}
<button
mat-stroked-button
type="button"
[disabled]="editing() || !models.hasValue()"
(click)="prepareCandidates(bulkDialog)"
>
Promover candidatas
</button>
</div>
@if (run(); as current) {
<section>
<h3>{{ current.label }}</h3>
<app-run-monitor [runId]="current.id" (finished)="finish($event)" />
</section>
}
@if (message()) {
<p class="message" role="status">{{ message() }}</p>
}
@if (models.isLoading()) {
<p class="muted">Cargando modelos…</p>
} @else if (models.error(); as error) {
<p role="alert">{{ errorText(error) }}</p>
} @else if (!models.hasValue() || !models.value().length) {
<p class="muted empty">Este dominio todavía no tiene modelos entrenados.</p>
}
@for (m of models.hasValue() ? models.value() : []; track m.name) {
<section class="model">
<h3>{{ m.title }}</h3>
<button mat-stroked-button type="button" (click)="selectTraining(m.name)">Reentrenar</button>
<table class="plain">
<thead>
<tr>
<th>Versión</th>
<th>Creada</th>
<th>Entrenamiento / prueba</th>
<th>Informes</th>
<th>Validación clínica</th>
<th>Comprobaciones y linaje</th>
</tr>
</thead>
<tbody>
@for (v of m.versions; track v.version) {
<tr>
<td>
v{{ v.version }} <span class="badge">{{ v.status }}</span>
</td>
<td>{{ v.created | date: 'yyyy-MM-dd HH:mm' }}</td>
<td class="num">
{{ v.metrics['n_train'] | number }} / {{ v.metrics['n_test'] | number }}
</td>
<td>
@for (report of v.reports; track report) {
<button
mat-stroked-button
type="button"
(click)="reportDownload(m.name, v.version, report)"
>
{{ reportNames[report] ?? report }}
</button>
}
@if (v.reports.includes('interpretability')) {
<button
mat-stroked-button
type="button"
(click)="chooseReport({ name: m.name, version: v.version })"
>
Ver gráficas
</button>
}
</td>
<td>
@if (!v.reports.includes('clinical_validation')) {
<input
#validation
type="file"
hidden
[attr.aria-label]="'Validación clínica de ' + m.name + ' v' + v.version"
(change)="upload(m.name, v.version, $event)"
/>
<button mat-stroked-button type="button" (click)="validation.click()">
Validación clínica
</button>
} @else {
Agregada
}
</td>
<td>
<button
mat-stroked-button
type="button"
(click)="
showVersion('checks', { name: m.name, version: v.version }, checksDialog)
"
>
Comprobaciones
</button>
<button
mat-stroked-button
type="button"
(click)="
showVersion('lineage', { name: m.name, version: v.version }, lineageDialog)
"
>
Linaje
</button>
</td>
</tr>
}
</tbody>
</table>
</section>
}
@if (chosen(); as version) {
<section>
<h3>Interpretabilidad · {{ version.name }} v{{ version.version }}</h3>
@if (feature(); as current) {
@if (ageFeatures().length > 1) {
<mat-form-field appearance="outline">
<mat-label>Característica</mat-label>
<mat-select [ngModel]="current" (ngModelChange)="selectedFeature.set($event)">
@for (feature of ageFeatures(); track feature) {
<mat-option [value]="feature">{{ feature }}</mat-option>
}
</mat-select>
</mat-form-field>
}
<mat-checkbox [(ngModel)]="overlay">Superponer estudios</mat-checkbox>
}
@if (report.error() || band.error() || analysed.error(); as error) {
<p role="alert">{{ errorText(error) }}</p>
}
@for (f of figures(); track f.title) {
<h4>{{ f.title }}</h4>
<app-plot
[figure]="f.figure"
[height]="
report.hasValue() && report.value()['kind'] === 'forest'
? forestHeight(f.figure.data.length)
: 360
"
/>
} @empty {
@if (report.isLoading() || band.isLoading()) {
<p class="muted">Cargando…</p>
} @else if (!report.error() && !band.error()) {
<p class="muted">Este informe no tiene gráficas.</p>
}
}
</section>
}
<dialog #checksDialog aria-label="Comprobaciones" (close)="checksFor.set(undefined)">
@if (checksFor(); as key) {
<h3>Comprobaciones · {{ key.name }} v{{ key.version }}</h3>
@if (checks.hasValue()) {
@let details = checks.value();
@let actions = checkActions(details);
<ul>
@for (check of details.checks; track check.report) {
<li>
{{ reportNames[check.report] ?? check.report }} ·
{{ check.present ? 'Presente' : 'Falta' }}
</li>
}
</ul>
<button
mat-stroked-button
type="button"
[disabled]="editing() || !actions.promote"
(click)="changeVersion(key, 'promote')"
>
Promover
</button>
<button
mat-stroked-button
type="button"
[disabled]="editing() || !actions.retire"
(click)="changeVersion(key, 'retire')"
>
Retirar
</button>
} @else if (checks.error(); as error) {
<p role="alert">{{ errorText(error) }}</p>
} @else {
<p>Cargando…</p>
}
@if (message()) {
<p role="status">{{ message() }}</p>
}
}
<form method="dialog"><button mat-stroked-button>Cerrar</button></form>
</dialog>
<dialog #lineageDialog aria-label="Linaje" (close)="lineageFor.set(undefined)">
@if (lineageFor(); as key) {
<h3>Linaje · {{ key.name }} v{{ key.version }}</h3>
@if (lineage.hasValue()) {
@let details = lineage.value();
<h4>Parámetros</h4>
<dl>
@for (entry of details.params | keyvalue; track entry.key) {
<dt>{{ entry.key }}</dt>
<dd>{{ entry.value }}</dd>
}
</dl>
<h4>Métricas</h4>
<dl>
@for (entry of details.metrics | keyvalue; track entry.key) {
<dt>{{ entry.key }}</dt>
<dd>{{ entry.value }}</dd>
}
</dl>
<h4>Etiquetas</h4>
<dl>
@for (entry of details.tags | keyvalue; track entry.key) {
<dt>{{ entry.key }}</dt>
<dd>{{ entry.value }}</dd>
}
</dl>
@if (details.imported; as imported) {
<h4>Importado de</h4>
<dl>
@for (entry of imported | keyvalue; track entry.key) {
<dt>{{ entry.key }}</dt>
<dd>{{ entry.value }}</dd>
}
</dl>
}
} @else if (lineage.error(); as error) {
<p role="alert">{{ errorText(error) }}</p>
} @else {
<p>Cargando…</p>
}
}
<form method="dialog"><button mat-stroked-button>Cerrar</button></form>
</dialog>
<dialog #bulkDialog aria-label="Promover candidatas">
<h3>Promover candidatas</h3>
<ul>
@for (candidate of candidates(); track candidate.name) {
<li>{{ candidate.name }} v{{ candidate.version }}</li>
}
</ul>
<button
mat-flat-button
type="button"
[disabled]="editing()"
(click)="promoteCandidates(bulkDialog)"
>
Promover
</button>
<form method="dialog"><button mat-stroked-button>Cancelar</button></form>
</dialog>
</section>