From 0795a971dfc77699170d03e46f96c6ddeb612392 Mon Sep 17 00:00:00 2001 From: Angel Capetillo Zavala Date: Thu, 24 Sep 2026 13:17:21 -0600 Subject: [PATCH] =?UTF-8?q?Refactor:=20Reorganizaci=C3=B3n=20de=20archivos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/_upload-button.scss | 13 + src/app/app.spec.ts | 7 +- src/app/file-configuration.html | 20 ++ src/app/file-configuration.scss | 92 +++++++ src/app/file-configuration.ts | 49 ++++ src/app/file-confirmation.html | 6 + src/app/file-confirmation.scss | 11 + src/app/file-confirmation.ts | 15 ++ src/app/file-list.html | 20 ++ src/app/file-list.scss | 87 +++++++ src/app/file-list.ts | 18 ++ src/app/file-selection.ts | 42 +++ src/app/information-upload-dialog.html | 72 +----- src/app/information-upload-dialog.scss | 313 ++--------------------- src/app/information-upload-dialog.ts | 91 +------ src/app/processing-status.scss | 12 +- src/app/source-selection.html | 12 + src/app/source-selection.scss | 63 +++++ src/app/source-selection.ts | 15 ++ src/app/sql-connection-config.scss | 12 +- src/app/sql-connection-confirmation.scss | 14 +- src/styles.scss | 3 + 22 files changed, 523 insertions(+), 464 deletions(-) create mode 100644 src/app/_upload-button.scss create mode 100644 src/app/file-configuration.html create mode 100644 src/app/file-configuration.scss create mode 100644 src/app/file-configuration.ts create mode 100644 src/app/file-confirmation.html create mode 100644 src/app/file-confirmation.scss create mode 100644 src/app/file-confirmation.ts create mode 100644 src/app/file-list.html create mode 100644 src/app/file-list.scss create mode 100644 src/app/file-list.ts create mode 100644 src/app/file-selection.ts create mode 100644 src/app/source-selection.html create mode 100644 src/app/source-selection.scss create mode 100644 src/app/source-selection.ts diff --git a/src/app/_upload-button.scss b/src/app/_upload-button.scss new file mode 100644 index 0000000..873ee16 --- /dev/null +++ b/src/app/_upload-button.scss @@ -0,0 +1,13 @@ +@mixin base { + border-radius: 8px; + font: inherit; + font-weight: 600; + min-height: 44px; + padding: 10px 18px; + transition: background-color 0.18s ease; +} + +@mixin focus { + outline: 3px solid rgb(168 194 67 / 65%); + outline-offset: 2px; +} diff --git a/src/app/app.spec.ts b/src/app/app.spec.ts index 35767cc..e56b414 100644 --- a/src/app/app.spec.ts +++ b/src/app/app.spec.ts @@ -115,10 +115,9 @@ describe('App', () => { 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); + const drop = new Event('drop', { bubbles: true, cancelable: true }); + Object.defineProperty(drop, 'dataTransfer', { value: { files: [jsonFile] } }); + overlay.querySelector('.dropzone')!.dispatchEvent(drop); detectDialogChanges(); fixture.detectChanges(); expect(overlay.querySelectorAll('.file-row')).toHaveLength(3); diff --git a/src/app/file-configuration.html b/src/app/file-configuration.html new file mode 100644 index 0000000..d452e2b --- /dev/null +++ b/src/app/file-configuration.html @@ -0,0 +1,20 @@ +
+ +

Arrastra tus archivos aquí

+

Excel · CSV · JSON · PDF

+ + +
+ +@if (messages.length > 0) { + +} + +@if (files.length > 0) { + +} diff --git a/src/app/file-configuration.scss b/src/app/file-configuration.scss new file mode 100644 index 0000000..374fb69 --- /dev/null +++ b/src/app/file-configuration.scss @@ -0,0 +1,92 @@ +@use 'upload-button' as button; + +:host { display: block; } +.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; +} +.dropzone--active { + background: #f5f8e9; + border-color: var(--color-primary); + 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: var(--color-text-secondary); + font-size: 13px; + margin: 0 0 16px; +} +.select-files-button { + --mat-button-outlined-label-text-color: var(--color-text); + --mat-button-outlined-outline-color: var(--color-border-subtle); + --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; +} +.select-files-button:hover { + background: var(--color-surface-hover); + border-color: var(--color-primary); +} +.select-files-button: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; +} + +.upload-action { + @include button.base; +} +.select-files-button:focus-visible { + @include button.focus; +} +@media (max-width: 600px) { + .dropzone { + min-height: 220px; + padding: 20px 12px; + } +} diff --git a/src/app/file-configuration.ts b/src/app/file-configuration.ts new file mode 100644 index 0000000..3569f88 --- /dev/null +++ b/src/app/file-configuration.ts @@ -0,0 +1,49 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; +import { MatIconModule } from '@angular/material/icon'; +import { FileListComponent } from './file-list'; + +@Component({ + imports: [MatButtonModule, MatIconModule, FileListComponent], + selector: 'app-file-configuration', + styleUrl: './file-configuration.scss', + templateUrl: './file-configuration.html', +}) +export class FileConfigurationComponent { + @Input({ required: true }) files: File[] = []; + @Input() messages: string[] = []; + @Output() readonly filesAdded = new EventEmitter(); + @Output() readonly removeRequested = new EventEmitter(); + isDragOver = false; + private dragDepth = 0; + + onFileSelection(event: Event): void { + const input = event.target as HTMLInputElement; + this.filesAdded.emit(input.files ? Array.from(input.files) : []); + input.value = ''; + } + + onDragEnter(event: DragEvent): void { + event.preventDefault(); + this.dragDepth++; + this.isDragOver = 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 = false; + } + + onDrop(event: DragEvent): void { + event.preventDefault(); + this.dragDepth = 0; + this.isDragOver = false; + this.filesAdded.emit(event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : []); + } +} diff --git a/src/app/file-confirmation.html b/src/app/file-confirmation.html new file mode 100644 index 0000000..15a8322 --- /dev/null +++ b/src/app/file-confirmation.html @@ -0,0 +1,6 @@ +
+
Fuente
Archivo
+
Archivos seleccionados
{{ files.length }}
+
Tamaño total
{{ formatFileSize(totalSize) }}
+
+ diff --git a/src/app/file-confirmation.scss b/src/app/file-confirmation.scss new file mode 100644 index 0000000..c45671d --- /dev/null +++ b/src/app/file-confirmation.scss @@ -0,0 +1,11 @@ +:host { display: block; } +.confirmation-summary { + display: grid; + gap: 10px; + grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); + margin: 0; + padding: 0; +} +.confirmation-summary div { background: #fcfdfb; border: 1px solid #e7eae3; border-radius: 8px; min-width: 0; padding: 10px 12px; } +.confirmation-summary dt { color: var(--color-text-secondary); font-size: 12px; } +.confirmation-summary dd { font-size: 15px; font-weight: 600; margin: 4px 0 0; overflow-wrap: anywhere; } diff --git a/src/app/file-confirmation.ts b/src/app/file-confirmation.ts new file mode 100644 index 0000000..2ea8c6d --- /dev/null +++ b/src/app/file-confirmation.ts @@ -0,0 +1,15 @@ +import { Component, Input } from '@angular/core'; +import { FileListComponent } from './file-list'; +import { formatFileSize } from './file-selection'; + +@Component({ + imports: [FileListComponent], + selector: 'app-file-confirmation', + styleUrl: './file-confirmation.scss', + templateUrl: './file-confirmation.html', +}) +export class FileConfirmationComponent { + @Input({ required: true }) files: File[] = []; + @Input({ required: true }) totalSize = 0; + readonly formatFileSize = formatFileSize; +} diff --git a/src/app/file-list.html b/src/app/file-list.html new file mode 100644 index 0000000..611882b --- /dev/null +++ b/src/app/file-list.html @@ -0,0 +1,20 @@ +
+
+

{{ readonly ? 'Archivos a procesar' : 'Archivos seleccionados' }}

+ {{ files.length }} +
+
    + @for (file of files; track file.name + ':' + file.size) { +
  • + + {{ file.name }} + {{ formatFileSize(file.size) }} + @if (!readonly) { + + } +
  • + } +
+
diff --git a/src/app/file-list.scss b/src/app/file-list.scss new file mode 100644 index 0000000..5314b40 --- /dev/null +++ b/src/app/file-list.scss @@ -0,0 +1,87 @@ +@use 'upload-button' as button; + +:host { display: block; } +.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: var(--color-step); + 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--readonly { grid-template-columns: 22px minmax(0, 1fr) auto; padding-right: 12px; } +.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; +} + +.file-row__remove:focus-visible { + @include button.focus; +} +@media (max-width: 600px) { + .file-row { + gap: 6px; + grid-template-columns: 20px minmax(0, 1fr) auto 36px; + padding-left: 8px; + } + .file-row--readonly { grid-template-columns: 20px minmax(0, 1fr) auto; } + .file-row__name { font-size: 12px; } + .file-row__size { font-size: 11px; } +} diff --git a/src/app/file-list.ts b/src/app/file-list.ts new file mode 100644 index 0000000..9af6c75 --- /dev/null +++ b/src/app/file-list.ts @@ -0,0 +1,18 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; +import { MatIconModule } from '@angular/material/icon'; +import { fileIcon, formatFileSize } from './file-selection'; + +@Component({ + imports: [MatButtonModule, MatIconModule], + selector: 'app-file-list', + styleUrl: './file-list.scss', + templateUrl: './file-list.html', +}) +export class FileListComponent { + @Input({ required: true }) files: File[] = []; + @Input() readonly = false; + @Output() readonly removeRequested = new EventEmitter(); + readonly fileIcon = fileIcon; + readonly formatFileSize = formatFileSize; +} diff --git a/src/app/file-selection.ts b/src/app/file-selection.ts new file mode 100644 index 0000000..04e3861 --- /dev/null +++ b/src/app/file-selection.ts @@ -0,0 +1,42 @@ +const allowedExtensions = new Set(['xlsx', 'csv', 'json', 'pdf']); + +function extensionOf(fileName: string): string { + const finalDot = fileName.lastIndexOf('.'); + return finalDot >= 0 ? fileName.slice(finalDot + 1).toLowerCase() : ''; +} + +export function selectFiles(selected: File[], incomingFiles: File[]): { files: File[]; messages: string[] } { + const messages: string[] = []; + const files = [...selected]; + for (const file of incomingFiles) { + if (!allowedExtensions.has(extensionOf(file.name))) { + messages.push(`${file.name} no fue agregado. Formato no compatible.`); + } else if (file.size === 0) { + messages.push(`${file.name} no fue agregado. El archivo está vacío.`); + } else if (files.some((existing) => existing.name === file.name && existing.size === file.size)) { + messages.push(`${file.name} ya se encuentra seleccionado.`); + } else { + files.push(file); + } + } + return { files, messages }; +} + +export function 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]}`; +} + +export function fileIcon(file: File): string { + const extension = extensionOf(file.name); + if (extension === 'pdf') return 'picture_as_pdf'; + if (extension === 'csv' || extension === 'xlsx') return 'table_chart'; + return 'data_object'; +} diff --git a/src/app/information-upload-dialog.html b/src/app/information-upload-dialog.html index 0cb07f6..2d9d6cc 100644 --- a/src/app/information-upload-dialog.html +++ b/src/app/information-upload-dialog.html @@ -24,59 +24,12 @@ @if (step() === 'source') {

Selecciona cómo deseas proporcionar los datos.

-
- - -
+
} @else if (step() === 'configuration' && source() === 'file') {

Selecciona los archivos que deseas procesar.

-
- -

Arrastra tus archivos aquí

-

Excel · CSV · JSON · PDF

- - -
- - @if (fileMessages().length > 0) { -
    - @for (message of fileMessages(); track $index) {
  • {{ message }}
  • } -
- } - - @if (files().length > 0) { -
-
-

Archivos seleccionados

- {{ files().length }} -
-
    - @for (file of files(); track file.name + ':' + file.size) { -
  • - - {{ file.name }} - {{ formatFileSize(file.size) }} - -
  • - } -
-
- } +
} @else if (step() === 'configuration') {

Configura la fuente seleccionada.

@@ -91,26 +44,7 @@ } @else {

Revisa la información antes de iniciar el procesamiento.

-
-
Fuente
Archivo
-
Archivos seleccionados
{{ files().length }}
-
Tamaño total
{{ formatFileSize(totalFileSize()) }}
-
-
-
-

Archivos a procesar

- {{ files().length }} -
-
    - @for (file of files(); track file.name + ':' + file.size) { -
  • - - {{ file.name }} - {{ formatFileSize(file.size) }} -
  • - } -
-
+
} diff --git a/src/app/information-upload-dialog.scss b/src/app/information-upload-dialog.scss index fd95de3..8a7142e 100644 --- a/src/app/information-upload-dialog.scss +++ b/src/app/information-upload-dialog.scss @@ -1,10 +1,12 @@ +@use 'upload-button' as button; + :host { display: block; } .upload-dialog { background: #fff; - color: #081839; + color: var(--color-text); max-height: 100dvh; overflow: auto; padding: 28px 32px 24px; @@ -22,7 +24,7 @@ margin: 0; } .upload-dialog__description { - color: #7a7a7a; + color: var(--color-text-secondary); font-size: 15px; line-height: 1.5; margin: 14px 0 0; @@ -33,8 +35,8 @@ } .upload-steps { align-items: center; - border-bottom: 1px solid #e3e7df; - color: #7a7a7a; + border-bottom: 1px solid var(--color-border); + color: var(--color-text-secondary); display: flex; justify-content: center; list-style: none; @@ -70,274 +72,26 @@ width: 16px; } .upload-steps__item--active { - color: #081839; + color: var(--color-text); font-weight: 600; } .upload-steps__item--active .upload-steps__number { - background: #a8c243; - color: #081839; + background: var(--color-primary); + color: var(--color-text); } .upload-steps__item--complete { color: #71882b; } .upload-steps__item--complete .upload-steps__number { - background: #f0f3e8; + background: var(--color-step); 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; -} -.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; -} -.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; -} -.confirmation-summary { - display: grid; - gap: 10px; - grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); - margin: 0; - padding: 0; -} -.confirmation-summary div { background: #fcfdfb; border: 1px solid #e7eae3; border-radius: 8px; min-width: 0; padding: 10px 12px; } -.confirmation-summary dt { color: #7a7a7a; font-size: 12px; } -.confirmation-summary dd { font-size: 15px; font-weight: 600; margin: 4px 0 0; overflow-wrap: anywhere; } -.file-row--readonly { grid-template-columns: 22px minmax(0, 1fr) auto; padding-right: 12px; } -.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; -} .upload-dialog__footer { align-items: center; - border-top: 1px solid #e3e7df; + border-top: 1px solid var(--color-border); display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; @@ -353,12 +107,7 @@ 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; + @include button.base; } .action-cancel, .action-back { @@ -367,22 +116,22 @@ } .action-cancel { --mat-button-text-label-text-color: #fff; - background: #7a7a7a; + background: var(--color-text-secondary); } .action-cancel:hover { background: #696969; } .action-back { - --mat-button-text-label-text-color: #081839; + --mat-button-text-label-text-color: var(--color-text); background: #fff; - border: 1px solid #d7dccf; + border: 1px solid var(--color-border-subtle); } .action-back:hover { - background: #f3f6e9; - border-color: #a8c243; + background: var(--color-surface-hover); + border-color: var(--color-primary); } .action-continue { - --mat-button-filled-container-color: #6f821c; + --mat-button-filled-container-color: var(--color-primary-action); --mat-button-filled-label-text-color: #f7f9ef; --mat-button-filled-state-layer-color: transparent; --mat-button-filled-ripple-color: transparent; @@ -424,31 +173,9 @@ 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--readonly { grid-template-columns: 20px minmax(0, 1fr) auto; } - .file-row__name { font-size: 12px; } - .file-row__size { font-size: 11px; } } @media (max-width: 360px) { @@ -461,3 +188,7 @@ } .action-continue { min-width: 92px; padding-inline: 10px; } } + +.upload-dialog__close:focus-visible, .upload-action:focus-visible { + @include button.focus; +} diff --git a/src/app/information-upload-dialog.ts b/src/app/information-upload-dialog.ts index 4ccfb68..8507507 100644 --- a/src/app/information-upload-dialog.ts +++ b/src/app/information-upload-dialog.ts @@ -5,13 +5,16 @@ import { MatIconModule } from '@angular/material/icon'; import { SqlConnectionConfig, SqlConnectionConfigComponent } from './sql-connection-config'; import { SqlConnectionConfirmationComponent, SqlConnectionVerificationState } from './sql-connection-confirmation'; import { ProcessingStatusComponent } from './processing-status'; +import { SourceSelectionComponent, UploadSource } from './source-selection'; +import { FileConfigurationComponent } from './file-configuration'; +import { FileConfirmationComponent } from './file-confirmation'; +import { formatFileSize, selectFiles } from './file-selection'; -type UploadSource = 'file' | 'sql'; type UploadStep = 'source' | 'configuration' | 'confirmation'; export type ProcessingState = 'processing' | 'success' | 'error'; @Component({ - imports: [MatButtonModule, MatDialogModule, MatIconModule, SqlConnectionConfigComponent, SqlConnectionConfirmationComponent, ProcessingStatusComponent], + imports: [MatButtonModule, MatDialogModule, MatIconModule, SqlConnectionConfigComponent, SqlConnectionConfirmationComponent, ProcessingStatusComponent, SourceSelectionComponent, FileConfigurationComponent, FileConfirmationComponent], selector: 'app-information-upload-dialog', styleUrl: './information-upload-dialog.scss', templateUrl: './information-upload-dialog.html', @@ -22,15 +25,12 @@ export class InformationUploadDialog implements OnDestroy { readonly files = signal([]); readonly totalFileSize = computed(() => this.files().reduce((total, file) => total + file.size, 0)); readonly fileMessages = signal([]); - readonly isDragOver = signal(false); readonly sqlConfig = signal({ host: '', port: '', database: '', username: '', password: '' }); readonly sqlConfigValid = signal(false); readonly sqlVerificationState = signal('idle'); readonly processingState = signal(null); readonly processingProgress = signal(0); - private dragDepth = 0; - private readonly allowedExtensions = new Set(['xlsx', 'csv', 'json', 'pdf']); private verifiedSqlConfig: SqlConnectionConfig | null = null; private verificationTimer: ReturnType | null = null; private processingTimer: ReturnType | null = null; @@ -142,86 +142,15 @@ export class InformationUploadDialog implements OnDestroy { this.processingTimer = null; } - 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]}`; - } + readonly formatFileSize = formatFileSize; - 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() : ''; + addFiles(incomingFiles: File[]): void { + const selection = selectFiles(this.files(), incomingFiles); + if (selection.files.length !== this.files().length) this.files.set(selection.files); + this.fileMessages.set(selection.messages); } } diff --git a/src/app/processing-status.scss b/src/app/processing-status.scss index a98076d..d496375 100644 --- a/src/app/processing-status.scss +++ b/src/app/processing-status.scss @@ -2,7 +2,7 @@ .processing { align-items: center; background: #fff; - color: #081839; + color: var(--color-text); display: flex; justify-content: center; min-height: min(500px, 100dvh); @@ -11,23 +11,23 @@ } .processing__active, .processing__success { margin: auto; max-width: 520px; width: 100%; } .processing h2 { font-family: var(--font-heading); font-size: clamp(24px, 4vw, 30px); line-height: 1.2; margin: 0; } -.processing__intro, .processing__success p { color: #7a7a7a; font-size: 15px; line-height: 1.55; margin: 14px 0 30px; } +.processing__intro, .processing__success p { color: var(--color-text-secondary); font-size: 15px; line-height: 1.55; margin: 14px 0 30px; } .processing__meter { align-items: center; display: flex; gap: 14px; } .processing__meter mat-progress-bar { --mat-progress-bar-active-indicator-color: #71882b; --mat-progress-bar-track-color: #e9eddf; flex: 1; } -.processing__percentage { color: #081839; font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; text-align: right; } +.processing__percentage { color: var(--color-text); font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; text-align: right; } .processing__current { color: #52651d; font-size: 15px; font-weight: 600; margin: 18px 0 26px; } .processing__stages { display: grid; gap: 14px; list-style: none; margin: 0 auto; max-width: 320px; padding: 0; text-align: left; } .processing__stages li { align-items: center; display: flex; gap: 10px; font-size: 14px; } .processing__stages mat-icon { flex: 0 0 20px; font-size: 20px; height: 20px; width: 20px; } .processing__stage--complete { color: #71882b; } -.processing__stage--active { color: #081839; font-weight: 600; } +.processing__stage--active { color: var(--color-text); font-weight: 600; } .processing__stage--pending { color: #858585; } .processing__note { color: #858585; font-size: 13px; line-height: 1.5; margin: 30px auto 0; max-width: 300px; } .processing__success { padding: 28px 0; } -.processing__success-icon { align-items: center; background: #f0f3e8; border-radius: 50%; color: #71882b; display: inline-flex; height: 64px; justify-content: center; margin-bottom: 22px; width: 64px; } +.processing__success-icon { align-items: center; background: var(--color-step); border-radius: 50%; color: #71882b; display: inline-flex; height: 64px; justify-content: center; margin-bottom: 22px; width: 64px; } .processing__success-icon mat-icon { font-size: 34px; height: 34px; width: 34px; } .processing__success p { margin-bottom: 28px; } -.processing__finish { --mat-button-filled-container-color: #6f821c; --mat-button-filled-label-text-color: #f7f9ef; --mat-button-filled-state-layer-color: transparent; border-radius: 8px; font-weight: 600; min-height: 46px; min-width: 150px; } +.processing__finish { --mat-button-filled-container-color: var(--color-primary-action); --mat-button-filled-label-text-color: #f7f9ef; --mat-button-filled-state-layer-color: transparent; border-radius: 8px; font-weight: 600; min-height: 46px; min-width: 150px; } .processing__finish:hover { --mat-button-filled-container-color: #809625; } .visually-hidden { clip: rect(0, 0, 0, 0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; } @media (max-width: 480px) { .processing { min-height: min(440px, 100dvh); padding: 28px 4px; } .processing__intro { font-size: 14px; } .processing__stages { gap: 12px; } } diff --git a/src/app/source-selection.html b/src/app/source-selection.html new file mode 100644 index 0000000..a84cd0d --- /dev/null +++ b/src/app/source-selection.html @@ -0,0 +1,12 @@ +
+ + +
diff --git a/src/app/source-selection.scss b/src/app/source-selection.scss new file mode 100644 index 0000000..66915b4 --- /dev/null +++ b/src/app/source-selection.scss @@ -0,0 +1,63 @@ +@use 'upload-button' as button; + +:host { display: block; } +.source-options { + display: grid; + gap: 16px; + grid-template-columns: repeat(2, minmax(0, 1fr)); +} +.source-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; +} +.source-card:focus-visible { + @include button.focus; +} +.source-card--selected { + background: #fbfcf6; + border: 2px solid var(--color-primary); + padding: 19px; +} +.source-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; +} +.source-card__copy { + display: grid; + gap: 6px; + min-width: 0; +} +.source-card__title { + font-size: 16px; + font-weight: 600; +} +.source-card__description { + color: var(--color-text-secondary); + font-size: 13px; + line-height: 1.45; +} +.source-card__check { + color: #71882b; + margin-left: auto; +} +@media (max-width: 600px) { + .source-options { grid-template-columns: 1fr; } + .source-card { min-height: 94px; padding: 16px; } + .source-card--selected { padding: 15px; } +} diff --git a/src/app/source-selection.ts b/src/app/source-selection.ts new file mode 100644 index 0000000..a0487e3 --- /dev/null +++ b/src/app/source-selection.ts @@ -0,0 +1,15 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { MatIconModule } from '@angular/material/icon'; + +export type UploadSource = 'file' | 'sql'; + +@Component({ + imports: [MatIconModule], + selector: 'app-source-selection', + styleUrl: './source-selection.scss', + templateUrl: './source-selection.html', +}) +export class SourceSelectionComponent { + @Input() source: UploadSource | null = null; + @Output() readonly sourceChange = new EventEmitter(); +} diff --git a/src/app/sql-connection-config.scss b/src/app/sql-connection-config.scss index 3fd36c2..101f082 100644 --- a/src/app/sql-connection-config.scss +++ b/src/app/sql-connection-config.scss @@ -1,28 +1,28 @@ :host { display: block; min-width: 0; } .sql-config { display: grid; gap: 2px; min-width: 0; } -.sql-config__hint { color: #7a7a7a; font-size: 14px; margin: 0 0 10px; } +.sql-config__hint { color: var(--color-text-secondary); font-size: 14px; margin: 0 0 10px; } .sql-config__host-row { display: grid; gap: 12px; grid-template-columns: minmax(0, 2.5fr) minmax(130px, 1fr); } mat-form-field { - --mat-form-field-outlined-focus-outline-color: #a8c243; + --mat-form-field-outlined-focus-outline-color: var(--color-primary); --mat-form-field-outlined-focus-label-text-color: #71882b; --mat-form-field-outlined-label-text-color: #596273; min-width: 0; width: 100%; } -mat-form-field input { color: #081839; } +mat-form-field input { color: var(--color-text); } .password-toggle { - --mat-icon-button-icon-color: #7a7a7a; + --mat-icon-button-icon-color: var(--color-text-secondary); --mat-icon-button-state-layer-color: transparent; --mat-icon-button-ripple-color: transparent; background: transparent; border: 0; border-radius: 50%; box-shadow: none; - color: #7a7a7a; + color: var(--color-text-secondary); opacity: 0.82; transition: color 120ms ease, opacity 120ms ease; } .password-toggle:hover { background: transparent; color: #596273; opacity: 1; } .password-toggle:active { background: transparent; color: #4d586a; } -.password-toggle:focus-visible { outline: 2px solid #a8c243; outline-offset: -3px; } +.password-toggle:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -3px; } @media (max-width: 560px) { .sql-config__host-row { grid-template-columns: minmax(0, 1fr); gap: 2px; } } diff --git a/src/app/sql-connection-confirmation.scss b/src/app/sql-connection-confirmation.scss index fdee929..9247823 100644 --- a/src/app/sql-connection-confirmation.scss +++ b/src/app/sql-connection-confirmation.scss @@ -12,8 +12,8 @@ min-width: 0; padding: 10px 12px; } -.sql-summary dt { color: #7a7a7a; font-size: 12px; } -.sql-summary dd { color: #081839; font-size: 15px; font-weight: 600; margin: 4px 0 0; overflow-wrap: anywhere; } +.sql-summary dt { color: var(--color-text-secondary); font-size: 12px; } +.sql-summary dd { color: var(--color-text); font-size: 15px; font-weight: 600; margin: 4px 0 0; overflow-wrap: anywhere; } .connection-check { align-items: center; background: #fcfdfb; @@ -25,16 +25,16 @@ margin-top: 14px; padding: 12px 14px; } -.connection-check h3 { color: #081839; font-size: 14px; font-weight: 600; margin: 0; } -.connection-check p { color: #7a7a7a; font-size: 13px; margin: 4px 0 0; } +.connection-check h3 { color: var(--color-text); font-size: 14px; font-weight: 600; margin: 0; } +.connection-check p { color: var(--color-text-secondary); font-size: 13px; margin: 4px 0 0; } .connection-check__status { align-items: center; display: flex; gap: 7px; min-height: 20px; } .connection-check__status p { margin: 4px 0 0; } .connection-check__spinner { --mat-progress-spinner-active-indicator-color: #71882b; flex: 0 0 auto; } .connection-check__success { color: #71882b; } -.connection-check__error { color: #7a7a7a; } +.connection-check__error { color: var(--color-text-secondary); } .connection-check__action { align-items: flex-end; display: flex; flex-direction: column; gap: 3px; } -.connection-check__action button { --mat-button-outlined-label-text-color: #596273; --mat-button-outlined-outline-color: #d7dccf; white-space: nowrap; } -.connection-check__action span { color: #7a7a7a; font-size: 11px; } +.connection-check__action button { --mat-button-outlined-label-text-color: #596273; --mat-button-outlined-outline-color: var(--color-border-subtle); white-space: nowrap; } +.connection-check__action span { color: var(--color-text-secondary); font-size: 11px; } @media (max-width: 760px) { .sql-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } } @media (max-width: 480px) { .sql-summary { grid-template-columns: minmax(0, 1fr); } diff --git a/src/styles.scss b/src/styles.scss index f91119b..a16e42c 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -8,6 +8,9 @@ --color-surface: #ffffff; --color-border: #e3e7df; --color-step: #f0f3e8; + --color-border-subtle: #d7dccf; + --color-surface-hover: #f3f6e9; + --color-primary-action: #6f821c; --font-body: 'Roboto', sans-serif; --font-heading: 'Rajdhani', 'Roboto Condensed', 'Arial Narrow', sans-serif; }