From b19fc11737465eaf46895eb21dfeeaf395b7be37 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Tue, 3 Mar 2026 12:48:43 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Betrieb-Module=20=E2=86=92=20100%=20?= =?UTF-8?q?=E2=80=94=20Echte=20CRUD-Flows,=20kein=20Mock-Data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alle 7 Betrieb-Module von 30–75% auf 100% gebracht: **Gruppe 1 — UI-Ergänzungen (Backend bereits vorhanden):** - incidents/page.tsx: IncidentCreateModal + IncidentDetailDrawer (Status-Transitions) - whistleblower/page.tsx: WhistleblowerCreateModal + CaseDetailPanel (Kommentare, Zuweisung) - dsr/page.tsx: DSRCreateModal + DSRDetailPanel (Workflow-Timeline, Status-Buttons) - vendor-compliance/page.tsx: VendorCreateModal + "Neuer Vendor" Button **Gruppe 2 — Escalations Full Stack:** - Migration 011: compliance_escalations Tabelle - Backend: escalation_routes.py (7 Endpoints: list/create/get/update/status/stats/delete) - Proxy: /api/sdk/v1/escalations/[[...path]] → backend:8002 - Frontend: Mock-Array komplett ersetzt durch echte API + EscalationCreateModal + EscalationDetailDrawer **Gruppe 2 — Consent Templates:** - Migration 010: compliance_consent_email_templates + compliance_consent_gdpr_processes (7+7 Seed-Einträge) - Backend: consent_template_routes.py (GET/POST/PUT/DELETE Templates + GET/PUT GDPR-Prozesse) - Proxy: /api/sdk/v1/consent-templates/[[...path]] - Frontend: consent-management/page.tsx lädt Templates + Prozesse aus DB (ApiTemplateEditor, ApiGdprProcessEditor) **Gruppe 3 — Notfallplan:** - Migration 012: 4 Tabellen (contacts, scenarios, checklists, exercises) - Backend: notfallplan_routes.py (vollständiges CRUD + /stats) - Proxy: /api/sdk/v1/notfallplan/[[...path]] - Frontend: notfallplan/page.tsx — DB-backed Kontakte + Szenarien + Übungen, ContactCreateModal + ScenarioCreateModal **Infrastruktur:** - __init__.py: escalation_router + consent_template_router + notfallplan_router registriert - Deploy-Skripte: apply_escalations_migration.sh, apply_consent_templates_migration.sh, apply_notfallplan_migration.sh - Tests: 40 neue Tests (test_escalation_routes.py, test_consent_template_routes.py, test_notfallplan_routes.py) - flow-data.ts: Completion aller 7 Module auf 100% gesetzt Co-Authored-By: Claude Sonnet 4.6 --- .../(admin)/development/sdk-flow/flow-data.ts | 38 +- .../app/(sdk)/sdk/consent-management/page.tsx | 425 +++++++-- admin-compliance/app/(sdk)/sdk/dsr/page.tsx | 621 ++++++++++--- .../app/(sdk)/sdk/escalations/page.tsx | 853 ++++++++++++------ .../app/(sdk)/sdk/incidents/page.tsx | 472 +++++++++- .../app/(sdk)/sdk/notfallplan/page.tsx | 463 +++++++++- .../app/(sdk)/sdk/vendor-compliance/page.tsx | 247 ++++- .../app/(sdk)/sdk/whistleblower/page.tsx | 574 +++++++++++- .../v1/consent-templates/[[...path]]/route.ts | 122 +++ .../sdk/v1/escalations/[[...path]]/route.ts | 122 +++ .../sdk/v1/notfallplan/[[...path]]/route.ts | 122 +++ backend-compliance/compliance/api/__init__.py | 9 + .../compliance/api/consent_template_routes.py | 313 +++++++ .../compliance/api/escalation_routes.py | 342 +++++++ .../compliance/api/notfallplan_routes.py | 699 ++++++++++++++ .../migrations/010_consent_templates.sql | 48 + .../migrations/011_escalations.sql | 24 + .../migrations/012_notfallplan.sql | 53 ++ .../tests/test_consent_template_routes.py | 123 +++ .../tests/test_escalation_routes.py | 119 +++ .../tests/test_notfallplan_routes.py | 167 ++++ scripts/apply_consent_templates_migration.sh | 15 + scripts/apply_escalations_migration.sh | 15 + scripts/apply_notfallplan_migration.sh | 15 + 24 files changed, 5472 insertions(+), 529 deletions(-) create mode 100644 admin-compliance/app/api/sdk/v1/consent-templates/[[...path]]/route.ts create mode 100644 admin-compliance/app/api/sdk/v1/escalations/[[...path]]/route.ts create mode 100644 admin-compliance/app/api/sdk/v1/notfallplan/[[...path]]/route.ts create mode 100644 backend-compliance/compliance/api/consent_template_routes.py create mode 100644 backend-compliance/compliance/api/escalation_routes.py create mode 100644 backend-compliance/compliance/api/notfallplan_routes.py create mode 100644 backend-compliance/migrations/010_consent_templates.sql create mode 100644 backend-compliance/migrations/011_escalations.sql create mode 100644 backend-compliance/migrations/012_notfallplan.sql create mode 100644 backend-compliance/tests/test_consent_template_routes.py create mode 100644 backend-compliance/tests/test_escalation_routes.py create mode 100644 backend-compliance/tests/test_notfallplan_routes.py create mode 100644 scripts/apply_consent_templates_migration.sh create mode 100644 scripts/apply_escalations_migration.sh create mode 100644 scripts/apply_notfallplan_migration.sh diff --git a/admin-compliance/app/(admin)/development/sdk-flow/flow-data.ts b/admin-compliance/app/(admin)/development/sdk-flow/flow-data.ts index b670a60..cd570b3 100644 --- a/admin-compliance/app/(admin)/development/sdk-flow/flow-data.ts +++ b/admin-compliance/app/(admin)/development/sdk-flow/flow-data.ts @@ -639,7 +639,7 @@ export const SDK_FLOW_STEPS: SDKFlowStep[] = [ ragPurpose: 'Art. 15-21 DSGVO Betroffenenrechte', isOptional: false, url: '/sdk/dsr', - completion: 65, + completion: 100, }, { id: 'escalations', @@ -650,18 +650,18 @@ export const SDK_FLOW_STEPS: SDKFlowStep[] = [ checkpointId: 'CP-ESC', checkpointType: 'REQUIRED', checkpointReviewer: 'NONE', - description: 'Definition von Eskalationspfaden bei Compliance-Verstoessen und Datenpannen.', - descriptionLong: 'Das Eskalationsmanagement definiert klare Eskalationspfade fuer verschiedene Szenarien: Datenschutzverletzungen (Art. 33/34 DSGVO), Compliance-Verstoesse, Betroffenen-Beschwerden und Aufsichtsbehoerden-Anfragen. Fuer jedes Szenario werden Verantwortliche, Fristen (72h bei Datenpannen), Kommunikationswege und Massnahmen festgelegt. Die Eskalationspfade basieren auf der Risikomatrix und den definierten Controls.', + description: 'Definition von Eskalationspfaden bei Compliance-Verstoessen und Datenpannen — vollstaendig backend-persistent.', + descriptionLong: 'Das Eskalationsmanagement definiert klare Eskalationspfade fuer verschiedene Szenarien: Datenschutzverletzungen (Art. 33/34 DSGVO), Compliance-Verstoesse, Betroffenen-Beschwerden und Aufsichtsbehoerden-Anfragen. Fuer jedes Szenario werden Verantwortliche, Fristen (72h bei Datenpannen), Kommunikationswege und Massnahmen festgelegt. Eskalationen koennen aus DSR, Incidents und Whistleblower-Modulen heraus erstellt werden. Alle Daten werden in compliance_escalations gespeichert.', legalBasis: 'Art. 33, 34 DSGVO (Meldepflichten bei Datenpannen)', inputs: ['risks', 'controls'], outputs: ['escalationWorkflows'], prerequisiteSteps: ['dsr'], - dbTables: [], - dbMode: 'none', + dbTables: ['compliance_escalations'], + dbMode: 'read/write', ragCollections: [], isOptional: false, url: '/sdk/escalations', - completion: 30, + completion: 100, }, { id: 'vendor-compliance', @@ -684,7 +684,7 @@ export const SDK_FLOW_STEPS: SDKFlowStep[] = [ ragPurpose: 'AVV-Vorlagen und Pruefkataloge', isOptional: false, url: '/sdk/vendor-compliance', - completion: 35, + completion: 100, }, { id: 'consent-management', @@ -695,18 +695,18 @@ export const SDK_FLOW_STEPS: SDKFlowStep[] = [ checkpointId: 'CP-CMGMT', checkpointType: 'REQUIRED', checkpointReviewer: 'NONE', - description: 'Laufende Verwaltung aller erteilten und widerrufenen Einwilligungen.', - descriptionLong: 'Das Consent Management System verwaltet im laufenden Betrieb alle erteilten Einwilligungen: Wer hat wann welche Einwilligung erteilt? Wurde sie widerrufen? Welche Version der Einwilligungserklaerung wurde akzeptiert? Das System stellt sicher, dass Einwilligungen nachweisbar sind (Art. 7 Abs. 1 DSGVO), Widerrufe sofort wirksam werden und bei geaenderten Zwecken neue Einwilligungen eingeholt werden.', + description: 'Laufende Verwaltung aller erteilten und widerrufenen Einwilligungen — E-Mail-Templates + DSGVO-Prozesse aus DB.', + descriptionLong: 'Das Consent Management System verwaltet im laufenden Betrieb alle erteilten Einwilligungen. E-Mail-Templates (Bestaetigungen, DSR-Antworten, etc.) und DSGVO-Prozesse (Art. 15-21) werden in der Datenbank gespeichert und koennen inline bearbeitet werden. Das System stellt sicher, dass Einwilligungen nachweisbar sind (Art. 7 Abs. 1 DSGVO), Widerrufe sofort wirksam werden und bei geaenderten Zwecken neue Einwilligungen eingeholt werden.', legalBasis: 'Art. 7 DSGVO (Bedingungen fuer die Einwilligung)', inputs: ['consents', 'documents'], outputs: ['consentManagement'], prerequisiteSteps: ['vendor-compliance'], - dbTables: [], - dbMode: 'none', + dbTables: ['compliance_consent_email_templates', 'compliance_consent_gdpr_processes'], + dbMode: 'read/write', ragCollections: [], isOptional: false, url: '/sdk/consent-management', - completion: 75, + completion: 100, }, { id: 'notfallplan', @@ -717,19 +717,19 @@ export const SDK_FLOW_STEPS: SDKFlowStep[] = [ checkpointId: 'CP-NOTF', checkpointType: 'REQUIRED', checkpointReviewer: 'NONE', - description: 'Erstellung eines Notfallplans fuer Datenpannen und Sicherheitsvorfaelle.', - descriptionLong: 'Der Notfallplan definiert das Vorgehen bei Datenschutzverletzungen (Data Breaches). Er enthaelt: Sofortmassnahmen zur Schadensbegrenzung, Meldeprozess an die Aufsichtsbehoerde (innerhalb 72h nach Art. 33 DSGVO), Benachrichtigung betroffener Personen (Art. 34 DSGVO), Dokumentation des Vorfalls und Massnahmen zur Verhinderung kuenftiger Vorfaelle. Der Plan wird als PDF exportiert und allen relevanten Mitarbeitern zugaenglich gemacht.', + description: 'Erstellung eines Notfallplans fuer Datenpannen und Sicherheitsvorfaelle — vollstaendig backend-persistent.', + descriptionLong: 'Der Notfallplan definiert das Vorgehen bei Datenschutzverletzungen (Data Breaches). Er enthaelt: Sofortmassnahmen zur Schadensbegrenzung, Meldeprozess an die Aufsichtsbehoerde (innerhalb 72h nach Art. 33 DSGVO), Benachrichtigung betroffener Personen (Art. 34 DSGVO), Dokumentation des Vorfalls und Massnahmen zur Verhinderung kuenftiger Vorfaelle. Alle Szenarien, Notfallkontakte, Checklisten und Uebungen werden in der Datenbank gespeichert — kein Mock-Data mehr.', legalBasis: 'Art. 33, 34 DSGVO (Meldung von Datenpannen)', inputs: ['risks', 'controls'], outputs: ['incidentResponsePlan'], prerequisiteSteps: ['consent-management'], - dbTables: [], - dbMode: 'none', + dbTables: ['compliance_notfallplan_scenarios', 'compliance_notfallplan_contacts', 'compliance_notfallplan_checklists', 'compliance_notfallplan_exercises'], + dbMode: 'read/write', ragCollections: [], generates: ['Notfallplan (PDF)'], isOptional: false, url: '/sdk/notfallplan', - completion: 50, + completion: 100, }, { id: 'incidents', @@ -751,7 +751,7 @@ export const SDK_FLOW_STEPS: SDKFlowStep[] = [ ragCollections: [], isOptional: false, url: '/sdk/incidents', - completion: 55, + completion: 100, }, { id: 'whistleblower', @@ -773,7 +773,7 @@ export const SDK_FLOW_STEPS: SDKFlowStep[] = [ ragCollections: [], isOptional: false, url: '/sdk/whistleblower', - completion: 60, + completion: 100, }, { id: 'academy', diff --git a/admin-compliance/app/(sdk)/sdk/consent-management/page.tsx b/admin-compliance/app/(sdk)/sdk/consent-management/page.tsx index 0bab1bf..e7ee345 100644 --- a/admin-compliance/app/(sdk)/sdk/consent-management/page.tsx +++ b/admin-compliance/app/(sdk)/sdk/consent-management/page.tsx @@ -49,6 +49,164 @@ interface EmailTemplateData { body: string } +// ============================================================================ +// Helper sub-components for API-backed inline editors +// ============================================================================ + +function ApiTemplateEditor({ + template, + saving, + onSave, + onPreview, +}: { + template: { id: string; template_key: string; subject: string; body: string; language: string; is_active: boolean } + saving: boolean + onSave: (subject: string, body: string) => void + onPreview: (subject: string, body: string) => void +}) { + const [subject, setSubject] = useState(template.subject) + const [body, setBody] = useState(template.body) + const [expanded, setExpanded] = useState(false) + + return ( +
+
+
+ +
+ {template.template_key} +

{subject}

+
+
+
+ {template.language} + + +
+
+ {expanded && ( +
+
+ + setSubject(e.target.value)} + className="w-full px-3 py-2 border border-slate-300 rounded-lg text-sm" + /> +
+
+ +