155 lines
6.8 KiB
HTML
155 lines
6.8 KiB
HTML
<section class="pane" aria-labelledby="connections-title">
|
|
<header class="pane__header">
|
|
<h2 id="connections-title">Conexiones</h2>
|
|
<button mat-icon-button type="button" matTooltip="Obtener datos" aria-label="Obtener datos" (click)="addConnection.emit()">
|
|
<mat-icon aria-hidden="true">add_circle</mat-icon>
|
|
</button>
|
|
</header>
|
|
|
|
@if (store.connections().length === 0) {
|
|
<div class="pane__empty">
|
|
<app-file-dropzone [accept]="store.acceptedExtensions()" [keepSelection]="false" (filesChange)="onFilesDropped($event)"></app-file-dropzone>
|
|
<button mat-stroked-button type="button" class="pane__db-button" (click)="addConnection.emit()">
|
|
<mat-icon aria-hidden="true">storage</mat-icon>Conectar una base de datos
|
|
</button>
|
|
</div>
|
|
} @else {
|
|
<mat-accordion multi displayMode="flat" class="connections">
|
|
@for (connection of store.connections(); track connection.id) {
|
|
<mat-expansion-panel [expanded]="true" class="connection">
|
|
<mat-expansion-panel-header class="connection__header">
|
|
<mat-icon class="connection__icon" aria-hidden="true">{{ connection.icon }}</mat-icon>
|
|
<span class="connection__text">
|
|
<span class="connection__label" [title]="connection.label">{{ connection.label }}</span>
|
|
<span class="connection__type">{{ connection.typeLabel }} · {{ connection.tables().length }} tabla(s)</span>
|
|
</span>
|
|
@switch (connection.state()) {
|
|
@case ('loading') {
|
|
<mat-spinner diameter="18" aria-label="Abriendo conexión"></mat-spinner>
|
|
}
|
|
@case ('error') {
|
|
<mat-icon class="connection__error-icon" [matTooltip]="connection.error() ?? ''" aria-label="Error">error</mat-icon>
|
|
}
|
|
}
|
|
<button
|
|
mat-icon-button
|
|
type="button"
|
|
class="connection__menu"
|
|
[matMenuTriggerFor]="menu"
|
|
(click)="$event.stopPropagation()"
|
|
[attr.aria-label]="'Acciones de ' + connection.label"
|
|
>
|
|
<mat-icon aria-hidden="true">more_vert</mat-icon>
|
|
</button>
|
|
<mat-menu #menu="matMenu">
|
|
@if (isSql(connection)) {
|
|
<button mat-menu-item type="button" (click)="addQuery.emit(connection)">
|
|
<mat-icon aria-hidden="true">manage_search</mat-icon>Nueva consulta SQL
|
|
</button>
|
|
}
|
|
@if (isPdf(connection)) {
|
|
<button mat-menu-item type="button" (click)="drawRegions.emit(connection)" [disabled]="!connection.detection()">
|
|
<mat-icon aria-hidden="true">crop_free</mat-icon>Dibujar regiones
|
|
</button>
|
|
}
|
|
<button mat-menu-item type="button" (click)="store.reloadConnection(connection)">
|
|
<mat-icon aria-hidden="true">refresh</mat-icon>Volver a leer
|
|
</button>
|
|
<button mat-menu-item type="button" (click)="store.removeConnection(connection)">
|
|
<mat-icon aria-hidden="true">delete</mat-icon>Quitar conexión
|
|
</button>
|
|
</mat-menu>
|
|
</mat-expansion-panel-header>
|
|
|
|
@if (connection.error(); as error) {
|
|
<p class="connection__error" role="alert">{{ error }}</p>
|
|
}
|
|
|
|
<div
|
|
class="tables"
|
|
cdkDropList
|
|
cdkDropListSortingDisabled
|
|
[cdkDropListData]="connection.tables()"
|
|
[cdkDropListEnterPredicate]="nothingEnters"
|
|
>
|
|
@for (table of connection.tables(); track table.id) {
|
|
<div class="table-item" cdkDrag [cdkDragData]="table" (dblclick)="useTable.emit({ table })">
|
|
<mat-icon class="table-item__icon" aria-hidden="true">{{ table.icon }}</mat-icon>
|
|
<span class="table-item__text">
|
|
<span class="table-item__name" [title]="table.name">{{ table.name }}</span>
|
|
<span class="table-item__kind">{{ table.kindLabel }}</span>
|
|
</span>
|
|
@if (flowCount(table); as count) {
|
|
<span class="table-item__flows" [matTooltip]="count + ' flujo(s) usan esta tabla'">{{ count }}</span>
|
|
}
|
|
<button
|
|
mat-icon-button
|
|
type="button"
|
|
class="table-item__action"
|
|
matTooltip="Mapear a la base"
|
|
[attr.aria-label]="'Mapear ' + table.name"
|
|
(click)="useTable.emit({ table })"
|
|
>
|
|
<mat-icon aria-hidden="true">arrow_forward</mat-icon>
|
|
</button>
|
|
@if (table.removable) {
|
|
<button
|
|
mat-icon-button
|
|
type="button"
|
|
class="table-item__action"
|
|
matTooltip="Quitar"
|
|
[attr.aria-label]="'Quitar ' + table.name"
|
|
(click)="store.removeTable(table)"
|
|
>
|
|
<mat-icon aria-hidden="true">close</mat-icon>
|
|
</button>
|
|
}
|
|
<div *cdkDragPreview class="drag-preview">
|
|
<mat-icon aria-hidden="true">{{ table.icon }}</mat-icon>{{ table.label }}
|
|
</div>
|
|
<div *cdkDragPlaceholder class="table-item table-item--placeholder"></div>
|
|
</div>
|
|
} @empty {
|
|
@if (connection.state() === 'ready') {
|
|
<p class="tables__empty">
|
|
Sin tablas.
|
|
</p>
|
|
}
|
|
}
|
|
</div>
|
|
</mat-expansion-panel>
|
|
}
|
|
</mat-accordion>
|
|
}
|
|
|
|
<mat-divider></mat-divider>
|
|
|
|
<header class="pane__header">
|
|
<h2>Destino</h2>
|
|
<span class="pane__caption">{{ store.targets().length }} tablas</span>
|
|
</header>
|
|
<p class="pane__hint">Arrastra una tabla de origen sobre una entidad para mapearla directamente.</p>
|
|
<mat-list class="targets" dense>
|
|
@for (target of store.targets(); track target.key) {
|
|
<mat-list-item
|
|
class="target-item"
|
|
cdkDropList
|
|
[cdkDropListData]="target"
|
|
[cdkDropListEnterPredicate]="onlyTables"
|
|
(cdkDropListDropped)="onDropOnTarget($event)"
|
|
>
|
|
<mat-icon matListItemIcon aria-hidden="true">table_chart</mat-icon>
|
|
<span matListItemTitle class="target-item__title">
|
|
{{ target.table }}
|
|
@if (store.flowsByTarget().get(target.key); as count) {
|
|
<span class="target-item__flows" [matTooltip]="count + ' flujo(s) cargan esta tabla'">{{ count }}</span>
|
|
}
|
|
</span>
|
|
<span matListItemLine>
|
|
{{ target.fields.length }} campos@if (target.conflict_fields) { · clave {{ target.conflict_fields.join(', ') }} }
|
|
</span>
|
|
</mat-list-item>
|
|
}
|
|
</mat-list>
|
|
</section>
|