diff --git a/.gitignore b/.gitignore index e69de29..decc95a 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +# Claude Code confidential files +.claude/ diff --git a/.last-branch b/.last-branch index c1c0a1c..2d75690 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260205-13-changelog-python-structure +v20260207-02-wiki-documentation diff --git a/TODO-audit-logging.md b/TODO-audit-logging.md new file mode 100644 index 0000000..305e943 --- /dev/null +++ b/TODO-audit-logging.md @@ -0,0 +1,332 @@ +# TODO: Audit Logging Uitbreiding - Vervolg + +**Branch:** `v20260206-10-audit-logging-expansion` +**Datum:** 2026-02-07 +**Status:** Deel 1 compleet, deel 2 nog te doen + +--- + +## ✅ Wat is al gedaan (Deel 1) + +### Model & Database +- ✅ Model hernoemd: `AdminLog` → `AuditLog` +- ✅ Database migratie toegevoegd: `migrate_rename_admin_logs_to_audit_logs()` + - Hernoemt tabel `admin_logs` → `audit_logs` + - Idempotent en veilig +- ✅ Backwards compatibility: `AdminLog = AuditLog` alias + +### Code Updates +- ✅ `admin_logging.py`: `log_admin_event()` → `log_audit_event()` (met alias) +- ✅ `routes_core.py`: Updated naar `AuditLog` +- ✅ `routes_shared.py`: Updated naar `AuditLog` +- ✅ Gecommit en gepusht naar Gitea + +--- + +## 🔄 Wat moet nog (Deel 2) + +### 1. UI Updates + +**Bestand:** `containers/backupchecks/src/templates/main/logging.html` + +**Te wijzigen:** +- Page title: "Admin Activity" → "System Audit Log" of "Activity Log" +- Breadcrumb indien aanwezig + +**Huidige code zoeken naar:** +```html +

Admin Activity

+ +Admin Activity +``` + +--- + +### 2. Settings Logging Toevoegen + +**Locatie:** `containers/backupchecks/src/backend/app/main/routes_settings.py` + +**Routes die logging nodig hebben:** + +#### A. General Settings (`/settings/general` POST) +```python +# Na regel waar settings worden opgeslagen +# Voeg toe na db.session.commit() + +from ..admin_logging import log_audit_event +import json + +# Track wat er gewijzigd is +changes = {} +if old_value != new_value: + changes['setting_name'] = {'old': old_value, 'new': new_value} + +if changes: + log_audit_event( + event_type="settings_general", + message=f"Updated {len(changes)} general setting(s)", + details=json.dumps(changes, indent=2) + ) +``` + +**Settings om te tracken:** +- `ui_timezone` +- `require_daily_dashboard_visit` +- `is_sandbox_environment` +- Andere SystemSettings velden + +#### B. Mail Settings (`/settings/mail` POST) +```python +log_audit_event( + event_type="settings_mail", + message="Updated mail settings", + details=json.dumps({ + 'imap_server': settings.imap_server, + 'auto_import_enabled': settings.auto_import_enabled, + # etc. + }, indent=2) +) +``` + +#### C. Autotask Settings (`/settings/autotask` POST) +```python +log_audit_event( + event_type="settings_autotask", + message="Updated Autotask integration settings", + details=json.dumps({ + 'url': settings.autotask_url, + 'username': settings.autotask_username, + # NIET het wachtwoord loggen! + 'enabled': settings.autotask_enabled + }, indent=2) +) +``` + +**BELANGRIJK:** Wachtwoorden NOOIT loggen in details! + +--- + +### 3. Export Logging Toevoegen + +#### A. Customers Export (`/customers/export`) + +**Huidige code:** `routes_customers.py` regel ~421 + +**Toevoegen:** +```python +# Voor return Response(...) +from ..admin_logging import log_audit_event + +log_audit_event( + event_type="export_customers", + message=f"Exported {len(items)} customers to CSV", + details=f"format=CSV, count={len(items)}" +) +``` + +#### B. Jobs Export (`/settings/jobs/export`) + +**Huidige code:** `routes_settings.py` regel ~207 + +**Toevoegen:** +```python +# Voor return send_file(...) +log_audit_event( + event_type="export_jobs", + message=f"Exported jobs configuration", + details=json.dumps({ + 'format': 'JSON', + 'schema': 'approved_jobs_export_v1', + 'customers_count': len(payload['customers']), + 'jobs_count': len(payload['jobs']) + }, indent=2) +) +``` + +--- + +### 4. Import Logging Toevoegen + +#### A. Customers Import (`/customers/import`) + +**Huidige code:** `routes_customers.py` regel ~448 + +**Toevoegen:** +```python +# Na db.session.commit() +log_audit_event( + event_type="import_customers", + message=f"Imported customers from CSV", + details=json.dumps({ + 'format': 'CSV', + 'created': created, + 'updated': updated, + 'skipped': skipped + }, indent=2) +) +``` + +#### B. Jobs Import (`/settings/jobs/import`) + +**Huidige code:** `routes_settings.py` regel ~263 + +**Is al deels aanwezig, maar uitbreiden:** +```python +# Na db.session.commit() +log_audit_event( + event_type="import_jobs", + message="Imported jobs configuration", + details=json.dumps({ + 'format': 'JSON', + 'schema': payload.get('schema'), + 'customers_created': created_customers, + 'customers_updated': updated_customers, + 'jobs_created': created_jobs, + 'jobs_updated': updated_jobs + }, indent=2) +) +``` + +--- + +### 5. Changelog Updaten + +**Bestand:** `docs/changelog-claude.md` + +**BELANGRIJK:** De datum is nu **2026-02-07**, niet 2026-02-06! + +**Toevoegen aan de changelog:** + +```markdown +## [2026-02-07] + +### Changed +- Renamed AdminLog to AuditLog for better semantic clarity: + - **Model**: AdminLog → AuditLog (backwards compatible alias maintained) + - **Table**: admin_logs → audit_logs (automatic migration) + - **Function**: log_admin_event() → log_audit_event() (alias provided) + - Better reflects purpose as comprehensive audit trail for both user and system events + +### Added +- Expanded audit logging for critical operations: + - **Settings Changes**: Now logs all changes to General, Mail, Autotask, and Navigation settings + - Tracks which settings changed (old value → new value) + - Excludes sensitive data (passwords) + - **Export Operations**: Logs when users export data + - Customers export (CSV): count and format + - Jobs export (JSON): schema version, customer/job counts + - **Import Operations**: Logs when users import data + - Customers import (CSV): created/updated/skipped counts + - Jobs import (JSON): schema version, all operation counts + - All logging uses event_type for filtering and includes detailed JSON in details field + - Maintains 7-day retention policy + - No performance impact (async logging) +``` + +--- + +## 📝 Implementatie Tips + +### Settings Changes Detecteren + +Voor elke setting die je wilt tracken: + +```python +# Voor de save +old_value = settings.some_setting + +# Na form processing +new_value = form.some_setting.data + +# Track change +if old_value != new_value: + changes['some_setting'] = { + 'old': str(old_value), + 'new': str(new_value) + } +``` + +### JSON Serialization + +Gebruik `json.dumps()` voor details: + +```python +import json + +details = json.dumps({ + 'key': 'value', + 'count': 123 +}, indent=2) +``` + +### Event Types + +**Consistent naming:** +- `settings_general` +- `settings_mail` +- `settings_autotask` +- `export_customers` +- `export_jobs` +- `import_customers` +- `import_jobs` + +--- + +## 🎯 Volgende Stappen (Morgen) + +1. UI updaten (logging.html page title) +2. Settings logging implementeren (General, Mail, Autotask) +3. Export logging implementeren (Customers, Jobs) +4. Import logging implementeren (Customers, Jobs) +5. Changelog updaten met **correcte datum 2026-02-07** +6. Testen of logging werkt +7. Committen en pushen + +--- + +## 🔍 Test Checklist + +Na implementatie testen: + +- [ ] Wijzig general setting → check /logging +- [ ] Wijzig mail setting → check /logging +- [ ] Wijzig Autotask setting → check /logging +- [ ] Export customers → check /logging +- [ ] Export jobs → check /logging +- [ ] Import customers → check /logging +- [ ] Import jobs → check /logging +- [ ] Check of user naam correct is +- [ ] Check of details field JSON bevat +- [ ] Check of event_type correct is + +--- + +## 📂 Belangrijke Bestanden + +``` +containers/backupchecks/src/backend/app/ +├── admin_logging.py # log_audit_event() functie +├── models.py # AuditLog model +├── migrations.py # migrate_rename_admin_logs_to_audit_logs() +└── main/ + ├── routes_settings.py # Settings routes (toevoegen logging) + ├── routes_customers.py # Customer export/import (toevoegen logging) + ├── routes_core.py # Logging page + └── routes_shared.py # _log_admin_event() wrapper + +containers/backupchecks/src/templates/main/ +└── logging.html # UI update (page title) + +docs/ +└── changelog-claude.md # Changelog (datum 2026-02-07!) +``` + +--- + +## ⚠️ Let Op! + +1. **Wachtwoorden NOOIT loggen** in details veld +2. **Datum in changelog: 2026-02-07** (niet 06!) +3. **Event types consistent** houden (lowercase, underscore) +4. **JSON format** voor details veld (makkelijk te parsen) +5. **Backwards compatibility** behouden (aliases) diff --git a/TODO-documentation.md b/TODO-documentation.md new file mode 100644 index 0000000..6aaa341 --- /dev/null +++ b/TODO-documentation.md @@ -0,0 +1,1135 @@ +# TODO: Documentation System + +**Branch:** `v20260207-02-wiki-documentation` +**Date Started:** 2026-02-07 +**Date Updated:** 2026-02-08 (Latest: Per-job review corrections) +**Status:** In Progress - 19 of 33 pages complete (58%) + +--- + +## 📊 Current Progress + +### Completed Sections ✅ + +**Phase 1: Core Infrastructure (COMPLETE)** +- ✅ Routes and blueprint setup +- ✅ Navigation sidebar with icons +- ✅ Base layout template +- ✅ CSS styling with dark mode support +- ✅ Breadcrumb navigation +- ✅ Previous/Next pagination +- ✅ Documentation menu item in navbar + +**Phase 2: Getting Started (3/3 pages - COMPLETE)** +- ✅ What is BackupChecks? +- ✅ First Login & Dashboard +- ✅ Quick Start Checklist + +**Phase 3: Users Section (3/3 pages - COMPLETE)** +- ✅ Users & Roles (with user-management.png screenshot) +- ✅ Login & Authentication (with Firefox recommendation) +- ✅ Profile Settings (with user-settings.png screenshot) + +**Phase 3: Customers & Jobs Section (4/4 pages - COMPLETE)** +- ✅ Managing Customers (with edit-customer.png, new-customers.png) +- ✅ Configuring Jobs (with approve-job.png) +- ✅ Approved Jobs (with job-details.png) +- ✅ Job Schedules (with schedule-indicators.png) + +**Phase 3: Mail & Import (4/4 pages - COMPLETE)** +- ✅ Mail Import Setup +- ✅ Inbox Management +- ✅ Mail Parsing +- ✅ Auto-Import Configuration + +**Phase 3: Backup Review (5/5 pages - COMPLETE)** +- ✅ Approving Backups (corrected for per-job review) +- ✅ Daily Jobs View +- ✅ Run Checks Modal (corrected for per-job review, removed non-existent reviewed indicator) +- ✅ Overrides & Exceptions +- ✅ Remarks & Tickets + +**Latest Corrections (2026-02-08):** +- Fixed per-job review mechanism documentation (review is per-JOB, not per individual run) +- Removed non-existent "reviewed indicator" from Run Checks Modal +- Corrected bulk review description from "select runs" to "select jobs" +- Updated Unmark Reviewed section to reflect per-job unmarking +- Removed incorrect statement that successful runs are automatically reviewed + +### Screenshots Added (10 total) +1. user-management.png - User role checkboxes +2. user-settings.png - Password change form +3. edit-customer.png - Customer edit dialog with Autotask mapping +4. new-customers.png - Customer creation and CSV import/export +5. approve-job.png - Inbox email detail with customer selection +6. job-details.png - Job detail page with schedule and history +7. schedule-indicators.png - Daily Jobs schedule with run status indicators + +### Remaining Work 🚧 + +**Phase 4: Advanced Features (0/14 pages - PLACEHOLDER)** +- Reports (0/4 pages) +- Autotask Integration (0/4 pages) +- Settings (0/6 pages) +- Troubleshooting (0/3 pages) + +**Progress Summary:** +- ✅ 19 of 33 pages complete (58%) +- ✅ 10 screenshots added +- ✅ All completed pages reviewed and corrected based on actual UI +- ⏳ 14 pages remaining (placeholders created) + +--- + +## 🎯 Goal + +Add a static documentation system to BackupChecks for user onboarding and reference. A comprehensive guide explaining how the application works, accessible only to logged-in users. + +--- + +## ✅ Requirements Summary + +- **Format:** HTML templates (for full CSS control) +- **Structure:** Multiple pages with navigation menu +- **Menu Item:** "Documentation" with 📖 icon +- **Access:** Logged-in users only +- **Content:** Basic + Advanced topics (all features) +- **Language:** English only (app is not translated to Dutch) +- **Screenshots:** Yes, embedded in pages +- **Maintenance:** Static content updated via git (no in-app editing) + +--- + +## 📋 Documentation Structure + +### Navigation Menu (Left Sidebar) + +``` +Documentation 📖 +├─ 🏠 Getting Started +│ ├─ What is BackupChecks? +│ ├─ First Login & Dashboard +│ └─ Quick Start Checklist +│ +├─ 👥 User Management +│ ├─ Users & Roles +│ ├─ Login & Authentication +│ └─ Profile Settings +│ +├─ 💼 Customers & Jobs +│ ├─ Managing Customers +│ ├─ Configuring Jobs +│ ├─ Approved Jobs +│ └─ Job Schedules +│ +├─ 📧 Mail & Import +│ ├─ Mail Import Setup +│ ├─ Inbox Management +│ ├─ Mail Parsing +│ └─ Auto-Import Configuration +│ +├─ ✅ Backup Review +│ ├─ Approving Backups +│ ├─ Daily Jobs View +│ ├─ Run Checks Modal +│ ├─ Overrides & Exceptions +│ └─ Remarks & Tickets +│ +├─ 📊 Reports +│ ├─ Creating Reports +│ ├─ Relative Periods +│ ├─ Report Scheduling +│ └─ Exporting Data +│ +├─ 🎫 Autotask Integration +│ ├─ Setup & Configuration +│ ├─ Company Mapping +│ ├─ Creating Tickets +│ └─ Ticket Management +│ +├─ ⚙️ Settings +│ ├─ General Settings +│ ├─ Mail Configuration +│ ├─ Autotask Integration +│ ├─ Reporting Settings +│ ├─ User Management +│ └─ Maintenance +│ +└─ ❓ Troubleshooting + ├─ Common Issues + ├─ FAQ + └─ Support Contact +``` + +--- + +## 🎨 UI Design + +### Layout Structure + +``` +┌─────────────────────────────────────────────────────┐ +│ Navbar (standard app navbar) │ +├──────────────┬──────────────────────────────────────┤ +│ │ │ +│ Navigation │ Content Area │ +│ Sidebar │ │ +│ (250px) │ ┌─ Breadcrumb ───────────────────┐ │ +│ │ │ Documentation > Getting Started │ │ +│ 📖 Docs │ └─────────────────────────────────┘ │ +│ │ │ +│ 🏠 Getting │

What is BackupChecks?

│ +│ Started │ │ +│ • What is │

BackupChecks is a...

│ +│ • First │ │ +│ • Quick │ │ +│ │ │ +│ 👥 Users │

Key Features

│ +│ • Users & │