feat(export): adicionar exportação Excel do ranking com barra de progresso
- Novo endpoint GET /api/v1/ranking/exportar/excel - Exporta apenas consultores com pontuação > 0 - Usa xlsxwriter para geração rápida (~40s para 300k registros) - Layout profissional com formatação, filtros e cores condicionais - Barra de progresso real no frontend com dois estados: - Animação indeterminada durante geração no servidor - Progresso real durante download do arquivo - Botão de exportação integrado ao layout do sistema - Suporte a cancelamento da exportação
This commit is contained in:
196
frontend/src/components/ExportProgress.css
Normal file
196
frontend/src/components/ExportProgress.css
Normal file
@@ -0,0 +1,196 @@
|
||||
.export-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.85);
|
||||
backdrop-filter: blur(8px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1100;
|
||||
animation: fadeIn 200ms ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.export-modal {
|
||||
background: linear-gradient(155deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.95));
|
||||
border: 1px solid var(--stroke);
|
||||
border-radius: 20px;
|
||||
padding: 2rem 2.5rem;
|
||||
min-width: 320px;
|
||||
max-width: 400px;
|
||||
text-align: center;
|
||||
box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 40px rgba(34, 197, 94, 0.1);
|
||||
animation: slideUp 300ms ease;
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.export-icon {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
margin: 0 auto 1rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.8rem;
|
||||
background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.15));
|
||||
border: 1px solid rgba(34, 197, 94, 0.3);
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.export-icon.generating {
|
||||
animation: spin 2s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.export-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 0.5rem;
|
||||
background: linear-gradient(120deg, #86efac, #22c55e);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
.export-status {
|
||||
font-size: 0.9rem;
|
||||
color: var(--muted);
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.progress-container {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 8px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #22c55e, #16a34a);
|
||||
border-radius: 4px;
|
||||
transition: width 150ms ease;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.progress-fill::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(255, 255, 255, 0.3),
|
||||
transparent
|
||||
);
|
||||
animation: shimmer 1.5s infinite;
|
||||
}
|
||||
|
||||
@keyframes shimmer {
|
||||
0% { transform: translateX(-100%); }
|
||||
100% { transform: translateX(100%); }
|
||||
}
|
||||
|
||||
.progress-fill.complete {
|
||||
background: linear-gradient(90deg, #22c55e, #16a34a);
|
||||
}
|
||||
|
||||
.progress-fill.complete::after {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.progress-fill.error {
|
||||
background: linear-gradient(90deg, #ef4444, #dc2626);
|
||||
}
|
||||
|
||||
.progress-fill.indeterminate {
|
||||
width: 30%;
|
||||
animation: indeterminate 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes indeterminate {
|
||||
0% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
50% {
|
||||
transform: translateX(230%);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
}
|
||||
|
||||
.progress-generating {
|
||||
font-size: 0.85rem;
|
||||
color: var(--muted);
|
||||
animation: blink 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
0%, 100% { opacity: 0.5; }
|
||||
50% { opacity: 1; }
|
||||
}
|
||||
|
||||
.progress-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.progress-percent {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
color: #86efac;
|
||||
}
|
||||
|
||||
.progress-bytes {
|
||||
font-size: 0.8rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.export-cancel {
|
||||
padding: 0.6rem 1.5rem;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 1px solid var(--stroke);
|
||||
color: var(--text);
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
font-size: 0.9rem;
|
||||
transition: all 150ms ease;
|
||||
}
|
||||
|
||||
.export-cancel:hover {
|
||||
background: rgba(239, 68, 68, 0.2);
|
||||
border-color: rgba(239, 68, 68, 0.4);
|
||||
color: #fca5a5;
|
||||
}
|
||||
82
frontend/src/components/ExportProgress.jsx
Normal file
82
frontend/src/components/ExportProgress.jsx
Normal file
@@ -0,0 +1,82 @@
|
||||
import './ExportProgress.css';
|
||||
|
||||
function ExportProgress({ progress, status, onCancel }) {
|
||||
const formatBytes = (bytes) => {
|
||||
if (bytes === 0) return '0 B';
|
||||
const k = 1024;
|
||||
const sizes = ['B', 'KB', 'MB', 'GB'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
||||
};
|
||||
|
||||
const isGenerating = status === 'preparing' || (status === 'downloading' && progress.total === 0);
|
||||
const isDownloading = status === 'downloading' && progress.total > 0;
|
||||
|
||||
const getStatusText = () => {
|
||||
if (isGenerating) {
|
||||
return 'Gerando arquivo no servidor...';
|
||||
}
|
||||
switch (status) {
|
||||
case 'downloading':
|
||||
return 'Baixando arquivo...';
|
||||
case 'complete':
|
||||
return 'Concluído!';
|
||||
case 'error':
|
||||
return 'Erro na exportação';
|
||||
default:
|
||||
return 'Exportando...';
|
||||
}
|
||||
};
|
||||
|
||||
const percent = Math.min(Math.round(progress.percent || 0), 100);
|
||||
const downloaded = progress.loaded || 0;
|
||||
const total = progress.total || 0;
|
||||
|
||||
return (
|
||||
<div className="export-overlay">
|
||||
<div className="export-modal">
|
||||
<div className={`export-icon ${isGenerating ? 'generating' : ''}`}>
|
||||
{status === 'complete' ? '✓' : status === 'error' ? '✕' : '📊'}
|
||||
</div>
|
||||
|
||||
<h3 className="export-title">Exportação Excel</h3>
|
||||
<p className="export-status">{getStatusText()}</p>
|
||||
|
||||
<div className="progress-container">
|
||||
<div className="progress-bar">
|
||||
{isGenerating ? (
|
||||
<div className="progress-fill indeterminate" />
|
||||
) : (
|
||||
<div
|
||||
className={`progress-fill ${status === 'complete' ? 'complete' : ''} ${status === 'error' ? 'error' : ''}`}
|
||||
style={{ width: `${percent}%` }}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="progress-info">
|
||||
{isGenerating ? (
|
||||
<span className="progress-generating">Processando ~300k registros...</span>
|
||||
) : (
|
||||
<>
|
||||
<span className="progress-percent">{percent}%</span>
|
||||
{total > 0 && (
|
||||
<span className="progress-bytes">
|
||||
{formatBytes(downloaded)} / {formatBytes(total)}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{status !== 'complete' && status !== 'error' && (
|
||||
<button className="export-cancel" onClick={onCancel}>
|
||||
Cancelar
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ExportProgress;
|
||||
Reference in New Issue
Block a user