Merge remote-tracking branch 'origin/feature/frontend-flujo_inicial-20260923' into wip/mapping

This commit is contained in:
Roberto Treviño Cervantes
2026-09-24 11:30:40 -06:00
15 changed files with 1213 additions and 40 deletions
+2 -1
View File
@@ -2,7 +2,8 @@
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"packageManager": "npm"
"packageManager": "npm",
"analytics": false
},
"newProjectRoot": "projects",
"projects": {
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+19 -6
View File
@@ -1,7 +1,20 @@
<mat-toolbar color="primary">
<span>{{ title }}</span>
</mat-toolbar>
<div class="app-shell">
<header class="site-header">
<div class="site-header__content">
<a class="brand" href="/" aria-label="ISSSTELEON, inicio">
<img src="assets/branding/isssteleon-logo.png" alt="ISSSTELEON" />
</a>
<span class="site-header__section">Análisis de información</span>
</div>
</header>
<main>
<router-outlet />
</main>
<main class="app-main">
<router-outlet />
</main>
<footer class="site-footer">
<div class="site-footer__content">
<img src="assets/branding/isssteleon-logo.png" alt="ISSSTELEON" />
</div>
</footer>
</div>
+2 -1
View File
@@ -1,3 +1,4 @@
import { Routes } from '@angular/router';
import { Home } from './home';
export const routes: Routes = [];
export const routes: Routes = [{ path: '', component: Home }];
+85 -2
View File
@@ -1,3 +1,86 @@
main {
padding: 1.5rem;
.app-shell {
display: flex;
flex-direction: column;
min-height: 100vh;
min-height: 100dvh;
}
.site-header {
background: var(--color-surface);
border-bottom: 1px solid var(--color-border);
}
.site-header__content {
align-items: center;
display: flex;
justify-content: space-between;
min-height: 88px;
padding: 0 clamp(32px, 3.2vw, 48px);
}
.brand {
align-items: center;
display: inline-flex;
}
.brand img {
display: block;
height: auto;
width: clamp(180px, 16vw, 200px);
}
.site-header__section {
color: var(--color-text);
font-size: 15px;
font-weight: 500;
letter-spacing: 0.01em;
}
.app-main {
display: flex;
flex: 1;
}
.site-footer {
background: var(--color-text-secondary);
}
.site-footer__content {
align-items: center;
display: flex;
justify-content: center;
min-height: 86px;
padding: 0 clamp(32px, 3.2vw, 48px);
}
.site-footer img {
display: block;
filter: brightness(0) invert(1);
height: auto;
width: clamp(160px, 15vw, 185px);
}
@media (max-width: 600px) {
.site-header__content {
min-height: 70px;
padding: 0 20px;
}
.brand img {
width: clamp(132px, 42vw, 170px);
}
.site-header__section {
font-size: 13px;
text-align: right;
}
.site-footer__content {
min-height: 76px;
padding: 0 20px;
}
.site-footer img {
width: 155px;
}
}
+161 -4
View File
@@ -1,12 +1,15 @@
import { TestBed } from '@angular/core/testing';
import { provideRouter, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { App } from './app';
import { routes } from './app.routes';
describe('App', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [App],
})
.compileComponents();
providers: [provideRouter(routes)],
}).compileComponents();
});
it('should create the app', () => {
@@ -15,11 +18,165 @@ describe('App', () => {
expect(app).toBeTruthy();
});
it('should render the toolbar title', async () => {
it('should render the ISSSTELEON header and home page', async () => {
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
await TestBed.inject(Router).navigateByUrl('/');
await fixture.whenStable();
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('mat-toolbar')?.textContent).toContain('ISSSTELEON');
expect(compiled.querySelector('.brand img')?.getAttribute('alt')).toBe('ISSSTELEON');
expect(compiled.querySelector('.site-header__section')?.textContent).toContain(
'Análisis de información',
);
expect(compiled.querySelector('h1')?.textContent).toContain('Analiza tu información');
});
it('opens one dialog and keeps it open on backdrop and Escape', async () => {
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
await TestBed.inject(Router).navigateByUrl('/');
await fixture.whenStable();
fixture.detectChanges();
fixture.nativeElement.querySelector('.home__action').click();
fixture.detectChanges();
await fixture.whenStable();
const dialog = TestBed.inject(MatDialog);
expect(dialog.openDialogs).toHaveLength(1);
const overlay = document.querySelector('.cdk-overlay-container')!;
expect(overlay.querySelector('#upload-title')?.textContent).toContain('Cargar información');
overlay.querySelector<HTMLElement>('.cdk-overlay-backdrop')?.click();
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
expect(dialog.openDialogs).toHaveLength(1);
expect(overlay.querySelector('.upload-dialog__continue')?.hasAttribute('disabled')).toBe(true);
});
it('selects either source, continues, returns with selection, and closes explicitly', async () => {
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
await TestBed.inject(Router).navigateByUrl('/');
await fixture.whenStable();
fixture.detectChanges();
fixture.nativeElement.querySelector('.home__action').click();
fixture.detectChanges();
await fixture.whenStable();
const overlay = document.querySelector('.cdk-overlay-container')!;
const cards = () => overlay.querySelectorAll<HTMLButtonElement>('.source-card');
const continueButton = overlay.querySelector<HTMLButtonElement>('.upload-dialog__continue')!;
const detectDialogChanges = () => TestBed.inject(MatDialog).openDialogs[0].componentRef?.changeDetectorRef.detectChanges();
expect(continueButton.disabled).toBe(true);
overlay.querySelector<HTMLButtonElement>('.source-card')!.click();
detectDialogChanges();
expect(continueButton.disabled).toBe(false);
continueButton.click();
detectDialogChanges();
fixture.detectChanges();
expect(overlay.querySelector('.upload-dialog__description')?.textContent).toContain(
'Selecciona los archivos que deseas procesar.',
);
expect(overlay.querySelector('.upload-steps__item--active')?.textContent).toContain(
'Configuración',
);
expect(continueButton.disabled).toBe(true);
const fileInput = overlay.querySelector<HTMLInputElement>('input[type="file"]')!;
const validFile = new File(['contenido'], 'pacientes.XLSX', {
type: 'application/octet-stream',
});
const csvFile = new File(['a,b'], 'consultas.csv', { type: 'text/csv' });
const invalidFile = new File(['x'], 'documento.docx');
const emptyFile = new File([], 'vacio.csv');
const selectFiles = (...files: File[]) => {
Object.defineProperty(fileInput, 'files', { configurable: true, value: files });
fileInput.dispatchEvent(new Event('change', { bubbles: true }));
detectDialogChanges();
fixture.detectChanges();
};
selectFiles(validFile, csvFile, invalidFile, emptyFile);
expect(overlay.querySelectorAll('.file-row')).toHaveLength(2);
expect(overlay.querySelector('.file-messages')?.textContent).toContain(
'documento.docx no fue agregado. Formato no compatible.',
);
expect(overlay.querySelector('.file-messages')?.textContent).toContain(
'vacio.csv no fue agregado. El archivo está vacío.',
);
expect(continueButton.disabled).toBe(false);
selectFiles(validFile);
expect(overlay.querySelectorAll('.file-row')).toHaveLength(2);
expect(overlay.querySelector('.file-messages')?.textContent).toContain(
'pacientes.XLSX ya se encuentra seleccionado.',
);
const jsonFile = new File(['{}'], 'nuevo.json', { type: 'application/json' });
const dialogComponent = TestBed.inject(MatDialog).openDialogs[0].componentRef!
.instance as import('./information-upload-dialog').InformationUploadDialog;
dialogComponent.onDrop({
preventDefault: () => undefined,
dataTransfer: { files: [jsonFile] },
} as unknown as DragEvent);
detectDialogChanges();
fixture.detectChanges();
expect(overlay.querySelectorAll('.file-row')).toHaveLength(3);
overlay.querySelector<HTMLButtonElement>('.file-row__remove')!.click();
detectDialogChanges();
fixture.detectChanges();
expect(overlay.querySelectorAll('.file-row')).toHaveLength(2);
continueButton.click();
detectDialogChanges();
fixture.detectChanges();
expect(overlay.querySelector('h3')?.textContent).toContain('Confirmación');
expect(overlay.querySelector('.configuration-placeholder p')?.textContent).toContain(
'La confirmación de los archivos se implementará en la siguiente fase.',
);
overlay.querySelector<HTMLButtonElement>('.upload-dialog__back')!.click();
detectDialogChanges();
fixture.detectChanges();
expect(overlay.querySelectorAll('.file-row')).toHaveLength(2);
while (overlay.querySelector('.file-row__remove')) {
overlay.querySelector<HTMLButtonElement>('.file-row__remove')!.click();
detectDialogChanges();
fixture.detectChanges();
}
expect(overlay.querySelectorAll('.file-row')).toHaveLength(0);
expect(overlay.querySelector<HTMLButtonElement>('.upload-dialog__continue')?.disabled).toBe(true);
overlay.querySelector<HTMLButtonElement>('.upload-dialog__back')!.click();
detectDialogChanges();
fixture.detectChanges();
expect(cards()[0].getAttribute('aria-pressed')).toBe('true');
overlay.querySelectorAll<HTMLButtonElement>('.source-card')[1].click();
detectDialogChanges();
const sqlContinueButton = overlay.querySelector<HTMLButtonElement>('.upload-dialog__continue')!;
expect(sqlContinueButton.disabled).toBe(false);
sqlContinueButton.click();
detectDialogChanges();
fixture.detectChanges();
expect(overlay.querySelector('h3')?.textContent).toContain('Conexión SQL');
expect(overlay.querySelector<HTMLButtonElement>('.upload-dialog__continue')?.disabled).toBe(true);
overlay.querySelector<HTMLButtonElement>('.upload-dialog__back')!.click();
detectDialogChanges();
fixture.detectChanges();
expect(cards()[1].getAttribute('aria-pressed')).toBe('true');
overlay.querySelector<HTMLButtonElement>('.upload-dialog__close')!.click();
fixture.detectChanges();
await new Promise((resolve) => setTimeout(resolve, 200));
expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0);
fixture.nativeElement.querySelector('.home__action').click();
fixture.detectChanges();
await fixture.whenStable();
const reopenedOverlay = document.querySelector('.cdk-overlay-container')!;
reopenedOverlay.querySelector<HTMLButtonElement>('.source-card')!.click();
const reopenedDialog = TestBed.inject(MatDialog).openDialogs[0].componentRef!;
reopenedDialog.changeDetectorRef.detectChanges();
reopenedOverlay.querySelector<HTMLButtonElement>('.upload-dialog__continue')!.click();
reopenedDialog.changeDetectorRef.detectChanges();
expect(reopenedOverlay.querySelector('.selected-files')).toBeNull();
expect(reopenedOverlay.querySelector<HTMLButtonElement>('.upload-dialog__continue')?.disabled).toBe(true);
reopenedOverlay.querySelector<HTMLButtonElement>('.upload-dialog__cancel')!.click();
fixture.detectChanges();
await new Promise((resolve) => setTimeout(resolve, 200));
expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0);
});
});
+2 -5
View File
@@ -1,13 +1,10 @@
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { MatToolbarModule } from '@angular/material/toolbar';
@Component({
imports: [RouterOutlet, MatToolbarModule],
imports: [RouterOutlet],
selector: 'app-root',
styleUrl: './app.scss',
templateUrl: './app.html',
})
export class App {
protected readonly title = 'ISSSTELEON';
}
export class App {}
+27
View File
@@ -0,0 +1,27 @@
<section class="home" aria-labelledby="home-title">
<div class="home__content">
<p class="home__eyebrow">ISSSTELEON · Análisis de información</p>
<h1 id="home-title">Analiza tu información</h1>
<p class="home__description">
Carga tus datos para procesarlos y consultar resultados de forma clara y sencilla.
</p>
<button class="home__action" type="button" (click)="openInformationDialog()">
<mat-icon aria-hidden="true">upload_file</mat-icon>
<span>Cargar información</span>
</button>
<ol class="steps" aria-label="Pasos del análisis de información">
<li class="steps__item">
<span class="steps__icon"><mat-icon aria-hidden="true">upload_file</mat-icon></span>
<span>Carga información</span>
</li>
<li class="steps__item">
<span class="steps__icon"><mat-icon aria-hidden="true">data_object</mat-icon></span>
<span>Procesa los datos</span>
</li>
<li class="steps__item">
<span class="steps__icon"><mat-icon aria-hidden="true">insights</mat-icon></span>
<span>Consulta resultados</span>
</li>
</ol>
</div>
</section>
+131
View File
@@ -0,0 +1,131 @@
:host {
display: flex;
flex: 1;
min-width: 0;
}
.home {
align-items: flex-start;
display: flex;
flex: 1;
justify-content: center;
min-height: inherit;
padding: 72px 32px;
text-align: center;
}
.home__content {
margin-inline: auto;
max-width: 780px;
width: 100%;
}
.home__eyebrow {
color: var(--color-text-secondary);
font-size: 12px;
font-weight: 500;
letter-spacing: 0.12em;
margin: 0 0 18px;
text-transform: uppercase;
}
h1 {
color: var(--color-primary);
font-family: var(--font-heading);
font-size: clamp(2.75rem, 5.1vw, 3.375rem);
font-weight: 700;
letter-spacing: -0.045em;
line-height: 1.08;
margin: 0;
}
.home__description {
color: var(--color-text-secondary);
font-size: 16px;
line-height: 1.6;
margin: 20px auto 30px;
max-width: 560px;
}
.home__action {
align-items: center;
background: #f8f9fa;
border: 1px solid #e9ecef;
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 0.2s ease,
border-color 0.2s ease,
color 0.2s ease,
transform 0.2s ease;
}
.home__action:hover {
background: #e9ecef;
border-color: #5f9ea0;
transform: translateY(-1px);
}
.home__action:focus-visible {
outline: 3px solid rgb(168 194 67 / 55%);
outline-offset: 3px;
}
.home__action:active {
transform: translateY(0);
}
.home__action mat-icon {
color: #5f9ea0;
margin: 0;
}
.steps {
align-items: center;
color: var(--color-text-secondary);
display: flex;
flex-wrap: wrap;
gap: 24px 36px;
justify-content: center;
list-style: none;
margin: 74px 0 0;
padding: 0;
}
.steps__item {
align-items: center;
display: inline-flex;
font-size: 14px;
gap: 10px;
}
.steps__icon {
align-items: center;
background: var(--color-step);
border-radius: 50%;
color: var(--color-primary);
display: inline-flex;
height: 38px;
justify-content: center;
width: 38px;
}
@media (max-width: 600px) {
.home {
padding: 56px 22px;
}
h1 {
font-size: clamp(2.35rem, 10vw, 2.8rem);
}
.home__description {
font-size: 15px;
margin-top: 16px;
}
.steps {
align-items: flex-start;
flex-direction: column;
gap: 16px;
margin: 52px auto 0;
max-width: 230px;
}
}
+27
View File
@@ -0,0 +1,27 @@
import { Component, inject } from '@angular/core';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { InformationUploadDialog } from './information-upload-dialog';
@Component({
imports: [MatDialogModule, MatIconModule],
selector: 'app-home',
styleUrl: './home.scss',
templateUrl: './home.html',
})
export class Home {
private readonly dialog = inject(MatDialog);
openInformationDialog(): void {
if (this.dialog.openDialogs.length > 0) return;
this.dialog.open(InformationUploadDialog, {
width: '800px',
maxWidth: 'calc(100vw - 32px)',
autoFocus: 'first-tabbable',
restoreFocus: true,
disableClose: true,
panelClass: 'information-upload-dialog-panel',
});
}
}
+105
View File
@@ -0,0 +1,105 @@
<section class="upload-dialog" aria-labelledby="upload-title">
<header class="upload-dialog__header">
<h2 id="upload-title">Cargar información</h2>
<button class="upload-dialog__close" mat-icon-button type="button" aria-label="Cerrar diálogo de carga de información" (click)="close()">
<mat-icon aria-hidden="true">close</mat-icon>
</button>
</header>
<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>
<li [class.upload-steps__item--active]="step() === 'configuration'" [class.upload-steps__item--complete]="step() === 'confirmation'" [attr.aria-current]="step() === 'configuration' ? 'step' : null">
<span class="upload-steps__number"><mat-icon aria-hidden="true">{{ step() === 'confirmation' ? 'check' : 'looks_two' }}</mat-icon></span><span>Configuración</span>
</li>
<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>
@if (step() === 'source') {
<p class="upload-dialog__description">Selecciona cómo deseas proporcionar los datos.</p>
<div class="upload-dialog__content">
<div class="source-options" role="group" aria-label="Selecciona una fuente de información">
<button class="source-card" [class.source-card--selected]="source() === 'file'" [attr.aria-pressed]="source() === 'file'" type="button" (click)="selectSource('file')">
<span class="source-card__icon"><mat-icon aria-hidden="true">upload_file</mat-icon></span>
<span class="source-card__copy"><span class="source-card__title">Archivo</span><span class="source-card__description">Excel, CSV, JSON o PDF</span></span>
@if (source() === 'file') { <mat-icon class="source-card__check" aria-hidden="true">check_circle</mat-icon> }
</button>
<button class="source-card" [class.source-card--selected]="source() === 'sql'" [attr.aria-pressed]="source() === 'sql'" type="button" (click)="selectSource('sql')">
<span class="source-card__icon"><mat-icon aria-hidden="true">storage</mat-icon></span>
<span class="source-card__copy"><span class="source-card__title">Conexión SQL</span><span class="source-card__description">Conecta una base de datos para utilizar su información.</span></span>
@if (source() === 'sql') { <mat-icon class="source-card__check" aria-hidden="true">check_circle</mat-icon> }
</button>
</div>
</div>
} @else if (step() === 'configuration' && source() === 'file') {
<p class="upload-dialog__description">Selecciona los archivos que deseas procesar.</p>
<div class="upload-dialog__content file-configuration">
<div class="dropzone" [class.dropzone--active]="isDragOver()" (dragenter)="onDragEnter($event)" (dragover)="onDragOver($event)" (dragleave)="onDragLeave($event)" (drop)="onDrop($event)">
<mat-icon class="dropzone__icon" aria-hidden="true">cloud_upload</mat-icon>
<p class="dropzone__title">Arrastra tus archivos aquí</p>
<p class="dropzone__formats">Excel · CSV · JSON · PDF</p>
<input #fileInput class="visually-hidden" type="file" multiple accept=".xlsx,.csv,.json,.pdf,application/pdf,application/json,text/csv" aria-label="Seleccionar archivos" (change)="onFileSelection($event)" />
<button class="upload-action upload-action--outlined select-files-button" mat-stroked-button type="button" (click)="fileInput.click()">
<mat-icon aria-hidden="true">upload_file</mat-icon>
<span>Seleccionar archivos</span>
</button>
</div>
@if (fileMessages().length > 0) {
<ul class="file-messages" aria-live="polite" aria-label="Mensajes sobre archivos">
@for (message of fileMessages(); track $index) { <li>{{ message }}</li> }
</ul>
}
@if (files().length > 0) {
<section class="selected-files" aria-labelledby="selected-files-title">
<header class="selected-files__header">
<h3 id="selected-files-title">Archivos seleccionados</h3>
<span class="selected-files__count" aria-label="Cantidad de archivos">{{ files().length }}</span>
</header>
<ul class="selected-files__list">
@for (file of files(); track file.name + ':' + file.size) {
<li class="file-row">
<mat-icon class="file-row__icon" aria-hidden="true">{{ fileIcon(file) }}</mat-icon>
<span class="file-row__name" [title]="file.name">{{ file.name }}</span>
<span class="file-row__size">{{ formatFileSize(file.size) }}</span>
<button class="file-row__remove" mat-icon-button type="button" [attr.aria-label]="'Eliminar ' + file.name" (click)="removeFile(file)">
<mat-icon aria-hidden="true">close</mat-icon>
</button>
</li>
}
</ul>
</section>
}
</div>
} @else if (step() === 'configuration') {
<p class="upload-dialog__description">Configura la fuente seleccionada.</p>
<div class="upload-dialog__content configuration-placeholder" aria-live="polite">
<span class="configuration-placeholder__icon"><mat-icon aria-hidden="true">storage</mat-icon></span>
<h3>Conexión SQL</h3>
<p>La configuración de la conexión se implementará en la siguiente fase.</p>
</div>
} @else {
<p class="upload-dialog__description">Revisa el siguiente paso de la carga de información.</p>
<div class="upload-dialog__content configuration-placeholder" aria-live="polite">
<span class="configuration-placeholder__icon"><mat-icon aria-hidden="true">checklist</mat-icon></span>
<h3>Confirmación</h3>
<p>La confirmación de los archivos se implementará en la siguiente fase.</p>
</div>
}
<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') {
<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" (click)="continue()">Continuar</button>
}
</div>
</footer>
</section>
+494
View File
@@ -0,0 +1,494 @@
:host {
display: block;
}
.upload-dialog {
background: #fff;
color: #081839;
padding: 28px 32px 24px;
}
.upload-dialog__header {
align-items: flex-start;
display: flex;
gap: 20px;
justify-content: space-between;
}
.upload-dialog__header h2 {
font-family: var(--font-heading);
font-size: 30px;
line-height: 1.15;
margin: 0;
}
.upload-dialog__description {
color: #7a7a7a;
font-size: 15px;
line-height: 1.5;
margin: 14px 0 0;
}
.upload-dialog__close {
color: #596273;
margin: -8px -10px 0 0;
}
.upload-steps {
align-items: center;
border-bottom: 1px solid #e3e7df;
color: #7a7a7a;
display: flex;
justify-content: center;
list-style: none;
margin: 24px 0 0;
padding: 0 0 20px;
}
.upload-steps li {
align-items: center;
display: flex;
font-size: 13px;
gap: 8px;
}
.upload-steps li + li::before {
background: #dfe3dc;
content: '';
height: 1px;
margin: 0 14px;
width: clamp(20px, 8vw, 70px);
}
.upload-steps__number {
align-items: center;
background: #f0f2ed;
border-radius: 50%;
display: inline-flex;
font-size: 12px;
height: 25px;
justify-content: center;
width: 25px;
}
.upload-steps__number mat-icon {
font-size: 16px;
height: 16px;
width: 16px;
}
.upload-steps__item--active {
color: #081839;
font-weight: 600;
}
.upload-steps__item--active .upload-steps__number {
background: #a8c243;
color: #081839;
}
.upload-steps__item--complete {
color: #71882b;
}
.upload-steps__item--complete .upload-steps__number {
background: #f0f3e8;
color: #71882b;
}
.upload-dialog__content {
padding: 18px 0 28px;
}
.source-options {
display: grid;
gap: 16px;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.source-card {
align-items: center;
background: #fff;
border: 1px solid #e3e7df;
border-radius: 9px;
color: #081839;
cursor: pointer;
display: flex;
gap: 16px;
min-height: 126px;
padding: 20px;
position: relative;
text-align: left;
transition:
background-color 0.16s ease,
border-color 0.16s ease;
}
.source-card:hover {
background: #fafbf7;
border-color: #c7d49a;
}
.source-card:focus-visible,
.upload-dialog__close:focus-visible,
.file-row__remove:focus-visible,
.upload-action:focus-visible {
outline: 3px solid rgb(168 194 67 / 65%);
outline-offset: 2px;
}
.source-card--selected {
background: #fbfcf6;
border: 2px solid #a8c243;
padding: 19px;
}
.source-card__icon {
align-items: center;
background: #f0f3e8;
border-radius: 8px;
color: #71882b;
display: inline-flex;
flex: 0 0 46px;
height: 46px;
justify-content: center;
}
.source-card__copy {
display: grid;
gap: 6px;
min-width: 0;
}
.source-card__title {
font-size: 16px;
font-weight: 600;
}
.source-card__description {
color: #7a7a7a;
font-size: 13px;
line-height: 1.45;
}
.source-card__check {
color: #71882b;
margin-left: auto;
}
.configuration-placeholder {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
min-height: 164px;
text-align: center;
}
.configuration-placeholder__icon {
align-items: center;
background: #f0f3e8;
border-radius: 50%;
color: #71882b;
display: inline-flex;
height: 48px;
justify-content: center;
width: 48px;
}
.configuration-placeholder h3 {
font-family: var(--font-heading);
font-size: 22px;
margin: 14px 0 6px;
}
.configuration-placeholder p {
color: #7a7a7a;
font-size: 14px;
line-height: 1.55;
margin: 0;
max-width: 460px;
}
.file-configuration {
padding-top: 18px;
}
.dropzone {
align-items: center;
background: #fcfdfb;
border: 1.5px dashed #cbd2c4;
border-radius: 10px;
display: flex;
flex-direction: column;
justify-content: center;
min-height: 244px;
padding: 24px;
text-align: center;
transition:
background-color 0.14s ease,
border-color 0.14s ease;
}
.dropzone--active {
background: #f5f8e9;
border-color: #a8c243;
border-style: solid;
}
.dropzone__icon {
color: #71882b;
font-size: 40px;
height: 40px;
width: 40px;
}
.dropzone__title {
font-size: 16px;
font-weight: 600;
margin: 14px 0 4px;
}
.dropzone__formats {
color: #7a7a7a;
font-size: 13px;
margin: 0 0 16px;
}
.select-files-button {
--mat-button-outlined-label-text-color: #081839;
--mat-button-outlined-outline-color: #d7dccf;
--mat-button-outlined-state-layer-color: transparent;
--mat-button-outlined-ripple-color: transparent;
background: #fff;
border: 1px solid var(--mat-button-outlined-outline-color);
transition: border-color 0.18s ease;
}
.upload-action--outlined:hover {
background: #f3f6e9;
border-color: #a8c243;
}
.upload-action--outlined:active {
background: #e8eed5;
}
.select-files-button mat-icon {
color: #5f9ea0;
margin: 0;
}
.visually-hidden {
clip: rect(0, 0, 0, 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
.file-messages {
background: #fffaf0;
border: 1px solid #ead8a7;
border-radius: 7px;
color: #634d13;
font-size: 13px;
line-height: 1.45;
list-style: none;
margin: 12px 0 0;
padding: 10px 14px;
}
.file-messages li + li {
margin-top: 4px;
}
.selected-files {
margin-top: 20px;
}
.selected-files__header {
align-items: center;
display: flex;
gap: 10px;
justify-content: space-between;
margin-bottom: 8px;
}
.selected-files__header h3 {
font-size: 15px;
font-weight: 600;
margin: 0;
}
.selected-files__count {
align-items: center;
background: #f0f3e8;
border-radius: 20px;
color: #52651d;
display: inline-flex;
font-size: 12px;
font-weight: 600;
height: 25px;
justify-content: center;
min-width: 25px;
padding: 0 7px;
}
.selected-files__list {
border: 1px solid #e7eae3;
border-radius: 8px;
list-style: none;
margin: 0;
max-height: 220px;
overflow-y: auto;
padding: 0;
}
.file-row {
align-items: center;
display: grid;
gap: 10px;
grid-template-columns: 22px minmax(0, 1fr) auto 40px;
min-height: 54px;
padding: 6px 8px 6px 12px;
}
.file-row + .file-row {
border-top: 1px solid #eef0eb;
}
.file-row__icon {
color: #71882b;
font-size: 20px;
height: 20px;
width: 20px;
}
.file-row__name {
font-size: 13px;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.file-row__size {
color: #737b6b;
font-size: 12px;
white-space: nowrap;
}
.file-row__remove {
color: #596273;
height: 36px;
line-height: 36px;
width: 36px;
}
.upload-dialog__footer {
align-items: center;
border-top: 1px solid #e3e7df;
display: grid;
gap: 10px;
grid-template-columns: minmax(0, 1fr) auto;
padding-top: 18px;
}
.action-cancel {
justify-self: start;
}
.upload-dialog__navigation {
align-items: center;
display: flex;
gap: 10px;
justify-self: end;
}
.upload-action {
border-radius: 8px;
font: inherit;
font-weight: 600;
min-height: 44px;
padding: 10px 18px;
transition: background-color 0.18s ease;
}
.action-cancel,
.action-back {
--mat-button-text-state-layer-color: transparent;
--mat-button-text-ripple-color: transparent;
}
.action-cancel {
--mat-button-text-label-text-color: #fff;
background: #7a7a7a;
}
.action-cancel:hover {
background: #696969;
}
.action-cancel:active {
background: #5d5d5d;
}
.action-back {
--mat-button-text-label-text-color: #081839;
background: #fff;
border: 1px solid #d7dccf;
}
.action-back:hover {
background: #f3f6e9;
border-color: #a8c243;
}
.action-back:active {
background: #e8eed5;
}
.action-continue {
--mat-button-filled-container-color: #6f821c;
--mat-button-filled-label-text-color: #f7f9ef;
--mat-button-filled-state-layer-color: transparent;
--mat-button-filled-ripple-color: transparent;
min-width: 124px;
}
.action-continue:hover:not(:disabled) {
--mat-button-filled-container-color: #809625;
}
.action-continue:active:not(:disabled) {
--mat-button-filled-container-color: #607216;
}
.action-continue:disabled {
--mat-button-filled-disabled-container-color: #e8ecdf;
--mat-button-filled-disabled-label-text-color: #9da38f;
--mat-button-filled-disabled-state-layer-color: transparent;
}
@media (max-width: 600px) {
.upload-dialog {
padding: 22px 20px 18px;
}
.upload-dialog__header h2 {
font-size: 26px;
}
.upload-dialog__description {
font-size: 14px;
margin-top: 12px;
}
.upload-steps {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.upload-steps li {
flex-direction: column;
font-size: 11px;
gap: 4px;
text-align: center;
}
.upload-steps li + li::before {
display: none;
}
.upload-steps__number {
height: 22px;
width: 22px;
}
.source-options {
grid-template-columns: 1fr;
}
.source-card {
min-height: 94px;
padding: 16px;
}
.source-card--selected {
padding: 15px;
}
.upload-dialog__content {
padding: 20px 0;
}
.dropzone {
min-height: 220px;
padding: 20px 12px;
}
.file-row {
gap: 6px;
grid-template-columns: 20px minmax(0, 1fr) auto 36px;
padding-left: 8px;
}
.file-row__name {
font-size: 12px;
}
.file-row__size {
font-size: 11px;
}
}
@media (max-width: 360px) {
.upload-dialog {
padding-inline: 16px;
}
.upload-steps li {
font-size: 10px;
}
.upload-dialog__footer {
gap: 4px;
}
.upload-dialog__navigation {
gap: 4px;
}
.action-cancel,
.action-back {
min-width: 56px;
padding-inline: 6px;
}
.action-continue {
min-width: 92px;
padding-inline: 10px;
}
}
@media (max-width: 300px) {
.upload-dialog__footer {
grid-template-columns: minmax(0, 1fr);
}
}
+129
View File
@@ -0,0 +1,129 @@
import { Component, signal } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
type UploadSource = 'file' | 'sql';
type UploadStep = 'source' | 'configuration' | 'confirmation';
@Component({
imports: [MatButtonModule, MatDialogModule, MatIconModule],
selector: 'app-information-upload-dialog',
styleUrl: './information-upload-dialog.scss',
templateUrl: './information-upload-dialog.html',
})
export class InformationUploadDialog {
readonly step = signal<UploadStep>('source');
readonly source = signal<UploadSource | null>(null);
readonly files = signal<File[]>([]);
readonly fileMessages = signal<string[]>([]);
readonly isDragOver = signal(false);
private dragDepth = 0;
private readonly allowedExtensions = new Set(['xlsx', 'csv', 'json', 'pdf']);
constructor(private readonly dialogRef: MatDialogRef<InformationUploadDialog>) {}
selectSource(source: UploadSource): void {
this.source.set(source);
}
continue(): void {
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');
}
}
back(): void {
if (this.step() === 'confirmation') this.step.set('configuration');
else if (this.step() === 'configuration') this.step.set('source');
}
close(): void {
this.dialogRef.close();
}
onFileSelection(event: Event): void {
const input = event.target as HTMLInputElement;
this.addFiles(input.files ? Array.from(input.files) : []);
input.value = '';
}
onDragEnter(event: DragEvent): void {
event.preventDefault();
this.dragDepth++;
this.isDragOver.set(true);
}
onDragOver(event: DragEvent): void {
event.preventDefault();
if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy';
}
onDragLeave(event: DragEvent): void {
event.preventDefault();
this.dragDepth = Math.max(0, this.dragDepth - 1);
if (this.dragDepth === 0) this.isDragOver.set(false);
}
onDrop(event: DragEvent): void {
event.preventDefault();
this.dragDepth = 0;
this.isDragOver.set(false);
this.addFiles(event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : []);
}
removeFile(fileToRemove: File): void {
this.files.update((files) => files.filter((file) => file !== fileToRemove));
}
formatFileSize(size: number): string {
if (size < 1024) return `${size} bytes`;
const units = ['KB', 'MB', 'GB'];
let value = size / 1024;
let unit = 0;
while (value >= 1024 && unit < units.length - 1) {
value /= 1024;
unit++;
}
return `${new Intl.NumberFormat('es-MX', { maximumFractionDigits: 1 }).format(value)} ${units[unit]}`;
}
fileIcon(file: File): string {
const extension = this.extensionOf(file.name);
if (extension === 'pdf') return 'picture_as_pdf';
if (extension === 'csv' || extension === 'xlsx') return 'table_chart';
return 'data_object';
}
private addFiles(incomingFiles: File[]): void {
const messages: string[] = [];
const accepted = [...this.files()];
for (const file of incomingFiles) {
const extension = this.extensionOf(file.name);
if (!this.allowedExtensions.has(extension)) {
messages.push(`${file.name} no fue agregado. Formato no compatible.`);
continue;
}
if (file.size === 0) {
messages.push(`${file.name} no fue agregado. El archivo está vacío.`);
continue;
}
if (accepted.some((existing) => existing.name === file.name && existing.size === file.size)) {
messages.push(`${file.name} ya se encuentra seleccionado.`);
continue;
}
accepted.push(file);
}
if (accepted.length !== this.files().length) this.files.set(accepted);
this.fileMessages.set(messages);
}
private extensionOf(fileName: string): string {
const finalDot = fileName.lastIndexOf('.');
return finalDot >= 0 ? fileName.slice(finalDot + 1).toLowerCase() : '';
}
}
+2 -2
View File
@@ -1,8 +1,8 @@
<!doctype html>
<html lang="en">
<html lang="es">
<head>
<meta charset="utf-8" />
<title>WebApp</title>
<title>Análisis de información | ISSSTELEON</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
+27 -19
View File
@@ -1,10 +1,17 @@
// Include theming for Angular Material with `mat.theme()`.
// This Sass mixin will define CSS variables that are used for styling Angular Material
// components according to the Material 3 design spec.
// Learn more about theming and how to use it for your application's
// custom components at https://material.angular.dev/guide/theming
@use '@angular/material' as mat;
:root {
--color-primary: #a8c243;
--color-text: #081839;
--color-text-secondary: #7a7a7a;
--color-background: #f7f8f6;
--color-surface: #ffffff;
--color-border: #e3e7df;
--color-step: #f0f3e8;
--font-body: 'Roboto', sans-serif;
--font-heading: 'Rajdhani', 'Roboto Condensed', 'Arial Narrow', sans-serif;
}
html {
height: 100%;
@include mat.theme(
@@ -20,20 +27,21 @@ html {
}
body {
// Default the application to a light color theme. This can be changed to
// `dark` to enable the dark color theme, or to `light dark` to defer to the
// user's system settings.
color-scheme: light;
// Set a default background, font and text colors for the application using
// Angular Material's system-level CSS variables. Learn more about these
// variables at https://material.angular.dev/guide/system-variables
background-color: var(--mat-sys-surface);
color: var(--mat-sys-on-surface);
font: var(--mat-sys-body-medium);
// Reset the user agent margin.
background: var(--color-background);
color: var(--color-text);
font-family: var(--font-body);
margin: 0;
height: 100%;
min-height: 100%;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
.information-upload-dialog-panel .mat-mdc-dialog-surface {
border-radius: 12px;
padding: 0;
}
/* You can add global styles to this file, and also import other style files */