119 lines
5.8 KiB
HTML
119 lines
5.8 KiB
HTML
<h2 mat-dialog-title>Cargar a la base de datos · {{ store.domain().toUpperCase() }}</h2>
|
|
<mat-dialog-content>
|
|
@if (validating()) {
|
|
<p class="lead">Validando todas las filas de {{ flows().length }} flujo(s)…</p>
|
|
<mat-progress-bar mode="indeterminate" aria-label="Validando"></mat-progress-bar>
|
|
} @else {
|
|
@if (!batch()) {
|
|
<p class="lead">
|
|
Se escribirán <strong>{{ totals().valid | number }}</strong> filas válidas de {{ totals().rows | number }} en
|
|
{{ flows().length }} flujo(s), en una sola transacción: si algo falla en la base, no se escribe nada.
|
|
@if (totals().errors > 0) {
|
|
<strong class="warn">{{ totals().errors | number }} fila(s) con errores se omitirán.</strong>
|
|
}
|
|
</p>
|
|
} @else if (outcome(); as o) {
|
|
<p class="lead lead--done">
|
|
<mat-icon aria-hidden="true">cloud_done</mat-icon>
|
|
Carga completa: {{ o.created | number }} insertadas, {{ o.updated | number }} actualizadas, {{ o.rejected | number }} omitidas.
|
|
@if (o.merged) {
|
|
{{ o.merged | number }} combinadas con registros de otras fuentes@if (o.warnings) {, {{ o.warnings | number }} valor(es) en desacuerdo}.
|
|
}
|
|
</p>
|
|
@if (o.created + o.updated > 0) {
|
|
<p class="lead">Los indicadores se recalcularán automáticamente. El avance y el resumen de esta carga pueden consultarse en la Bitácora de cargas.</p>
|
|
}
|
|
}
|
|
|
|
<table mat-table [dataSource]="flows()" class="flows">
|
|
<ng-container matColumnDef="flow">
|
|
<th mat-header-cell *matHeaderCellDef>Flujo</th>
|
|
<td mat-cell *matCellDef="let flow">
|
|
<span class="flows__name">{{ flow.table.name }}</span>
|
|
<span class="flows__target">→ {{ flow.target.table }}</span>
|
|
</td>
|
|
</ng-container>
|
|
<ng-container matColumnDef="status">
|
|
<th mat-header-cell *matHeaderCellDef>Estado</th>
|
|
<td mat-cell *matCellDef="let flow"><app-flow-status [status]="flow.status()"></app-flow-status></td>
|
|
</ng-container>
|
|
<ng-container matColumnDef="rows">
|
|
<th mat-header-cell *matHeaderCellDef>Filas</th>
|
|
<td mat-cell *matCellDef="let flow">{{ flow.validation()?.total_rows | number }}</td>
|
|
</ng-container>
|
|
<ng-container matColumnDef="valid">
|
|
<th mat-header-cell *matHeaderCellDef>Válidas</th>
|
|
<td mat-cell *matCellDef="let flow">{{ flow.validation()?.valid_count | number }}</td>
|
|
</ng-container>
|
|
<ng-container matColumnDef="errors">
|
|
<th mat-header-cell *matHeaderCellDef>Con error</th>
|
|
<td mat-cell *matCellDef="let flow" [class.warn]="flow.validation()?.error_count">{{ flow.validation()?.error_count | number }}</td>
|
|
</ng-container>
|
|
<ng-container matColumnDef="outcome">
|
|
<th mat-header-cell *matHeaderCellDef>Resultado</th>
|
|
<td mat-cell *matCellDef="let flow">
|
|
@if (flow.result(); as result) {
|
|
+{{ result.created }} · ↻{{ result.updated }} · ✕{{ result.rejected }}@if (result.merged) { · ⧉{{ result.merged }} }
|
|
} @else {
|
|
—
|
|
}
|
|
</td>
|
|
</ng-container>
|
|
<tr mat-header-row *matHeaderRowDef="columns"></tr>
|
|
<tr mat-row *matRowDef="let row; columns: columns"></tr>
|
|
</table>
|
|
|
|
@if (skipped().length > 0) {
|
|
<p class="note">
|
|
<mat-icon aria-hidden="true">info</mat-icon>
|
|
{{ skipped().length }} flujo(s) no se cargarán porque no están listos (faltan obligatorios o la fuente falló).
|
|
</p>
|
|
}
|
|
|
|
@if (!batch()) {
|
|
<section class="policy" aria-labelledby="policy-title">
|
|
<h3 id="policy-title">Si un registro ya existe en la base</h3>
|
|
<mat-radio-group [value]="store.upsertAvailable() ? store.onConflict() : 'reject'" (change)="setStrategy($event.value)">
|
|
<mat-radio-button value="reject">Omitirlo (se reporta como conflicto)</mat-radio-button>
|
|
<mat-radio-button value="upsert" [disabled]="!store.upsertAvailable()">
|
|
Actualizarlo con los campos mapeados (los demás campos no se tocan)
|
|
</mat-radio-button>
|
|
</mat-radio-group>
|
|
@if (!store.upsertAvailable()) {
|
|
<p class="note">Actualizar solo es posible cuando todas las tablas destino tienen clave natural (p. ej. Paciente).</p>
|
|
}
|
|
</section>
|
|
@if (mergeAvailable()) {
|
|
<section class="policy" aria-labelledby="merge-title">
|
|
<h3 id="merge-title">Datos de un mismo paciente en varias fuentes</h3>
|
|
<mat-checkbox [checked]="store.mergeDuplicates()" (change)="toggleMerge($event.checked)">
|
|
Combinar las filas con la misma clave en un solo registro antes de validar
|
|
</mat-checkbox>
|
|
<p class="note">
|
|
Cada fuente completa los campos que a las demás les faltan; si dos fuentes no coinciden en un valor se conserva
|
|
el del primer flujo y se reporta. La validación previa por flujo no considera esta combinación.
|
|
</p>
|
|
</section>
|
|
}
|
|
}
|
|
|
|
@if (store.committing()) {
|
|
<mat-progress-bar mode="indeterminate" aria-label="Cargando"></mat-progress-bar>
|
|
}
|
|
@if (store.commitError(); as error) {
|
|
<p class="error" role="alert"><mat-icon aria-hidden="true">error</mat-icon>{{ error }}</p>
|
|
}
|
|
}
|
|
</mat-dialog-content>
|
|
<mat-dialog-actions align="end">
|
|
@if (batch()) {
|
|
<button mat-button mat-dialog-close type="button">Cerrar</button>
|
|
<button mat-flat-button type="button" (click)="explore()"><mat-icon aria-hidden="true">travel_explore</mat-icon>Explorar la base</button>
|
|
} @else {
|
|
<button mat-button mat-dialog-close type="button">Cancelar</button>
|
|
<button mat-flat-button type="button" [disabled]="validating() || store.committing() || !canLoad()" (click)="load()">
|
|
<mat-icon aria-hidden="true">cloud_upload</mat-icon>Cargar {{ totals().valid | number }} filas
|
|
</button>
|
|
}
|
|
</mat-dialog-actions>
|