Update: Opciones de exportar

This commit is contained in:
Angel Capetillo Zavala
2026-09-25 10:53:05 -06:00
parent 0fcc9fb70c
commit 6543ddad7b
13 changed files with 320 additions and 21 deletions
+12
View File
@@ -0,0 +1,12 @@
<div class="action-options" role="group" aria-label="Acción sobre el análisis actual">
<button class="action-card" [class.action-card--selected]="intent === 'append'" [attr.aria-pressed]="intent === 'append'" type="button" (click)="intentChange.emit('append')">
<span class="action-card__icon"><mat-icon aria-hidden="true">playlist_add</mat-icon></span>
<span class="action-card__copy"><span class="action-card__title">Agregar información</span><span class="action-card__description">Combina los nuevos datos con el análisis actual.</span></span>
@if (intent === 'append') { <mat-icon class="action-card__check" aria-hidden="true">check_circle</mat-icon> }
</button>
<button class="action-card" [class.action-card--selected]="intent === 'replace'" [attr.aria-pressed]="intent === 'replace'" type="button" (click)="intentChange.emit('replace')">
<span class="action-card__icon"><mat-icon aria-hidden="true">restart_alt</mat-icon></span>
<span class="action-card__copy"><span class="action-card__title">Nuevo análisis</span><span class="action-card__description">Descarta los resultados actuales y comienza un nuevo análisis.</span></span>
@if (intent === 'replace') { <mat-icon class="action-card__check" aria-hidden="true">check_circle</mat-icon> }
</button>
</div>
+14
View File
@@ -0,0 +1,14 @@
@use 'upload-button' as button;
:host { display: block; }
.action-options { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.action-card { align-items: center; background: #fff; border: 1px solid var(--color-border); border-radius: 9px; color: var(--color-text); cursor: pointer; display: flex; gap: 16px; min-height: 126px; padding: 20px; position: relative; text-align: left; transition: background-color .18s ease, border-color .18s ease; }
.action-card:hover { background: var(--color-surface-hover); border-color: var(--color-primary); }
.action-card:focus-visible { @include button.focus; }
.action-card--selected { background: #fbfcf6; border: 2px solid var(--color-primary); padding: 19px; }
.action-card__icon { align-items: center; background: var(--color-step); border-radius: 8px; color: #71882b; display: inline-flex; flex: 0 0 46px; height: 46px; justify-content: center; }
.action-card__copy { display: grid; gap: 6px; min-width: 0; }
.action-card__title { font-size: 16px; font-weight: 600; }
.action-card__description { color: var(--color-text-secondary); font-size: 13px; line-height: 1.45; }
.action-card__check { color: #71882b; margin-left: auto; }
@media (max-width: 600px) { .action-options { grid-template-columns: 1fr; } .action-card { min-height: 94px; padding: 16px; } .action-card--selected { padding: 15px; } }
+14
View File
@@ -0,0 +1,14 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import type { UploadIntent } from './information-upload-dialog';
@Component({
imports: [MatIconModule],
selector: 'app-action-selection',
styleUrl: './action-selection.scss',
templateUrl: './action-selection.html',
})
export class ActionSelectionComponent {
@Input() intent: UploadIntent | null = null;
@Output() readonly intentChange = new EventEmitter<UploadIntent>();
}
+103
View File
@@ -499,6 +499,109 @@ describe('App', () => {
expect(root.querySelector('.dashboard__demo')?.textContent).toContain('Datos de demostración');
expect(root.querySelectorAll('.kpi')).toHaveLength(3);
expect(root.querySelectorAll('app-plotly-chart')).toHaveLength(3);
expect(root.querySelector('.dashboard__back')?.textContent).toContain('Volver al inicio');
expect(root.querySelector('.dashboard__export')?.textContent).toContain('Exportar');
expect(root.querySelector('.site-footer img')).not.toBeNull();
});
it('returns to Home and supports local PDF and Excel selection in the export dialog', async () => {
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
const root = fixture.nativeElement as HTMLElement;
const router = TestBed.inject(Router);
await router.navigateByUrl('/dashboard');
await fixture.whenStable();
fixture.detectChanges();
root.querySelector<HTMLButtonElement>('.dashboard__back')!.click();
await fixture.whenStable();
fixture.detectChanges();
expect(router.url).toBe('/');
expect((fixture.nativeElement as HTMLElement).querySelector('app-home')).not.toBeNull();
await router.navigateByUrl('/dashboard');
await fixture.whenStable();
fixture.detectChanges();
root.querySelector<HTMLButtonElement>('.dashboard__export')!.click();
fixture.detectChanges();
await fixture.whenStable();
const overlay = document.querySelector('.cdk-overlay-container')!;
const dialogRef = TestBed.inject(MatDialog).openDialogs[0];
const detect = () => dialogRef.componentRef?.changeDetectorRef.detectChanges();
const options = () => overlay.querySelectorAll<HTMLButtonElement>('.export-option');
expect(overlay.querySelector('#export-title')?.textContent).toContain('Exportar resultados');
expect(options()[0].getAttribute('aria-pressed')).toBe('false');
expect(options()[1].getAttribute('aria-pressed')).toBe('false');
expect(overlay.querySelector<HTMLButtonElement>('.export-dialog__submit')?.disabled).toBe(true);
options()[0].focus();
options()[0].click();
detect();
expect(options()[0].getAttribute('aria-pressed')).toBe('true');
expect(overlay.querySelector('.export-option--selected strong')?.textContent).toBe('PDF');
options()[1].click();
detect();
expect(options()[0].getAttribute('aria-pressed')).toBe('false');
expect(options()[1].getAttribute('aria-pressed')).toBe('true');
expect(overlay.querySelector('.export-dialog__submit')?.hasAttribute('disabled')).toBe(true);
overlay.querySelector<HTMLButtonElement>('.export-dialog__cancel')!.click();
fixture.detectChanges();
await new Promise((resolve) => setTimeout(resolve, 200));
expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0);
expect(router.url).toBe('/dashboard');
root.querySelector<HTMLButtonElement>('.dashboard__export')!.click();
fixture.detectChanges();
await fixture.whenStable();
const reopenedOverlay = document.querySelector('.cdk-overlay-container')!;
expect(reopenedOverlay.querySelectorAll('.export-option--selected')).toHaveLength(0);
reopenedOverlay.querySelector<HTMLButtonElement>('.export-dialog__close')!.click();
fixture.detectChanges();
await new Promise((resolve) => setTimeout(resolve, 200));
expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0);
expect(router.url).toBe('/dashboard');
});
it('opens the Dashboard action step, preserves its intent on back, and cancels without leaving results', async () => {
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
const router = TestBed.inject(Router);
await router.navigateByUrl('/dashboard');
await fixture.whenStable();
fixture.detectChanges();
const dashboard = fixture.nativeElement as HTMLElement;
dashboard.querySelector<HTMLButtonElement>('.dashboard__upload')!.click();
fixture.detectChanges();
await fixture.whenStable();
const overlay = document.querySelector('.cdk-overlay-container')!;
const dialog = TestBed.inject(MatDialog).openDialogs[0].componentRef!;
const detect = () => dialog.changeDetectorRef.detectChanges();
expect(overlay.querySelector('.action-options')).not.toBeNull();
const continueButton = overlay.querySelector<HTMLButtonElement>('.upload-dialog__continue')!;
expect(continueButton.disabled).toBe(true);
const cards = overlay.querySelectorAll<HTMLButtonElement>('.action-card');
cards[0].click();
detect();
expect(continueButton.disabled).toBe(false);
continueButton.click();
detect();
expect(overlay.querySelector('.source-options')).not.toBeNull();
overlay.querySelector<HTMLButtonElement>('.upload-dialog__back')!.click();
detect();
expect(overlay.querySelector<HTMLButtonElement>('.action-card')?.getAttribute('aria-pressed')).toBe('true');
overlay.querySelectorAll<HTMLButtonElement>('.action-card')[1].click();
detect();
expect(continueButton.disabled).toBe(false);
continueButton.click();
detect();
overlay.querySelector<HTMLButtonElement>('.source-card')!.click();
detect();
continueButton.click();
detect();
expect(overlay.querySelector('.file-configuration')).not.toBeNull();
overlay.querySelector<HTMLButtonElement>('.upload-dialog__cancel')!.click();
fixture.detectChanges();
await new Promise((resolve) => setTimeout(resolve, 200));
expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0);
expect(router.url).toBe('/dashboard');
expect((fixture.nativeElement as HTMLElement).querySelector('#dashboard-title')).not.toBeNull();
});
});
+14 -7
View File
@@ -1,12 +1,19 @@
<section class="dashboard" aria-labelledby="dashboard-title">
<div class="dashboard__intro">
<p class="dashboard__eyebrow">ISSSTELEON · Análisis de información</p>
<h1 id="dashboard-title">Resultados del análisis</h1>
<div class="dashboard__metadata">
<span class="dashboard__area">{{ result.analysisType }}</span>
<span class="dashboard__demo">Datos de demostración</span>
<button class="dashboard__back" type="button" (click)="returnHome()"><mat-icon aria-hidden="true">arrow_back</mat-icon><span>Volver al inicio</span></button>
<div class="dashboard__heading">
<div class="dashboard__intro">
<p class="dashboard__eyebrow">ISSSTELEON · Análisis de información</p>
<h1 id="dashboard-title">Resultados del análisis</h1>
<div class="dashboard__metadata">
<span class="dashboard__area">{{ result.analysisType }}</span>
<span class="dashboard__demo">Datos de demostración</span>
</div>
<p class="dashboard__note">Los indicadores y las gráficas muestran valores obtenidos del procesamiento de los datos.</p>
</div>
<div class="dashboard__actions">
<button class="dashboard__upload" type="button" (click)="openInformationDialog()"><mat-icon aria-hidden="true">upload_file</mat-icon><span>Cargar información</span></button>
<button class="dashboard__export" type="button" (click)="openExportDialog()"><mat-icon aria-hidden="true">download</mat-icon><span>Exportar</span></button>
</div>
<p class="dashboard__note">Los indicadores y las gráficas muestran valores obtenidos del procesamiento de los datos.</p>
</div>
<div class="dashboard__kpis" aria-label="Indicadores de demostración">
+16
View File
@@ -1,5 +1,19 @@
:host { display: block; flex: 1; min-width: 0; }
.dashboard { margin: 0 auto; max-width: 1440px; padding: 42px clamp(20px, 4vw, 56px) 72px; width: 100%; }
.dashboard__back { align-items: center; background: transparent; border: 0; border-radius: 6px; color: var(--color-text); cursor: pointer; display: inline-flex; font: inherit; gap: 7px; margin: 0 0 22px; min-height: 40px; padding: 6px 8px; }
.dashboard__back:hover { background: #eef1e8; }
.dashboard__back mat-icon { font-size: 20px; height: 20px; width: 20px; }
.dashboard__back:focus-visible, .dashboard__export:focus-visible { outline: 3px solid rgb(168 194 67 / 55%); outline-offset: 3px; }
.dashboard__heading { align-items: center; display: flex; gap: 24px; justify-content: space-between; }
.dashboard__intro { min-width: 0; }
.dashboard__actions { align-items: center; display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 10px; }
.dashboard__upload { align-items: center; background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; color: var(--color-text); cursor: pointer; display: inline-flex; flex: 0 0 auto; font: inherit; font-weight: 600; gap: 9px; min-height: 50px; padding: 12px 20px; transition: background-color .2s ease, border-color .2s ease; }
.dashboard__upload:hover { background: #e9ecef; border-color: #5f9ea0; }
.dashboard__upload mat-icon { color: #5f9ea0; }
.dashboard__upload:focus-visible { outline: 3px solid rgb(168 194 67 / 55%); outline-offset: 3px; }
.dashboard__export { align-items: center; background: #fff; border: 1px solid #d7dccf; border-radius: 8px; color: var(--color-text); cursor: pointer; display: inline-flex; font: inherit; font-weight: 600; gap: 9px; min-height: 50px; padding: 12px 20px; transition: background-color .2s ease, border-color .2s ease; }
.dashboard__export:hover { background: #f3f6e9; border-color: #a8c243; }
.dashboard__export mat-icon { color: #52691f; }
.dashboard__eyebrow { color: var(--color-text-secondary); font-size: 12px; font-weight: 600; letter-spacing: .12em; margin: 0 0 12px; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { color: var(--color-text); font-family: var(--font-heading); font-size: clamp(32px, 3.8vw, 46px); line-height: 1.1; margin-bottom: 16px; }
@@ -18,4 +32,6 @@ h1 { color: var(--color-text); font-family: var(--font-heading); font-size: clam
.chart-card h2 { color: var(--color-text); font-family: var(--font-heading); font-size: 22px; font-weight: 700; line-height: 1.2; margin: 0 0 12px; }
.chart-card--line { grid-column: 1 / -1; }
@media (max-width: 860px) { .dashboard__charts { grid-template-columns: minmax(0, 1fr); } .chart-card--line { grid-column: auto; } }
@media (max-width: 700px) { .dashboard__heading { align-items: flex-start; flex-direction: column; gap: 18px; } .dashboard__actions { width: 100%; } }
@media (max-width: 420px) { .dashboard__actions { align-items: stretch; flex-direction: column; } .dashboard__actions button { justify-content: center; width: 100%; } }
@media (max-width: 600px) { .dashboard { padding: 30px 16px 48px; } .dashboard__kpis { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 26px; } .kpi { padding: 18px 20px; } .chart-card { padding: 18px 12px 12px; } .chart-card h2 { font-size: 20px; margin-left: 6px; } }
+32 -2
View File
@@ -1,6 +1,12 @@
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { Router } from '@angular/router';
import { take } from 'rxjs';
import { mockAnalysisResult } from './dashboard.mock';
import { ChartFigure, PlotlyChart } from './plotly-chart';
import { InformationUploadDialog } from '../information-upload-dialog';
import { ExportResultsDialog } from './export-results-dialog';
const ink = '#081839';
const grid = '#e9ede5';
@@ -11,13 +17,37 @@ const muted = '#7a7a7a';
const font = { family: 'Roboto, sans-serif', color: ink, size: 12 };
@Component({
imports: [PlotlyChart],
imports: [MatDialogModule, MatIconModule, PlotlyChart],
selector: 'app-dashboard',
styleUrl: './dashboard.scss',
templateUrl: './dashboard.html',
})
export class Dashboard {
private readonly dialog = inject(MatDialog);
private readonly router = inject(Router);
readonly result = mockAnalysisResult;
returnHome(): void { void this.router.navigateByUrl('/'); }
openExportDialog(): void {
if (this.dialog.openDialogs.length > 0) return;
this.dialog.open(ExportResultsDialog, {
width: '640px', maxWidth: 'calc(100vw - 32px)',
autoFocus: 'first-tabbable', restoreFocus: true,
panelClass: 'export-results-dialog-panel',
});
}
openInformationDialog(): void {
if (this.dialog.openDialogs.length > 0) return;
this.dialog.open<InformationUploadDialog, { entryPoint: 'dashboard' }, 'completed' | undefined>(InformationUploadDialog, {
data: { entryPoint: 'dashboard' }, width: '800px', maxWidth: 'calc(100vw - 32px)',
autoFocus: 'first-tabbable', restoreFocus: true, disableClose: true,
panelClass: 'information-upload-dialog-panel',
}).afterClosed().pipe(take(1)).subscribe((result) => {
if (result === 'completed') void this.router.navigateByUrl('/dashboard');
});
}
readonly bars: ChartFigure = {
data: [{
type: 'bar',
@@ -0,0 +1,30 @@
<section class="export-dialog" aria-labelledby="export-title" aria-describedby="export-description">
<header class="export-dialog__header">
<div>
<h2 id="export-title">Exportar resultados</h2>
<p id="export-description">Selecciona el formato en el que deseas exportar los resultados del análisis.</p>
</div>
<button class="export-dialog__close" type="button" aria-label="Cerrar diálogo" (click)="close()"><mat-icon aria-hidden="true">close</mat-icon></button>
</header>
<div class="export-options" role="group" aria-label="Formato de exportación">
<button class="export-option" [class.export-option--selected]="selection() === 'pdf'" [attr.aria-pressed]="selection() === 'pdf'" type="button" (click)="select('pdf')">
<mat-icon class="export-option__icon" aria-hidden="true">picture_as_pdf</mat-icon>
<span class="export-option__copy"><strong>PDF</strong><span>Reporte visual del análisis y sus gráficas.</span></span>
@if (selection() === 'pdf') { <mat-icon class="export-option__check" aria-hidden="true">check_circle</mat-icon> }
</button>
<button class="export-option" [class.export-option--selected]="selection() === 'excel'" [attr.aria-pressed]="selection() === 'excel'" type="button" (click)="select('excel')">
<mat-icon class="export-option__icon" aria-hidden="true">table_chart</mat-icon>
<span class="export-option__copy"><strong>Excel</strong><span>Datos utilizados por los indicadores y las gráficas.</span></span>
@if (selection() === 'excel') { <mat-icon class="export-option__check" aria-hidden="true">check_circle</mat-icon> }
</button>
</div>
<footer class="export-dialog__footer">
<p>La generación del archivo se implementará en la siguiente fase.</p>
<div class="export-dialog__actions">
<button class="export-dialog__cancel" type="button" (click)="close()">Cancelar</button>
<button class="export-dialog__submit" type="button" disabled>Exportar</button>
</div>
</footer>
</section>
@@ -0,0 +1,28 @@
:host { display: block; }
.export-dialog { background: #fff; color: var(--color-text); padding: 28px 32px 24px; }
.export-dialog__header { align-items: flex-start; display: flex; gap: 20px; justify-content: space-between; }
.export-dialog__header h2 { font-family: var(--font-heading); font-size: 30px; line-height: 1.15; margin: 0; }
.export-dialog__header p { color: var(--color-text-secondary); font-size: 15px; line-height: 1.5; margin: 12px 0 0; }
.export-dialog__close { align-items: center; background: transparent; border: 0; border-radius: 50%; color: #596273; cursor: pointer; display: inline-flex; flex: 0 0 auto; height: 40px; justify-content: center; margin: -8px -10px 0 0; width: 40px; }
.export-dialog__close:hover { background: #f0f2ed; }
.export-options { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 26px 0; }
.export-option { align-items: flex-start; background: #fff; border: 1px solid #d7dccf; border-radius: 10px; color: var(--color-text); cursor: pointer; display: flex; gap: 13px; min-height: 112px; padding: 18px 15px; text-align: left; transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease; }
.export-option:hover { background: #f7f9f3; border-color: #9aaa64; }
.export-option:focus-visible, .export-dialog button:focus-visible { outline: 3px solid rgb(168 194 67 / 55%); outline-offset: 3px; }
.export-option--selected { background: #f4f7e9; border: 2px solid #6f821c; padding: 17px 14px; }
.export-option__icon { color: #52691f; flex: 0 0 auto; margin-top: 1px; }
.export-option__copy { display: grid; gap: 7px; line-height: 1.4; }
.export-option__copy strong { font-size: 16px; }
.export-option__copy > span { color: var(--color-text-secondary); font-size: 13px; }
.export-option__check { color: #52691f; flex: 0 0 auto; font-size: 20px; height: 20px; margin-left: auto; width: 20px; }
.export-dialog__footer { align-items: flex-end; border-top: 1px solid var(--color-border); display: flex; gap: 16px; justify-content: space-between; padding-top: 18px; }
.export-dialog__footer p { color: var(--color-text-secondary); font-size: 12px; line-height: 1.4; margin: 0; max-width: 240px; }
.export-dialog__actions { display: flex; flex: 0 0 auto; gap: 10px; }
.export-dialog__actions button { border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600; min-height: 44px; padding: 10px 18px; }
.export-dialog__cancel { background: #fff; border: 1px solid var(--color-border-subtle); color: var(--color-text); }
.export-dialog__cancel:hover { background: var(--color-surface-hover); }
.export-dialog__submit { background: var(--color-primary-action); border: 1px solid var(--color-primary-action); color: #fff; }
.export-dialog__submit:disabled { background: #e8ecdf; border-color: #e8ecdf; color: #9da38f; cursor: not-allowed; }
@media (max-width: 560px) { .export-dialog { padding: 22px 20px 18px; } .export-dialog__header h2 { font-size: 26px; } .export-options { grid-template-columns: minmax(0, 1fr); margin: 20px 0; } .export-option { min-height: 88px; } .export-dialog__footer { align-items: stretch; flex-direction: column; } .export-dialog__footer p { max-width: none; } .export-dialog__actions { justify-content: flex-end; } }
@media (max-width: 360px) { .export-dialog { padding-inline: 16px; } .export-dialog__actions { gap: 6px; } .export-dialog__actions button { padding-inline: 12px; } }
.export-dialog__close:focus-visible { outline: 3px solid rgb(168 194 67 / 55%); outline-offset: 2px; }
@@ -0,0 +1,20 @@
import { Component, signal } from '@angular/core';
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
export type ExportFormat = 'pdf' | 'excel';
@Component({
imports: [MatDialogModule, MatIconModule],
selector: 'app-export-results-dialog',
styleUrl: './export-results-dialog.scss',
templateUrl: './export-results-dialog.html',
})
export class ExportResultsDialog {
readonly selection = signal<ExportFormat | null>(null);
constructor(private readonly dialogRef: MatDialogRef<ExportResultsDialog>) {}
select(format: ExportFormat): void { this.selection.set(format); }
close(): void { this.dialogRef.close(); }
}
+2 -1
View File
@@ -18,7 +18,8 @@ export class Home {
openInformationDialog(): void {
if (this.dialog.openDialogs.length > 0) return;
this.dialog.open<InformationUploadDialog, void, 'completed' | undefined>(InformationUploadDialog, {
this.dialog.open<InformationUploadDialog, { entryPoint: 'home' }, 'completed' | undefined>(InformationUploadDialog, {
data: { entryPoint: 'home' },
width: '800px',
maxWidth: 'calc(100vw - 32px)',
autoFocus: 'first-tabbable',
+10 -5
View File
@@ -9,7 +9,7 @@
</button>
</header>
<ol class="upload-steps" aria-label="Etapas de carga de información">
@if (step() !== 'action') { <ol class="upload-steps" aria-label="Etapas de carga de información">
<li [class.upload-steps__item--active]="step() === 'source'" [class.upload-steps__item--complete]="step() !== 'source'" [attr.aria-current]="step() === 'source' ? 'step' : null">
<span class="upload-steps__number"><mat-icon aria-hidden="true">{{ step() === 'source' ? 'looks_one' : 'check' }}</mat-icon></span><span>Fuente</span>
</li>
@@ -19,9 +19,14 @@
<li [class.upload-steps__item--active]="step() === 'confirmation'" [attr.aria-current]="step() === 'confirmation' ? 'step' : null">
<span class="upload-steps__number"><mat-icon aria-hidden="true">looks_3</mat-icon></span><span>Confirmación</span>
</li>
</ol>
</ol> }
@if (step() === 'source') {
@if (step() === 'action') {
<p class="upload-dialog__description">¿Qué deseas hacer con la nueva información?</p>
<div class="upload-dialog__content">
<app-action-selection [intent]="intent()" (intentChange)="selectIntent($event)" />
</div>
} @else if (step() === 'source') {
<p class="upload-dialog__description">Selecciona cómo deseas proporcionar los datos.</p>
<div class="upload-dialog__content">
<app-source-selection [source]="source()" (sourceChange)="selectSource($event)" />
@@ -51,11 +56,11 @@
<footer class="upload-dialog__footer">
<button class="upload-action action-cancel upload-dialog__cancel" mat-button type="button" (click)="close()">Cancelar</button>
<div class="upload-dialog__navigation">
@if (step() !== 'source') {
@if ((step() !== 'source' && step() !== 'action') || (step() === 'source' && entryPoint === 'dashboard')) {
<button class="upload-action upload-action--outlined action-back upload-dialog__back" mat-button type="button" (click)="back()">Regresar</button>
}
@if (step() !== 'confirmation') {
<button class="upload-action action-continue upload-dialog__continue" mat-flat-button type="button" [disabled]="step() === 'source' ? !source() : source() === 'file' ? files().length === 0 : !sqlConfigValid()" (click)="continue()">Continuar</button>
<button class="upload-action action-continue upload-dialog__continue" mat-flat-button type="button" [disabled]="step() === 'action' ? !intent() : step() === 'source' ? !source() : source() === 'file' ? files().length === 0 : !sqlConfigValid()" (click)="continue()">Continuar</button>
} @else { <button class="upload-action action-continue upload-dialog__process" mat-flat-button type="button" [disabled]="source() === 'file' ? files().length === 0 : sqlVerificationState() !== 'success'" (click)="process()">Procesar</button> }
</div>
</footer>
+25 -6
View File
@@ -1,6 +1,6 @@
import { Component, computed, OnDestroy, signal } from '@angular/core';
import { Component, computed, Inject, OnDestroy, Optional, signal } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { SqlConnectionConfig, SqlConnectionConfigComponent } from './sql-connection-config';
import { SqlConnectionConfirmationComponent, SqlConnectionVerificationState } from './sql-connection-confirmation';
@@ -9,18 +9,27 @@ import { SourceSelectionComponent, UploadSource } from './source-selection';
import { FileConfigurationComponent } from './file-configuration';
import { FileConfirmationComponent } from './file-confirmation';
import { formatFileSize, selectFiles } from './file-selection';
import { ActionSelectionComponent } from './action-selection';
type UploadStep = 'source' | 'configuration' | 'confirmation';
type UploadStep = 'action' | 'source' | 'configuration' | 'confirmation';
/** Future WebApi contract: append adds to the current analysis; replace starts an independent analysis.
* Adding data may require analysis-type compatibility checks (CaCu/CAMA/TEA); those rules are not defined here.
*/
export type UploadIntent = 'append' | 'replace';
export type UploadEntryPoint = 'home' | 'dashboard';
export interface InformationUploadDialogData { entryPoint: UploadEntryPoint; }
export type ProcessingState = 'processing' | 'success' | 'error';
@Component({
imports: [MatButtonModule, MatDialogModule, MatIconModule, SqlConnectionConfigComponent, SqlConnectionConfirmationComponent, ProcessingStatusComponent, SourceSelectionComponent, FileConfigurationComponent, FileConfirmationComponent],
imports: [MatButtonModule, MatDialogModule, MatIconModule, ActionSelectionComponent, SqlConnectionConfigComponent, SqlConnectionConfirmationComponent, ProcessingStatusComponent, SourceSelectionComponent, FileConfigurationComponent, FileConfirmationComponent],
selector: 'app-information-upload-dialog',
styleUrl: './information-upload-dialog.scss',
templateUrl: './information-upload-dialog.html',
})
export class InformationUploadDialog implements OnDestroy {
readonly entryPoint: UploadEntryPoint;
readonly step = signal<UploadStep>('source');
readonly intent = signal<UploadIntent | null>(null);
readonly source = signal<UploadSource | null>(null);
readonly files = signal<File[]>([]);
readonly totalFileSize = computed(() => this.files().reduce((total, file) => total + file.size, 0));
@@ -35,14 +44,23 @@ export class InformationUploadDialog implements OnDestroy {
private verificationTimer: ReturnType<typeof setTimeout> | null = null;
private processingTimer: ReturnType<typeof setInterval> | null = null;
constructor(private readonly dialogRef: MatDialogRef<InformationUploadDialog>) {}
constructor(
private readonly dialogRef: MatDialogRef<InformationUploadDialog>,
@Optional() @Inject(MAT_DIALOG_DATA) data: InformationUploadDialogData | null,
) {
this.entryPoint = data?.entryPoint ?? 'home';
if (this.entryPoint === 'dashboard') this.step.set('action');
}
selectIntent(intent: UploadIntent): void { this.intent.set(intent); }
selectSource(source: UploadSource): void {
this.source.set(source);
}
continue(): void {
if (this.step() === 'source' && this.source()) this.step.set('configuration');
if (this.step() === 'action' && this.intent()) this.step.set('source');
else if (this.step() === 'source' && this.source()) this.step.set('configuration');
else if (this.step() === 'configuration' && this.source() === 'file' && this.files().length > 0) {
this.step.set('confirmation');
} else if (this.step() === 'configuration' && this.source() === 'sql' && this.sqlConfigValid()) {
@@ -88,6 +106,7 @@ export class InformationUploadDialog implements OnDestroy {
back(): void {
if (this.step() === 'confirmation') this.step.set('configuration');
else if (this.step() === 'source' && this.entryPoint === 'dashboard') this.step.set('action');
else if (this.step() === 'configuration') this.step.set('source');
}