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:
@@ -1,38 +0,0 @@
|
||||
/* eslint-disable */
|
||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||
|
||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { StrictHttpResponse } from '../../strict-http-response';
|
||||
import { RequestBuilder } from '../../request-builder';
|
||||
|
||||
import { Domain } from '../../models/domain';
|
||||
|
||||
export interface TrainingInputs$Params {
|
||||
domain: Domain;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function trainingInputs(http: HttpClient, rootUrl: string, params: TrainingInputs$Params, context?: HttpContext): Observable<StrictHttpResponse<{
|
||||
[key: string]: Array<string>;
|
||||
}>> {
|
||||
const rb = new RequestBuilder(rootUrl, trainingInputs.PATH, 'get');
|
||||
if (params) {
|
||||
rb.path('domain', params.domain, {});
|
||||
rb.path('name', params.name, {});
|
||||
}
|
||||
|
||||
return http.request(
|
||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<{
|
||||
[key: string]: Array<string>;
|
||||
}>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
trainingInputs.PATH = '/models/{domain}/{name}/inputs';
|
||||
@@ -1,43 +0,0 @@
|
||||
/* eslint-disable */
|
||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||
|
||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { StrictHttpResponse } from '../../strict-http-response';
|
||||
import { RequestBuilder } from '../../request-builder';
|
||||
|
||||
import { BodyUploadTrainingInputs } from '../../models/body-upload-training-inputs';
|
||||
import { Domain } from '../../models/domain';
|
||||
|
||||
export interface UploadTrainingInputs$Params {
|
||||
domain: Domain;
|
||||
name: string;
|
||||
set: string;
|
||||
body: BodyUploadTrainingInputs
|
||||
}
|
||||
|
||||
export function uploadTrainingInputs(http: HttpClient, rootUrl: string, params: UploadTrainingInputs$Params, context?: HttpContext): Observable<StrictHttpResponse<{
|
||||
[key: string]: any;
|
||||
}>> {
|
||||
const rb = new RequestBuilder(rootUrl, uploadTrainingInputs.PATH, 'post');
|
||||
if (params) {
|
||||
rb.path('domain', params.domain, {});
|
||||
rb.path('name', params.name, {});
|
||||
rb.path('set', params.set, {});
|
||||
rb.body(params.body, 'multipart/form-data');
|
||||
}
|
||||
|
||||
return http.request(
|
||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
uploadTrainingInputs.PATH = '/models/{domain}/{name}/inputs/{set}/files';
|
||||
@@ -53,10 +53,6 @@ export type { Score$Params as Score$Params } from './fn/models/score';
|
||||
export { score as score } from './fn/models/score';
|
||||
export type { Train$Params as Train$Params } from './fn/models/train';
|
||||
export { train as train } from './fn/models/train';
|
||||
export type { TrainingInputs$Params as TrainingInputs$Params } from './fn/models/training-inputs';
|
||||
export { trainingInputs as trainingInputs } from './fn/models/training-inputs';
|
||||
export type { UploadTrainingInputs$Params as UploadTrainingInputs$Params } from './fn/models/upload-training-inputs';
|
||||
export { uploadTrainingInputs as uploadTrainingInputs } from './fn/models/upload-training-inputs';
|
||||
export type { TrainingConfig$Params as TrainingConfig$Params } from './fn/models/training-config';
|
||||
export { trainingConfig as trainingConfig } from './fn/models/training-config';
|
||||
export type { Versions$Params as Versions$Params } from './fn/models/versions';
|
||||
|
||||
@@ -9,7 +9,6 @@ export type { BodyAddClinicalValidation } from './models/body-add-clinical-valid
|
||||
export type { BodyImportModels } from './models/body-import-models';
|
||||
export type { BodyStartPreview } from './models/body-start-preview';
|
||||
export type { BodyUpload } from './models/body-upload';
|
||||
export type { BodyUploadTrainingInputs } from './models/body-upload-training-inputs';
|
||||
export type { Browsed } from './models/browsed';
|
||||
export type { Cancel } from './models/cancel';
|
||||
export type { Catalog } from './models/catalog';
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
/* eslint-disable */
|
||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||
|
||||
export interface BodyUploadTrainingInputs {
|
||||
files: Array<Blob>;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ export async function exportErrorText(error: unknown): Promise<string> {
|
||||
template: `
|
||||
<section class="card" aria-labelledby="bundles-heading">
|
||||
<h2 id="bundles-heading">Bundles</h2>
|
||||
<form (ngSubmit)="export()">
|
||||
<form class="button-row" (ngSubmit)="export()">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Versiones</mat-label>
|
||||
<mat-select name="versions" [(ngModel)]="selection">
|
||||
@@ -60,7 +60,7 @@ export async function exportErrorText(error: unknown): Promise<string> {
|
||||
SHA-256 <code>{{ exportedHash() }}</code>
|
||||
</p>
|
||||
}
|
||||
<form (ngSubmit)="import(file)">
|
||||
<form class="button-row" (ngSubmit)="import(file)">
|
||||
<input
|
||||
#file
|
||||
type="file"
|
||||
|
||||
@@ -58,9 +58,11 @@ import type { Health } from '../api/models/health';
|
||||
}
|
||||
</p>
|
||||
@if (h.dashboard_url && h.dashboard_ok !== false) {
|
||||
<a mat-stroked-button [href]="h.dashboard_url" target="_blank" rel="noopener"
|
||||
>Panel de Dask</a
|
||||
>
|
||||
<div class="button-row">
|
||||
<a mat-stroked-button [href]="h.dashboard_url" target="_blank" rel="noopener"
|
||||
>Panel de Dask</a
|
||||
>
|
||||
</div>
|
||||
}
|
||||
} @else if (health.error() || options.error()) {
|
||||
<p role="alert">No se pudo consultar la ejecución.</p>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<section class="page">
|
||||
<h1>Gobernanza de modelos</h1>
|
||||
<p class="subtitle">Administra la ejecución, las versiones y el entrenamiento por dominio.</p>
|
||||
<nav class="domains" aria-label="Dominios">
|
||||
<nav class="domains button-row" aria-label="Dominios">
|
||||
@for (d of domains.hasValue() ? domains.value() : []; track d) {
|
||||
<a mat-stroked-button [routerLink]="['/gobernanza', d]" [class.active]="d === domain()">
|
||||
{{ labels[d] ?? d }}
|
||||
@@ -16,7 +16,6 @@
|
||||
[domain]="domainKey()"
|
||||
[execution]="execution.execution()"
|
||||
(trainingRequested)="training.focus()"
|
||||
(previewRequested)="showPreview.set(true)"
|
||||
/>
|
||||
<app-governance-training
|
||||
#training
|
||||
@@ -39,9 +38,6 @@
|
||||
[refresh]="models.refreshed()"
|
||||
(changed)="models.refresh()"
|
||||
/>
|
||||
@if (showPreview()) {
|
||||
<app-eeg-preview />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
display: block;
|
||||
}
|
||||
.domains {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
.domains a.active {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, computed, inject, input, linkedSignal, resource } from '@angular/core';
|
||||
import { Component, computed, inject, input, resource } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { Api } from '../api/api';
|
||||
@@ -8,29 +8,18 @@ import { DOMAINS } from '../app';
|
||||
import { Bundles } from './bundles';
|
||||
import { Execution } from './execution';
|
||||
import { Models } from './models';
|
||||
import { EegPreview } from './tea/preview';
|
||||
import { EegStudies } from './tea/studies';
|
||||
import { Training } from './training';
|
||||
|
||||
@Component({
|
||||
selector: 'app-gobernanza',
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
RouterLink,
|
||||
Execution,
|
||||
Models,
|
||||
Training,
|
||||
Bundles,
|
||||
EegStudies,
|
||||
EegPreview,
|
||||
],
|
||||
imports: [MatButtonModule, RouterLink, Execution, Models, Training, Bundles, EegStudies],
|
||||
templateUrl: './gobernanza.html',
|
||||
styleUrl: './gobernanza.scss',
|
||||
})
|
||||
export class Gobernanza {
|
||||
private readonly api = inject(Api);
|
||||
readonly domain = input.required<string>();
|
||||
protected readonly showPreview = linkedSignal({ source: this.domain, computation: () => false });
|
||||
protected readonly domainKey = computed(() => this.domain() as Domain);
|
||||
protected readonly labels = DOMAINS as Record<string, string>;
|
||||
protected readonly domains = resource({ loader: () => this.api.invoke(domains) });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<section class="card" aria-labelledby="models-heading">
|
||||
<h2 id="models-heading">Modelos</h2>
|
||||
<div class="actions">
|
||||
<div class="button-row">
|
||||
<button mat-flat-button type="button" (click)="selectTraining('all')">Entrenar modelos</button>
|
||||
<button
|
||||
mat-stroked-button
|
||||
@@ -19,7 +19,12 @@
|
||||
>
|
||||
Analizar EEG
|
||||
</button>
|
||||
<button mat-stroked-button type="button" (click)="previewRequested.emit()">
|
||||
<button
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
[attr.aria-pressed]="showPreview()"
|
||||
(click)="showPreview.set(!showPreview())"
|
||||
>
|
||||
Evaluar un solo estudio
|
||||
</button>
|
||||
}
|
||||
@@ -32,6 +37,9 @@
|
||||
Promover candidatas
|
||||
</button>
|
||||
</div>
|
||||
@if (domain() === 'tea') {
|
||||
<app-eeg-preview [active]="showPreview()" />
|
||||
}
|
||||
@if (run(); as current) {
|
||||
<section>
|
||||
<h3>{{ current.label }}</h3>
|
||||
@@ -52,7 +60,11 @@
|
||||
@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>
|
||||
<div class="button-row">
|
||||
<button mat-stroked-button type="button" (click)="selectTraining(m.name)">
|
||||
Reentrenar
|
||||
</button>
|
||||
</div>
|
||||
<table class="plain">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -75,24 +87,26 @@
|
||||
{{ 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>
|
||||
}
|
||||
<div class="button-row">
|
||||
@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>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@if (!v.reports.includes('clinical_validation')) {
|
||||
@@ -111,24 +125,26 @@
|
||||
}
|
||||
</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>
|
||||
<div class="button-row">
|
||||
<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>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -190,22 +206,24 @@
|
||||
</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>
|
||||
<div class="button-row">
|
||||
<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>
|
||||
</div>
|
||||
} @else if (checks.error(); as error) {
|
||||
<p role="alert">{{ errorText(error) }}</p>
|
||||
} @else {
|
||||
@@ -215,7 +233,7 @@
|
||||
<p role="status">{{ message() }}</p>
|
||||
}
|
||||
}
|
||||
<form method="dialog"><button mat-stroked-button>Cerrar</button></form>
|
||||
<form class="button-row" method="dialog"><button mat-stroked-button>Cerrar</button></form>
|
||||
</dialog>
|
||||
|
||||
<dialog #lineageDialog aria-label="Linaje" (close)="lineageFor.set(undefined)">
|
||||
@@ -259,7 +277,7 @@
|
||||
<p>Cargando…</p>
|
||||
}
|
||||
}
|
||||
<form method="dialog"><button mat-stroked-button>Cerrar</button></form>
|
||||
<form class="button-row" method="dialog"><button mat-stroked-button>Cerrar</button></form>
|
||||
</dialog>
|
||||
|
||||
<dialog #bulkDialog aria-label="Promover candidatas">
|
||||
@@ -269,14 +287,16 @@
|
||||
<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>
|
||||
<div class="button-row">
|
||||
<button
|
||||
mat-flat-button
|
||||
type="button"
|
||||
[disabled]="editing()"
|
||||
(click)="promoteCandidates(bulkDialog)"
|
||||
>
|
||||
Promover
|
||||
</button>
|
||||
<form method="dialog"><button mat-stroked-button>Cancelar</button></form>
|
||||
</div>
|
||||
</dialog>
|
||||
</section>
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
.model {
|
||||
margin-bottom: var(--space-4);
|
||||
overflow-x: auto;
|
||||
@@ -31,6 +24,3 @@
|
||||
dialog {
|
||||
max-width: min(90vw, 64rem);
|
||||
}
|
||||
dialog form {
|
||||
margin-top: var(--space-3);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { checkActions } from './models';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Api } from '../api/api';
|
||||
import { checkActions, Models } from './models';
|
||||
|
||||
describe('version checks', () => {
|
||||
it('enables promotion only when the API says the version is promotable', () => {
|
||||
@@ -14,3 +16,30 @@ describe('version checks', () => {
|
||||
expect(checkActions({ status: 'candidate', promotable: true, checks: [] }).retire).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('single study evaluation', () => {
|
||||
it('toggles the preview form below the Modelos button row', async () => {
|
||||
TestBed.overrideProvider(Api, { useValue: { invoke: vi.fn().mockResolvedValue([]) } });
|
||||
const fixture = TestBed.createComponent(Models);
|
||||
fixture.componentRef.setInput('domain', 'tea');
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const host: HTMLElement = fixture.nativeElement;
|
||||
const toggle = host.querySelector<HTMLButtonElement>('button[aria-pressed]')!;
|
||||
const form = host.querySelector<HTMLFormElement>('.button-row + app-eeg-preview > form')!;
|
||||
expect(toggle.getAttribute('aria-pressed')).toBe('false');
|
||||
expect(form.hidden).toBe(true);
|
||||
|
||||
toggle.click();
|
||||
fixture.detectChanges();
|
||||
expect(toggle.getAttribute('aria-pressed')).toBe('true');
|
||||
expect(form.hidden).toBe(false);
|
||||
expect(form.querySelectorAll('input')).toHaveLength(3);
|
||||
|
||||
toggle.click();
|
||||
fixture.detectChanges();
|
||||
expect(toggle.getAttribute('aria-pressed')).toBe('false');
|
||||
expect(form.hidden).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
linkedSignal,
|
||||
output,
|
||||
resource,
|
||||
signal,
|
||||
@@ -36,6 +37,7 @@ import { Plot } from '../plot';
|
||||
import { download } from '../export';
|
||||
import { interpretabilityFigures, studyPoints, type Centile } from './figures';
|
||||
import { errorText, RunMonitor } from './run-monitor';
|
||||
import { EegPreview } from './tea/preview';
|
||||
|
||||
const REPORTS: Record<string, string> = {
|
||||
technical_validation: 'Validación técnica',
|
||||
@@ -78,6 +80,7 @@ export function checkActions(checks: Checks) {
|
||||
MatSelectModule,
|
||||
Plot,
|
||||
RunMonitor,
|
||||
EegPreview,
|
||||
],
|
||||
templateUrl: './models.html',
|
||||
styleUrl: './models.scss',
|
||||
@@ -87,7 +90,7 @@ export class Models {
|
||||
readonly domain = input.required<Domain>();
|
||||
readonly execution = input<Choice>();
|
||||
readonly trainingRequested = output<void>();
|
||||
readonly previewRequested = output<void>();
|
||||
protected readonly showPreview = linkedSignal({ source: this.domain, computation: () => false });
|
||||
protected readonly reportNames = REPORTS;
|
||||
protected readonly errorText = errorText;
|
||||
readonly refreshed = signal(0);
|
||||
|
||||
@@ -77,14 +77,16 @@ export function eta(progress: Progress): number | null {
|
||||
<p role="alert">{{ r.error }}</p>
|
||||
}
|
||||
@if (!terminal.has(r.state)) {
|
||||
<button
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
[disabled]="cancelling() || r.state === 'cancelling'"
|
||||
(click)="cancel()"
|
||||
>
|
||||
Cancelar
|
||||
</button>
|
||||
<div class="button-row">
|
||||
<button
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
[disabled]="cancelling() || r.state === 'cancelling'"
|
||||
(click)="cancel()"
|
||||
>
|
||||
Cancelar
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
} @else {
|
||||
<p role="status">Consultando ejecución…</p>
|
||||
|
||||
+158
-158
@@ -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);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<section class="card" aria-labelledby="studies-heading">
|
||||
<h2 id="studies-heading">Estudios EEG</h2>
|
||||
<form (ngSubmit)="analyze()">
|
||||
<form class="button-row" (ngSubmit)="analyze()">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Alcance</mat-label>
|
||||
<mat-select name="scope" [(ngModel)]="mode">
|
||||
|
||||
+14
-120
@@ -1,4 +1,3 @@
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import {
|
||||
Component,
|
||||
ElementRef,
|
||||
@@ -14,8 +13,6 @@ import {
|
||||
import { FormsModule, ReactiveFormsModule, UntypedFormGroup } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { FormlyForm, provideFormlyCore } from '@ngx-formly/core';
|
||||
import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
|
||||
import { withFormlyMaterial } from '@ngx-formly/material';
|
||||
@@ -23,8 +20,6 @@ import type { JSONSchema7, JSONSchema7TypeName } from 'json-schema';
|
||||
import { Api } from '../api/api';
|
||||
import { train } from '../api/fn/models/train';
|
||||
import { trainingConfig } from '../api/fn/models/training-config';
|
||||
import { trainingInputs } from '../api/fn/models/training-inputs';
|
||||
import { uploadTrainingInputs } from '../api/fn/models/upload-training-inputs';
|
||||
import type { Domain } from '../api/models/domain';
|
||||
import type { Execution } from '../api/models/execution';
|
||||
import type { TrainingConfig } from '../api/models/training-config';
|
||||
@@ -112,26 +107,10 @@ export function sourcePayload<T extends object>(source: T, variants: Variants):
|
||||
) as T;
|
||||
}
|
||||
|
||||
function allowedFile(file: File, allowed: string[]): boolean {
|
||||
return allowed.some((pattern) => {
|
||||
if (pattern === '*.edf') return file.name.toLowerCase().endsWith('.edf');
|
||||
return file.name === pattern;
|
||||
});
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-governance-training',
|
||||
imports: [
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
FormlyForm,
|
||||
MatButtonModule,
|
||||
MatCheckboxModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
],
|
||||
imports: [FormsModule, ReactiveFormsModule, FormlyForm, MatButtonModule, MatCheckboxModule],
|
||||
providers: [provideFormlyCore([...withFormlyMaterial(), FORMLY_TYPES])],
|
||||
styles: ':host { display: grid; gap: var(--space-4); }',
|
||||
template: `
|
||||
<section class="card" aria-labelledby="training-heading">
|
||||
<h2 #heading id="training-heading" tabindex="-1">Entrenamiento</h2>
|
||||
@@ -142,18 +121,20 @@ function allowedFile(file: File, allowed: string[]): boolean {
|
||||
@let form = config.value();
|
||||
<form (ngSubmit)="start(form.model)">
|
||||
<formly-form [form]="form.form" [fields]="form.fields" [model]="form.model" />
|
||||
@if (domain() === 'tea') {
|
||||
<mat-checkbox name="promote" [(ngModel)]="autoPromote"
|
||||
>Promover al terminar</mat-checkbox
|
||||
<div class="button-row">
|
||||
@if (domain() === 'tea') {
|
||||
<mat-checkbox name="promote" [(ngModel)]="autoPromote"
|
||||
>Promover al terminar</mat-checkbox
|
||||
>
|
||||
}
|
||||
<button
|
||||
mat-flat-button
|
||||
type="submit"
|
||||
[disabled]="busy() || disabled() || form.form.invalid"
|
||||
>
|
||||
}
|
||||
<button
|
||||
mat-flat-button
|
||||
type="submit"
|
||||
[disabled]="busy() || disabled() || form.form.invalid"
|
||||
>
|
||||
Entrenar
|
||||
</button>
|
||||
Entrenar
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
} @else if (config.error(); as error) {
|
||||
<p role="alert">{{ errorText(error) }}</p>
|
||||
@@ -162,43 +143,6 @@ function allowedFile(file: File, allowed: string[]): boolean {
|
||||
<p role="status">{{ message() }}</p>
|
||||
}
|
||||
</section>
|
||||
@if (inputs.hasValue() && inputs.value(); as metadata) {
|
||||
<section class="card" aria-labelledby="training-upload-heading">
|
||||
<h2 id="training-upload-heading">Subir archivos</h2>
|
||||
<form (ngSubmit)="upload(setName.value, files)">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Conjunto</mat-label>
|
||||
<input matInput #setName required />
|
||||
</mat-form-field>
|
||||
<input
|
||||
#files
|
||||
type="file"
|
||||
multiple
|
||||
required
|
||||
[accept]="accept(metadata['allowed'])"
|
||||
hidden
|
||||
aria-label="Archivos"
|
||||
(change)="selectedFiles.set(files.files)"
|
||||
/>
|
||||
<button mat-stroked-button type="button" (click)="files.click()">Archivos</button>
|
||||
@for (file of selectedFiles(); track $index) {
|
||||
<span>{{ file.name }}</span>
|
||||
}
|
||||
<button
|
||||
mat-stroked-button
|
||||
type="submit"
|
||||
[disabled]="uploading() || !selectedFiles()?.length"
|
||||
>
|
||||
Subir archivos
|
||||
</button>
|
||||
</form>
|
||||
@if (uploadMessage()) {
|
||||
<p role="status">{{ uploadMessage() }}</p>
|
||||
}
|
||||
</section>
|
||||
} @else if (inputs.error(); as error) {
|
||||
<p role="alert">{{ errorText(error) }}</p>
|
||||
}
|
||||
`,
|
||||
})
|
||||
export class Training {
|
||||
@@ -237,25 +181,8 @@ export class Training {
|
||||
return { fields, model, variants, form: new UntypedFormGroup({}) };
|
||||
},
|
||||
});
|
||||
protected readonly inputs = resource({
|
||||
params: () => ({ domain: this.domain(), name: this.name() }),
|
||||
loader: async ({ params }) => {
|
||||
try {
|
||||
return await this.api.invoke(trainingInputs, params);
|
||||
} catch (error) {
|
||||
if (error instanceof HttpErrorResponse && error.status === 404) return undefined;
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
readonly busy = model(false);
|
||||
protected readonly selectedFiles = linkedSignal({
|
||||
source: () => (this.inputs.hasValue() ? this.inputs.value() : undefined),
|
||||
computation: (): FileList | null => null,
|
||||
});
|
||||
protected readonly uploading = signal(false);
|
||||
protected readonly message = signal('');
|
||||
protected readonly uploadMessage = signal('');
|
||||
protected readonly autoPromote = linkedSignal({ source: this.domain, computation: () => false });
|
||||
protected readonly errorText = errorText;
|
||||
|
||||
@@ -289,37 +216,4 @@ export class Training {
|
||||
if (domain === this.domain()) this.busy.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected accept(allowed: string[]): string {
|
||||
return allowed
|
||||
.map((pattern) =>
|
||||
pattern.startsWith('*.') ? pattern.slice(1) : '.' + pattern.split('.').pop(),
|
||||
)
|
||||
.join(',');
|
||||
}
|
||||
|
||||
protected async upload(set: string, input: HTMLInputElement): Promise<void> {
|
||||
const files = Array.from(input.files ?? []);
|
||||
const allowed = this.inputs.hasValue() ? (this.inputs.value()?.['allowed'] ?? []) : [];
|
||||
if (!files.length || files.some((file) => !allowedFile(file, allowed))) {
|
||||
this.uploadMessage.set('Archivos permitidos: ' + allowed.join(', '));
|
||||
return;
|
||||
}
|
||||
this.uploading.set(true);
|
||||
this.uploadMessage.set('');
|
||||
try {
|
||||
await this.api.invoke(uploadTrainingInputs, {
|
||||
domain: this.domain(),
|
||||
name: this.name(),
|
||||
set: set.trim(),
|
||||
body: { files },
|
||||
});
|
||||
input.value = '';
|
||||
this.selectedFiles.set(null);
|
||||
} catch (error) {
|
||||
this.uploadMessage.set(errorText(error));
|
||||
} finally {
|
||||
this.uploading.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import { Loading } from '../loading';
|
||||
<section class="page">
|
||||
<h1>{{ title() }}</h1>
|
||||
<p class="subtitle">Explora los indicadores de {{ title().toLowerCase() }}.</p>
|
||||
<app-report-button />
|
||||
<app-report-button class="button-row" />
|
||||
@if (measures.isLoading()) {
|
||||
<app-loading what="los indicadores" />
|
||||
} @else if (measures.error()) {
|
||||
|
||||
Reference in New Issue
Block a user