integration layer; merge work on indicators from forks with existing ingestion pipeline
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
@let f = flow();
|
||||
<section class="editor" [attr.aria-label]="'Flujo ' + f.label">
|
||||
<header class="editor__header">
|
||||
<div class="editor__route">
|
||||
<mat-icon aria-hidden="true">{{ f.table.icon }}</mat-icon>
|
||||
<span class="editor__source" [title]="f.label">{{ f.label }}</span>
|
||||
<mat-icon class="editor__arrow" aria-hidden="true">arrow_right_alt</mat-icon>
|
||||
<mat-icon class="editor__target-icon" aria-hidden="true">table_chart</mat-icon>
|
||||
<span class="editor__target">{{ f.target.domain.toUpperCase() }} · {{ f.target.table }}</span>
|
||||
<app-flow-status [status]="f.status()"></app-flow-status>
|
||||
</div>
|
||||
<div class="editor__actions">
|
||||
@if (f.totalRows() !== null) {
|
||||
<span class="editor__rows">{{ f.totalRows() | number }} filas en la fuente</span>
|
||||
}
|
||||
@if (documentTable()) {
|
||||
<button mat-stroked-button type="button" [disabled]="f.loading()" (click)="reviewExtraction()">
|
||||
<mat-icon aria-hidden="true">rule</mat-icon>Revisar extracción
|
||||
</button>
|
||||
}
|
||||
<button mat-stroked-button type="button" (click)="store.reloadFlow(f)" matTooltip="Volver a leer la fuente">
|
||||
<mat-icon aria-hidden="true">refresh</mat-icon>Actualizar
|
||||
</button>
|
||||
<button mat-flat-button type="button" [disabled]="!f.canSubmit || f.validating()" (click)="validate()">
|
||||
<mat-icon aria-hidden="true">fact_check</mat-icon>Validar
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@if (f.loading()) {
|
||||
<mat-progress-bar mode="indeterminate" aria-label="Leyendo la fuente"></mat-progress-bar>
|
||||
}
|
||||
@if (f.error(); as error) {
|
||||
<p class="editor__error" role="alert">
|
||||
<mat-icon aria-hidden="true">error</mat-icon>{{ error }}
|
||||
<button mat-button type="button" (click)="store.reloadFlow(f)">Reintentar</button>
|
||||
</p>
|
||||
}
|
||||
|
||||
@if (f.preview()) {
|
||||
<mat-tab-group
|
||||
[selectedIndex]="tab()"
|
||||
(selectedIndexChange)="tab.set($event)"
|
||||
animationDuration="0ms"
|
||||
mat-stretch-tabs="false"
|
||||
mat-align-tabs="start"
|
||||
class="editor__tabs"
|
||||
>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>
|
||||
<mat-icon aria-hidden="true">account_tree</mat-icon>Mapeo
|
||||
@if (f.missingRequired().length) {
|
||||
<span class="tab-count tab-count--warn">{{ f.missingRequired().length }}</span>
|
||||
}
|
||||
</ng-template>
|
||||
<div class="editor__panel"><app-column-mapper [flow]="f"></app-column-mapper></div>
|
||||
</mat-tab>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label><mat-icon aria-hidden="true">table_view</mat-icon>Datos</ng-template>
|
||||
<div class="editor__panel"><app-data-grid [flow]="f"></app-data-grid></div>
|
||||
</mat-tab>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>
|
||||
<mat-icon aria-hidden="true">fact_check</mat-icon>Validación
|
||||
@if (f.validation(); as validation) {
|
||||
<span class="tab-count" [class.tab-count--warn]="validation.error_count > 0">{{ validation.error_count | number }}</span>
|
||||
}
|
||||
</ng-template>
|
||||
<div class="editor__panel"><app-validation-report [flow]="f" (validate)="validate()"></app-validation-report></div>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
}
|
||||
</section>
|
||||
@@ -0,0 +1,101 @@
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.editor {
|
||||
background: var(--mat-sys-surface);
|
||||
border: 1px solid var(--mat-sys-outline-variant);
|
||||
border-radius: var(--mat-sys-corner-large);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.editor__header {
|
||||
align-items: center;
|
||||
border-bottom: 1px solid var(--mat-sys-outline-variant);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3);
|
||||
justify-content: space-between;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
}
|
||||
|
||||
.editor__route {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
|
||||
> mat-icon {
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
flex: none;
|
||||
}
|
||||
}
|
||||
|
||||
.editor__source,
|
||||
.editor__target {
|
||||
font: var(--mat-sys-title-small);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.editor__source {
|
||||
max-width: 36ch;
|
||||
}
|
||||
|
||||
.editor__arrow {
|
||||
color: var(--mat-sys-outline) !important;
|
||||
}
|
||||
|
||||
.editor__target-icon {
|
||||
color: var(--mat-sys-primary) !important;
|
||||
}
|
||||
|
||||
.editor__actions {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.editor__rows {
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
font: var(--mat-sys-body-small);
|
||||
margin-right: var(--space-2);
|
||||
}
|
||||
|
||||
.editor__error {
|
||||
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-4);
|
||||
}
|
||||
|
||||
.editor__tabs ::ng-deep .mat-mdc-tab .mdc-tab__text-label {
|
||||
gap: 6px;
|
||||
|
||||
mat-icon {
|
||||
font-size: 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.editor__panel {
|
||||
padding: var(--space-4);
|
||||
}
|
||||
|
||||
.tab-count {
|
||||
background: var(--mat-sys-surface-container-highest);
|
||||
border-radius: 999px;
|
||||
font: var(--mat-sys-label-small);
|
||||
padding: 1px 7px;
|
||||
}
|
||||
|
||||
.tab-count--warn {
|
||||
background: #fff1d6;
|
||||
color: #7a4b00;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { Component, computed, inject, input, signal } from '@angular/core';
|
||||
import { MatBadgeModule } from '@angular/material/badge';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { DocumentTable } from '../../domain/document-source';
|
||||
import { ImportFlow } from '../../domain/import-flow';
|
||||
import { ConnectWorkspaceStore } from '../../state/connect-workspace.store';
|
||||
import { ColumnMapper } from '../column-mapper/column-mapper';
|
||||
import { DataGrid } from '../data-grid/data-grid';
|
||||
import { DocumentReviewData, DocumentReviewDialog } from '../document-review-dialog/document-review-dialog';
|
||||
import { FlowStatusChip } from '../shared/flow-status';
|
||||
import { ValidationReport } from '../validation-report/validation-report';
|
||||
|
||||
const VALIDATION_TAB = 2;
|
||||
|
||||
/** Everything about the selected flow: its mapping, its data, its validation. */
|
||||
@Component({
|
||||
selector: 'app-flow-editor',
|
||||
imports: [
|
||||
ColumnMapper,
|
||||
DataGrid,
|
||||
DecimalPipe,
|
||||
FlowStatusChip,
|
||||
MatBadgeModule,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatProgressBarModule,
|
||||
MatTabsModule,
|
||||
MatTooltipModule,
|
||||
ValidationReport,
|
||||
],
|
||||
templateUrl: './flow-editor.html',
|
||||
styleUrl: './flow-editor.scss',
|
||||
})
|
||||
export class FlowEditor {
|
||||
readonly flow = input.required<ImportFlow>();
|
||||
readonly store = inject(ConnectWorkspaceStore);
|
||||
private readonly dialog = inject(MatDialog);
|
||||
readonly tab = signal(0);
|
||||
|
||||
/** Document sources get a review of what was extracted, record by record. */
|
||||
readonly documentTable = computed(() => {
|
||||
const table = this.flow().table;
|
||||
return table instanceof DocumentTable ? table : null;
|
||||
});
|
||||
|
||||
reviewExtraction(): void {
|
||||
const table = this.documentTable();
|
||||
if (!table) return;
|
||||
const segmentations = this.store.connectors().find((c) => c.kind === 'document')?.segmentations ?? [];
|
||||
this.dialog
|
||||
.open<DocumentReviewDialog, DocumentReviewData, boolean>(DocumentReviewDialog, {
|
||||
data: { table, target: this.flow().target, segmentations },
|
||||
width: '1280px',
|
||||
maxWidth: '98vw',
|
||||
autoFocus: false,
|
||||
disableClose: true,
|
||||
})
|
||||
.afterClosed()
|
||||
.subscribe((applied) => applied && this.store.flowsOf(table).forEach((flow) => this.store.reloadFlow(flow)));
|
||||
}
|
||||
|
||||
async validate(): Promise<void> {
|
||||
await this.store.validate(this.flow());
|
||||
this.tab.set(VALIDATION_TAB);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user