integration layer; merge work on indicators from forks with existing ingestion pipeline
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<div class="models">
|
||||
<div class="models__toolbar">
|
||||
<mat-button-toggle-group hideSingleSelectionIndicator [value]="domain()" (change)="setDomain($event.value)" aria-label="Dominio">
|
||||
@for (option of domains; track option.id) {
|
||||
<mat-button-toggle [value]="option.id">{{ option.label }}</mat-button-toggle>
|
||||
}
|
||||
</mat-button-toggle-group>
|
||||
<span class="models__spacer"></span>
|
||||
<button mat-icon-button type="button" (click)="reload()" aria-label="Recargar" matTooltip="Recargar">
|
||||
<mat-icon aria-hidden="true">refresh</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (loading()) {
|
||||
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
|
||||
}
|
||||
@if (loadError(); as error) {
|
||||
<p class="models__alert" role="alert"><mat-icon aria-hidden="true">error</mat-icon>{{ error }}</p>
|
||||
}
|
||||
|
||||
<table mat-table [dataSource]="versions()" class="models__table">
|
||||
<ng-container matColumnDef="version">
|
||||
<th mat-header-cell *matHeaderCellDef>Versión</th>
|
||||
<td mat-cell *matCellDef="let v">
|
||||
<div class="models__tag">{{ v.name }}:{{ v.version }}</div>
|
||||
@if (metrics(v).length) {
|
||||
<mat-chip-set>
|
||||
@for (metric of metrics(v); track metric.key) {
|
||||
<mat-chip>{{ metric.key }}: {{ metric.value }}</mat-chip>
|
||||
}
|
||||
</mat-chip-set>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="scenario">
|
||||
<th mat-header-cell *matHeaderCellDef>Dominio · escenario</th>
|
||||
<td mat-cell *matCellDef="let v">{{ v.tags.domain }} · {{ v.tags.scenario }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="environment">
|
||||
<th mat-header-cell *matHeaderCellDef>Entorno</th>
|
||||
<td mat-cell *matCellDef="let v">
|
||||
<span class="models__env" [class.models__env--prod]="v.tags.environment === 'PROD'">{{ v.tags.environment }}</span>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="cohort_version_id">
|
||||
<th mat-header-cell *matHeaderCellDef>Cohorte</th>
|
||||
<td mat-cell *matCellDef="let v">{{ v.tags.cohort_version_id ?? '— (sin enlazar)' }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="status">
|
||||
<th mat-header-cell *matHeaderCellDef>Estatus</th>
|
||||
<td mat-cell *matCellDef="let v"><app-model-status [status]="v.status"></app-model-status></td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="created_at">
|
||||
<th mat-header-cell *matHeaderCellDef>Creada</th>
|
||||
<td mat-cell *matCellDef="let v">{{ v.created_at | date: 'short' }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="acciones">
|
||||
<th mat-header-cell *matHeaderCellDef></th>
|
||||
<td mat-cell *matCellDef="let v">
|
||||
<button mat-button type="button" (click)="open(v)">
|
||||
<mat-icon aria-hidden="true">info</mat-icon>Detalle
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
|
||||
@if (!loading() && versions().length === 0) {
|
||||
<p class="models__empty"><mat-icon aria-hidden="true">model_training</mat-icon>Aún no hay versiones entrenadas para este filtro.</p>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,72 @@
|
||||
.models {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.models__toolbar {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.models__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.models__alert {
|
||||
align-items: center;
|
||||
background: var(--mat-sys-error-container);
|
||||
color: var(--mat-sys-on-error-container);
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
margin: 0;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
}
|
||||
|
||||
.models__table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.models__tag {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.models__env {
|
||||
background: var(--mat-sys-surface-variant);
|
||||
border-radius: 999px;
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
font: var(--mat-sys-label-small);
|
||||
padding: 2px 10px;
|
||||
}
|
||||
|
||||
.models__env--prod {
|
||||
background: #d8f0da;
|
||||
color: #1e5c25;
|
||||
}
|
||||
|
||||
.models__production {
|
||||
align-items: center;
|
||||
color: #1e5c25;
|
||||
display: inline-flex;
|
||||
gap: 4px;
|
||||
|
||||
mat-icon {
|
||||
font-size: 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.models__inactive {
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
}
|
||||
|
||||
.models__empty {
|
||||
align-items: center;
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
display: flex;
|
||||
font: var(--mat-sys-body-small);
|
||||
gap: var(--space-2);
|
||||
margin: 0;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { Component, DestroyRef, OnInit, inject, signal } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { DOMAINS } from '../../../connect/state/connect-workspace.store';
|
||||
import { apiErrorMessage } from '../../../connect/api/api.types';
|
||||
import { GovernanceApi } from '../../api/governance.api';
|
||||
import { ModelVersion } from '../../api/governance.types';
|
||||
import { ModelStatusChip } from '../model-status-chip/model-status-chip';
|
||||
import { ModelVersionDialog } from '../model-version-dialog/model-version-dialog';
|
||||
|
||||
/**
|
||||
* Every registered model version with its status (desarrollo, candidata,
|
||||
* en producción, retirada). The detail dialog holds the promotion
|
||||
* checklist, lineage, artifacts and reports.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-model-versions-panel',
|
||||
imports: [
|
||||
DatePipe,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatChipsModule,
|
||||
MatIconModule,
|
||||
MatProgressBarModule,
|
||||
MatSnackBarModule,
|
||||
MatTableModule,
|
||||
MatTooltipModule,
|
||||
ModelStatusChip,
|
||||
],
|
||||
templateUrl: './model-versions-panel.html',
|
||||
styleUrl: './model-versions-panel.scss',
|
||||
})
|
||||
export class ModelVersionsPanel implements OnInit {
|
||||
private readonly api = inject(GovernanceApi);
|
||||
private readonly snackBar = inject(MatSnackBar);
|
||||
private readonly dialog = inject(MatDialog);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
readonly domains = [{ id: null, label: 'Todos' }, ...DOMAINS.map((d) => ({ id: d.id as string | null, label: d.label }))];
|
||||
readonly domain = signal<string | null>(null);
|
||||
readonly versions = signal<ModelVersion[]>([]);
|
||||
readonly loading = signal(false);
|
||||
readonly loadError = signal<string | null>(null);
|
||||
|
||||
readonly displayedColumns = ['version', 'scenario', 'environment', 'cohort_version_id', 'status', 'created_at', 'acciones'];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
setDomain(domain: string | null): void {
|
||||
this.domain.set(domain);
|
||||
this.reload();
|
||||
}
|
||||
|
||||
reload(): void {
|
||||
this.loading.set(true);
|
||||
this.loadError.set(null);
|
||||
this.api
|
||||
.listModelVersions(this.domain() ? { domain: this.domain()! } : {})
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: ({ model_versions }) => {
|
||||
this.loading.set(false);
|
||||
this.versions.set(model_versions);
|
||||
},
|
||||
error: (error) => {
|
||||
this.loading.set(false);
|
||||
this.loadError.set(apiErrorMessage(error, 'No se pudieron cargar las versiones de modelo.'));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
open(version: ModelVersion): void {
|
||||
this.dialog
|
||||
.open<ModelVersionDialog, ModelVersion, boolean>(ModelVersionDialog, { data: version, width: '880px', maxWidth: '96vw', autoFocus: false })
|
||||
.afterClosed()
|
||||
.subscribe((changed) => {
|
||||
if (!changed) return;
|
||||
this.snackBar.open(`${version.name}:${version.version} actualizada.`, 'OK', { duration: 3000 });
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
|
||||
metrics(version: ModelVersion): { key: string; value: unknown }[] {
|
||||
return Object.entries(version.metrics ?? {}).map(([key, value]) => ({ key, value }));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user