feat(ui): redisenar pantalla de login con paridad visual 1:1 a desktop OneverAccess

This commit is contained in:
Carlos Tello
2026-10-14 07:50:07 -03:00
parent cfb24d81c4
commit b2568ed873
+454 -162
View File
@@ -1,7 +1,7 @@
// ============================================================================== // ==============================================================================
// Vista de Inicio de Sesión de Operador / Guardia // Vista de Inicio de Sesión de Operador / Guardia (OnEverControl Web)
// Sistema de Diseño OnEver (C:\Workspace\OemspotPySYS\styles\design_system.py) // Paridad Visual 1:1 con la versión de escritorio de OneverAccess (login_window.py)
// Optimizado para uso táctil en tablets Samsung Galaxy Tab y Windows (Touch-First) // Sistema de Diseño OnEver con Ola Gradiente (Indigo/Blue), Pills inputs y Glassmorphism
// ============================================================================== // ==============================================================================
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { useAuth } from '../context/AuthContext'; import { useAuth } from '../context/AuthContext';
@@ -15,11 +15,14 @@ export const LoginView: React.FC = () => {
const [username, setUsername] = useState<string>('guardia'); const [username, setUsername] = useState<string>('guardia');
const [password, setPassword] = useState<string>(''); const [password, setPassword] = useState<string>('');
const [showPassword, setShowPassword] = useState<boolean>(false);
const [selectedWks, setSelectedWks] = useState<string>(workstation || 'CFT-DESK'); const [selectedWks, setSelectedWks] = useState<string>(workstation || 'CFT-DESK');
const [availableWorkstations, setAvailableWorkstations] = useState<WorkstationListItem[]>([]); const [availableWorkstations, setAvailableWorkstations] = useState<WorkstationListItem[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false); const [isLoading, setIsLoading] = useState<boolean>(false);
const [errorMsg, setErrorMsg] = useState<string | null>(null); const [errorMsg, setErrorMsg] = useState<string | null>(null);
const isDark = theme === 'dark';
useEffect(() => { useEffect(() => {
// Carga de Workstations reales desde SQL Server // Carga de Workstations reales desde SQL Server
workstationApi workstationApi
@@ -56,12 +59,20 @@ export const LoginView: React.FC = () => {
setWorkstation(selectedWks); setWorkstation(selectedWks);
await login(username.trim(), password, selectedWks); await login(username.trim(), password, selectedWks);
} catch (err: any) { } catch (err: any) {
setErrorMsg(err.message || 'Error al iniciar sesión. Verifique sus credenciales.'); setErrorMsg(err.message || 'Credenciales inválidas. Verifique usuario o contraseña.');
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
}; };
const toggleFullscreen = () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().catch(() => {});
} else {
document.exitFullscreen().catch(() => {});
}
};
return ( return (
<div <div
style={{ style={{
@@ -69,212 +80,493 @@ export const LoginView: React.FC = () => {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
minHeight: '100%', minHeight: '100%',
backgroundColor: 'var(--bg-main)', backgroundColor: isDark ? '#090D16' : '#F1F5F9',
backgroundImage: isDark
? 'radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 60%)'
: 'radial-gradient(circle at 50% 0%, rgba(14, 165, 233, 0.12) 0%, transparent 60%)',
padding: '1.5rem', padding: '1.5rem',
position: 'relative', position: 'relative',
userSelect: 'none',
}} }}
> >
{/* Botón flotante de alternancia de tema (Oscuro / Claro) */} {/* Botones Flotantes de Utilidades (Tema y Pantalla Completa) */}
<button <div
type="button"
onClick={toggleTheme}
className="btn-outline"
style={{ style={{
position: 'absolute', position: 'absolute',
top: '1.25rem', top: '1.25rem',
right: '1.25rem', right: '1.25rem',
minHeight: '38px', display: 'flex',
padding: '0 0.85rem', gap: '0.5rem',
fontSize: '0.85rem', zIndex: 10,
}} }}
title="Cambiar tema OnEver (Oscuro / Claro)"
> >
{theme === 'dark' ? '☀️ Modo Claro' : '🌙 Modo Oscuro'} <button
</button> type="button"
onClick={toggleTheme}
style={{
minHeight: '38px',
padding: '0 0.85rem',
fontSize: '0.85rem',
backgroundColor: isDark ? 'rgba(30, 41, 59, 0.85)' : 'rgba(255, 255, 255, 0.9)',
color: isDark ? '#F8FAFC' : '#0F172A',
border: `1px solid ${isDark ? '#334155' : '#CBD5E1'}`,
borderRadius: '19px',
cursor: 'pointer',
backdropFilter: 'blur(8px)',
boxShadow: '0 4px 12px rgba(0,0,0,0.1)',
display: 'flex',
alignItems: 'center',
gap: '0.4rem',
fontWeight: 600,
}}
title="Cambiar tema OnEver (Oscuro / Claro)"
>
<span>{isDark ? '☀️' : '🌙'}</span>
<span>{isDark ? 'Claro' : 'Oscuro'}</span>
</button>
<button
type="button"
onClick={toggleFullscreen}
style={{
minHeight: '38px',
width: '38px',
padding: 0,
fontSize: '1rem',
backgroundColor: isDark ? 'rgba(30, 41, 59, 0.85)' : 'rgba(255, 255, 255, 0.9)',
color: isDark ? '#F8FAFC' : '#0F172A',
border: `1px solid ${isDark ? '#334155' : '#CBD5E1'}`,
borderRadius: '50%',
cursor: 'pointer',
backdropFilter: 'blur(8px)',
boxShadow: '0 4px 12px rgba(0,0,0,0.1)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
title="Pantalla Completa"
>
⛶
</button>
</div>
{/* Tarjeta de Login (Paridad con LoginBackgroundFrame de OneverAccess Desktop) */}
<div <div
className="card"
style={{ style={{
width: '100%', width: '100%',
maxWidth: '460px', maxWidth: '440px',
boxShadow: 'var(--shadow-lg)', backgroundColor: isDark ? '#0F172A' : '#FFFFFF',
backgroundColor: 'var(--bg-sidebar)', borderRadius: '24px',
border: '1px solid var(--border)', border: `1px solid ${isDark ? '#1E293B' : '#E2E8F0'}`,
borderRadius: '10px', boxShadow: isDark
padding: '2.25rem', ? '0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(99, 102, 241, 0.1)'
: '0 25px 50px -12px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(14, 165, 233, 0.1)',
position: 'relative',
overflow: 'hidden',
display: 'flex',
flexDirection: 'column',
}} }}
> >
{/* Cabecera del Login */} {/* Onda Decorativa Superior con Gradiente Curvo (Idéntica a LoginBackgroundFrame) */}
<div style={{ textAlign: 'center', marginBottom: '1.75rem' }}> <div
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
height: '165px',
overflow: 'hidden',
pointerEvents: 'none',
zIndex: 1,
}}
>
<svg
viewBox="0 0 440 165"
preserveAspectRatio="none"
style={{ width: '100%', height: '100%', display: 'block' }}
>
<defs>
<linearGradient id="loginWaveGrad" x1="0%" y1="0%" x2="100%" y2="100%">
{isDark ? (
<>
<stop offset="0%" stopColor="#6366f1" /> {/* Indigo */}
<stop offset="100%" stopColor="#3b82f6" /> {/* Blue */}
</>
) : (
<>
<stop offset="0%" stopColor="#8b5cf6" /> {/* Purple */}
<stop offset="100%" stopColor="#0ea5e9" /> {/* Light Blue */}
</>
)}
</linearGradient>
</defs>
{/* Curva Bezier cúbica idéntica al painter.cubicTo de PyQt6 */}
<path
d="M 0 0 L 0 135 C 154 85, 286 160, 440 115 L 440 0 Z"
fill="url(#loginWaveGrad)"
/>
</svg>
</div>
{/* Contenido Principal del Formulario */}
<div
style={{
padding: '2.5rem 2.25rem 2rem',
position: 'relative',
zIndex: 2,
display: 'flex',
flexDirection: 'column',
}}
>
{/* Logo Corporativo OneverAccess */}
<div <div
style={{ style={{
display: 'inline-flex', display: 'flex',
flexDirection: 'column',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
marginBottom: '1rem', marginBottom: '2.5rem',
height: '110px',
}} }}
> >
<img <img
src={theme === 'dark' ? '/logo_login_dark.png' : '/logo_login_light.png'} src={isDark ? '/logo_login_dark.png' : '/logo_login_light.png'}
alt="OnEver Access" alt="OnEver Access"
style={{ maxHeight: '52px', width: 'auto', objectFit: 'contain' }} style={{
maxHeight: '85px',
maxWidth: '280px',
width: 'auto',
objectFit: 'contain',
filter: 'drop-shadow(0 4px 8px rgba(0,0,0,0.25))',
}}
onError={(e) => { onError={(e) => {
(e.target as HTMLImageElement).src = '/logo_mini.png'; (e.target as HTMLImageElement).src = '/logo_mini.png';
}} }}
/> />
</div> </div>
<h1
style={{ {/* Formulario */}
fontSize: '1.65rem', <form
fontWeight: 700, onSubmit={handleSubmit}
margin: '0 0 0.35rem 0', style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}
color: 'var(--text-1)',
letterSpacing: '-0.02em',
}}
> >
OnEverControl {/* Puesto de Control / Workstation (Pill Shape) */}
</h1> <div>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '0.5rem' }}> <label
<span style={{ fontSize: '0.88rem', color: 'var(--text-2)' }}> style={{
Puesto de Control Web • Modo Garita display: 'flex',
</span> alignItems: 'center',
<span gap: '0.4rem',
fontSize: '0.75rem',
fontWeight: 700,
color: isDark ? '#94A3B8' : '#64748B',
marginBottom: '0.4rem',
letterSpacing: '0.05em',
textTransform: 'uppercase',
paddingLeft: '0.75rem',
}}
>
<span>🖥️</span> Puesto de Control (Workstation)
</label>
<select
value={selectedWks}
onChange={(e) => setSelectedWks(e.target.value)}
style={{
width: '100%',
height: '46px',
borderRadius: '23px',
backgroundColor: isDark ? '#1E293B' : '#F8FAFC',
border: `1px solid ${isDark ? '#374151' : '#CBD5E1'}`,
color: isDark ? '#F8FAFC' : '#0F172A',
padding: '0 20px',
fontSize: '0.9rem',
fontWeight: 600,
outline: 'none',
cursor: 'pointer',
appearance: 'auto',
}}
>
{availableWorkstations.length > 0 ? (
availableWorkstations.map((w) => (
<option key={w.id} value={w.name}>
{w.name} (ID {w.id})
</option>
))
) : (
<option value="CFT-DESK">CFT-DESK (ID 100001)</option>
)}
</select>
</div>
{/* Campo Usuario (Pill Shape) */}
<div>
<label
style={{
display: 'flex',
alignItems: 'center',
gap: '0.4rem',
fontSize: '0.75rem',
fontWeight: 700,
color: isDark ? '#94A3B8' : '#64748B',
marginBottom: '0.4rem',
letterSpacing: '0.05em',
textTransform: 'uppercase',
paddingLeft: '0.75rem',
}}
>
<span>👤</span> Usuario
</label>
<input
type="text"
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder="Username"
autoCapitalize="none"
autoCorrect="off"
required
style={{
width: '100%',
height: '46px',
borderRadius: '23px',
backgroundColor: isDark ? '#1E293B' : '#F8FAFC',
border: `1px solid ${isDark ? '#374151' : '#CBD5E1'}`,
color: isDark ? '#F8FAFC' : '#0F172A',
padding: '0 20px',
fontSize: '0.925rem',
fontWeight: 500,
outline: 'none',
transition: 'border-color 0.2s, box-shadow 0.2s',
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = '#2563EB';
e.currentTarget.style.boxShadow = '0 0 0 3px rgba(37, 99, 235, 0.2)';
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = isDark ? '#374151' : '#CBD5E1';
e.currentTarget.style.boxShadow = 'none';
}}
/>
</div>
{/* Campo Contraseña con Botón de Ojo (Pill Shape) */}
<div>
<label
style={{
display: 'flex',
alignItems: 'center',
gap: '0.4rem',
fontSize: '0.75rem',
fontWeight: 700,
color: isDark ? '#94A3B8' : '#64748B',
marginBottom: '0.4rem',
letterSpacing: '0.05em',
textTransform: 'uppercase',
paddingLeft: '0.75rem',
}}
>
<span>🔒</span> Contraseña
</label>
<div
style={{
display: 'flex',
alignItems: 'center',
height: '46px',
borderRadius: '23px',
backgroundColor: isDark ? '#1E293B' : '#F8FAFC',
border: `1px solid ${isDark ? '#374151' : '#CBD5E1'}`,
overflow: 'hidden',
transition: 'border-color 0.2s, box-shadow 0.2s',
}}
id="passwordContainer"
>
<input
type={showPassword ? 'text' : 'password'}
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="Password"
required
style={{
flex: 1,
height: '100%',
border: 'none',
backgroundColor: 'transparent',
color: isDark ? '#F8FAFC' : '#0F172A',
padding: '0 0 0 20px',
fontSize: '0.925rem',
fontWeight: 500,
outline: 'none',
}}
onFocus={() => {
const el = document.getElementById('passwordContainer');
if (el) {
el.style.borderColor = '#2563EB';
el.style.boxShadow = '0 0 0 3px rgba(37, 99, 235, 0.2)';
}
}}
onBlur={() => {
const el = document.getElementById('passwordContainer');
if (el) {
el.style.borderColor = isDark ? '#374151' : '#CBD5E1';
el.style.boxShadow = 'none';
}
}}
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
style={{
height: '100%',
width: '46px',
border: 'none',
backgroundColor: 'transparent',
color: isDark ? '#94A3B8' : '#64748B',
fontSize: '1.1rem',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
paddingRight: '6px',
transition: 'color 0.15s',
}}
title={showPassword ? 'Ocultar contraseña' : 'Ver contraseña'}
>
{showPassword ? '👁️' : '🔒'}
</button>
</div>
</div>
{/* Mensaje de Error (si ocurre) */}
{errorMsg && (
<div
style={{
padding: '0.55rem 0.85rem',
backgroundColor: 'rgba(239, 68, 68, 0.12)',
border: '1px solid #EF4444',
borderRadius: '12px',
color: '#EF4444',
fontSize: '0.825rem',
fontWeight: 600,
textAlign: 'center',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '0.4rem',
}}
>
<span>⚠️</span> {errorMsg}
</div>
)}
{/* Botón Ingresar / Login (Pill Shape estilo OnEver Desktop) */}
<button
type="submit"
disabled={isLoading}
style={{ style={{
fontSize: '0.68rem', width: '100%',
padding: '0.15rem 0.45rem', height: '46px',
borderRadius: '4px', borderRadius: '23px',
backgroundColor: 'var(--hover-bg)', backgroundColor: isDark ? 'transparent' : '#2563EB',
border: '1px solid var(--border)', color: isDark ? '#38BDF8' : '#FFFFFF',
color: 'var(--accent)', border: isDark ? '2px solid #38BDF8' : '2px solid #2563EB',
fontWeight: 600, fontSize: '0.95rem',
fontWeight: 700,
letterSpacing: '0.02em',
cursor: isLoading ? 'not-allowed' : 'pointer',
marginTop: '0.5rem',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '0.5rem',
transition: 'all 0.2s ease',
boxShadow: isDark ? '0 4px 15px rgba(56, 189, 248, 0.15)' : '0 4px 15px rgba(37, 99, 235, 0.25)',
}}
onMouseEnter={(e) => {
if (!isLoading) {
e.currentTarget.style.backgroundColor = isDark ? '#38BDF8' : '#1D4ED8';
e.currentTarget.style.color = '#FFFFFF';
e.currentTarget.style.boxShadow = isDark
? '0 6px 20px rgba(56, 189, 248, 0.35)'
: '0 6px 20px rgba(37, 99, 235, 0.35)';
}
}}
onMouseLeave={(e) => {
if (!isLoading) {
e.currentTarget.style.backgroundColor = isDark ? 'transparent' : '#2563EB';
e.currentTarget.style.color = isDark ? '#38BDF8' : '#FFFFFF';
e.currentTarget.style.boxShadow = isDark
? '0 4px 15px rgba(56, 189, 248, 0.15)'
: '0 4px 15px rgba(37, 99, 235, 0.25)';
}
}} }}
> >
{APP_BUILD} {isLoading ? (
</span> <>
</div> <span>⏳</span> Validando credenciales...
</div> </>
) : (
'Login'
)}
</button>
</form>
{/* Alerta de Error */} {/* Pie Informativo y Estado de Conexión */}
{errorMsg && (
<div <div
style={{ style={{
padding: '0.75rem 1rem', marginTop: '1.75rem',
backgroundColor: 'var(--color-danger-bg)', textAlign: 'center',
color: 'var(--danger-hover)',
borderRadius: '8px',
marginBottom: '1.5rem',
fontSize: '0.875rem',
border: '1px solid var(--danger)',
display: 'flex', display: 'flex',
flexDirection: 'column',
alignItems: 'center', alignItems: 'center',
gap: '0.5rem', gap: '0.4rem',
}} }}
> >
<span>⚠️</span> {errorMsg} <div
</div>
)}
<form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: '1.25rem' }}>
{/* Selector de Workstation Real desde SQL Server */}
<div>
<label
style={{ style={{
display: 'block', display: 'flex',
fontSize: '0.85rem', alignItems: 'center',
fontWeight: 600, justifyContent: 'center',
color: 'var(--text-2)', gap: '0.45rem',
marginBottom: '0.5rem', fontSize: '0.75rem',
color: isDark ? '#94A3B8' : '#64748B',
fontWeight: 500,
}} }}
> >
Puesto de Control / Workstation: <img
</label> src="/logo_os.png"
<select alt=""
className="input-touch" style={{ width: '14px', height: '14px', objectFit: 'contain' }}
value={selectedWks} onError={(e) => {
onChange={(e) => setSelectedWks(e.target.value)} (e.target as HTMLElement).style.display = 'none';
style={{ width: '100%' }} }}
> />
{availableWorkstations.length > 0 ? ( <span>OnEver Access · Control Web {APP_VERSION}</span>
availableWorkstations.map((w) => ( <span
<option key={w.id} value={w.name}> style={{
{w.name} (ID {w.id}) fontSize: '0.65rem',
</option> padding: '0.1rem 0.35rem',
)) borderRadius: '4px',
) : ( backgroundColor: isDark ? '#1E293B' : '#E2E8F0',
<option value="CFT-DESK">CFT-DESK (ID 100001)</option> color: isDark ? '#38BDF8' : '#0284C7',
)} fontWeight: 600,
</select> }}
</div> >
{APP_BUILD}
</span>
</div>
{/* Campo Usuario */} <div
<div>
<label
style={{ style={{
display: 'block', display: 'flex',
fontSize: '0.85rem', alignItems: 'center',
fontWeight: 600, gap: '0.35rem',
color: 'var(--text-2)', fontSize: '0.725rem',
marginBottom: '0.5rem', color: isDark ? '#64748B' : '#94A3B8',
}} }}
> >
Usuario: <span style={{ color: '#10B981', fontSize: '0.65rem' }}>●</span>
</label> <span>Conectado a Microsoft SQL Server (Transaccional)</span>
<input </div>
type="text"
className="input-touch"
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder="Ej: guardia, supervisor"
autoCapitalize="none"
autoCorrect="off"
required
style={{ width: '100%' }}
/>
</div> </div>
{/* Campo Contraseña */}
<div>
<label
style={{
display: 'block',
fontSize: '0.85rem',
fontWeight: 600,
color: 'var(--text-2)',
marginBottom: '0.5rem',
}}
>
Contraseña:
</label>
<input
type="password"
className="input-touch"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="••••••••"
required
style={{ width: '100%' }}
/>
</div>
{/* Botón de Ingreso Táctil */}
<button
type="submit"
className="btn btn-primary"
disabled={isLoading}
style={{
width: '100%',
minHeight: '50px',
fontSize: '1rem',
fontWeight: 700,
marginTop: '0.5rem',
}}
>
{isLoading ? 'Iniciando Sesión...' : 'Iniciar Turno'}
</button>
</form>
<div style={{ marginTop: '2rem', textAlign: 'center', fontSize: '0.75rem', color: 'var(--text-3)' }}>
OnEver Access · Control Web {APP_VERSION} ({APP_BUILD}) • Conectado a Microsoft SQL Server
</div> </div>
</div> </div>
</div> </div>