Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/lucavallini/aibar-frontend/llms.txt

Use this file to discover all available pages before exploring further.

The Audit Log (/auditoria) is a read-only chronological record of every significant action performed anywhere in the Aibar SRL App. Every time a user creates a trip, edits a driver, cancels a fuel entry, or deactivates an account, the backend writes a new audit event capturing who did it, what entity was affected, and a detail payload describing the change. The log is visible to administrators only and is the primary tool for accountability, tracing errors, and understanding the full history of any record across all modules.
This module is protected by adminGuard. Only users with the administrador role can access /auditoria. Any other authenticated user is automatically redirected to /viajes.

Data Model

Auditoria

Each row in the audit log is represented by the following interface:
export interface Auditoria {
  id: string;           // Unique identifier of the audit event
  usuario_id: string;   // ID of the user who performed the action
  tipo_accion: string;  // One of: 'alta', 'edicion', 'cancelacion', 'baja'
  entidad: string;      // Module/entity type affected (e.g. 'viaje', 'chofer')
  entidad_id: string;   // ID of the specific record that was affected
  detalle: string | null; // Free-text JSON blob describing what changed
  fecha_hora: string;   // ISO 8601 timestamp of when the action occurred
}

RespuestaPaginada<Auditoria>

All list responses are wrapped in the shared pagination envelope:
export interface RespuestaPaginada<T> {
  items: T[];
  total: number;
  pagina: number;
  tamano_pagina: number;
  total_paginas: number;
}

Response Fields

id
string
Unique UUID of this audit log entry. Never reused or modified.
usuario_id
string
The id of the Usuario who triggered this event. Cross-reference with the Users module to identify the responsible operator or administrator.
tipo_accion
string
The category of action that was recorded. One of alta, edicion, cancelacion, or baja. See Action Types below.
entidad
string
The module or entity type that was affected. Matches one of the values used in the entity filter: viaje, chofer, camion, multa, combustible, usuario.
entidad_id
string
The UUID of the specific record within entidad that was created, edited, cancelled, or deactivated.
detalle
string | null
A free-text or JSON-serialised blob describing the specifics of the change — for example, which fields were modified and what their old and new values were. Can be null for actions where no additional detail is relevant. The UI renders this as plain text; null values are displayed as -.
fecha_hora
string
ISO 8601 timestamp of when the action occurred (e.g. "2025-06-15T14:32:07.000Z"). The UI formats this as dd/MM/yyyy HH:mm using Angular’s DatePipe.

Action Types

Every audit event carries a tipo_accion value that describes the kind of operation performed. The frontend applies a CSS badge class matching the action name.

alta

A new record was created. Triggered when a trip is registered, a driver is added, a truck is onboarded, etc.

edicion

An existing record was edited. Triggered when any field on an existing entity is updated through the Edit modal.

cancelacion

A record was cancelled. Typically used for trips or fines that are voided without being permanently removed.

baja

A record was soft-deactivated or deleted. Sets activo: false on the affected entity rather than removing it from the database.

Entity Filter

The audit log can be narrowed to a single module using the entidad query parameter. The component exposes a <select> populated from the entidades array defined in ListaAuditoria:
entidades = ['viaje', 'chofer', 'camion', 'multa', 'combustible', 'usuario'];
Selecting an option calls cambiarFiltroEntidad(valor), which resets the page to 1 and refetches with the new filter. Selecting Todos los eventos sends no entidad parameter, returning the full cross-module history.
Filter valueModule
viajeTrips
choferDrivers
camionTrucks
multaFines
combustibleFuel
usuarioUser accounts

AuditoriaService API

The service is registered application-wide via providedIn: 'root' and exposes a single method.
@Injectable({ providedIn: 'root' })
export class AuditoriaService {
  private apiUrl = `${environment.apiUrl}/auditoria`;

  constructor(private http: HttpClient) {}

  listar(
    entidad?: string,
    pagina: number = 1,
    tamanoPagina: number = 50
  ): Observable<RespuestaPaginada<Auditoria>> {
    const filtro = entidad ? `&entidad=${entidad}` : '';
    return this.http.get<RespuestaPaginada<Auditoria>>(
      `${this.apiUrl}/?pagina=${pagina}&tamano_pagina=${tamanoPagina}${filtro}`
    );
  }
}

listar(entidad?, pagina, tamanoPagina)

Fetches a paginated page of audit events, optionally filtered to a single entity type.
ParameterTypeDefaultDescription
entidadstringundefinedWhen provided, only events for this entity type are returned. Omit or pass undefined for all entities.
paginanumber1Page number to retrieve
tamanoPaginanumber50Records per page — larger than other modules to reduce navigation through high-volume audit data
The default page size for the audit log is 50 records, compared to 20 in most other modules. This is intentional: audit events are dense and read-only, so larger pages reduce the number of clicks needed to review a period of activity.
HTTP requests:
# All events, first page
GET /auditoria/?pagina=1&tamano_pagina=50

# Filtered to trips only
GET /auditoria/?pagina=1&tamano_pagina=50&entidad=viaje

# Page 3 of driver events
GET /auditoria/?pagina=3&tamano_pagina=50&entidad=chofer
Returns: Observable<RespuestaPaginada<Auditoria>>

Usage Example

The following TypeScript snippet shows how ListaAuditoria loads events and reacts to filter changes, taken directly from the component source:
export class ListaAuditoria implements OnInit {
  eventos = signal<Auditoria[]>([]);
  filtroEntidad = signal<string>('');

  cargando = signal(true);
  error = signal<string | null>(null);

  pagina = signal(1);
  totalPaginas = signal(1);
  total = signal(0);
  tamanoPagina = 50;

  entidades = ['viaje', 'chofer', 'camion', 'multa', 'combustible', 'usuario'];

  constructor(private auditoriaService: AuditoriaService) {}

  ngOnInit(): void {
    this.cargarEventos();
  }

  cargarEventos(): void {
    this.cargando.set(true);
    this.error.set(null);

    // Pass undefined when the filter is empty to fetch all entities
    const entidad = this.filtroEntidad() || undefined;

    this.auditoriaService.listar(entidad, this.pagina(), this.tamanoPagina).subscribe({
      next: (respuesta) => {
        this.eventos.set(respuesta.items);
        this.total.set(respuesta.total);
        this.totalPaginas.set(respuesta.total_paginas);
        this.cargando.set(false);
      },
      error: () => {
        this.error.set('No se pudieron cargar los eventos de auditoría');
        this.cargando.set(false);
      }
    });
  }

  // Called when the entity <select> changes — always resets to page 1
  cambiarFiltroEntidad(valor: string): void {
    this.filtroEntidad.set(valor);
    this.pagina.set(1);
    this.cargarEventos();
  }

  cambiarPagina(nueva: number): void {
    this.pagina.set(nueva);
    this.cargarEventos();
  }
}

Audit Table Columns

The /auditoria view renders one row per event with the following four columns:
ColumnSource fieldNotes
Fecha y horafecha_horaFormatted as dd/MM/yyyy HH:mm via Angular DatePipe
Accióntipo_accionDisplayed as a coloured badge; CSS class matches the action name
EntidadentidadPlain text module name
DetalledetalleRaw detail string; renders - when null
Audit records are read-only. There are no edit or delete controls anywhere in the frontend. The table and its pagination component are the only UI elements on the page, intentionally keeping the view simple and tamper-proof.

Workflow

1

Navigate to Auditoría

Click Auditoría in the sidebar. The page loads the most recent 50 events across all modules, sorted by fecha_hora descending.
2

Filter by entity (optional)

Use the Filtrar por tipo dropdown to narrow the log to a specific module such as viaje or usuario. The page resets to 1 and the table refreshes immediately.
3

Paginate through history

Use the pagination controls at the bottom of the table to move through older events. Each page loads 50 records from the API.
4

Inspect the Detalle column

Read the detalle field on any row to see what specifically changed. For edits this typically contains a JSON snapshot of the modified fields. For alta and baja events it may contain the full entity snapshot or be null.

Build docs developers (and LLMs) love