# Activity Logs

## Purpose
Activity Logs provides a comprehensive audit trail of all system activities. It tracks user actions, system events, and administrative changes for security and compliance purposes. The page allows filtering, searching, and exporting log data.

## Components
- Page header with icon and title
- Statistics cards (4 metrics)
- Search & Filter section
- Logs data table
- Log Details modal
- Business Rules section

## Header
- **Title**: "Activity Logs"
- **Subtitle**: "Audit trail and system activity tracking"
- **Page Icon**: Blue background with document icon

### Statistics Cards
| Card | ID | Description |
|------|-----|-------------|
| Total Logs | `totalLogs` | All logged activities |
| Today's Actions | `todayActions` | Activities today |
| Failed Actions | `failedActions` | Failed activities |
| Active Users | `activeUsers` | Users with recent activity |

## Filters
| Filter | ID | Type | Options |
|--------|-----|------|---------|
| Search | `searchInput` | text | placeholder: "Search logs..." |
| Action Type | `filterAction` | select | All, Login, Logout, Create, Update, Delete, Export |
| User | `filterUser` | text | — |
| Date From | `filterDateFrom` | date | — |
| Date To | `filterDateTo` | date | — |

## Search
- **Input ID**: `searchInput`
- **Placeholder**: "Search logs..."
- **Searches**: User, action, module, IP address

## Buttons
| Button | Action | Location |
|--------|--------|----------|
| Search | Apply search query | Filter bar |
| Reset Filters | Clear all filters | Filter bar |
| Export Logs | Export logs to CSV | Action bar |
| Refresh | Reload log list | Action bar |
| Clear Logs | Clear old logs | Action bar |

## Forms
None (read-only log viewer)

## Tables

### Logs Table
| Column | Description |
|--------|-------------|
| Log ID | Unique log identifier |
| Timestamp | When the action occurred |
| User | User who performed the action |
| Action | Action type (Login, Create, Update, Delete, Export) |
| Module | Affected module |
| IP Address | User's IP address |
| Details | Additional details |
| Status | Action status (Success, Failed) |

## Action Buttons

### Row Actions
| Button | Function | Icon |
|--------|----------|------|
| View Details | View full log details | Eye |

### Batch Actions
| Button | Function | Location |
|--------|----------|----------|
| Export Selected | Export selected logs | Action bar |
| Delete Selected | Delete selected logs | Action bar |

## Workflow
1. Admin navigates to Activity Logs page
2. Views statistics cards showing log counts
3. Uses filters to find specific activities
4. Can filter by action type, user, date range
5. Views log list with all details
6. Can view full log details in modal
7. Can export filtered logs to CSV
8. Can clear old logs (with confirmation)
9. Can refresh list to get latest data

## Translation Requirements
| Key | English | Description |
|-----|---------|-------------|
| `activity_logs` | Activity Logs | Page title |
| `audit_trail_tracking` | Audit trail and system activity tracking | Subtitle |
| `total_logs` | Total Logs | Stat label |
| `todays_actions` | Today's Actions | Stat label |
| `failed_actions` | Failed Actions | Stat label |
| `active_users` | Active Users | Stat label |
| `search_logs` | Search logs... | Placeholder |
| `action_type` | Action Type | Filter label |
| `user` | User | Filter label |
| `date_range` | Date Range | Filter label |
| `export_logs` | Export Logs | Button text |
| `refresh` | Refresh | Button text |
| `clear_logs` | Clear Logs | Button text |
| `log_id` | Log ID | Column |
| `timestamp` | Timestamp | Column |
| `action` | Action | Column |
| `module` | Module | Column |
| `ip_address` | IP Address | Column |
| `details` | Details | Column |
| `status` | Status | Column |
| `view_details` | View Details | Action |
| `login` | Login | Action |
| `logout` | Logout | Action |
| `create` | Create | Action |
| `update` | Update | Action |
| `delete` | Delete | Action |
| `export` | Export | Action |
| `success` | Success | Status |
| `failed` | Failed | Status |
| `clear_old_logs` | Clear Old Logs | Confirmation title |
| `clear_confirmation` | Are you sure you want to clear old logs? | Confirmation message |

## Responsive Requirements

### Desktop (≥1024px)
- 4-column statistics grid
- Horizontal filter bar
- Full-width data table

### Tablet (768px–1023px)
- 2-column statistics grid
- Stacked filter fields
- Horizontally scrollable table

### Mobile (<768px)
- 2-column statistics grid
- Full-width stacked filters
- Horizontally scrollable table

## API Dependency
- **Logs API**: GET `/api/logs` — List activity logs
- **Log Details**: GET `/api/logs/:id` — Get log details
- **Export Logs**: GET `/api/logs/export` — CSV export
- **Clear Logs**: DELETE `/api/logs/clear` — Clear old logs
