diff --git a/e2e/pages.spec.ts b/e2e/pages.spec.ts index d638cfd..e44a3bf 100644 --- a/e2e/pages.spec.ts +++ b/e2e/pages.spec.ts @@ -149,16 +149,11 @@ test('tea gobernanza: every section in sync mode, and the preview saved as PDF', 'Ejecución', 'Modelos', 'Entrenamiento', - 'Subir archivos', 'Bundles', 'Estudios EEG', ]); - await expect(page.locator('app-eeg-preview')).toHaveCount(0); + await expect(page.getByRole('heading', { name: 'Subir archivos', exact: true })).toHaveCount(0); await expect(page.getByText('Archivos de entrenamiento', { exact: true })).toHaveCount(0); - const uploads = page.getByRole('region', { name: 'Subir archivos' }); - await expect(uploads.getByLabel('Conjunto')).toBeVisible(); - await expect(uploads.getByRole('button', { name: 'Archivos', exact: true })).toBeVisible(); - await expect(uploads.getByRole('button', { name: 'Subir archivos' })).toBeDisabled(); await page.getByRole('combobox', { name: 'Modo' }).click(); await page.getByRole('option', { name: 'Sync' }).click(); await expect(page.getByRole('status').filter({ hasText: 'Disponible' })).toBeVisible(); @@ -205,14 +200,28 @@ test('tea gobernanza: every section in sync mode, and the preview saved as PDF', { timeout: 10 * 60_000 }, ); - await page - .locator('app-governance-models') - .getByRole('button', { - name: 'Evaluar un solo estudio', - }) - .click(); - const preview = page.locator('app-eeg-preview'); - await expect(preview.getByRole('heading', { name: 'Vista previa' })).toBeVisible(); + const models = page.getByRole('region', { name: 'Modelos' }); + const toggle = models.getByRole('button', { name: 'Evaluar un solo estudio' }); + const preview = models.locator('.button-row + app-eeg-preview'); + const edf = preview.getByRole('button', { name: 'EDF', exact: true }); + const ados = preview.getByRole('button', { name: 'ADOS-2 (PDF)', exact: true }); + const birth = preview.getByLabel('Fecha de nacimiento'); + await expect(toggle).toHaveAttribute('aria-pressed', 'false'); + await expect(edf).toBeHidden(); + await expect(ados).toBeHidden(); + await expect(birth).toBeHidden(); + await toggle.click(); + await expect(toggle).toHaveAttribute('aria-pressed', 'true'); + await expect(page.getByRole('heading', { name: 'Vista previa', exact: true })).toHaveCount(0); + await expect(edf).toBeVisible(); + await expect(ados).toBeVisible(); + await expect(birth).toBeVisible(); + await toggle.click(); + await expect(toggle).toHaveAttribute('aria-pressed', 'false'); + await expect(edf).toBeHidden(); + await expect(ados).toBeHidden(); + await expect(birth).toBeHidden(); + await toggle.click(); await preview.getByLabel('EDF').setInputFiles(process.env['TEA_EDF']!); await preview.getByLabel('ADOS-2 (PDF)').setInputFiles(process.env['TEA_ADOS2']!); await preview.getByLabel('Fecha de nacimiento').fill(process.env['TEA_BIRTH']!); @@ -306,9 +315,5 @@ test('cacu gobernanza: the shared sections only, none of the TEA ones', async ({ const nav = page.getByRole('navigation', { name: 'Dominios' }); await expect(nav.getByRole('link', { name: 'Cáncer de mama' })).toBeVisible(); await expect(nav.getByRole('link', { name: 'Trastorno del espectro autista' })).toBeVisible(); - expect( - problems.filter( - (p) => !p.endsWith('/models/cacu/all/inputs') && !p.startsWith('console: Failed to load'), - ), - ).toEqual([]); + expect(problems.filter((p) => !p.startsWith('console: Failed to load'))).toEqual([]); }); diff --git a/openapi.json b/openapi.json index ae92b0c..77b49fc 100644 --- a/openapi.json +++ b/openapi.json @@ -255,24 +255,6 @@ "title": "Body_upload", "type": "object" }, - "Body_upload_training_inputs": { - "properties": { - "files": { - "items": { - "format": "binary", - "type": "string" - }, - "minItems": 1, - "title": "Files", - "type": "array" - } - }, - "required": [ - "files" - ], - "title": "Body_upload_training_inputs", - "type": "object" - }, "Browsed": { "properties": { "entries": { @@ -5121,134 +5103,6 @@ ] } }, - "/models/{domain}/{name}/inputs": { - "get": { - "operationId": "training_inputs", - "parameters": [ - { - "in": "path", - "name": "domain", - "required": true, - "schema": { - "$ref": "#/components/schemas/Domain" - } - }, - { - "in": "path", - "name": "name", - "required": true, - "schema": { - "title": "Name", - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": { - "items": { - "type": "string" - }, - "type": "array" - }, - "title": "Response Training Inputs", - "type": "object" - } - } - }, - "description": "Successful Response" - }, - "422": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - "description": "Validation Error" - } - }, - "summary": "Training Inputs", - "tags": [ - "models" - ] - } - }, - "/models/{domain}/{name}/inputs/{set}/files": { - "post": { - "operationId": "upload_training_inputs", - "parameters": [ - { - "in": "path", - "name": "domain", - "required": true, - "schema": { - "$ref": "#/components/schemas/Domain" - } - }, - { - "in": "path", - "name": "name", - "required": true, - "schema": { - "title": "Name", - "type": "string" - } - }, - { - "in": "path", - "name": "set", - "required": true, - "schema": { - "title": "Set", - "type": "string" - } - } - ], - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/Body_upload_training_inputs" - } - } - }, - "required": true - }, - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": true, - "title": "Response Upload Training Inputs", - "type": "object" - } - } - }, - "description": "Successful Response" - }, - "422": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - "description": "Validation Error" - } - }, - "summary": "Upload Training Inputs", - "tags": [ - "models" - ] - } - }, "/models/{domain}/{name}/training-config": { "get": { "operationId": "training_config", diff --git a/src/app/api/fn/models/training-inputs.ts b/src/app/api/fn/models/training-inputs.ts deleted file mode 100644 index b27ecf2..0000000 --- a/src/app/api/fn/models/training-inputs.ts +++ /dev/null @@ -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; -}>> { - 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 => r instanceof HttpResponse), - map((r: HttpResponse) => { - return r as StrictHttpResponse<{ - [key: string]: Array; - }>; - }) - ); -} - -trainingInputs.PATH = '/models/{domain}/{name}/inputs'; diff --git a/src/app/api/fn/models/upload-training-inputs.ts b/src/app/api/fn/models/upload-training-inputs.ts deleted file mode 100644 index c483dcc..0000000 --- a/src/app/api/fn/models/upload-training-inputs.ts +++ /dev/null @@ -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> { - 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 => r instanceof HttpResponse), - map((r: HttpResponse) => { - return r as StrictHttpResponse<{ - [key: string]: any; - }>; - }) - ); -} - -uploadTrainingInputs.PATH = '/models/{domain}/{name}/inputs/{set}/files'; diff --git a/src/app/api/functions.ts b/src/app/api/functions.ts index d416e2c..d3d4ba4 100644 --- a/src/app/api/functions.ts +++ b/src/app/api/functions.ts @@ -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'; diff --git a/src/app/api/models.ts b/src/app/api/models.ts index a68d2c9..eb26067 100644 --- a/src/app/api/models.ts +++ b/src/app/api/models.ts @@ -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'; diff --git a/src/app/api/models/body-upload-training-inputs.ts b/src/app/api/models/body-upload-training-inputs.ts deleted file mode 100644 index 56fd3a3..0000000 --- a/src/app/api/models/body-upload-training-inputs.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable */ -/* Code generated by ng-openapi-gen DO NOT EDIT. */ - -export interface BodyUploadTrainingInputs { - files: Array; -} diff --git a/src/app/gobernanza/bundles.ts b/src/app/gobernanza/bundles.ts index 9e3726f..97415da 100644 --- a/src/app/gobernanza/bundles.ts +++ b/src/app/gobernanza/bundles.ts @@ -44,7 +44,7 @@ export async function exportErrorText(error: unknown): Promise { template: `

Bundles

-
+ Versiones @@ -60,7 +60,7 @@ export async function exportErrorText(error: unknown): Promise { SHA-256 {{ exportedHash() }}

} - + @if (h.dashboard_url && h.dashboard_ok !== false) { - Panel de Dask + } } @else if (health.error() || options.error()) {

No se pudo consultar la ejecución.

diff --git a/src/app/gobernanza/gobernanza.html b/src/app/gobernanza/gobernanza.html index 84159eb..7a39d85 100644 --- a/src/app/gobernanza/gobernanza.html +++ b/src/app/gobernanza/gobernanza.html @@ -1,7 +1,7 @@

Gobernanza de modelos

Administra la ejecución, las versiones y el entrenamiento por dominio.

-
diff --git a/src/app/gobernanza/gobernanza.scss b/src/app/gobernanza/gobernanza.scss index b7a501a..e938531 100644 --- a/src/app/gobernanza/gobernanza.scss +++ b/src/app/gobernanza/gobernanza.scss @@ -2,9 +2,6 @@ display: block; } .domains { - display: flex; - flex-wrap: wrap; - gap: var(--space-3); margin-bottom: var(--space-4); } .domains a.active { diff --git a/src/app/gobernanza/gobernanza.ts b/src/app/gobernanza/gobernanza.ts index e6987a6..38dbb73 100644 --- a/src/app/gobernanza/gobernanza.ts +++ b/src/app/gobernanza/gobernanza.ts @@ -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(); - protected readonly showPreview = linkedSignal({ source: this.domain, computation: () => false }); protected readonly domainKey = computed(() => this.domain() as Domain); protected readonly labels = DOMAINS as Record; protected readonly domains = resource({ loader: () => this.api.invoke(domains) }); diff --git a/src/app/gobernanza/models.html b/src/app/gobernanza/models.html index 4060051..8105d23 100644 --- a/src/app/gobernanza/models.html +++ b/src/app/gobernanza/models.html @@ -1,6 +1,6 @@

Modelos

-
+
- } @@ -32,6 +37,9 @@ Promover candidatas
+ @if (domain() === 'tea') { + + } @if (run(); as current) {

{{ current.label }}

@@ -52,7 +60,11 @@ @for (m of models.hasValue() ? models.value() : []; track m.name) {

{{ m.title }}

- +
+ +
@@ -75,24 +87,26 @@ {{ v.metrics['n_train'] | number }} / {{ v.metrics['n_test'] | number }} } @@ -190,22 +206,24 @@ } - - +
+ + +
} @else if (checks.error(); as error) {

{{ errorText(error) }}

} @else { @@ -215,7 +233,7 @@

{{ message() }}

} } - + @@ -259,7 +277,7 @@

Cargando…

} } -
+
@@ -269,14 +287,16 @@
  • {{ candidate.name }} v{{ candidate.version }}
  • } - -
    +
    + +
    +
    diff --git a/src/app/gobernanza/models.scss b/src/app/gobernanza/models.scss index 8bb0aad..2715814 100644 --- a/src/app/gobernanza/models.scss +++ b/src/app/gobernanza/models.scss @@ -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); -} diff --git a/src/app/gobernanza/models.spec.ts b/src/app/gobernanza/models.spec.ts index a7e01ab..acbd102 100644 --- a/src/app/gobernanza/models.spec.ts +++ b/src/app/gobernanza/models.spec.ts @@ -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('button[aria-pressed]')!; + const form = host.querySelector('.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); + }); +}); diff --git a/src/app/gobernanza/models.ts b/src/app/gobernanza/models.ts index 634e328..6d3cc8c 100644 --- a/src/app/gobernanza/models.ts +++ b/src/app/gobernanza/models.ts @@ -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 = { 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(); readonly execution = input(); readonly trainingRequested = output(); - readonly previewRequested = output(); + protected readonly showPreview = linkedSignal({ source: this.domain, computation: () => false }); protected readonly reportNames = REPORTS; protected readonly errorText = errorText; readonly refreshed = signal(0); diff --git a/src/app/gobernanza/run-monitor.ts b/src/app/gobernanza/run-monitor.ts index 404c79c..be04e47 100644 --- a/src/app/gobernanza/run-monitor.ts +++ b/src/app/gobernanza/run-monitor.ts @@ -77,14 +77,16 @@ export function eta(progress: Progress): number | null {

    {{ r.error }}

    } @if (!terminal.has(r.state)) { - +
    + +
    } } @else {

    Consultando ejecución…

    diff --git a/src/app/gobernanza/tea/preview.ts b/src/app/gobernanza/tea/preview.ts index afe7a60..3a44fc7 100644 --- a/src/app/gobernanza/tea/preview.ts +++ b/src/app/gobernanza/tea/preview.ts @@ -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: ` -
    -

    Vista previa

    -
    - - - @for (file of edfFiles(); track $index) { - {{ file.name }} - } - - - @for (file of adosFiles(); track $index) { - {{ file.name }} - } - - Fecha de nacimiento - - - - - @if (error()) { -

    {{ error() }}

    +
    + + + @for (file of edfFiles(); track $index) { + {{ file.name }} } - @if (runId(); as id) { - + + + @for (file of adosFiles(); track $index) { + {{ file.name }} } - + + Fecha de nacimiento + + + + + @if (error()) { +

    {{ error() }}

    + } + @if (runId(); as id) { + + } + + @if (result(); as r) { +

    Resultado de la vista previa

    +

    + {{ r.eeg.level }} · + {{ r.eeg.valid === true ? 'Válido' : r.eeg.valid === false ? 'No válido' : '—' }} +

    + @if (r.eeg.error) { +

    {{ r.eeg.error }}

    + } +

    Comprobaciones

    +
    - @for (report of v.reports; track report) { - - } - @if (v.reports.includes('interpretability')) { - - } +
    + @for (report of v.reports; track report) { + + } + @if (v.reports.includes('interpretability')) { + + } +
    @if (!v.reports.includes('clinical_validation')) { @@ -111,24 +125,26 @@ } - - +
    + + +
    + + + + + + + + + + + @for (check of r.eeg.checks; track $index) { + + + + + + + + } + +
    ComprobaciónElectrodoResultadoRangoAnormal
    {{ check['code'] }}{{ check['electrode'] ?? '—' }}{{ check['value'] ?? check['text'] ?? '—' }} {{ check['unit'] }}{{ check['low'] ?? '—' }} / {{ check['high'] ?? '—' }} + {{ check['abnormal'] === true ? 'Sí' : check['abnormal'] === false ? 'No' : '—' }} +
    +

    Métricas

    + + + + + + + + + + + + @for (metric of r.eeg.metrics; track metric.code) { + + + + + + + + @for (site of metric.electrodes | keyvalue; track site.key) { + + + + + + + + } + @for (site of metric.zones | keyvalue; track site.key) { + + + + + + + + } + } + +
    MétricaValorzp5 / mediana / p95Fuera de rango
    {{ metric.code }}{{ metric.value ?? '—' }}{{ metric.score?.z ?? '—' }} + {{ metric.score?.p5 ?? '—' }} / {{ metric.score?.median ?? '—' }} / + {{ metric.score?.p95 ?? '—' }} + {{ metric.score?.outside ?? '—' }}
    {{ site.key }}{{ site.value.value ?? '—' }}{{ site.value.score?.z ?? '—' }} + {{ site.value.score?.p5 ?? '—' }} / {{ site.value.score?.median ?? '—' }} / + {{ site.value.score?.p95 ?? '—' }} + {{ site.value.score?.outside ?? '—' }}
    {{ site.key }}{{ site.value.value ?? '—' }}{{ site.value.score?.z ?? '—' }} + {{ site.value.score?.p5 ?? '—' }} / {{ site.value.score?.median ?? '—' }} / + {{ site.value.score?.p95 ?? '—' }} + {{ site.value.score?.outside ?? '—' }}
    + @if (r.ados2; as ados2) { +

    ADOS-2

    +

    {{ ados2.classification }} · CSS {{ ados2.css ?? '—' }}

    +
    + @for (item of ados2.items | keyvalue: unsorted; track item.key) { +
    {{ ados2.titles[item.key] ?? item.key }}
    +
    {{ item.value ?? '—' }}
    + } +
    + } + @if (r.warnings.length) { +

    Advertencias

    +
      + @for (warning of r.warnings; track $index) { +
    • {{ warning }}
    • + } +
    + } + } + @if (pdfError()) { +

    {{ pdfError() }}

    + } +
    @if (result(); as r) { -

    Resultado de la vista previa

    -

    - {{ r.eeg.level }} · - {{ r.eeg.valid === true ? 'Válido' : r.eeg.valid === false ? 'No válido' : '—' }} -

    - @if (r.eeg.error) { -

    {{ r.eeg.error }}

    - } -

    Comprobaciones

    - - - - - - - - - - - - @for (check of r.eeg.checks; track $index) { - - - - - - - - } - -
    ComprobaciónElectrodoResultadoRangoAnormal
    {{ check['code'] }}{{ check['electrode'] ?? '—' }}{{ check['value'] ?? check['text'] ?? '—' }} {{ check['unit'] }}{{ check['low'] ?? '—' }} / {{ check['high'] ?? '—' }} - {{ - check['abnormal'] === true ? 'Sí' : check['abnormal'] === false ? 'No' : '—' - }} -
    -

    Métricas

    - - - - - - - - - - - - @for (metric of r.eeg.metrics; track metric.code) { - - - - - - - - @for (site of metric.electrodes | keyvalue; track site.key) { - - - - - - - - } - @for (site of metric.zones | keyvalue; track site.key) { - - - - - - - - } - } - -
    MétricaValorzp5 / mediana / p95Fuera de rango
    {{ metric.code }}{{ metric.value ?? '—' }}{{ metric.score?.z ?? '—' }} - {{ metric.score?.p5 ?? '—' }} / {{ metric.score?.median ?? '—' }} / - {{ metric.score?.p95 ?? '—' }} - {{ metric.score?.outside ?? '—' }}
    {{ site.key }}{{ site.value.value ?? '—' }}{{ site.value.score?.z ?? '—' }} - {{ site.value.score?.p5 ?? '—' }} / {{ site.value.score?.median ?? '—' }} / - {{ site.value.score?.p95 ?? '—' }} - {{ site.value.score?.outside ?? '—' }}
    {{ site.key }}{{ site.value.value ?? '—' }}{{ site.value.score?.z ?? '—' }} - {{ site.value.score?.p5 ?? '—' }} / {{ site.value.score?.median ?? '—' }} / - {{ site.value.score?.p95 ?? '—' }} - {{ site.value.score?.outside ?? '—' }}
    - @if (r.ados2; as ados2) { -

    ADOS-2

    -

    {{ ados2.classification }} · CSS {{ ados2.css ?? '—' }}

    -
    - @for (item of ados2.items | keyvalue: unsorted; track item.key) { -
    {{ ados2.titles[item.key] ?? item.key }}
    -
    {{ item.value ?? '—' }}
    - } -
    - } - @if (r.warnings.length) { -

    Advertencias

    -
      - @for (warning of r.warnings; track $index) { -
    • {{ warning }}
    • - } -
    - } + } - @if (pdfError()) { -

    {{ pdfError() }}

    - } - - @if (result(); as r) { - - } - -
    - -
    + + + `, }) export class EegPreview { + readonly active = input.required(); private readonly api = inject(Api); protected readonly edfFiles = signal(null); protected readonly adosFiles = signal(null); diff --git a/src/app/gobernanza/tea/studies.html b/src/app/gobernanza/tea/studies.html index be42500..9143306 100644 --- a/src/app/gobernanza/tea/studies.html +++ b/src/app/gobernanza/tea/studies.html @@ -1,6 +1,6 @@

    Estudios EEG

    -
    + Alcance diff --git a/src/app/gobernanza/training.ts b/src/app/gobernanza/training.ts index f4dd8c8..5e192d9 100644 --- a/src/app/gobernanza/training.ts +++ b/src/app/gobernanza/training.ts @@ -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(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: `

    Entrenamiento

    @@ -142,18 +121,20 @@ function allowedFile(file: File, allowed: string[]): boolean { @let form = config.value(); - @if (domain() === 'tea') { - Promover al terminar + @if (domain() === 'tea') { + Promover al terminar + } + + Entrenar + +
    } @else if (config.error(); as error) {

    {{ errorText(error) }}

    @@ -162,43 +143,6 @@ function allowedFile(file: File, allowed: string[]): boolean {

    {{ message() }}

    }
    - @if (inputs.hasValue() && inputs.value(); as metadata) { -
    -

    Subir archivos

    -
    - - Conjunto - - - - - @for (file of selectedFiles(); track $index) { - {{ file.name }} - } - -
    - @if (uploadMessage()) { -

    {{ uploadMessage() }}

    - } -
    - } @else if (inputs.error(); as error) { -

    {{ errorText(error) }}

    - } `, }) 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 { - 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); - } - } } diff --git a/src/app/indicadores/indicadores.ts b/src/app/indicadores/indicadores.ts index e13e1fe..646b487 100644 --- a/src/app/indicadores/indicadores.ts +++ b/src/app/indicadores/indicadores.ts @@ -29,7 +29,7 @@ import { Loading } from '../loading';

    {{ title() }}

    Explora los indicadores de {{ title().toLowerCase() }}.

    - + @if (measures.isLoading()) { } @else if (measures.error()) { diff --git a/src/styles.scss b/src/styles.scss index c4a9339..f7c26a6 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -123,6 +123,17 @@ html { @include meta.load-css('print'); } +.button-row:not([hidden]) { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-3); +} + +.button-row:not(td > *):not([hidden]) { + margin-block: var(--space-3); +} + .filters { display: flex; flex-wrap: wrap;