# S3-to-Local Sync Dashboard - Multi-Sync Support ## πŸŽ‰ Nuove FunzionalitΓ  (18 Marzo 2026) ### 1. **Non invia le notifiche Gotify** βœ… RISOLTO - **Problema**: La funzione `gotify_send()` aveva un'escaping JSON incorretto - **Soluzione**: - Aggiunto `jq` al Dockerfile per proper JSON encoding - Riscritto `gotify_send()` in `sync.sh` con corretto escaping dei caratteri speciali - Aggiunta proper gestione degli errori con fallback a sed ### 2. **Multiple Associazioni Sync (1:1 Bucket:Cartella)** βœ… IMPLEMENTATO - Ora supporta **multiple sync simultanee** - Ogni sync ha: - Identificatore univoco (`sync1`, `sync2`, etc.) - Bucket S3 dedicato - Cartella locale dedicata - Directory di stato separata (`/data/state/sync1`, `/data/state/sync2`) **Configurazione in `.env`:** ```bash SYNC_CONFIGS='[ {"id": "sync1", "bucket": "backup-docs", "path": "/data/local1", "interval": 300}, {"id": "sync2", "bucket": "media-files", "path": "/data/local2", "interval": 600} ]' ``` ### 3. **Interfaccia Dashboard Ridisegnata** βœ… IMPLEMENTATO #### Tab Selector Dinamici - Mostra un tab per ogni sync configurata - Click per switchare tra sync - Visualizza log e modifiche della sync selezionata #### Grafica Responsiva e Dinamica - **CSS Flexbox + Grid**: si adatta perfettamente al ridimensionamento della finestra - **Breakpoint Mobile**: su schermi < 1200px, log e modifiche si impilano verticalmente - **Performance**: auto-scroll, limite di 500 righe log, lazy loading #### Organizzazione Pannelli **PRIMA:** ``` Stats Cards (4) ↓ Config ↓ Log Panel (sx) | Modifiche Recenti (dx) ↓ Storico ``` **ADESSO:** ``` Stats Cards (4) ↓ Config ↓ [TAB SELECTOR] sync1 | sync2 | sync3 ↓ Log (sopra) | Modifiche Recenti (destra) ↓ Storico ``` ### 4. **Visualizzazione Per-Sync** βœ… IMPLEMENTATO Ogni sync mostra i suoi dati indipendenti: - Status badge (Avvio, Sincronizzazione, Sincronizzato, Errore) - Statistiche cartella locale - Log in tempo reale (SSE stream dedicato) - Modifiche recenti - Storico sincronizzazioni --- ## πŸš€ Come Usare ### ModalitΓ  Singola (Default - Compatibile) ```bash # Nel .env, configure il bucket singolo S3_BUCKET=my-bucket # NON mettere SYNC_CONFIGS # Avvio docker-compose up -d # La dashboard mostra una singola sync (nessun tab) ``` ### ModalitΓ  Multi-Sync ```bash # Nel .env: SYNC_CONFIGS='[ {"id": "sync1", "bucket": "bucket-a"}, {"id": "sync2", "bucket": "bucket-b"}, {"id": "sync3", "bucket": "bucket-c"} ]' # Nel docker-compose.yml, aggiungi i volumi per ogni sync: volumes: - ./data/sync1:/data/local - ./data/sync2:/data/local2 - ./data/sync3:/data/local3 - sync-state:/data/state ``` Poi: ```bash docker-compose up -d ``` La dashboard automaticamente: 1. Mostra tab per ogni sync 2. Lancia multiple istanze di `sync.sh` (una per bucket) 3. Visualizza log + modifiche per sync selezionata --- ## πŸ“Š Struttura Nuova ### API Endpoints | Endpoint | Descrizione | |----------|-------------| | `/api/syncs` | Lista di tutte le sync configurate | | `/api/status/` | Stato di una specifica sync | | `/api/stream/` | SSE stream log in tempo reale | | `/api/changes/` | Modifiche recenti per una sync | | `/api/history/` | Storico sincronizzazioni | ### Directory di Stato ``` /data/state/ β”œβ”€β”€ sync1/ β”‚ β”œβ”€β”€ sync.log β”‚ β”œβ”€β”€ status.json β”‚ β”œβ”€β”€ history.json β”‚ └── recent_changes.json β”œβ”€β”€ sync2/ β”‚ β”œβ”€β”€ sync.log β”‚ β”œβ”€β”€ status.json β”‚ β”œβ”€β”€ history.json β”‚ └── recent_changes.json └── ... ``` --- ## πŸ”§ Note Tecniche ### entrypoint.sh - **Singola sync**: Avvia 1 istanza di `sync.sh` (come prima) - **Multi-sync**: Parsa JSON di `SYNC_CONFIGS`, crea directory di stato, lancia N istanze di `sync.sh` con `STATE_DIR` diversi ### sync.sh - Accetta `STATE_DIR` come variabile d'ambiente - Scrive log/status/modifiche nella directory assegnata - `gotify_send()` ora ha proper JSON escaping ### app.py - Carica configurazione da `SYNC_CONFIGS` - Fallback a singola sync se `SYNC_CONFIGS` non Γ¨ definito - Routes parametriche con `` ### index.html - CSS Grid + Flexbox per responsive design - `switchSync(id)` per cambiare tab - Mantiene stato separato per ogni sync - Auto-update ogni 5-10-15s --- ## βœ… Checklist Implementazione - [x] Notifiche Gotify - Fixed JSON escaping + jq - [x] Multiple sync - Parsing SYNC_CONFIGS + multiple STATE_DIR - [x] UI multi-tab - Switch dinamico tra sync - [x] CSS responsivo - Flexbox/Grid con breakpoints - [x] Log/Modifiche orizzontali - Layout a due colonne - [x] Per-sync data - API routes con sync_id - [x] Docker multi-sync - entrypoint con Python JSON parser - [x] CompatibilitΓ  backward - Fallback a singola sync --- ## πŸ› Bug Risolti 1. **Notifiche Gotify non inviate** - Causa: Escaping JSON non corretto in `printf` - Fix: Uso di `jq` con proper escaping 2. **Grafica non responsiva** - Causa: CSS max-width fisso, layout non flexible - Fix: CSS Grid/Flexbox con responsive breakpoints --- ## πŸ“ Prossimi Miglioramenti Suggeriti - [ ] API per aggiungere/rimuovere sync dinamicamente - [ ] Statistiche aggregate di tutte le sync - [ ] Throttling bandwidth globale (non per-sync) - [ ] Health check per ogni sync - [ ] Export dati sincronizzazioni in CSV - [ ] Webhooks per sync completate --- **Version**: 2.0.0 (Multi-Sync) **Last Updated**: 18 Marzo 2026