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
+409 -117
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,130 +80,211 @@ 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',
display: 'flex',
gap: '0.5rem',
zIndex: 10,
}}
>
<button
type="button"
onClick={toggleTheme}
style={{
minHeight: '38px', minHeight: '38px',
padding: '0 0.85rem', padding: '0 0.85rem',
fontSize: '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)" title="Cambiar tema OnEver (Oscuro / Claro)"
> >
{theme === 'dark' ? '☀️ Modo Claro' : '🌙 Modo Oscuro'} <span>{isDark ? '☀️' : '🌙'}</span>
<span>{isDark ? 'Claro' : 'Oscuro'}</span>
</button> </button>
<div <button
className="card" type="button"
onClick={toggleFullscreen}
style={{ style={{
width: '100%', minHeight: '38px',
maxWidth: '460px', width: '38px',
boxShadow: 'var(--shadow-lg)', padding: 0,
backgroundColor: 'var(--bg-sidebar)', fontSize: '1rem',
border: '1px solid var(--border)', backgroundColor: isDark ? 'rgba(30, 41, 59, 0.85)' : 'rgba(255, 255, 255, 0.9)',
borderRadius: '10px', color: isDark ? '#F8FAFC' : '#0F172A',
padding: '2.25rem', border: `1px solid ${isDark ? '#334155' : '#CBD5E1'}`,
}} borderRadius: '50%',
> cursor: 'pointer',
{/* Cabecera del Login */} backdropFilter: 'blur(8px)',
<div style={{ textAlign: 'center', marginBottom: '1.75rem' }}> boxShadow: '0 4px 12px rgba(0,0,0,0.1)',
<div display: 'flex',
style={{
display: 'inline-flex',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
marginBottom: '1rem', }}
title="Pantalla Completa"
>
⛶
</button>
</div>
{/* Tarjeta de Login (Paridad con LoginBackgroundFrame de OneverAccess Desktop) */}
<div
style={{
width: '100%',
maxWidth: '440px',
backgroundColor: isDark ? '#0F172A' : '#FFFFFF',
borderRadius: '24px',
border: `1px solid ${isDark ? '#1E293B' : '#E2E8F0'}`,
boxShadow: isDark
? '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',
}}
>
{/* Onda Decorativa Superior con Gradiente Curvo (Idéntica a LoginBackgroundFrame) */}
<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
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
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={{
fontSize: '1.65rem',
fontWeight: 700,
margin: '0 0 0.35rem 0',
color: 'var(--text-1)',
letterSpacing: '-0.02em',
}}
>
OnEverControl
</h1>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '0.5rem' }}>
<span style={{ fontSize: '0.88rem', color: 'var(--text-2)' }}>
Puesto de Control Web • Modo Garita
</span>
<span
style={{
fontSize: '0.68rem',
padding: '0.15rem 0.45rem',
borderRadius: '4px',
backgroundColor: 'var(--hover-bg)',
border: '1px solid var(--border)',
color: 'var(--accent)',
fontWeight: 600,
}}
>
{APP_BUILD}
</span>
</div>
</div>
{/* Alerta de Error */} {/* Formulario */}
{errorMsg && ( <form
<div onSubmit={handleSubmit}
style={{ style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}
padding: '0.75rem 1rem',
backgroundColor: 'var(--color-danger-bg)',
color: 'var(--danger-hover)',
borderRadius: '8px',
marginBottom: '1.5rem',
fontSize: '0.875rem',
border: '1px solid var(--danger)',
display: 'flex',
alignItems: 'center',
gap: '0.5rem',
}}
> >
<span>⚠️</span> {errorMsg} {/* Puesto de Control / Workstation (Pill Shape) */}
</div>
)}
<form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: '1.25rem' }}>
{/* Selector de Workstation Real desde SQL Server */}
<div> <div>
<label <label
style={{ style={{
display: 'block', display: 'flex',
fontSize: '0.85rem', alignItems: 'center',
fontWeight: 600, gap: '0.4rem',
color: 'var(--text-2)', fontSize: '0.75rem',
marginBottom: '0.5rem', fontWeight: 700,
color: isDark ? '#94A3B8' : '#64748B',
marginBottom: '0.4rem',
letterSpacing: '0.05em',
textTransform: 'uppercase',
paddingLeft: '0.75rem',
}} }}
> >
Puesto de Control / Workstation: <span>🖥️</span> Puesto de Control (Workstation)
</label> </label>
<select <select
className="input-touch"
value={selectedWks} value={selectedWks}
onChange={(e) => setSelectedWks(e.target.value)} onChange={(e) => setSelectedWks(e.target.value)}
style={{ width: '100%' }} 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.length > 0 ? (
availableWorkstations.map((w) => ( availableWorkstations.map((w) => (
@@ -206,75 +298,275 @@ export const LoginView: React.FC = () => {
</select> </select>
</div> </div>
{/* Campo Usuario */} {/* Campo Usuario (Pill Shape) */}
<div> <div>
<label <label
style={{ style={{
display: 'block', display: 'flex',
fontSize: '0.85rem', alignItems: 'center',
fontWeight: 600, gap: '0.4rem',
color: 'var(--text-2)', fontSize: '0.75rem',
marginBottom: '0.5rem', fontWeight: 700,
color: isDark ? '#94A3B8' : '#64748B',
marginBottom: '0.4rem',
letterSpacing: '0.05em',
textTransform: 'uppercase',
paddingLeft: '0.75rem',
}} }}
> >
Usuario: <span>👤</span> Usuario
</label> </label>
<input <input
type="text" type="text"
className="input-touch"
value={username} value={username}
onChange={(e) => setUsername(e.target.value)} onChange={(e) => setUsername(e.target.value)}
placeholder="Ej: guardia, supervisor" placeholder="Username"
autoCapitalize="none" autoCapitalize="none"
autoCorrect="off" autoCorrect="off"
required required
style={{ width: '100%' }} 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> </div>
{/* Campo Contraseña */} {/* Campo Contraseña con Botón de Ojo (Pill Shape) */}
<div> <div>
<label <label
style={{ style={{
display: 'block', display: 'flex',
fontSize: '0.85rem', alignItems: 'center',
fontWeight: 600, gap: '0.4rem',
color: 'var(--text-2)', fontSize: '0.75rem',
marginBottom: '0.5rem', fontWeight: 700,
color: isDark ? '#94A3B8' : '#64748B',
marginBottom: '0.4rem',
letterSpacing: '0.05em',
textTransform: 'uppercase',
paddingLeft: '0.75rem',
}} }}
> >
Contraseña: <span>🔒</span> Contraseña
</label> </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 <input
type="password" type={showPassword ? 'text' : 'password'}
className="input-touch"
value={password} value={password}
onChange={(e) => setPassword(e.target.value)} onChange={(e) => setPassword(e.target.value)}
placeholder="••••••••" placeholder="Password"
required required
style={{ width: '100%' }} 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> </div>
{/* Botón de Ingreso Táctil */} {/* 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 <button
type="submit" type="submit"
className="btn btn-primary"
disabled={isLoading} disabled={isLoading}
style={{ style={{
width: '100%', width: '100%',
minHeight: '50px', height: '46px',
fontSize: '1rem', borderRadius: '23px',
backgroundColor: isDark ? 'transparent' : '#2563EB',
color: isDark ? '#38BDF8' : '#FFFFFF',
border: isDark ? '2px solid #38BDF8' : '2px solid #2563EB',
fontSize: '0.95rem',
fontWeight: 700, fontWeight: 700,
letterSpacing: '0.02em',
cursor: isLoading ? 'not-allowed' : 'pointer',
marginTop: '0.5rem', 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)';
}
}} }}
> >
{isLoading ? 'Iniciando Sesión...' : 'Iniciar Turno'} {isLoading ? (
<>
<span>⏳</span> Validando credenciales...
</>
) : (
'Login'
)}
</button> </button>
</form> </form>
<div style={{ marginTop: '2rem', textAlign: 'center', fontSize: '0.75rem', color: 'var(--text-3)' }}> {/* Pie Informativo y Estado de Conexión */}
OnEver Access · Control Web {APP_VERSION} ({APP_BUILD}) • Conectado a Microsoft SQL Server <div
style={{
marginTop: '1.75rem',
textAlign: 'center',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
gap: '0.4rem',
}}
>
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '0.45rem',
fontSize: '0.75rem',
color: isDark ? '#94A3B8' : '#64748B',
fontWeight: 500,
}}
>
<img
src="/logo_os.png"
alt=""
style={{ width: '14px', height: '14px', objectFit: 'contain' }}
onError={(e) => {
(e.target as HTMLElement).style.display = 'none';
}}
/>
<span>OnEver Access · Control Web {APP_VERSION}</span>
<span
style={{
fontSize: '0.65rem',
padding: '0.1rem 0.35rem',
borderRadius: '4px',
backgroundColor: isDark ? '#1E293B' : '#E2E8F0',
color: isDark ? '#38BDF8' : '#0284C7',
fontWeight: 600,
}}
>
{APP_BUILD}
</span>
</div>
<div
style={{
display: 'flex',
alignItems: 'center',
gap: '0.35rem',
fontSize: '0.725rem',
color: isDark ? '#64748B' : '#94A3B8',
}}
>
<span style={{ color: '#10B981', fontSize: '0.65rem' }}>●</span>
<span>Conectado a Microsoft SQL Server (Transaccional)</span>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>