Overview
The Role Management system defines access levels and permissions across the P.FLEX platform. Each role encapsulates a set of permissions that control what users can view and modify in the system.Role Data Model
TheRoleDefinition interface defines the structure of roles:
Unique identifier for the role
Display name of the role (e.g., “Supervisor”, “Jefatura”)
Brief description of the role’s responsibilities and purpose
Array of permission strings that define what the role can accessExample:
["Ver Dashboard", "Aprobar OTs", "Reportes"]System Roles
P.FLEX includes four core system roles:Jefatura (Management)
Jefatura Permissions
- Ver Dashboard: Access to executive dashboard and KPIs
- Aprobar OTs: Approve and manage work orders
- Reportes: Generate and export production reports
- Gestión Usuarios: Manage user accounts and permissions
Supervisor
Supervisor Permissions
- Asignar Tareas: Assign work orders to operators
- Cerrar Turno: Close shift and generate shift reports
- Validar Calidad: Validate quality control checks
- Ver OTs: View work orders (read-only)
Operario (Operator)
Operario Permissions
- Registrar Producción: Record production quantities and status
- Ver OTs: View assigned work orders
Operarios can be restricted to specific production areas
Sistemas (System Admin)
Sistemas Permissions
- Admin Total: Full system access including:
- System configuration
- Database management
- User administration
- Machine configuration
- Security settings
Role Management Operations
Updating a Role
Modify role permissions usingupdateRole():
Modify Permissions
Toggle permissions on/off using the permission checkboxes:
- Dashboard access
- Inventory management
- Quality validation
- Report generation
Deleting a Role
Remove custom roles usingdeleteRole():
Permission System
The permission system uses string-based permission keys:Available Permissions
Dashboard & Reporting
Dashboard & Reporting
Ver Dashboard- View production dashboard and metricsReportes- Generate and export reportsVer KPIs- Access key performance indicators
Work Order Management
Work Order Management
Ver OTs- View work orders (read-only)Aprobar OTs- Approve and modify work ordersAsignar Tareas- Assign work orders to operators
Production & Quality
Production & Quality
Registrar Producción- Record production dataValidar Calidad- Perform quality control validationCerrar Turno- Close shift and generate reports
Inventory
Inventory
Ver Inventario- View inventory levelsAjustar Inventario- Manually adjust stock quantities
Administration
Administration
Gestión Usuarios- Create and manage user accountsAdmin Total- Full system administration access
Permission Matrix
The role management interface displays a visual permission matrix:| Module | Jefatura | Supervisor | Operario | Sistemas |
|---|---|---|---|---|
| Dashboard | ✅ | ❌ | ❌ | ✅ |
| Configuración Global | ❌ | ❌ | ❌ | ✅ |
| Edición de Registros | ✅ | ⚠️ | ❌ | ✅ |
✅ = Full Access | ⚠️ = Limited Access | ❌ = No Access
Managing Permissions
Toggle Permission
Permissions can be toggled programmatically:Audit Logging
All role modifications are logged:| Action | Module | Details |
|---|---|---|
| Update Role | ADMIN | Role name and modified permissions |
| Delete Role | ADMIN | Role name |
Best Practices
Principle of Least Privilege
Assign only the minimum permissions required for each role to perform their duties
Regular Audits
Periodically review role permissions to ensure they align with current responsibilities
Document Changes
Use descriptive role descriptions to document the purpose and scope of each role
Test Before Deploy
Test permission changes with a test account before applying to production roles
Code Reference
Key source files:- Data Model:
src/features/admin/models/admin.models.ts:13-18 - Service Methods:
src/features/admin/services/admin.service.ts:42-55 - UI Component:
src/features/admin/components/admin-roles.component.ts - Default Roles:
src/services/state.service.ts:61-66
