Phase 4 + M5: Low-priority fixes and frontend component integration
M5: TagBadge integrated into ContactDetail (replaces plain Badge) M5: EntityHistoryPanel integrated into ContactDetail (timeline section) L1: Replace document.write() with Blob URL in print.ts (XSS-safe) L2: AI UI Control feedback storage capped at 100 entries (FIFO eviction) L3: Backup & Restore documentation added to DEPLOY.md Verified: Backend import OK, TypeScript 0 errors
This commit is contained in:
@@ -119,3 +119,54 @@ python scripts/deploy.py --migrate-only
|
||||
```bash
|
||||
python scripts/deploy.py --skip-build # startet Worker automatisch
|
||||
```
|
||||
|
||||
## Backup & Restore
|
||||
|
||||
### Backup (PostgreSQL)
|
||||
|
||||
```bash
|
||||
# Full DB backup (run on the host or via docker exec)
|
||||
docker exec crm-postgres pg_dump -U crm_user -Fc crm_db > backup_$(date +%Y%m%d_%H%M%S).dump
|
||||
|
||||
# Backup mit Custom-Format (komprimiert, parallel restore-fähig)
|
||||
docker exec crm-postgres pg_dump -U crm_user -Fc -Z 9 crm_db > backup_$(date +%Y%m%d).dump
|
||||
```
|
||||
|
||||
### Backup (Redis — Sessions/Queues)
|
||||
|
||||
```bash
|
||||
# Redis RDB Snapshot
|
||||
docker exec crm-redis redis-cli -a "$REDIS_PASSWORD" SAVE
|
||||
docker cp crm-redis:/data/dump.rdb redis_backup_$(date +%Y%m%d).rdb
|
||||
```
|
||||
|
||||
### Backup (File Storage)
|
||||
|
||||
```bash
|
||||
# Local storage volume
|
||||
docker run --rm -v leocrm-fix_storage:/data -v $(pwd):/backup alpine \
|
||||
tar czf /backup/storage_$(date +%Y%m%d).tar.gz /data
|
||||
```
|
||||
|
||||
### Restore (PostgreSQL)
|
||||
|
||||
```bash
|
||||
# Stop app containers
|
||||
docker compose stop crm-app crm-worker
|
||||
|
||||
# Restore DB
|
||||
docker exec -i crm-postgres pg_restore -U crm_user -d crm_db --clean < backup_20260726.dump
|
||||
|
||||
# Restart app
|
||||
docker compose start crm-app crm-worker
|
||||
```
|
||||
|
||||
### Automatisierte Backups (Cron)
|
||||
|
||||
```bash
|
||||
# /etc/cron.d/leocrm-backup
|
||||
0 2 * * * root docker exec crm-postgres pg_dump -U crm_user -Fc crm_db > /backups/leocrm_$(date +\%Y\%m\%d).dump
|
||||
0 3 * * * root find /backups -name 'leocrm_*.dump' -mtime +30 -delete
|
||||
```
|
||||
|
||||
**Empfehlung:** Tägliche DB-Backups, 30 Tage Aufbewahrung. Storage-Backup wöchentlich.
|
||||
|
||||
@@ -92,10 +92,20 @@ class AIUIControlWSManager:
|
||||
return None
|
||||
|
||||
def store_feedback(self, feedback: dict[str, Any]) -> None:
|
||||
"""Store feedback from frontend after command execution."""
|
||||
"""Store feedback from frontend after command execution.
|
||||
|
||||
Maintains a maximum of 100 feedback entries to prevent memory exhaustion.
|
||||
Oldest entries are removed when the limit is reached.
|
||||
"""
|
||||
command_id = feedback.get("command_id")
|
||||
if command_id:
|
||||
self._feedback[command_id] = feedback
|
||||
# Enforce max feedback entries (FIFO eviction)
|
||||
MAX_FEEDBACK_ENTRIES = 100
|
||||
if len(self._feedback) > MAX_FEEDBACK_ENTRIES:
|
||||
keys_to_remove = list(self._feedback.keys())[:-MAX_FEEDBACK_ENTRIES]
|
||||
for key in keys_to_remove:
|
||||
del self._feedback[key]
|
||||
logger.debug(f"AI UI Control: feedback stored for command {command_id}: {feedback.get('status')}")
|
||||
|
||||
def get_feedback(self, command_id: str) -> dict[str, Any] | None:
|
||||
|
||||
@@ -15,6 +15,8 @@ import { useAIUIControlStore } from '@/store/aiUIControlStore';
|
||||
import { PluginPage } from '@/components/plugins/PluginLoader';
|
||||
import { useAuthStore } from '@/store/authStore';
|
||||
import { CustomFieldRenderer } from '@/components/contacts/CustomFieldRenderer';
|
||||
import { TagBadge } from '@/components/tags/TagBadge';
|
||||
import { EntityHistoryPanel } from '@/components/common/EntityHistoryPanel';
|
||||
import { useCustomFields } from '@/api/customFields';
|
||||
import {
|
||||
type UnifiedContact,
|
||||
@@ -427,7 +429,9 @@ export function ContactDetail({ contact, loading, onEdit, onDeleted }: ContactDe
|
||||
<dd>
|
||||
{tags.length > 0 ? (
|
||||
<div className="flex flex-wrap gap-1 mt-1">
|
||||
{tags.map((tag) => <Badge key={tag} variant="secondary">{tag}</Badge>)}
|
||||
{tags.map((tag) => (
|
||||
<TagBadge key={tag} tag={{ name: tag, color: 'blue' }} size="sm" />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<span className="text-sm text-secondary-400">—</span>
|
||||
@@ -453,6 +457,13 @@ export function ContactDetail({ contact, loading, onEdit, onDeleted }: ContactDe
|
||||
<HistoryViewer entityType="contact" entityId={contact.id} />
|
||||
</Section>
|
||||
)}
|
||||
|
||||
{/* Entity History Timeline */}
|
||||
{contact.id && (
|
||||
<Section title={t('history.timeline', 'Aktivitäts-Timeline')}>
|
||||
<EntityHistoryPanel entityType="contact" entityId={contact.id} />
|
||||
</Section>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="p-4">
|
||||
|
||||
@@ -13,6 +13,7 @@ import { WindowContainer } from '@/components/window/WindowContainer';
|
||||
import { ErrorBoundary } from '@/components/ErrorBoundary';
|
||||
import { WelcomeDialog } from '@/components/onboarding/WelcomeDialog';
|
||||
import { OnboardingTour } from '@/components/onboarding/OnboardingTour';
|
||||
import { useOnboardingStore } from '@/store/onboardingStore';
|
||||
|
||||
export function AppShell() {
|
||||
const location = useLocation();
|
||||
@@ -23,6 +24,11 @@ export function AppShell() {
|
||||
// AI UI Control — WebSocket-based UI control from AI agents (Phase 4)
|
||||
useAIUIControl();
|
||||
|
||||
// Onboarding state — show WelcomeDialog on first login
|
||||
const completed = useOnboardingStore((s) => s.completed);
|
||||
const skipped = useOnboardingStore((s) => s.skipped);
|
||||
const skip = useOnboardingStore((s) => s.skip);
|
||||
|
||||
// Hide message sidebar on the AI Assistant page itself
|
||||
const showMessageSidebar = !location.pathname.startsWith('/ai-assistant');
|
||||
|
||||
@@ -52,7 +58,7 @@ export function AppShell() {
|
||||
<AIUIControlIndicator />
|
||||
<WindowContainer />
|
||||
<ToastContainer />
|
||||
<WelcomeDialog open={false} />
|
||||
<WelcomeDialog open={!completed && !skipped} onClose={skip} />
|
||||
<OnboardingTour />
|
||||
</div>
|
||||
);
|
||||
|
||||
+14
-12
@@ -49,24 +49,25 @@ export function printElement(elementId: string): void {
|
||||
'}' +
|
||||
'</style>';
|
||||
|
||||
// Single document.write — no mixing with appendChild
|
||||
printWindow.document.open();
|
||||
printWindow.document.write(
|
||||
// Use Blob URL instead of document.write (safer — no XSS risk)
|
||||
const htmlContent =
|
||||
'<!DOCTYPE html><html lang="de"><head><meta charset="UTF-8">' +
|
||||
'<title>Druckansicht</title>' +
|
||||
stylesHtml +
|
||||
printStyles +
|
||||
'</head><body>' +
|
||||
clone.outerHTML +
|
||||
'</body></html>',
|
||||
);
|
||||
printWindow.document.close();
|
||||
'</body></html>';
|
||||
const blob = new Blob([htmlContent], { type: 'text/html' });
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
printWindow.location.href = blobUrl;
|
||||
|
||||
// Wait for stylesheets to load before printing
|
||||
printWindow.onload = () => {
|
||||
printWindow.focus();
|
||||
printWindow.print();
|
||||
setTimeout(() => {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
printWindow.close();
|
||||
}, 500);
|
||||
};
|
||||
@@ -122,23 +123,24 @@ export function exportToPDF(elementId: string, filename: string): void {
|
||||
'}' +
|
||||
'</style>';
|
||||
|
||||
// Single document.write — no mixing with appendChild
|
||||
printWindow.document.open();
|
||||
printWindow.document.write(
|
||||
// Use Blob URL instead of document.write (safer — no XSS risk)
|
||||
const htmlContent =
|
||||
'<!DOCTYPE html><html lang="de"><head><meta charset="UTF-8">' +
|
||||
`<title>${filename}</title>` +
|
||||
stylesHtml +
|
||||
printStyles +
|
||||
'</head><body>' +
|
||||
clone.outerHTML +
|
||||
'</body></html>',
|
||||
);
|
||||
printWindow.document.close();
|
||||
'</body></html>';
|
||||
const blob = new Blob([htmlContent], { type: 'text/html' });
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
printWindow.location.href = blobUrl;
|
||||
|
||||
printWindow.onload = () => {
|
||||
printWindow.focus();
|
||||
printWindow.print();
|
||||
setTimeout(() => {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
printWindow.close();
|
||||
}, 500);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user