feat(ui-camera): aplicar sistema de diseno OnEver y soporte universal de camaras en Android y Windows
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
// ==============================================================================
|
||||
// Modal de Escaneo Óptico con Cámara de Tablet (BarcodeDetector / PDF417 / QR)
|
||||
// Optimizado para tablets Samsung Galaxy Tab A9/A11 (4GB RAM) con liberación inmediata de hardware
|
||||
// Modal de Escaneo Óptico con Cámara para Tablets (Android) y Windows
|
||||
// Soporte de Video en Vivo (WebRTC) + ZXing Library (PDF417 / QR) + Captura de Foto Nativa
|
||||
// Cumple con el sistema de diseño OnEver (C:\Workspace\OemspotPySYS\styles\design_system.py)
|
||||
// ==============================================================================
|
||||
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
||||
import { BrowserMultiFormatReader, BarcodeFormat, DecodeHintType } from '@zxing/library';
|
||||
import { accessApi } from '../../api/accessApi';
|
||||
import { DNIParsedResult } from '../../types';
|
||||
|
||||
@@ -19,23 +21,57 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
}) => {
|
||||
const videoRef = useRef<HTMLVideoElement | null>(null);
|
||||
const streamRef = useRef<MediaStream | null>(null);
|
||||
const intervalRef = useRef<number | null>(null);
|
||||
const zxingReaderRef = useRef<BrowserMultiFormatReader | null>(null);
|
||||
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
||||
|
||||
const [hasCamera, setHasCamera] = useState<boolean>(true);
|
||||
const [insecureContextWarning, setInsecureContextWarning] = useState<boolean>(false);
|
||||
const [errorMsg, setErrorMsg] = useState<string | null>(null);
|
||||
const [isProcessing, setIsProcessing] = useState<boolean>(false);
|
||||
const [torchEnabled, setTorchEnabled] = useState<boolean>(false);
|
||||
const [supportsTorch, setSupportsTorch] = useState<boolean>(false);
|
||||
const [manualText, setManualText] = useState<string>('');
|
||||
const [availableDevices, setAvailableDevices] = useState<MediaDeviceInfo[]>([]);
|
||||
const [selectedDeviceId, setSelectedDeviceId] = useState<string>('');
|
||||
|
||||
// Inicializar lector ZXing configurado para DNI Argentino (PDF417 + QR + Code128)
|
||||
useEffect(() => {
|
||||
const hints = new Map();
|
||||
hints.set(DecodeHintType.POSSIBLE_FORMATS, [
|
||||
BarcodeFormat.PDF_417,
|
||||
BarcodeFormat.QR_CODE,
|
||||
BarcodeFormat.CODE_128,
|
||||
]);
|
||||
hints.set(DecodeHintType.TRY_HARDER, true);
|
||||
|
||||
zxingReaderRef.current = new BrowserMultiFormatReader(hints, 250);
|
||||
|
||||
return () => {
|
||||
if (zxingReaderRef.current) {
|
||||
try {
|
||||
zxingReaderRef.current.reset();
|
||||
} catch {
|
||||
// Cleanup
|
||||
}
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const stopCamera = useCallback(() => {
|
||||
if (intervalRef.current) {
|
||||
clearInterval(intervalRef.current);
|
||||
intervalRef.current = null;
|
||||
if (zxingReaderRef.current) {
|
||||
try {
|
||||
zxingReaderRef.current.reset();
|
||||
} catch {
|
||||
// Ignorar
|
||||
}
|
||||
}
|
||||
if (streamRef.current) {
|
||||
streamRef.current.getTracks().forEach((track) => {
|
||||
track.stop();
|
||||
try {
|
||||
track.stop();
|
||||
} catch {
|
||||
// Ignorar
|
||||
}
|
||||
});
|
||||
streamRef.current = null;
|
||||
}
|
||||
@@ -48,6 +84,7 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
async (rawText: string) => {
|
||||
if (isProcessing || !rawText) return;
|
||||
setIsProcessing(true);
|
||||
setErrorMsg(null);
|
||||
try {
|
||||
const res = await accessApi.parseDni(rawText);
|
||||
if (res.valido) {
|
||||
@@ -55,7 +92,7 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
onScanSuccess(res);
|
||||
onClose();
|
||||
} else {
|
||||
setErrorMsg('Código detectado pero no corresponde a un DNI argentino válido.');
|
||||
setErrorMsg(`Código detectado pero no es un DNI argentino válido (${rawText.slice(0, 30)}...).`);
|
||||
}
|
||||
} catch (err: any) {
|
||||
setErrorMsg(err.message || 'Error al interpretar el código escaneado.');
|
||||
@@ -66,21 +103,68 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
[isProcessing, stopCamera, onScanSuccess, onClose]
|
||||
);
|
||||
|
||||
const startCamera = useCallback(async () => {
|
||||
const startCamera = useCallback(async (deviceIdToUse?: string) => {
|
||||
setErrorMsg(null);
|
||||
setHasCamera(true);
|
||||
|
||||
try {
|
||||
const constraints: MediaStreamConstraints = {
|
||||
video: {
|
||||
facingMode: { ideal: 'environment' }, // Cámara trasera de la tablet
|
||||
width: { ideal: 1280 },
|
||||
height: { ideal: 720 },
|
||||
},
|
||||
audio: false,
|
||||
};
|
||||
// Verificar si el navegador permite acceso a mediaDevices
|
||||
const isSecure = window.isSecureContext || window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
|
||||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
||||
setHasCamera(false);
|
||||
if (!isSecure) {
|
||||
setInsecureContextWarning(true);
|
||||
setErrorMsg(
|
||||
'El navegador bloqueó la cámara porque la conexión es HTTP sobre red local. Utilice el botón "📷 Tomar Foto con Cámara" para escanear sin restricciones de seguridad.'
|
||||
);
|
||||
} else {
|
||||
setErrorMsg('Dispositivo de video no soportado o bloqueado por el sistema operativo.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 1. Obtener lista de cámaras disponibles si es posible
|
||||
try {
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
const videoDevices = devices.filter((d) => d.kind === 'videoinput');
|
||||
setAvailableDevices(videoDevices);
|
||||
} catch {
|
||||
// En algunos navegadores enumerateDevices requiere haber abierto stream previo
|
||||
}
|
||||
|
||||
// 2. Definir constraints (con fallback para Windows laptop vs Android tablet)
|
||||
let stream: MediaStream | null = null;
|
||||
|
||||
try {
|
||||
// Intento 1: Cámara trasera de tablet / dispositivo específico
|
||||
const videoConstraints: MediaTrackConstraints = deviceIdToUse
|
||||
? { deviceId: { exact: deviceIdToUse } }
|
||||
: {
|
||||
facingMode: { ideal: 'environment' },
|
||||
width: { ideal: 1280 },
|
||||
height: { ideal: 720 },
|
||||
};
|
||||
|
||||
stream = await navigator.mediaDevices.getUserMedia({
|
||||
video: videoConstraints,
|
||||
audio: false,
|
||||
});
|
||||
} catch {
|
||||
// Intento 2: Fallback simple para webcam de PC Windows o cámara estándar
|
||||
try {
|
||||
stream = await navigator.mediaDevices.getUserMedia({
|
||||
video: true,
|
||||
audio: false,
|
||||
});
|
||||
} catch (innerErr: any) {
|
||||
throw innerErr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!stream) {
|
||||
throw new Error('No se pudo inicializar el flujo de video.');
|
||||
}
|
||||
|
||||
const stream = await navigator.mediaDevices.getUserMedia(constraints);
|
||||
streamRef.current = stream;
|
||||
|
||||
if (videoRef.current) {
|
||||
@@ -95,37 +179,83 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
setSupportsTorch(true);
|
||||
}
|
||||
|
||||
// Inicializar detección si BarcodeDetector está disponible
|
||||
if ('BarcodeDetector' in window) {
|
||||
const BarcodeDetectorClass = (window as any).BarcodeDetector;
|
||||
const detector = new BarcodeDetectorClass({
|
||||
formats: ['pdf417', 'qr_code', 'code_128'],
|
||||
});
|
||||
|
||||
intervalRef.current = window.setInterval(async () => {
|
||||
if (!videoRef.current || isProcessing) return;
|
||||
try {
|
||||
const barcodes = await detector.detect(videoRef.current);
|
||||
if (barcodes.length > 0) {
|
||||
const rawVal = barcodes[0].rawValue;
|
||||
if (rawVal) {
|
||||
handleDecodedString(rawVal);
|
||||
// Iniciar decodificación continua con ZXing sobre el elemento video
|
||||
if (zxingReaderRef.current && videoRef.current) {
|
||||
zxingReaderRef.current.decodeFromVideoElementContinuously(
|
||||
videoRef.current,
|
||||
(result: any) => {
|
||||
if (result) {
|
||||
const text = result.getText?.() || result.text;
|
||||
if (text) {
|
||||
handleDecodedString(text);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignorar errores de frame no listo
|
||||
}
|
||||
}, 300); // Muestreo cada 300ms optimizado para 4GB RAM
|
||||
);
|
||||
}
|
||||
} catch (err: any) {
|
||||
setHasCamera(false);
|
||||
setErrorMsg('No se pudo acceder a la cámara de la tablet. Permiso denegado o dispositivo no disponible.');
|
||||
const name = err.name || '';
|
||||
if (name === 'NotAllowedError' || name === 'PermissionDeniedError') {
|
||||
setErrorMsg('Permiso de cámara denegado. Habilite el acceso en la barra del navegador.');
|
||||
} else if (name === 'NotFoundError' || name === 'DevicesNotFoundError') {
|
||||
setErrorMsg('No se detectó ninguna cámara conectada al dispositivo.');
|
||||
} else if (name === 'NotReadableError') {
|
||||
setErrorMsg('La cámara está siendo usada por otra aplicación en Windows.');
|
||||
} else {
|
||||
setErrorMsg(`No se pudo iniciar la cámara: ${err.message || 'Error desconocido'}`);
|
||||
}
|
||||
}
|
||||
}, [handleDecodedString, isProcessing]);
|
||||
}, [handleDecodedString]);
|
||||
|
||||
// Manejador de captura de foto nativa (funciona sin HTTPS en tablets Android)
|
||||
const handlePhotoCaptured = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
setIsProcessing(true);
|
||||
setErrorMsg(null);
|
||||
|
||||
try {
|
||||
const reader = new FileReader();
|
||||
reader.onload = async (event) => {
|
||||
const dataUrl = event.target?.result as string;
|
||||
if (!dataUrl) {
|
||||
setIsProcessing(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Crear imagen temporal para decodificar con ZXing
|
||||
const img = new Image();
|
||||
img.src = dataUrl;
|
||||
img.onload = async () => {
|
||||
try {
|
||||
if (zxingReaderRef.current) {
|
||||
const result = await zxingReaderRef.current.decodeFromImageElement(img);
|
||||
if (result && result.getText()) {
|
||||
handleDecodedString(result.getText());
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ZXing no pudo decodificar directo; intentar OCR / backend fallback
|
||||
}
|
||||
|
||||
// Si el código no fue legible directo de la foto, avisar al usuario
|
||||
setErrorMsg('No se pudo detectar el código de barras en la foto. Intente con mejor iluminación o acerque el código.');
|
||||
setIsProcessing(false);
|
||||
};
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} catch (err: any) {
|
||||
setErrorMsg('Error al procesar la imagen capturada.');
|
||||
setIsProcessing(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
startCamera();
|
||||
startCamera(selectedDeviceId || undefined);
|
||||
} else {
|
||||
stopCamera();
|
||||
}
|
||||
@@ -133,7 +263,7 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
return () => {
|
||||
stopCamera();
|
||||
};
|
||||
}, [isOpen, startCamera, stopCamera]);
|
||||
}, [isOpen, startCamera, stopCamera, selectedDeviceId]);
|
||||
|
||||
const toggleTorch = async () => {
|
||||
if (!streamRef.current) return;
|
||||
@@ -166,7 +296,8 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.85)',
|
||||
backgroundColor: 'rgba(2, 6, 23, 0.85)',
|
||||
backdropFilter: 'blur(4px)',
|
||||
zIndex: 9999,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
@@ -176,16 +307,17 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="card"
|
||||
style={{
|
||||
width: '100%',
|
||||
maxWidth: '640px',
|
||||
backgroundColor: 'var(--bg-surface)',
|
||||
borderRadius: 'var(--radius-lg)',
|
||||
maxWidth: '620px',
|
||||
backgroundColor: 'var(--bg-sidebar)',
|
||||
borderRadius: '10px',
|
||||
overflow: 'hidden',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
boxShadow: 'var(--shadow-lg)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
border: '1px solid var(--border)',
|
||||
}}
|
||||
>
|
||||
{/* Cabecera del Escáner */}
|
||||
@@ -195,30 +327,35 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
padding: '1rem 1.25rem',
|
||||
borderBottom: '1px solid var(--border-subtle)',
|
||||
backgroundColor: 'var(--bg-card)',
|
||||
borderBottom: '1px solid var(--divider)',
|
||||
backgroundColor: 'var(--bg-sidebar)',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
|
||||
<span style={{ fontSize: '1.25rem' }}>📷</span>
|
||||
<h2 style={{ fontSize: '1.1rem', fontWeight: 600, margin: 0, color: 'var(--text-primary)' }}>
|
||||
Escanear DNI Argentino (Cámara Tablet)
|
||||
</h2>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.65rem' }}>
|
||||
<span style={{ fontSize: '1.3rem' }}>📷</span>
|
||||
<div>
|
||||
<h2 style={{ fontSize: '1.05rem', fontWeight: 700, margin: 0, color: 'var(--text-1)' }}>
|
||||
Escanear DNI Argentino (Cámara / PDF417)
|
||||
</h2>
|
||||
<span style={{ fontSize: '0.75rem', color: 'var(--text-3)' }}>
|
||||
Soporta DNI tarjeta, PDF417, QR digital y fotos nativas
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
stopCamera();
|
||||
onClose();
|
||||
}}
|
||||
className="btn-outline"
|
||||
style={{
|
||||
background: 'transparent',
|
||||
padding: '0.35rem 0.65rem',
|
||||
minHeight: '36px',
|
||||
border: 'none',
|
||||
fontSize: '1.5rem',
|
||||
color: 'var(--text-muted)',
|
||||
cursor: 'pointer',
|
||||
padding: '0.25rem 0.5rem',
|
||||
fontSize: '1.25rem',
|
||||
color: 'var(--text-2)',
|
||||
}}
|
||||
title="Cerrar"
|
||||
title="Cerrar modal"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
@@ -229,7 +366,7 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
height: '320px',
|
||||
height: '310px',
|
||||
backgroundColor: '#000',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
@@ -253,11 +390,11 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
width: '80%',
|
||||
height: '65%',
|
||||
border: '2px dashed var(--accent-primary)',
|
||||
borderRadius: '12px',
|
||||
boxShadow: '0 0 0 9999px rgba(0, 0, 0, 0.45)',
|
||||
width: '82%',
|
||||
height: '62%',
|
||||
border: '2px dashed var(--blue-base)',
|
||||
borderRadius: '10px',
|
||||
boxShadow: '0 0 0 9999px rgba(2, 6, 23, 0.5)',
|
||||
pointerEvents: 'none',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
@@ -266,21 +403,27 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
||||
color: '#fff',
|
||||
padding: '0.25rem 0.75rem',
|
||||
borderRadius: '4px',
|
||||
backgroundColor: 'rgba(15, 23, 42, 0.85)',
|
||||
color: 'var(--text-1)',
|
||||
padding: '0.3rem 0.85rem',
|
||||
borderRadius: '6px',
|
||||
fontSize: '0.8rem',
|
||||
border: '1px solid var(--border)',
|
||||
}}
|
||||
>
|
||||
Ubique el código de barras PDF417 o QR aquí
|
||||
Ubique el código PDF417 o QR aquí
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div style={{ padding: '2rem', textAlign: 'center', color: 'var(--text-muted)' }}>
|
||||
<p>📷 Cámara no disponible en este dispositivo o sin permisos.</p>
|
||||
<p style={{ fontSize: '0.85rem' }}>Puede ingresar el código manualmente abajo.</p>
|
||||
<div style={{ padding: '2rem', textAlign: 'center', color: 'var(--text-2)', maxWidth: '480px' }}>
|
||||
<div style={{ fontSize: '2.5rem', marginBottom: '0.75rem' }}>📷</div>
|
||||
<p style={{ fontWeight: 600, color: 'var(--text-1)' }}>Cámara en vivo no inicializada</p>
|
||||
<p style={{ fontSize: '0.825rem', marginTop: '0.5rem', color: 'var(--text-3)' }}>
|
||||
{insecureContextWarning
|
||||
? 'En red local sin HTTPS, el navegador restringe el streaming continuo. Puede usar la opción de Foto Nativa debajo que opera directamente sin restricciones.'
|
||||
: 'Puede tomar una foto directa o ingresar el código manualmente abajo.'}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -292,16 +435,17 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
backgroundColor: 'rgba(0,0,0,0.6)',
|
||||
backgroundColor: 'rgba(2, 6, 23, 0.8)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
color: '#fff',
|
||||
color: 'var(--text-1)',
|
||||
fontSize: '1rem',
|
||||
fontWeight: 600,
|
||||
gap: '0.5rem',
|
||||
}}
|
||||
>
|
||||
⏳ Interpretando datos de identidad...
|
||||
<span>⏳</span> Procesando datos de identidad...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -310,30 +454,74 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
{errorMsg && (
|
||||
<div
|
||||
style={{
|
||||
padding: '0.75rem 1rem',
|
||||
backgroundColor: 'var(--status-danger-bg)',
|
||||
color: 'var(--status-danger)',
|
||||
fontSize: '0.85rem',
|
||||
borderBottom: '1px solid var(--border-subtle)',
|
||||
padding: '0.65rem 1rem',
|
||||
backgroundColor: 'var(--color-danger-bg)',
|
||||
color: 'var(--danger-hover)',
|
||||
fontSize: '0.825rem',
|
||||
borderBottom: '1px solid var(--border)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '0.5rem',
|
||||
}}
|
||||
>
|
||||
⚠️ {errorMsg}
|
||||
<span>⚠️</span> {errorMsg}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Barra de Acciones y Controles Táctiles */}
|
||||
<div style={{ padding: '1rem', display: 'flex', flexDirection: 'column', gap: '0.75rem' }}>
|
||||
<div style={{ display: 'flex', gap: '0.5rem', justifyContent: 'space-between' }}>
|
||||
<div style={{ padding: '1rem', display: 'flex', flexDirection: 'column', gap: '0.75rem', backgroundColor: 'var(--bg-sidebar)' }}>
|
||||
{/* Selector de cámara si hay múltiples dispositivos */}
|
||||
{availableDevices.length > 1 && (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
|
||||
<span style={{ fontSize: '0.75rem', color: 'var(--text-2)', fontWeight: 600 }}>CÁMARA:</span>
|
||||
<select
|
||||
className="input-touch"
|
||||
value={selectedDeviceId}
|
||||
onChange={(e) => setSelectedDeviceId(e.target.value)}
|
||||
style={{ minHeight: '36px', fontSize: '0.85rem' }}
|
||||
>
|
||||
<option value="">(Automática / Trasera)</option>
|
||||
{availableDevices.map((d) => (
|
||||
<option key={d.deviceId} value={d.deviceId}>
|
||||
{d.label || `Cámara ${d.deviceId.slice(0, 6)}...`}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Botones principales: Foto Nativa (Universal) + Linterna */}
|
||||
<div style={{ display: 'flex', gap: '0.65rem' }}>
|
||||
<input
|
||||
type="file"
|
||||
ref={fileInputRef}
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
onChange={handlePhotoCaptured}
|
||||
style={{ display: 'none' }}
|
||||
/>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
style={{ flex: 1, minHeight: '44px' }}
|
||||
title="Abre la cámara nativa de Android / Windows para fotografiar el DNI"
|
||||
>
|
||||
📸 Capturar Foto de DNI
|
||||
</button>
|
||||
|
||||
{supportsTorch && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={toggleTorch}
|
||||
style={{ flex: 1, minHeight: '48px' }}
|
||||
style={{ minHeight: '44px', padding: '0 0.85rem' }}
|
||||
>
|
||||
{torchEnabled ? '🔦 Apagar Linterna' : '💡 Encender Linterna'}
|
||||
{torchEnabled ? '🔦 Apagar' : '💡 Linterna'}
|
||||
</button>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
@@ -341,29 +529,29 @@ export const CameraScannerModal: React.FC<CameraScannerModalProps> = ({
|
||||
stopCamera();
|
||||
onClose();
|
||||
}}
|
||||
style={{ flex: 1, minHeight: '48px' }}
|
||||
style={{ minHeight: '44px', padding: '0 1rem' }}
|
||||
>
|
||||
Cancelar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Formulario alternativo de carga manual de texto crudo */}
|
||||
<form onSubmit={handleManualSubmit} style={{ display: 'flex', gap: '0.5rem', marginTop: '0.5rem' }}>
|
||||
{/* Formulario alternativo de carga manual de texto o número */}
|
||||
<form onSubmit={handleManualSubmit} style={{ display: 'flex', gap: '0.5rem', marginTop: '0.25rem' }}>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
placeholder="Pegar o escribir código DNI o número..."
|
||||
placeholder="Pegar código PDF417, QR o número de DNI..."
|
||||
value={manualText}
|
||||
onChange={(e) => setManualText(e.target.value)}
|
||||
style={{ flex: 1, fontSize: '0.9rem' }}
|
||||
style={{ flex: 1, fontSize: '0.875rem', minHeight: '42px' }}
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-primary"
|
||||
disabled={!manualText.trim() || isProcessing}
|
||||
style={{ minHeight: '48px', padding: '0 1rem' }}
|
||||
style={{ minHeight: '42px', padding: '0 1.15rem' }}
|
||||
>
|
||||
Procesar
|
||||
Interpretar
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
export type ThemeMode = 'dark' | 'light';
|
||||
|
||||
export const useTheme = () => {
|
||||
const [theme, setThemeState] = useState<ThemeMode>(() => {
|
||||
const saved = localStorage.getItem('onever_theme');
|
||||
if (saved === 'dark' || saved === 'light') return saved;
|
||||
return 'dark'; // Dark mode por defecto en puestos de control
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('onever_theme', theme);
|
||||
}, [theme]);
|
||||
|
||||
const toggleTheme = () => {
|
||||
setThemeState((prev) => (prev === 'dark' ? 'light' : 'dark'));
|
||||
};
|
||||
|
||||
const setTheme = (newTheme: ThemeMode) => {
|
||||
setThemeState(newTheme);
|
||||
};
|
||||
|
||||
return { theme, toggleTheme, setTheme };
|
||||
};
|
||||
+215
-46
@@ -1,5 +1,7 @@
|
||||
/* ==============================================================================
|
||||
Reset Base y Layout Táctil (100dvh) para Tablets
|
||||
OnEver Design System - Hoja de Estilos Base y Componentes
|
||||
Inspirado en C:\Workspace\OemspotPySYS\styles\design_system.py
|
||||
Optimizado para Tablets Samsung Galaxy Tab A9/A11 y Escritorio Windows
|
||||
============================================================================== */
|
||||
|
||||
*, *::before, *::after {
|
||||
@@ -13,16 +15,14 @@ html, body {
|
||||
height: 100%;
|
||||
height: 100dvh;
|
||||
overflow: hidden;
|
||||
background-color: var(--bg-app);
|
||||
color: var(--text-primary);
|
||||
background-color: var(--bg-main);
|
||||
color: var(--text-1);
|
||||
font-family: var(--font-family);
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
/* Prevenir zoom accidental en tablets */
|
||||
touch-action: manipulation;
|
||||
/* Prevenir recarga por arrastre en Chrome Android */
|
||||
overscroll-behavior-y: contain;
|
||||
user-select: none;
|
||||
}
|
||||
@@ -35,81 +35,250 @@ html, body {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Clases de utilidad táctil */
|
||||
.touch-target {
|
||||
min-height: var(--touch-min-size);
|
||||
min-width: var(--touch-min-size);
|
||||
/* ==============================================================================
|
||||
TIPOGRAFÍA Y TÍTULOS
|
||||
============================================================================== */
|
||||
h1, h2, h3, h4, .section-title {
|
||||
color: var(--text-1);
|
||||
font-family: var(--font-family);
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 1.25rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.telemetry-value {
|
||||
color: var(--success);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* ==============================================================================
|
||||
INPUTS Y COMBOS (Estilo OnEver: border-radius 10px, background #1E293B)
|
||||
============================================================================== */
|
||||
input, select, textarea, .input-touch {
|
||||
background-color: var(--input-bg);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-1);
|
||||
padding: 8px 12px;
|
||||
border-radius: 10px;
|
||||
min-height: 44px;
|
||||
font-family: var(--font-family);
|
||||
font-size: 0.95rem;
|
||||
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
input:focus, select:focus, textarea:focus, .input-touch:focus {
|
||||
border-color: var(--blue-base);
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
|
||||
}
|
||||
|
||||
input:read-only, textarea:read-only {
|
||||
background-color: var(--hover-bg);
|
||||
color: var(--text-3);
|
||||
border: 1px dashed var(--border);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
input::placeholder, textarea::placeholder {
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
select {
|
||||
cursor: pointer;
|
||||
appearance: auto;
|
||||
}
|
||||
|
||||
/* ==============================================================================
|
||||
BOTONES (Estilo OnEver: #2563EB, border-radius 10px, hover #3B82F6)
|
||||
============================================================================== */
|
||||
button, .btn, .touch-button {
|
||||
background-color: var(--blue-base);
|
||||
color: var(--btn-text);
|
||||
border-radius: 10px;
|
||||
padding: 8px 16px;
|
||||
font-weight: 600;
|
||||
font-family: var(--font-family);
|
||||
font-size: 0.95rem;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.touch-button {
|
||||
min-height: var(--touch-button-height);
|
||||
padding: 0 1.25rem;
|
||||
border-radius: var(--touch-radius);
|
||||
font-size: var(--font-size-base);
|
||||
font-weight: 600;
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease, transform 0.05s ease;
|
||||
gap: 0.5rem;
|
||||
transition: background-color 0.15s ease, transform 0.05s ease, border-color 0.15s ease;
|
||||
min-height: 44px;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
.touch-button:active {
|
||||
button:hover, .btn:hover, .touch-button:hover {
|
||||
background-color: var(--blue-hover);
|
||||
}
|
||||
|
||||
button:active, .btn:active, .touch-button:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
button:disabled, .btn:disabled, .touch-button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* Variantes de Botones */
|
||||
.btn-primary {
|
||||
background-color: var(--color-primary);
|
||||
background-color: var(--blue-base);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: var(--color-primary-hover);
|
||||
background-color: var(--blue-hover);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: var(--bg-surface-highlight);
|
||||
color: var(--text-primary);
|
||||
border-color: var(--border-strong);
|
||||
.btn-danger, button[class*="danger"] {
|
||||
background-color: var(--danger);
|
||||
color: var(--btn-text);
|
||||
}
|
||||
.btn-danger:hover, button[class*="danger"]:hover {
|
||||
background-color: var(--danger-hover);
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background-color: var(--color-danger);
|
||||
.btn-secondary, .btn-outline, button[class*="outline"] {
|
||||
background-color: transparent;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-2);
|
||||
}
|
||||
.btn-secondary:hover, .btn-outline:hover, button[class*="outline"]:hover {
|
||||
background-color: var(--hover-bg);
|
||||
color: var(--text-1);
|
||||
border-color: var(--border);
|
||||
}
|
||||
|
||||
.btn-success, button[class*="on-status"] {
|
||||
border: 1px solid var(--success);
|
||||
color: var(--success);
|
||||
background-color: var(--bg-sidebar);
|
||||
}
|
||||
.btn-success:hover, button[class*="on-status"]:hover {
|
||||
background-color: var(--success);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background-color: var(--color-success);
|
||||
color: #ffffff;
|
||||
/* ==============================================================================
|
||||
TARJETAS, PANELES Y HARDWARE CARDS (border 1px, radius 10px)
|
||||
============================================================================== */
|
||||
.card, .hardware-card, .right-panel {
|
||||
background-color: var(--bg-sidebar);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
transition: border-color 0.15s ease;
|
||||
}
|
||||
|
||||
/* Indicadores y Badges */
|
||||
.card:hover, .hardware-card:hover {
|
||||
border-color: var(--border);
|
||||
}
|
||||
|
||||
/* ==============================================================================
|
||||
PESTAÑAS ESTILO ONEVER
|
||||
============================================================================== */
|
||||
.tab-list {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.tab-btn {
|
||||
background: transparent;
|
||||
color: var(--text-3);
|
||||
padding: 9px 16px;
|
||||
font-weight: 600;
|
||||
border-radius: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: color 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.tab-btn:hover {
|
||||
background: transparent;
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.tab-btn.active, .tab-btn[aria-selected="true"] {
|
||||
background: transparent;
|
||||
color: var(--blue-base);
|
||||
border-bottom: 2px solid var(--blue-base);
|
||||
}
|
||||
|
||||
/* ==============================================================================
|
||||
BADGES E INDICADORES
|
||||
============================================================================== */
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.25rem 0.625rem;
|
||||
gap: 0.35rem;
|
||||
padding: 0.25rem 0.65rem;
|
||||
border-radius: 9999px;
|
||||
font-size: var(--font-size-xs);
|
||||
font-weight: 600;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.badge-success {
|
||||
background-color: var(--color-success-bg);
|
||||
color: var(--color-success);
|
||||
border: 1px solid var(--color-success);
|
||||
color: var(--success);
|
||||
border: 1px solid var(--success);
|
||||
}
|
||||
|
||||
.badge-danger {
|
||||
background-color: var(--color-danger-bg);
|
||||
color: var(--color-danger);
|
||||
border: 1px solid var(--color-danger);
|
||||
color: var(--danger);
|
||||
border: 1px solid var(--danger);
|
||||
}
|
||||
|
||||
.badge-info {
|
||||
background-color: rgba(56, 189, 248, 0.15);
|
||||
color: var(--color-info);
|
||||
border: 1px solid var(--color-info);
|
||||
background-color: var(--status-info-bg);
|
||||
color: var(--status-info);
|
||||
border: 1px solid var(--status-info);
|
||||
}
|
||||
|
||||
.badge-warning {
|
||||
background-color: var(--status-warning-bg);
|
||||
color: var(--warning);
|
||||
border: 1px solid var(--warning);
|
||||
}
|
||||
|
||||
.badge-neutral {
|
||||
background-color: var(--hover-bg);
|
||||
color: var(--text-2);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* ==============================================================================
|
||||
BARRA DE SCROLL MODERNA (Estilo OnEver: #0F172A / #374151)
|
||||
============================================================================== */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: var(--bg-main);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--bg-main);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-3);
|
||||
}
|
||||
|
||||
+117
-48
@@ -1,73 +1,142 @@
|
||||
/* ==============================================================================
|
||||
OnEver Design Tokens (Tokens Semánticos de Diseño)
|
||||
Optimizado para Garitas y Tablets de 4GB RAM (Samsung Tab A9 / A11)
|
||||
OnEver Design System - Tokens de Diseño Oficiales
|
||||
Fiel réplica de styles/design_system.py (OnEverDesignSystem)
|
||||
Paleta Dark / Light, Tipografía 'Segoe UI' / 'Roboto', Bordes 10px
|
||||
============================================================================== */
|
||||
|
||||
:root {
|
||||
/* Paleta Dark Mode (Por defecto en garitas de seguridad) */
|
||||
--bg-app: #0b0f19;
|
||||
--bg-surface: #121826;
|
||||
--bg-surface-elevated: #1a2235;
|
||||
--bg-surface-highlight: #232e48;
|
||||
/* --- PALETA DARK (Por defecto) --- */
|
||||
--bg-main: #0F172A;
|
||||
--bg-sidebar: #020617;
|
||||
--text-1: #E0E6ED;
|
||||
--text-2: #9CA3AF;
|
||||
--text-3: #6B7280;
|
||||
--border: #374151;
|
||||
--divider: #1F2937;
|
||||
--blue-base: #2563EB;
|
||||
--blue-hover: #3B82F6;
|
||||
--success: #10B981;
|
||||
--danger: #EF4444;
|
||||
--danger-hover: #F87171;
|
||||
--warning: #F59E0B;
|
||||
--selection-bg: #2563EB;
|
||||
--selection-text: #FFFFFF;
|
||||
--hover-bg: #23283E;
|
||||
--input-bg: #1E293B;
|
||||
--btn-text: #FFFFFF;
|
||||
--sidebar-icon: #FFFFFF;
|
||||
|
||||
--border-subtle: #232d42;
|
||||
--border-strong: #334155;
|
||||
/* Aliases Semánticos de Compatibilidad */
|
||||
--bg-app: var(--bg-main);
|
||||
--bg-surface: var(--bg-sidebar);
|
||||
--bg-surface-elevated: var(--input-bg);
|
||||
--bg-surface-highlight: var(--hover-bg);
|
||||
|
||||
--text-primary: #f8fafc;
|
||||
--text-secondary: #94a3b8;
|
||||
--text-muted: #64748b;
|
||||
--border-subtle: var(--divider);
|
||||
--border-strong: var(--border);
|
||||
|
||||
/* Estados y Semántica */
|
||||
--color-primary: #0284c7;
|
||||
--color-primary-hover: #0369a1;
|
||||
--color-success: #10b981;
|
||||
--text-primary: var(--text-1);
|
||||
--text-secondary: var(--text-2);
|
||||
--text-muted: var(--text-3);
|
||||
|
||||
--brand-primary: var(--blue-base);
|
||||
--color-primary: var(--blue-base);
|
||||
--color-primary-hover: var(--blue-hover);
|
||||
|
||||
--color-success: var(--success);
|
||||
--status-success: var(--success);
|
||||
--color-success-bg: rgba(16, 185, 129, 0.15);
|
||||
--color-danger: #ef4444;
|
||||
--color-danger-bg: rgba(239, 68, 68, 0.15);
|
||||
--color-warning: #f59e0b;
|
||||
--color-warning-bg: rgba(245, 158, 11, 0.15);
|
||||
--color-info: #38bdf8;
|
||||
|
||||
/* Touch Targets y Ergonomía Táctil */
|
||||
--color-danger: var(--danger);
|
||||
--status-danger: var(--danger);
|
||||
--color-danger-bg: rgba(239, 68, 68, 0.15);
|
||||
|
||||
--color-warning: var(--warning);
|
||||
--status-warning: var(--warning);
|
||||
--status-warning-bg: rgba(245, 158, 11, 0.15);
|
||||
|
||||
--color-info: #38BDF8;
|
||||
--status-info: #38BDF8;
|
||||
--status-info-bg: rgba(56, 189, 248, 0.15);
|
||||
|
||||
/* Touch Targets y Ergonomía */
|
||||
--touch-min-size: 48px;
|
||||
--touch-button-height: 52px;
|
||||
--touch-input-height: 50px;
|
||||
--touch-radius: 8px;
|
||||
--touch-button-height: 48px;
|
||||
--touch-input-height: 44px;
|
||||
--touch-radius: 10px;
|
||||
--radius-md: 10px;
|
||||
--radius-lg: 12px;
|
||||
|
||||
/* Tipografía */
|
||||
--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
--font-family: 'Segoe UI', 'Roboto', system-ui, -apple-system, sans-serif;
|
||||
--font-size-xs: 0.75rem;
|
||||
--font-size-sm: 0.875rem;
|
||||
--font-size-base: 1rem;
|
||||
--font-size-base: 0.9375rem;
|
||||
--font-size-lg: 1.125rem;
|
||||
--font-size-xl: 1.25rem;
|
||||
--font-size-2xl: 1.5rem;
|
||||
|
||||
/* Sombras y elevación */
|
||||
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
||||
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
|
||||
/* Sombras */
|
||||
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
|
||||
--shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.45);
|
||||
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
/* Modo Claro Opcional (Para puestos al sol directo) */
|
||||
/* --- PALETA LIGHT (OnEverDesignSystem Light) --- */
|
||||
[data-theme="light"] {
|
||||
--bg-app: #f1f5f9;
|
||||
--bg-surface: #ffffff;
|
||||
--bg-surface-elevated: #f8fafc;
|
||||
--bg-surface-highlight: #e2e8f0;
|
||||
--bg-main: #FFFFFF;
|
||||
--bg-sidebar: #F4F5F6;
|
||||
--text-1: #212327;
|
||||
--text-2: #50565E;
|
||||
--text-3: #808893;
|
||||
--border: #DEE0E3;
|
||||
--divider: #EFEFF0;
|
||||
--blue-base: #006FFF;
|
||||
--blue-hover: #338BFF;
|
||||
--success: #38CC65;
|
||||
--danger: #F0383B;
|
||||
--danger-hover: #FF7B80;
|
||||
--warning: #F5A524;
|
||||
--selection-bg: #EBEFFF;
|
||||
--selection-text: #006FFF;
|
||||
--hover-bg: #F3F4F6;
|
||||
--input-bg: #FFFFFF;
|
||||
--btn-text: #FFFFFF;
|
||||
--sidebar-icon: #374151;
|
||||
|
||||
--border-subtle: #cbd5e1;
|
||||
--border-strong: #94a3b8;
|
||||
--bg-app: var(--bg-main);
|
||||
--bg-surface: var(--bg-sidebar);
|
||||
--bg-surface-elevated: var(--input-bg);
|
||||
--bg-surface-highlight: var(--hover-bg);
|
||||
|
||||
--text-primary: #0f172a;
|
||||
--text-secondary: #475569;
|
||||
--text-muted: #64748b;
|
||||
--border-subtle: var(--divider);
|
||||
--border-strong: var(--border);
|
||||
|
||||
--color-primary: #0284c7;
|
||||
--color-primary-hover: #0369a1;
|
||||
--color-success: #059669;
|
||||
--color-success-bg: rgba(5, 150, 105, 0.1);
|
||||
--color-danger: #dc2626;
|
||||
--color-danger-bg: rgba(220, 38, 38, 0.1);
|
||||
--color-warning: #d97706;
|
||||
--color-warning-bg: rgba(217, 119, 6, 0.1);
|
||||
--text-primary: var(--text-1);
|
||||
--text-secondary: var(--text-2);
|
||||
--text-muted: var(--text-3);
|
||||
|
||||
--brand-primary: var(--blue-base);
|
||||
--color-primary: var(--blue-base);
|
||||
--color-primary-hover: var(--blue-hover);
|
||||
|
||||
--color-success: var(--success);
|
||||
--status-success: var(--success);
|
||||
--color-success-bg: rgba(56, 204, 101, 0.15);
|
||||
|
||||
--color-danger: var(--danger);
|
||||
--status-danger: var(--danger);
|
||||
--color-danger-bg: rgba(240, 56, 59, 0.15);
|
||||
|
||||
--color-warning: var(--warning);
|
||||
--status-warning: var(--warning);
|
||||
--status-warning-bg: rgba(245, 165, 36, 0.15);
|
||||
|
||||
--color-info: #0284C7;
|
||||
--status-info: #0284C7;
|
||||
--status-info-bg: rgba(2, 132, 199, 0.15);
|
||||
|
||||
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
|
||||
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { workstationApi } from '../api/workstationApi';
|
||||
import { accessApi } from '../api/accessApi';
|
||||
import { hardwareApi } from '../api/hardwareApi';
|
||||
import { useWebSocket } from '../hooks/useWebSocket';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
import { CameraScannerModal } from '../components/scanner/CameraScannerModal';
|
||||
import {
|
||||
WorkstationConfig,
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
|
||||
export const ControlPostView: React.FC = () => {
|
||||
const { user, workstation, logout } = useAuth();
|
||||
const { theme, toggleTheme } = useTheme();
|
||||
|
||||
// Configuración de Estación y Módulos
|
||||
const [config, setConfig] = useState<WorkstationConfig | null>(null);
|
||||
@@ -348,6 +350,16 @@ export const ControlPostView: React.FC = () => {
|
||||
👤 Operador: <strong>{user?.username}</strong>
|
||||
</span>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={toggleTheme}
|
||||
style={{ minHeight: '38px', padding: '0 0.75rem', fontSize: '0.85rem' }}
|
||||
title="Cambiar tema OnEver (Oscuro / Claro)"
|
||||
>
|
||||
{theme === 'dark' ? '☀️' : '🌙'}
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
// ==============================================================================
|
||||
// Vista de Inicio de Sesión de Operador / Guardia
|
||||
// Optimizado para uso táctil en tablets Samsung Galaxy Tab (Touch-First)
|
||||
// Sistema de Diseño OnEver (C:\Workspace\OemspotPySYS\styles\design_system.py)
|
||||
// Optimizado para uso táctil en tablets Samsung Galaxy Tab y Windows (Touch-First)
|
||||
// ==============================================================================
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { workstationApi, WorkstationListItem } from '../api/workstationApi';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
|
||||
export const LoginView: React.FC = () => {
|
||||
const { login, workstation, setWorkstation } = useAuth();
|
||||
const { theme, toggleTheme } = useTheme();
|
||||
|
||||
const [username, setUsername] = useState<string>('guardia');
|
||||
const [password, setPassword] = useState<string>('');
|
||||
const [selectedWks, setSelectedWks] = useState<string>(workstation || 'CFT-DESK');
|
||||
@@ -17,11 +21,14 @@ export const LoginView: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
// Carga de Workstations reales desde SQL Server
|
||||
workstationApi.getAvailableWorkstations()
|
||||
workstationApi
|
||||
.getAvailableWorkstations()
|
||||
.then((list) => {
|
||||
if (list && list.length > 0) {
|
||||
setAvailableWorkstations(list);
|
||||
const currentMatch = list.find((w) => w.name.toUpperCase() === (workstation || 'CFT-DESK').toUpperCase());
|
||||
const currentMatch = list.find(
|
||||
(w) => w.name.toUpperCase() === (workstation || 'CFT-DESK').toUpperCase()
|
||||
);
|
||||
if (currentMatch) {
|
||||
setSelectedWks(currentMatch.name);
|
||||
} else {
|
||||
@@ -61,19 +68,39 @@ export const LoginView: React.FC = () => {
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
minHeight: '100%',
|
||||
backgroundColor: 'var(--bg-app)',
|
||||
backgroundColor: 'var(--bg-main)',
|
||||
padding: '1.5rem',
|
||||
position: 'relative',
|
||||
}}
|
||||
>
|
||||
{/* Botón flotante de alternancia de tema (Oscuro / Claro) */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggleTheme}
|
||||
className="btn-outline"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: '1.25rem',
|
||||
right: '1.25rem',
|
||||
minHeight: '38px',
|
||||
padding: '0 0.85rem',
|
||||
fontSize: '0.85rem',
|
||||
}}
|
||||
title="Cambiar tema OnEver (Oscuro / Claro)"
|
||||
>
|
||||
{theme === 'dark' ? '☀️ Modo Claro' : '🌙 Modo Oscuro'}
|
||||
</button>
|
||||
|
||||
<div
|
||||
className="card"
|
||||
style={{
|
||||
width: '100%',
|
||||
maxWidth: '460px',
|
||||
boxShadow: 'var(--shadow-lg)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
borderRadius: 'var(--radius-lg)',
|
||||
padding: '2rem',
|
||||
backgroundColor: 'var(--bg-sidebar)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: '10px',
|
||||
padding: '2.25rem',
|
||||
}}
|
||||
>
|
||||
{/* Cabecera del Login */}
|
||||
@@ -82,8 +109,9 @@ export const LoginView: React.FC = () => {
|
||||
style={{
|
||||
width: '64px',
|
||||
height: '64px',
|
||||
borderRadius: '16px',
|
||||
backgroundColor: 'var(--accent-primary-alpha)',
|
||||
borderRadius: '12px',
|
||||
backgroundColor: 'var(--hover-bg)',
|
||||
border: '1px solid var(--border)',
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
@@ -93,10 +121,18 @@ export const LoginView: React.FC = () => {
|
||||
>
|
||||
🛡️
|
||||
</div>
|
||||
<h1 style={{ fontSize: '1.6rem', fontWeight: 700, margin: '0 0 0.5rem 0', color: 'var(--text-primary)' }}>
|
||||
<h1
|
||||
style={{
|
||||
fontSize: '1.65rem',
|
||||
fontWeight: 700,
|
||||
margin: '0 0 0.4rem 0',
|
||||
color: 'var(--text-1)',
|
||||
letterSpacing: '-0.02em',
|
||||
}}
|
||||
>
|
||||
OnEverControl
|
||||
</h1>
|
||||
<p style={{ margin: 0, fontSize: '0.9rem', color: 'var(--text-muted)' }}>
|
||||
<p style={{ margin: 0, fontSize: '0.9rem', color: 'var(--text-2)' }}>
|
||||
Puesto de Control Web • Modo Cliente Garita
|
||||
</p>
|
||||
</div>
|
||||
@@ -106,15 +142,18 @@ export const LoginView: React.FC = () => {
|
||||
<div
|
||||
style={{
|
||||
padding: '0.75rem 1rem',
|
||||
backgroundColor: 'var(--status-danger-bg)',
|
||||
color: 'var(--status-danger)',
|
||||
borderRadius: 'var(--radius-sm)',
|
||||
backgroundColor: 'var(--color-danger-bg)',
|
||||
color: 'var(--danger-hover)',
|
||||
borderRadius: '8px',
|
||||
marginBottom: '1.5rem',
|
||||
fontSize: '0.9rem',
|
||||
border: '1px solid var(--status-danger)',
|
||||
fontSize: '0.875rem',
|
||||
border: '1px solid var(--danger)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '0.5rem',
|
||||
}}
|
||||
>
|
||||
⚠️ {errorMsg}
|
||||
<span>⚠️</span> {errorMsg}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -126,7 +165,7 @@ export const LoginView: React.FC = () => {
|
||||
display: 'block',
|
||||
fontSize: '0.85rem',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text-secondary)',
|
||||
color: 'var(--text-2)',
|
||||
marginBottom: '0.5rem',
|
||||
}}
|
||||
>
|
||||
@@ -157,7 +196,7 @@ export const LoginView: React.FC = () => {
|
||||
display: 'block',
|
||||
fontSize: '0.85rem',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text-secondary)',
|
||||
color: 'var(--text-2)',
|
||||
marginBottom: '0.5rem',
|
||||
}}
|
||||
>
|
||||
@@ -183,7 +222,7 @@ export const LoginView: React.FC = () => {
|
||||
display: 'block',
|
||||
fontSize: '0.85rem',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text-secondary)',
|
||||
color: 'var(--text-2)',
|
||||
marginBottom: '0.5rem',
|
||||
}}
|
||||
>
|
||||
@@ -207,9 +246,9 @@ export const LoginView: React.FC = () => {
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
width: '100%',
|
||||
minHeight: '52px',
|
||||
fontSize: '1.05rem',
|
||||
fontWeight: 600,
|
||||
minHeight: '50px',
|
||||
fontSize: '1rem',
|
||||
fontWeight: 700,
|
||||
marginTop: '0.5rem',
|
||||
}}
|
||||
>
|
||||
@@ -217,8 +256,8 @@ export const LoginView: React.FC = () => {
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div style={{ marginTop: '2rem', textAlign: 'center', fontSize: '0.75rem', color: 'var(--text-muted)' }}>
|
||||
OnEverControl Web v0.6.0-beta • Conectado a Microsoft SQL Server videoman
|
||||
<div style={{ marginTop: '2rem', textAlign: 'center', fontSize: '0.75rem', color: 'var(--text-3)' }}>
|
||||
OnEverControl Web v0.6.1-beta • Conectado a Microsoft SQL Server videoman
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user