## Backend Changes - Add new API endpoints: combustible, pois, mantenimiento, video, configuracion - Fix vehiculos endpoint to return paginated response with items array - Add /vehiculos/all endpoint for non-paginated list - Add /geocercas/all endpoint - Add /alertas/configuracion GET/PUT endpoints - Add /viajes/activos and /viajes/iniciar endpoints - Add /reportes/stats, /reportes/templates, /reportes/preview endpoints - Add /conductores/all and /conductores/disponibles endpoints - Update router.py to include all new modules ## Frontend Changes - Fix authentication token handling (snake_case vs camelCase) - Update vehiculosApi.listAll to use /vehiculos/all - Fix FuelGauge component usage in Combustible page - Fix chart component exports (named + default exports) - Update API client for proper token refresh ## Infrastructure - Rename services from ADAN to ATLAS - Configure Cloudflare tunnel for atlas.consultoria-as.com - Update systemd service files - Configure PostgreSQL with TimescaleDB - Configure Redis, Mosquitto, Traccar, MediaMTX ## Documentation - Update installation guides - Update API reference - Rename all ADAN references to ATLAS Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""Endpoints para configuración del sistema."""
|
|
|
|
from typing import Optional
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.core.database import get_db
|
|
from app.core.security import get_current_user
|
|
from app.models.usuario import Usuario
|
|
from app.models.configuracion import Configuracion
|
|
|
|
router = APIRouter(prefix="/configuracion", tags=["Configuracion"])
|
|
|
|
|
|
@router.get("")
|
|
async def obtener_configuracion(
|
|
db: AsyncSession = Depends(get_db),
|
|
current_user: Usuario = Depends(get_current_user),
|
|
):
|
|
"""Obtiene la configuración del sistema."""
|
|
result = await db.execute(select(Configuracion).limit(1))
|
|
config = result.scalar_one_or_none()
|
|
if not config:
|
|
return {
|
|
"nombre_empresa": "Atlas GPS",
|
|
"timezone": "America/Mexico_City",
|
|
"unidad_distancia": "km",
|
|
"unidad_velocidad": "km/h",
|
|
"limite_velocidad_default": 120,
|
|
"alerta_bateria_baja": 20,
|
|
"alerta_sin_senal_minutos": 30,
|
|
}
|
|
return {
|
|
"nombre_empresa": config.valor if config.clave == "nombre_empresa" else "Atlas GPS",
|
|
"timezone": "America/Mexico_City",
|
|
"unidad_distancia": "km",
|
|
"unidad_velocidad": "km/h",
|
|
}
|
|
|
|
|
|
@router.patch("")
|
|
async def actualizar_configuracion(
|
|
data: dict,
|
|
db: AsyncSession = Depends(get_db),
|
|
current_user: Usuario = Depends(get_current_user),
|
|
):
|
|
"""Actualiza la configuración del sistema."""
|
|
for clave, valor in data.items():
|
|
result = await db.execute(select(Configuracion).where(Configuracion.clave == clave))
|
|
config = result.scalar_one_or_none()
|
|
if config:
|
|
config.valor = str(valor)
|
|
else:
|
|
config = Configuracion(clave=clave, valor=str(valor))
|
|
db.add(config)
|
|
await db.commit()
|
|
return {"message": "Configuración actualizada"}
|